[PATCH] D39903: [libclang] Allow pretty printing declarations

2017-11-30 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added reviewers: ilya-biryukov, cameron314.
nik added a comment.

Anyone?


https://reviews.llvm.org/D39903



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


[PATCH] D40671: [clang-tidy] Support specific categories for NOLINT directive

2017-11-30 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Could you please explain what category means? Could i disable all of 
`cppcoreguidelines` with something like `// NOLINT (cppcoreguidelines-*)`?




Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:297
+  if (NolintIndex != StringRef::npos) {
+auto BracketIndex = NolintIndex + NolintMacro.size();
+if (BracketIndex < Line.size() && Line[BracketIndex] == '(') {

Maybe some comments whats happening might be helpfull. It would simplify later 
modifications.



Comment at: test/clang-tidy/nolintnextline.cpp:14
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };

missing `)`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671



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


[libcxx] r319523 - [libcxx] Support getentropy as a source of randomness for std::random_device

2017-11-30 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Nov 30 22:34:33 2017
New Revision: 319523

URL: http://llvm.org/viewvc/llvm-project?rev=319523&view=rev
Log:
[libcxx] Support getentropy as a source of randomness for std::random_device

Use this source use on Fuchsia where this is the oficially way
to obtain randomness. This could be also used on other platforms
that already support getentropy such as *BSD or Linux.

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

Modified:
libcxx/trunk/include/__config
libcxx/trunk/src/random.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=319523&r1=319522&r2=319523&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Nov 30 22:34:33 2017
@@ -273,6 +273,8 @@
   // random data even when using sandboxing mechanisms such as chroots,
   // Capsicum, etc.
 # define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__Fuchsia__)
+# define _LIBCPP_USING_GETENTROPY
 #elif defined(__native_client__)
   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
   // including accesses to the special files under /dev. C++11's

Modified: libcxx/trunk/src/random.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/random.cpp?rev=319523&r1=319522&r2=319523&view=diff
==
--- libcxx/trunk/src/random.cpp (original)
+++ libcxx/trunk/src/random.cpp Thu Nov 30 22:34:33 2017
@@ -25,7 +25,9 @@
 #include 
 #include 
 
-#if defined(_LIBCPP_USING_DEV_RANDOM)
+#if defined(_LIBCPP_USING_GETENTROPY)
+#include 
+#elif defined(_LIBCPP_USING_DEV_RANDOM)
 #include 
 #include 
 #elif defined(_LIBCPP_USING_NACL_RANDOM)
@@ -35,7 +37,30 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_USING_ARC4_RANDOM)
+#if defined(_LIBCPP_USING_GETENTROPY)
+
+random_device::random_device(const string& __token)
+{
+if (__token != "/dev/urandom")
+__throw_system_error(ENOENT, ("random device not supported " + 
__token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+unsigned r;
+size_t n = sizeof(r);
+int err = getentropy(&r, n);
+if (err)
+__throw_system_error(errno, "random_device getentropy failed");
+return r;
+}
+
+#elif defined(_LIBCPP_USING_ARC4_RANDOM)
 
 random_device::random_device(const string& __token)
 {


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


[PATCH] D40319: [libcxx] Support getentropy as a source of randomness for std::random_device

2017-11-30 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319523: [libcxx] Support getentropy as a source of 
randomness for std::random_device (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D40319?vs=123842&id=125076#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40319

Files:
  libcxx/trunk/include/__config
  libcxx/trunk/src/random.cpp


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -273,6 +273,8 @@
   // random data even when using sandboxing mechanisms such as chroots,
   // Capsicum, etc.
 # define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__Fuchsia__)
+# define _LIBCPP_USING_GETENTROPY
 #elif defined(__native_client__)
   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
   // including accesses to the special files under /dev. C++11's
Index: libcxx/trunk/src/random.cpp
===
--- libcxx/trunk/src/random.cpp
+++ libcxx/trunk/src/random.cpp
@@ -25,7 +25,9 @@
 #include 
 #include 
 
-#if defined(_LIBCPP_USING_DEV_RANDOM)
+#if defined(_LIBCPP_USING_GETENTROPY)
+#include 
+#elif defined(_LIBCPP_USING_DEV_RANDOM)
 #include 
 #include 
 #elif defined(_LIBCPP_USING_NACL_RANDOM)
@@ -35,7 +37,30 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_USING_ARC4_RANDOM)
+#if defined(_LIBCPP_USING_GETENTROPY)
+
+random_device::random_device(const string& __token)
+{
+if (__token != "/dev/urandom")
+__throw_system_error(ENOENT, ("random device not supported " + 
__token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+unsigned r;
+size_t n = sizeof(r);
+int err = getentropy(&r, n);
+if (err)
+__throw_system_error(errno, "random_device getentropy failed");
+return r;
+}
+
+#elif defined(_LIBCPP_USING_ARC4_RANDOM)
 
 random_device::random_device(const string& __token)
 {


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -273,6 +273,8 @@
   // random data even when using sandboxing mechanisms such as chroots,
   // Capsicum, etc.
 # define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__Fuchsia__)
+# define _LIBCPP_USING_GETENTROPY
 #elif defined(__native_client__)
   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
   // including accesses to the special files under /dev. C++11's
Index: libcxx/trunk/src/random.cpp
===
--- libcxx/trunk/src/random.cpp
+++ libcxx/trunk/src/random.cpp
@@ -25,7 +25,9 @@
 #include 
 #include 
 
-#if defined(_LIBCPP_USING_DEV_RANDOM)
+#if defined(_LIBCPP_USING_GETENTROPY)
+#include 
+#elif defined(_LIBCPP_USING_DEV_RANDOM)
 #include 
 #include 
 #elif defined(_LIBCPP_USING_NACL_RANDOM)
@@ -35,7 +37,30 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_USING_ARC4_RANDOM)
+#if defined(_LIBCPP_USING_GETENTROPY)
+
+random_device::random_device(const string& __token)
+{
+if (__token != "/dev/urandom")
+__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+unsigned r;
+size_t n = sizeof(r);
+int err = getentropy(&r, n);
+if (err)
+__throw_system_error(errno, "random_device getentropy failed");
+return r;
+}
+
+#elif defined(_LIBCPP_USING_ARC4_RANDOM)
 
 random_device::random_device(const string& __token)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

2017-11-30 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson added inline comments.



Comment at: lib/Driver/ToolChains/Darwin.cpp:1457-1465
   if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
  getTriple().getArch() == llvm::Triple::x86_64))
 Platform = IPhoneOSSimulator;
   if (TvOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64))
 Platform = TvOSSimulator;
   if (WatchOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||

arphaman wrote:
> bob.wilson wrote:
> > These checks should set the simulator target as well.
> This would break the `__APPLE_EMBEDDED_SIMULATOR__` macro, as that has to be 
> specified only when is used `-m(iphone|tv|watch)simulator-version-min`. Or 
> should we still set `__APPLE_EMBEDDED_SIMULATOR__` in the driver and allow 
> `-simulator` even without `-m(iphone|tv|watch)simulator-version-min`?
The intention is that using a target triple with "simulator" in the environment 
should replace the use of -m*simulator-version-min.


Repository:
  rC Clang

https://reviews.llvm.org/D40682



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


[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk planned changes to this revision.
vsk added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:2756
  SourceLocation EndLoc) {
+  if (FI.isNoReturn()) {
+// Noreturn functions don't return.

efriedma wrote:
> vsk wrote:
> > efriedma wrote:
> > > Unfortunately, this won't catch cases where the caller has a noreturn 
> > > marking, but the callee doesn't.  Maybe strip the noreturn attribute from 
> > > the caller, then put the sanitizer check into both the caller and callee?
> > If the caller sees a noreturn marking on the call target, inserting a 
> > 'reached-unreachable' check after the call is UB, and the optimizer throws 
> > it away. Perhaps you had a different case in mind?
> I'm thinking of the case where the caller can't see the callee, like this:
> 
> a.c:
> void a(void) __attribute((noreturn));
> void b(void) { a(); }
> 
> b.c:
> void a(void) {}
Got it. So clang would then do:

a.c:
void a(void) /* strip the noreturn attribute */;
void b(void) { a(); /* insert a reached-unreachable check here */}


https://reviews.llvm.org/D40698



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


[PATCH] D40280: [CMake][libcxx] Include AddLLVM needed for tests in the right context

2017-11-30 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319515: Include AddLLVM needed for tests in the right 
context (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D40280?vs=123711&id=125072#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40280

Files:
  libcxx/trunk/CMakeLists.txt
  libcxx/trunk/test/CMakeLists.txt


Index: libcxx/trunk/test/CMakeLists.txt
===
--- libcxx/trunk/test/CMakeLists.txt
+++ libcxx/trunk/test/CMakeLists.txt
@@ -49,10 +49,6 @@
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
 set(LIBCXX_TEST_DEPS "")
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
@@ -64,7 +60,12 @@
 endif()
 
 if (LIBCXX_INCLUDE_TESTS)
-  include(AddLLVM) # for add_lit_testsuite
+  include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+
   add_lit_testsuite(check-cxx
 "Running libcxx tests"
 ${CMAKE_CURRENT_BINARY_DIR}
Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -684,6 +684,7 @@
 endif()
 
 if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  include(AddLLVM) # for get_llvm_lit_path
   # Make sure the llvm-lit script is generated into the bin directory, and do
   # it after adding all tests, since the generated script will only work
   # correctly discovered tests against test locations from the source tree that


Index: libcxx/trunk/test/CMakeLists.txt
===
--- libcxx/trunk/test/CMakeLists.txt
+++ libcxx/trunk/test/CMakeLists.txt
@@ -49,10 +49,6 @@
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
 set(LIBCXX_TEST_DEPS "")
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
@@ -64,7 +60,12 @@
 endif()
 
 if (LIBCXX_INCLUDE_TESTS)
-  include(AddLLVM) # for add_lit_testsuite
+  include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+
   add_lit_testsuite(check-cxx
 "Running libcxx tests"
 ${CMAKE_CURRENT_BINARY_DIR}
Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -684,6 +684,7 @@
 endif()
 
 if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  include(AddLLVM) # for get_llvm_lit_path
   # Make sure the llvm-lit script is generated into the bin directory, and do
   # it after adding all tests, since the generated script will only work
   # correctly discovered tests against test locations from the source tree that
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r319515 - Include AddLLVM needed for tests in the right context

2017-11-30 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Nov 30 19:16:50 2017
New Revision: 319515

URL: http://llvm.org/viewvc/llvm-project?rev=319515&view=rev
Log:
Include AddLLVM needed for tests in the right context

AddLLVM is needed for several functions that are used in tests and
as such needs to be included from the right context which previously
wasn't the case.

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=319515&r1=319514&r2=319515&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Nov 30 19:16:50 2017
@@ -684,6 +684,7 @@ if (LIBCXX_INCLUDE_TESTS)
 endif()
 
 if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  include(AddLLVM) # for get_llvm_lit_path
   # Make sure the llvm-lit script is generated into the bin directory, and do
   # it after adding all tests, since the generated script will only work
   # correctly discovered tests against test locations from the source tree that

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=319515&r1=319514&r2=319515&view=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Thu Nov 30 19:16:50 2017
@@ -49,10 +49,6 @@ set(LIBCXX_EXECUTOR "None" CACHE STRING
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
 set(LIBCXX_TEST_DEPS "")
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
@@ -64,7 +60,12 @@ if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
 endif()
 
 if (LIBCXX_INCLUDE_TESTS)
-  include(AddLLVM) # for add_lit_testsuite
+  include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+
   add_lit_testsuite(check-cxx
 "Running libcxx tests"
 ${CMAKE_CURRENT_BINARY_DIR}


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


[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-11-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:2756
  SourceLocation EndLoc) {
+  if (FI.isNoReturn()) {
+// Noreturn functions don't return.

vsk wrote:
> efriedma wrote:
> > Unfortunately, this won't catch cases where the caller has a noreturn 
> > marking, but the callee doesn't.  Maybe strip the noreturn attribute from 
> > the caller, then put the sanitizer check into both the caller and callee?
> If the caller sees a noreturn marking on the call target, inserting a 
> 'reached-unreachable' check after the call is UB, and the optimizer throws it 
> away. Perhaps you had a different case in mind?
I'm thinking of the case where the caller can't see the callee, like this:

a.c:
void a(void) __attribute((noreturn));
void b(void) { a(); }

b.c:
void a(void) {}


https://reviews.llvm.org/D40698



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


[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:2756
  SourceLocation EndLoc) {
+  if (FI.isNoReturn()) {
+// Noreturn functions don't return.

efriedma wrote:
> Unfortunately, this won't catch cases where the caller has a noreturn 
> marking, but the callee doesn't.  Maybe strip the noreturn attribute from the 
> caller, then put the sanitizer check into both the caller and callee?
If the caller sees a noreturn marking on the call target, inserting a 
'reached-unreachable' check after the call is UB, and the optimizer throws it 
away. Perhaps you had a different case in mind?



Comment at: lib/CodeGen/CGCall.cpp:2764
 // Naked functions don't have epilogues.
-Builder.CreateUnreachable();
+EmitUnreachable(EndLoc);
 return;

efriedma wrote:
> This is likely a problem.  Not because the code is supposed to be reachable, 
> but because putting additional code into a naked function can have weird 
> effects.  Probably not worth messing with this case.
Sorry for the noisy change. I recognized it as a mistake a second after I 
uploaded the new diff :(.


https://reviews.llvm.org/D40698



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


[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-11-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:2756
  SourceLocation EndLoc) {
+  if (FI.isNoReturn()) {
+// Noreturn functions don't return.

Unfortunately, this won't catch cases where the caller has a noreturn marking, 
but the callee doesn't.  Maybe strip the noreturn attribute from the caller, 
then put the sanitizer check into both the caller and callee?



Comment at: lib/CodeGen/CGCall.cpp:2764
 // Naked functions don't have epilogues.
-Builder.CreateUnreachable();
+EmitUnreachable(EndLoc);
 return;

This is likely a problem.  Not because the code is supposed to be reachable, 
but because putting additional code into a naked function can have weird 
effects.  Probably not worth messing with this case.


https://reviews.llvm.org/D40698



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


[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 125071.
vsk added a comment.

- Leave out an unrelated change in the handling of NakedAttr.


https://reviews.llvm.org/D40698

Files:
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-noreturn.c

Index: test/CodeGen/ubsan-noreturn.c
===
--- /dev/null
+++ test/CodeGen/ubsan-noreturn.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s
+
+// CHECK-LABEL: @f(
+void __attribute__((noreturn)) f() {
+  // CHECK: __ubsan_handle_builtin_unreachable
+  // CHECK: unreachable
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3736,6 +3736,10 @@
 llvm::ConstantInt *TypeId, llvm::Value *Ptr,
 ArrayRef StaticArgs);
 
+  /// Emit a reached-unreachable diagnostic if \p Loc is valid and runtime
+  /// checking is enabled. Otherwise, just emit an unreachable instruction.
+  void EmitUnreachable(SourceLocation Loc);
+
   /// \brief Create a basic block that will call the trap intrinsic, and emit a
   /// conditional branch to it, for the -ftrapv checks.
   void EmitTrapCheck(llvm::Value *Checked);
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3030,6 +3030,17 @@
   CGM.addUsedGlobal(F);
 }
 
+void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
+  if (SanOpts.has(SanitizerKind::Unreachable)) {
+SanitizerScope SanScope(this);
+EmitCheck(std::make_pair(static_cast(Builder.getFalse()),
+ SanitizerKind::Unreachable),
+  SanitizerHandler::BuiltinUnreachable,
+  EmitCheckSourceLocation(Loc), None);
+  }
+  Builder.CreateUnreachable();
+}
+
 void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -2753,6 +2753,12 @@
 void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
  bool EmitRetDbgLoc,
  SourceLocation EndLoc) {
+  if (FI.isNoReturn()) {
+// Noreturn functions don't return.
+EmitUnreachable(EndLoc);
+return;
+  }
+
   if (CurCodeDecl && CurCodeDecl->hasAttr()) {
 // Naked functions don't have epilogues.
 Builder.CreateUnreachable();
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1218,14 +1218,7 @@
   case Builtin::BI__debugbreak:
 return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
   case Builtin::BI__builtin_unreachable: {
-if (SanOpts.has(SanitizerKind::Unreachable)) {
-  SanitizerScope SanScope(this);
-  EmitCheck(std::make_pair(static_cast(Builder.getFalse()),
-   SanitizerKind::Unreachable),
-SanitizerHandler::BuiltinUnreachable,
-EmitCheckSourceLocation(E->getExprLoc()), None);
-} else
-  Builder.CreateUnreachable();
+EmitUnreachable(E->getExprLoc());
 
 // We do need to preserve an insertion point.
 EmitBlock(createBasicBlock("unreachable.cont"));
Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -124,8 +124,8 @@
   -  ``-fsanitize=signed-integer-overflow``: Signed integer overflow,
  including all the checks added by ``-ftrapv``, and checking for
  overflow in signed division (``INT_MIN / -1``).
-  -  ``-fsanitize=unreachable``: If control flow reaches
- ``__builtin_unreachable``.
+  -  ``-fsanitize=unreachable``: If control flow reaches an unreachable
+ program point.
   -  ``-fsanitize=unsigned-integer-overflow``: Unsigned integer
  overflows. Note that unlike signed integer overflow, unsigned integer
  is not undefined behavior. However, while it has well-defined semantics,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40700: [ubsan] Diagnose noreturn functions which return (compiler-rt)

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
Herald added subscribers: dberris, kubamracek.

This is a test and a wording update for the clang change: 
https://reviews.llvm.org/D40698


https://reviews.llvm.org/D40700

Files:
  lib/ubsan/ubsan_handlers.cc
  test/ubsan/TestCases/Misc/unreachable.cpp


Index: test/ubsan/TestCases/Misc/unreachable.cpp
===
--- test/ubsan/TestCases/Misc/unreachable.cpp
+++ test/ubsan/TestCases/Misc/unreachable.cpp
@@ -1,6 +1,18 @@
-// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && not %run %t 2>&1 | 
FileCheck %s
+// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t
+// RUN: not %run %t builtin 2>&1 | FileCheck %s -check-prefix=BUILTIN
+// RUN: not %run %t noreturn 2>&1 | FileCheck %s -check-prefix=NORETURN
+
+#include 
+
+void __attribute__((noreturn)) return_unexpectedly() {
+  // NORETURN: unreachable.cpp:[[@LINE+1]]:1: runtime error: execution reached 
an unreachable program point
+}
 
 int main(int, char **argv) {
-  // CHECK: unreachable.cpp:5:3: runtime error: execution reached a 
__builtin_unreachable() call
-  __builtin_unreachable();
+  if (strcmp(argv[1], "builtin") == 0)
+// BUILTIN: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution 
reached an unreachable program point
+__builtin_unreachable();
+  else if (strcmp(argv[1], "noreturn") == 0)
+return_unexpectedly();
+  return 0;
 }
Index: lib/ubsan/ubsan_handlers.cc
===
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -297,7 +297,7 @@
 static void handleBuiltinUnreachableImpl(UnreachableData *Data,
  ReportOptions Opts) {
   ScopedReport R(Opts, Data->Loc, ErrorType::UnreachableCall);
-  Diag(Data->Loc, DL_Error, "execution reached a __builtin_unreachable() 
call");
+  Diag(Data->Loc, DL_Error, "execution reached an unreachable program point");
 }
 
 void __ubsan::__ubsan_handle_builtin_unreachable(UnreachableData *Data) {


Index: test/ubsan/TestCases/Misc/unreachable.cpp
===
--- test/ubsan/TestCases/Misc/unreachable.cpp
+++ test/ubsan/TestCases/Misc/unreachable.cpp
@@ -1,6 +1,18 @@
-// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t
+// RUN: not %run %t builtin 2>&1 | FileCheck %s -check-prefix=BUILTIN
+// RUN: not %run %t noreturn 2>&1 | FileCheck %s -check-prefix=NORETURN
+
+#include 
+
+void __attribute__((noreturn)) return_unexpectedly() {
+  // NORETURN: unreachable.cpp:[[@LINE+1]]:1: runtime error: execution reached an unreachable program point
+}
 
 int main(int, char **argv) {
-  // CHECK: unreachable.cpp:5:3: runtime error: execution reached a __builtin_unreachable() call
-  __builtin_unreachable();
+  if (strcmp(argv[1], "builtin") == 0)
+// BUILTIN: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution reached an unreachable program point
+__builtin_unreachable();
+  else if (strcmp(argv[1], "noreturn") == 0)
+return_unexpectedly();
+  return 0;
 }
Index: lib/ubsan/ubsan_handlers.cc
===
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -297,7 +297,7 @@
 static void handleBuiltinUnreachableImpl(UnreachableData *Data,
  ReportOptions Opts) {
   ScopedReport R(Opts, Data->Loc, ErrorType::UnreachableCall);
-  Diag(Data->Loc, DL_Error, "execution reached a __builtin_unreachable() call");
+  Diag(Data->Loc, DL_Error, "execution reached an unreachable program point");
 }
 
 void __ubsan::__ubsan_handle_builtin_unreachable(UnreachableData *Data) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 125069.
vsk retitled this revision from "[ubsan] Diagnose reached-unreachable after 
noreturn calls" to "[ubsan] Diagnose noreturn functions which return".
vsk edited the summary of this revision.
vsk added a comment.

- Emit the check in the noreturn function, so that the UB does not result in 
the optimizer throwing away the diagnostic instrumentation.


https://reviews.llvm.org/D40698

Files:
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-noreturn.c

Index: test/CodeGen/ubsan-noreturn.c
===
--- /dev/null
+++ test/CodeGen/ubsan-noreturn.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s
+
+// CHECK-LABEL: @f(
+void __attribute__((noreturn)) f() {
+  // CHECK: __ubsan_handle_builtin_unreachable
+  // CHECK: unreachable
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3736,6 +3736,10 @@
 llvm::ConstantInt *TypeId, llvm::Value *Ptr,
 ArrayRef StaticArgs);
 
+  /// Emit a reached-unreachable diagnostic if \p Loc is valid and runtime
+  /// checking is enabled. Otherwise, just emit an unreachable instruction.
+  void EmitUnreachable(SourceLocation Loc);
+
   /// \brief Create a basic block that will call the trap intrinsic, and emit a
   /// conditional branch to it, for the -ftrapv checks.
   void EmitTrapCheck(llvm::Value *Checked);
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3030,6 +3030,17 @@
   CGM.addUsedGlobal(F);
 }
 
+void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
+  if (SanOpts.has(SanitizerKind::Unreachable)) {
+SanitizerScope SanScope(this);
+EmitCheck(std::make_pair(static_cast(Builder.getFalse()),
+ SanitizerKind::Unreachable),
+  SanitizerHandler::BuiltinUnreachable,
+  EmitCheckSourceLocation(Loc), None);
+  }
+  Builder.CreateUnreachable();
+}
+
 void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -2753,9 +2753,15 @@
 void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
  bool EmitRetDbgLoc,
  SourceLocation EndLoc) {
+  if (FI.isNoReturn()) {
+// Noreturn functions don't return.
+EmitUnreachable(EndLoc);
+return;
+  }
+
   if (CurCodeDecl && CurCodeDecl->hasAttr()) {
 // Naked functions don't have epilogues.
-Builder.CreateUnreachable();
+EmitUnreachable(EndLoc);
 return;
   }
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1218,14 +1218,7 @@
   case Builtin::BI__debugbreak:
 return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
   case Builtin::BI__builtin_unreachable: {
-if (SanOpts.has(SanitizerKind::Unreachable)) {
-  SanitizerScope SanScope(this);
-  EmitCheck(std::make_pair(static_cast(Builder.getFalse()),
-   SanitizerKind::Unreachable),
-SanitizerHandler::BuiltinUnreachable,
-EmitCheckSourceLocation(E->getExprLoc()), None);
-} else
-  Builder.CreateUnreachable();
+EmitUnreachable(E->getExprLoc());
 
 // We do need to preserve an insertion point.
 EmitBlock(createBasicBlock("unreachable.cont"));
Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -124,8 +124,8 @@
   -  ``-fsanitize=signed-integer-overflow``: Signed integer overflow,
  including all the checks added by ``-ftrapv``, and checking for
  overflow in signed division (``INT_MIN / -1``).
-  -  ``-fsanitize=unreachable``: If control flow reaches
- ``__builtin_unreachable``.
+  -  ``-fsanitize=unreachable``: If control flow reaches an unreachable
+ program point.
   -  ``-fsanitize=unsigned-integer-overflow``: Unsigned integer
  overflows. Note that unlike signed integer overflow, unsigned integer
  is not undefined behavior. However, while it has well-defined semantics,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40698: [ubsan] Diagnose reached-unreachable after noreturn calls

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk planned changes to this revision.
vsk added a comment.

Ah, I've found a problem while writing run-time tests. I'll need to take 
another cut at this.


https://reviews.llvm.org/D40698



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


r319513 - [c++2a] P0515R3: Support for overloaded operator<=>.

2017-11-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov 30 18:13:10 2017
New Revision: 319513

URL: http://llvm.org/viewvc/llvm-project?rev=319513&view=rev
Log:
[c++2a] P0515R3: Support for overloaded operator<=>.

No CodeGen support for MSABI yet, we don't know how to mangle this there.

Added:
cfe/trunk/test/CodeGenCXX/cxx2a-three-way-comparison.cpp
cfe/trunk/test/SemaCXX/cxx2a-three-way-comparison.cpp
Modified:
cfe/trunk/include/clang/Basic/OperatorKinds.def
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Lexer/cxx2a-spaceship.cpp

Modified: cfe/trunk/include/clang/Basic/OperatorKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OperatorKinds.def?rev=319513&r1=319512&r2=319513&view=diff
==
--- cfe/trunk/include/clang/Basic/OperatorKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OperatorKinds.def Thu Nov 30 18:13:10 2017
@@ -89,6 +89,7 @@ OVERLOADED_OPERATOR(EqualEqual
 OVERLOADED_OPERATOR(ExclaimEqual , "!="  , exclaimequal   , false, 
true , false)
 OVERLOADED_OPERATOR(LessEqual, "<="  , lessequal  , false, 
true , false)
 OVERLOADED_OPERATOR(GreaterEqual , ">="  , greaterequal   , false, 
true , false)
+OVERLOADED_OPERATOR(Spaceship, "<=>" , spaceship  , false, 
true , false)
 OVERLOADED_OPERATOR(AmpAmp   , "&&"  , ampamp , false, 
true , false)
 OVERLOADED_OPERATOR(PipePipe , "||"  , pipepipe   , false, 
true , false)
 OVERLOADED_OPERATOR(PlusPlus , "++"  , plusplus   , true , 
true , false)

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=319513&r1=319512&r2=319513&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Nov 30 18:13:10 2017
@@ -2195,6 +2195,9 @@ CXXNameMangler::mangleOperatorName(Overl
   // Proposal on cxx-abi-dev, 2015-10-21.
   //  ::= aw# co_await
   case OO_Coawait: Out << "aw"; break;
+  // Proposed in cxx-abi github issue 43.
+  //  ::= ss# <=>
+  case OO_Spaceship: Out << "ss"; break;
 
   case OO_None:
   case NUM_OVERLOADED_OPERATORS:

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=319513&r1=319512&r2=319513&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Nov 30 18:13:10 2017
@@ -1192,6 +1192,15 @@ void MicrosoftCXXNameMangler::mangleOper
   //  ::= ?__L # co_await
   case OO_Coawait: Out << "?__L"; break;
 
+  case OO_Spaceship: {
+// FIXME: Once MS picks a mangling, use it.
+DiagnosticsEngine &Diags = Context.getDiags();
+unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+  "cannot mangle this three-way comparison operator yet");
+Diags.Report(Loc, DiagID);
+break;
+  }
+
   case OO_Conditional: {
 DiagnosticsEngine &Diags = Context.getDiags();
 unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=319513&r1=319512&r2=319513&view=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Nov 30 18:13:10 2017
@@ -1384,6 +1384,10 @@ static Stmt::StmtClass DecodeOperatorCal
   case OO_GreaterEqual:
 BinaryOp = BO_GE;
 return Stmt::BinaryOperatorClass;
+
+  case OO_Spaceship:
+// FIXME: Update this once we support <=> expressions.
+llvm_unreachable("<=> expressions not supported yet");
   
   case OO_AmpAmp:
 BinaryOp = BO_LAnd;

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=319513&r1=319512&r2=319513&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu Nov 30 18:13:10 2017
@@ -2184,7 +2184,7 @@ bool Parser::ParseUnqualifiedIdTemplateI
 ///! =<  >+= -=   *=  /=  %=
 ///^=&=   |= <<   >> >>= <<=  ==  !=
 ///<=>=   && ||   ++ --   ,   ->* ->
-///()[]
+///()[]   <=>
 ///
 ///   conversion-function-id: [C++ 12.3.2]
 /// operator conversion-type-id

Modified

[PATCH] D40562: [Sema] Ignore decls in namespaces when global decls are not wanted.

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

In https://reviews.llvm.org/D40562#940201, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D40562#939950, @arphaman wrote:
>
> > This change breaks cached completions for declarations in namespaces in 
> > libclang. What exactly are you trying to achieve here? We could introduce 
> > another flag maybe.
>
>
> Am I right to assume this cache is there to reduce the amount of `Decl`s we 
> need to deserialize from `Preamble`s? Maybe we could fix the cache to also 
> include namespace-level `Decl`s? It should improve performance of the cached 
> completions.


I'm not actually 100% sure, but I would imagine that this one of the reasons, 
yes. It would be nice to improve the cache to have things like namespace-level 
`Decl`, although how will lookup work in that case? Btw, do you think the cache 
can be reused in clangd as well?

> But for a quick workaround we could introduce a separate flag.


https://reviews.llvm.org/D40562



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


[PATCH] D40698: [ubsan] Diagnose reached-unreachable after noreturn calls

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

It's possible to reach an 'unreachable' instruction if a call to a
noreturn function returns. Diagnose this behavior.

Note: Most of the changes in this patch -- passing empty SourceLocations
in places where they are either not needed or do not apply -- are NFC.

Testing: check-clang, check-ubsan, check-ubsan-minimal

rdar://33660464


https://reviews.llvm.org/D40698

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/ubsan-unreachable.cpp

Index: test/CodeGenCXX/ubsan-unreachable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-unreachable.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=unreachable | FileCheck %s
+
+extern void __attribute__((noreturn)) abort();
+
+// CHECK-LABEL: define void @_Z14calls_noreturnv
+void calls_noreturn() {
+  abort();
+
+  // CHECK: __ubsan_handle_builtin_unreachable
+  // CHECK: unreachable
+}
+
+struct A {
+  // Test regular members.
+  void __attribute__((noreturn)) does_not_return1() {
+abort();
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A5call1Ev
+  void call1() {
+does_not_return1();
+
+// CHECK: __ubsan_handle_builtin_unreachable
+// CHECK: unreachable
+  }
+
+  // Test static members.
+  static void __attribute__((noreturn)) does_not_return2() {
+abort();
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A5call2Ev
+  void call2() {
+does_not_return2();
+
+// CHECK: __ubsan_handle_builtin_unreachable
+// CHECK: unreachable
+  }
+
+  // Test calls through pointers to non-static member functions.
+  typedef void __attribute__((noreturn)) (A::*MemFn)();
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A5call3Ev
+  void call3() {
+MemFn MF = &A::does_not_return1;
+(this->*MF)();
+
+// CHECK: __ubsan_handle_builtin_unreachable
+// CHECK: unreachable
+  }
+};
+
+void force_irgen() {
+  A a;
+  a.call1();
+  a.call2();
+  a.call3();
+}
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3941,7 +3941,7 @@
   CGCallee Callee = CGCallee::forDirect(CalleePtr, CD);
   const CGFunctionInfo &CalleeInfo = CGM.getTypes().arrangeCXXConstructorCall(
   Args, CD, Ctor_Complete, ExtraArgs.Prefix, ExtraArgs.Suffix);
-  CGF.EmitCall(CalleeInfo, Callee, ReturnValueSlot(), Args);
+  CGF.EmitCall(CalleeInfo, Callee, ReturnValueSlot(), Args, SourceLocation());
 
   Cleanups.ForceCleanup();
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3278,6 +3278,7 @@
   /// LLVM arguments and the types they were derived from.
   RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee,
   ReturnValueSlot ReturnValue, const CallArgList &Args,
+  SourceLocation Loc,
   llvm::Instruction **callOrInvoke = nullptr);
 
   RValue EmitCall(QualType FnType, const CGCallee &Callee, const CallExpr *E,
@@ -3740,6 +3741,10 @@
   /// conditional branch to it, for the -ftrapv checks.
   void EmitTrapCheck(llvm::Value *Checked);
 
+  /// If the unreachable sanitizer is disabled or \p Loc is invalid, simply
+  /// emit an UnreachableInst. Otherwise, emit a runtime trap.
+  void EmitUnreachable(SourceLocation Loc);
+
   /// \brief Emit a call to trap or debugtrap and attach function attribute
   /// "trap-func-name" if specified.
   llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID);
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -357,7 +357,8 @@
   // Now emit our call.
   llvm::Instruction *CallOrInvoke;
   CGCallee Callee = CGCallee::forDirect(CalleePtr, MD);
-  RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, &CallOrInvoke);
+  RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, SourceLocation(),
+   &CallOrInvoke);
 
   // Consider return adjustment if we have ThunkInfo.
   if (Thunk && !Thunk->Return.isEmpty())
Index: lib/CodeGen/CGObjCMac.cpp
===
--- lib/CodeGen/CGObjCMac.cpp
+++ lib/CodeGen/CGObjCMac.cpp
@@ -2167,7 +2167,7 @@
   Fn = llvm::ConstantExpr::getBitCast(Fn, MSI.MessengerType);
   CGCallee Callee = CGCallee::forDirect(Fn);
   RValue rvalue = CGF

[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

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



Comment at: lib/Driver/ToolChains/Darwin.cpp:1457-1465
   if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
  getTriple().getArch() == llvm::Triple::x86_64))
 Platform = IPhoneOSSimulator;
   if (TvOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64))
 Platform = TvOSSimulator;
   if (WatchOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||

bob.wilson wrote:
> These checks should set the simulator target as well.
This would break the `__APPLE_EMBEDDED_SIMULATOR__` macro, as that has to be 
specified only when is used `-m(iphone|tv|watch)simulator-version-min`. Or 
should we still set `__APPLE_EMBEDDED_SIMULATOR__` in the driver and allow 
`-simulator` even without `-m(iphone|tv|watch)simulator-version-min`?


Repository:
  rC Clang

https://reviews.llvm.org/D40682



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


[PATCH] D39284: Allow conditions to be decomposed with structured bindings

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



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:414
+def ext_decomp_decl_cond : ExtWarn<
+  "decomposed condition is a Clang extension">;
 def err_decomp_decl_spec : Error<

Phrase this as "ISO C++17 does not permit structured binding declaration in a 
condition"



Comment at: lib/Sema/SemaDeclCXX.cpp:712-720
+  Diag(Decomp.getLSquareLoc(), [&] {
+if (getLangOpts().CPlusPlus1z) {
+  if (D.getContext() == Declarator::ConditionContext)
+return diag::ext_decomp_decl_cond;
+  else
+return diag::warn_cxx14_compat_decomp_decl;
+} else

Using a lambda here seems like unwarranted complexity. A three-way ternary of 
the form

```
!getLangOpts().CPlusPlus1z ? diag::ext_decomp_decl :
D.getContext() == Declarator::ConditionContext ? diag::ext_decomp_decl_cond :
diag::warn_cxx14_compat_decomp_decl
```

would be fine. Feel free to ignore clang-format if it wants to format it 
stupidly.



Comment at: test/Misc/warning-flags.c:19
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 

Please read and respect this rule :)



Comment at: test/Parser/cxx1z-decomposition.cpp:35-36
   void g() {
-// A condition is not a simple-declaration.
-for (; auto [a, b, c] = S(); ) {} // expected-error {{not permitted in 
this context}}
-if (auto [a, b, c] = S()) {} // expected-error {{not permitted in this 
context}}
-if (int n; auto [a, b, c] = S()) {} // expected-error {{not permitted in 
this context}}
-switch (auto [a, b, c] = S()) {} // expected-error {{not permitted in this 
context}}
-switch (int n; auto [a, b, c] = S()) {} // expected-error {{not permitted 
in this context}}
-while (auto [a, b, c] = S()) {} // expected-error {{not permitted in this 
context}}
+// A condition is allowed as a Clang extension.
+// See commentary in test/Parser/decomposed-condition.cpp
 

You have removed test coverage here, at least for the `if` //init-statement// 
case. Please just update the comments on these tests rather than removing them.


https://reviews.llvm.org/D39284



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


r319509 - [c++2a] P0515R3: lexer support for new <=> token.

2017-11-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov 30 17:07:10 2017
New Revision: 319509

URL: http://llvm.org/viewvc/llvm-project?rev=319509&view=rev
Log:
[c++2a] P0515R3: lexer support for new <=> token.

Added:
cfe/trunk/test/Lexer/cxx2a-spaceship.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/TokenConcatenation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=319509&r1=319508&r2=319509&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Nov 30 17:07:10 2017
@@ -31,6 +31,14 @@ def warn_cxx98_compat_less_colon_colon :
   "'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98">,
   InGroup, DefaultIgnore;
 
+def warn_cxx17_compat_spaceship : Warning<
+  "'<=>' operator is incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
+def warn_cxx2a_compat_spaceship : Warning<
+  "'<=>' is a single token in C++2a; "
+  "add a space to avoid a change in behavior">,
+  InGroup;
+
 // Trigraphs.
 def trigraph_ignored : Warning<"trigraph ignored">, InGroup;
 def trigraph_ignored_block_comment : Warning<

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=319509&r1=319508&r2=319509&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Thu Nov 30 17:07:10 2017
@@ -194,6 +194,7 @@ PUNCTUATOR(less,"<")
 PUNCTUATOR(lessless,"<<")
 PUNCTUATOR(lessequal,   "<=")
 PUNCTUATOR(lesslessequal,   "<<=")
+PUNCTUATOR(spaceship,   "<=>")
 PUNCTUATOR(greater, ">")
 PUNCTUATOR(greatergreater,  ">>")
 PUNCTUATOR(greaterequal,">=")

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=319509&r1=319508&r2=319509&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Nov 30 17:07:10 2017
@@ -3522,6 +3522,24 @@ LexNextToken:
 Kind = tok::lessless;
   }
 } else if (Char == '=') {
+  char After = getCharAndSize(CurPtr+SizeTmp, SizeTmp2);
+  if (After == '>') {
+if (getLangOpts().CPlusPlus2a) {
+  if (!isLexingRawMode())
+Diag(BufferPtr, diag::warn_cxx17_compat_spaceship);
+  CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
+   SizeTmp2, Result);
+  Kind = tok::spaceship;
+  break;
+}
+// Suggest adding a space between the '<=' and the '>' to avoid a
+// change in semantics if this turns up in C++ <=17 mode.
+if (getLangOpts().CPlusPlus && !isLexingRawMode()) {
+  Diag(BufferPtr, diag::warn_cxx2a_compat_spaceship)
+<< FixItHint::CreateInsertion(
+   getSourceLocation(CurPtr + SizeTmp, SizeTmp2), " ");
+}
+  }
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
   Kind = tok::lessequal;
 } else if (LangOpts.Digraphs && Char == ':') { // '<:' -> '['

Modified: cfe/trunk/lib/Lex/TokenConcatenation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenConcatenation.cpp?rev=319509&r1=319508&r2=319509&view=diff
==
--- cfe/trunk/lib/Lex/TokenConcatenation.cpp (original)
+++ cfe/trunk/lib/Lex/TokenConcatenation.cpp Thu Nov 30 17:07:10 2017
@@ -103,6 +103,10 @@ TokenConcatenation::TokenConcatenation(P
   if (PP.getLangOpts().CPlusPlus1z)
 TokenInfo[tok::utf8_char_constant] |= aci_custom;
 
+  // These tokens have custom code in C++2a mode.
+  if (PP.getLangOpts().CPlusPlus2a)
+TokenInfo[tok::lessequal ] |= aci_custom_firstchar;
+
   // These tokens change behavior if followed by an '='.
   TokenInfo[tok::amp ] |= aci_avoid_equal;   // &=
   TokenInfo[tok::plus] |= aci_avoid_equal;   // +=
@@ -283,5 +287,7 @@ bool TokenConcatenation::AvoidConcat(con
 return FirstChar == '#' || FirstChar == '@' || FirstChar == '%';
   case tok::arrow:   // ->*
 return PP.getLangOpts().CPlusPlus && FirstChar == '*';
+  case tok::lessequal:   // <=> (C++2a)
+return PP.getLangOpts().CPlusPlus2a && FirstChar == '>';
   }
 }

Added: cfe/trunk/test/Lexer/cxx2a-spaceship.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx2a-spaceship.cpp?rev=319509&view=auto
=

[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

2017-11-30 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson requested changes to this revision.
bob.wilson added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Driver/ToolChains/Darwin.cpp:1457-1465
   if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
  getTriple().getArch() == llvm::Triple::x86_64))
 Platform = IPhoneOSSimulator;
   if (TvOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64))
 Platform = TvOSSimulator;
   if (WatchOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||

These checks should set the simulator target as well.


Repository:
  rC Clang

https://reviews.llvm.org/D40682



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

smeenai wrote:
> compnerd wrote:
> > smeenai wrote:
> > > I guess `_DLL` is appropriate here. Ideally though I think adding the 
> > > pragma should be keyed on exactly the same conditional that determines 
> > > whether we annotate with dllexport/dllimport, and right now that's only 
> > > conditional on `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
> > Its more complicated.  This is for the *user* not the library itself.  When 
> > building the shared library we need to ensure that it is not added 
> > (`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a user, 
> > the `_DLL` tells you about the dynamic/static behavior.
> I know, but the dllimport annotations are also for the *user*. If you're 
> getting the dllimport annotations, you should also be getting the pragma, and 
> vice-versa.
Right, but `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS` does not imply use of a 
static libc++, but `!defined(_DLL)` does, unless Im missing something.  So 
doesn't this do exactly what you were thinking of?


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660



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


r319505 - Mark all library options as hidden.

2017-11-30 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Nov 30 16:53:10 2017
New Revision: 319505

URL: http://llvm.org/viewvc/llvm-project?rev=319505&view=rev
Log:
Mark all library options as hidden.

These command line options are not intended for public use, and often
don't even make sense in the context of a particular tool anyway. About
90% of them are already hidden, but when people add new options they
forget to hide them, so if you were to make a brand new tool today, link
against one of LLVM's libraries, and run tool -help you would get a
bunch of junk that doesn't make sense for the tool you're writing.

This patch hides these options. The real solution is to not have
libraries defining command line options, but that's a much larger effort
and not something I'm prepared to take on.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=319505&r1=319504&r2=319505&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Nov 30 16:53:10 2017
@@ -61,7 +61,7 @@ using namespace clang;
 using namespace CodeGen;
 
 static llvm::cl::opt LimitedCoverage(
-"limited-coverage-experimental", llvm::cl::ZeroOrMore,
+"limited-coverage-experimental", llvm::cl::ZeroOrMore, llvm::cl::Hidden,
 llvm::cl::desc("Emit limited coverage mapping information (experimental)"),
 llvm::cl::init(false));
 

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=319505&r1=319504&r2=319505&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Thu Nov 30 16:53:10 2017
@@ -22,9 +22,10 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
 
-static llvm::cl::opt EnableValueProfiling(
-  "enable-value-profiling", llvm::cl::ZeroOrMore,
-  llvm::cl::desc("Enable value profiling"), llvm::cl::init(false));
+static llvm::cl::opt
+EnableValueProfiling("enable-value-profiling", llvm::cl::ZeroOrMore,
+ llvm::cl::desc("Enable value profiling"),
+ llvm::cl::Hidden, llvm::cl::init(false));
 
 using namespace clang;
 using namespace CodeGen;


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


[PATCH] D40563: [SemaCodeComplete] Allow passing out scope specifiers in qualified-id completions via completion context.

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

In https://reviews.llvm.org/D40563#940536, @ioeric wrote:

> In https://reviews.llvm.org/D40563#939964, @arphaman wrote:
>
> > If nothing uses `getCXXScopeSpecifier` right now we can't really test it 
> > with a clang or c-index-test regression test. A completion unit test could 
> > work here. I don't think we actually have existing completion unit tests 
> > though, so you would have to create one from scratch. But if 
> > `getCXXScopeSpecifier` will be used in a follow up patch maybe it will be 
> > easier to commit this without a test together with the followup patch?
>
>
> I have another clangd patch that uses this, but this would still need to be a 
> separate patch since they are in different repos...


You can commit the two in one either using the monrepo or sparse SVN checkout ;)
But I wouldn't object if you commit this separately right before the clangd 
patch, so LGTM


https://reviews.llvm.org/D40563



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


[PATCH] D40568: design document for a hardware-assisted memory safety (HWAMS) tool, similar to AddressSanitizer

2017-11-30 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc updated this revision to Diff 125045.
kcc added a comment.

Rename the new tool to HWASAN


Repository:
  rC Clang

https://reviews.llvm.org/D40568

Files:
  docs/HardwareAssistedAddressSanitizerDesign.rst
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -84,6 +84,7 @@
PTHInternals
PCHInternals
ItaniumMangleAbiTags
+   HardwareAssistedAddressSanitizerDesign.rst
 
 
 Indices and tables
Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- /dev/null
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -0,0 +1,123 @@
+=
+HardwareAssistedAddressSanitizer Design Documentation
+=
+
+This page is a design document for
+**HardwareAssistedAddressSanitizer** (or HWASAN)
+a tool similar to :doc:`AddressSanitizer`,
+but based on partial hardware assistance.
+
+The document is a draft, suggestions are welcome.
+
+
+Introduction
+
+
+:doc:`AddressSanitizer`
+tags every 8 bytes of the application memory with a 1 byte tag (using *shadow memory*),
+uses *redzones* to find buffer-overflows and
+*quarantine* to find use-after-free.
+The redzones, the quarantine, and, to a less extent, the shadow, are the
+sources of AddressSanitizer's memory overhead.
+See the `AddressSanitizer paper`_ for details.
+
+AArch64 has the `Address Tagging`_, a hardware feature that allows
+software to use 8 most significant bits of a 64-bit pointer as
+a tag. HardwareAssistedAddressSanitizer uses `Address Tagging`_
+to implement a memory safety tool, similar to :doc:`AddressSanitizer`,
+but with smaller memory overhead and slightly different (mostly better)
+accuracy guarantees.
+
+Algorithm
+=
+* Every heap/stack/global memory object is forcibly aligned by `N` bytes
+  (`N` is e.g. 16 or 64)
+* For every such object a random `K`-bit tag `T` is chosen (`K` is e.g. 4 or 8)
+* The pointer to the object is tagged with `T`.
+* The memory for the object is also tagged with `T`
+  (using a `N=>1` shadow memory)
+* Every load and store is instrumented to read the memory tag and compare it
+  with the pointer tag, exception is raised on tag mismatch.
+
+Instrumentation
+===
+
+Memory Accesses
+---
+All memory accesses are prefixed with a call to a run-time function.
+The function encodes the type and the size of access in its name;
+it receives the address as a parameter, e.g. `__hwasan_load4(void *ptr)`;
+it loads the memory tag, compares it with the
+pointer tag, and executes `__builtin_trap` (or calls `__hwasan_error_load4(void *ptr)`) on mismatch.
+
+It's possible to inline this callback too.
+
+Heap
+
+
+Tagging the heap memory/pointers is done by `malloc`.
+This can be based on any malloc that forces all objects to be N-aligned.
+
+Stack
+-
+
+Special compiler instrumentation is required to align the local variables
+by N, tag the memory and the pointers.
+Stack instrumentation is expected to be a major source of overhead,
+but could be optional.
+TODO: details.
+
+Globals
+---
+
+TODO: details.
+
+Error reporting
+---
+
+Errors are generated by `__builtin_trap` and are handled by a signal handler.
+
+
+Comparison with AddressSanitizer
+
+
+HardwareAssistedAddressSanitizer:
+  * Is less portable than :doc:`AddressSanitizer`
+as it relies on hardware `Address Tagging`_ (AArch64).
+Address Tagging can be emulated with compiler instrumentation,
+but it will require the instrumentation to remove the tags before
+any load or store, which is infeasible in any realistic environment
+that contains non-instrumented code.
+  * May have compatibility problems if the target code uses higher
+pointer bits for other purposes.
+  * May require changes in the OS kernels (e.g. Linux seems to dislike
+tagged pointers passed from address space).
+  * **Does not require redzones to detect buffer overflows**,
+but the buffer overflow detection is probabilistic, with roughly
+`(2**K-1)/(2**K)` probability of catching a bug.
+  * **Does not require quarantine to detect heap-use-after-free,
+or stack-use-after-return**.
+The detection is similarly probabilistic.
+
+The memory overhead of HardwareAssistedAddressSanitizer is expected to be much smaller
+than that of AddressSanitizer:
+`1/N` extra memory for the shadow
+and some overhead due to `N`-aligning all objects.
+
+
+Related Work
+
+* `SPARC ADI`_ implements a similar tool mostly in hardware.
+* `Effective and Efficient Memory Protection Using Dynamic Tainting`_ discusses
+  similar approaches ("lock & key").
+* `Watchdog`_ discussed a heavier, but still somewhat similar
+  "lock & key" approach.
+* *TODO: add more "related work" links. Suggestions are welcome.*
+
+
+.. _Wat

[PATCH] D40681: [libc++abi] Add install-cxxabi-stripped target

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319499: [libc++abi] Add install-cxxabi-stripped target 
(authored by smeenai).

Repository:
  rL LLVM

https://reviews.llvm.org/D40681

Files:
  libcxxabi/trunk/src/CMakeLists.txt


Index: libcxxabi/trunk/src/CMakeLists.txt
===
--- libcxxabi/trunk/src/CMakeLists.txt
+++ libcxxabi/trunk/src/CMakeLists.txt
@@ -192,6 +192,12 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)


Index: libcxxabi/trunk/src/CMakeLists.txt
===
--- libcxxabi/trunk/src/CMakeLists.txt
+++ libcxxabi/trunk/src/CMakeLists.txt
@@ -192,6 +192,12 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r319499 - [libc++abi] Add install-cxxabi-stripped target

2017-11-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Nov 30 15:25:51 2017
New Revision: 319499

URL: http://llvm.org/viewvc/llvm-project?rev=319499&view=rev
Log:
[libc++abi] Add install-cxxabi-stripped target

LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++abi, let's do it manually.

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

Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=319499&r1=319498&r2=319499&view=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Thu Nov 30 15:25:51 2017
@@ -192,6 +192,12 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND LI
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)


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


[PATCH] D40685: [libunwind] Switch to add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319498: [libunwind] Switch to add_llvm_install_targets 
(authored by smeenai).

Repository:
  rL LLVM

https://reviews.llvm.org/D40685

Files:
  libunwind/trunk/src/CMakeLists.txt


Index: libunwind/trunk/src/CMakeLists.txt
===
--- libunwind/trunk/src/CMakeLists.txt
+++ libunwind/trunk/src/CMakeLists.txt
@@ -139,9 +139,7 @@
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()


Index: libunwind/trunk/src/CMakeLists.txt
===
--- libunwind/trunk/src/CMakeLists.txt
+++ libunwind/trunk/src/CMakeLists.txt
@@ -139,9 +139,7 @@
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r319498 - [libunwind] Switch to add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Nov 30 15:24:08 2017
New Revision: 319498

URL: http://llvm.org/viewvc/llvm-project?rev=319498&view=rev
Log:
[libunwind] Switch to add_llvm_install_targets

This gains us the install-unwind-stripped target, to perform stripping
during installation.

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

Modified:
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=319498&r1=319497&r2=319498&view=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Thu Nov 30 15:24:08 2017
@@ -139,9 +139,7 @@ if (LIBUNWIND_INSTALL_LIBRARY)
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()


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


[PATCH] D40687: [compiler-rt] Switch to add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added subscribers: mgorny, dberris.

This gains us the install-*-stripped targets, to strip binaries during
installation. These targets otherwise mimic the existing install targets.


https://reviews.llvm.org/D40687

Files:
  cmake/Modules/AddCompilerRT.cmake
  cmake/base-config-ix.cmake


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -11,6 +11,7 @@
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
+add_custom_target(install-compiler-rt-stripped)
 set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")
 
 # Setting these variables from an LLVM build is sufficient that compiler-rt can
Index: cmake/Modules/AddCompilerRT.cmake
===
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -205,14 +205,15 @@
   # The parent install target specifies the parent component to scrape up
   # anything not installed by the individual install targets, and to handle
   # installation when running the multi-configuration generators.
-  add_custom_target(install-${LIB_PARENT_TARGET}
-DEPENDS ${LIB_PARENT_TARGET}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${LIB_PARENT_TARGET}
+   DEPENDS ${LIB_PARENT_TARGET}
+   COMPONENT ${LIB_PARENT_TARGET})
   set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
 FOLDER "Compiler-RT Misc")
+  set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
+FOLDER "Compiler-RT Misc")
   add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
+  add_dependencies(install-compiler-rt-stripped 
install-${LIB_PARENT_TARGET}-stripped)
 endif()
   endif()
 
@@ -262,15 +263,14 @@
 # We only want to generate per-library install targets if you aren't using
 # an IDE because the extra targets get cluttered in IDEs.
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${libname}
-DEPENDS ${libname}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${libname}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${libname}
+   DEPENDS ${libname}
+   COMPONENT ${libname})
   # If you have a parent target specified, we bind the new install target
   # to the parent install target.
   if(LIB_PARENT_TARGET)
 add_dependencies(install-${LIB_PARENT_TARGET} install-${libname})
+add_dependencies(install-${LIB_PARENT_TARGET}-stripped 
install-${libname}-stripped)
   endif()
 endif()
 if(APPLE)


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -11,6 +11,7 @@
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
+add_custom_target(install-compiler-rt-stripped)
 set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")
 
 # Setting these variables from an LLVM build is sufficient that compiler-rt can
Index: cmake/Modules/AddCompilerRT.cmake
===
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -205,14 +205,15 @@
   # The parent install target specifies the parent component to scrape up
   # anything not installed by the individual install targets, and to handle
   # installation when running the multi-configuration generators.
-  add_custom_target(install-${LIB_PARENT_TARGET}
-DEPENDS ${LIB_PARENT_TARGET}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${LIB_PARENT_TARGET}
+   DEPENDS ${LIB_PARENT_TARGET}
+   COMPONENT ${LIB_PARENT_TARGET})
   set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
 FOLDER "Compiler-RT Misc")
+  set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
+FOLDER "Compiler-RT Misc")
   add_depe

[clang-tools-extra] r319497 - [clangd] Logger implicitly adds newline

2017-11-30 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov 30 15:21:34 2017
New Revision: 319497

URL: http://llvm.org/viewvc/llvm-project?rev=319497&view=rev
Log:
[clangd] Logger implicitly adds newline

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=319497&r1=319496&r2=319497&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Nov 30 15:21:34 2017
@@ -1151,7 +1151,7 @@ CppFile::CppFile(PathRef FileName, tooli
   RebuildInProgress(false), PCHs(std::move(PCHs)), Logger(Logger) {
   Logger.log("Opened file " + FileName + " with command [" +
  this->Command.Directory + "] " +
- llvm::join(this->Command.CommandLine, " ") + "\n");
+ llvm::join(this->Command.CommandLine, " "));
 
   std::lock_guard Lock(Mutex);
   LatestAvailablePreamble = nullptr;

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=319497&r1=319496&r2=319497&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Thu Nov 30 
15:21:34 2017
@@ -100,8 +100,7 @@ DirectoryBasedGlobalCompilationDatabase:
 tryLoadDatabaseFromPath(CompileCommandsDir.getValue());
 if (ReturnValue == nullptr)
   Logger.log("Failed to find compilation database for " + Twine(File) +
- "in overriden directory " + CompileCommandsDir.getValue() +
- "\n");
+ "in overriden directory " + CompileCommandsDir.getValue());
 return ReturnValue;
   }
 
@@ -114,7 +113,7 @@ DirectoryBasedGlobalCompilationDatabase:
 return CDB;
   }
 
-  Logger.log("Failed to find compilation database for " + Twine(File) + "\n");
+  Logger.log("Failed to find compilation database for " + Twine(File));
   return nullptr;
 }
 

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=319497&r1=319496&r2=319497&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Thu Nov 30 15:21:34 
2017
@@ -41,7 +41,7 @@ void JSONOutput::writeMessage(const json
 void JSONOutput::log(const Twine &Message) {
   trace::log(Message);
   std::lock_guard Guard(StreamMutex);
-  Logs << Message;
+  Logs << Message << '\n';
   Logs.flush();
 }
 
@@ -55,7 +55,7 @@ void JSONOutput::mirrorInput(const Twine
 
 void RequestContext::reply(json::Expr &&Result) {
   if (!ID) {
-Out.log("Attempted to reply to a notification!\n");
+Out.log("Attempted to reply to a notification!");
 return;
   }
   SPAN_ATTACH(tracer(), "Reply", Result);
@@ -68,7 +68,7 @@ void RequestContext::reply(json::Expr &&
 
 void RequestContext::replyError(ErrorCode code,
 const llvm::StringRef &Message) {
-  Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
+  Out.log("Error " + Twine(static_cast(code)) + ": " + Message);
   SPAN_ATTACH(tracer(), "Error",
   (json::obj{{"code", static_cast(code)},
  {"message", Message.str()}}));
@@ -166,7 +166,7 @@ void clangd::runLanguageServerLoop(std::
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
   "The previous value for this message (" +
-  std::to_string(ContentLength) + ") was ignored.\n");
+  std::to_string(ContentLength) + ") was ignored.");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -186,7 +186,7 @@ void clangd::runLanguageServerLoop(std::
 if (ContentLength > 1 << 30) { // 1024M
   In.ignore(ContentLength);
   Out.log("Skipped overly large message of " + Twine(ContentLength) +
-  " bytes.\n");
+  " bytes.");
   continue;
 }
 
@@ -202,7 +202,7 @@ void clangd::runLanguageServerLoop(std::
 if (!In) {
   Out.log("Input was aborted. Read only " +
   std::to_string(In.gcount()) + " bytes of expected " +
-  std::to_string(ContentLength) + ".\n");
+  std::to_string(ContentLength) + ".");

Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2017-11-30 Thread Reid Kleckner via cfe-commits
On Thu, Nov 30, 2017 at 10:21 AM, Dan Olson via Phabricator <
revi...@reviews.llvm.org> wrote:

> dolson added a comment.
>
> Hello,
>
> In the process of upgrading from clang 3.6.1 to a newer version, I ran
> into this new error and thus imported the new intrinsics from intrin.h for
> rep movsb and friends.  I see several discussions in this thread about how
> having the registers solely in the inputs list is not sufficient for
> something like "rep movsb" because the modified registers will not be
> clobbered, however none of these suggested changes made it into the
> eventual intrin.h.
>
> I found that using the versions of `__movsb` and `__stosb` that are at the
> head revision intrin.h produced bad code generation vs the versions with
> the clobbers.  Note this is on PS4 under the older clang 3.6.1, but I don't
> see anything in this CL that would update the clobber behavior for newer
> versions of clang.
>
> Shouldn't the intrinsics be updated to use input/output registers or some
> other method of clobbering?


Yes, they should be. I misread this thread and thought somebody had gone
and fixed these, but I guess not. I sent out https://reviews.llvm.org/D40686
.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r319496 - [clangd] Log file compile commands

2017-11-30 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov 30 15:16:23 2017
New Revision: 319496

URL: http://llvm.org/viewvc/llvm-project?rev=319496&view=rev
Log:
[clangd] Log file compile commands

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=319496&r1=319495&r2=319496&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Nov 30 15:16:23 2017
@@ -1149,6 +1149,9 @@ CppFile::CppFile(PathRef FileName, tooli
 : FileName(FileName), Command(std::move(Command)),
   StorePreamblesInMemory(StorePreamblesInMemory), RebuildCounter(0),
   RebuildInProgress(false), PCHs(std::move(PCHs)), Logger(Logger) {
+  Logger.log("Opened file " + FileName + " with command [" +
+ this->Command.Directory + "] " +
+ llvm::join(this->Command.CommandLine, " ") + "\n");
 
   std::lock_guard Lock(Mutex);
   LatestAvailablePreamble = nullptr;


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


[PATCH] D40685: [libunwind] Switch to add_llvm_install_targets

2017-11-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D40685



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


[PATCH] D40681: [libc++abi] Add install-cxxabi-stripped target

2017-11-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D40681



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


[PATCH] D40685: [libunwind] Switch to add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

This gains us the install-unwind-stripped target, to perform stripping
during installation.


https://reviews.llvm.org/D40685

Files:
  src/CMakeLists.txt


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -139,9 +139,7 @@
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -139,9 +139,7 @@
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319495 - Update website to mention that you still need -frelaxed-template-template-args to enable the corresponding C++17 feature in Clang 5.

2017-11-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov 30 15:07:29 2017
New Revision: 319495

URL: http://llvm.org/viewvc/llvm-project?rev=319495&view=rev
Log:
Update website to mention that you still need -frelaxed-template-template-args 
to enable the corresponding C++17 feature in Clang 5.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=319495&r1=319494&r2=319495&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Nov 30 15:07:29 2017
@@ -768,7 +768,8 @@ reverse construction order in that ABI.
 
 (12): Despite being the the resolution to a Defect Report, 
this
 feature is disabled by default in all language versions, and can be enabled
-explicitly with the flag -frelaxed-template-template-args in Clang 4.
+explicitly with the flag -frelaxed-template-template-args in Clang 4
+onwards.
 The change to the standard lacks a corresponding change for template partial
 ordering, resulting in ambiguity errors for reasonable and previously-valid
 code. This issue is expected to be rectified soon.


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


[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-11-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Still worried about the effect on tools which parse clang diagnostics... please 
send a message to cfe-dev.  Hopefully we'll get responses there.


https://reviews.llvm.org/D33765



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


[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

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

r316380 added support for the 'simulator' environment to LLVM's triple. Clang's 
driver should pass this to the compiler when `-msimulator-version-min` 
option is specified so that the compiler can avoid using OS & arch specific 
checks.


Repository:
  rC Clang

https://reviews.llvm.org/D40682

Files:
  include/clang/Driver/ToolChain.h
  lib/CodeGen/CGObjCMac.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/darwin-version.c

Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -41,7 +41,7 @@
 
 // RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10 %s
-// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0
+// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0-simulator
 
 // RUN: %clang -target arm64-apple-ios11.1 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
@@ -85,13 +85,13 @@
 // CHECK-VERSION-TVOS83: "thumbv7-apple-tvos8.3.0"
 // RUN: %clang -target i386-apple-darwin -mtvos-simulator-version-min=8.3 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVSIM83 %s
-// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0"
+// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0-simulator"
 // RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s
 // CHECK-VERSION-WATCHOS20: "thumbv7k-apple-watchos2.0.0"
 // RUN: %clang -target i386-apple-darwin -mwatchos-simulator-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHSIM20 %s
-// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0"
+// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0-simulator"
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -987,6 +987,11 @@
 Builder.defineMacro("__nullable", "_Nullable");
   }
 
+  // Add a macro to differentiate between regular iOS/tvOS/watchOS targets and
+  // the corresponding simulator targets.
+  if (TI.getTriple().isOSDarwin() && TI.getTriple().isSimulatorEnvironment())
+Builder.defineMacro("__APPLE_EMBEDDED_SIMULATOR__", "1");
+
   // OpenMP definition
   // OpenMP 2.2:
   //   In implementations that support a preprocessor, the _OPENMP
Index: lib/Driver/ToolChains/Darwin.h
===
--- lib/Driver/ToolChains/Darwin.h
+++ lib/Driver/ToolChains/Darwin.h
@@ -317,7 +317,7 @@
   // FIXME: Eliminate these ...Target functions and derive separate tool chains
   // for these targets and put version in constructor.
   void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor,
- unsigned Micro) const {
+ unsigned Micro, bool Simulator) const {
 // FIXME: For now, allow reinitialization as long as values don't
 // change. This will go away when we move away from argument translation.
 if (TargetInitialized && TargetPlatform == Platform &&
@@ -328,6 +328,8 @@
 TargetInitialized = true;
 TargetPlatform = Platform;
 TargetVersion = VersionTuple(Major, Minor, Micro);
+if (Simulator)
+  const_cast(this)->setTripleEnvironment(llvm::Triple::Simulator);
   }
 
   bool isTargetIPhoneOS() const {
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1214,13 +1214,16 @@
   if (iOSVersion)
 ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args);
 
-  // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
-  // -m(iphone|tv|watch)simulator-version-min=X.Y.
+  bool Simulator;
+  // Differentiate between m(iphone|tv|watch)os-version-min=X.Y and
+  // -m(iphone|tv|watch)simulator-version-min=X.Y using the 'simulator'
+  // environment in the triple.
   if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
   Args.hasArg(options::OPT_mtvos_simulator_version_min_EQ) ||
   Args.hasArg(options::OPT_mwatchos_simulator_version_min_EQ))
-Args.append(Args.MakeSeparateArg(nullptr, Opts.getOption(options::OPT_D),
- " __APPLE_EMBEDDED_SIMULATOR__=1"));
+Simulator = true;
+  else
+Simulator = false;
 
   if (OSXVersion && (iOSVersion || TvOSVersion || WatchOSVersion)) {
 getDriver().Diag(diag::err_drv_argument_not_allowed_with)
@@ -1461,7 +1464,7 @@
  getTriple().getArch() == llvm::Tripl

[PATCH] D40681: [libc++abi] Add install-cxxabi-stripped target

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++abi, let's do it manually.


https://reviews.llvm.org/D40681

Files:
  src/CMakeLists.txt


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -192,6 +192,12 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -192,6 +192,12 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40680: [libc++] Create install-stripped targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 125034.
smeenai added a comment.

Don't add deprecated target names, since clients should be switching over to 
the new ones.


https://reviews.llvm.org/D40680

Files:
  include/CMakeLists.txt
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,13 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,6 +58,8 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,13 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,6 +58,8 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40680: [libc++] Create install-stripped targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++, let's do it manually.


https://reviews.llvm.org/D40680

Files:
  include/CMakeLists.txt
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,14 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
+add_custom_target(install-libcxx-stripped DEPENDS install-cxx-stripped)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,9 +58,12 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
+add_custom_target(install-libcxx-headers-stripped DEPENDS 
install-libcxx-headers)
   endif()
 
 endif()


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,14 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
+add_custom_target(install-libcxx-stripped DEPENDS install-cxx-stripped)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,9 +58,12 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
+add_custom_target(install-libcxx-headers-stripped DEPENDS install-libcxx-headers)
   endif()
 
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40675: [clang] Use add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319489: [clang] Use add_llvm_install_targets (authored by 
smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D40675?vs=125013&id=125026#toc

Repository:
  rC Clang

https://reviews.llvm.org/D40675

Files:
  cmake/modules/AddClang.cmake
  lib/Headers/CMakeLists.txt
  runtime/CMakeLists.txt
  tools/c-index-test/CMakeLists.txt
  tools/libclang/CMakeLists.txt

Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -141,9 +141,7 @@
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-clang-headers
-DEPENDS clang-headers
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-clang-headers
+   DEPENDS clang-headers
+   COMPONENT clang-headers)
 endif()
Index: tools/c-index-test/CMakeLists.txt
===
--- tools/c-index-test/CMakeLists.txt
+++ tools/c-index-test/CMakeLists.txt
@@ -56,10 +56,8 @@
 COMPONENT c-index-test)
 
   if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-add_custom_target(install-c-index-test
-  DEPENDS c-index-test
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=c-index-test
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-c-index-test
+ DEPENDS c-index-test
+ COMPONENT c-index-test)
   endif()
 endif()
Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -148,9 +148,6 @@
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-libclang-headers
-DEPENDS
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=libclang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-libclang-headers
+   COMPONENT libclang-headers)
 endif()
Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -101,12 +101,9 @@
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
 COMPONENT compiler-rt)
 
-  add_custom_target(install-compiler-rt
-DEPENDS compiler-rt
-COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=compiler-rt
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-USES_TERMINAL)
+  add_llvm_install_targets(install-compiler-rt
+   DEPENDS compiler-rt
+   COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -104,11 +104,9 @@
 RUNTIME DESTINATION bin)
 
   if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-add_custom_target(install-${name}
-  DEPENDS ${name}
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=${name}
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
   endif()
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
@@ -147,11 +145,9 @@
   COMPONENT ${name})
 
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${name}
-DEPENDS ${name}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${name}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${name}
+   DEPENDS ${name}
+   COMPONENT ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

r319489 - [clang] Use add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Nov 30 14:35:02 2017
New Revision: 319489

URL: http://llvm.org/viewvc/llvm-project?rev=319489&view=rev
Log:
[clang] Use add_llvm_install_targets

Use this function to create the install targets rather than doing so
manually, which gains us the `-stripped` install targets to perform
stripped installations.

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

Modified:
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/runtime/CMakeLists.txt
cfe/trunk/tools/c-index-test/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Thu Nov 30 14:35:02 2017
@@ -104,11 +104,9 @@ macro(add_clang_library name)
 RUNTIME DESTINATION bin)
 
   if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-add_custom_target(install-${name}
-  DEPENDS ${name}
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=${name}
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
   endif()
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
@@ -147,11 +145,9 @@ macro(add_clang_tool name)
   COMPONENT ${name})
 
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${name}
-DEPENDS ${name}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${name}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${name}
+   DEPENDS ${name}
+   COMPONENT ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Thu Nov 30 14:35:02 2017
@@ -141,9 +141,7 @@ install(
   DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-clang-headers
-DEPENDS clang-headers
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-clang-headers
+   DEPENDS clang-headers
+   COMPONENT clang-headers)
 endif()

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Thu Nov 30 14:35:02 2017
@@ -101,12 +101,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} 
-DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P 
${BINARY_DIR}/cmake_install.cmake \)"
 COMPONENT compiler-rt)
 
-  add_custom_target(install-compiler-rt
-DEPENDS compiler-rt
-COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=compiler-rt
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-USES_TERMINAL)
+  add_llvm_install_targets(install-compiler-rt
+   DEPENDS compiler-rt
+   COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan 
ubsan ubsan-minimal)

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Thu Nov 30 14:35:02 2017
@@ -56,10 +56,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 COMPONENT c-index-test)
 
   if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-add_custom_target(install-c-index-test
-  DEPENDS c-index-test
-  COMMAND "${CM

r319487 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-30 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Nov 30 14:33:48 2017
New Revision: 319487

URL: http://llvm.org/viewvc/llvm-project?rev=319487&view=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/CXXInheritance.h
cfe/trunk/include/clang/AST/DeclLookups.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/AST/ExprObjC.cpp

Modified: cfe/trunk/include/clang/AST/CXXInheritance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=319487&r1=319486&r2=319487&view=diff
==
--- cfe/trunk/include/clang/AST/CXXInheritance.h (original)
+++ cfe/trunk/include/clang/AST/CXXInheritance.h Thu Nov 30 14:33:48 2017
@@ -1,4 +1,4 @@
-//===-- CXXInheritance.h - C++ Inheritance --*- C++ 
-*-===//
+//===- CXXInheritance.h - C++ Inheritance ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -16,19 +16,23 @@
 
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeOrdering.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include 
+#include "llvm/ADT/iterator_range.h"
 #include 
+#include 
+#include 
 
 namespace clang {
-  
-class CXXBaseSpecifier;
-class CXXMethodDecl;
-class CXXRecordDecl;
+
+class ASTContext;
 class NamedDecl;
   
 /// \brief Represents an element in a path from a derived class to a
@@ -66,12 +70,12 @@ struct CXXBasePathElement {
 /// subobject is being used.
 class CXXBasePath : public SmallVector {
 public:
-  CXXBasePath() : Access(AS_public) {}
-
   /// \brief The access along this inheritance path.  This is only
   /// calculated when recording paths.  AS_none is a special value
   /// used to indicate a path which permits no legal access.
-  AccessSpecifier Access;
+  AccessSpecifier Access = AS_public;
+
+  CXXBasePath() = default;
 
   /// \brief The set of declarations found inside this base class
   /// subobject.
@@ -113,8 +117,10 @@ public:
 /// refer to the same base class subobject of type A (the virtual
 /// one), there is no ambiguity.
 class CXXBasePaths {
+  friend class CXXRecordDecl;
+
   /// \brief The type from which this search originated.
-  CXXRecordDecl *Origin;
+  CXXRecordDecl *Origin = nullptr;
   
   /// Paths - The actual set of paths that can be taken from the
   /// derived class to the same base class.
@@ -152,15 +158,13 @@ class CXXBasePaths {
   CXXBasePath ScratchPath;
 
   /// DetectedVirtual - The base class that is virtual.
-  const RecordType *DetectedVirtual;
+  const RecordType *DetectedVirtual = nullptr;
   
   /// \brief Array of the declarations that have been found. This
   /// array is constructed only if needed, e.g., to iterate over the
   /// results within LookupResult.
   std::unique_ptr DeclsFound;
-  unsigned NumDeclsFound;
-  
-  friend class CXXRecordDecl;
+  unsigned NumDeclsFound = 0;
   
   void ComputeDeclsFound();
 
@@ -169,17 +173,16 @@ class CXXBasePaths {
  bool LookupInDependent = false);
 
 public:
-  typedef std::list::iterator paths_iterator;
-  typedef std::list::const_iterator const_paths_iterator;
-  typedef NamedDecl **decl_iterator;
+  using paths_iterator = std::list::iterator;
+  using const_paths_iterator = std::list::const_iterator;
+  using decl_iterator = NamedDecl **;
   
   /// BasePaths - Construct a new BasePaths structure to record the
   /// paths for a derived-to-base search.
   explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true,
 bool DetectVirtual = true)
-  : Origin(), FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
-DetectVirtual(DetectVirtual), DetectedVirtual(nullptr),
-NumDeclsFound(0) {}
+  : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
+DetectVirtual(DetectVirtual) {}
 
   paths_iterator begin() { return Paths.begin(); }
   paths_iterator end()   { return Paths.end(); }
@@ -189,7 +192,8 @@ public:
   CXXBasePath&   front()   { return Paths.front(); }
   const CXXBasePath& front() const { return Paths.front(); }
   
-  typedef llvm::iterator_range decl_range;
+  using decl_range = llvm::iterator_range;
+
   decl_range found_decls();
   
   /// \brief Determine whether the path from the most-derived type to the
@@ -231,25 +235,24 @@ public:
 /// \brief Uniquely identifies a virtual method within a class
 /// hierarchy by the method itself and a class subobject number.
 struct UniqueVirtualMethod {
-  UniqueVirtualMethod()
-: Method(nullptr), Subobject(0), InVirtualSubobject(nullptr) { }
-
-  UniqueVir

[PATCH] D40675: [clang] Use add_llvm_install_targets

2017-11-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D40675



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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: test/Sema/_Float128.cpp:1
+// RUN: %clang_cc1 -verify -std=gnu++11 %s
+// RUN: %clang_cc1 -verify -std=c++11 %s

GCC documents that it does not support `_Float128` in C++ mode, and I think 
their decision makes sense:
On various targets, `long double` and `__float128` are not the same type, but 
they decided to mangle them the same under `-mlong-double-128` anyway. They 
also decided to make `__float128` and `_Float128` synonyms in the C mode on at 
least some of those targets.

The unfortunate state of affairs with the mangling may be okay for an extension 
type like `__float128`, but creating that situation with `_Float128` does not 
seem wise. The test here is explicitly C++, so it seems this patch exposes 
`_Float128` in C++ mode in a state that needs more discussion (and, in my 
opinion, one that should not ship).



https://reviews.llvm.org/D40673



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


r319485 - [CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

2017-11-30 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Nov 30 14:22:21 2017
New Revision: 319485

URL: http://llvm.org/viewvc/llvm-project?rev=319485&view=rev
Log:
[CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

CUDA-9 headers check for specific libc++ version and ifdef out
some of the definitions we need if LIBCPP_VERSION >= 3800.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=319485&r1=319484&r2=319485&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Thu Nov 30 14:22:21 
2017
@@ -270,12 +270,18 @@ static inline __device__ void __brkpt(in
 // include guard from math.h wrapper from libstdc++. We have to undo the header
 // guard temporarily to get the definitions we need.
 #pragma push_macro("_GLIBCXX_MATH_H")
+#pragma push_macro("_LIBCPP_VERSION")
 #if CUDA_VERSION >= 9000
 #undef _GLIBCXX_MATH_H
+// We also need to undo another guard that checks for libc++ 3.8+
+#ifdef _LIBCPP_VERSION
+#define _LIBCPP_VERSION 3700
+#endif
 #endif
 
 #include "math_functions.hpp"
 #pragma pop_macro("_GLIBCXX_MATH_H")
+#pragma pop_macro("_LIBCPP_VERSION")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


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


[PATCH] D40198: [CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

2017-11-30 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319485: [CUDA] Tweak CUDA wrappers to make cuda-9 work with 
libc++ (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D40198?vs=123421&id=125021#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40198

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -270,12 +270,18 @@
 // include guard from math.h wrapper from libstdc++. We have to undo the header
 // guard temporarily to get the definitions we need.
 #pragma push_macro("_GLIBCXX_MATH_H")
+#pragma push_macro("_LIBCPP_VERSION")
 #if CUDA_VERSION >= 9000
 #undef _GLIBCXX_MATH_H
+// We also need to undo another guard that checks for libc++ 3.8+
+#ifdef _LIBCPP_VERSION
+#define _LIBCPP_VERSION 3700
+#endif
 #endif
 
 #include "math_functions.hpp"
 #pragma pop_macro("_GLIBCXX_MATH_H")
+#pragma pop_macro("_LIBCPP_VERSION")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -270,12 +270,18 @@
 // include guard from math.h wrapper from libstdc++. We have to undo the header
 // guard temporarily to get the definitions we need.
 #pragma push_macro("_GLIBCXX_MATH_H")
+#pragma push_macro("_LIBCPP_VERSION")
 #if CUDA_VERSION >= 9000
 #undef _GLIBCXX_MATH_H
+// We also need to undo another guard that checks for libc++ 3.8+
+#ifdef _LIBCPP_VERSION
+#define _LIBCPP_VERSION 3700
+#endif
 #endif
 
 #include "math_functions.hpp"
 #pragma pop_macro("_GLIBCXX_MATH_H")
+#pragma pop_macro("_LIBCPP_VERSION")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40677: [libcxx] Make std::basic_istream::get 0-terminate input array in case of error.

2017-11-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9:

  [...] In any case, if n is greater than zero it then stores a null
  character into the next successive location of the array.

rdar://problem/35566567


https://reviews.llvm.org/D40677

Files:
  libcxx/include/istream
  
libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
  
libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp

Index: libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
===
--- libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
+++ libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
@@ -7,13 +7,23 @@
 //
 //===--===//
 
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // basic_istream& get(char_type* s, streamsize n, char_type delim);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 struct testbuf
 : public std::basic_streambuf
@@ -67,7 +77,33 @@
 assert(!is.fail());
 assert(std::string(s) == " ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.get(s, 5, '*');
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == "");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(" ");
+std::istream is(&sb);
+char s[5] = "test";
+is.exceptions(std::istream::eofbit | std::istream::badbit);
+try
+{
+is.get(s, 5, '*');
+assert(false);
+}
+catch (std::ios_base::failure&)
+{
+}
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == " ");
+assert(is.gcount() == 1);
 }
+#endif
 {
 testbuf sb(L"  ** ");
 std::wistream is(&sb);
@@ -95,5 +131,31 @@
 assert(!is.fail());
 assert(std::wstring(s) == L" ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.get(s, 5, L'*');
+assert( is.eof());
+assert( is.fail());
+assert(std::wstring(s) == L"");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(L" ");
+std::wistream is(&sb);
+wchar_t s[5] = L"test";
+is.exceptions(std::wistream::eofbit | std::wistream::badbit);
+try
+{
+is.get(s, 5, L'*');
+assert(false);
+}
+catch (std::ios_base::failure&)
+{
+}
+assert( is.eof());
+assert( is.fail());
+assert(std::wstring(s) == L" ");
+assert(is.gcount() == 1);
 }
+#endif
 }
Index: libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
===
--- libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
+++ libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
@@ -7,13 +7,23 @@
 //
 //===--===//
 
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // basic_istream& get(char_type* s, streamsize n);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 struct testbuf
 : public std::basic_streambuf
@@ -67,7 +77,33 @@
 assert(!is.fail());
 assert(std::string(s) == " ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.get(s, 5);
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == "");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(" ");
+std::istream is(&sb);
+char s[5] = "test";
+is.exceptions(std::istream::eofbit | std::istr

[PATCH] D40486: [clangd] Implemented logging using Context

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This is pretty bikesheddy, but I wonder what you think about passing Ctx as the 
first vs last parameter.
First has some advantages (maybe I just read too much Go though):

- it's a short expr, and F(short, long) tends to format better than F(long, 
short). Particularly with lambdas but also long strings.
- it doesn't interfere with default args

It would be nice if we could be completely uniform here.


https://reviews.llvm.org/D40486



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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> _Float128 is only *sometimes* the same type as __float128.

But we don't have hppa or IA-64 backends, so we're fine for now, I think. :)




Comment at: lib/Frontend/InitPreprocessor.cpp:817
   DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");
+  DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q");
+

We should have a FIXME here to switch away from the non-standard "Q" when we 
can.


https://reviews.llvm.org/D40673



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


[PATCH] D40675: [clang] Use add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

Use this function to create the install targets rather than doing so
manually, which gains us the `-stripped` install targets to perform
stripped installations.


Repository:
  rC Clang

https://reviews.llvm.org/D40675

Files:
  cmake/modules/AddClang.cmake
  lib/Headers/CMakeLists.txt
  runtime/CMakeLists.txt
  tools/c-index-test/CMakeLists.txt
  tools/libclang/CMakeLists.txt

Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -148,9 +148,6 @@
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-libclang-headers
-DEPENDS
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=libclang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-libclang-headers
+   COMPONENT libclang-headers)
 endif()
Index: tools/c-index-test/CMakeLists.txt
===
--- tools/c-index-test/CMakeLists.txt
+++ tools/c-index-test/CMakeLists.txt
@@ -56,10 +56,8 @@
 COMPONENT c-index-test)
 
   if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-add_custom_target(install-c-index-test
-  DEPENDS c-index-test
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=c-index-test
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-c-index-test
+ DEPENDS c-index-test
+ COMPONENT c-index-test)
   endif()
 endif()
Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -101,12 +101,9 @@
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
 COMPONENT compiler-rt)
 
-  add_custom_target(install-compiler-rt
-DEPENDS compiler-rt
-COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=compiler-rt
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-USES_TERMINAL)
+  add_llvm_install_targets(install-compiler-rt
+   DEPENDS compiler-rt
+   COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -141,9 +141,7 @@
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-clang-headers
-DEPENDS clang-headers
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-clang-headers
+   DEPENDS clang-headers
+   COMPONENT clang-headers)
 endif()
Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -104,11 +104,9 @@
 RUNTIME DESTINATION bin)
 
   if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-add_custom_target(install-${name}
-  DEPENDS ${name}
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=${name}
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
   endif()
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
@@ -147,11 +145,9 @@
   COMPONENT ${name})
 
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${name}
-DEPENDS ${name}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${name}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${name}
+   DEPENDS ${name}
+   COMPONENT ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@ilya-biryukov We should get this landed.
I'm happy (my comments were addressed a few rounds ago) - any concerns?


https://reviews.llvm.org/D39430



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


[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@ilya-biryukov Ping... this is the patch we wanted to land this week, so long 
result sets are correct for user testing next week.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39882



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


[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 125009.
sammccall added a comment.
Herald added a subscriber: klimek.

Rebase and remove debug output.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39882

Files:
  clangd/ClangdUnit.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -742,6 +742,61 @@
   EXPECT_FALSE(ContainsItem(Results, "CCC"));
 }
 
+TEST_F(ClangdCompletionTest, Filter) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true, Opts,
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  const char *Body = R"cpp(
+int Abracadabra;
+int Alakazam;
+struct S {
+  int FooBar;
+  int FooBaz;
+  int Qux;
+};
+  )cpp";
+  auto Complete = [&](StringRef Query) {
+StringWithPos Completion = parseTextMarker(
+formatv("{0} int main() { {1}{{complete}} }", Body, Query).str(),
+"complete");
+Server.addDocument(FooCpp, Completion.Text);
+return Server
+.codeComplete(FooCpp, Completion.MarkerPos, StringRef(Completion.Text))
+.get()
+.Value;
+  };
+
+  auto Foba = Complete("S().Foba");
+  EXPECT_TRUE(ContainsItem(Foba, "FooBar"));
+  EXPECT_TRUE(ContainsItem(Foba, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(Foba, "Qux"));
+
+  auto FR = Complete("S().FR");
+  EXPECT_TRUE(ContainsItem(FR, "FooBar"));
+  EXPECT_FALSE(ContainsItem(FR, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(FR, "Qux"));
+
+  auto Op = Complete("S().opr");
+  EXPECT_TRUE(ContainsItem(Op, "operator="));
+
+  auto Aaa = Complete("aaa");
+  EXPECT_TRUE(ContainsItem(Aaa, "Abracadabra"));
+  EXPECT_TRUE(ContainsItem(Aaa, "Alakazam"));
+
+  auto UA = Complete("_a");
+  EXPECT_TRUE(ContainsItem(UA, "static_cast"));
+  EXPECT_FALSE(ContainsItem(UA, "Abracadabra"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -446,13 +446,16 @@
   void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override final {
+StringRef Filter = S.getPreprocessor().getCodeCompletionFilter();
 std::priority_queue Candidates;
 for (unsigned I = 0; I < NumResults; ++I) {
   auto &Result = Results[I];
   if (!ClangdOpts.IncludeIneligibleResults &&
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
+  if (!Filter.empty() && !fuzzyMatch(S, Context, Filter, Result))
+continue;
   Candidates.emplace(Result);
   if (ClangdOpts.Limit && Candidates.size() > ClangdOpts.Limit) {
 Candidates.pop();
@@ -476,6 +479,39 @@
   CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
 
 private:
+  bool fuzzyMatch(Sema &S, const CodeCompletionContext &CCCtx, StringRef Filter,
+  CodeCompletionResult Result) {
+switch (Result.Kind) {
+case CodeCompletionResult::RK_Declaration:
+  if (auto *ID = Result.Declaration->getIdentifier())
+return fuzzyMatch(Filter, ID->getName());
+  break;
+case CodeCompletionResult::RK_Keyword:
+  return fuzzyMatch(Filter, Result.Keyword);
+case CodeCompletionResult::RK_Macro:
+  return fuzzyMatch(Filter, Result.Macro->getName());
+case CodeCompletionResult::RK_Pattern:
+  return fuzzyMatch(Filter, Result.Pattern->getTypedText());
+}
+auto *CCS = Result.CreateCodeCompletionString(
+S, CCCtx, *Allocator, CCTUInfo, /*IncludeBriefComments=*/false);
+return fuzzyMatch(Filter, CCS->getTypedText());
+  }
+
+  // Checks whether Target matches the Filter.
+  // Currently just requires a case-insensitive subsequence match.
+  // FIXME: make stricter and word-based: 'unique_ptr' should not match 'que'.
+  // FIXME: return a score to be incorporated into ranking.
+  static bool fuzzyMatch(StringRef Filter, StringRef Target) {
+size_t TPos = 0;
+for (char C : Filter) {
+  TPos = Target.find_lower(C, TPos);
+  if (TPos == StringRef::npos)
+return false;
+}
+return true;
+  }
+
   CompletionItem
   ProcessCodeCompleteResult(const CompletionCandidate &Candidate,
 const Code

[PATCH] D40671: Support specific categories for NOLINT directive

2017-11-30 Thread Anton via Phabricator via cfe-commits
xgsa updated this revision to Diff 125008.
xgsa added a reviewer: dcoughlin.
xgsa added a comment.

Update the diff to contain the full context


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,7 +13,16 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-category)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-category, google-explicit-constructor)
 
 void f() {
   int i;
@@ -35,4 +44,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 11 warnings (11 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,8 +4,21 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-category)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-category, google-explicit-constructor)
+class C4 { C4(int i); };
 
 
 // NOLINTNEXTLINE
@@ -28,6 +41,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
 #include "llvm/ADT/SmallString.h"
+#include 
 #include 
 #include 
 using namespace clang;
@@ -289,8 +290,37 @@
   LastErrorRelatesToUserCode = false;
   LastErrorPassesLineFilter = false;
 }
-
-static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc) {
+static bool IsNOLINTFound(StringRef NolintMacro, StringRef Line,
+  unsigned DiagID, const ClangTidyContext &Context) {
+  const auto NolintIndex = Line.find(NolintMacro);
+  if (NolintIndex != StringRef::npos) {
+auto BracketIndex = NolintIndex + NolintMacro.size();
+if (BracketIndex < Line.size() && Line[BracketIndex] == '(') {
+  ++BracketIndex;
+  const auto BracketEndIndex = Line.find(')', BracketIndex);
+  if (BracketEndIndex != StringRef::npos) {
+auto ChecksStr =
+Line.substr(BracketIndex, BracketEndIndex - BracketIndex);
+if (ChecksStr != "*") {
+  auto CheckName = Context.getCheckName(DiagID);
+  // Allow specifying a few check names, delimited with comma
+  SmallVector Checks;
+  ChecksStr.split(Checks, ',', -1, false);
+  for (auto &Check : Checks) {
+Check = Check.trim();
+  }
+  return std::find(Checks.begin(), Checks.end(), CheckName) !=
+ Checks.end();
+}
+  }
+}
+return true;
+  }
+  return false;
+}
+static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc,
+   unsigned DiagID,
+   const ClangTidyContext &Context) {
   bool Invalid;
   const char *CharacterData = SM.getCharacterData(Loc, &Invalid);
   if (Invalid)
@@ -301,8 +331,7 @@
   while (*P != '\0' && *P != '\r' && *P != '\n')
 ++P;
   StringRef RestOfLine(CharacterData, P - CharacterData + 1);
-  // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
-  if (RestOfLine.find("NOLINT") != StringRef::npos)
+  if (IsNOLINTFound("NOLINT", RestOfLine, DiagID, Context))
 return true;
 
   // Check if there's a NOLINTNEXTLINE on the previous line.
@@ -329,16 +358,17 @@
 --P;
 
   RestOfLine = StringRef(P, LineEnd - P + 1);
-  if (RestOfLine.find("NOLINTNEXTLINE") != StringRef::npos)
+  if (IsNOLINTFound("NOLINTNEXTLINE", RestOfLine, DiagID, Context))
 return true;
 
   return false;
 }
 
-static bool LineIsMarkedWithNOLINTinMacro(SourceManager

[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Per https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html, this doesn't appear 
to be correct: `_Float128` is only *sometimes* the same type as `__float128`.


https://reviews.llvm.org/D40673



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


[clang-tools-extra] r319479 - [Documentation] Style fixes for Objective-C checks documentation to follow C/C++ example.

2017-11-30 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Nov 30 13:42:27 2017
New Revision: 319479

URL: http://llvm.org/viewvc/llvm-project?rev=319479&view=rev
Log:
[Documentation] Style fixes for Objective-C checks documentation to follow 
C/C++ example.

Release Notes should just repeat first sentence from documentation.

Remove duplicated entry from Release Notes.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-nserror-init.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/objc-forbidden-subclassing.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=319479&r1=319478&r2=319479&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Nov 30 13:42:27 2017
@@ -57,11 +57,6 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New `objc-avoid-nserror-init
-  
`_ 
check
-
-  Add new check to detect the use of [NSError init].
-
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
@@ -143,13 +138,13 @@ Improvements to clang-tidy
 - New `google-objc-avoid-throwing-exception
   
`_
 check
 
-  Add new check to detect throwing exceptions in Objective-C code, which 
should be avoided.
+  Finds uses of throwing exceptions usages in Objective-C files.
 
 - New `google-objc-global-variable-declaration
   
`_
 check
 
-  Add new check for Objective-C code to ensure global variables follow the
-  naming convention of 'k[A-Z].*' (for constants) or 'g[A-Z].*' (for 
variables).
+  Finds global variable declarations in Objective-C files that do not follow 
the
+  pattern of variable names in Google's Objective-C Style Guide.
 
 - New `hicpp-exception-baseclass
   
`_
 check
@@ -166,7 +161,7 @@ Improvements to clang-tidy
 - New `objc-avoid-nserror-init
   
`_ 
check
 
-  Add new check to detect the use of [NSError init].
+  Finds improper initialization of ``NSError`` objects.
 
 - New `objc-avoid-spinlock
   `_ 
check
@@ -177,15 +172,14 @@ Improvements to clang-tidy
 - New `objc-forbidden-subclassing
   
`_
 check
 
-  Ensures Objective-C classes do not subclass any classes which are
-  not intended to be subclassed. Includes a list of classes from Foundation
-  and UIKit which are documented as not supporting subclassing.
+  Finds Objective-C classes which are subclasses of classes which are not
+  designed to be subclassed.
 
 - New `objc-property-declaration
   
`_
 check
 
-  Add new check for Objective-C code to ensure property names follow the naming
-  convention of Apple's programming guide.
+  Finds property declarations in Objective-C files that do not follow the
+  pattern of property names in Apple's programming guide.
 
 - New `readability-static-accessed-through-instance
   
`_
 check
@@ -245,6 +239,7 @@ Improvements to clang-tidy
   
`_
 
 The check's options were renamed as follows:
+
 - `AllowConditionalIntegerCasts` -> `AllowIntegerConditions`,
 - `AllowConditionalPointerCasts` -> `AllowPointerConditions`.
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst?rev=319479&r1=319478&r2=319479&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
 Thu Nov 30 13:42:27 2017
@@ -3,7 +3,8 @@
 google-objc-avoid-throwing-exception
 ==

[PATCH] D40654: [clangd] Set completion options per-request.

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Nice!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40654



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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

LGTM for the CUDA test changes.


https://reviews.llvm.org/D40673



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


[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319478: [clangd] New conventions for JSON-marshalling 
functions, centralize machinery (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D40596?vs=124715&id=125004#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40596

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/JSONExpr.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/test/clangd/trace.test
  clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
@@ -229,6 +229,64 @@
   }
 }
 
+// Sample struct with typical JSON-mapping rules.
+struct CustomStruct {
+  CustomStruct() : B(false) {}
+  CustomStruct(std::string S, llvm::Optional I, bool B)
+  : S(S), I(I), B(B) {}
+  std::string S;
+  llvm::Optional I;
+  bool B;
+};
+inline bool operator==(const CustomStruct &L, const CustomStruct &R) {
+  return L.S == R.S && L.I == R.I && L.B == R.B;
+}
+inline std::ostream &operator<<(std::ostream &OS, const CustomStruct &S) {
+  return OS << "(" << S.S << ", " << (S.I ? std::to_string(*S.I) : "None")
+<< ", " << S.B << ")";
+}
+bool fromJSON(const json::Expr &E, CustomStruct &R) {
+  ObjectMapper O(E);
+  if (!O || !O.map("str", R.S) || !O.map("int", R.I))
+return false;
+  O.map("bool", R.B);
+  return true;
+}
+
+TEST(JSONTest, Deserialize) {
+  std::map> R;
+  CustomStruct ExpectedStruct = {"foo", 42, true};
+  std::map> Expected;
+  Expr J = obj{{"foo", ary{
+   obj{
+   {"str", "foo"},
+   {"int", 42},
+   {"bool", true},
+   {"unknown", "ignored"},
+   },
+   obj{{"str", "bar"}},
+   obj{
+   {"str", "baz"},
+   {"bool", "string"}, // OK, deserialize ignores.
+   },
+   }}};
+  Expected["foo"] = {
+  CustomStruct("foo", 42, true),
+  CustomStruct("bar", llvm::None, false),
+  CustomStruct("baz", llvm::None, false),
+  };
+  ASSERT_TRUE(fromJSON(J, R));
+  EXPECT_EQ(R, Expected);
+
+  CustomStruct V;
+  EXPECT_FALSE(fromJSON(nullptr, V)) << "Not an object " << V;
+  EXPECT_FALSE(fromJSON(obj{}, V)) << "Missing required field " << V;
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}}, V)) << "Wrong type " << V;
+  // Optional must parse as the correct type if present.
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}, {"int", "string"}}, V))
+  << "Wrong type for Optional " << V;
+}
+
 } // namespace
 } // namespace json
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
===
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
@@ -21,7 +21,7 @@
 // Helper for attaching ProtocolCallbacks methods to a JSONRPCDispatcher.
 // Invoke like: Registerer("foo", &ProtocolCallbacks::onFoo)
 // onFoo should be: void onFoo(Ctx &C, FooParams &Params)
-// FooParams should have a static factory method: parse(const json::Expr&).
+// FooParams should have a fromJSON function.
 struct HandlerRegisterer {
   template 
   void operator()(StringRef Method,
@@ -31,11 +31,9 @@
 auto *Callbacks = this->Callbacks;
 Dispatcher.registerHandler(
 Method, [=](RequestContext C, const json::Expr &RawParams) {
-  if (auto P = [&] {
-trace::Span Tracer("Parse");
-return std::decay::type::parse(RawParams);
-  }()) {
-(Callbacks->*Handler)(std::move(C), *P);
+  typename std::remove_reference::type P;
+  if (fromJSON(RawParams, P)) {
+(Callbacks->*Handler)(std::move(C), P);
   } else {
 Out->log("Failed to decode " + Method + " request.\n");
   }
Index: clang-tools-extra/trunk/clangd/JSONExpr.h
===
--- clang-tools-extra/trunk/clangd/JSONExpr.h
+++ clang-tools-extra/trunk/clangd/JSONExpr.h
@@ -36,7 +36,7 @@
 //   - booleans
 //   - null: nullptr
 //   - arrays: {"foo", 42.0, false}
-//   - serializable things: any T with a T::unparse(const T&) -> Expr
+//   - serializable things: types with toJSON(const T&)->Expr, found by ADL
 //
 // They can also be constructed from object/array helpers:
 //   - json::obj is a type like map
@@ -65,6 +65,28 @@
 //   if (Optional Font = Opts->getSt

[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rCTE319478: [clangd] New conventions for JSON-marshalling 
functions, centralize machinery (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D40596?vs=124715&id=125003#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40596

Files:
  clangd/ClangdLSPServer.cpp
  clangd/JSONExpr.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  test/clangd/trace.test
  unittests/clangd/JSONExprTests.cpp

Index: unittests/clangd/JSONExprTests.cpp
===
--- unittests/clangd/JSONExprTests.cpp
+++ unittests/clangd/JSONExprTests.cpp
@@ -229,6 +229,64 @@
   }
 }
 
+// Sample struct with typical JSON-mapping rules.
+struct CustomStruct {
+  CustomStruct() : B(false) {}
+  CustomStruct(std::string S, llvm::Optional I, bool B)
+  : S(S), I(I), B(B) {}
+  std::string S;
+  llvm::Optional I;
+  bool B;
+};
+inline bool operator==(const CustomStruct &L, const CustomStruct &R) {
+  return L.S == R.S && L.I == R.I && L.B == R.B;
+}
+inline std::ostream &operator<<(std::ostream &OS, const CustomStruct &S) {
+  return OS << "(" << S.S << ", " << (S.I ? std::to_string(*S.I) : "None")
+<< ", " << S.B << ")";
+}
+bool fromJSON(const json::Expr &E, CustomStruct &R) {
+  ObjectMapper O(E);
+  if (!O || !O.map("str", R.S) || !O.map("int", R.I))
+return false;
+  O.map("bool", R.B);
+  return true;
+}
+
+TEST(JSONTest, Deserialize) {
+  std::map> R;
+  CustomStruct ExpectedStruct = {"foo", 42, true};
+  std::map> Expected;
+  Expr J = obj{{"foo", ary{
+   obj{
+   {"str", "foo"},
+   {"int", 42},
+   {"bool", true},
+   {"unknown", "ignored"},
+   },
+   obj{{"str", "bar"}},
+   obj{
+   {"str", "baz"},
+   {"bool", "string"}, // OK, deserialize ignores.
+   },
+   }}};
+  Expected["foo"] = {
+  CustomStruct("foo", 42, true),
+  CustomStruct("bar", llvm::None, false),
+  CustomStruct("baz", llvm::None, false),
+  };
+  ASSERT_TRUE(fromJSON(J, R));
+  EXPECT_EQ(R, Expected);
+
+  CustomStruct V;
+  EXPECT_FALSE(fromJSON(nullptr, V)) << "Not an object " << V;
+  EXPECT_FALSE(fromJSON(obj{}, V)) << "Missing required field " << V;
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}}, V)) << "Wrong type " << V;
+  // Optional must parse as the correct type if present.
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}, {"int", "string"}}, V))
+  << "Wrong type for Optional " << V;
+}
+
 } // namespace
 } // namespace json
 } // namespace clangd
Index: clangd/JSONExpr.h
===
--- clangd/JSONExpr.h
+++ clangd/JSONExpr.h
@@ -36,7 +36,7 @@
 //   - booleans
 //   - null: nullptr
 //   - arrays: {"foo", 42.0, false}
-//   - serializable things: any T with a T::unparse(const T&) -> Expr
+//   - serializable things: types with toJSON(const T&)->Expr, found by ADL
 //
 // They can also be constructed from object/array helpers:
 //   - json::obj is a type like map
@@ -65,6 +65,28 @@
 //   if (Optional Font = Opts->getString("font"))
 // assert(Opts->at("font").kind() == Expr::String);
 //
+// === Converting expressions to objects ===
+//
+// The convention is to have a deserializer function findable via ADL:
+// fromJSON(const json::Expr&, T&)->bool
+// Deserializers are provided for:
+//   - bool
+//   - int
+//   - double
+//   - std::string
+//   - vector, where T is deserializable
+//   - map, where T is deserializable
+//   - Optional, where T is deserializable
+//
+// ObjectMapper can help writing fromJSON() functions for object types:
+//   bool fromJSON(const Expr &E, MyStruct &R) {
+// ObjectMapper O(E);
+// if (!O || !O.map("mandatory_field", R.MandatoryField))
+//   return false;
+// O.map("optional_field", R.OptionalField);
+// return true;
+//   }
+//
 // === Serialization ===
 //
 // Exprs can be serialized to JSON:
@@ -127,12 +149,11 @@
   Expr(T D) : Type(T_Number) {
 create(D);
   }
-  // Types with a static T::unparse function returning an Expr.
-  // FIXME: should this be a free unparse() function found by ADL?
+  // Types with a toJSON(const T&)->Expr function, found by ADL.
   template ::value>>
-  Expr(const T &V) : Expr(T::unparse(V)) {}
+Expr, decltype(toJSON(*(const T *)nullptr))>::value>>
+  Expr(const T &V) : Expr(toJSON(V)) {}
 
   Expr &operator=(const Expr &M) {
 destroy();
@@ -432,6 +453,101 @@
 using obj = Expr::ObjectExpr;
 using ary = Expr::ArrayExpr;
 
+// Standard deserializers.
+inline bool fromJSON(const json::Expr &E, std::

[clang-tools-extra] r319478 - [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov 30 13:32:29 2017
New Revision: 319478

URL: http://llvm.org/viewvc/llvm-project?rev=319478&view=rev
Log:
[clangd] New conventions for JSON-marshalling functions, centralize machinery

Summary:
 - JSON<->Obj interface is now ADL functions, so they play nicely with enums
 - recursive vector/map parsing and ObjectMapper moved to JSONExpr and tested
 - renamed (un)parse to (de)serialize, since text -> JSON is called parse
 - Protocol.cpp gets a bit shorter

Sorry for the giant patch, it's prety mechanical though

Reviewers: ilya-biryukov

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/JSONExpr.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/test/clangd/trace.test
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=319478&r1=319477&r2=319478&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Nov 30 13:32:29 2017
@@ -117,7 +117,7 @@ void ClangdLSPServer::onCommand(Ctx C, E
 // We don't need the response so id == 1 is OK.
 // Ideally, we would wait for the response and if there is no error, we
 // would reply success/failure to the original RPC.
-C.call("workspace/applyEdit", 
ApplyWorkspaceEditParams::unparse(ApplyEdit));
+C.call("workspace/applyEdit", ApplyEdit);
   } else {
 // We should not get here because ExecuteCommandParams would not have
 // parsed in the first place and this handler should not be called. But if
@@ -140,7 +140,7 @@ void ClangdLSPServer::onRename(Ctx C, Re
   std::vector Edits = replacementsToEdits(Code, *Replacements);
   WorkspaceEdit WE;
   WE.changes = {{Params.textDocument.uri.uri, Edits}};
-  C.reply(WorkspaceEdit::unparse(WE));
+  C.reply(WE);
 }
 
 void ClangdLSPServer::onDocumentDidClose(Ctx C,

Modified: clang-tools-extra/trunk/clangd/JSONExpr.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONExpr.h?rev=319478&r1=319477&r2=319478&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONExpr.h (original)
+++ clang-tools-extra/trunk/clangd/JSONExpr.h Thu Nov 30 13:32:29 2017
@@ -36,7 +36,7 @@ namespace json {
 //   - booleans
 //   - null: nullptr
 //   - arrays: {"foo", 42.0, false}
-//   - serializable things: any T with a T::unparse(const T&) -> Expr
+//   - serializable things: types with toJSON(const T&)->Expr, found by ADL
 //
 // They can also be constructed from object/array helpers:
 //   - json::obj is a type like map
@@ -65,6 +65,28 @@ namespace json {
 //   if (Optional Font = Opts->getString("font"))
 // assert(Opts->at("font").kind() == Expr::String);
 //
+// === Converting expressions to objects ===
+//
+// The convention is to have a deserializer function findable via ADL:
+// fromJSON(const json::Expr&, T&)->bool
+// Deserializers are provided for:
+//   - bool
+//   - int
+//   - double
+//   - std::string
+//   - vector, where T is deserializable
+//   - map, where T is deserializable
+//   - Optional, where T is deserializable
+//
+// ObjectMapper can help writing fromJSON() functions for object types:
+//   bool fromJSON(const Expr &E, MyStruct &R) {
+// ObjectMapper O(E);
+// if (!O || !O.map("mandatory_field", R.MandatoryField))
+//   return false;
+// O.map("optional_field", R.OptionalField);
+// return true;
+//   }
+//
 // === Serialization ===
 //
 // Exprs can be serialized to JSON:
@@ -127,12 +149,11 @@ public:
   Expr(T D) : Type(T_Number) {
 create(D);
   }
-  // Types with a static T::unparse function returning an Expr.
-  // FIXME: should this be a free unparse() function found by ADL?
+  // Types with a toJSON(const T&)->Expr function, found by ADL.
   template ::value>>
-  Expr(const T &V) : Expr(T::unparse(V)) {}
+Expr, decltype(toJSON(*(const T *)nullptr))>::value>>
+  Expr(const T &V) : Expr(toJSON(V)) {}
 
   Expr &operator=(const Expr &M) {
 destroy();
@@ -432,6 +453,101 @@ inline Expr::ObjectExpr::ObjectExpr(std:
 using obj = Expr::ObjectExpr;
 using ary = Expr::ArrayExpr;
 
+// Standard deserializers.
+inline bool fromJSON(const json::Expr &E, std::string &Out) {
+  if (auto S = E.asString()) {
+Out = *S;
+return true;
+  }
+  return false;
+}
+inline bool fromJSON(const json::Expr &E, int &Out) {
+  if (auto S = E.asInteger()) {
+Out = *S;
+return true;
+  }
+  return false;
+}
+inline bool fromJSON(const json:

[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clangd/JSONExpr.h:71
+// The convention is to have a deserialize function findable via ADL:
+// deserialize(const json::Expr&, T&)->bool
+// Deserializers are provided for:

ilya-biryukov wrote:
> The name `deserialize` may be a bit too general and prone to clashes with 
> other code. Maybe choosing something a bit more specific like 
> `json_deserialize` is a better option.
> On the other hand, we do the SFINAE trick to check the types are correct in 
> `Expr` constructor, so we should be fine either way.
Yeah, these are a bit generic. Renamed to `toJSON`/`fromJSON` - not perfect 
names but they're short and I find it easier to remember which direction they 
convert in.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40596



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


[PATCH] D40671: Support specific categories for NOLINT directive

2017-11-30 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please upload patches with full context (`-U99`)
Also, you probably want to add some reviewers, see CODE_OWNERS.txt e.g.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671



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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added a project: clang.

Fedora27 is using a new version of glibc that refers to the _Float128 type. 
This patch adds that name as an alias to __float128. I also added some 
predefined macro values for the digits, mantissa, epilon, etc (FloatMacros).  
For the test case, I copied an existing __float128 test.  This functionality 
needs work long term, but it should be sufficient to tread water for a while.  
At Intel we have test servers running our LLVM compiler with various open 
source workloads, the server has been upgraded to Fedora27 so many workloads 
are failing due to _Float128. What do you think?


https://reviews.llvm.org/D40673

Files:
  include/clang/Basic/TokenKinds.def
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/cuda-types.cu
  test/Sema/_Float128.cpp

Index: test/Sema/_Float128.cpp
===
--- /dev/null
+++ test/Sema/_Float128.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -std=gnu++11 %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple powerpc64-linux -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
+
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+_Float128 f;
+_Float128 tiny = __FLT128_EPSILON__;
+template struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<_Float128> {};
+int g(int x, _Float128 *y) {
+  return x + *y;
+}
+
+// expected-no-diagnostics
+#else
+#if !defined(__STRICT_ANSI__)
+_Float128 f;  // expected-error {{__float128 is not supported on this target}}
+template struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<_Float128> {};  // expected-error {{__float128 is not supported on this target}}
+
+int g(int x, _Float128 *y) {  // expected-error {{__float128 is not supported on this target}}
+  return x + *y;
+}
+
+#else
+_Float128 f;  // expected-error {{__float128 is not supported on this target}}
+template struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<_Float128> {};  // expected-error {{__float128 is not supported on this target}}
+
+int g(int x, _Float128 *y) {  // expected-error {{__float128 is not supported on this target}}
+  return x + *y;
+}
+
+#endif  // !defined(__STRICT_ANSI__)
+#endif  // defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
Index: test/Preprocessor/cuda-types.cu
===
--- test/Preprocessor/cuda-types.cu
+++ test/Preprocessor/cuda-types.cu
@@ -9,40 +9,40 @@
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
 // RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
 // RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/po

[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-11-30 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 125000.
juliehockett marked 4 inline comments as done.

https://reviews.llvm.org/D40580

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-multiple-inheritance.cpp

Index: test/clang-tidy/fuchsia-multiple-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
+
+class Base_A {
+public:
+  virtual int foo() { return 0; }
+};
+
+class Base_B {
+public:
+  virtual int bar() { return 0; }
+};
+
+class Base_A_child : public Base_A {
+public:
+  virtual int baz() { return 0; }
+};
+
+class Interface_A {
+public:
+  virtual int foo() = 0;
+};
+
+class Interface_B {
+public:
+  virtual int bar() = 0;
+};
+
+class Interface_C {
+public:
+  virtual int blat() = 0;
+};
+
+class Interface_A_with_member {
+public:
+  virtual int foo() = 0;
+  int val = 0;
+};
+
+class Interface_with_A_Parent : public Base_A {
+public:
+  virtual int baz() = 0;
+};
+
+// Inherits from multiple concrete classes.
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
+class Bad_Child1 : public Base_A, Base_B {};
+
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+class Bad_Child2 : public Base_A, Interface_A_with_member {
+  virtual int foo() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+  virtual int baz() override { return 0; }
+};
+
+// Easy cases of single inheritance
+class Simple_Child1 : public Base_A {};
+class Simple_Child2 : public Interface_A {
+  virtual int foo() override { return 0; }
+};
+
+// Valid uses of multiple inheritance
+class Good_Child1 : public Interface_A, Interface_B {
+  virtual int foo() override { return 0; }
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child2 : public Base_A, Interface_B {
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
+  virtual int bar() override { return 0; }
+  virtual int blat() override { return 0; }
+};
+
+int main(void) {
+  Bad_Child1 a;
+  Bad_Child2 b;
+  Bad_Child3 c;
+  Simple_Child1 d;
+  Simple_Child2 e;
+  Good_Child1 f;
+  Good_Child2 g;
+  Good_Child3 h;
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -69,6 +69,7 @@
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
fuchsia-default-arguments
+   fuchsia-multiple-inheritance
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
@@ -0,0 +1,46 @@
+.. title:: clang-tidy - fuchsia-multiple-inheritance
+
+fuchsia-multiple-inheritance
+
+
+Warns if a class inherits from multiple classes that are not pure virtual.
+
+For example, declaring a class that inherits from multiple concrete classes is
+disallowed:
+
+.. code-block:: c++
+
+  class Base_A {
+  public:
+virtual int foo() { return 0; }
+  };
+
+  class Base_B {
+  public:
+virtual int bar() { return 0; }
+  };
+
+  // Warning
+  class Bad_Child1 : public Base_A, Base_B {};
+
+A class that inherits from a pure virtual is allowed:
+
+.. code-block:: c++
+
+  class Interface_A {
+  public:
+virtual int foo() = 0;
+  };
+
+  class Interface_B {
+  public:
+virtual int bar() = 0;
+  };
+
+  // No warning
+  class Good_Child1 : public Interface_A, Interface_B {
+virtual int foo() override { return 0; }
+virtual int bar() override { return 0; }
+  };
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -135,6 +135,11 @@
 
   Warns if a function or method is declared or called with default arguments.
 
+- New `fuchsia-multiple-inheritance

[PATCH] D40671: Support specific categories for NOLINT directive

2017-11-30 Thread Anton via Phabricator via cfe-commits
xgsa created this revision.
xgsa added a project: clang-tools-extra.

The NOLINT directive was extended to support the "NOLINT(category)" and 
"NOLINT(*)" syntax. Also it is possible to specify a few categories separated 
with comma "NOLINT(cat1, cat2)"


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,8 +13,17 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-category)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-category, google-explicit-constructor)
+
 void f() {
   int i;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: unused variable 'i' [clang-diagnostic-unused-variable]
@@ -35,4 +44,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 11 warnings (11 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,10 +4,23 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-category)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
 
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-category, google-explicit-constructor)
+class C4 { C4(int i); };
+
+
 // NOLINTNEXTLINE
 
 class D { D(int i); };
@@ -28,6 +41,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
 #include "llvm/ADT/SmallString.h"
+#include 
 #include 
 #include 
 using namespace clang;
@@ -289,8 +290,37 @@
   LastErrorRelatesToUserCode = false;
   LastErrorPassesLineFilter = false;
 }
-
-static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc) {
+static bool IsNOLINTFound(StringRef NolintMacro, StringRef Line,
+  unsigned DiagID, const ClangTidyContext &Context) {
+  const auto NolintIndex = Line.find(NolintMacro);
+  if (NolintIndex != StringRef::npos) {
+auto BracketIndex = NolintIndex + NolintMacro.size();
+if (BracketIndex < Line.size() && Line[BracketIndex] == '(') {
+  ++BracketIndex;
+  const auto BracketEndIndex = Line.find(')', BracketIndex);
+  if (BracketEndIndex != StringRef::npos) {
+auto ChecksStr =
+Line.substr(BracketIndex, BracketEndIndex - BracketIndex);
+if (ChecksStr != "*") {
+  auto CheckName = Context.getCheckName(DiagID);
+  // Allow specifying a few check names, delimited with comma
+  SmallVector Checks;
+  ChecksStr.split(Checks, ',', -1, false);
+  for (auto &Check : Checks) {
+Check = Check.trim();
+  }
+  return std::find(Checks.begin(), Checks.end(), CheckName) !=
+ Checks.end();
+}
+  }
+}
+return true;
+  }
+  return false;
+}
+static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc,
+   unsigned DiagID,
+   const ClangTidyContext &Context) {
   bool Invalid;
   const char *CharacterData = SM.getCharacterData(Loc, &Invalid);
   if (Invalid)
@@ -301,8 +331,7 @@
   while (*P != '\0' && *P != '\r' && *P != '\n')
 ++P;
   StringRef RestOfLine(CharacterData, P - CharacterData + 1);
-  // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
-  if (RestOfLine.find("NOLINT") != StringRef::npos)
+  if (IsNOLINTFound("NOLINT", RestOfLine, DiagID, Context))
 return true;
 
   // Check if there's a NOLINTNEXTLINE on the previous line.
@@ -329,16 +358,17 @@
 --P;
 
   RestOfLine = StringRef(P, LineEnd -

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

2017-11-30 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine closed this revision.
saugustine added a comment.

Committed as https://reviews.llvm.org/rL319474.


https://reviews.llvm.org/D36431



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


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

2017-11-30 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/ClangdServer.cpp:526
+if (!AST)
+  llvm::make_error(
+  "invalid AST",

missing return?
I get a warning that looks legit:
./tools/clang/tools/extra/clangd/ClangdServer.cpp:526:7: warning: ignoring 
return value of function declared with 'warn_unused_result' attribute 
[-Wunused-result]
  llvm::make_error(



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425



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


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

2017-11-30 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/ClangdLSPServer.cpp:228
 llvm::toString(Items.takeError()));
+
   C.reply(json::ary(Items->Value));

remove extra line



Comment at: clangd/ClangdUnit.cpp:1054
+return llvm::errc::no_such_file_or_directory;
+  } else {
+FileID FID = AST.getASTContext().getSourceManager().translateFile(F);

else is not needed because it returns in the if



Comment at: clangd/ClangdUnit.cpp:1080
+return llvm::errc::no_such_file_or_directory;
+  } else {
+SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(),

else is not needed since you return in the if



Comment at: clangd/ClangdUnit.cpp:1209
+H.range = L->range;
+  else
+H.range = Range();

```
 else
H.range = Range();
```
Remove this, once the bug in Protocol.cpp is fixed, the Range will be truly 
optional.



Comment at: clangd/ClangdUnit.cpp:1247
+H.range = L->range;
+  else
+H.range = Range();

```
 else
H.range = Range();
```
Remove this, once the bug in Protocol.cpp is fixed, the Range will be truly 
optional.



Comment at: clangd/ClangdUnit.cpp:1505
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
-  /*StoreInMemory=*/That->StorePreamblesInMemory,
-  SerializedDeclsCollector);
+  /*StoreInMemory=*/true, SerializedDeclsCollector);
 

revert this change



Comment at: clangd/Protocol.cpp:498
+// Default Hover values
+Hover H;
+return json::obj{

remove, we have to return the contents of the H that was passed as parameter, 
not a new one. I hit this bug while testing with no range (hover text in 
another file)

So this should be
```
if (H.range.hasValue()) {
return json::obj{
{"contents", json::ary(H.contents)},
{"range", H.range.getValue()},
};
  }

  return json::obj{
{"contents", json::ary(H.contents)},
};
```



Comment at: clangd/Protocol.h:26
 #include "llvm/ADT/Optional.h"
-#include 
+#include "llvm/Support/YAMLParser.h"
 #include 

revert this change?



Comment at: clangd/Protocol.h:463
+
+  /**
+   * The hover's content

Documentation should use /// like the others



Comment at: clangd/Protocol.h:468
+
+  /**
+   * An optional range is a range inside a text document

Documentation should use /// like the others


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894



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


[PATCH] D40668: [Blocks] Inherit sanitizer options from parent decl

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

There is no way to apply sanitizer suppressions to ObjC blocks. A
reasonable default is to have blocks inherit their parent's sanitizer
options.

rdar://32769634


https://reviews.llvm.org/D40668

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenObjC/no-sanitize.m


Index: test/CodeGenObjC/no-sanitize.m
===
--- test/CodeGenObjC/no-sanitize.m
+++ test/CodeGenObjC/no-sanitize.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck 
%s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -784,7 +784,9 @@
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;


Index: test/CodeGenObjC/no-sanitize.m
===
--- test/CodeGenObjC/no-sanitize.m
+++ test/CodeGenObjC/no-sanitize.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck %s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -784,7 +784,9 @@
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-11-30 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added a comment.
This revision now requires changes to proceed.

very minor comments




Comment at: clangd/ClangdServer.h:288
+  /// Get document highlights for a symbol hovered on.
+  llvm::Expected>>
+  findDocumentHighlights(PathRef File, Position Pos);

"for a symbol hovered on."

It doesn't have to be a symbol and the user doesn't have to hover on it. So 
maybe just "for a given position"



Comment at: clangd/ClangdUnit.cpp:1088
+  SourceLocation LocStart = ValSourceRange.getBegin();
+  SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(), 
0,
+ SourceMgr, LangOpts);

  const FileEntry *F = 
SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart));
  if (!F)
return llvm::None;



Comment at: clangd/ClangdUnit.cpp:1098
+  Location L;
+  if (const FileEntry *F =
+  SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {

maybe move the check earlier? see comment above.



Comment at: clangd/Protocol.h:601
+
+/**
+ * A document highlight is a range inside a text document which deserves

Use /// like other structs


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I'm fine with future proofing, but not if it doesn't actually work in the 
present :)




Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

compnerd wrote:
> smeenai wrote:
> > I guess `_DLL` is appropriate here. Ideally though I think adding the 
> > pragma should be keyed on exactly the same conditional that determines 
> > whether we annotate with dllexport/dllimport, and right now that's only 
> > conditional on `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
> Its more complicated.  This is for the *user* not the library itself.  When 
> building the shared library we need to ensure that it is not added 
> (`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a user, 
> the `_DLL` tells you about the dynamic/static behavior.
I know, but the dllimport annotations are also for the *user*. If you're 
getting the dllimport annotations, you should also be getting the pragma, and 
vice-versa.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 124983.
compnerd added a comment.

@rnk/@smeenai don't want future proofing


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,11 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   pragma comment(lib, "c++.lib")
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus



Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,11 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   pragma comment(lib, "c++.lib")
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus

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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

smeenai wrote:
> rnk wrote:
> > smeenai wrote:
> > > This feels more like a Windows (or perhaps COFF) thing than a Microsoft 
> > > ABI thing.
> > I think if you're not using the MS ABI, you're probably using the GCC-style 
> > driver to compile and link, and that is what normally adds the C++ library 
> > to the link line.
> Yeah, that's fair.
Well, is it really a windows thing?  What about MinGW/cygwin?

The interesting thing here is that if you use the `itanium` environment, 
`-lc++` is added to the linker invocation (though it is the BFD linker rather 
than lld).  For the MSVC environment, which assumes a MS ABI style C++ library, 
we do not emit the `c++.lib`.  However, this would accomplish that.



Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

smeenai wrote:
> I guess `_DLL` is appropriate here. Ideally though I think adding the pragma 
> should be keyed on exactly the same conditional that determines whether we 
> annotate with dllexport/dllimport, and right now that's only conditional on 
> `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
Its more complicated.  This is for the *user* not the library itself.  When 
building the shared library we need to ensure that it is not added 
(`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a user, the 
`_DLL` tells you about the dynamic/static behavior.



Comment at: include/__config:1269
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")

rnk wrote:
> smeenai wrote:
> > We never create a `c++d.lib`, as far as I can see. It's always either 
> > `c++.lib` for the import library or `libc++.lib` for the static library.
> Yeah, I'd leave that out until we actually commit cmake or install scripts 
> that make this library.
Okay, I can drop this bit of the diff.


https://reviews.llvm.org/D40660



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


[PATCH] D36555: Move x86-specific sources to x86-specific source lists.

2017-11-30 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine closed this revision.
saugustine added a comment.

Committed as R319464.


https://reviews.llvm.org/D36555



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

rnk wrote:
> smeenai wrote:
> > This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI 
> > thing.
> I think if you're not using the MS ABI, you're probably using the GCC-style 
> driver to compile and link, and that is what normally adds the C++ library to 
> the link line.
Yeah, that's fair.


https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

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



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

smeenai wrote:
> This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI 
> thing.
I think if you're not using the MS ABI, you're probably using the GCC-style 
driver to compile and link, and that is what normally adds the C++ library to 
the link line.



Comment at: include/__config:1269
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")

smeenai wrote:
> We never create a `c++d.lib`, as far as I can see. It's always either 
> `c++.lib` for the import library or `libc++.lib` for the static library.
Yeah, I'd leave that out until we actually commit cmake or install scripts that 
make this library.


https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI 
thing.



Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

I guess `_DLL` is appropriate here. Ideally though I think adding the pragma 
should be keyed on exactly the same conditional that determines whether we 
annotate with dllexport/dllimport, and right now that's only conditional on 
`_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.



Comment at: include/__config:1269
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")

We never create a `c++d.lib`, as far as I can see. It's always either `c++.lib` 
for the import library or `libc++.lib` for the static library.


https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 124976.
compnerd added a comment.

Fix pragma, ensure that we do not try to recursively link.


https://reviews.llvm.org/D40660

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus



Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus

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


[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 124972.
Wizard added a comment.

restore file names


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40528

Files:
  clang-tidy/objc/AvoidNSErrorInitCheck.cpp
  clang-tidy/objc/AvoidNSErrorInitCheck.h
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-avoid-nserror-init.rst
  test/clang-tidy/objc-avoid-nserror-init.m

Index: test/clang-tidy/objc-avoid-nserror-init.m
===
--- /dev/null
+++ test/clang-tidy/objc-avoid-nserror-init.m
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s objc-avoid-nserror-init %t
+@interface NSError
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@implementation foo
+- (void)bar {
+NSError *error = [[NSError alloc] init];
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to create a new NSError [objc-avoid-nserror-init]
+}
+@end
Index: docs/clang-tidy/checks/objc-avoid-nserror-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-avoid-nserror-init.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-avoid-nserror-init
+
+objc-avoid-nserror-init
+===
+
+This check will find out improper initialization of NSError objects.
+
+According to Apple developer document, we should always use factory method 
+``errorWithDomain:code:userInfo:`` to create new NSError objects instead
+of ``[NSError alloc] init]``. Otherwise it will lead to a warning message
+during runtime.
+
+The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -173,6 +173,7 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
@@ -158,6 +163,11 @@
   Finds uses of bitwise operations on signed integer types, which may lead to 
   undefined or implementation defined behaviour.
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New `objc-avoid-spinlock
   `_ check
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
@@ -23,6 +24,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"objc-avoid-nserror-init");
 CheckFactories.registerCheck(
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
Index: clang-tidy/objc/CMakeLists.txt
===
--- clang-tidy/objc/CMakeLists.txt
+++ clang-tidy/objc/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
+  AvoidNSErrorInitCheck.cpp
   AvoidSpinlockCheck.cpp
   ForbiddenSubclassingCheck.cpp
   ObjCTidyModule.cpp
Index: clang-tidy/objc/AvoidNSErrorInitCheck.h
===
--- /dev/null
+++ clang-tidy/objc/AvoidNSErrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H

[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319460: add new check to find NSError init invocation 
(authored by Wizard).

Changed prior to commit:
  https://reviews.llvm.org/D40528?vs=124972&id=124973#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40528

Files:
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst

Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds usages of [NSSError init]. It is not the proper way of creating
+/// NSError. errorWithDomain:code:userInfo: should be used instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-nserror-init.html
+class AvoidNSErrorInitCheck : public ClangTidyCheck {
+ public:
+  AvoidNSErrorInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
@@ -0,0 +1,37 @@
+//===--- AvoidNSErrorInitCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "AvoidNSErrorInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcMessageExpr(hasSelector("init"),
+ hasReceiverType(asString("NSError *")))
+ .bind("nserrorInit"),
+ this);
+}
+
+void AvoidNSErrorInitCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedExpr =
+  Result.Nodes.getNodeAs("nserrorInit");
+  diag(MatchedExpr->getLocStart(),
+   "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to "
+   "create a new NSError");
+}
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
@@ -1,37 +0,0 @@
-//===--- AvoidNSErrorInitCheck.cpp - clang-tidy===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===

[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319459: add new check to find NSError init invocation 
(authored by Wizard).

Changed prior to commit:
  https://reviews.llvm.org/D40528?vs=124972&id=124974#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40528

Files:
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
  clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-nserror-init.rst
  clang-tools-extra/trunk/test/clang-tidy/objc-avoid-nserror-init.m

Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds usages of [NSSError init]. It is not the proper way of creating
+/// NSError. errorWithDomain:code:userInfo: should be used instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-nserror-init.html
+class AvoidNSErrorInitCheck : public ClangTidyCheck {
+ public:
+  AvoidNSErrorInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
@@ -0,0 +1,37 @@
+//===--- AvoidNSErrorInitCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "AvoidNSErrorInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcMessageExpr(hasSelector("init"),
+ hasReceiverType(asString("NSError *")))
+ .bind("nserrorInit"),
+ this);
+}
+
+void AvoidNSErrorInitCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedExpr =
+  Result.Nodes.getNodeAs("nserrorInit");
+  diag(MatchedExpr->getLocStart(),
+   "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to "
+   "create a new NSError");
+}
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
@@ -23,6 +24,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"objc-avoid-nserror-init");
 CheckFactories.registerCheck(
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/objc/C

[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 124971.
Wizard added a comment.

change file name cases


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40528

Files:
  clang-tidy/objc/AvoidNSEErrorInitCheck.cpp
  clang-tidy/objc/AvoidNSEErrorInitCheck.h
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-avoid-nserror-init.rst
  test/clang-tidy/objc-avoid-nserror-init.m

Index: test/clang-tidy/objc-avoid-nserror-init.m
===
--- /dev/null
+++ test/clang-tidy/objc-avoid-nserror-init.m
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s objc-avoid-nserror-init %t
+@interface NSError
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@implementation foo
+- (void)bar {
+NSError *error = [[NSError alloc] init];
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to create a new NSError [objc-avoid-nserror-init]
+}
+@end
Index: docs/clang-tidy/checks/objc-avoid-nserror-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-avoid-nserror-init.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-avoid-nserror-init
+
+objc-avoid-nserror-init
+===
+
+This check will find out improper initialization of NSError objects.
+
+According to Apple developer document, we should always use factory method 
+``errorWithDomain:code:userInfo:`` to create new NSError objects instead
+of ``[NSError alloc] init]``. Otherwise it will lead to a warning message
+during runtime.
+
+The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -173,6 +173,7 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
@@ -158,6 +163,11 @@
   Finds uses of bitwise operations on signed integer types, which may lead to 
   undefined or implementation defined behaviour.
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New `objc-avoid-spinlock
   `_ check
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
@@ -23,6 +24,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"objc-avoid-nserror-init");
 CheckFactories.registerCheck(
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
Index: clang-tidy/objc/CMakeLists.txt
===
--- clang-tidy/objc/CMakeLists.txt
+++ clang-tidy/objc/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
+  AvoidNSErrorInitCheck.cpp
   AvoidSpinlockCheck.cpp
   ForbiddenSubclassingCheck.cpp
   ObjCTidyModule.cpp
Index: clang-tidy/objc/AvoidNSEErrorInitCheck.h
===
--- /dev/null
+++ clang-tidy/objc/AvoidNSEErrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINI

[PATCH] D40588: [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319458: [OpenMP] Diagnose undeclared variables on declare 
target clause (authored by kli).

Repository:
  rC Clang

https://reviews.llvm.org/D40588

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_target_messages.cpp


Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }
Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, 
only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared 
identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared 
identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
 extern int b;


Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }
Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
 extern int b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40588: [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319458: [OpenMP] Diagnose undeclared variables on declare 
target clause (authored by kli).

Changed prior to commit:
  https://reviews.llvm.org/D40588?vs=124811&id=124969#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40588

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/declare_target_messages.cpp


Index: cfe/trunk/test/OpenMP/declare_target_messages.cpp
===
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, 
only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared 
identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared 
identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
 extern int b;
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }


Index: cfe/trunk/test/OpenMP/declare_target_messages.cpp
===
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
 extern int b;
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319458 - [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Kelvin Li via cfe-commits
Author: kli
Date: Thu Nov 30 10:52:06 2017
New Revision: 319458

URL: http://llvm.org/viewvc/llvm-project?rev=319458&view=rev
Log:
[OpenMP] Diagnose undeclared variables on declare target clause

Clang asserts on undeclared variables on the to or link clause in the declare
target directive. The patch is to properly diagnose the error.

// foo1 and foo2 are not declared
#pragma omp declare target to(foo1)
#pragma omp declare target link(foo2)

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


Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319458&r1=319457&r2=319458&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Nov 30 10:52:06 2017
@@ -1506,7 +1506,7 @@ public:
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }

Modified: cfe/trunk/test/OpenMP/declare_target_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_messages.cpp?rev=319458&r1=319457&r2=319458&view=diff
==
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp Thu Nov 30 10:52:06 2017
@@ -13,6 +13,10 @@ void f();
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, 
only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared 
identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared 
identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
 extern int b;


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


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks @ilya-biryukov, @inspirer, @klimek for the helpful comments!

I've addressed hopefully the most important and added more rigorous testing.
Sorry for the large delta, the most invasive change was of course adding the 
extra dimension to the scoring table. (Which fixed a bunch of problems)




Comment at: clangd/FuzzyMatch.cpp:118
+0x00, 0x00, 0x00, 0x00, // Control characters
+0xff, 0xff, 0xff, 0xff, // Punctuation
+0x55, 0x55, 0xf5, 0xff, // Numbers->Lower, more Punctuation.

ilya-biryukov wrote:
> I'm not sure if we care, but maybe we should treat `+`, `-` and other symbols 
> that could be in operator names (e.g., `operator +`) differently for C++.
> Could also make sense for other languages with overloaded operators.
You might be right, but in the absence of concrete problems I think treating 
them as punctuation is actually the most conservative thing to do.

E.g. matching [op=] against "operator=" gets big penalties if we treat '=' as 
Lower, and treating it as Upper seems likely to have other weird effects... 
Punctuation/separators are treated pretty neutrally.



Comment at: clangd/FuzzyMatch.cpp:245
+  if (!P && WordRole[W] == Tail)
+return AwfulScore;
+  ScoreT S = 0;

ilya-biryukov wrote:
> Does it mean I will get no matches in the following situation?
> 
> `Items = [printf, scanf]`
> `Pattern = f`
> 
> It may be a bit confusing, since I do have a match, even though is terrible 
> and it's ok to put those items very low in the list.
> A more real example is:
> `Items = [fprintf, fscanf]`
> `Pattern = print`
> 
> Would `fprintf` match in that case? I think it should.
> 
> Another important one:
> `Items = [istream, ostream]`
> `Pattern = stream`
Done. VSCode will filter these out, but I agree these are important and don't 
seem to cause problems.



Comment at: clangd/FuzzyMatch.cpp:254
+  // Penalty: matching inside a segment (and previous char wasn't matched).
+  if (WordRole[W] == Tail && P && !Matched[P - 1][W - 1])
+S -= 3;

inspirer wrote:
> You need a third boolean dimension in your DP table for this condition to 
> work - "matches".
> 
> Consider matching "Abde" against "AbdDe". The result should be [Ab]d[De] and 
> not [Abd]D[e]. While evaluating Abd against AbdD, you will have to choose 
> between two ways to represent the match and no matter what you choose, 
> scoring in this line will not know whether your previous char matched, since 
> you merged two branches and kept only one of them.
> 
> This scoring works OK-ish since you check "if (Diag >= Left)" above and so 
> you Matched table is full of trues, but you matches will gravitate towards 
> the ends of the candidate string if you decide to show them in the UI.
Thank you for this! Fixed. The naming around Scores/ScoreInfo is a bit clumsy, 
happy to take suggestions :-(

I've also made all our tests assert the exact characters matched. We don't have 
an API or need this feature, but it makes the tests detect a lot more 
misbehavior that's hard to capture otherwise.



Comment at: clangd/FuzzyMatch.h:53
+
+  int PatN, WordN;   // Length of pattern and word.
+  char Pat[MaxPat], Word[MaxWord];   // Raw pattern and word data.

ilya-biryukov wrote:
> Maybe we could split the data we store into two sections:
> 1. Pattern-specific data. Initialized on construction, never changed later.
> 2. Per-match data. Initialized per `match()` call.
> 
> Otherwise it is somewhat hard to certify whether everything is being 
> initialized properly.
This hides the parallels between the Pattern and Word data, I'm not sure I like 
it better overall.

I've added a comment describing this split, reordered some variables, and 
renamed IsSubstring to WordContainsPattern, which I think clarifies this a bit. 
WDYT?


https://reviews.llvm.org/D40060



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


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 124968.
sammccall marked 5 inline comments as done.
sammccall added a comment.

- added more VSCode tests, and made test assert matched characters. This 
uncovered algorithm problems
- cache now includes "did previous character match" in the key (scoring depends 
on this, so we gave incorrect results)
- added a penalty for non-consecutive matches
- first character matching inside a segment downgraded from a ban to a penalty 
This allows [stream] to match "istream"
- don't award case bonuses if the query is all lowercase. This helps matches 
like [ccm] -> [c]ode[C]ompletec[m] compete with [c]odeComplete[cm]


https://reviews.llvm.org/D40060

Files:
  clangd/CMakeLists.txt
  clangd/FuzzyMatch.cpp
  clangd/FuzzyMatch.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FuzzyMatchTests.cpp

Index: unittests/clangd/FuzzyMatchTests.cpp
===
--- /dev/null
+++ unittests/clangd/FuzzyMatchTests.cpp
@@ -0,0 +1,252 @@
+//===-- FuzzyMatchTests.cpp - String fuzzy matcher tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using namespace llvm;
+using testing::Not;
+
+struct ExpectedMatch {
+  ExpectedMatch(StringRef Annotated) : Word(Annotated), Annotated(Annotated) {
+for (char C : "[]")
+  Word.erase(std::remove(Word.begin(), Word.end(), C), Word.end());
+  }
+  std::string Word;
+  StringRef Annotated;
+};
+raw_ostream &operator<<(raw_ostream &OS, const ExpectedMatch &M) {
+  return OS << "'" << M.Word << "' as " << M.Annotated;
+}
+
+struct MatchesMatcher : public testing::MatcherInterface {
+  ExpectedMatch Candidate;
+  MatchesMatcher(ExpectedMatch Candidate) : Candidate(std::move(Candidate)) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+raw_os_ostream(*OS) << "Matches " << Candidate;
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+auto Result = Matcher.match(Candidate.Word);
+auto AnnotatedMatch = Matcher.dumpLast(*OS << "\n");
+return Result && AnnotatedMatch == Candidate.Annotated;
+  }
+};
+
+// Accepts patterns that match a given word.
+// Dumps the debug tables on match failure.
+testing::Matcher matches(StringRef M) {
+  return testing::MakeMatcher(new MatchesMatcher(M));
+}
+
+TEST(FuzzyMatch, Matches) {
+  EXPECT_THAT("u_p", matches("[u]nique[_p]tr"));
+  EXPECT_THAT("up", matches("[u]nique_[p]tr"));
+  EXPECT_THAT("uq", matches("[u]ni[q]ue_ptr"));
+  EXPECT_THAT("qp", Not(matches("unique_ptr")));
+  EXPECT_THAT("log", Not(matches("SVGFEMorphologyElement")));
+
+  EXPECT_THAT("tit", matches("win.[tit]"));
+  EXPECT_THAT("title", matches("win.[title]"));
+  EXPECT_THAT("WordCla", matches("[Word]Character[Cla]ssifier"));
+  EXPECT_THAT("WordCCla", matches("[WordC]haracter[Cla]ssifier"));
+
+  EXPECT_THAT("dete", Not(matches("editor.quickSuggestionsDelay")));
+
+  EXPECT_THAT("highlight", matches("editorHover[Highlight]"));
+  EXPECT_THAT("hhighlight", matches("editor[H]over[Highlight]"));
+  EXPECT_THAT("dhhighlight", Not(matches("editorHoverHighlight")));
+
+  EXPECT_THAT("-moz", matches("[-moz]-foo"));
+  EXPECT_THAT("moz", matches("-[moz]-foo"));
+  EXPECT_THAT("moza", matches("-[moz]-[a]nimation"));
+
+  EXPECT_THAT("ab", matches("[ab]A"));
+  EXPECT_THAT("ccm", matches("[c]a[cm]elCase"));
+  EXPECT_THAT("bti", Not(matches("the_black_knight")));
+  EXPECT_THAT("ccm", Not(matches("camelCase")));
+  EXPECT_THAT("cmcm", Not(matches("camelCase")));
+  EXPECT_THAT("BK", matches("the_[b]lack_[k]night"));
+  EXPECT_THAT("KeyboardLayout=", Not(matches("KeyboardLayout")));
+  EXPECT_THAT("LLL", matches("SVisual[L]ogger[L]ogs[L]ist"));
+  EXPECT_THAT("", Not(matches("SVilLoLosLi")));
+  EXPECT_THAT("", Not(matches("SVisualLoggerLogsList")));
+  EXPECT_THAT("TEdit", matches("[T]ext[Edit]"));
+  EXPECT_THAT("TEdit", matches("[T]ext[Edit]or"));
+  EXPECT_THAT("TEdit", matches("[Te]xte[dit]"));
+  EXPECT_THAT("TEdit", matches("[t]ext_[edit]"));
+  EXPECT_THAT("TEditDit", matches("[T]ext[Edit]or[D]ecorat[i]on[T]ype"));
+  EXPECT_THAT("TEdit", matches("[T]ext[Edit]orDecorationType"));
+  EXPECT_THAT("Tedit", matches("[T]ext[Edit]"));
+  EXPECT_THAT("ba", Not(matches("?AB?")));
+  EXPECT_THAT("bkn", matches("the_[b]lack_[kn]ight"));
+  EXPECT_THAT("bt", matches("the_[b]lack_knigh[t]"));
+  EXPECT_THAT("ccm"

[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2017-11-30 Thread Dan Olson via Phabricator via cfe-commits
dolson added a comment.

Hello,

In the process of upgrading from clang 3.6.1 to a newer version, I ran into 
this new error and thus imported the new intrinsics from intrin.h for rep movsb 
and friends.  I see several discussions in this thread about how having the 
registers solely in the inputs list is not sufficient for something like "rep 
movsb" because the modified registers will not be clobbered, however none of 
these suggested changes made it into the eventual intrin.h.

I found that using the versions of `__movsb` and `__stosb` that are at the head 
revision intrin.h produced bad code generation vs the versions with the 
clobbers.  Note this is on PS4 under the older clang 3.6.1, but I don't see 
anything in this CL that would update the clobber behavior for newer versions 
of clang.

Shouldn't the intrinsics be updated to use input/output registers or some other 
method of clobbering?


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
Herald added a subscriber: cfe-commits.

The MSVC driver and clang do not link against the C++ runtime
explicitly.  Instead, they rely on the auto-linking via the pragma
(through `use_ansi.h`) to link against the correct version of the C++
runtime.  Attempt to do something similar here so that linking real C++
code on Windows does not require the user to explicitly specify
`c++.lib` when using libc++ as a C++ runtime on windows.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma(lib, "c++d.lib")
+#   else
+# pragma(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus



Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma(lib, "c++d.lib")
+#   else
+# pragma(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus

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


r319450 - [OPENMP] Fix possible assert for target regions with incorrect inner

2017-11-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov 30 10:01:54 2017
New Revision: 319450

URL: http://llvm.org/viewvc/llvm-project?rev=319450&view=rev
Log:
[OPENMP] Fix possible assert for target regions with incorrect inner
teams region.

If the inner teams region is not correct, it may cause an assertion when
processing outer target region. Patch fixes this problem.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319450&r1=319449&r2=319450&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Nov 30 10:01:54 2017
@@ -2674,7 +2674,6 @@ static bool checkNestingOfRegions(Sema &
   NestingProhibited = ParentRegion != OMPD_target;
   OrphanSeen = ParentRegion == OMPD_unknown;
   Recommend = ShouldBeInTargetRegion;
-  Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
 }
 if (!NestingProhibited &&
 !isOpenMPTargetExecutionDirective(CurrentRegion) &&
@@ -6569,6 +6568,8 @@ StmtResult Sema::ActOnOpenMPTeamsDirecti
 
   getCurFunction()->setHasBranchProtectedScope();
 
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
 }
 
@@ -7071,6 +7072,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
  "omp teams distribute loop exprs were not built");
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
 }
@@ -7119,6 +7123,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
 return StmtError();
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeSimdDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
 }
@@ -7167,6 +7174,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
 return StmtError();
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeParallelForSimdDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
 }
@@ -7213,6 +7223,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
  "omp for loop exprs were not built");
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeParallelForDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
   DSAStack->isCancelRegion());

Modified: cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp?rev=319450&r1=319449&r2=319450&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp Thu Nov 30 
10:01:54 2017
@@ -689,6 +689,9 @@ void test_loop_eh() {
   void g() { throw 0; }
 };
   }
+  #pragma omp target
+  #pragma omp teams distribute
+  f; // expected-error {{use of undeclared identifier 'f'}}
 }
 
 void test_loop_firstprivate_lastprivate() {

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp?rev=319450&r1=319449&r2=319450&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp Thu Nov 30 
10:01:54 2017
@@ -9,6 +9,9 @@ static int pvt;
 #pragma omp teams distribute parallel for // expected-error {{unexpected 
OpenMP directive '#pragma omp teams distribute parallel for'}}
 
 int main(int argc, char **argv) {
+  #pragma omp target
+  #pragma omp teams distribute parallel for
+  f; // expected-error {{use of undeclared identifier 'f'}}
 #pragma omp target
 #pragma omp teams distribute parallel for { // expected-warning {{extra tokens 
at the end of '#pragma omp teams distribute parallel for' are ignored}}
   for (int i = 0; i < argc; ++i)

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp?rev=319450&r1=319449&r2

[PATCH] D40448: Add a printing policy for AST dumping

2017-11-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping.


https://reviews.llvm.org/D40448



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


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-11-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:35-36
+  StringRef Name = Node->getIdentifier()->getName();
+  if (InterfaceMap.count(Name)) {
+isInterface = InterfaceMap.lookup(Name);
+return true;

One lookup is enough here. Use `StringMap::find()` instead of count + lookup.


https://reviews.llvm.org/D40580



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


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

2017-11-30 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

In https://reviews.llvm.org/D36431#940169, @nemanjai wrote:

> This has been sitting in approved state for more than 2 months. As far as I 
> can tell, it wasn't committed. Do you plan to commit this soon or are you 
> abandoning it for some reason?


My apologies. I have gotten distracted by other things and will get this 
submitted shortly.


https://reviews.llvm.org/D36431



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


[PATCH] D40605: Better trade-off for excess characters vs. staying within the column limits.

2017-11-30 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: unittests/Format/FormatTest.cpp:10007
+format("// foo foo foo foo foo foo foo foo foo foo foo foo\n",
+   Style));
 }

Could you also add a test with line comments surrounded by stuff, like in:
```
int f() {
  int a = /* long block comment */ 42;
}


Repository:
  rC Clang

https://reviews.llvm.org/D40605



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


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

2017-11-30 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 124951.
Nebiroth marked 6 inline comments as done.
Nebiroth added a comment.

  Minor code cleanup
  getDeclarationLocation now returns llvm::Optional
  operator< for DocumentHighlight struct now properly compares the kind field


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 479
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nint test1 = bonjour;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();\n}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Verify local variable 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}}
+# Verify struct highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}}
+# Verify method highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":14,"line":2},"start":{"character":7,"line":2}}},{"kind":1,"range":{"end":{"character":22,"line":6},"start":{"character":15,"line":6}}},{"kind":1,"range":{"end":{"character":12,"line":21},"start":{"character":5,"line":21}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":14}}}
+# Verify Read-access of a symbol (kind = 2) 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 48
+
+{"jsonrpc":"2.0","id":1,"method":"shutdown"}
+
+Content-Length: 33
+
+{"jsonr

  1   2   >