[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-24 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D45619#1075677, @bjope wrote:

> buildbots have been failing all day (and were still failing). So I pushed my 
> suggested fix.
>  I hope that was OK.


Thank you. It seems everything is OK now.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


r330689 - [AST] Use a bit of trickery to make test pass on platforms where wchar_t is unsigned.

2018-04-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Apr 24 00:53:10 2018
New Revision: 330689

URL: http://llvm.org/viewvc/llvm-project?rev=330689&view=rev
Log:
[AST] Use a bit of trickery to make test pass on platforms where wchar_t is 
unsigned.

Modified:
cfe/trunk/test/SemaCXX/constexpr-string.cpp

Modified: cfe/trunk/test/SemaCXX/constexpr-string.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-string.cpp?rev=330689&r1=330688&r2=330689&view=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-string.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-string.cpp Tue Apr 24 00:53:10 2018
@@ -107,7 +107,7 @@ namespace WcscmpEtc {
   static_assert(__builtin_wcscmp(L"abab", L"abab\0banana") == 0);
   static_assert(__builtin_wcscmp(L"abab\0banana", L"abab\0canada") == 0);
 #if __WCHAR_WIDTH__ == 32
-  static_assert(__builtin_wcscmp(L"a\x83838383", L"a") == -1);
+  static_assert(__builtin_wcscmp(L"a\x83838383", L"a") == wchar_t(-1U) >> 31);
 #endif
   static_assert(__builtin_wcscmp(0, L"abab") == 0); // expected-error {{not an 
integral constant}} expected-note {{dereferenced null}}
   static_assert(__builtin_wcscmp(L"abab", 0) == 0); // expected-error {{not an 
integral constant}} expected-note {{dereferenced null}}
@@ -124,7 +124,8 @@ namespace WcscmpEtc {
   static_assert(__builtin_wcsncmp(0, 0, 0) == 0);
   static_assert(__builtin_wcsncmp(L"abab\0banana", L"abab\0canada", 100) == 0);
 #if __WCHAR_WIDTH__ == 32
-  static_assert(__builtin_wcsncmp(L"a\x83838383", L"aa", 2) == -1);
+  static_assert(__builtin_wcsncmp(L"a\x83838383", L"aa", 2) ==
+wchar_t(-1U) >> 31);
 #endif
 
   static_assert(__builtin_wcsncmp(kFoobar, kFoobazfoobar, 6) == -1);
@@ -136,7 +137,8 @@ namespace WcscmpEtc {
   static_assert(__builtin_wmemcmp(L"abaa", L"abba", 2) == 0);
   static_assert(__builtin_wmemcmp(0, 0, 0) == 0);
 #if __WCHAR_WIDTH__ == 32
-  static_assert(__builtin_wmemcmp(L"a\x83838383", L"aa", 2) == -1);
+  static_assert(__builtin_wmemcmp(L"a\x83838383", L"aa", 2) ==
+wchar_t(-1U) >> 31);
 #endif
   static_assert(__builtin_wmemcmp(L"abab\0banana", L"abab\0banana", 100) == 
0); // expected-error {{not an integral constant}} expected-note {{dereferenced 
one-past-the-end}}
   static_assert(__builtin_wmemcmp(L"abab\0banana", L"abab\0canada", 100) == 
-1); // FIXME: Should we reject this?


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


[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.

2018-04-24 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan updated this revision to Diff 143684.
ebevhan added a comment.

Removed local variable and added some more to the test.


https://reviews.llvm.org/D45865

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/array-bounds.cpp
  test/SemaCXX/constant-expression-cxx11.cpp


Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -528,15 +528,18 @@
 constexpr int xs0 = p[-3]; // ok
 constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} 
expected-note {{cannot refer to element -1}}
 
-constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
14, 15, 16 };
+constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
14, 15, 16 }; // expected-note {{array 'zs' declared here}}
 static_assert(zs[0][0][0][0] == 1, "");
 static_assert(zs[1][1][1][1] == 16, "");
 static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant 
expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
 static_assert((&zs[0][0][0][2])[-1] == 2, "");
 static_assert(**(**(zs + 1) + 1) == 11, "");
 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); 
// expected-error {{constant expression}} expected-note {{cannot refer to 
element -1 of array of 2 elements in a constant expression}}
 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
-constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // expected-error {{constant 
expression}} expected-note {{cannot access array element of pointer past the 
end}}
+constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // \
+expected-error {{constant expression}} \
+expected-note {{cannot access array element of pointer past the end}} \
+expected-warning {{array index 2 is past the end of the array (which contains 
2 elements)}}
 
 constexpr int fail(const int &p) {
   return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 
elements}}
Index: test/SemaCXX/array-bounds.cpp
===
--- test/SemaCXX/array-bounds.cpp
+++ test/SemaCXX/array-bounds.cpp
@@ -269,3 +269,18 @@
   struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
   return x[1] + x[11]; // expected-warning {{array index 11 is past the end of 
the array (which contains 10 elements)}}
 }
+
+int multi[2][2][2]; // expected-note 3 {{array 'multi' declared here}}
+int test_multiarray() {
+  return multi[2][0][0] + // expected-warning {{array index 2 is past the end 
of the array (which contains 2 elements)}}
+ multi[0][2][0] + // expected-warning {{array index 2 is past the end 
of the array (which contains 2 elements)}}
+ multi[0][0][2];  // expected-warning {{array index 2 is past the end 
of the array (which contains 2 elements)}}
+}
+
+struct multi_s {
+  int arr[4];
+};
+struct multi_s multi2[4]; // expected-note {{array 'multi2' declared here}}
+int test_struct_multiarray() {
+  return multi2[4].arr[0]; // expected-warning {{array index 4 is past the end 
of the array (which contains 4 elements)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11277,7 +11277,12 @@
 const ArraySubscriptExpr *ASE = cast(expr);
 CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE,
  AllowOnePastEnd > 0);
-return;
+expr = ASE->getBase();
+break;
+  }
+  case Stmt::MemberExprClass: {
+expr = cast(expr)->getBase();
+break;
   }
   case Stmt::OMPArraySectionExprClass: {
 const OMPArraySectionExpr *ASE = cast(expr);


Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -528,15 +528,18 @@
 constexpr int xs0 = p[-3]; // ok
 constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
 
-constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; // expected-note {{array 'zs' declared here}}
 static_assert(zs[0][0][0][0] == 1, "");
 static_assert(zs[1][1][1][1] == 16, "");
 static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
 static_assert((&zs[0][0][0][2])[-1] == 2, "");
 static_assert(**(**(zs + 1) + 1) == 11, "");
 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}}
 static_assert(*

r330690 - [AST] Another attempt at fixing the ARM bots.

2018-04-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Apr 24 01:18:32 2018
New Revision: 330690

URL: http://llvm.org/viewvc/llvm-project?rev=330690&view=rev
Log:
[AST] Another attempt at fixing the ARM bots.

Modified:
cfe/trunk/test/SemaCXX/constexpr-string.cpp

Modified: cfe/trunk/test/SemaCXX/constexpr-string.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-string.cpp?rev=330690&r1=330689&r2=330690&view=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-string.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-string.cpp Tue Apr 24 01:18:32 2018
@@ -107,7 +107,7 @@ namespace WcscmpEtc {
   static_assert(__builtin_wcscmp(L"abab", L"abab\0banana") == 0);
   static_assert(__builtin_wcscmp(L"abab\0banana", L"abab\0canada") == 0);
 #if __WCHAR_WIDTH__ == 32
-  static_assert(__builtin_wcscmp(L"a\x83838383", L"a") == wchar_t(-1U) >> 31);
+  static_assert(__builtin_wcscmp(L"a\x83838383", L"a") == (wchar_t)-1U >> 31);
 #endif
   static_assert(__builtin_wcscmp(0, L"abab") == 0); // expected-error {{not an 
integral constant}} expected-note {{dereferenced null}}
   static_assert(__builtin_wcscmp(L"abab", 0) == 0); // expected-error {{not an 
integral constant}} expected-note {{dereferenced null}}
@@ -125,7 +125,7 @@ namespace WcscmpEtc {
   static_assert(__builtin_wcsncmp(L"abab\0banana", L"abab\0canada", 100) == 0);
 #if __WCHAR_WIDTH__ == 32
   static_assert(__builtin_wcsncmp(L"a\x83838383", L"aa", 2) ==
-wchar_t(-1U) >> 31);
+(wchar_t)-1U >> 31);
 #endif
 
   static_assert(__builtin_wcsncmp(kFoobar, kFoobazfoobar, 6) == -1);
@@ -138,7 +138,7 @@ namespace WcscmpEtc {
   static_assert(__builtin_wmemcmp(0, 0, 0) == 0);
 #if __WCHAR_WIDTH__ == 32
   static_assert(__builtin_wmemcmp(L"a\x83838383", L"aa", 2) ==
-wchar_t(-1U) >> 31);
+(wchar_t)-1U >> 31);
 #endif
   static_assert(__builtin_wmemcmp(L"abab\0banana", L"abab\0banana", 100) == 
0); // expected-error {{not an integral constant}} expected-note {{dereferenced 
one-past-the-end}}
   static_assert(__builtin_wmemcmp(L"abab\0banana", L"abab\0canada", 100) == 
-1); // FIXME: Should we reject this?


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


[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".

2018-04-24 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Artem. Cool patch!

Maybe we should create an analyzer option for this? So, all users who want 
webkit-like behaviour will just enable (or disable, don't know what's better) 
the option and get the feature. I know that introducing a new option is 
undesirable but it seems to be a good compromise here.


https://reviews.llvm.org/D45839



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


[PATCH] D41241: [Solaris] Only define _REENTRANT if -pthread

2018-04-24 Thread Rainer Orth via Phabricator via cfe-commits
ro added a reviewer: fedor.sergeev.
ro added a comment.

ping^5


Repository:
  rC Clang

https://reviews.llvm.org/D41241



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


r330692 - [libclang] Only mark CXCursors for explicit attributes with a type

2018-04-24 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Tue Apr 24 01:39:46 2018
New Revision: 330692

URL: http://llvm.org/viewvc/llvm-project?rev=330692&view=rev
Log:
[libclang] Only mark CXCursors for explicit attributes with a type

All attributes have a source range associated with it. However, implicit
attributes are added by the compiler, and not added because the user
wrote something in the input. So no token type should be set to
CXCursor_*Attr.

The problem was visible when a class gets marked by e.g.
MSInheritanceAttr, which has the full CXXRecordDecl's range as its
own range. The effect of marking that range as CXCursor_UnexposedAttr
was that all cursors for the record decl, including all child decls,
would become CXCursor_UnexposedAttr.

Added:
cfe/trunk/test/Index/annotate-tokens-unexposed.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Added: cfe/trunk/test/Index/annotate-tokens-unexposed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens-unexposed.cpp?rev=330692&view=auto
==
--- cfe/trunk/test/Index/annotate-tokens-unexposed.cpp (added)
+++ cfe/trunk/test/Index/annotate-tokens-unexposed.cpp Tue Apr 24 01:39:46 2018
@@ -0,0 +1,20 @@
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:16:1 %s -target 
x86_64-pc-windows-msvc | FileCheck %s
+class Foo
+{
+public:
+void step(int v);
+Foo();
+};
+
+void bar()
+{
+// Introduce a MSInheritanceAttr node on the CXXRecordDecl for Foo. The
+// existance of this attribute should not mark all cursors for tokens in
+// Foo as UnexposedAttr.
+&Foo::step;
+}
+
+Foo::Foo()
+{}
+
+// CHECK-NOT: UnexposedAttr=

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=330692&r1=330691&r2=330692&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Apr 24 01:39:46 2018
@@ -1796,7 +1796,7 @@ bool CursorVisitor::VisitCXXRecordDecl(C
 
 bool CursorVisitor::VisitAttributes(Decl *D) {
   for (const auto *I : D->attrs())
-if (Visit(MakeCXCursor(I, D, TU)))
+if (!I->isImplicit() && Visit(MakeCXCursor(I, D, TU)))
 return true;
 
   return false;


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


r330694 - Link to AggressiveInstCombine in a few places. Unbreaks build for me.

2018-04-24 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Apr 24 01:40:44 2018
New Revision: 330694

URL: http://llvm.org/viewvc/llvm-project?rev=330694&view=rev
Log:
Link to AggressiveInstCombine in a few places. Unbreaks build for me.

/usr/local/bin/ld.lld: error: undefined symbol: 
llvm::createAggressiveInstCombinerPass()
>>> referenced by cc1_main.cpp
>>>   
>>> tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o:(_GLOBAL__sub_I_cc1_main.cpp)

And so on

The bot coverage is clearly missing.

Modified:
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=330694&r1=330693&r2=330694&view=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Tue Apr 24 01:40:44 2018
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   Coverage
   IPO
   IRReader
+  AggressiveInstCombine
   InstCombine
   Instrumentation
   LTO

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=330694&r1=330693&r2=330694&view=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Tue Apr 24 01:40:44 2018
@@ -4,6 +4,7 @@ set( LLVM_LINK_COMPONENTS
   CodeGen
   Core
   IPO
+  AggressiveInstCombine
   InstCombine
   Instrumentation
   MC


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


[PATCH] D38615: [libclang] Only mark CXCursors for explicit attributes with a type

2018-04-24 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv closed this revision.
erikjv added a comment.

Committed as r330692


https://reviews.llvm.org/D38615



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


r330696 - [GCC] Match a GCC version with a patch suffix without a third version component

2018-04-24 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Apr 24 01:50:11 2018
New Revision: 330696

URL: http://llvm.org/viewvc/llvm-project?rev=330696&view=rev
Log:
[GCC] Match a GCC version with a patch suffix without a third version component

Previously it would only accept a string as a GCC version if it had
either two components and no suffix, or three components with an
optional suffix.

Debian and ubuntu provided mingw compilers have lib/gcc/target entries
like "5.3-posix" and "5.3-win32". This doesn't try to make any specific
preference between them (other than lexical sorting of the suffix).

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

Added:
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include-fixed/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include-fixed/.keep

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/backward/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/backward/.keep

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/x86_64-w64-mingw32/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/x86_64-w64-mingw32/.keep
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32/include/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32/include/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/mingw.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=330696&r1=330695&r2=330696&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Apr 24 01:50:11 2018
@@ -1594,21 +1594,29 @@ Generic_GCC::GCCVersion Generic_GCC::GCC
   GoodVersion.MajorStr = First.first.str();
   if (First.second.empty())
 return GoodVersion;
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 
0)
+  StringRef MinorStr = Second.first;
+  if (Second.second.empty()) {
+if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
+  GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+  MinorStr = MinorStr.slice(0, EndNumber);
+}
+  }
+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  GoodVersion.MinorStr = MinorStr.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
   //   5(handled above)
   //   4.4
+  //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
+  StringRef PatchText = Second.second.str();
   if (!PatchText.empty()) {
 if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
   // Try to parse the number and any suffix.

Added: 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include-fixed/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include-fixed/.keep?rev=330696&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/backward/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c%2B%2B/backward/.keep?rev=330696&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_p

r330695 - [test] Fix a typo in a test directory name. NFC.

2018-04-24 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Apr 24 01:49:57 2018
New Revision: 330695

URL: http://llvm.org/viewvc/llvm-project?rev=330695&view=rev
Log:
[test] Fix a typo in a test directory name. NFC.

Added:

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/x86_64-w64-mingw32/

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/x86_64-w64-mingw32/.keep
  - copied, changed from r330681, 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/86_64-w64-mingw32/.keep
Removed:

cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/86_64-w64-mingw32/.keep

Removed: 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/86_64-w64-mingw32/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c%2B%2B/4.8/86_64-w64-mingw32/.keep?rev=330694&view=auto
==
(empty)

Copied: 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/x86_64-w64-mingw32/.keep
 (from r330681, 
cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c++/4.8/86_64-w64-mingw32/.keep)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c%2B%2B/4.8/x86_64-w64-mingw32/.keep?p2=cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c%2B%2B/4.8/x86_64-w64-mingw32/.keep&p1=cfe/trunk/test/Driver/Inputs/mingw_ubuntu_tree/usr/include/c%2B%2B/4.8/86_64-w64-mingw32/.keep&r1=330681&r2=330695&rev=330695&view=diff
==
(empty)


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


[PATCH] D45505: [GCC] Match a GCC version with a patch suffix without a third version component

2018-04-24 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330696: [GCC] Match a GCC version with a patch suffix 
without a third version component (authored by mstorsjo, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45505

Files:
  lib/Driver/ToolChains/Gnu.cpp
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include-fixed/.keep
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/backward/.keep
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/x86_64-w64-mingw32/.keep
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32/include/.keep
  test/Driver/mingw.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1594,21 +1594,29 @@
   GoodVersion.MajorStr = First.first.str();
   if (First.second.empty())
 return GoodVersion;
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 
0)
+  StringRef MinorStr = Second.first;
+  if (Second.second.empty()) {
+if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
+  GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+  MinorStr = MinorStr.slice(0, EndNumber);
+}
+  }
+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  GoodVersion.MinorStr = MinorStr.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
   //   5(handled above)
   //   4.4
+  //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
+  StringRef PatchText = Second.second.str();
   if (!PatchText.empty()) {
 if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
   // Try to parse the number and any suffix.
Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -49,3 +49,10 @@
 // CHECK_MINGW_UBUNTU_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}include{{/|}}c++{{/|}}4.8{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}include{{/|}}c++{{/|}}4.8{{/|}}backward"
 // CHECK_MINGW_UBUNTU_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// RUN: %clang -target x86_64-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ 
-c -### --sysroot=%S/Inputs/mingw_ubuntu_posix_tree/usr %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UBUNTU_POSIX_TREE %s
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1594,21 +1594,29 @@
   GoodVersion.MajorStr = First.first.str();
   if (First.second.empty())
 return GoodVersion;
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
+  StringRef MinorStr = Second.first;
+  if (Second.second.empty()) {
+if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
+  GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+  MinorStr = MinorStr.slice(0, EndNumber);
+}
+  }
+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  GoodVersion.MinorStr = MinorStr.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
   //   5(handled above)
   //   4.4
+  //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = GoodVersion.P

[PATCH] D45887: [CodeComplete] Fix completion at the end of keywords

2018-04-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice! I'm a little surprised that this wasn't fixed before, so I'm worried I 
missing something.
But nobody else has reviewed it, and it really seems right (and the test cases 
you fixed did seem broken). We can always revert :)




Comment at: lib/Lex/Lexer.cpp:1647
 // looking up the identifier in the identifier table.
 IdentifierInfo *II = PP->LookUpIdentifierInfo(Result);
 

move this down to where it's used - it's ignored for CC



Comment at: lib/Lex/Lexer.cpp:1649
 
-// Finally, now that we know we have an identifier, pass this off to the
-// preprocessor, which may macro expand it or something.
-if (II->isHandleIdentifierCase())
-  return PP->HandleIdentifier(Result);
-
-if (II->getTokenID() == tok::identifier && isCodeCompletionPoint(CurPtr)
-&& II->getPPKeywordID() == tok::pp_not_keyword
-&& II->getObjCKeywordID() == tok::objc_not_keyword) {
+if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.

maybe this deserves a comment describing exactly this change, something like:

If the completion point is at the end of an identifier, we want to treat it as 
incomplete even if it
is valid. This allows e.g. `class^` to complete to `classifier`.




Comment at: test/CodeCompletion/end-of-ident-macro.cpp:3
+#define FUNCTOR
+
+using FUNCTION = int();

nit: remove this blank line?



Comment at: test/CodeCompletion/end-of-ident-macro.cpp:6
+
+FUNC(int) a = 10;
+// ^FUNC(int)

Maybe add a comment above this line:

We should get all three completions when the cursor is at the beginning, 
middle, or end.

(I know documenting the intent of lit tests seems to not be fashionable, but... 
:-)


Repository:
  rC Clang

https://reviews.llvm.org/D45887



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


[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-24 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: lib/Basic/Targets/AArch64.h:85-89
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+

thopre wrote:
> From what I understood of the original patch, getConstraintRegister is a sort 
> of a more comprehensive version of convertRegister. On ARM convertRegister 
> handles U and p constraint specially, should this do the same?
Did you mean `convertConstraint`? As I understand, this function does 
canonicalization of constraints. If a constraint happens to be single-register, 
it is converted into `{register}` form (but this does not happen on ARM). On 
the other hand, `getConstraintRegister` takes a constraint and an asm label and 
converts them into a register (and in our case the register always comes from 
the asm label, never from the constraint), so I don't think we need to handle U 
and p specially.


https://reviews.llvm.org/D45965



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


[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D45815#1073581, @nik wrote:

> Hmm, that indicates that template function bodies are actually not that
>  dominant, which I also haven't thought. Now I'm doubting the correctness of
>  my patch/tests.


The numbers are definitely interesting, we need to double-check if that it's 
the case. But they definitely make a good point for including this option.
It seems Qt and LLVM are exactly the types of codebases where skipping the 
templates doesn't bring much value, as most of the code is not templated. On 
the other hand, skipping inline function might potentially be a win for those.

I'm still tempted to say that we should either skip all bodies or none of them 
to keep the code simpler, but I see why having errors from template 
instantiations is preferable.


Repository:
  rC Clang

https://reviews.llvm.org/D45815



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added inline comments.



Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226
+DiagnosticBuilder &Diag) {
+  if (getLangOpts().CPlusPlus11) {
+StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsncpy_s";

aaron.ballman wrote:
> Charusso wrote:
> > aaron.ballman wrote:
> > > What about C?
> > The `else` part would fire.
> I think this comment got moved to an unrelated area. I was talking about 
> `NotNullTerminatedResultCheck::memmoveFix()`, where there is no `else` 
> clause. However, I'm also not entirely certain why you are assuming the _s 
> versions of those functions are available in C++ (they're in Annex K for C, 
> which is an optional annex).
The `else` clause is missing, according to the documentation: 

> - ``memmove``, ``wmemmove``:
>   - C11: New function is ``memmove_s``/``wmemmove_s``, it has four arguments,
>   - the new second argument is the first argument's length, and
>   - the third argument will be moved as the fourth, where ``+ 1`` needed.
> 
>   - Before C11: The third argument gets a ``+ 1`` operation.

So the third argument as a token remains third if I add an extra second 
argument as a string, that's why it's work well on both options.


https://reviews.llvm.org/D45050



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 143698.
Charusso marked an inline comment as done.
Charusso added a comment.

Changed CXX11 to C11 and made a little refactor.


https://reviews.llvm.org/D45050

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tidy/bugprone/NotNullTerminatedResultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-c11.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-c11.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-before-c11.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-c11.c

Index: test/clang-tidy/bugprone-not-null-terminated-result-wcslen-c11.c
===
--- /dev/null
+++ test/clang-tidy/bugprone-not-null-terminated-result-wcslen-c11.c
@@ -0,0 +1,149 @@
+// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- -- -std=c11
+
+typedef unsigned int size_t;
+typedef unsigned int wchar_t;
+typedef int errno_t;
+size_t wcslen(const wchar_t *);
+wchar_t *wcschr(const wchar_t *, int);
+errno_t *wcsncpy_s(wchar_t *, const wchar_t *, size_t);
+
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *malloc(size_t);
+void *realloc(void *, size_t);
+
+void *wmemcpy(void *, const void *, size_t);
+errno_t wmemcpy_s(void *, size_t, const void *, size_t);
+void *wmemchr(const void *, int, size_t);
+void *wmemmove(void *, const void *, size_t);
+errno_t wmemmove_s(void *, size_t, const void *, size_t);
+void *wmemset(void *, int, size_t);
+
+int wcsncmp(const wchar_t *, const wchar_t *, size_t);
+size_t wcsxfrm(wchar_t *, const wchar_t *, size_t);
+
+
+void bad_alloca(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)alloca(wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'alloca' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: alloca(wcslen(src) + 1);
+}
+
+void good_alloca(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)alloca(wcslen(src) + 1);
+}
+
+void bad_calloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)calloc(wcslen(src), sizeof(wchar_t));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'calloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: calloc((wcslen(src) + 1), sizeof(wchar_t));
+}
+
+void good_calloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)calloc((wcslen(src) + 1), sizeof(wchar_t));
+}
+
+void bad_malloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)malloc(wcslen(src) * 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'malloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: malloc((wcslen(src) * 2) + 1);
+}
+
+void good_malloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)malloc((wcslen(src) * 2) + 1);
+}
+
+void bad_realloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)realloc(dest, (wcslen(dest) + wcslen(src)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'realloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: realloc(dest, (wcslen(dest) + (wcslen(src) + 1)));
+}
+
+void good_realloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)realloc(dest, (wcslen(dest) + (wcslen(src) + 1)));
+}
+
+void bad_wmemcpy(wchar_t *dest, const wchar_t *src) {
+  wmemcpy(dest, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src));
+}
+
+void good_wmemcpy_c11(wchar_t *dest, const wchar_t *src) {
+  wcsncpy_s(dest, src, wcslen(src));
+}
+
+void bad_wmemcpy_s(wchar_t *dest, const wchar_t *src) {
+  wmemcpy_s(dest, wcslen(dest), src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src));
+}
+
+void good_wmemcpy_s(wchar_t *dest, const wchar_t *src) {
+  wcsncpy_s(dest, src, wcslen(src));
+}
+
+void bad_wmemchr(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)wmemchr(src, '\0', wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: the result from calling 'wmemchr' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcschr(src, '\0');
+}
+
+void good_wmemchr(wchar_t *dest, const wchar_t *src) {
+  dest = wcschr(src, '\0');
+}
+
+void bad_wmemmove(wchar_t *dest, const wchar_t *src) {
+  wmemmove(dest, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result fro

[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Frontend/ASTUnit.h:679
+  struct SkipFunctionBodiesOptions {
+SkipFunctionBodiesOptions() {}
+enum { None, MainFileAndPreamble, Preamble } Scope = None;

Default ctor will be generated automatically. Maybe remove explicit definition?



Comment at: include/clang/Frontend/FrontendOptions.h:302
 
+  SkipFunctionBodiesKind SkipFunctionBodies;
+

Maybe add a comment to match the code style of other options?



Comment at: lib/Frontend/ASTUnit.cpp:1662
+{
+  SkipFunctionBodiesModifierRAII m(Invocation->getFrontendOpts(),
+   SkipFunctionBodiesOpts);

Maybe use LLVM's `make_scope_exit` from `ADT/ScopeExit.h` instead of creating a 
separate RAII class?
Or even directy set/restore the value of the flag right in the function.
Given that LLVM does not use exceptions, RAII class does not seem to buy much 
in terms of correctness and doesn't really make the code easier to read, IMO.

But up to you.



Comment at: lib/Parse/Parser.cpp:1107
 
+  bool SkipFunctionBodyRequested = false;
+  switch (SkipFunctionBodies) {

`Requested` in this name is a bit confusing, e.g. it's not clear who requested 
it.
Maybe rename to `TrySkipFunctionBody` or something similar?


Repository:
  rC Clang

https://reviews.llvm.org/D45815



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


r330704 - [ASTImporter] Allow testing of import sequences; fix import of typedefs for anonymous decls

2018-04-24 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Tue Apr 24 03:11:53 2018
New Revision: 330704

URL: http://llvm.org/viewvc/llvm-project?rev=330704&view=rev
Log:
[ASTImporter] Allow testing of import sequences; fix import of typedefs for 
anonymous decls

This patch introduces the ability to test an arbitrary sequence of imports
between a given set of virtual source files. This should finally allow
us to write simple tests and fix annoying issues inside ASTImporter
that cause failures in CSA CTU. This is done by refactoring
ASTImporterTest functions and introducing `testImportSequence` facility.
As a side effect, `testImport` facility was generalized a bit more. It
should now allow import of non-decl AST nodes; however, there is still no
test using this ability.

As a "test for test", there is also a fix for import anonymous TagDecls
referred by typedef. Before this patch, the setting of typedef for anonymous
structure was delayed; however, this approach misses the corner case if
an enum constant is imported directly. In this patch, typedefs for
anonymous declarations are imported right after the anonymous declaration
is imported, without any delay.

Thanks to Adam Balogh for suggestions included into this patch.

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


Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/test/Analysis/Inputs/ctu-other.cpp
cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
cfe/trunk/test/Analysis/ctu-main.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=330704&r1=330703&r2=330704&view=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Tue Apr 24 03:11:53 2018
@@ -83,10 +83,6 @@ class TypeSourceInfo;
 ///  the "from" source manager to the corresponding CXXBasesSpecifier
 ///  in the "to" source manager.
 ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers;
-
-/// \brief Imported, anonymous tag declarations that are missing their 
-/// corresponding typedefs.
-SmallVector AnonTagsWithPendingTypedefs;
 
 /// \brief Declaration (from, to) pairs that are known not to be equivalent
 /// (which we have already complained about).
@@ -136,6 +132,9 @@ class TypeSourceInfo;
 /// \returns the equivalent declaration in the "to" context, or a NULL 
type 
 /// if an error occurred.
 Decl *Import(Decl *FromD);
+Decl *Import(const Decl *FromD) {
+  return Import(const_cast(FromD));
+}
 
 /// \brief Return the copy of the given declaration in the "to" context if
 /// it has already been imported from the "from" context.  Otherwise return

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=330704&r1=330703&r2=330704&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Apr 24 03:11:53 2018
@@ -1088,6 +1088,17 @@ void ASTNodeImporter::ImportDeclContext(
 Importer.Import(From);
 }
 
+static void setTypedefNameForAnonDecl(TagDecl *From, TagDecl *To,
+   ASTImporter &Importer) {
+  if (TypedefNameDecl *FromTypedef = From->getTypedefNameForAnonDecl()) {
+auto *ToTypedef =
+  cast_or_null(Importer.Import(FromTypedef));
+assert (ToTypedef && "Failed to import typedef of an anonymous structure");
+
+To->setTypedefNameForAnonDecl(ToTypedef);
+  }
+}
+
 bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To, 
ImportDefinitionKind Kind) {
   if (To->getDefinition() || To->isBeingDefined()) {
@@ -1098,6 +1109,8 @@ bool ASTNodeImporter::ImportDefinition(R
   }
   
   To->startDefinition();
+
+  setTypedefNameForAnonDecl(From, To, Importer);
   
   // Add base classes.
   if (auto *ToCXX = dyn_cast(To)) {
@@ -1229,6 +1242,8 @@ bool ASTNodeImporter::ImportDefinition(E
   
   To->startDefinition();
 
+  setTypedefNameForAnonDecl(From, To, Importer);
+
   QualType T = 
Importer.Import(Importer.getFromContext().getTypeDeclType(From));
   if (T.isNull())
 return true;
@@ -1707,6 +1722,11 @@ Decl *ASTNodeImporter::VisitTypedefNameD
   if (T.isNull())
 return nullptr;
 
+  // Some nodes (like anonymous tags referred by typedefs) are allowed to
+  // import their enclosing typedef directly. Check if this is the case.
+  if (Decl *AlreadyImported = Importer.GetAlreadyImportedOrNull(D))
+return AlreadyImported;
+
   // Create the new typedef node.
   TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
   SourceLocation StartL = Importer.Import(D->getLocStart());
@@ -6576,29 +6596,7 @@ Decl *ASTImporter::Import(Dec

[PATCH] D44079: [ASTImporter] Allow testing of import sequences; fix import of typedefs for anonymous decls

2018-04-24 Thread Aleksei Sidorin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
a.sidorin marked an inline comment as done.
Closed by commit rL330704: [ASTImporter] Allow testing of import sequences; fix 
import of typedefs for… (authored by a.sidorin, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44079?vs=141537&id=143702#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44079

Files:
  cfe/trunk/include/clang/AST/ASTImporter.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/test/Analysis/Inputs/ctu-other.cpp
  cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
  cfe/trunk/test/Analysis/ctu-main.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -20,10 +20,15 @@
 
 #include "DeclMatcher.h"
 #include "gtest/gtest.h"
+#include "llvm/ADT/StringMap.h"
 
 namespace clang {
 namespace ast_matchers {
 
+using internal::Matcher;
+using internal::BindableMatcher;
+using llvm::StringMap;
+
 typedef std::vector ArgVector;
 typedef std::vector RunOptions;
 
@@ -70,22 +75,61 @@
 
 // Creates a virtual file and assigns that to the context of given AST. If the
 // file already exists then the file will not be created again as a duplicate.
-static void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
-  const std::string &Code) {
+static void
+createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
+  std::unique_ptr &&Buffer) {
   assert(ToAST);
   ASTContext &ToCtx = ToAST->getASTContext();
   auto *OFS = static_cast(
   ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
   auto *MFS =
   static_cast(OFS->overlays_begin()->get());
-  MFS->addFile(FileName, 0, llvm::MemoryBuffer::getMemBuffer(Code.c_str()));
+  MFS->addFile(FileName, 0, std::move(Buffer));
 }
 
-template
+static void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
+  StringRef Code) {
+  return createVirtualFileIfNeeded(ToAST, FileName,
+   llvm::MemoryBuffer::getMemBuffer(Code));
+}
+
+template 
+NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
+NodeType Node) {
+  ASTContext &ToCtx = To->getASTContext();
+
+  // Add 'From' file to virtual file system so importer can 'find' it
+  // while importing SourceLocations. It is safe to add same file multiple
+  // times - it just isn't replaced.
+  StringRef FromFileName = From->getMainFileName();
+  createVirtualFileIfNeeded(To, FromFileName,
+From->getBufferForFile(FromFileName));
+
+  auto Imported = Importer.Import(Node);
+
+  // This should dump source locations and assert if some source locations
+  // were not imported.
+  SmallString<1024> ImportChecker;
+  llvm::raw_svector_ostream ToNothing(ImportChecker);
+  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+
+  // This traverses the AST to catch certain bugs like poorly or not
+  // implemented subtrees.
+  Imported->dump(ToNothing);
+
+  return Imported;
+}
+
+const StringRef DeclToImportID = "declToImport";
+const StringRef DeclToVerifyID = "declToVerify";
+
+template 
 testing::AssertionResult
 testImport(const std::string &FromCode, const ArgVector &FromArgs,
const std::string &ToCode, const ArgVector &ToArgs,
-   MatchVerifier &Verifier, const MatcherType &AMatcher) {
+   MatchVerifier &Verifier,
+   const BindableMatcher &SearchMatcher,
+   const BindableMatcher &VerificationMatcher) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -97,46 +141,47 @@
   ASTContext &FromCtx = FromAST->getASTContext(),
   &ToCtx = ToAST->getASTContext();
 
-  // Add input.cc to virtual file system so importer can 'find' it
-  // while importing SourceLocations.
-  createVirtualFileIfNeeded(ToAST.get(), InputFileName, FromCode);
-
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
 
-  IdentifierInfo *ImportedII = &FromCtx.Idents.get("declToImport");
-  assert(ImportedII && "Declaration with 'declToImport' name"
-   "should be specified in test!");
-  DeclarationName ImportDeclName(ImportedII);
-  SmallVector FoundDecls;
-  FromCtx.getTranslationUnitDecl()->localUncachedLookup(
-ImportDeclName, FoundDecls);
-
-  if (FoundDecls.size() != 1)
-return testing::AssertionFailure() << "Multiple declarations were found!";
+  auto FoundNodes = match(SearchMatcher, FromCtx);
+  if (FoundNodes.size() != 1)
+return testing::AssertionFailure()
+   << "Multiple potential nodes were found!";
+
+  auto ToImport = selectFirst(Decl

[PATCH] D45407: [StaticAnalyzer] Added notes to the plist output

2018-04-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Can someone commit this for me? I don't have a write access.


Repository:
  rC Clang

https://reviews.llvm.org/D45407



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


[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name

2018-04-24 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig updated this revision to Diff 143706.
SimeonEhrig added a comment.

Add a comment, which declares the need of a unique ctor/dotr name.


https://reviews.llvm.org/D44435

Files:
  lib/CodeGen/CGCUDANV.cpp
  unittests/CodeGen/IncrementalProcessingTest.cpp

Index: unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- unittests/CodeGen/IncrementalProcessingTest.cpp
+++ unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -21,9 +21,11 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Target/TargetOptions.h"
 #include "gtest/gtest.h"
 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -171,4 +173,122 @@
 
 }
 
+
+// In CUDA incremental processing, a CUDA ctor or dtor will be generated for
+// every statement if a fatbinary file exists.
+const char CUDATestProgram1[] =
+"void cudaFunc1(){}\n";
+
+const char CUDATestProgram2[] =
+"void cudaFunc2(){}\n";
+
+const Function* getCUDActor(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("__cuda_module_ctor_"))
+  return &Func;
+
+  return nullptr;
+}
+
+const Function* getCUDAdtor(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("__cuda_module_dtor_"))
+  return &Func;
+
+  return nullptr;
+}
+
+TEST(IncrementalProcessing, EmitCUDAGlobalInitFunc) {
+LLVMContext Context;
+CompilerInstance compiler;
+
+compiler.createDiagnostics();
+compiler.getLangOpts().CPlusPlus = 1;
+compiler.getLangOpts().CPlusPlus11 = 1;
+compiler.getLangOpts().CUDA = 1;
+
+compiler.getTargetOpts().Triple = llvm::Triple::normalize(
+llvm::sys::getProcessTriple());
+compiler.setTarget(clang::TargetInfo::CreateTargetInfo(
+  compiler.getDiagnostics(),
+  std::make_shared(
+compiler.getTargetOpts(;
+
+// To enable the generating of cuda host code, it's needs to set up the
+// auxTriple.
+llvm::Triple hostTriple(llvm::sys::getProcessTriple());
+compiler.getFrontendOpts().AuxTriple =
+hostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
+auto targetOptions = std::make_shared();
+targetOptions->Triple = compiler.getFrontendOpts().AuxTriple;
+targetOptions->HostTriple = compiler.getTarget().getTriple().str();
+compiler.setAuxTarget(clang::TargetInfo::CreateTargetInfo(
+compiler.getDiagnostics(), targetOptions));
+
+// A fatbinary file is necessary, that the code generator generates the ctor
+// and dtor.
+auto tmpFatbinFileOrError = llvm::sys::fs::TempFile::create("dummy.fatbin");
+ASSERT_TRUE((bool)tmpFatbinFileOrError);
+auto tmpFatbinFile = std::move(*tmpFatbinFileOrError);
+compiler.getCodeGenOpts().CudaGpuBinaryFileName = tmpFatbinFile.TmpName;
+
+compiler.createFileManager();
+compiler.createSourceManager(compiler.getFileManager());
+compiler.createPreprocessor(clang::TU_Prefix);
+compiler.getPreprocessor().enableIncrementalProcessing();
+
+compiler.createASTContext();
+
+CodeGenerator* CG =
+CreateLLVMCodeGen(
+compiler.getDiagnostics(),
+"main-module",
+compiler.getHeaderSearchOpts(),
+compiler.getPreprocessorOpts(),
+compiler.getCodeGenOpts(),
+Context);
+
+compiler.setASTConsumer(std::unique_ptr(CG));
+compiler.createSema(clang::TU_Prefix, nullptr);
+Sema& S = compiler.getSema();
+
+std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S,
+   /*SkipFunctionBodies*/ false));
+Parser &P = *ParseOP.get();
+
+std::array, 3> M;
+M[0] = IncrementalParseAST(compiler, P, *CG, nullptr);
+ASSERT_TRUE(M[0]);
+
+M[1] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram1);
+ASSERT_TRUE(M[1]);
+ASSERT_TRUE(M[1]->getFunction("_Z9cudaFunc1v"));
+
+M[2] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram2);
+ASSERT_TRUE(M[2]);
+ASSERT_TRUE(M[2]->getFunction("_Z9cudaFunc2v"));
+// First code should not end up in second module:
+ASSERT_FALSE(M[2]->getFunction("_Z9cudaFunc1v"));
+
+// Make sure, that cuda ctor's and dtor's exist:
+const Function* CUDActor1 = getCUDActor(*M[1]);
+ASSERT_TRUE(CUDActor1);
+
+const Function* CUDActor2 = getCUDActor(*M[2]);
+ASSERT_TRUE(CUDActor2);
+
+const Function* CUDAdtor1 = getCUDAdtor(*M[1]);
+ASSERT_TRUE(CUDAdtor1);
+
+const Function* CUDAdtor2 = getCUDAdtor(*M[2]);
+ASSERT_TRUE(CUDAdtor2);
+
+// Compare the names of both ctor's and dtor's to check, that they are
+// unique.
+ASSERT_FALSE(CUDActor1->getName() == CUDActor2->getName());
+ASSERT_FALSE(CUDAdtor1->getName() == CUDAdtor2->getName());
+
+ASSERT_FALSE((bool)tmpFatbinFile.discard());
+}
+
 } // end anonymous namespace

[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.

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

LGTM!


https://reviews.llvm.org/D45865



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226
+DiagnosticBuilder &Diag) {
+  if (getLangOpts().CPlusPlus11) {
+StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsncpy_s";

Charusso wrote:
> aaron.ballman wrote:
> > Charusso wrote:
> > > aaron.ballman wrote:
> > > > What about C?
> > > The `else` part would fire.
> > I think this comment got moved to an unrelated area. I was talking about 
> > `NotNullTerminatedResultCheck::memmoveFix()`, where there is no `else` 
> > clause. However, I'm also not entirely certain why you are assuming the _s 
> > versions of those functions are available in C++ (they're in Annex K for C, 
> > which is an optional annex).
> The `else` clause is missing, according to the documentation: 
> 
> > - ``memmove``, ``wmemmove``:
> >   - C11: New function is ``memmove_s``/``wmemmove_s``, it has four 
> > arguments,
> >   - the new second argument is the first argument's length, and
> >   - the third argument will be moved as the fourth, where ``+ 1`` needed.
> > 
> >   - Before C11: The third argument gets a ``+ 1`` operation.
> 
> So the third argument as a token remains third if I add an extra second 
> argument as a string, that's why it's work well on both options.
I don't think you should assume the _s versions are available in C++, because 
they're not available everywhere. In fact, they're not available everywhere in 
C either (for instance, there is no Annex K implementation in glibc).

My recommendation would be to either gate this on the presence of a definition 
of the `__STDC_LIB_EXT1__` macro and that the ` __STDC_WANT_LIB_EXT1__` macro 
is defined but not defined to 0, or to make it a configurable option. I have a 
slight preference for the config option because not all implementations 
implement all of Annex K but still have a reasonable _s implementation of the 
Annex K APIs (like Microsoft's implementation) so I can picture users wanting a 
way to opt-in even without the macros.


https://reviews.llvm.org/D45050



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


[PATCH] D41648: [clang-tidy] implement cppcoreguidelines macro rules

2018-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp:77
+DiagnosticMessage =
+"function like macro used; consider a (constexpr) template function";
+  if (Info->isVariadic())

function like -> function-like

Why is constexpr in parentheses?



Comment at: clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp:80
+DiagnosticMessage =
+"variadic macro used; consider using a variadic template";
+

Should this also suggest a constexpr variadic template?



Comment at: clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp:86
+void MacroUsageCheck::warnNaming(const MacroDirective *MD) {
+  diag(MD->getLocation(), "use CAPS_ONLY for macros");
+}

How about: `macro definition does not define the macro name using all uppercase 
characters` or something along those lines?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41648



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


[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:71
+  // supported by specific code pages only.
+  if (Bytes.find_if_not(isASCII) != StringRef::npos)
+return false;

I am starting to think that this functionality should be refactored because the 
check is now O(N^2) in the worst case because all of the bytes of the string 
need to be touched twice. It would be nice for performance reasons to combine 
this so that there's only a single pass over all of the characters.

What do you think?


https://reviews.llvm.org/D45932



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


[PATCH] D45999: [clangd] Retrieve minimally formatted comment text in completion.

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, hokein, ioeric.
Herald added subscribers: jkorous, MaskRay, klimek.

Previous implementation used to extract brief text from doxygen comments.
Brief text parsing slows down completion and is not suited for
non-doxygen comments.

This commit switches to providing comments that mimic the ones
originally written in the source code, doing minimal reindenting and
removing the comments markers to make the output more user-friendly.

It means we lose support for doxygen-specific features, e.g. extracting
brief text, but provide useful results for non-doxygen comments.
Switching the doxygen support back is an option, but I suggest to see
whether the current approach gives more useful results.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45999

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/CodeCompletionStrings.cpp
  clangd/CodeCompletionStrings.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/CodeCompletionStringsTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -490,11 +490,11 @@
 }
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"),
-   AllOf(QName("nx::ff"),
- Labeled("ff(int x, double y)"),
- Detail("int"), Doc("Foo comment.";
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  QName("nx"), AllOf(QName("nx::ff"), Labeled("ff(int x, double y)"),
+ Detail("int"), Doc("Foo comment.";
 }
 
 TEST_F(SymbolCollectorTest, PlainAndSnippet) {
Index: unittests/clangd/CodeCompletionStringsTests.cpp
===
--- unittests/clangd/CodeCompletionStringsTests.cpp
+++ unittests/clangd/CodeCompletionStringsTests.cpp
@@ -51,23 +51,24 @@
 }
 
 TEST_F(CompletionStringTest, Documentation) {
-  Builder.addBriefComment("Is this brief?");
-  EXPECT_EQ(getDocumentation(*Builder.TakeString()), "Is this brief?");
+  Builder.addBriefComment("This is ignored");
+  EXPECT_EQ(getDocumentation(*Builder.TakeString(), "Is this brief?"),
+"Is this brief?");
 }
 
 TEST_F(CompletionStringTest, DocumentationWithAnnotation) {
-  Builder.addBriefComment("Is this brief?");
+  Builder.addBriefComment("This is ignored");
   Builder.AddAnnotation("Ano");
-  EXPECT_EQ(getDocumentation(*Builder.TakeString()),
+  EXPECT_EQ(getDocumentation(*Builder.TakeString(), "Is this brief?"),
 "Annotation: Ano\n\nIs this brief?");
 }
 
 TEST_F(CompletionStringTest, MultipleAnnotations) {
   Builder.AddAnnotation("Ano1");
   Builder.AddAnnotation("Ano2");
   Builder.AddAnnotation("Ano3");
 
-  EXPECT_EQ(getDocumentation(*Builder.TakeString()),
+  EXPECT_EQ(getDocumentation(*Builder.TakeString(), ""),
 "Annotations: Ano1 Ano2 Ano3\n");
 }
 
@@ -97,7 +98,7 @@
 
 TEST_F(CompletionStringTest, FunctionSnippet) {
   Builder.AddResultTypeChunk("result no no");
-  Builder.addBriefComment("Foo's comment");
+  Builder.addBriefComment("This comment is ignored");
   Builder.AddTypedTextChunk("Foo");
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
   Builder.AddPlaceholderChunk("p1");
@@ -113,7 +114,7 @@
   labelAndInsertText(*CCS, /*EnableSnippets=*/true);
   EXPECT_EQ(Label, "Foo(p1, p2)");
   EXPECT_EQ(InsertText, "Foo(${1:p1}, ${2:p2})");
-  EXPECT_EQ(getDocumentation(*CCS), "Foo's comment");
+  EXPECT_EQ(getDocumentation(*CCS, "Foo's comment"), "Foo's comment");
   EXPECT_EQ(getFilterText(*CCS), "Foo");
 }
 
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -236,8 +236,7 @@
   // completion. At least there aren't any we're aware of.
   EXPECT_THAT(Results.items, Not(Contains(Kind(CompletionItemKind::Snippet;
   // Check documentation.
-  EXPECT_IFF(Opts.IncludeBriefComments, Results.items,
- Contains(IsDocumented()));
+  EXPECT_IFF(Opts.IncludeComments, Results.items, Contains(IsDocumented()));
 }
 
 void TestGlobalScopeCompletion(clangd::CodeCompleteOptions Opts) {
@@ -282,8 +281,7 @@
   AllOf(Has("local_var"), Has("LocalClass"),
 Contains(Kind(CompletionItemKind::Snippet;
   // Check documentation.
-  EXPECT_IFF(Opts.IncludeBriefComments, Results.items,
- Contains(IsDocumented()));
+  EXPECT_IFF(Opts.IncludeComments, Results.items, Contains(IsDocumented()));
 }
 
 TEST(CompletionTest, CompletionOptions) {
@@ -294,7 +292,7 @@
   // We used to tes

[PATCH] D46000: [AST] Added a helper to extract a user-friendly text of a comment.

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, hokein, ioeric.

The helper is used in clangd for documentation shown in code completion
and storing the docs in the symbols. See https://reviews.llvm.org/D45999.

This patch reuses the code of the Doxygen comment lexer, disabling the
bits that do command and html tag parsing.
The new helper works on all comments, including non-doxygen comments
and is faster. However, it does not understand or transform any
doxygen directives, i.e. cannot extract brief text, etc.


Repository:
  rC Clang

https://reviews.llvm.org/D46000

Files:
  include/clang/AST/CommentLexer.h
  include/clang/AST/RawCommentList.h
  lib/AST/CommentLexer.cpp
  lib/AST/RawCommentList.cpp

Index: lib/AST/RawCommentList.cpp
===
--- lib/AST/RawCommentList.cpp
+++ lib/AST/RawCommentList.cpp
@@ -335,3 +335,83 @@
  BeforeThanCompare(SourceMgr));
   std::swap(Comments, MergedComments);
 }
+
+std::string RawComment::getFormattedText(const ASTContext &Ctx) const {
+  auto &SourceMgr = Ctx.getSourceManager();
+  llvm::StringRef CommentText = getRawText(SourceMgr);
+  if (CommentText.empty())
+return ""; // we couldn't retreive the comment.
+
+  llvm::BumpPtrAllocator Allocator;
+  comments::Lexer L(Allocator, Ctx.getDiagnostics(),
+Ctx.getCommentCommandTraits(), getSourceRange().getBegin(),
+CommentText.begin(), CommentText.end(),
+/*ParseCommentText=*/false);
+
+  // Trim whitespace at the start of \p S of length up to the value of \p
+  // MaxSkip.
+  auto SkipWs = [](llvm::StringRef S, unsigned MaxSkip) -> llvm::StringRef {
+unsigned SkipLen = std::min(
+MaxSkip, (unsigned)std::min(S.size(), S.find_first_not_of(" \t")));
+return S.drop_front(SkipLen);
+  };
+
+  std::string Result;
+  unsigned IndentColumn = 0;
+
+  // Processes one line of the comment and adds it to the result.
+  // Handles skipping the indent at the start of the line.
+  // Returns false when eof is reached and true otherwise.
+  auto LexLine = [&](bool IsFirstLine) -> bool {
+comments::Token Tok;
+// Lex the first token on the line. We handle it separately, because we to
+// fix up its indentation.
+L.lex(Tok);
+if (Tok.is(comments::tok::eof))
+  return false;
+if (Tok.is(comments::tok::newline)) {
+  Result += "\n";
+  return true;
+}
+llvm::StringRef TokText = L.getSpelling(Tok, SourceMgr);
+bool LocInvalid = false;
+unsigned TokColumn =
+SourceMgr.getSpellingColumnNumber(Tok.getLocation(), &LocInvalid);
+if (LocInvalid)
+  TokColumn = 0;
+// Compute the length of whitespace we're allowed to skip.
+unsigned MaxSkip;
+if (IsFirstLine) {
+  // For the first line we skip all leading ws.
+  MaxSkip = std::numeric_limits::max();
+} else {
+  // For the rest, we skip up to the column of first non-ws symbol on the
+  // first line..
+  MaxSkip = std::max((int)IndentColumn - (int)TokColumn, 0);
+}
+llvm::StringRef Trimmed = SkipWs(TokText, MaxSkip);
+Result += Trimmed;
+// Remember the amount of whitespace we skipped in the first line to remove
+// indent up to that column in the following lines.
+if (IsFirstLine)
+  IndentColumn = TokColumn + TokText.size() - Trimmed.size();
+// Lex all tokens in the rest of the line.
+for (L.lex(Tok); Tok.isNot(comments::tok::eof); L.lex(Tok)) {
+  if (Tok.is(comments::tok::newline)) {
+Result += "\n";
+return true;
+  }
+  Result += L.getSpelling(Tok, SourceMgr);
+}
+// We've reached the end of the line.
+return false;
+  };
+
+  // Proces first line separately to remember indent for the following lines.
+  if (!LexLine(/*IsFirstLine=*/true))
+return Result;
+  // Process the rest of the lines.
+  while (LexLine(/*IsFirstLine=*/false))
+;
+  return Result;
+}
Index: lib/AST/CommentLexer.cpp
===
--- lib/AST/CommentLexer.cpp
+++ lib/AST/CommentLexer.cpp
@@ -291,6 +291,14 @@
 }
 
 void Lexer::lexCommentText(Token &T) {
+  if (ParseCommands)
+lexCommentTextWithCommands(T);
+  else
+lexCommentTextWithoutCommands(T);
+}
+
+void Lexer::lexCommentTextWithCommands(Token &T) {
+  assert(ParseCommands);
   assert(CommentState == LCS_InsideBCPLComment ||
  CommentState == LCS_InsideCComment);
 
@@ -448,6 +456,39 @@
   }
 }
 
+void Lexer::lexCommentTextWithoutCommands(Token &T) {
+  assert(!ParseCommands);
+  assert(CommentState == LCS_InsideBCPLComment ||
+ CommentState == LCS_InsideCComment);
+  assert(State == LS_Normal);
+
+  const char *TokenPtr = BufferPtr;
+  assert(TokenPtr < CommentEnd);
+  while (TokenPtr != CommentEnd) {
+switch(*TokenPtr) {
+  case '\n':
+  case '\r':
+TokenPtr = skipNewline(TokenPtr, CommentEnd);
+for

[PATCH] D46001: [CodeComplete] Expose helpers to get RawComment of completion result.

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, hokein, ioeric.

Used in clangd, see https://reviews.llvm.org/D45999.


Repository:
  rC Clang

https://reviews.llvm.org/D46001

Files:
  include/clang/Sema/CodeCompleteConsumer.h
  lib/AST/RawCommentList.cpp
  lib/Sema/SemaCodeComplete.cpp

Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -2765,27 +2765,11 @@
 if (Declaration) {
   Result.addParentContext(Declaration->getDeclContext());
   Pattern->ParentName = Result.getParentName();
-  // Provide code completion comment for self.GetterName where
-  // GetterName is the getter method for a property with name
-  // different from the property name (declared via a property
-  // getter attribute.
-  const NamedDecl *ND = Declaration;
-  if (const ObjCMethodDecl *M = dyn_cast(ND))
-if (M->isPropertyAccessor())
-  if (const ObjCPropertyDecl *PDecl = M->findPropertyDecl())
-if (PDecl->getGetterName() == M->getSelector() &&
-PDecl->getIdentifier() != M->getIdentifier()) {
-  if (const RawComment *RC = 
-Ctx.getRawCommentForAnyRedecl(M)) {
-Result.addBriefComment(RC->getBriefText(Ctx));
-Pattern->BriefComment = Result.getBriefComment();
-  }
-  else if (const RawComment *RC = 
- Ctx.getRawCommentForAnyRedecl(PDecl)) {
-Result.addBriefComment(RC->getBriefText(Ctx));
-Pattern->BriefComment = Result.getBriefComment();
-  }
-}
+  if (const RawComment *RC =
+  getPatternCompletionComment(Ctx, Declaration)) {
+Result.addBriefComment(RC->getBriefText(Ctx));
+Pattern->BriefComment = Result.getBriefComment();
+  }
 }
 
 return Pattern;
@@ -2845,14 +2829,9 @@
 
   if (IncludeBriefComments) {
 // Add documentation comment, if it exists.
-if (const RawComment *RC = Ctx.getRawCommentForAnyRedecl(ND)) {
+if (const RawComment *RC = getCompletionComment(Ctx, Declaration)) {
   Result.addBriefComment(RC->getBriefText(Ctx));
 } 
-else if (const ObjCMethodDecl *OMD = dyn_cast(ND))
-  if (OMD->isPropertyAccessor())
-if (const ObjCPropertyDecl *PDecl = OMD->findPropertyDecl())
-  if (const RawComment *RC = Ctx.getRawCommentForAnyRedecl(PDecl))
-Result.addBriefComment(RC->getBriefText(Ctx));
   }
 
   if (StartsNestedNameSpecifier) {
@@ -3042,6 +3021,61 @@
   return Result.TakeString();
 }
 
+const RawComment *clang::getCompletionComment(const ASTContext &Ctx,
+  const NamedDecl *ND) {
+  if (!ND)
+return nullptr;
+  if (auto *RC = Ctx.getRawCommentForAnyRedecl(ND))
+return RC;
+
+  // Try to find comment from a property for ObjC methods.
+  const ObjCMethodDecl *M = dyn_cast(ND);
+  if (!M)
+return nullptr;
+  const ObjCPropertyDecl *PDecl = M->findPropertyDecl();
+  if (!PDecl)
+return nullptr;
+
+  return Ctx.getRawCommentForAnyRedecl(PDecl);
+}
+
+const RawComment *clang::getPatternCompletionComment(const ASTContext &Ctx,
+ const NamedDecl *ND) {
+  const ObjCMethodDecl *M = dyn_cast_or_null(ND);
+  if (!M || !M->isPropertyAccessor())
+return nullptr;
+
+  // Provide code completion comment for self.GetterName where
+  // GetterName is the getter method for a property with name
+  // different from the property name (declared via a property
+  // getter attribute.
+  const ObjCPropertyDecl *PDecl = M->findPropertyDecl();
+  if (!PDecl)
+return nullptr;
+  if (PDecl->getGetterName() == M->getSelector() &&
+  PDecl->getIdentifier() != M->getIdentifier()) {
+if (auto *RC = Ctx.getRawCommentForAnyRedecl(M))
+  return RC;
+if (auto *RC = Ctx.getRawCommentForAnyRedecl(PDecl))
+  return RC;
+  }
+  return nullptr;
+}
+
+/// \brief Get the documentation comment used to produce
+/// CodeCompletionString::BriefComment.
+const RawComment *clang::getParameterComment(
+const ASTContext &Ctx,
+const CodeCompleteConsumer::OverloadCandidate &Result,
+unsigned CurrentArg) {
+  auto FDecl = Result.getFunction();
+  if (!FDecl)
+return nullptr;
+  if (CurrentArg < FDecl->getNumParams())
+return Ctx.getRawCommentForAnyRedecl(FDecl->getParamDecl(CurrentArg));
+  return nullptr;
+}
+
 /// \brief Add function overload parameter chunks to the given code completion
 /// string.
 static void AddOverloadParameterChunks(ASTContext &Context,
@@ -3137,10 +3171,10 @@
   }
 
   if (FDecl) {
-if (IncludeBriefComments && CurrentArg < FDecl->getNumParams())
-  if (auto RC = S.getASTContext().getRawCommentForAnyRedecl(
-  FDecl->getParamDecl(CurrentArg)))
+if (IncludeBriefComments) {
+ 

[PATCH] D46002: [clangd] Parse all comments in Sema and completion.

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, hokein, ioeric.
Herald added subscribers: jkorous, MaskRay, klimek.

And add tests for the comment extraction code.

clangd will now show non-doxygen comments in completion for results
coming from Sema and Dynamic index.
Static index does not include the comments yet, I will enable it in
a separate commit after investigating which implications it has for
the size of the index.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46002

Files:
  clangd/ClangdUnit.cpp
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -17,6 +17,7 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "index/MemIndex.h"
+#include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -808,6 +809,74 @@
   UnorderedElementsAre("";
 }
 
+TEST(CompletionTest, Comments) {
+  auto ExtractComment = [](llvm::StringRef CommentText) -> std::string {
+std::string CompletionSource = CommentText;
+CompletionSource += "\n";
+CompletionSource += "void foobarbaz() { foobarbaz^ }";
+
+auto Completions = completions(CompletionSource).items;
+assert(Completions.size() == 1);
+return Completions.front().documentation;
+  };
+
+  // FIXME: this code should be a unit-test instead for
+  // RawComment::getFormattedText instead.
+
+  // clang-format off
+  auto ExpectedOutput =
+R"(This function does this and that.
+For example,
+   Runnning it in that case will give you
+   this result.
+That's about it.)";
+  // Two-slash comments.
+  EXPECT_EQ(ExpectedOutput, ExtractComment(
+R"cpp(
+// This function does this and that.
+// For example,
+//Runnning it in that case will give you
+//this result.
+// That's about it.)cpp"));
+
+  // Three-slash comments.
+  EXPECT_EQ(ExpectedOutput, ExtractComment(
+R"cpp(
+/// This function does this and that.
+/// For example,
+///Runnning it in that case will give you
+///this result.
+/// That's about it.)cpp"));
+
+  // Block comments.
+  EXPECT_EQ(ExpectedOutput, ExtractComment(
+R"cpp(
+/* This function does this and that.
+ * For example,
+ *Runnning it in that case will give you
+ *this result.
+ * That's about it.*/)cpp"));
+
+  // Doxygen-style block comments.
+  EXPECT_EQ(ExpectedOutput, ExtractComment(
+R"cpp(
+/** This function does this and that.
+  * For example,
+  *Runnning it in that case will give you
+  *this result.
+  * That's about it.*/)cpp"));
+
+  // Weird indentation.
+  EXPECT_EQ(ExpectedOutput, ExtractComment(
+R"cpp(
+   // This function does this and that.
+  //  For example,
+  // Runnning it in that case will give you
+//   this result.
+   // That's about it.)cpp"));
+  // clang-format on
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -22,6 +22,7 @@
 #include "SourceCode.h"
 #include "Trace.h"
 #include "index/Index.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -703,6 +704,7 @@
 return false;
   }
   CI->getFrontendOpts().DisableFree = false;
+  CI->getLangOpts()->CommentOpts.ParseAllComments = true;
 
   std::unique_ptr ContentsBuffer =
   llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName);
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -25,6 +25,7 @@
 #include "clang/Sema/Sema.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Basic/LangOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
@@ -358,6 +359,7 @@
 }
 // createInvocationFromCommandLine sets DisableFree.
 CI->getFrontendOpts().DisableFree = false;
+CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   }
 
   std::unique_ptr ContentsBuffer =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46003: [clang-tidy] Fix PR35468

2018-04-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added a reviewer: alexfh.
Herald added subscribers: dkrupp, rnkovacs, baloghadamsoftware, whisperity.

Auto return type was not correctly considered by the Unconventional Assign 
Operator check.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46003

Files:
  clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
  test/clang-tidy/misc-unconventional-assign-operator.cpp


Index: test/clang-tidy/misc-unconventional-assign-operator.cpp
===
--- test/clang-tidy/misc-unconventional-assign-operator.cpp
+++ test/clang-tidy/misc-unconventional-assign-operator.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++17 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
 
 namespace std {
 template 
@@ -25,6 +25,12 @@
   AlsoGood& operator=(AlsoGood);
 };
 
+struct PR35468 {
+  template auto &operator=(const T &) {
+return *this;
+  }
+};
+
 struct BadReturnType {
   void operator=(const BadReturnType&);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 
'BadReturnType&' [misc-unconventional-assign-operator]
Index: clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -24,9 +24,9 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
+  const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType(
+  pointee(unless(isConstQualified()),
+  anyOf(autoType(), hasDeclaration(equalsBoundNode("class")));
 
   const auto IsSelf = qualType(
   anyOf(hasDeclaration(equalsBoundNode("class")),


Index: test/clang-tidy/misc-unconventional-assign-operator.cpp
===
--- test/clang-tidy/misc-unconventional-assign-operator.cpp
+++ test/clang-tidy/misc-unconventional-assign-operator.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++11 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++17 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
 
 namespace std {
 template 
@@ -25,6 +25,12 @@
   AlsoGood& operator=(AlsoGood);
 };
 
+struct PR35468 {
+  template auto &operator=(const T &) {
+return *this;
+  }
+};
+
 struct BadReturnType {
   void operator=(const BadReturnType&);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturnType&' [misc-unconventional-assign-operator]
Index: clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -24,9 +24,9 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
+  const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType(
+  pointee(unless(isConstQualified()),
+  anyOf(autoType(), hasDeclaration(equalsBoundNode("class")));
 
   const auto IsSelf = qualType(
   anyOf(hasDeclaration(equalsBoundNode("class")),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330710 - [GCC] Don't keep a StringRef to a temporary std::string

2018-04-24 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Apr 24 04:57:02 2018
New Revision: 330710

URL: http://llvm.org/viewvc/llvm-project?rev=330710&view=rev
Log:
[GCC] Don't keep a StringRef to a temporary std::string

This fixes failures in asan builds and possibly other buildbots
as well, after SVN r330696.

Prior to that revision, the std::string was stored in another
variable, before assigning to a StringRef.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=330710&r1=330709&r2=330710&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Apr 24 04:57:02 2018
@@ -1616,7 +1616,7 @@ Generic_GCC::GCCVersion Generic_GCC::GCC
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = Second.second.str();
+  StringRef PatchText = Second.second;
   if (!PatchText.empty()) {
 if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
   // Try to parse the number and any suffix.


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


[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)

2018-04-24 Thread Mikhail Dvoretckii via Phabricator via cfe-commits
mike.dvoretsky updated this revision to Diff 143715.
mike.dvoretsky added a comment.

Updated per comments.


https://reviews.llvm.org/D45722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/avx2-builtins.c
  clang/test/CodeGen/avx512bw-builtins.c
  clang/test/CodeGen/sse2-builtins.c

Index: clang/test/CodeGen/sse2-builtins.c
===
--- clang/test/CodeGen/sse2-builtins.c
+++ clang/test/CodeGen/sse2-builtins.c
@@ -893,7 +893,33 @@
 
 __m128i test_mm_sad_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_sad_epu8
-  // CHECK: call <2 x i64> @llvm.x86.sse2.psad.bw(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: %{{.*}} = icmp ugt <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = sub <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = sub <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <2 x i32> 
+  // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64>
+  // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}}
   return _mm_sad_epu8(A, B);
 }
 
Index: clang/test/CodeGen/avx512bw-builtins.c
===
--- clang/test/CodeGen/avx512bw-builtins.c
+++ clang/test/CodeGen/avx512bw-builtins.c
@@ -1945,7 +1945,33 @@
 
 __m512i test_mm512_sad_epu8(__m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_sad_epu8
-  // CHECK: @llvm.x86.avx512.psad.bw.512
+  // CHECK: %{{.*}} = icmp ugt <64 x i8> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = sub <64 x i8> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = sub <64 x i8> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = select <64 x i1> %{{.*}}, <64 x i8> %{{.*}}, <64 x i8> %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <8 x i32> 
+  // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64>
+  // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}}
   return _mm512_sad_epu8(__A, __B); 
 }
 
Index: clang/test/CodeGen/avx2-builtins.c
===
--- clang/test/CodeGen/avx2-builtins.c
+++ clang/test/CodeGen/avx2-builtins.c
@@ -943,7 +943,33 @@
 
 __m256i test_mm256_sad_epu8(__m256i x, __m256i y) {
   // CHECK-LABEL: test_mm256_sad_epu8
- 

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

2018-04-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.
Herald added a subscriber: chrib.

Ping @joerg and @rnk - what's a sensible path forward with respect to this? 
@rnk thinks this change is correct, while @joerg disagrees, but hasn't had time 
to look into it yet. Is it acceptable to apply this now and then revert later 
once @joerg has analyzed the issue?


https://reviews.llvm.org/D38680



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


[PATCH] D45984: [X86] directstore and movdir64b intrinsics

2018-04-24 Thread Gabor Buella via Phabricator via cfe-commits
GBuella updated this revision to Diff 143718.

https://reviews.llvm.org/D45984

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cpuid.h
  lib/Headers/movdirintrin.h
  lib/Headers/x86intrin.h
  test/CodeGen/builtin-movdir.c
  test/Driver/x86-target-features.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1466,6 +1466,8 @@
 // CHECK_TRM_M32: #define __FXSR__ 1
 // CHECK_TRM_M32: #define __GFNI__ 1
 // CHECK_TRM_M32: #define __MMX__ 1
+// CHECK_TRM_M32: #define __MOVDIR64B__ 1
+// CHECK_TRM_M32: #define __MOVDIRI__ 1
 // CHECK_TRM_M32: #define __MPX__ 1
 // CHECK_TRM_M32: #define __PCLMUL__ 1
 // CHECK_TRM_M32: #define __POPCNT__ 1
@@ -1504,6 +1506,8 @@
 // CHECK_TRM_M64: #define __FXSR__ 1
 // CHECK_TRM_M64: #define __GFNI__ 1
 // CHECK_TRM_M64: #define __MMX__ 1
+// CHECK_TRM_M64: #define __MOVDIR64B__ 1
+// CHECK_TRM_M64: #define __MOVDIRI__ 1
 // CHECK_TRM_M64: #define __MPX__ 1
 // CHECK_TRM_M64: #define __PCLMUL__ 1
 // CHECK_TRM_M64: #define __POPCNT__ 1
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -149,3 +149,13 @@
 // RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s
 // WAITPKG: "-target-feature" "+waitpkg"
 // NO-WAITPKG: "-target-feature" "-waitpkg"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmovdiri %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MOVDIRI %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdiri %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIRI %s
+// MOVDIRI: "-target-feature" "+movdiri"
+// NO-MOVDIRI: "-target-feature" "-movdiri"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmovdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MOVDIR64B %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIR64B %s
+// MOVDIR64B: "-target-feature" "+movdir64b"
+// NO-MOVDIR64B: "-target-feature" "-movdir64b"
Index: test/CodeGen/builtin-movdir.c
===
--- /dev/null
+++ test/CodeGen/builtin-movdir.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK
+
+#include 
+#include 
+
+void test_directstore32(void *dst, uint32_t value) {
+  // CHECK-LABEL: test_directstore32
+  // CHECK: call void @llvm.x86.directstore32
+  _directstoreu_u32(dst, value);
+}
+
+#ifdef __x86_64__
+
+void test_directstore64(void *dst, uint64_t value) {
+  // X86_64-LABEL: test_directstore64
+  // X86_64: call void @llvm.x86.directstore64
+  _directstoreu_u64(dst, value);
+}
+
+#endif
+
+void test_dir64b(void *dst, const void *src) {
+  // CHECK-LABEL: test_dir64b
+  // CHECK: call void @llvm.x86.movdir64b
+  _movdir64b(dst, src);
+}
+
+// CHECK: declare void @llvm.x86.directstore32(i8*, i32)
+// X86_64: declare void @llvm.x86.directstore64(i8*, i64)
+// CHECK: declare void @llvm.x86.movdir64b(i8*, i8*)
Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -100,4 +100,9 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+  defined(__MOVDIRI__) || defined(__MOVDIR64B__)
+#include 
+#endif
+
 #endif /* __X86INTRIN_H */
Index: lib/Headers/movdirintrin.h
===
--- /dev/null
+++ lib/Headers/movdirintrin.h
@@ -0,0 +1,58 @@
+/*===- movdirintrin.h --===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions 

[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-24 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:71
+  // supported by specific code pages only.
+  if (Bytes.find_if_not(isASCII) != StringRef::npos)
+return false;

aaron.ballman wrote:
> I am starting to think that this functionality should be refactored because 
> the check is now O(N^2) in the worst case because all of the bytes of the 
> string need to be touched twice. It would be nice for performance reasons to 
> combine this so that there's only a single pass over all of the characters.
> 
> What do you think?
Sorry, but why O(N^2)? `isASCII` is O(1), it's just `return C<=127`. 
`find_if_not` is O(N).


https://reviews.llvm.org/D45932



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


[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-24 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: include/clang/Frontend/ASTUnit.h:679
+  struct SkipFunctionBodiesOptions {
+SkipFunctionBodiesOptions() {}
+enum { None, MainFileAndPreamble, Preamble } Scope = None;

ilya-biryukov wrote:
> Default ctor will be generated automatically. Maybe remove explicit 
> definition?
or replace by constructor with parameters


Repository:
  rC Clang

https://reviews.llvm.org/D45815



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


[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:71
+  // supported by specific code pages only.
+  if (Bytes.find_if_not(isASCII) != StringRef::npos)
+return false;

zinovy.nis wrote:
> aaron.ballman wrote:
> > I am starting to think that this functionality should be refactored because 
> > the check is now O(N^2) in the worst case because all of the bytes of the 
> > string need to be touched twice. It would be nice for performance reasons 
> > to combine this so that there's only a single pass over all of the 
> > characters.
> > 
> > What do you think?
> Sorry, but why O(N^2)? `isASCII` is O(1), it's just `return C<=127`. 
> `find_if_not` is O(N).
The `find_if_not()` call you add touches every character in the string to see 
if it's ASCII and it all characters are ASCII, then `containsEscape()` calls 
`find()` which touches every character again (assuming the searched character 
is never encountered).

Looking a bit deeper, `isRawStringLiteral()` also calls `find()`, but it 
asserts that the character is found, so not every character is touched in the 
string and it should find a the searched character quite quickly.


https://reviews.llvm.org/D45932



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


[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.

2018-04-24 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Thank you! I do not have commit rights, so if someone could commit this that 
would be great.


https://reviews.llvm.org/D45865



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


[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-24 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:71
+  // supported by specific code pages only.
+  if (Bytes.find_if_not(isASCII) != StringRef::npos)
+return false;

aaron.ballman wrote:
> zinovy.nis wrote:
> > aaron.ballman wrote:
> > > I am starting to think that this functionality should be refactored 
> > > because the check is now O(N^2) in the worst case because all of the 
> > > bytes of the string need to be touched twice. It would be nice for 
> > > performance reasons to combine this so that there's only a single pass 
> > > over all of the characters.
> > > 
> > > What do you think?
> > Sorry, but why O(N^2)? `isASCII` is O(1), it's just `return C<=127`. 
> > `find_if_not` is O(N).
> The `find_if_not()` call you add touches every character in the string to see 
> if it's ASCII and it all characters are ASCII, then `containsEscape()` calls 
> `find()` which touches every character again (assuming the searched character 
> is never encountered).
> 
> Looking a bit deeper, `isRawStringLiteral()` also calls `find()`, but it 
> asserts that the character is found, so not every character is touched in the 
> string and it should find a the searched character quite quickly.
OK, I'll see how to combine theses checks into a single one.

But anyway I see only 2*O(N), not O(N^2) here.


https://reviews.llvm.org/D45932



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


[PATCH] D46007: [analyzer] Add `TaintBugVisitor` to the ArrayBoundV2, DivideZero and VLASize.

2018-04-24 Thread Henry Wong via Phabricator via cfe-commits
MTC created this revision.
MTC added reviewers: NoQ, george.karpenkov, xazax.hun, a.sidorin.
Herald added subscribers: cfe-commits, rnkovacs, szepet.

Add `TaintBugVisitor` to the ArrayBoundV2, DivideZero, VLASize to be able to 
indicate where the taint information originated from.


Repository:
  rC Clang

https://reviews.llvm.org/D46007

Files:
  lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
  lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  test/Analysis/taint-diagnostic-visitor.c

Index: test/Analysis/taint-diagnostic-visitor.c
===
--- test/Analysis/taint-diagnostic-visitor.c
+++ test/Analysis/taint-diagnostic-visitor.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core -analyzer-output=text -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -analyzer-output=text -verify %s
 
 // This file is for testing enhanced diagnostics produced by the GenericTaintChecker
 
@@ -11,3 +11,26 @@
   scanf("%s", buf); // expected-note {{Taint originated here}}
   system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}}
 }
+
+int taintDiagnosticOutOfBound() {
+  int index;
+  int Array[] = {1, 2, 3, 4, 5};
+  scanf("%d", &index); // expected-note {{Taint originated here}}
+  return Array[index]; // expected-warning {{Out of bound memory access (index is tainted)}}
+   // expected-note@-1 {{Out of bound memory access (index is tainted)}}
+}
+
+int taintDiagnosticDivZero(int operand) {
+  scanf("%d", &operand); // expected-note {{Value assigned to 'operand'}}
+ // expected-note@-1 {{Taint originated here}}
+  return 10 / operand; // expected-warning {{Division by a tainted value, possibly zero}}
+   // expected-note@-1 {{Division by a tainted value, possibly zero}}
+}
+
+void taintDiagnosticVLA() {
+  int x;
+  scanf("%d", &x); // expected-note {{Value assigned to 'x'}}
+   // expected-note@-1 {{Taint originated here}}
+  int vla[x]; // expected-warning {{Declared variable-length array (VLA) has tainted size}}
+  // expected-note@-1 {{Declared variable-length array (VLA) has tainted size}}
+}
Index: lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -32,19 +32,18 @@
   mutable std::unique_ptr BT;
   enum VLASize_Kind { VLA_Garbage, VLA_Zero, VLA_Tainted, VLA_Negative };
 
-  void reportBug(VLASize_Kind Kind,
- const Expr *SizeE,
- ProgramStateRef State,
- CheckerContext &C) const;
+  void reportBug(VLASize_Kind Kind, const Expr *SizeE, ProgramStateRef State,
+ CheckerContext &C,
+ std::unique_ptr Visitor = nullptr) const;
+
 public:
   void checkPreStmt(const DeclStmt *DS, CheckerContext &C) const;
 };
 } // end anonymous namespace
 
-void VLASizeChecker::reportBug(VLASize_Kind Kind,
-   const Expr *SizeE,
-   ProgramStateRef State,
-   CheckerContext &C) const {
+void VLASizeChecker::reportBug(
+VLASize_Kind Kind, const Expr *SizeE, ProgramStateRef State,
+CheckerContext &C, std::unique_ptr Visitor) const {
   // Generate an error node.
   ExplodedNode *N = C.generateErrorNode(State);
   if (!N)
@@ -73,6 +72,7 @@
   }
 
   auto report = llvm::make_unique(*BT, os.str(), N);
+  report->addVisitor(std::move(Visitor));
   report->addRange(SizeE->getSourceRange());
   bugreporter::trackNullOrUndefValue(N, SizeE, *report);
   C.emitReport(std::move(report));
@@ -108,7 +108,8 @@
 
   // Check if the size is tainted.
   if (state->isTainted(sizeV)) {
-reportBug(VLA_Tainted, SE, nullptr, C);
+reportBug(VLA_Tainted, SE, nullptr, C,
+  llvm::make_unique(sizeV));
 return;
   }
 
Index: lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
+++ lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
@@ -24,22 +24,25 @@
 namespace {
 class DivZeroChecker : public Checker< check::PreStmt > {
   mutable std::unique_ptr BT;
-  void reportBug(const char *Msg,
- ProgramStateRef StateZero,
- CheckerContext &C) const ;
+  void reportBug(const char *Msg, ProgramStateRef StateZero, CheckerContext &C,
+ std::unique_ptr Visitor = nullptr) const;
+
 public:
   void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const;
 };
 } // end anonymous namespace
 
-void DivZeroChecker::reportBug(c

[PATCH] D46003: [clang-tidy] Fix PR35468

2018-04-24 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with one comment.




Comment at: test/clang-tidy/misc-unconventional-assign-operator.cpp:1
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++17 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
 

I'd prefer to add a separate test file for C++17-dependent tests. It would be 
nice to ensure the rest works fine in C++11.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46003



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


[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 143728.
hokein marked 14 inline comments as done.
hokein added a comment.

Address review comments:

- clarify the flow of go to definition.
- simplify the test code.
- some function move-out stuff.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45717

Files:
  clangd/ClangdServer.cpp
  clangd/FindSymbols.cpp
  clangd/XRefs.cpp
  clangd/XRefs.h
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -13,11 +13,14 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "XRefs.h"
+#include "gmock/gmock.h"
+#include "index/FileIndex.h"
+#include "index/SymbolCollector.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
+#include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -37,17 +40,33 @@
 };
 
 // FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef Code) {
-  auto CI = createInvocationFromCommandLine(
-  {"clang", "-xc++", testPath("Foo.cpp").c_str()});
-  auto Buf = MemoryBuffer::getMemBuffer(Code);
+ParsedAST build(StringRef MainCode, StringRef HeaderCode = "") {
+  auto HeaderPath = testPath("foo.h");
+  auto MainPath = testPath("foo.cpp");
+  llvm::IntrusiveRefCntPtr VFS(
+  new vfs::InMemoryFileSystem());
+  VFS->addFile(MainPath, 0, llvm::MemoryBuffer::getMemBuffer(MainCode));
+  VFS->addFile(HeaderPath, 0, llvm::MemoryBuffer::getMemBuffer(HeaderCode));
+  std::vector Cmd = {"clang", "-xc++", MainPath.c_str()};
+  if (!HeaderCode.empty()) {
+std::vector args = {"-include", HeaderPath.c_str()};
+Cmd.insert(Cmd.begin() + 1, args.begin(), args.end());
+  }
+  auto CI = createInvocationFromCommandLine(Cmd);
+
+  auto Buf = MemoryBuffer::getMemBuffer(MainCode);
   auto AST = ParsedAST::Build(std::move(CI), nullptr, std::move(Buf),
-  std::make_shared(),
-  vfs::getRealFileSystem());
+  std::make_shared(), VFS);
   assert(AST.hasValue());
   return std::move(*AST);
 }
 
+std::unique_ptr buildIndex(StringRef MainCode,
+StringRef HeaderCode) {
+  auto AST = build(MainCode, HeaderCode);
+  return MemIndex::build(indexAST(&AST));
+}
+
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -106,6 +125,66 @@
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
 
+TEST(GoToDefinition, WithIndex) {
+  Annotations SymbolHeader(R"cpp(
+class $forward[[Forward]];
+class $foo[[Foo]] {};
+
+void $f1[[f1]]();
+
+inline void $f2[[f2]]() {}
+  )cpp");
+  Annotations SymbolCpp(R"cpp(
+  class $forward[[forward]] {};
+  void  $f1[[f1]]() {}
+)cpp");
+
+  auto Index = buildIndex(SymbolCpp.code(), SymbolHeader.code());
+  auto runFindDefinitionsWithIndex =
+  [&Index](const Annotations &Main) {
+auto AST = build(/*MainCode=*/Main.code(),
+ /*HeaderCode=*/"");
+return clangd::findDefinitions(AST, Main.point(), Index.get());
+  };
+
+  Annotations Test(R"cpp(// only declaration in AST.
+void [[f1]]();
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(SymbolCpp.range("f1")), RangeIs(Test.range())}));
+
+  Test = Annotations(R"cpp(// definition in AST.
+void [[f1]]() {}
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(Test.range()), RangeIs(SymbolHeader.range("f1"))}));
+
+  Test = Annotations(R"cpp(// forward declaration in AST.
+class [[Foo]];
+F^oo* create();
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(SymbolHeader.range("foo")), RangeIs(Test.range())}));
+
+  Test = Annotations(R"cpp(// defintion in AST.
+class [[Forward]] {};
+F^orward create();
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray({
+  RangeIs(Test.range()), RangeIs(SymbolHeader.range("forward")),
+  }));
+}
+
 TEST(GoToDefinition, All) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clangd/index/FileIndex.h
===
--- clangd/index/FileIndex.h
+++ clangd/index/FileIndex.h
@@ -23,6

[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the useful comments! I refined the patch, and it becomes a bit 
larger (including some moving stuff).




Comment at: clangd/XRefs.cpp:137
+
+IdentifiedSymbol getSymbolAtPosition(ParsedAST &AST, SourceLocation Pos) {
+  auto DeclMacrosFinder = std::make_shared(

sammccall wrote:
> this is a nice abstraction - consider hiding the DeclarationAndMacrosFinder 
> inside it!
Inlining DeclarationAndMacrosFinder implementation inside this function would 
hurt the code readability, I'd leave it as it is. Now all client sides are 
using this function instead of  `DeclarationAndMacrosFinder`.



Comment at: clangd/XRefs.cpp:215
 
-  indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
- DeclMacrosFinder, IndexOpts);
+  // Handle goto definition for macros.
+  if (!Symbols.Macros.empty()) {

sammccall wrote:
> So now you're early-out if there are macros.
> This means if you have
> 
> ```
> void log(string s) { cout << s; }
> #define LOG log
> LOG("hello");
> ```
> 
> You'll offer only line 2 as an option, and not line 1.
> I'm not sure that's bad, but it's non-obvious - I think it's the thing that 
> the comment should call out.
> e.g. "If the cursor is on a macro, go to the macro's definition without 
> trying to resolve the code it expands to"
> (The current comment just echoes the code)
This is a non-functional change.

For the above example, only line 2 will be offered. This is expected behavior 
IMO -- when we go to definition on a macro, users would expect the macro 
definition.



Comment at: clangd/XRefs.cpp:237
+  //(e.g. function declaration in header), and a location of definition if
+  //they are available, definition comes first.
+  struct CandidateLocation {

sammccall wrote:
> first why?
because this is `go to definition`, so it is sensible to return the 
`definition` as the first result, right?



Comment at: clangd/XRefs.cpp:256
+CandidateLocation &Candidate = ResultCandidates[ID];
+bool IsDef = GetDefinition(D) == D;
+// Populate one of the slots with location for the AST.

sammccall wrote:
> why do you not use GetDefinition(D) as the definition, in the case where it's 
> not equal to D?
Done. Added a comment.



Comment at: clangd/XRefs.cpp:277
+// it.
+auto ToLSPLocation = [&HintPath](
+const SymbolLocation &Loc) -> llvm::Optional 
{

sammccall wrote:
> (The double-nested lambda is somewhat hard to read, can this just be a 
> top-level function? That's what's needed to share it, right?)
Moved it to `XRef.h`, and also replace the one in `findsymbols`.



Comment at: clangd/XRefs.cpp:516
 
   SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
   auto DeclMacrosFinder = std::make_shared(

sammccall wrote:
> can you also use `getSymbolAtPosition` here?
Yeah, I just missed this.



Comment at: unittests/clangd/XRefsTests.cpp:43
+ParsedAST build(StringRef MainCode, StringRef HeaderCode = "",
+StringRef BaseName = "Main",
+llvm::IntrusiveRefCntPtr

sammccall wrote:
> why allow BaseName to be chosen?
The same reason (allowed us to use the same FS between the index and AST).



Comment at: unittests/clangd/XRefsTests.cpp:44
+StringRef BaseName = "Main",
+llvm::IntrusiveRefCntPtr
+InMemoryFileSystem = nullptr) {

sammccall wrote:
> why do you need to pass in the FS? The FS shouldn't need to be the same 
> between the index and AST.
I intended to use one FS for index and AST, because we'd like to test the AST 
case which includes the index header file, but it turns out this is not needed 
and add complexity of the testcode, removed it.



Comment at: unittests/clangd/XRefsTests.cpp:52
+  std::vector Cmd = {"clang", "-xc++", MainPath.c_str()};
+  if (!HeaderCode.empty()) {
+InMemoryFileSystem->addFile(HeaderPath, 0,

sammccall wrote:
> why do this conditionally?
It is unnecessary if no header code is provided. And `-include` option would 
affect the test somehow, if we do it unconditionally, it breaks one of the 
existing test cases (no location was found). I haven't digged into the reason...

```cpp
int [[i]];
#define ADDRESSOF(X) &X;
int *j = ADDRESSOF(^i);
```



Comment at: unittests/clangd/XRefsTests.cpp:72
 
+std::unique_ptr buildIndexFromAST(ParsedAST *AST) {
+  SymbolCollector::Options CollectorOpts;

sammccall wrote:
> can we reuse FileIndex instead of reimplementing it?
Shared the implementation from FileIndex.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45717




[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:71
+  // supported by specific code pages only.
+  if (Bytes.find_if_not(isASCII) != StringRef::npos)
+return false;

zinovy.nis wrote:
> aaron.ballman wrote:
> > zinovy.nis wrote:
> > > aaron.ballman wrote:
> > > > I am starting to think that this functionality should be refactored 
> > > > because the check is now O(N^2) in the worst case because all of the 
> > > > bytes of the string need to be touched twice. It would be nice for 
> > > > performance reasons to combine this so that there's only a single pass 
> > > > over all of the characters.
> > > > 
> > > > What do you think?
> > > Sorry, but why O(N^2)? `isASCII` is O(1), it's just `return C<=127`. 
> > > `find_if_not` is O(N).
> > The `find_if_not()` call you add touches every character in the string to 
> > see if it's ASCII and it all characters are ASCII, then `containsEscape()` 
> > calls `find()` which touches every character again (assuming the searched 
> > character is never encountered).
> > 
> > Looking a bit deeper, `isRawStringLiteral()` also calls `find()`, but it 
> > asserts that the character is found, so not every character is touched in 
> > the string and it should find a the searched character quite quickly.
> OK, I'll see how to combine theses checks into a single one.
> 
> But anyway I see only 2*O(N), not O(N^2) here.
Oh, derp, that's my thinko -- sorry! You are correct, that's 2 * O(N) and not 
O(N^2).


https://reviews.llvm.org/D45932



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


[PATCH] D45887: [CodeComplete] Fix completion at the end of keywords

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Lex/Lexer.cpp:1647
 // looking up the identifier in the identifier table.
 IdentifierInfo *II = PP->LookUpIdentifierInfo(Result);
 

sammccall wrote:
> move this down to where it's used - it's ignored for CC
It actually updates `Result` too!
And things break if we don't call it. Added a comment.


Repository:
  rC Clang

https://reviews.llvm.org/D45887



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


[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".

2018-04-24 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:144
+// includes the full path.
+if (SM.getFilename(IL).contains("UnifiedSource")) {
+  StringRef Name = SM.getFilename(SL);

NoQ wrote:
> NoQ wrote:
> > probinson wrote:
> > > george.karpenkov wrote:
> > > > NoQ wrote:
> > > > > george.karpenkov wrote:
> > > > > > Is this `if` really necessary? This logic has too much overfitting, 
> > > > > > and it seems that if someone decides to include `.cc` files, we 
> > > > > > should analyze them in any case, right? We also would prefer to not 
> > > > > > stop working if webkit decides on using a different naming for 
> > > > > > those.
> > > > > This is indeed an act of overfitting. But also there are very few 
> > > > > reasons to include a non-header file, and all of them are pretty 
> > > > > exotic. I'm not sure we want to analyze these files in all cases. So 
> > > > > i want to play safe until we gather more data.
> > > > I would still say that just analyzing included c++ files is a lesser 
> > > > evil.
> > > Agreed.  WebKit is not the only project that does this kind of thing.
> > The question is, are all such projects in fact interested in having the 
> > analyzer analyze the respective code?
> > 
> > For instance, if the included code is autogenerated by an external tool, 
> > users are probably not interested in finding bugs in such code because they 
> > will be unable to fix them.
> > 
> > Are you interested in providing a list of examples of projects that do this 
> > kind of thing, explain why are they doing it, and whether they will be 
> > interested in having warnings in included files?
> Note that we're not talking about warnings that are *emitted* in the included 
> file. We're talking about warnings that *originate* within the included file 
> (and as such most likely stay within the included file and its includes). 
> This makes a difference because we are doing inter-procedural analysis. I.e., 
> if we find that passing a null pointer in the main file into a header 
> function causes a null dereference in the header function, the report that 
> originates within the main file will be emitted in the header with auxiliary 
> path notes in the main file.
> 
> So if a small chunk of code is included but the main file still contains 
> reasonable stuff, we'll be able to find most bugs in the included code as it 
> is being used from the rest of the file. The problem only arises when all 
> code is included.
Game teams are known to use "unity" builds, developing their code in separate 
files then having a master .cpp that will `#include` everything in a given 
library/component.  This separates source into reasonable sized and logically 
coherent units, but the unity build improves build time for these large 
projects.  If a team is using static analysis, they will want it on the entire 
compilation.


https://reviews.llvm.org/D45839



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


[PATCH] D45887: [CodeComplete] Fix completion at the end of keywords

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 143731.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

- Added comments
- Fix nits in tests


Repository:
  rC Clang

https://reviews.llvm.org/D45887

Files:
  lib/Lex/Lexer.cpp
  test/CodeCompletion/end-of-ident-macro.cpp
  test/CodeCompletion/end-of-ident.cpp
  test/CodeCompletion/macros.c
  test/CodeCompletion/namespace.cpp
  test/CodeCompletion/operator.cpp
  test/CodeCompletion/tag.c
  test/CodeCompletion/tag.cpp
  test/CodeCompletion/using-namespace.cpp
  test/CodeCompletion/using.cpp
  test/Index/complete-exprs.c
  test/Index/complete-preprocessor.m

Index: test/Index/complete-preprocessor.m
===
--- test/Index/complete-preprocessor.m
+++ test/Index/complete-preprocessor.m
@@ -13,7 +13,7 @@
 
 FOO(in,t) value;
 
-// RUN: c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:4:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText define}{HorizontalSpace  }{Placeholder macro} (40)
 // CHECK-CC1-NEXT: NotImplemented:{TypedText define}{HorizontalSpace  }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (40)
 // CHECK-CC1-NEXT: NotImplemented:{TypedText error}{HorizontalSpace  }{Placeholder message} (40)
@@ -55,8 +55,8 @@
 // RUN: c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: macro definition:{TypedText BAR} (40)
 // CHECK-CC3: macro definition:{TypedText FOO} (40)
-// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: c-index-test -code-completion-at=%s:11:13 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:11:14 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: macro definition:{TypedText BAR} (70)
 // CHECK-CC4: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70)
Index: test/Index/complete-exprs.c
===
--- test/Index/complete-exprs.c
+++ test/Index/complete-exprs.c
@@ -24,15 +24,15 @@
   (type)f;
 }
 
-// RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
 // CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
 // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
 // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
 // CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: macro definition:{TypedText __VERSION__} (70)
Index: test/CodeCompletion/using.cpp
===
--- test/CodeCompletion/using.cpp
+++ test/CodeCompletion/using.cpp
@@ -13,8 +13,8 @@
   void foo() {
 int N3;
 
-using
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+using 
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: I1
 // CHECK-CC1: I4
 // CHECK-CC1: I5
Index: test/CodeCompletion/using-namespace.cpp
===
--- test/CodeCompletion/using-namespace.cpp
+++ test/CodeCompletion/using-namespace.cpp
@@ -11,8 +11,8 @@
   namespace I1 { }
   
   void foo() {
- 

[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-24 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 143732.
miyuki added a comment.

Added a comment for getConstraintRegister


https://reviews.llvm.org/D45965

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/AArch64.h
  lib/Basic/Targets/ARM.h
  test/Sema/arm-asm.c
  test/Sema/arm64-inline-asm.c


Index: test/Sema/arm64-inline-asm.c
===
--- test/Sema/arm64-inline-asm.c
+++ test/Sema/arm64-inline-asm.c
@@ -7,3 +7,9 @@
 
   asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not 
match register size specified by the constraint and modifier}} expected-note 
{{use constraint modifier "w"}}
 }
+
+void test_clobber_conflict(void) {
+  register long x asm("x1");
+  asm volatile("nop" :: "r"(x) : "%x1"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%x1"); // expected-error {{conflicts with 
asm clobber list}}
+}
Index: test/Sema/arm-asm.c
===
--- test/Sema/arm-asm.c
+++ test/Sema/arm-asm.c
@@ -10,3 +10,10 @@
   long long foo = 0, bar = 0;
   asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
 }
+
+void test_clobber_conflict(void) {
+  register int x asm("r1");
+  asm volatile("nop" :: "r"(x) : "%r1"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("nop" :: "l"(x) : "%r1"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%r1"); // expected-error {{conflicts with 
asm clobber list}}
+}
Index: lib/Basic/Targets/ARM.h
===
--- lib/Basic/Targets/ARM.h
+++ lib/Basic/Targets/ARM.h
@@ -155,6 +155,11 @@
  std::string &SuggestedModifier) const override;
   const char *getClobbers() const override;
 
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 
   int getEHDataRegisterNumber(unsigned RegNo) const override;
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -82,6 +82,11 @@
  std::string &SuggestedModifier) const override;
   const char *getClobbers() const override;
 
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+
   int getEHDataRegisterNumber(unsigned RegNo) const override;
 };
 
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -629,6 +629,12 @@
   StringRef getNormalizedGCCRegisterName(StringRef Name,
  bool ReturnCanonical = false) const;
 
+  /// \brief Extracts a register from the passed constraint (if it is a
+  /// single-register constraint) and the asm label expression related to a
+  /// variable in the input or output list of an inline asm statement.
+  ///
+  /// This function is used by Sema in order to diagnose conflicts between
+  /// the clobber list and the input/output lists.
   virtual StringRef getConstraintRegister(StringRef Constraint,
   StringRef Expression) const {
 return "";


Index: test/Sema/arm64-inline-asm.c
===
--- test/Sema/arm64-inline-asm.c
+++ test/Sema/arm64-inline-asm.c
@@ -7,3 +7,9 @@
 
   asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
 }
+
+void test_clobber_conflict(void) {
+  register long x asm("x1");
+  asm volatile("nop" :: "r"(x) : "%x1"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%x1"); // expected-error {{conflicts with asm clobber list}}
+}
Index: test/Sema/arm-asm.c
===
--- test/Sema/arm-asm.c
+++ test/Sema/arm-asm.c
@@ -10,3 +10,10 @@
   long long foo = 0, bar = 0;
   asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
 }
+
+void test_clobber_conflict(void) {
+  register int x asm("r1");
+  asm volatile("nop" :: "r"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("nop" :: "l"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%r1"); // expected-error {{conflicts with asm clobber list}}
+}
Index: lib/Basic/Targets/ARM.h
===
--- lib/Basic/Targets/ARM.h
+++ lib/Basic/Targets/ARM.h
@@ -155,6 +155,11 @@
  

r330717 - [CodeComplete] Fix completion at the end of keywords

2018-04-24 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Apr 24 06:48:53 2018
New Revision: 330717

URL: http://llvm.org/viewvc/llvm-project?rev=330717&view=rev
Log:
[CodeComplete] Fix completion at the end of keywords

Summary:
Make completion behave consistently no matter if it is run at the
start, in the middle or at the end of an identifier that happens to
be a keyword or a macro name. Since completion is often ran on
incomplete identifiers, they may turn into keywords by accident.

For example, we should produce same results for all of these
completion points:

// ^ is completion point.
^class
cla^ss
class^

Previously clang produced different results for the last case (as if
the completion point was after a space: `class ^`).

This change also updates some offsets in tests that (unintentionally?)
relied on the old behavior.

Reviewers: sammccall, bkramer, arphaman, aaron.ballman

Reviewed By: sammccall

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeCompletion/end-of-ident-macro.cpp
cfe/trunk/test/CodeCompletion/end-of-ident.cpp
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/CodeCompletion/macros.c
cfe/trunk/test/CodeCompletion/namespace.cpp
cfe/trunk/test/CodeCompletion/operator.cpp
cfe/trunk/test/CodeCompletion/tag.c
cfe/trunk/test/CodeCompletion/tag.cpp
cfe/trunk/test/CodeCompletion/using-namespace.cpp
cfe/trunk/test/CodeCompletion/using.cpp
cfe/trunk/test/Index/complete-exprs.c
cfe/trunk/test/Index/complete-preprocessor.m

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=330717&r1=330716&r2=330717&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Apr 24 06:48:53 2018
@@ -1645,20 +1645,24 @@ FinishIdentifier:
 // Fill in Result.IdentifierInfo and update the token kind,
 // looking up the identifier in the identifier table.
 IdentifierInfo *II = PP->LookUpIdentifierInfo(Result);
+// Note that we have to call PP->LookUpIdentifierInfo() even for code
+// completion, it writes IdentifierInfo into Result, and callers rely on 
it.
 
-// Finally, now that we know we have an identifier, pass this off to the
-// preprocessor, which may macro expand it or something.
-if (II->isHandleIdentifierCase())
-  return PP->HandleIdentifier(Result);
-
-if (II->getTokenID() == tok::identifier && isCodeCompletionPoint(CurPtr)
-&& II->getPPKeywordID() == tok::pp_not_keyword
-&& II->getObjCKeywordID() == tok::objc_not_keyword) {
+// If the completion point is at the end of an identifier, we want to treat
+// the identifier as incomplete even if it resolves to a macro or a 
keyword.
+// This allows e.g. 'class^' to complete to 'classifier'.
+if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
   cutOffLexing();
   return true;
 }
+
+// Finally, now that we know we have an identifier, pass this off to the
+// preprocessor, which may macro expand it or something.
+if (II->isHandleIdentifierCase())
+  return PP->HandleIdentifier(Result);
+
 return true;
   }
 

Added: cfe/trunk/test/CodeCompletion/end-of-ident-macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/end-of-ident-macro.cpp?rev=330717&view=auto
==
--- cfe/trunk/test/CodeCompletion/end-of-ident-macro.cpp (added)
+++ cfe/trunk/test/CodeCompletion/end-of-ident-macro.cpp Tue Apr 24 06:48:53 
2018
@@ -0,0 +1,16 @@
+#define FUNC(X) X
+#define FUNCTOR
+using FUNCTION = int();
+// We should get all three completions when the cursor is at the beginning,
+// middle, or end.
+FUNC(int) a = 10;
+// ^FUNC(int)
+// RUN: %clang_cc1 -code-completion-at=%s:6:1 -code-completion-macros %s | 
FileCheck %s
+// FU^NC(int)
+// RUN: %clang_cc1 -code-completion-at=%s:6:3 -code-completion-macros %s | 
FileCheck %s
+// FUNC^(int)
+// RUN: %clang_cc1 -code-completion-at=%s:6:5 -code-completion-macros %s | 
FileCheck %s
+
+// CHECK: COMPLETION: FUNC : FUNC(<#X#>)
+// CHECK: COMPLETION: FUNCTION : FUNCTION
+// CHECK: COMPLETION: FUNCTOR : FUNCTOR
\ No newline at end of file

Added: cfe/trunk/test/CodeCompletion/end-of-ident.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/end-of-ident.cpp?rev=330717&view=auto
==
--- cfe/trunk/test/CodeCompletion/end-of-ident.cpp (added)
+++ cfe/trunk/test/CodeCompletion/end-of-ident.cpp Tue Apr 24 06:48:53 2018
@@ -0,0 +1,20 @@
+class classifier {};
+// We should get all three completions when the cursor is at the beginning,
+// middle, or end.
+class cls
+// ^class cls
+// RUN: %clang_cc1 -code-completi

[PATCH] D45887: [CodeComplete] Fix completion at the end of keywords

2018-04-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330717: [CodeComplete] Fix completion at the end of keywords 
(authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45887?vs=143731&id=143733#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45887

Files:
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/test/CodeCompletion/end-of-ident-macro.cpp
  cfe/trunk/test/CodeCompletion/end-of-ident.cpp
  cfe/trunk/test/CodeCompletion/macros.c
  cfe/trunk/test/CodeCompletion/namespace.cpp
  cfe/trunk/test/CodeCompletion/operator.cpp
  cfe/trunk/test/CodeCompletion/tag.c
  cfe/trunk/test/CodeCompletion/tag.cpp
  cfe/trunk/test/CodeCompletion/using-namespace.cpp
  cfe/trunk/test/CodeCompletion/using.cpp
  cfe/trunk/test/Index/complete-exprs.c
  cfe/trunk/test/Index/complete-preprocessor.m

Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -1645,20 +1645,24 @@
 // Fill in Result.IdentifierInfo and update the token kind,
 // looking up the identifier in the identifier table.
 IdentifierInfo *II = PP->LookUpIdentifierInfo(Result);
+// Note that we have to call PP->LookUpIdentifierInfo() even for code
+// completion, it writes IdentifierInfo into Result, and callers rely on it.
 
-// Finally, now that we know we have an identifier, pass this off to the
-// preprocessor, which may macro expand it or something.
-if (II->isHandleIdentifierCase())
-  return PP->HandleIdentifier(Result);
-
-if (II->getTokenID() == tok::identifier && isCodeCompletionPoint(CurPtr)
-&& II->getPPKeywordID() == tok::pp_not_keyword
-&& II->getObjCKeywordID() == tok::objc_not_keyword) {
+// If the completion point is at the end of an identifier, we want to treat
+// the identifier as incomplete even if it resolves to a macro or a keyword.
+// This allows e.g. 'class^' to complete to 'classifier'.
+if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
   cutOffLexing();
   return true;
 }
+
+// Finally, now that we know we have an identifier, pass this off to the
+// preprocessor, which may macro expand it or something.
+if (II->isHandleIdentifierCase())
+  return PP->HandleIdentifier(Result);
+
 return true;
   }
 
Index: cfe/trunk/test/Index/complete-exprs.c
===
--- cfe/trunk/test/Index/complete-exprs.c
+++ cfe/trunk/test/Index/complete-exprs.c
@@ -24,15 +24,15 @@
   (type)f;
 }
 
-// RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
 // CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
 // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
 // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
 // CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: macro definition:{TypedText __VERSION__} (70)
Index: cfe/trunk/test/Index/complete-preprocessor.m
===
--- cfe/trunk/test/Index/complete-preprocessor.m
+++ cfe/trunk/test/Index/complete-preprocessor.m
@@ -13,7 +13,7 @@
 
 FOO(in,t) value;
 
-// RUN: c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s

[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-24 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added inline comments.



Comment at: lib/Basic/Targets/AArch64.h:85-89
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+

miyuki wrote:
> thopre wrote:
> > From what I understood of the original patch, getConstraintRegister is a 
> > sort of a more comprehensive version of convertRegister. On ARM 
> > convertRegister handles U and p constraint specially, should this do the 
> > same?
> Did you mean `convertConstraint`? As I understand, this function does 
> canonicalization of constraints. If a constraint happens to be 
> single-register, it is converted into `{register}` form (but this does not 
> happen on ARM). On the other hand, `getConstraintRegister` takes a constraint 
> and an asm label and converts them into a register (and in our case the 
> register always comes from the asm label, never from the constraint), so I 
> don't think we need to handle U and p specially.
Forgot to send this:

Fair enough. Since you seems to have the expected behavior of this function 
well understood, would you mind adding a comment here and in 
clang/Basic/TargetInfo.h?

Luckily we had a similar chat offline. Thanks for the change


https://reviews.llvm.org/D45965



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


[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-24 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

FWIW LGTM.


https://reviews.llvm.org/D45965



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


[PATCH] D45884: [Sema] Fix parsing of anonymous union in language linkage specification

2018-04-24 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 143736.
jkorous added a comment.

Addressed comments + proposal for refactoring of the namespace-related logic.


https://reviews.llvm.org/D45884

Files:
  Sema/SemaDecl.cpp
  SemaCXX/anonymous-union-export.cpp
  SemaCXX/anonymous-union.cpp


Index: SemaCXX/anonymous-union.cpp
===
--- SemaCXX/anonymous-union.cpp
+++ SemaCXX/anonymous-union.cpp
@@ -80,6 +80,10 @@
   float float_val;
 };
 
+extern "C++" {
+union { }; // expected-error{{anonymous unions at namespace or global scope 
must be declared 'static'}}
+}
+
 static union {
   int int_val2; // expected-note{{previous definition is here}}
   float float_val2;
Index: SemaCXX/anonymous-union-export.cpp
===
--- /dev/null
+++ SemaCXX/anonymous-union-export.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++17 -fmodules-ts -emit-obj -verify %s
+
+export module M;
+export {
+union { bool a; }; // expected-error{{anonymous unions at namespace or 
global scope must be declared 'static'}}
+}
Index: Sema/SemaDecl.cpp
===
--- Sema/SemaDecl.cpp
+++ Sema/SemaDecl.cpp
@@ -4645,12 +4645,16 @@
 unsigned DiagID;
 if (Record->isUnion()) {
   // C++ [class.union]p6:
+  // C++17 [class.union.anon]p2:
   //   Anonymous unions declared in a named namespace or in the
   //   global namespace shall be declared static.
+
+  DeclContext *OwnerScope = Owner->getRedeclContext();
+
   if (DS.getStorageClassSpec() != DeclSpec::SCS_static &&
-  (isa(Owner) ||
-   (isa(Owner) &&
-cast(Owner)->getDeclName( {
+  (OwnerScope->isTranslationUnit() ||
+   (OwnerScope->isNamespace() &&
+!cast(OwnerScope)->isAnonymousNamespace( {
 Diag(Record->getLocation(), diag::err_anonymous_union_not_static)
   << FixItHint::CreateInsertion(Record->getLocation(), "static ");
 


Index: SemaCXX/anonymous-union.cpp
===
--- SemaCXX/anonymous-union.cpp
+++ SemaCXX/anonymous-union.cpp
@@ -80,6 +80,10 @@
   float float_val;
 };
 
+extern "C++" {
+union { }; // expected-error{{anonymous unions at namespace or global scope must be declared 'static'}}
+}
+
 static union {
   int int_val2; // expected-note{{previous definition is here}}
   float float_val2;
Index: SemaCXX/anonymous-union-export.cpp
===
--- /dev/null
+++ SemaCXX/anonymous-union-export.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++17 -fmodules-ts -emit-obj -verify %s
+
+export module M;
+export {
+union { bool a; }; // expected-error{{anonymous unions at namespace or global scope must be declared 'static'}}
+}
Index: Sema/SemaDecl.cpp
===
--- Sema/SemaDecl.cpp
+++ Sema/SemaDecl.cpp
@@ -4645,12 +4645,16 @@
 unsigned DiagID;
 if (Record->isUnion()) {
   // C++ [class.union]p6:
+  // C++17 [class.union.anon]p2:
   //   Anonymous unions declared in a named namespace or in the
   //   global namespace shall be declared static.
+
+  DeclContext *OwnerScope = Owner->getRedeclContext();
+
   if (DS.getStorageClassSpec() != DeclSpec::SCS_static &&
-  (isa(Owner) ||
-   (isa(Owner) &&
-cast(Owner)->getDeclName( {
+  (OwnerScope->isTranslationUnit() ||
+   (OwnerScope->isNamespace() &&
+!cast(OwnerScope)->isAnonymousNamespace( {
 Diag(Record->getLocation(), diag::err_anonymous_union_not_static)
   << FixItHint::CreateInsertion(Record->getLocation(), "static ");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-24 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik marked 3 inline comments as done.
nik added a comment.

In https://reviews.llvm.org/D45815#1076434, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D45815#1073581, @nik wrote:
>
> > Hmm, that indicates that template function bodies are actually not that
> >  dominant, which I also haven't thought. Now I'm doubting the correctness of
> >  my patch/tests.
>
>
> The numbers are definitely interesting, we need to double-check if that it's 
> the case. But they definitely make a good point for including this option.
>  It seems Qt and LLVM are exactly the types of codebases where skipping the 
> templates doesn't bring much value, as most of the code is not templated. On 
> the other hand, skipping inline function might potentially be a win for those.
>
> I'm still tempted to say that we should either skip all bodies or none of 
> them to keep the code simpler, but I see why having errors from template 
> instantiations is preferable.


OK, I've rechecked this change. I don't see any obvious mistake :)

In my previous tests/timings I had some modifications to the clang command line 
applied (extra diagnostics enabled with -Weverything and maybe others, using 
-isystem instead of -I). I've reverted these and made some runs/timings with 
only "-Wall -Wextra" (https://dpaste.de/cZgZ/raw) - The difference between 
skip-all-in-preamble and skip-only-non-template-in-preamble becomes even 
smaller now for Qt Creator's texteditor.cpp.




Comment at: include/clang/Frontend/ASTUnit.h:679
+  struct SkipFunctionBodiesOptions {
+SkipFunctionBodiesOptions() {}
+enum { None, MainFileAndPreamble, Preamble } Scope = None;

ilya-biryukov wrote:
> Default ctor will be generated automatically. Maybe remove explicit 
> definition?
The explicit definition is needed to workaround 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58328 
("SkipFunctionBodiesOptions()" is used as default value in some function 
signatures)



Comment at: include/clang/Frontend/ASTUnit.h:679
+  struct SkipFunctionBodiesOptions {
+SkipFunctionBodiesOptions() {}
+enum { None, MainFileAndPreamble, Preamble } Scope = None;

yvvan wrote:
> nik wrote:
> > ilya-biryukov wrote:
> > > Default ctor will be generated automatically. Maybe remove explicit 
> > > definition?
> > The explicit definition is needed to workaround 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58328 
> > ("SkipFunctionBodiesOptions()" is used as default value in some function 
> > signatures)
> or replace by constructor with parameters
That would not really help in this case.



Comment at: include/clang/Frontend/FrontendOptions.h:302
 
+  SkipFunctionBodiesKind SkipFunctionBodies;
+

ilya-biryukov wrote:
> Maybe add a comment to match the code style of other options?
No comment here is in line with "CodeCompleteOptions CodeCompleteOpts" below. 
That one has also its comments at definition. Also, I can't come up with a 
comment that adds more value than the name itself and that does not duplicate 
the comment from SkipFunctionBodies.h.




Comment at: lib/Frontend/ASTUnit.cpp:1662
+{
+  SkipFunctionBodiesModifierRAII m(Invocation->getFrontendOpts(),
+   SkipFunctionBodiesOpts);

ilya-biryukov wrote:
> Maybe use LLVM's `make_scope_exit` from `ADT/ScopeExit.h` instead of creating 
> a separate RAII class?
> Or even directy set/restore the value of the flag right in the function.
> Given that LLVM does not use exceptions, RAII class does not seem to buy much 
> in terms of correctness and doesn't really make the code easier to read, IMO.
> 
> But up to you.
I've added the RAII class solely to minimize duplication. Now I'm just passing 
the flags to getMainBufferWithPrecompiledPreamble() and set/reset there 
directly.



Comment at: lib/Parse/Parser.cpp:1107
 
+  bool SkipFunctionBodyRequested = false;
+  switch (SkipFunctionBodies) {

ilya-biryukov wrote:
> `Requested` in this name is a bit confusing, e.g. it's not clear who 
> requested it.
> Maybe rename to `TrySkipFunctionBody` or something similar?
TrySkipFunctionBody somewhat collides with the function 
trySkippingFunctionBody(). I'm using "ShouldSkipFunctionBody" now.


Repository:
  rC Clang

https://reviews.llvm.org/D45815



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


[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-24 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik updated this revision to Diff 143738.
nik marked 2 inline comments as done.
nik added a comment.
Herald added a subscriber: eraman.

Addressed inline comments.


Repository:
  rC Clang

https://reviews.llvm.org/D45815

Files:
  include/clang-c/Index.h
  include/clang/Frontend/ASTUnit.h
  include/clang/Frontend/FrontendOptions.h
  include/clang/Frontend/SkipFunctionBodies.h
  include/clang/Parse/ParseAST.h
  include/clang/Parse/Parser.h
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseAST.cpp
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/Parser.cpp
  test/Parser/skip-function-bodies.h
  test/Parser/skip-function-bodies.mm
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/Indexing.cpp
  unittests/CodeGen/BufferSourceTest.cpp
  unittests/CodeGen/CodeGenExternalTest.cpp
  unittests/CodeGen/IncrementalProcessingTest.cpp
  unittests/CodeGen/TBAAMetadataTest.cpp
  unittests/Frontend/PCHPreambleTest.cpp
  unittests/Lex/PPCallbacksTest.cpp
  unittests/Tooling/ToolingTest.cpp

Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -250,7 +250,7 @@
 struct SkipBodyAction : public clang::ASTFrontendAction {
   std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
  StringRef) override {
-Compiler.getFrontendOpts().SkipFunctionBodies = true;
+Compiler.getFrontendOpts().SkipFunctionBodies = SkipFunctionBodiesKind::All;
 return llvm::make_unique();
   }
 };
Index: unittests/Lex/PPCallbacksTest.cpp
===
--- unittests/Lex/PPCallbacksTest.cpp
+++ unittests/Lex/PPCallbacksTest.cpp
@@ -201,7 +201,7 @@
 
 ASTConsumer Consumer;
 Sema S(PP, Context, Consumer);
-Parser P(PP, S, false);
+Parser P(PP, S, SkipFunctionBodiesKind::None);
 PragmaOpenCLExtensionCallbacks* Callbacks = new PragmaOpenCLExtensionCallbacks;
 PP.addPPCallbacks(std::unique_ptr(Callbacks));
 
Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -103,7 +103,9 @@
   }
 
   bool ReparseAST(const std::unique_ptr &AST) {
-bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), VFS);
+bool reparseFailed =
+AST->Reparse(PCHContainerOpts, GetRemappedFiles(),
+ ASTUnit::SkipFunctionBodiesOptions(), VFS);
 return !reparseFailed;
   }
 
Index: unittests/CodeGen/TBAAMetadataTest.cpp
===
--- unittests/CodeGen/TBAAMetadataTest.cpp
+++ unittests/CodeGen/TBAAMetadataTest.cpp
@@ -73,7 +73,7 @@
   }
 
   const BasicBlock *compile() {
-clang::ParseAST(compiler.getSema(), false, false);
+clang::ParseAST(compiler.getSema(), false, clang::SkipFunctionBodiesKind::None);
 M = CG->GetModule();
 
 // Do not expect more than one function definition.
Index: unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- unittests/CodeGen/IncrementalProcessingTest.cpp
+++ unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -143,7 +143,7 @@
 Sema& S = compiler.getSema();
 
 std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S,
-   /*SkipFunctionBodies*/ false));
+   SkipFunctionBodiesKind::None));
 Parser &P = *ParseOP.get();
 
 std::array, 3> M;
Index: unittests/CodeGen/CodeGenExternalTest.cpp
===
--- unittests/CodeGen/CodeGenExternalTest.cpp
+++ unittests/CodeGen/CodeGenExternalTest.cpp
@@ -294,7 +294,7 @@
 sm.setMainFileID(sm.createFileID(
 llvm::MemoryBuffer::getMemBuffer(TestProgram), clang::SrcMgr::C_User));
 
-clang::ParseAST(compiler.getSema(), false, false);
+clang::ParseAST(compiler.getSema(), false, clang::SkipFunctionBodiesKind::None);
 
 ASSERT_TRUE(test_codegen_fns_ran);
 }
Index: unittests/CodeGen/BufferSourceTest.cpp
===
--- unittests/CodeGen/BufferSourceTest.cpp
+++ unittests/CodeGen/BufferSourceTest.cpp
@@ -74,7 +74,7 @@
 sm.setMainFileID(sm.createFileID(
 llvm::MemoryBuffer::getMemBuffer(TestProgram), clang::SrcMgr::C_User));
 
-clang::ParseAST(compiler.getSema(), false, false);
+clang::ParseAST(compiler.getSema(), false, clang::SkipFunctionBodiesKind::None);
 }
 
 } // end anonymous namespace
Index: tools/libclang/Indexing.cpp
===
--- tools/libclang/Indexing.cpp
+++ tools/libclang/Indexing.cpp
@@ -540,7 +540,7 @@
   bool SkipBodies = (index_options & CXInde

[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-24 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre accepted this revision.
thopre added a comment.
This revision is now accepted and ready to land.

As I said, LGTM. Please wait a few days (say next Monday) in case anyone else 
has any objection.


https://reviews.llvm.org/D45965



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


[clang-tools-extra] r330719 - [clang-tidy] Fix PR35468

2018-04-24 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Apr 24 07:45:58 2018
New Revision: 330719

URL: http://llvm.org/viewvc/llvm-project?rev=330719&view=rev
Log:
[clang-tidy] Fix PR35468

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

Added:

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp?rev=330719&r1=330718&r2=330719&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
Tue Apr 24 07:45:58 2018
@@ -24,9 +24,9 @@ void UnconventionalAssignOperatorCheck::
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
+  const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType(
+  pointee(unless(isConstQualified()),
+  anyOf(autoType(), hasDeclaration(equalsBoundNode("class")));
 
   const auto IsSelf = qualType(
   anyOf(hasDeclaration(equalsBoundNode("class")),

Added: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp?rev=330719&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
 Tue Apr 24 07:45:58 2018
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++17 -fno-delayed-template-parsing
+
+struct BadModifier {
+  BadModifier& operator=(const BadModifier&) const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 
'const'
+};
+
+struct PR35468 {
+  template auto &operator=(const T &) {
+return *this;
+  }
+};


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


[PATCH] D46003: [clang-tidy] Fix PR35468

2018-04-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330719: [clang-tidy] Fix PR35468 (authored by xazax, 
committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D46003?vs=143712&id=143743#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46003

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -24,9 +24,9 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
+  const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType(
+  pointee(unless(isConstQualified()),
+  anyOf(autoType(), hasDeclaration(equalsBoundNode("class")));
 
   const auto IsSelf = qualType(
   anyOf(hasDeclaration(equalsBoundNode("class")),
Index: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++17 -fno-delayed-template-parsing
+
+struct BadModifier {
+  BadModifier& operator=(const BadModifier&) const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 
'const'
+};
+
+struct PR35468 {
+  template auto &operator=(const T &) {
+return *this;
+  }
+};


Index: clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -24,9 +24,9 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
+  const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType(
+  pointee(unless(isConstQualified()),
+  anyOf(autoType(), hasDeclaration(equalsBoundNode("class")));
 
   const auto IsSelf = qualType(
   anyOf(hasDeclaration(equalsBoundNode("class")),
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++17 -fno-delayed-template-parsing
+
+struct BadModifier {
+  BadModifier& operator=(const BadModifier&) const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const'
+};
+
+struct PR35468 {
+  template auto &operator=(const T &) {
+return *this;
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330721 - [OpenCL] Fix diagnostic of thread_local

2018-04-24 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Apr 24 07:47:29 2018
New Revision: 330721

URL: http://llvm.org/viewvc/llvm-project?rev=330721&view=rev
Log:
[OpenCL] Fix diagnostic of thread_local

Commit 08c258670c ("[OpenCL] Generic address space has been added in
OpenCL v2.0.", 2014-11-26) did not mark the thread_local keyword as a
storage class specifier, whereas it did mark _Thread_local as such.
According to the C++14 spec s7.1.1, thread_local is a storage class
specifier, so mark it as such.

I will add a test for this in a follow-up commit that adds keyword
restrictions to the OpenCL C++ language mode.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=330721&r1=330720&r2=330721&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Apr 24 07:47:29 2018
@@ -3454,6 +3454,7 @@ void Parser::ParseDeclarationSpecifiers(
 case tok::kw_thread_local:
   isInvalid = DS.SetStorageClassSpecThread(DeclSpec::TSCS_thread_local, 
Loc,
PrevSpec, DiagID);
+  isStorageClass = true;
   break;
 case tok::kw__Thread_local:
   isInvalid = DS.SetStorageClassSpecThread(DeclSpec::TSCS__Thread_local,


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


[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes

2018-04-24 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

ping.


Repository:
  rC Clang

https://reviews.llvm.org/D42966



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


r330722 - [Attr] Print enum attributes at correct position

2018-04-24 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Apr 24 07:50:23 2018
New Revision: 330722

URL: http://llvm.org/viewvc/llvm-project?rev=330722&view=rev
Log:
[Attr] Print enum attributes at correct position

For example, given:

  void fn() {
enum __attribute__((deprecated)) T *p;
  }

-ast-print produced:

  void fn() {
enum T __attribute__((deprecated(""))) *p;
  }

-ast-print on that produced:

  void fn() {
enum T *p __attribute__((deprecated("")));
  }

The attribute is on enum T in the first case, but it's on p in the
other cases.

Details:

Within enum declarations, enum attributes were always printed after
the tag and any member list.  When no member list was present but the
enum was a type specifier in a variable declaration, the attribute
then applied to the variable not the enum, changing the semantics.

This patch fixes that by always printing attributes between the enum's
keyword and tag, as clang already does for structs, unions, and
classes.

Reviewed By: rsmith

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Sema/ast-print.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=330722&r1=330721&r2=330722&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Apr 24 07:50:23 2018
@@ -496,14 +496,17 @@ void DeclPrinter::VisitTypeAliasDecl(Typ
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-  Out << "class ";
+  Out << " class";
 else
-  Out << "struct ";
+  Out << " struct";
   }
-  Out << *D;
+
+  prettyPrintAttributes(D);
+
+  Out << ' ' << *D;
 
   if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
 Out << " : " << D->getIntegerType().stream(Policy);
@@ -513,7 +516,6 @@ void DeclPrinter::VisitEnumDecl(EnumDecl
 VisitDeclContext(D);
 Indent() << "}";
   }
-  prettyPrintAttributes(D);
 }
 
 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {

Modified: cfe/trunk/test/Sema/ast-print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=330722&r1=330721&r2=330722&view=diff
==
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Tue Apr 24 07:50:23 2018
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
 
 typedef void func_typedef();
 func_typedef xxx;
@@ -58,7 +65,7 @@ struct pair_t {
 };
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style 
field designator extension}}
 
 void initializers() {
   // CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -70,11 +77,30 @@ void initializers() {
   } z = {(struct Z){}};
 }
 
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is 
deprecated}}
   // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+  // CHECK-NEXT: };
+  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// FIXME: If enum is forward-declared at file scope, attributes are lost.
+// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *E

[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2018-04-24 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho marked an inline comment as done.
mikhail.ramalho added a comment.

ping.




Comment at: unittests/Tooling/QualTypeNamesTest.cpp:225
+
+  TypeNameVisitor PrintingPolicy;
+  PrintingPolicy.ExpectedQualTypeNames["a"] = "short";

rnk wrote:
> Please choose a different variable name that doesn't clash with the 
> PrintingPolicy type.
Done.


https://reviews.llvm.org/D36610



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


[PATCH] D45456: [Attr] Print enum attributes at correct position

2018-04-24 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Thanks.


https://reviews.llvm.org/D45456



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


[PATCH] D45456: [Attr] Print enum attributes at correct position

2018-04-24 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330722: [Attr] Print enum attributes at correct position 
(authored by jdenny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45456?vs=142672&id=143745#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45456

Files:
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/test/Sema/ast-print.c


Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -496,14 +496,17 @@
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-  Out << "class ";
+  Out << " class";
 else
-  Out << "struct ";
+  Out << " struct";
   }
-  Out << *D;
+
+  prettyPrintAttributes(D);
+
+  Out << ' ' << *D;
 
   if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
 Out << " : " << D->getIntegerType().stream(Policy);
@@ -513,7 +516,6 @@
 VisitDeclContext(D);
 Indent() << "}";
   }
-  prettyPrintAttributes(D);
 }
 
 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {
Index: cfe/trunk/test/Sema/ast-print.c
===
--- cfe/trunk/test/Sema/ast-print.c
+++ cfe/trunk/test/Sema/ast-print.c
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
 
 typedef void func_typedef();
 func_typedef xxx;
@@ -58,7 +65,7 @@
 };
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style 
field designator extension}}
 
 void initializers() {
   // CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -70,11 +77,30 @@
   } z = {(struct Z){}};
 }
 
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is 
deprecated}}
   // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+  // CHECK-NEXT: };
+  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// FIXME: If enum is forward-declared at file scope, attributes are lost.
+// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
+
+// CHECK-LABEL: EnumWithAttributes3Fn
+void EnumWithAttributes3Fn() {
+  // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 
*EnumWithAttributes3Ptr;
+  // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}
+  // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked 
deprecated here}}
+  enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;
+  // Printing must not put the attribute after the tag where it would apply to
+  // the variable instead of the type, and then our deprecation warning would
+  // move to this use of the variable.
+  void *p = EnumWithAttributes3Ptr;
+}


Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -496,14 +496,17 @@
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-

[PATCH] D45456: [Attr] Print enum attributes at correct position

2018-04-24 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330722: [Attr] Print enum attributes at correct position 
(authored by jdenny, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D45456

Files:
  lib/AST/DeclPrinter.cpp
  test/Sema/ast-print.c


Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
 
 typedef void func_typedef();
 func_typedef xxx;
@@ -58,7 +65,7 @@
 };
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style 
field designator extension}}
 
 void initializers() {
   // CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -70,11 +77,30 @@
   } z = {(struct Z){}};
 }
 
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is 
deprecated}}
   // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+  // CHECK-NEXT: };
+  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// FIXME: If enum is forward-declared at file scope, attributes are lost.
+// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
+
+// CHECK-LABEL: EnumWithAttributes3Fn
+void EnumWithAttributes3Fn() {
+  // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 
*EnumWithAttributes3Ptr;
+  // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}
+  // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked 
deprecated here}}
+  enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;
+  // Printing must not put the attribute after the tag where it would apply to
+  // the variable instead of the type, and then our deprecation warning would
+  // move to this use of the variable.
+  void *p = EnumWithAttributes3Ptr;
+}
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -496,14 +496,17 @@
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-  Out << "class ";
+  Out << " class";
 else
-  Out << "struct ";
+  Out << " struct";
   }
-  Out << *D;
+
+  prettyPrintAttributes(D);
+
+  Out << ' ' << *D;
 
   if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
 Out << " : " << D->getIntegerType().stream(Policy);
@@ -513,7 +516,6 @@
 VisitDeclContext(D);
 Indent() << "}";
   }
-  prettyPrintAttributes(D);
 }
 
 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {


Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been explicitly marked d

[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments

2018-04-24 Thread Momchil Velikov via Phabricator via cfe-commits
chill created this revision.
chill added reviewers: john.brawn, olista01, eli.friedman, rengolin.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

The "Procedure Call Procedure Call Standard for the ARM®  Architecture" 
(https://static.docs.arm.com/ihi0042/f/IHI0042F_aapcs.pdf), specifies that 
composite types are passed  according to their natural alignment:

> 5.5 Parameter Passing
>  ...
>  B.5 If the argument is an alignment adjusted type its value is passed as a 
> copy of the actual value. The
>  copy will have an alignment defined as follows.
> 
> - For a Fundamental Data Type, the alignment is the natural alignment of that 
> type, after any promotions
> - For a Composite Type, the alignment of the copy will have 4-byte alignment 
> if its natural alignment is <= 4 and 8-byte alignment if its natural 
> alignment is >= 8

The "natural alignment" is defined as the maximum of the alignment of the 
top-level components:

> 4.3 Composite Types
>  ...
> 
> - The natural alignment of a composite type is the maximum of each of the 
> member alignments of the 'top-level' members of the composite type i.e. 
> before any alignment adjustment of the entire composite is applied

`clang`,  however, uses the actual alignment of the composite, instead of the 
natural alignment.

This patch fixes passing of composite types to use the natural alignment.  With 
this patch `clang` conforms to AAPCS and is compatible with GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D46013

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecordLayout.h
  lib/AST/ASTContext.cpp
  lib/AST/RecordLayout.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/aapcs-align.cc
  test/CodeGen/arm-arguments.c

Index: test/CodeGen/arm-arguments.c
===
--- test/CodeGen/arm-arguments.c
+++ test/CodeGen/arm-arguments.c
@@ -211,10 +211,13 @@
 // APCS-GNU: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align {{[0-9]+}} %[[b]], i8* align {{[0-9]+}} %[[c]]
 // APCS-GNU: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
 // APCS-GNU: load <4 x float>, <4 x float>* %[[d]], align 16
-// AAPCS-LABEL: define arm_aapcscc <4 x float> @f35(i32 %i, %struct.s35* byval align 8, %struct.s35* byval align 8)
-// AAPCS: %[[a:.*]] = alloca %struct.s35, align 16
-// AAPCS: %[[b:.*]] = bitcast %struct.s35* %[[a]] to i8*
-// AAPCS: %[[c:.*]] = bitcast %struct.s35* %0 to i8*
-// AAPCS: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %[[b]], i8* align 8 %[[c]]
-// AAPCS: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
-// AAPCS: load <4 x float>, <4 x float>* %[[d]], align 16
+
+// AAPCS-LABEL: define arm_aapcscc <4 x float> @f35(i32 %i, %struct.s35* byval align 4 %s1, %struct.s35* byval align 4 %s2)
+// AAPCS: %[[a_addr:.*]] = alloca <4 x float>, align 16
+// AAPCS: %[[b_addr:.*]] = alloca <4 x float>, align 16
+// AAPCS: %[[p1:.*]] = bitcast %struct.s35* %s1 to <4 x float>*
+// AAPCS: %[[a:.*]] = load <4 x float>, <4 x float>* %[[p1]], align 4
+// AAPCS: %[[p2:.*]] = bitcast %struct.s35* %s2 to <4 x float>*
+// AAPCS: %[[b:.*]] = load <4 x float>, <4 x float>* %[[p2]], align 4
+// AAPCS: store <4 x float> %[[a]], <4 x float>* %[[a_addr]], align 16
+// AAPCS: store <4 x float> %[[b]], <4 x float>* %[[b_addr]], align 16
Index: test/CodeGen/aapcs-align.cc
===
--- /dev/null
+++ test/CodeGen/aapcs-align.cc
@@ -0,0 +1,102 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple arm-none-none-eabi \
+// RUN:   -O2 \
+// RUN:   -target-cpu cortex-a8 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+extern "C" {
+
+struct S {
+  int x, y;
+};
+
+// Base case, nothing interesting.
+void f0(int, S);
+void f0m(int, int, int, int, int, S);
+void g0() {
+  S s = {6, 7};
+  f0(1, s);
+  f0m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g0
+// CHECK: call void @f0{{.*}}[2 x i32] [i32 6, i32 7]
+// CHECK: call void @f0m{{.*}}[2 x i32] [i32 6, i32 7]
+// CHECK: declare void @f0(i32, [2 x i32])
+// CHECK: declare void @f0m(i32, i32, i32, i32, i32, [2 x i32])
+
+// Aligned struct, passed according to its natural alignment.
+struct __attribute__((aligned(8))) S8 {
+  int x, y;
+} s8;
+
+void f1(int, S8);
+void f1m(int, int, int, int, int, S8 s);
+void g1() {
+  S8 s = {6, 7};
+  f1(1, s);
+  f1m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g1
+// CHECK: call void @f1{{.*}}[2 x i32] [i32 6, i32 7]
+// CHECK: call void @f1m{{.*}}[2 x i32] [i32 6, i32 7]
+// CHECK: declare void @f1(i32, [2 x i32])
+// CHECK: declare void @f1m(i32, i32, i32, i32, i32, [2 x i32])
+
+// Aligned struct, passed according to its natural alignment.
+struct alignas(16) S16 {
+  int x, y;
+};
+
+extern "C" void f2(int, S16);
+extern "C" void f2m(int, int, int, int, int, S16);
+
+void g2() {
+  S16 s = {6, 7};
+  f2(1, s);
+  f2m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g2
+// CHECK: c

[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching

2018-04-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


https://reviews.llvm.org/D44984



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


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-24 Thread Stuart Brady via Phabricator via cfe-commits
stuart created this revision.
stuart added reviewers: Anastasia, yaxunl.
Herald added a subscriber: cfe-commits.

SPIR-V encodes the read_only and write_only access qualifiers of pipes,
so separate LLVM IR types are required to target SPIR-V.  Other backends
may also find this useful.

These new types are opencl.pipe_ro_t and opencl.pipe_wo_t, which replace
opencl.pipe_t.

This replaces __get_pipe_num_packets(...) and __get_pipe_max_packets(...)
which took a read_only pipe with separate versions for read_only and
write_only pipes, namely:

- __get_pipe_num_packets_ro(...)
- __get_pipe_num_packets_wo(...)
- __get_pipe_max_packets_ro(...)
- __get_pipe_max_packets_wo(...)


Repository:
  rC Clang

https://reviews.llvm.org/D46015

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/pipe_builtin.cl
  test/CodeGenOpenCL/pipe_types.cl
  test/Index/pipe-size.cl

Index: test/Index/pipe-size.cl
===
--- test/Index/pipe-size.cl
+++ test/Index/pipe-size.cl
@@ -5,12 +5,12 @@
 __kernel void testPipe( pipe int test )
 {
 int s = sizeof(test);
-// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store %opencl.pipe_ro_t* %test, %opencl.pipe_ro_t** %test.addr, align 8
 // X86: store i32 8, i32* %s, align 4
-// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)** %test.addr, align 4
 // SPIR: store i32 4, i32* %s, align 4
-// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)** %test.addr, align 8
 // SPIR64: store i32 8, i32* %s, align 4
-// AMDGCN: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)* addrspace(5)* %test.addr, align 8
+// AMDGCN: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)* addrspace(5)* %test.addr, align 8
 // AMDGCN: store i32 8, i32 addrspace(5)* %s, align 4
 }
Index: test/CodeGenOpenCL/pipe_types.cl
===
--- test/CodeGenOpenCL/pipe_types.cl
+++ test/CodeGenOpenCL/pipe_types.cl
@@ -1,34 +1,35 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
 
-// CHECK: %opencl.pipe_t = type opaque
+// CHECK: %opencl.pipe_ro_t = type opaque
+// CHECK: %opencl.pipe_wo_t = type opaque
 typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
 typedef int __attribute__((ext_vector_type(4))) int4;
 
 void test1(read_only pipe int p) {
-// CHECK: define void @test1(%opencl.pipe_t* %p)
+// CHECK: define void @test1(%opencl.pipe_ro_t* %p)
   reserve_id_t rid;
 // CHECK: %rid = alloca %opencl.reserve_id_t
 }
 
 void test2(write_only pipe float p) {
-// CHECK: define void @test2(%opencl.pipe_t* %p)
+// CHECK: define void @test2(%opencl.pipe_wo_t* %p)
 }
 
 void test3(read_only pipe const int p) {
-// CHECK: define void @test3(%opencl.pipe_t* %p)
+// CHECK: define void @test3(%opencl.pipe_ro_t* %p)
 }
 
 void test4(read_only pipe uchar3 p) {
-// CHECK: define void @test4(%opencl.pipe_t* %p)
+// CHECK: define void @test4(%opencl.pipe_ro_t* %p)
 }
 
 void test5(read_only pipe int4 p) {
-// CHECK: define void @test5(%opencl.pipe_t* %p)
+// CHECK: define void @test5(%opencl.pipe_ro_t* %p)
 }
 
 typedef read_only pipe int MyPipe;
 kernel void test6(MyPipe p) {
-// CHECK: define spir_kernel void @test6(%opencl.pipe_t* %p)
+// CHECK: define spir_kernel void @test6(%opencl.pipe_ro_t* %p)
 }
 
 struct Person {
@@ -41,7 +42,7 @@
  read_only pipe struct Person SPipe) {
 // CHECK: define void @test_reserved_read_pipe
   read_pipe (SPipe, SDst);
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
   read_pipe (SPipe, SDst);
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
 }
Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -1,79 +1,93 @@
 // RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
 
-// CHECK: %opencl.pipe_t = type opaque
-// CHECK: %opencl.reserve_id_t = type opaque
+// CHECK-DAG: %opencl.pipe_ro_t = type opaque
+// CHECK-DAG: %opencl.pipe_wo_t = type opaque
+// CHECK-DAG: %opencl.reserve_id_t = type opaque
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
 
 void test

[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching

2018-04-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Otherwise LGTM.




Comment at: lib/CodeGen/CGCUDANV.cpp:51-52
   llvm::Constant *getLaunchFn() const;
+  std::string addPrefixToName(CodeGenModule &CGM, StringRef FuncName) const;
+  std::string addUnderscoredPrefixToName(CodeGenModule &CGM,
+ StringRef FuncName) const;

tra wrote:
> `const CodeGenModule &CGM`
Why doesn't the CGNVCUDARuntime just hold on to a reference to the CGM?  That's 
what we do with all the other separated singletons (like the CGCXXABI), and it 
would let you avoid some of the redundant fields like Context and TheModule.


https://reviews.llvm.org/D44984



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


[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D42966#1069674, @mikhail.ramalho wrote:

> Sure. Basically, the previous code would not generate the USR for the 
> function's parameters.
>
> The issue was that SM.getFileEntryForID would return NULL because there is no 
> actual file, that's why I changed to get the presumedLoc and build the name 
> using the column/line.
>
> I know that using column/line not the preferable method to generate USR but I 
> couldn't find a way to generate the offset of a presumed location.





Repository:
  rC Clang

https://reviews.llvm.org/D42966



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


[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes

2018-04-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry for the delay.

In https://reviews.llvm.org/D42966#1069674, @mikhail.ramalho wrote:

> Sure. Basically, the previous code would not generate the USR for the 
> function's parameters. 
>  The issue was that SM.getFileEntryForID would return NULL because there is 
> no actual file


Why wasn't there a file for function parameter? Function parameters *are* 
declared in some file, or am I missing something?

More general question is: how do we want USRs for function parameters to work, 
specifically should USR of the same param of different declarations be the same 
or different?


Repository:
  rC Clang

https://reviews.llvm.org/D42966



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D44882#1066743, @malaperle wrote:

> In https://reviews.llvm.org/D44882#1065632, @sammccall wrote:
>
> > In https://reviews.llvm.org/D44882#1065631, @malaperle wrote:
> >
> > > In https://reviews.llvm.org/D44882#1065622, @sammccall wrote:
> > >
> > > > Still LG, thanks!
> > > >  I'll look into the testing issue.
> > >
> > >
> > > I thought about it after... I think it was because I was trying to test 
> > > with std::unordered_map (to prevent multiple results) which needs 
> > > std=c++11, I'll try with something else.
> >
> >
> > Worth a shot, but don't count on it - for c++ clang switched to using 
> > std=c++11 by default a while ago.
>
>
> I just tried "std::basic_ostringstream" and that works. Seems safer.


So this fails if there's no standard library available without flags, which is 
the case in google's test environment to ensure hermeticity :-(

In the short-term, we've disabled the test internally - did it trigger any 
buildbot failures?
In the medium term we should probably find a better way to test this :(


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D45470: Emit an error when mixing and

2018-04-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: clang/test/Headers/stdatomic.cpp:4
+
+#include 
+

Is there a reason we want to test this twice - once in clang and once in libc++?
We can use `expected-error` in libc++ tests to check the error.



https://reviews.llvm.org/D45470



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


[PATCH] D46019: [ASTImporter] Fix isa cast assert

2018-04-24 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, xazax.hun, szepet.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

Do early return if we can't import the found decl for a member expr.
This follows the pre-existing scheme, e.g with E->getMemberDecl().


Repository:
  rC Clang

https://reviews.llvm.org/D46019

Files:
  lib/AST/ASTImporter.cpp


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -6085,9 +6085,13 @@
   if (!ToMember && E->getMemberDecl())
 return nullptr;
 
-  DeclAccessPair ToFoundDecl = DeclAccessPair::make(
-dyn_cast(Importer.Import(E->getFoundDecl().getDecl())),
-E->getFoundDecl().getAccess());
+  auto *ToDecl =
+  
dyn_cast_or_null(Importer.Import(E->getFoundDecl().getDecl()));
+  if (!ToDecl && E->getFoundDecl().getDecl())
+return nullptr;
+
+  DeclAccessPair ToFoundDecl =
+  DeclAccessPair::make(ToDecl, E->getFoundDecl().getAccess());
 
   DeclarationNameInfo ToMemberNameInfo(
 Importer.Import(E->getMemberNameInfo().getName()),


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -6085,9 +6085,13 @@
   if (!ToMember && E->getMemberDecl())
 return nullptr;
 
-  DeclAccessPair ToFoundDecl = DeclAccessPair::make(
-dyn_cast(Importer.Import(E->getFoundDecl().getDecl())),
-E->getFoundDecl().getAccess());
+  auto *ToDecl =
+  dyn_cast_or_null(Importer.Import(E->getFoundDecl().getDecl()));
+  if (!ToDecl && E->getFoundDecl().getDecl())
+return nullptr;
+
+  DeclAccessPair ToFoundDecl =
+  DeclAccessPair::make(ToDecl, E->getFoundDecl().getAccess());
 
   DeclarationNameInfo ToMemberNameInfo(
 Importer.Import(E->getMemberNameInfo().getName()),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2018-04-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.

Please move the tests into test/std and commit.


https://reviews.llvm.org/D34331



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-24 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D44882#1076864, @sammccall wrote:

> So this fails if there's no standard library available without flags, which 
> is the case in google's test environment to ensure hermeticity :-(
>
> In the short-term, we've disabled the test internally - did it trigger any 
> buildbot failures?
>  In the medium term we should probably find a better way to test this :(


No buildbot failures yet. But I suggest we just remove the test and add it back 
when we collect more symbols, i.e. in main files. WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D45985: [test] Add a testcase for MinGW sysroot detections from SVN r330244. NFC.

2018-04-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: test/Driver/mingw-sysroot.cpp:1-2
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+

Hah. :)


Repository:
  rC Clang

https://reviews.llvm.org/D45985



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


[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode

2018-04-24 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: yaxunl, bader.
Herald added subscribers: cfe-commits, Anastasia.

Restrict the following keywords in the OpenCL C++ language mode,
according to Section 2.9 of the OpenCL C++ 1.0 Specification.

- dynamic_cast
- typeid
- goto
- register (already restricted in OpenCL C, update the diagnostic)
- thread_local
- asm
- exceptions (try/catch/throw)

Support the __global, __local, __constant, __private, and __generic
keywords in OpenCL C++.  OpenCL C++ does not provide the unprefixed
address space qualifiers such as global.  Instead, libclcxx provides
explicit address space pointer classes such as global_ptr and
global that are implemented using the __-prefixed qualifiers.

This patch is only a first stab at implementing the restrictions of
OpenCL C++ and is by no means complete.  It primarily covers
restrictions that are easily caught before Sema.


Repository:
  rC Clang

https://reviews.llvm.org/D46022

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  lib/Basic/IdentifierTable.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  test/Parser/opencl-cl20.cl
  test/Parser/opencl-cxx-keywords.cl
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/storageclass.cl
  test/SemaOpenCLCXX/restricted.cl

Index: test/SemaOpenCLCXX/restricted.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/restricted.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+
+// This test checks that various C/C++/OpenCL C constructs are not available in
+// OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9.
+
+// Test storage class qualifiers.
+kernel void test_storage_classes() {
+  register int x;
+  // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}}
+  thread_local int y;
+  // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}}
+}
Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -10,14 +10,14 @@
 static global float g_global_static_var = 0;   // expected-error {{program scope variable must reside in constant address space}}
 static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
 static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
-static generic float g_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
+static generic float g_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
 
 extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
 extern constant float g_constant_extern_var;
 extern global float g_global_extern_var;   // expected-error {{extern variable must reside in constant address space}}
 extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
 extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}}
-extern generic float g_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
+extern generic float g_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
 
 void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
@@ -32,7 +32,7 @@
 constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}}
   }
 
-  auto int L3 = 7;// expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
+  auto int L3 = 7;// expected-error{{OpenCL C version 1.2 does not support the 'auto' storage class specifier}}
   global int L4;  // expected-error{{function scope variable cannot be declared in global address space}}
   __attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}}
 
@@ -64,12 +64,12 @@
   static global float l_global_static_var = 0; // expected-

[PATCH] D45984: [X86] directstore and movdir64b intrinsics

2018-04-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D45984



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


[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)

2018-04-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8425
+  llvm::Type *VTy = llvm::VectorType::get(QTy, N);
+  llvm::Type *BTy = llvm::VectorType::get(CGF.Builder.getInt8Ty(), N * 8);
+  SmallVector ShuffleMask;

Is this not a dead variable now?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8426
+  llvm::Type *BTy = llvm::VectorType::get(CGF.Builder.getInt8Ty(), N * 8);
+  SmallVector ShuffleMask;
+  ShuffleMask.resize(N);

SmallVector ShuffleMask(N);

Then you don't need the resize call.


https://reviews.llvm.org/D45722



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


[PATCH] D46019: [ASTImporter] Fix isa cast assert

2018-04-24 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

This LGTM, but could you please add a test?


Repository:
  rC Clang

https://reviews.llvm.org/D46019



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

I'd also like to point out that as I mentioned before, the checker's name 
itself is misleading (it is a leftover from an earlier implementation of  this 
checker). Here are just some ideas I came up with:

- UninitializedObjectChecker
- UninitializedFieldsChecker
- UninitializedFieldsAfterConstructionChecker
- UninitializedMembersChecker
- UninitializedMembersAfterConstructionChecker

Of these I like the first the most, but I'm open for anything, if you have an 
idea for it.

In https://reviews.llvm.org/D45532#1075789, @NoQ wrote:

> Guys, what do you think about a checker that warns on uninitialized fields 
> only when at least one field is initialized? I'd be much more confident about 
> turning such check on by default. We can still keep a `pedantic` version.


Sounds good! I just finished implementing it along with a few minor (like some 
TODOs and fixes according to inline comments) and not-so-minor (like ignoring 
fields from system headers)  changes. I'll update the diff and post results on 
it once I finish checking the LLVM/Clang project. I feel very confident about 
the upcoming version.


https://reviews.llvm.org/D45532



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


[PATCH] D44387: [x86] Introduce the pconfig/encl[u|s|v] intrinsics

2018-04-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I see that gcc implements all of this with wrappers around inline assembly. Any 
reason we couldn't just do that?




Comment at: lib/Headers/pconfigintrin.h:31
+
+#define MKTME_KEY_PROGRAM 0x0001
+

This doesn't match the name used by gcc. It also needs to start with 
underscores since all names without underscores belong to user code.



Comment at: lib/Headers/sgxintrin.h:52
+}
+
+#endif

You need to undef __DEFAULT_FN_ATTRS


https://reviews.llvm.org/D44387



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


[PATCH] D46007: [analyzer] Add `TaintBugVisitor` to the ArrayBoundV2, DivideZero and VLASize.

2018-04-24 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Mostly LG.




Comment at: lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:75
   auto report = llvm::make_unique(*BT, os.str(), N);
+  report->addVisitor(std::move(Visitor));
   report->addRange(SizeE->getSourceRange());

In this patch, sometimes we check the visitor to be non-null, sometimes not.  
As I can see, `BugReport::addVisitor()` works well with `nullptr` arguments (it 
checks arguments) so I think we can omit the checks.


Repository:
  rC Clang

https://reviews.llvm.org/D46007



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


[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode

2018-04-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I'm not sure that doing this in the lexer is appropriate; you should just 
diagnose the unsupported feature in Sema, or at best the parser.


Repository:
  rC Clang

https://reviews.llvm.org/D46022



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


[PATCH] D45921: Add getDeserializationListener to ASTReader

2018-04-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This seems fine, but I wonder if we should expose a mechanism that will create 
a multiplex listener automatically as needed?


https://reviews.llvm.org/D45921



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


[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

2018-04-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D45179#1056183, @rjmccall wrote:

> Is Marshall arguing that the standard doesn't allow compilers to warn about 
> failing to use these function results prior to C++17?  Because I don't think 
> that's true; warnings are thoroughly non-normative.


I have proposed to add different forms of "nodiscard" warnings to libc++ in the 
past, and received **strong** pushback from people who:

- Compile with -Werror
- Don't want to change their code.

I'm not willing to have that argument again.


Repository:
  rCXX libc++

https://reviews.llvm.org/D45179



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


Re: [PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

2018-04-24 Thread Nico Weber via cfe-commits
So you're happy with this opt-in version?

On Tue, Apr 24, 2018 at 1:29 PM, Marshall Clow via Phabricator via
cfe-commits  wrote:

> mclow.lists added a comment.
>
> In https://reviews.llvm.org/D45179#1056183, @rjmccall wrote:
>
> > Is Marshall arguing that the standard doesn't allow compilers to warn
> about failing to use these function results prior to C++17?  Because I
> don't think that's true; warnings are thoroughly non-normative.
>
>
> I have proposed to add different forms of "nodiscard" warnings to libc++
> in the past, and received **strong** pushback from people who:
>
> - Compile with -Werror
> - Don't want to change their code.
>
> I'm not willing to have that argument again.
>
>
> Repository:
>   rCXX libc++
>
> https://reviews.llvm.org/D45179
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name

2018-04-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:287
+CtorSuffix.append("_");
+CtorSuffix.append(ModuleName);
+  }

SimeonEhrig wrote:
> tra wrote:
> > There is a general problem with this approach. File name can contain the 
> > characters that PTX does not allow.
> > We currently only deal with '.' and '@', but that's not enough here.
> > You may want to either mangle the name somehow to avoid/convert illegal 
> > characters or use some other way to provide unique suffix. Hex-encoded hash 
> > of the file name would avoid this problem, for example.
> > 
> > 
> > 
> Maybe I'm wrong but I think, that should be no problem, because the 
> generating of a cuda ctor/dtor have nothing to do with the PTX generation. 
> 
> The function 'makeModuleCtorFunction' should just generate llvm ir code for 
> the host (e.g. x86_64).
> 
> If I'm wrong, could you tell me please, where in the source code the 
> 'makeModuleCtorFunction' affect the PTX generation.
You are correct that PTX is irrelevant here. I've completely missed that this 
will be generated for the host, which is more forgiving. 

That said, I'm still not completely sure whether we're guaranteed that using 
arbitrary characters in a symbol name is OK on x86 and, potentially, other host 
platforms. As an experiment, try using a module which has a space in its name.


https://reviews.llvm.org/D44435



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


r330744 - [X86] Add recently added intrinsic headers to the module map.

2018-04-24 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Apr 24 10:40:49 2018
New Revision: 330744

URL: http://llvm.org/viewvc/llvm-project?rev=330744&view=rev
Log:
[X86] Add recently added intrinsic headers to the module map.

Modified:
cfe/trunk/lib/Headers/module.modulemap

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=330744&r1=330743&r2=330744&view=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Tue Apr 24 10:40:49 2018
@@ -63,6 +63,9 @@ module _Builtin_intrinsics [system] [ext
 textual header "fma4intrin.h"
 textual header "mwaitxintrin.h"
 textual header "clzerointrin.h"
+textual header "wbnoinvdintrin.h"
+textual header "cldemoteintrin.h"
+textual header "waitpkgintrin.h"
 
 explicit module mm_malloc {
   requires !freestanding


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


r330743 - [X86] Consistently use double underscore at the beginning of the include guards in our intrinsic headers.

2018-04-24 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Apr 24 10:40:47 2018
New Revision: 330743

URL: http://llvm.org/viewvc/llvm-project?rev=330743&view=rev
Log:
[X86] Consistently use double underscore at the beginning of the include guards 
in our intrinsic headers.

Most files used double underscore, but a few used single. This converges them 
all to double.

Modified:
cfe/trunk/lib/Headers/__wmmintrin_aes.h
cfe/trunk/lib/Headers/__wmmintrin_pclmul.h
cfe/trunk/lib/Headers/clzerointrin.h
cfe/trunk/lib/Headers/mwaitxintrin.h
cfe/trunk/lib/Headers/nmmintrin.h
cfe/trunk/lib/Headers/popcntintrin.h
cfe/trunk/lib/Headers/smmintrin.h
cfe/trunk/lib/Headers/waitpkgintrin.h
cfe/trunk/lib/Headers/wmmintrin.h

Modified: cfe/trunk/lib/Headers/__wmmintrin_aes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_aes.h?rev=330743&r1=330742&r2=330743&view=diff
==
--- cfe/trunk/lib/Headers/__wmmintrin_aes.h (original)
+++ cfe/trunk/lib/Headers/__wmmintrin_aes.h Tue Apr 24 10:40:47 2018
@@ -20,8 +20,8 @@
  *
  *===---===
  */
-#ifndef _WMMINTRIN_AES_H
-#define _WMMINTRIN_AES_H
+#ifndef __WMMINTRIN_AES_H
+#define __WMMINTRIN_AES_H
 
 #include 
 
@@ -148,4 +148,4 @@ _mm_aesimc_si128(__m128i __V)
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif  /* _WMMINTRIN_AES_H */
+#endif  /* __WMMINTRIN_AES_H */

Modified: cfe/trunk/lib/Headers/__wmmintrin_pclmul.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_pclmul.h?rev=330743&r1=330742&r2=330743&view=diff
==
--- cfe/trunk/lib/Headers/__wmmintrin_pclmul.h (original)
+++ cfe/trunk/lib/Headers/__wmmintrin_pclmul.h Tue Apr 24 10:40:47 2018
@@ -20,8 +20,8 @@
  *
  *===---===
  */
-#ifndef _WMMINTRIN_PCLMUL_H
-#define _WMMINTRIN_PCLMUL_H
+#ifndef __WMMINTRIN_PCLMUL_H
+#define __WMMINTRIN_PCLMUL_H
 
 /// \brief Multiplies two 64-bit integer values, which are selected from source
 ///operands using the immediate-value operand. The multiplication is a
@@ -54,4 +54,4 @@
   ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \
 (__v2di)(__m128i)(__Y), (char)(__I)))
 
-#endif /* _WMMINTRIN_PCLMUL_H */
+#endif /* __WMMINTRIN_PCLMUL_H */

Modified: cfe/trunk/lib/Headers/clzerointrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/clzerointrin.h?rev=330743&r1=330742&r2=330743&view=diff
==
--- cfe/trunk/lib/Headers/clzerointrin.h (original)
+++ cfe/trunk/lib/Headers/clzerointrin.h Tue Apr 24 10:40:47 2018
@@ -24,8 +24,8 @@
 #error "Never use  directly; include  instead."
 #endif
 
-#ifndef _CLZEROINTRIN_H
-#define _CLZEROINTRIN_H
+#ifndef __CLZEROINTRIN_H
+#define __CLZEROINTRIN_H
 
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
@@ -47,4 +47,4 @@ _mm_clzero (void * __line)
 
 #undef __DEFAULT_FN_ATTRS 
 
-#endif /* _CLZEROINTRIN_H */
+#endif /* __CLZEROINTRIN_H */

Modified: cfe/trunk/lib/Headers/mwaitxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/mwaitxintrin.h?rev=330743&r1=330742&r2=330743&view=diff
==
--- cfe/trunk/lib/Headers/mwaitxintrin.h (original)
+++ cfe/trunk/lib/Headers/mwaitxintrin.h Tue Apr 24 10:40:47 2018
@@ -25,8 +25,8 @@
 #error "Never use  directly; include  instead."
 #endif
 
-#ifndef _MWAITXINTRIN_H
-#define _MWAITXINTRIN_H
+#ifndef __MWAITXINTRIN_H
+#define __MWAITXINTRIN_H
 
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("mwaitx")))
@@ -44,4 +44,4 @@ _mm_mwaitx(unsigned __extensions, unsign
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* _MWAITXINTRIN_H */
+#endif /* __MWAITXINTRIN_H */

Modified: cfe/trunk/lib/Headers/nmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/nmmintrin.h?rev=330743&r1=330742&r2=330743&view=diff
==
--- cfe/trunk/lib/Headers/nmmintrin.h (original)
+++ cfe/trunk/lib/Headers/nmmintrin.h Tue Apr 24 10:40:47 2018
@@ -21,10 +21,10 @@
  *===---===
  */
 
-#ifndef _NMMINTRIN_H
-#define _NMMINTRIN_H
+#ifndef __NMMINTRIN_H
+#define __NMMINTRIN_H
 
 /* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h,
just include it now then.  */
 #include 
-#endif /* _NMMINTRIN_H */
+#endif /* __NMMINTRIN_H */

Modified: cfe/trunk/lib/Headers/popcntintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/popcntintrin.h?rev=330743

r330745 - [HWASan] Update HWASan assembly snippet in the docs

2018-04-24 Thread Alex Shlyapnikov via cfe-commits
Author: alekseyshl
Date: Tue Apr 24 10:41:48 2018
New Revision: 330745

URL: http://llvm.org/viewvc/llvm-project?rev=330745&view=rev
Log:
[HWASan] Update HWASan assembly snippet in the docs

Summary: To complement https://reviews.llvm.org/D45840

Reviewers: eugenis

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst

Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst?rev=330745&r1=330744&r2=330745&view=diff
==
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst (original)
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Tue Apr 24 
10:41:48 2018
@@ -52,15 +52,16 @@ verifies the tags. Currently, the follow
   // int foo(int *a) { return *a; }
   // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c
   foo:
-   0:  08 dc 44 d3 ubfxx8, x0, #4, #52  // shadow address
-   4:  08 01 40 39 ldrbw8, [x8] // load shadow
-   8:  09 fc 78 d3 lsr x9, x0, #56  // address tag
-   c:  3f 01 08 6b cmp w9, w8   // compare tags
-  10:  61 00 00 54 b.ne#12  // jump on mismatch
-  14:  00 00 40 b9 ldr w0, [x0] // original load
-  18:  c0 03 5f d6 ret
-  1c:  40 20 21 d4 brk #0x902   // trap
-
+   0:  08 00 00 90 adrpx8, 0 <__hwasan_shadow>
+   4:  08 01 40 f9 ldr x8, [x8] // shadow base (to be 
resolved by the loader)
+   8:  09 dc 44 d3 ubfxx9, x0, #4, #52  // shadow offset
+   c:  28 69 68 38 ldrbw8, [x9, x8] // load shadow tag
+  10:  09 fc 78 d3 lsr x9, x0, #56  // extract address tag
+  14:  3f 01 08 6b cmp w9, w8   // compare tags
+  18:  61 00 00 54 b.ne24   // jump on mismatch
+  1c:  00 00 40 b9 ldr w0, [x0] // original load
+  20:  c0 03 5f d6 ret
+  24:  40 20 21 d4 brk #0x902   // trap
 
 Alternatively, memory accesses are prefixed with a function call.
 


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


[PATCH] D45996: [HWASan] Update HWASan assembly snippet in the docs

2018-04-24 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330745: [HWASan] Update HWASan assembly snippet in the docs 
(authored by alekseyshl, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45996

Files:
  cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst


Index: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -52,15 +52,16 @@
   // int foo(int *a) { return *a; }
   // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c
   foo:
-   0:  08 dc 44 d3 ubfxx8, x0, #4, #52  // shadow address
-   4:  08 01 40 39 ldrbw8, [x8] // load shadow
-   8:  09 fc 78 d3 lsr x9, x0, #56  // address tag
-   c:  3f 01 08 6b cmp w9, w8   // compare tags
-  10:  61 00 00 54 b.ne#12  // jump on mismatch
-  14:  00 00 40 b9 ldr w0, [x0] // original load
-  18:  c0 03 5f d6 ret
-  1c:  40 20 21 d4 brk #0x902   // trap
-
+   0:  08 00 00 90 adrpx8, 0 <__hwasan_shadow>
+   4:  08 01 40 f9 ldr x8, [x8] // shadow base (to be 
resolved by the loader)
+   8:  09 dc 44 d3 ubfxx9, x0, #4, #52  // shadow offset
+   c:  28 69 68 38 ldrbw8, [x9, x8] // load shadow tag
+  10:  09 fc 78 d3 lsr x9, x0, #56  // extract address tag
+  14:  3f 01 08 6b cmp w9, w8   // compare tags
+  18:  61 00 00 54 b.ne24   // jump on mismatch
+  1c:  00 00 40 b9 ldr w0, [x0] // original load
+  20:  c0 03 5f d6 ret
+  24:  40 20 21 d4 brk #0x902   // trap
 
 Alternatively, memory accesses are prefixed with a function call.
 


Index: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -52,15 +52,16 @@
   // int foo(int *a) { return *a; }
   // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c
   foo:
-   0:	08 dc 44 d3 	ubfx	x8, x0, #4, #52  // shadow address
-   4:	08 01 40 39 	ldrb	w8, [x8] // load shadow
-   8:	09 fc 78 d3 	lsr	x9, x0, #56  // address tag
-   c:	3f 01 08 6b 	cmp	w9, w8   // compare tags
-  10:	61 00 00 54 	b.ne	#12  // jump on mismatch
-  14:	00 00 40 b9 	ldr	w0, [x0] // original load
-  18:	c0 03 5f d6 	ret
-  1c:	40 20 21 d4 	brk	#0x902   // trap
-
+   0:	08 00 00 90 	adrp	x8, 0 <__hwasan_shadow>
+   4:	08 01 40 f9 	ldr	x8, [x8] // shadow base (to be resolved by the loader)
+   8:	09 dc 44 d3 	ubfx	x9, x0, #4, #52  // shadow offset
+   c:	28 69 68 38 	ldrb	w8, [x9, x8] // load shadow tag
+  10:	09 fc 78 d3 	lsr	x9, x0, #56  // extract address tag
+  14:	3f 01 08 6b 	cmp	w9, w8   // compare tags
+  18:	61 00 00 54 	b.ne	24   // jump on mismatch
+  1c:	00 00 40 b9 	ldr	w0, [x0] // original load
+  20:	c0 03 5f d6 	ret
+  24:	40 20 21 d4 	brk	#0x902   // trap
 
 Alternatively, memory accesses are prefixed with a function call.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check

2018-04-24 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun added a comment.

Could someone help getting this merged? I don't have commit access to the repo.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45891



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


[PATCH] D45996: [HWASan] Update HWASan assembly snippet in the docs

2018-04-24 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330745: [HWASan] Update HWASan assembly snippet in the docs 
(authored by alekseyshl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45996?vs=143671&id=143782#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45996

Files:
  docs/HardwareAssistedAddressSanitizerDesign.rst


Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- docs/HardwareAssistedAddressSanitizerDesign.rst
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -52,15 +52,16 @@
   // int foo(int *a) { return *a; }
   // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c
   foo:
-   0:  08 dc 44 d3 ubfxx8, x0, #4, #52  // shadow address
-   4:  08 01 40 39 ldrbw8, [x8] // load shadow
-   8:  09 fc 78 d3 lsr x9, x0, #56  // address tag
-   c:  3f 01 08 6b cmp w9, w8   // compare tags
-  10:  61 00 00 54 b.ne#12  // jump on mismatch
-  14:  00 00 40 b9 ldr w0, [x0] // original load
-  18:  c0 03 5f d6 ret
-  1c:  40 20 21 d4 brk #0x902   // trap
-
+   0:  08 00 00 90 adrpx8, 0 <__hwasan_shadow>
+   4:  08 01 40 f9 ldr x8, [x8] // shadow base (to be 
resolved by the loader)
+   8:  09 dc 44 d3 ubfxx9, x0, #4, #52  // shadow offset
+   c:  28 69 68 38 ldrbw8, [x9, x8] // load shadow tag
+  10:  09 fc 78 d3 lsr x9, x0, #56  // extract address tag
+  14:  3f 01 08 6b cmp w9, w8   // compare tags
+  18:  61 00 00 54 b.ne24   // jump on mismatch
+  1c:  00 00 40 b9 ldr w0, [x0] // original load
+  20:  c0 03 5f d6 ret
+  24:  40 20 21 d4 brk #0x902   // trap
 
 Alternatively, memory accesses are prefixed with a function call.
 


Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- docs/HardwareAssistedAddressSanitizerDesign.rst
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -52,15 +52,16 @@
   // int foo(int *a) { return *a; }
   // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c
   foo:
-   0:	08 dc 44 d3 	ubfx	x8, x0, #4, #52  // shadow address
-   4:	08 01 40 39 	ldrb	w8, [x8] // load shadow
-   8:	09 fc 78 d3 	lsr	x9, x0, #56  // address tag
-   c:	3f 01 08 6b 	cmp	w9, w8   // compare tags
-  10:	61 00 00 54 	b.ne	#12  // jump on mismatch
-  14:	00 00 40 b9 	ldr	w0, [x0] // original load
-  18:	c0 03 5f d6 	ret
-  1c:	40 20 21 d4 	brk	#0x902   // trap
-
+   0:	08 00 00 90 	adrp	x8, 0 <__hwasan_shadow>
+   4:	08 01 40 f9 	ldr	x8, [x8] // shadow base (to be resolved by the loader)
+   8:	09 dc 44 d3 	ubfx	x9, x0, #4, #52  // shadow offset
+   c:	28 69 68 38 	ldrb	w8, [x9, x8] // load shadow tag
+  10:	09 fc 78 d3 	lsr	x9, x0, #56  // extract address tag
+  14:	3f 01 08 6b 	cmp	w9, w8   // compare tags
+  18:	61 00 00 54 	b.ne	24   // jump on mismatch
+  1c:	00 00 40 b9 	ldr	w0, [x0] // original load
+  20:	c0 03 5f d6 	ret
+  24:	40 20 21 d4 	brk	#0x902   // trap
 
 Alternatively, memory accesses are prefixed with a function call.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

2018-04-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D45179#1077048, @mclow.lists wrote:

> In https://reviews.llvm.org/D45179#1056183, @rjmccall wrote:
>
> > Is Marshall arguing that the standard doesn't allow compilers to warn about 
> > failing to use these function results prior to C++17?  Because I don't 
> > think that's true; warnings are thoroughly non-normative.
>
>
> I have proposed to add different forms of "nodiscard" warnings to libc++ in 
> the past, and received **strong** pushback from people who:
>
> - Compile with -Werror
> - Don't want to change their code.
>
>   I'm not willing to have that argument again.


Alright, well, I won't push you on it.


Repository:
  rCXX libc++

https://reviews.llvm.org/D45179



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


[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching

2018-04-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:51-52
   llvm::Constant *getLaunchFn() const;
+  std::string addPrefixToName(CodeGenModule &CGM, StringRef FuncName) const;
+  std::string addUnderscoredPrefixToName(CodeGenModule &CGM,
+ StringRef FuncName) const;

rjmccall wrote:
> tra wrote:
> > `const CodeGenModule &CGM`
> Why doesn't the CGNVCUDARuntime just hold on to a reference to the CGM?  
> That's what we do with all the other separated singletons (like the 
> CGCXXABI), and it would let you avoid some of the redundant fields like 
> Context and TheModule.
Actually,  CGCUDARuntime already has CGM field, so the CGM argument can be just 
dropped.


https://reviews.llvm.org/D44984



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


[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

2018-04-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D45179#1077055, @thakis wrote:

> So you're happy with this opt-in version?


I'm happy with an opt-in mechanism, yes.
This one is not quite right yet.

BTW, I expect a //large// set of calls in the standard library to get marked as 
`[[nodiscard]]` in Rapperswil.




Comment at: include/__config:1016
+// because GCC does not silence them via (void) cast.
+#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17
+#  define _LIBCPP_NODISCARD [[nodiscard]]

`[[nodiscard]]` is a C++17 feature. This test should be `>=`, not `>`.



Comment at: include/__config:1026
+(_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD))
+#  define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
 #else

I wouldn't change this; just leave it as `[[nodiscard]]`


Repository:
  rCXX libc++

https://reviews.llvm.org/D45179



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


[PATCH] D45964: [Driver] Fix implicit config files from prefixed symlinks

2018-04-24 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

Thank you for fixing this issue!

LGTM




Comment at: lib/Driver/Driver.cpp:132
  ArrayRef Args) {
-  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  if (ClangNameParts.TargetPrefix.empty() && ClangNameParts.DriverMode == 
nullptr)
+ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);

Maybe this check could be made a method of `ParsedClangName`, something like 
`isEmpty`?


Repository:
  rC Clang

https://reviews.llvm.org/D45964



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


  1   2   >