[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

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

In https://reviews.llvm.org/D39673#917524, @martell wrote:

> I mostly expect this to be useful where environment has builds all 3 versions 
> of the libunwind. where the library is named differently based on the eh 
> model.
>  e.g. `libunwind-sjlj.a` `libunwind-seh.a` and `libunwind-dwarf.a`
>  With the above exception flags the version of libunwind with the matching 
> model should be automatically linked, I imagine it to be stored in a similar 
> locations as the compiler-rt libs.


Ah, I see. I'm a little hesitant about such an environment, because code built 
with each exception handling model is essentially a different ABI, and having 
them all in the same setup feels pretty prone to errors. Like, you need to have 
built your libcxx and libcxxabi with matching exception handling models as 
well, so then you need three copies of them as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true

2017-11-07 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

ping?


https://reviews.llvm.org/D37187



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


[clang-tools-extra] r317552 - Add new check in google module for Objective-C code to ensure global variables follow the naming convention of Google Objective-C Style Guide

2017-11-07 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Nov  7 00:53:37 2017
New Revision: 317552

URL: http://llvm.org/viewvc/llvm-project?rev=317552&view=rev
Log:
Add new check in google module for Objective-C code to ensure global variables 
follow the naming convention of Google Objective-C Style Guide

Summary:
This is a new checker for objc files in clang-tidy.

The new check finds global variable declarations in Objective-C files that are 
not follow the pattern of variable names in Google's Objective-C Style Guide.

All the global variables should follow the pattern of "g[A-Z].*" (variables) or 
"k[A-Z].*" (constants). The check will suggest a variable name that follows the 
pattern
if it can be inferred from the original name.

Patch by Yan Zhang!

Reviewers: benhamilton, hokein, alexfh

Reviewed By: hokein

Subscribers: Eugene.Zelenko, mgorny

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

Added:
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.h

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

clang-tools-extra/trunk/test/clang-tidy/google-objc-global-variable-declaration.m
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=317552&r1=317551&r2=317552&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Tue Nov  7 
00:53:37 2017
@@ -6,6 +6,7 @@ add_clang_library(clangTidyGoogleModule
   ExplicitConstructorCheck.cpp
   ExplicitMakePairCheck.cpp
   GlobalNamesInHeadersCheck.cpp
+  GlobalVariableDeclarationCheck.cpp
   GoogleTidyModule.cpp
   IntegerTypesCheck.cpp
   NonConstReferences.cpp

Added: 
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp?rev=317552&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp 
Tue Nov  7 00:53:37 2017
@@ -0,0 +1,90 @@
+//===--- GlobalVariableDeclarationCheck.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 "GlobalVariableDeclarationCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+namespace {
+
+FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
+  char FC = Decl->getName()[0];
+  if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
+// No fix available if first character is not alphabetical character, or it
+// is a single-character variable, since it is difficult to determine the 
+// proper fix in this case. Users should create a proper variable name by
+// their own.
+return FixItHint();
+  }
+  char SC = Decl->getName()[1];
+  if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) {
+// No fix available if the prefix is correct but the second character is 
not
+// alphabetical, since it is difficult to determine the proper fix in this
+// case.
+return FixItHint();
+  }
+  auto NewName = (IsConst ? "k" : "g") +
+ llvm::StringRef(std::string(1, FC)).upper() +
+ Decl->getName().substr(1).str();
+  return FixItHint::CreateReplacement(
+  CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
+  llvm::StringRef(NewName));
+}
+}  // namespace
+
+void GlobalVariableDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  // The relevant Style Guide rule only applies to Objective-C.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
+  // need to add two matchers since we need to bind different ids to 
distinguish
+  // constants and variables. Since bind() can only be called on node matchers,
+  // we cannot make it in one matcher.
+  Finder->addMatcher(
+  varDecl(hasGlobalStorage(), unless(hasType(isConstQualified())),

[clang-tools-extra] r317553 - [clangd] fix MSVC build errors

2017-11-07 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Nov  7 00:57:54 2017
New Revision: 317553

URL: http://llvm.org/viewvc/llvm-project?rev=317553&view=rev
Log:
[clangd] fix MSVC build errors

Modified:
clang-tools-extra/trunk/clangd/JSONExpr.cpp
clang-tools-extra/trunk/clangd/JSONExpr.h

Modified: clang-tools-extra/trunk/clangd/JSONExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONExpr.cpp?rev=317553&r1=317552&r2=317553&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONExpr.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONExpr.cpp Tue Nov  7 00:57:54 2017
@@ -2,10 +2,10 @@
 
 #include "llvm/Support/Format.h"
 
+using namespace llvm;
 namespace clang {
 namespace clangd {
 namespace json {
-using namespace llvm;
 
 void Expr::copyFrom(const Expr &M) {
   Type = M.Type;

Modified: clang-tools-extra/trunk/clangd/JSONExpr.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONExpr.h?rev=317553&r1=317552&r2=317553&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONExpr.h (original)
+++ clang-tools-extra/trunk/clangd/JSONExpr.h Tue Nov  7 00:57:54 2017
@@ -154,7 +154,7 @@ public:
 ObjectKey(const llvm::formatv_object_base &V) : ObjectKey(V.str()) {}
 
 ObjectKey(const ObjectKey &C) { *this = C; }
-ObjectKey(ObjectKey &&C) = default;
+ObjectKey(ObjectKey &&C) : ObjectKey(static_cast(C)) {}
 ObjectKey &operator=(const ObjectKey &C) {
   if (C.Owned) {
 Owned.reset(new std::string(*C.Owned));


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


[PATCH] D39717: Always use prctl(PR_SET_PTRACER)

2017-11-07 Thread Mike Hommey via Phabricator via cfe-commits
glandium created this revision.
Herald added a subscriber: kubamracek.

Sufficiently old Linux kernel headers don't provide the PR_SET_PTRACER, but we 
can still call prctl with it if the runtime kernel is newer. Even if it's not, 
prctl will only return EINVAL.


https://reviews.llvm.org/D39717

Files:
  lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc


Index: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
===
--- lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -57,6 +57,13 @@
 #include "sanitizer_mutex.h"
 #include "sanitizer_placement_new.h"
 
+// Sufficiently old kernel header don't provide this value, but we can still
+// call prctl with it if the runtime kernel is newer. Even if it's not, prctl
+// will only return EINVAL.
+#ifndef PR_SET_PTRACER
+#define PR_SET_PTRACER 0x59616d61
+#endif
+
 // This module works by spawning a Linux task which then attaches to every
 // thread in the caller process with ptrace. This suspends the threads, and
 // PTRACE_GETREGS can then be used to obtain their register state. The callback
@@ -433,9 +440,7 @@
 ScopedSetTracerPID scoped_set_tracer_pid(tracer_pid);
 // On some systems we have to explicitly declare that we want to be traced
 // by the tracer thread.
-#ifdef PR_SET_PTRACER
 internal_prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
-#endif
 // Allow the tracer thread to start.
 tracer_thread_argument.mutex.Unlock();
 // NOTE: errno is shared between this thread and the tracer thread.


Index: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
===
--- lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -57,6 +57,13 @@
 #include "sanitizer_mutex.h"
 #include "sanitizer_placement_new.h"
 
+// Sufficiently old kernel header don't provide this value, but we can still
+// call prctl with it if the runtime kernel is newer. Even if it's not, prctl
+// will only return EINVAL.
+#ifndef PR_SET_PTRACER
+#define PR_SET_PTRACER 0x59616d61
+#endif
+
 // This module works by spawning a Linux task which then attaches to every
 // thread in the caller process with ptrace. This suspends the threads, and
 // PTRACE_GETREGS can then be used to obtain their register state. The callback
@@ -433,9 +440,7 @@
 ScopedSetTracerPID scoped_set_tracer_pid(tracer_pid);
 // On some systems we have to explicitly declare that we want to be traced
 // by the tracer thread.
-#ifdef PR_SET_PTRACER
 internal_prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
-#endif
 // Allow the tracer thread to start.
 tracer_thread_argument.mutex.Unlock();
 // NOTE: errno is shared between this thread and the tracer thread.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-11-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Weekly ping. This week is C++ committee, so it's again going to be hard to get 
Richards attention :( It's an unfortunate time of year to land major 
API-touching changes.


https://reviews.llvm.org/D5767



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


[PATCH] D39718: [clangd] Add ErrorCodes enum class.

2017-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: ilya-biryukov.

Avoid using magic number in the code everywhere.


https://reviews.llvm.org/D39718

Files:
  clangd/ClangdLSPServer.cpp
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -32,6 +32,22 @@
 
 class Logger;
 
+enum class ErrorCodes {
+  // Defined by JSON RPC.
+  ParseError = -32700,
+  InvalidRequest = -32600,
+  MethodNotFound = -32601,
+  InvalidParams = -32602,
+  InternalError = -32603,
+  serverErrorStart = -32099,
+  serverErrorEnd = -32000,
+  ServerNotInitialized = -32002,
+  UnknownErrorCode = -32001,
+
+  // Defined by the protocol.
+  RequestCancelled = -32800,
+};
+
 struct URI {
   std::string uri;
   std::string file;
Index: clangd/JSONRPCDispatcher.h
===
--- clangd/JSONRPCDispatcher.h
+++ clangd/JSONRPCDispatcher.h
@@ -12,6 +12,7 @@
 
 #include "JSONExpr.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
@@ -60,7 +61,7 @@
   /// Sends a successful reply.
   void reply(json::Expr &&Result);
   /// Sends an error response to the client, and logs it.
-  void replyError(int code, const llvm::StringRef &Message);
+  void replyError(ErrorCodes code, const llvm::StringRef &Message);
   /// Sends a request to the client.
   void call(llvm::StringRef Method, json::Expr &&Params);
 
Index: clangd/JSONRPCDispatcher.cpp
===
--- clangd/JSONRPCDispatcher.cpp
+++ clangd/JSONRPCDispatcher.cpp
@@ -65,13 +65,13 @@
   });
 }
 
-void RequestContext::replyError(int code, const llvm::StringRef &Message) {
-  Out.log("Error " + llvm::Twine(code) + ": " + Message + "\n");
+void RequestContext::replyError(ErrorCodes code, const llvm::StringRef &Message) {
+  Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", code}, {"message", Message}}},
+{"error", json::obj{{"code", static_cast(code)}, {"message", Message}}},
 });
   }
 }
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -85,7 +85,8 @@
 void ClangdLSPServer::onDocumentDidChange(Ctx C,
   DidChangeTextDocumentParams &Params) {
   if (Params.contentChanges.size() != 1)
-return C.replyError(-32602, "can only apply one change at a time");
+return C.replyError(ErrorCodes::InvalidParams,
+"can only apply one change at a time");
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file,
  Params.contentChanges[0].text);
@@ -119,7 +120,8 @@
 // parsed in the first place and this handler should not be called. But if
 // more commands are added, this will be here has a safe guard.
 C.replyError(
-1, llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
+ErrorCodes::InvalidParams,
+llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
   }
 }
 
@@ -191,7 +193,8 @@
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!SignatureHelp)
-return C.replyError(-32602, llvm::toString(SignatureHelp.takeError()));
+return C.replyError(ErrorCodes::InvalidParams,
+llvm::toString(SignatureHelp.takeError()));
   C.reply(SignatureHelp->Value);
 }
 
@@ -201,7 +204,8 @@
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!Items)
-return C.replyError(-32602, llvm::toString(Items.takeError()));
+return C.replyError(ErrorCodes::InvalidParams,
+llvm::toString(Items.takeError()));
   C.reply(json::ary(Items->Value));
 }
 
@@ -228,7 +232,7 @@
   // Set up JSONRPCDispatcher.
   JSONRPCDispatcher Dispatcher(
   [](RequestContext Ctx, llvm::yaml::MappingNode *Params) {
-Ctx.replyError(-32601, "method not found");
+Ctx.replyError(ErrorCodes::MethodNotFound, "method not found");
   });
   registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-11-07 Thread jina via Phabricator via cfe-commits
jina.nahias created this revision.

https://reviews.llvm.org/D39719

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


Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6224,10 +6224,15 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return 
_mm512_mask_cmpneq_epu32_mask(_mm512_kunpackb(_mm512_cmpneq_epu32_mask(__A,__B),_mm512_cmpneq_epu32_mask(__C,__D)),__E,
 __F);
 }
 
 __mmask16 test_mm512_kxnor(__mmask16 __A, __mmask16 __B) {
Index: test/CodeGen/avx512bw-builtins.c
===
--- test/CodeGen/avx512bw-builtins.c
+++ test/CodeGen/avx512bw-builtins.c
@@ -1626,16 +1626,26 @@
   return _mm512_maskz_set1_epi8(__M, __A); 
 }
 
-__mmask64 test_mm512_kunpackd(__mmask64 __A, __mmask64 __B) {
+__mmask64 test_mm512_kunpackd(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackd
-  // CHECK: @llvm.x86.avx512.kunpck.dq
-  return _mm512_kunpackd(__A, __B); 
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: and i64 %{{.*}}, 4294967295
+  // CHECK: shl i64 %{{.*}}, 32
+  // CHECK: or i64 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i64 %{{.*}} to <64 x i1>
+  return 
_mm512_mask_cmpneq_epu8_mask(_mm512_kunpackd(_mm512_cmpneq_epu8_mask(__B, 
__A),_mm512_cmpneq_epu8_mask(__C, __D)), __E, __F); 
 }
 
-__mmask32 test_mm512_kunpackw(__mmask32 __A, __mmask32 __B) {
+__mmask32 test_mm512_kunpackw(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackw
-  // CHECK: @llvm.x86.avx512.kunpck.wd
-  return _mm512_kunpackw(__A, __B); 
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: and i32 %{{.*}}, 65535
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i32 %{{.*}} to <32 x i1>
+  return 
_mm512_mask_cmpneq_epu16_mask(_mm512_kunpackw(_mm512_cmpneq_epu16_mask(__B, 
__A),_mm512_cmpneq_epu16_mask(__C, __D)), __E, __F); 
 }
 
 __m512i test_mm512_mask_loadu_epi16(__m512i __W, __mmask32 __U, void const 
*__P) {
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -9011,7 +9011,7 @@
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) 
__B);
+  return (__mmask16)  (( __B  & 0xFF) | ((__mmask16) __A << 8));
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
Index: lib/Headers/avx512bwintrin.h
===
--- lib/Headers/avx512bwintrin.h
+++ lib/Headers/avx512bwintrin.h
@@ -2042,15 +2042,13 @@
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __B  & 0x) | ((__mmask64) __A << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A,
-(__mmask32) __B);
+return (__mmask32)  (( __B  & 0x) | ((__mmask32) __A << 16));
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS


Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6224,10 +6224,15 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return _mm512_mask_cmpneq_epu32_mask(

[PATCH] D39705: [clangd] Fix opening declarations located in non-preamble inclusion

2017-11-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clangd/ClangdUnit.cpp:970
+SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {
+  StringRef FilePath = F->tryGetRealPathName();
+  if (FilePath.empty())

Can you add a comment about when this is needed?
like // Non-preamble included files may have relative paths.


Repository:
  rL LLVM

https://reviews.llvm.org/D39705



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


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

2017-11-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Sorry for jumping in late, but I'm somewhat questioning whether an extra 
function in the API is worth the cost here:
If you already have a printing policy, getting the type name will be 1 line 
instead of 2; having an extra function in a large API seems not worth it at a 
first glance.


https://reviews.llvm.org/D36610



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


[PATCH] D39718: [clangd] Add ErrorCodes enum class.

2017-11-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/Protocol.h:35
 
+enum class ErrorCodes {
+  // Defined by JSON RPC.

nit: could you call this ErrorCode? The plural doesn't make so much sense as a 
type name.



Comment at: clangd/Protocol.h:42
+  InternalError = -32603,
+  serverErrorStart = -32099,
+  serverErrorEnd = -32000,

`serverErrorStart`/`End` are not error codes, they're for comparing the numeric 
values to a range.

Given this is an enum **class** and we have to cast to int to do comparisons, I 
don't think these belong inside the enum, but rather as ints, outside it.

However, these limits aren't used at all yet, so probably just remove them for 
now.


https://reviews.llvm.org/D39718



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


[PATCH] D35295: [docs] Add section 'Half-Precision Floating Point'

2017-11-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317558: [docs] Add section 'Half-Precision Floating Point' 
(authored by SjoerdMeijer).

Changed prior to commit:
  https://reviews.llvm.org/D35295?vs=121265&id=121854#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35295

Files:
  cfe/trunk/docs/LanguageExtensions.rst


Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -436,6 +436,49 @@
 
 See also :ref:`langext-__builtin_shufflevector`, 
:ref:`langext-__builtin_convertvector`.
 
+Half-Precision Floating Point
+=
+
+Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
+``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
+`_)
+and ``_Float16`` in ISO/IEC TS 18661-3:2015.
+
+``__fp16`` is a storage and interchange format only. This means that values of
+``__fp16`` promote to (at least) float when used in arithmetic operations.
+There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
+not the ARM alternative format.
+
+ISO/IEC TS 18661-3:2015 defines C support for additional floating point types.
+``_FloatN`` is defined as a binary floating type, where the N suffix denotes
+the number of bits and is 16, 32, 64, or greater and equal to 128 and a
+multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` is
+that arithmetic on ``_Float16`` is performed in half-precision, thus it is not
+a storage-only format. ``_Float16`` is available as a source language type in
+both C and C++ mode.
+
+It is recommended that portable code use the ``_Float16`` type because
+``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
+defined by the C standards committee, so using ``_Float16`` will not prevent
+code from being ported to architectures other than Arm.  Also, ``_Float16``
+arithmetic and operations will directly map on half-precision instructions when
+they are available (e.g. Armv8.2-A), avoiding conversions to/from
+single-precision, and thus will result in more performant code. If
+half-precision instructions are unavailable, values will be promoted to
+single-precision, similar to the semantics of ``__fp16`` except that the
+results will be stored in single-precision.
+
+In an arithmetic operation where one operand is of ``__fp16`` type and the
+other is of ``_Float16`` type, the ``_Float16`` type is first converted to
+``__fp16`` type and then the operation is completed as if both operands were of
+``__fp16`` type.
+
+To define a ``_Float16`` literal, suffix ``f16`` can be appended to the 
compile-time
+constant declaration. There is no default argument promotion for ``_Float16``; 
this
+applies to the standard floating types only. As a consequence, for example, an
+explicit cast is required for printing a ``_Float16`` value (there is no string
+format specifier for ``_Float16``).
+
 Messages on ``deprecated`` and ``unavailable`` Attributes
 =
 


Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -436,6 +436,49 @@
 
 See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`.
 
+Half-Precision Floating Point
+=
+
+Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
+``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
+`_)
+and ``_Float16`` in ISO/IEC TS 18661-3:2015.
+
+``__fp16`` is a storage and interchange format only. This means that values of
+``__fp16`` promote to (at least) float when used in arithmetic operations.
+There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
+not the ARM alternative format.
+
+ISO/IEC TS 18661-3:2015 defines C support for additional floating point types.
+``_FloatN`` is defined as a binary floating type, where the N suffix denotes
+the number of bits and is 16, 32, 64, or greater and equal to 128 and a
+multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` is
+that arithmetic on ``_Float16`` is performed in half-precision, thus it is not
+a storage-only format. ``_Float16`` is available as a source language type in
+both C and C++ mode.
+
+It is recommended that portable code use the ``_Float16`` type because
+``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
+defined by the C standards committee, so using ``_Float16`` will not prevent
+code from being ported to architectures other than Arm.  Also, ``_Float16``
+

r317558 - [docs] Add section 'Half-Precision Floating Point'

2017-11-07 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Tue Nov  7 02:09:45 2017
New Revision: 317558

URL: http://llvm.org/viewvc/llvm-project?rev=317558&view=rev
Log:
[docs] Add section 'Half-Precision Floating Point'

This documents the differences/interactions between _Float16 and __fp16
and is a companion change for the _Float16 type implementation (r312794).

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

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=317558&r1=317557&r2=317558&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue Nov  7 02:09:45 2017
@@ -436,6 +436,49 @@ const_cast   no
 
 See also :ref:`langext-__builtin_shufflevector`, 
:ref:`langext-__builtin_convertvector`.
 
+Half-Precision Floating Point
+=
+
+Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
+``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
+`_)
+and ``_Float16`` in ISO/IEC TS 18661-3:2015.
+
+``__fp16`` is a storage and interchange format only. This means that values of
+``__fp16`` promote to (at least) float when used in arithmetic operations.
+There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
+not the ARM alternative format.
+
+ISO/IEC TS 18661-3:2015 defines C support for additional floating point types.
+``_FloatN`` is defined as a binary floating type, where the N suffix denotes
+the number of bits and is 16, 32, 64, or greater and equal to 128 and a
+multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` is
+that arithmetic on ``_Float16`` is performed in half-precision, thus it is not
+a storage-only format. ``_Float16`` is available as a source language type in
+both C and C++ mode.
+
+It is recommended that portable code use the ``_Float16`` type because
+``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
+defined by the C standards committee, so using ``_Float16`` will not prevent
+code from being ported to architectures other than Arm.  Also, ``_Float16``
+arithmetic and operations will directly map on half-precision instructions when
+they are available (e.g. Armv8.2-A), avoiding conversions to/from
+single-precision, and thus will result in more performant code. If
+half-precision instructions are unavailable, values will be promoted to
+single-precision, similar to the semantics of ``__fp16`` except that the
+results will be stored in single-precision.
+
+In an arithmetic operation where one operand is of ``__fp16`` type and the
+other is of ``_Float16`` type, the ``_Float16`` type is first converted to
+``__fp16`` type and then the operation is completed as if both operands were of
+``__fp16`` type.
+
+To define a ``_Float16`` literal, suffix ``f16`` can be appended to the 
compile-time
+constant declaration. There is no default argument promotion for ``_Float16``; 
this
+applies to the standard floating types only. As a consequence, for example, an
+explicit cast is required for printing a ``_Float16`` value (there is no string
+format specifier for ``_Float16``).
+
 Messages on ``deprecated`` and ``unavailable`` Attributes
 =
 


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


[PATCH] D39682: [analyzer] Fix a crash on logical operators with vectors.

2017-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 121856.
NoQ added a comment.

A better name for the test function.


https://reviews.llvm.org/D39682

Files:
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Analysis/vector.c


Index: test/Analysis/vector.c
===
--- /dev/null
+++ test/Analysis/vector.c
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
+
+typedef int __attribute__((ext_vector_type(2))) V;
+
+void clang_analyzer_numTimesReached();
+void clang_analyzer_eval(int);
+
+int flag;
+
+V pass_through_and_set_flag(V v) {
+  flag = 1;
+  return v;
+}
+
+V dont_crash_and_dont_split_state(V x, V y) {
+  flag = 0;
+  V z = x && pass_through_and_set_flag(y);
+  clang_analyzer_eval(flag); // expected-warning{{TRUE}}
+  // FIXME: For now we treat vector operator && as short-circuit,
+  // but in fact it is not. It should always evaluate
+  // pass_through_and_set_flag(). It should not split state.
+  // Now we also get FALSE on the other path.
+  // expected-warning@-5{{FALSE}}
+
+  // FIXME: Should be 1 since we should not split state.
+  clang_analyzer_numTimesReached(); // expected-warning{{2}}
+  return z;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -628,6 +628,16 @@
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
   ProgramStateRef state = Pred->getState();
 
+  if (B->getType()->isVectorType()) {
+// FIXME: We do not model vector arithmetic yet. When adding support for
+// that, note that the CFG-based reasoning below does not apply, because
+// logical operators on vectors are not short-circuit. Currently they are
+// modeled as short-circuit in Clang CFG but this is incorrect.
+// Do not set the value for the expression. It'd be UnknownVal by default.
+Bldr.generateNode(B, Pred, state);
+return;
+  }
+
   ExplodedNode *N = Pred;
   while (!N->getLocation().getAs()) {
 ProgramPoint P = N->getLocation();


Index: test/Analysis/vector.c
===
--- /dev/null
+++ test/Analysis/vector.c
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+typedef int __attribute__((ext_vector_type(2))) V;
+
+void clang_analyzer_numTimesReached();
+void clang_analyzer_eval(int);
+
+int flag;
+
+V pass_through_and_set_flag(V v) {
+  flag = 1;
+  return v;
+}
+
+V dont_crash_and_dont_split_state(V x, V y) {
+  flag = 0;
+  V z = x && pass_through_and_set_flag(y);
+  clang_analyzer_eval(flag); // expected-warning{{TRUE}}
+  // FIXME: For now we treat vector operator && as short-circuit,
+  // but in fact it is not. It should always evaluate
+  // pass_through_and_set_flag(). It should not split state.
+  // Now we also get FALSE on the other path.
+  // expected-warning@-5{{FALSE}}
+
+  // FIXME: Should be 1 since we should not split state.
+  clang_analyzer_numTimesReached(); // expected-warning{{2}}
+  return z;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -628,6 +628,16 @@
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
   ProgramStateRef state = Pred->getState();
 
+  if (B->getType()->isVectorType()) {
+// FIXME: We do not model vector arithmetic yet. When adding support for
+// that, note that the CFG-based reasoning below does not apply, because
+// logical operators on vectors are not short-circuit. Currently they are
+// modeled as short-circuit in Clang CFG but this is incorrect.
+// Do not set the value for the expression. It'd be UnknownVal by default.
+Bldr.generateNode(B, Pred, state);
+return;
+  }
+
   ExplodedNode *N = Pred;
   while (!N->getLocation().getAs()) {
 ProgramPoint P = N->getLocation();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39718: [clangd] Add ErrorCodes enum class.

2017-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 121858.
hokein added a comment.

Address review comments:

- ErrorCodes => ErrorCode
- Remove serverErrorStart/serverErrorEnd


https://reviews.llvm.org/D39718

Files:
  clangd/ClangdLSPServer.cpp
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -32,6 +32,21 @@
 
 class Logger;
 
+enum class ErrorCode {
+  // Defined by JSON RPC.
+  ParseError = -32700,
+  InvalidRequest = -32600,
+  MethodNotFound = -32601,
+  InvalidParams = -32602,
+  InternalError = -32603,
+
+  ServerNotInitialized = -32002,
+  UnknownErrorCode = -32001,
+
+  // Defined by the protocol.
+  RequestCancelled = -32800,
+};
+
 struct URI {
   std::string uri;
   std::string file;
Index: clangd/JSONRPCDispatcher.h
===
--- clangd/JSONRPCDispatcher.h
+++ clangd/JSONRPCDispatcher.h
@@ -12,6 +12,7 @@
 
 #include "JSONExpr.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
@@ -60,7 +61,7 @@
   /// Sends a successful reply.
   void reply(json::Expr &&Result);
   /// Sends an error response to the client, and logs it.
-  void replyError(int code, const llvm::StringRef &Message);
+  void replyError(ErrorCode code, const llvm::StringRef &Message);
   /// Sends a request to the client.
   void call(llvm::StringRef Method, json::Expr &&Params);
 
Index: clangd/JSONRPCDispatcher.cpp
===
--- clangd/JSONRPCDispatcher.cpp
+++ clangd/JSONRPCDispatcher.cpp
@@ -65,13 +65,13 @@
   });
 }
 
-void RequestContext::replyError(int code, const llvm::StringRef &Message) {
-  Out.log("Error " + llvm::Twine(code) + ": " + Message + "\n");
+void RequestContext::replyError(ErrorCode code, const llvm::StringRef &Message) {
+  Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", code}, {"message", Message}}},
+{"error", json::obj{{"code", static_cast(code)}, {"message", Message}}},
 });
   }
 }
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -85,7 +85,8 @@
 void ClangdLSPServer::onDocumentDidChange(Ctx C,
   DidChangeTextDocumentParams &Params) {
   if (Params.contentChanges.size() != 1)
-return C.replyError(-32602, "can only apply one change at a time");
+return C.replyError(ErrorCode::InvalidParams,
+"can only apply one change at a time");
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file,
  Params.contentChanges[0].text);
@@ -119,7 +120,8 @@
 // parsed in the first place and this handler should not be called. But if
 // more commands are added, this will be here has a safe guard.
 C.replyError(
-1, llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
+ErrorCode::InvalidParams,
+llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
   }
 }
 
@@ -191,7 +193,8 @@
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!SignatureHelp)
-return C.replyError(-32602, llvm::toString(SignatureHelp.takeError()));
+return C.replyError(ErrorCode::InvalidParams,
+llvm::toString(SignatureHelp.takeError()));
   C.reply(SignatureHelp->Value);
 }
 
@@ -201,7 +204,8 @@
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!Items)
-return C.replyError(-32602, llvm::toString(Items.takeError()));
+return C.replyError(ErrorCode::InvalidParams,
+llvm::toString(Items.takeError()));
   C.reply(json::ary(Items->Value));
 }
 
@@ -228,7 +232,7 @@
   // Set up JSONRPCDispatcher.
   JSONRPCDispatcher Dispatcher(
   [](RequestContext Ctx, llvm::yaml::MappingNode *Params) {
-Ctx.replyError(-32601, "method not found");
+Ctx.replyError(ErrorCode::MethodNotFound, "method not found");
   });
   registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39722: [ASTImporter] Support Import TypeTraitExpr

2017-11-07 Thread Takafumi Kubota via Phabricator via cfe-commits
tk1012 created this revision.
Herald added a subscriber: klimek.

This fixes unsupporting of importing TypeTraitExpr in ASTImporter.
TypeTraitExpr is caused by "__builtin_types_compatible_p()" that is usually 
used in the assertion in C code.
For example, PostgreSQL uses the builtin function in its assertion, and 
ASTImporter currently fails to import the assertion because of 
diag::err_unsupported_ast_node.


https://reviews.llvm.org/D39722

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -485,6 +485,16 @@
has(atomicType()));
 }
 
+TEST(ImportExpr, ImportTypeTraitExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("void declToImport() { 
__builtin_types_compatible_p(int, int); }",
+ Lang_C, "", Lang_C, Verifier,
+ functionDecl(
+   hasBody(
+ compoundStmt(
+   has(
+ typeTraitExpr()));
+}
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -280,6 +280,7 @@
 Expr *VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E);
 Expr *VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
 Expr *VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E);
+Expr *VisitTypeTraitExpr(TypeTraitExpr *E);
 
 
 template
@@ -5529,6 +5530,27 @@
 Replacement);
 }
 
+Expr *ASTNodeImporter::VisitTypeTraitExpr(TypeTraitExpr *E) {
+  QualType ToType = Importer.Import(E->getType());
+  if (ToType.isNull())
+return nullptr;
+
+  SmallVector ToArgVec;
+  for(auto FromArg : E->getArgs()) {
+TypeSourceInfo *ToTI = Importer.Import(FromArg);
+ToArgVec.push_back(ToTI);
+  }
+  ArrayRef ToArgRef(ToArgVec);
+
+  return TypeTraitExpr::Create( Importer.getToContext(),
+ ToType,
+ Importer.Import(E->getLocStart()),
+ E->getTrait(),
+ ToArgRef,
+ Importer.Import(E->getLocEnd()),
+ E->getValue());
+}
+
 void ASTNodeImporter::ImportOverrides(CXXMethodDecl *ToMethod,
   CXXMethodDecl *FromMethod) {
   for (auto *FromOverriddenMethod : FromMethod->overridden_methods())
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2239,6 +2239,17 @@
 2, std::numeric_limits::max()>
 allOf = {internal::DynTypedMatcher::VO_AllOf};
 
+/// \brief Matches __builtin_types_compatible_p:
+/// GNU extension to check equivalent types
+/// Given
+/// \code
+///   __builtin_types_compatible_p(int, int)
+/// \endcode
+//  will generate TypeTraitExpr <...> 'int'
+const internal::VariadicDynCastAllOfMatcher<
+  Stmt,
+  TypeTraitExpr> typeTraitExpr;
+
 /// \brief Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
 ///
 /// Given


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -485,6 +485,16 @@
has(atomicType()));
 }
 
+TEST(ImportExpr, ImportTypeTraitExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("void declToImport() { __builtin_types_compatible_p(int, int); }",
+ Lang_C, "", Lang_C, Verifier,
+ functionDecl(
+   hasBody(
+ compoundStmt(
+   has(
+ typeTraitExpr()));
+}
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -280,6 +280,7 @@
 Expr *VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E);
 Expr *VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
 Expr *VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E);
+Expr *VisitTypeTraitExpr(TypeTraitExpr *E);
 
 
 template
@@ -5529,6 +5530,27 @@
 Replacement);
 }
 
+Expr *ASTNodeImporter::VisitTypeTraitExpr(TypeTraitExpr *E) {
+  QualType ToType = Importer.Import(E->getType());
+  if (ToType.isNull())
+return nullptr;
+
+  SmallVector ToArgVec;
+  for(auto FromArg : E->getArgs()) {
+TypeSourceInfo *ToTI = Importer.Import(FromArg);
+ToArgVec.push_back(ToTI);

[PATCH] D39478: [clang-format] Handle leading comments in using declaration

2017-11-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.

Looks good. Do you have submit access?


https://reviews.llvm.org/D39478



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


[PATCH] D39718: [clangd] Add ErrorCodes enum class.

2017-11-07 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317559: [clangd] Add ErrorCode enum class. (authored by 
hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D39718

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
  clang-tools-extra/trunk/clangd/Protocol.h

Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -85,7 +85,8 @@
 void ClangdLSPServer::onDocumentDidChange(Ctx C,
   DidChangeTextDocumentParams &Params) {
   if (Params.contentChanges.size() != 1)
-return C.replyError(-32602, "can only apply one change at a time");
+return C.replyError(ErrorCode::InvalidParams,
+"can only apply one change at a time");
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file,
  Params.contentChanges[0].text);
@@ -119,7 +120,8 @@
 // parsed in the first place and this handler should not be called. But if
 // more commands are added, this will be here has a safe guard.
 C.replyError(
-1, llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
+ErrorCode::InvalidParams,
+llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
   }
 }
 
@@ -191,7 +193,8 @@
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!SignatureHelp)
-return C.replyError(-32602, llvm::toString(SignatureHelp.takeError()));
+return C.replyError(ErrorCode::InvalidParams,
+llvm::toString(SignatureHelp.takeError()));
   C.reply(SignatureHelp->Value);
 }
 
@@ -201,7 +204,8 @@
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!Items)
-return C.replyError(-32602, llvm::toString(Items.takeError()));
+return C.replyError(ErrorCode::InvalidParams,
+llvm::toString(Items.takeError()));
   C.reply(json::ary(Items->Value));
 }
 
@@ -228,7 +232,7 @@
   // Set up JSONRPCDispatcher.
   JSONRPCDispatcher Dispatcher(
   [](RequestContext Ctx, llvm::yaml::MappingNode *Params) {
-Ctx.replyError(-32601, "method not found");
+Ctx.replyError(ErrorCode::MethodNotFound, "method not found");
   });
   registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
 
Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
===
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
@@ -12,6 +12,7 @@
 
 #include "JSONExpr.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
@@ -60,7 +61,7 @@
   /// Sends a successful reply.
   void reply(json::Expr &&Result);
   /// Sends an error response to the client, and logs it.
-  void replyError(int code, const llvm::StringRef &Message);
+  void replyError(ErrorCode code, const llvm::StringRef &Message);
   /// Sends a request to the client.
   void call(llvm::StringRef Method, json::Expr &&Params);
 
Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
===
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
@@ -65,13 +65,13 @@
   });
 }
 
-void RequestContext::replyError(int code, const llvm::StringRef &Message) {
-  Out.log("Error " + llvm::Twine(code) + ": " + Message + "\n");
+void RequestContext::replyError(ErrorCode code, const llvm::StringRef &Message) {
+  Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", code}, {"message", Message}}},
+{"error", json::obj{{"code", static_cast(code)}, {"message", Message}}},
 });
   }
 }
Index: clang-tools-extra/trunk/clangd/Protocol.h
===
--- clang-tools-extra/trunk/clangd/Protocol.h
+++ clang-tools-extra/trunk/clangd/Protocol.h
@@ -32,6 +32,21 @@
 
 class Logger;
 
+enum class ErrorCode {
+  // Defined by JSON RPC.
+  ParseError = -32700,
+  InvalidRequest = -32600,
+  MethodNotFound = -32601,
+  InvalidParams = -32602,
+  InternalError = -32603,
+
+  ServerNotInitialized = -32002,
+  UnknownErrorCode = -32001,
+
+  // Defined by the protocol.
+  RequestCancelled = -32800,
+};
+
 struct URI {
   std::string uri;
   std::string file;
___
cf

[clang-tools-extra] r317559 - [clangd] Add ErrorCode enum class.

2017-11-07 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Nov  7 02:21:02 2017
New Revision: 317559

URL: http://llvm.org/viewvc/llvm-project?rev=317559&view=rev
Log:
[clangd] Add ErrorCode enum class.

Summary: Avoid using magic number in the code everywhere.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=317559&r1=317558&r2=317559&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Nov  7 02:21:02 2017
@@ -85,7 +85,8 @@ void ClangdLSPServer::onDocumentDidOpen(
 void ClangdLSPServer::onDocumentDidChange(Ctx C,
   DidChangeTextDocumentParams &Params) 
{
   if (Params.contentChanges.size() != 1)
-return C.replyError(-32602, "can only apply one change at a time");
+return C.replyError(ErrorCode::InvalidParams,
+"can only apply one change at a time");
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file,
  Params.contentChanges[0].text);
@@ -119,7 +120,8 @@ void ClangdLSPServer::onCommand(Ctx C, E
 // parsed in the first place and this handler should not be called. But if
 // more commands are added, this will be here has a safe guard.
 C.replyError(
-1, llvm::formatv("Unsupported command \"{0}\".", 
Params.command).str());
+ErrorCode::InvalidParams,
+llvm::formatv("Unsupported command \"{0}\".", Params.command).str());
   }
 }
 
@@ -191,7 +193,8 @@ void ClangdLSPServer::onSignatureHelp(Ct
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!SignatureHelp)
-return C.replyError(-32602, llvm::toString(SignatureHelp.takeError()));
+return C.replyError(ErrorCode::InvalidParams,
+llvm::toString(SignatureHelp.takeError()));
   C.reply(SignatureHelp->Value);
 }
 
@@ -201,7 +204,8 @@ void ClangdLSPServer::onGoToDefinition(C
   Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character});
   if (!Items)
-return C.replyError(-32602, llvm::toString(Items.takeError()));
+return C.replyError(ErrorCode::InvalidParams,
+llvm::toString(Items.takeError()));
   C.reply(json::ary(Items->Value));
 }
 
@@ -228,7 +232,7 @@ bool ClangdLSPServer::run(std::istream &
   // Set up JSONRPCDispatcher.
   JSONRPCDispatcher Dispatcher(
   [](RequestContext Ctx, llvm::yaml::MappingNode *Params) {
-Ctx.replyError(-32601, "method not found");
+Ctx.replyError(ErrorCode::MethodNotFound, "method not found");
   });
   registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
 

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=317559&r1=317558&r2=317559&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Tue Nov  7 02:21:02 
2017
@@ -65,13 +65,13 @@ void RequestContext::reply(json::Expr &&
   });
 }
 
-void RequestContext::replyError(int code, const llvm::StringRef &Message) {
-  Out.log("Error " + llvm::Twine(code) + ": " + Message + "\n");
+void RequestContext::replyError(ErrorCode code, const llvm::StringRef 
&Message) {
+  Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", code}, {"message", Message}}},
+{"error", json::obj{{"code", static_cast(code)}, {"message", 
Message}}},
 });
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=317559&r1=317558&r2=317559&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Tue Nov  7 02:21:02 2017
@@ -12,6 +12,7 @@
 
 #include "JSONExpr.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
@@ -60,7 +61,7 @@ public:
   /// Sends a successful reply.
   void reply(

[PATCH] D39422: [analyzer] pr34779: CStringChecker: Don't get crashed by non-standard standard library function definitions.

2017-11-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317565: [analyzer] pr34779: CStringChecker: Accept 
non-standard headers. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D39422?vs=120834&id=121866#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39422

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/test/Analysis/string-with-signedness.c


Index: cfe/trunk/test/Analysis/string-with-signedness.c
===
--- cfe/trunk/test/Analysis/string-with-signedness.c
+++ cfe/trunk/test/Analysis/string-with-signedness.c
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -Wno-incompatible-library-redeclaration 
-analyzer-checker=core,unix.cstring,alpha.unix.cstring -verify %s
+
+// expected-no-diagnostics
+
+void *strcpy(unsigned char *, unsigned char *);
+
+unsigned char a, b;
+void testUnsignedStrcpy() {
+  strcpy(&a, &b);
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -289,8 +289,8 @@
   if (!ER)
 return state;
 
-  assert(ER->getValueType() == C.getASTContext().CharTy &&
-"CheckLocation should only be called with char* ElementRegions");
+  if (ER->getValueType() != C.getASTContext().CharTy)
+return state;
 
   // Get the size of the array.
   const SubRegion *superReg = cast(ER->getSuperRegion());
@@ -874,6 +874,8 @@
   if (!ER)
 return true; // cf top comment.
 
+  // FIXME: Does this crash when a non-standard definition
+  // of a library function is encountered?
   assert(ER->getValueType() == C.getASTContext().CharTy &&
  "IsFirstBufInBound should only be called with char* ElementRegions");
 


Index: cfe/trunk/test/Analysis/string-with-signedness.c
===
--- cfe/trunk/test/Analysis/string-with-signedness.c
+++ cfe/trunk/test/Analysis/string-with-signedness.c
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -Wno-incompatible-library-redeclaration -analyzer-checker=core,unix.cstring,alpha.unix.cstring -verify %s
+
+// expected-no-diagnostics
+
+void *strcpy(unsigned char *, unsigned char *);
+
+unsigned char a, b;
+void testUnsignedStrcpy() {
+  strcpy(&a, &b);
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -289,8 +289,8 @@
   if (!ER)
 return state;
 
-  assert(ER->getValueType() == C.getASTContext().CharTy &&
-"CheckLocation should only be called with char* ElementRegions");
+  if (ER->getValueType() != C.getASTContext().CharTy)
+return state;
 
   // Get the size of the array.
   const SubRegion *superReg = cast(ER->getSuperRegion());
@@ -874,6 +874,8 @@
   if (!ER)
 return true; // cf top comment.
 
+  // FIXME: Does this crash when a non-standard definition
+  // of a library function is encountered?
   assert(ER->getValueType() == C.getASTContext().CharTy &&
  "IsFirstBufInBound should only be called with char* ElementRegions");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317565 - [analyzer] pr34779: CStringChecker: Accept non-standard headers.

2017-11-07 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Nov  7 02:51:15 2017
New Revision: 317565

URL: http://llvm.org/viewvc/llvm-project?rev=317565&view=rev
Log:
[analyzer] pr34779: CStringChecker: Accept non-standard headers.

Do not crash when trying to define and call a non-standard
strcpy(unsigned char *, unsigned char *) during analysis.

At the same time, do not try to actually evaluate the call.

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

Added:
cfe/trunk/test/Analysis/string-with-signedness.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=317565&r1=317564&r2=317565&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Tue Nov  7 
02:51:15 2017
@@ -289,8 +289,8 @@ ProgramStateRef CStringChecker::CheckLoc
   if (!ER)
 return state;
 
-  assert(ER->getValueType() == C.getASTContext().CharTy &&
-"CheckLocation should only be called with char* ElementRegions");
+  if (ER->getValueType() != C.getASTContext().CharTy)
+return state;
 
   // Get the size of the array.
   const SubRegion *superReg = cast(ER->getSuperRegion());
@@ -874,6 +874,8 @@ bool CStringChecker::IsFirstBufInBound(C
   if (!ER)
 return true; // cf top comment.
 
+  // FIXME: Does this crash when a non-standard definition
+  // of a library function is encountered?
   assert(ER->getValueType() == C.getASTContext().CharTy &&
  "IsFirstBufInBound should only be called with char* ElementRegions");
 

Added: cfe/trunk/test/Analysis/string-with-signedness.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/string-with-signedness.c?rev=317565&view=auto
==
--- cfe/trunk/test/Analysis/string-with-signedness.c (added)
+++ cfe/trunk/test/Analysis/string-with-signedness.c Tue Nov  7 02:51:15 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -Wno-incompatible-library-redeclaration 
-analyzer-checker=core,unix.cstring,alpha.unix.cstring -verify %s
+
+// expected-no-diagnostics
+
+void *strcpy(unsigned char *, unsigned char *);
+
+unsigned char a, b;
+void testUnsignedStrcpy() {
+  strcpy(&a, &b);
+}


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


[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location

2017-11-07 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic added a comment.

ping


https://reviews.llvm.org/D39053



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


[PATCH] D39707: [analyzer] assume bitwise arithmetic axioms

2017-11-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

This looks like a great addition! Apart from some nits, LGTM.




Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:487
+
+// result >= constant
+return Result.Intersect(BV, F, SIE->getRHS(), BV.getMaxValue(T));

Comments should be sentences (start with capital letter and have a period).



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:498
+  return Result;
+
+}

This new line is redundant. Also, there are way more new lines in this method 
than there usually are in LLVM.


https://reviews.llvm.org/D39707



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


[PATCH] D39711: [analyzer] ObjCGenerics: Don't warn on cast conversions involving explicit cast

2017-11-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D39711#917433, @dcoughlin wrote:

> @xazax.hun Would you be willing to take a look?


Sure, I basically agree with George.




Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:587
   if (TrackedType &&
+  !isa(CE) &&
   !ASTCtxt.canAssignObjCInterfaces(DestObjectPtrType, *TrackedType) &&

george.karpenkov wrote:
> Should it check that we are actually casting to the right type? Also it's a 
> bit strange that isa<> check on line 569 did not catch this case, maybe that 
> if- branch should be generalized instead?
I agree, line 569 supposed to handle this case and also update the state 
accordingly.


https://reviews.llvm.org/D39711



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


[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-11-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: lib/Headers/avx512bwintrin.h:2045
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __B  & 0x) | ((__mmask64) __A << 32));
 }

Is this right? The Intel docs says it should be:
```
k[31:0] := a[31:0]
k[63:32] := b[31:0]
k[MAX:64] := 0
```

Also, is the cast on __A necessary?

Same for the others.


https://reviews.llvm.org/D39719



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


[clang-tools-extra] r317570 - [clang-tidy] Misc redundant expressions checker updated for macros

2017-11-07 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Nov  7 05:17:58 2017
New Revision: 317570

URL: http://llvm.org/viewvc/llvm-project?rev=317570&view=rev
Log:
[clang-tidy] Misc redundant expressions checker updated for macros

Redundant Expression Checker is updated to be able to detect expressions that
contain macros. Also, other small details are modified to improve the current
implementation.

The improvements in detail are as follows:
* Binary and ternary operator expressions containing two constants, with at
least one of them from a macro, are detected and tested for redundancy.

Macro expressions are treated somewhat differently from other expressions,
because the particular values of macros can vary across builds.
They can be considered correct and intentional, even if macro values equal,
produce ranges that exclude each other or fully overlap, etc. 

* The code structure is slightly modified: typos are corrected,
comments are added and some functions are renamed to improve comprehensibility,
both in the checker and the test file. A few test cases are moved to another
function.

* The checker is now able to detect redundant CXXFunctionalCastExprs as well.
A corresponding test case is added.

Patch by: Lilla Barancsuk!

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-redundant-expression.rst
clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=317570&r1=317569&r2=317570&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Tue 
Nov  7 05:17:58 2017
@@ -23,7 +23,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -38,8 +37,8 @@ namespace {
 using llvm::APSInt;
 } // namespace
 
-static const char KnownBannedMacroNames[] =
-"EAGAIN;EWOULDBLOCK;SIGCLD;SIGCHLD;";
+static const llvm::StringSet<> KnownBannedMacroNames = {"EAGAIN", 
"EWOULDBLOCK",
+"SIGCLD", "SIGCHLD"};
 
 static bool incrementWithoutOverflow(const APSInt &Value, APSInt &Result) {
   Result = Value;
@@ -99,7 +98,6 @@ static bool areEquivalentExpr(const Expr
   case Stmt::StringLiteralClass:
 return cast(Left)->getBytes() ==
cast(Right)->getBytes();
-
   case Stmt::DependentScopeDeclRefExprClass:
 if (cast(Left)->getDeclName() !=
 cast(Right)->getDeclName())
@@ -113,16 +111,14 @@ static bool areEquivalentExpr(const Expr
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
-
+  case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
-return cast(Left)->getTypeAsWritten() ==
-   cast(Right)->getTypeAsWritten();
-
+return cast(Left)->getTypeAsWritten() ==
+   cast(Right)->getTypeAsWritten();
   case Stmt::CallExprClass:
   case Stmt::ImplicitCastExprClass:
   case Stmt::ArraySubscriptExprClass:
 return true;
-
   case Stmt::UnaryOperatorClass:
 if (cast(Left)->isIncrementDecrementOp())
   return false;
@@ -282,7 +278,8 @@ static bool rangeSubsumesRange(BinaryOpe
   }
 }
 
-static void canonicalNegateExpr(BinaryOperatorKind &Opcode, APSInt &Value) {
+static void transformSubToCanonicalAddExpr(BinaryOperatorKind &Opcode,
+   APSInt &Value) {
   if (Opcode == BO_Sub) {
 Opcode = BO_Add;
 Value = -Value;
@@ -295,32 +292,77 @@ AST_MATCHER(Expr, isIntegerConstantExpr)
   return Node.isIntegerConstantExpr(Finder->getASTContext());
 }
 
-// Returns a matcher for integer constant expression.
+AST_MATCHER(BinaryOperator, operandsAreEquivalent) {
+  return areEquivalentExpr(Node.getLHS(), Node.getRHS());
+}
+
+AST_MATCHER(ConditionalOperator, expressionsAreEquivalent) {
+  return areEquivalentExpr(Node.getTrueExpr(), Node.getFalseExpr());
+}
+
+AST_MATCHER(CallExpr, parametersAreEquivalent) {
+  return Node.getNumArgs() == 2 &&
+ areEquivalentExpr(Node.getArg(0), Node.getArg(1));
+}
+
+AST_MATCHER(BinaryOperator, binaryOperatorIsInMacro) {
+  return Node.getOperatorLoc().isMacroID();
+}
+
+AST_MATCHER(ConditionalOperator, conditionalOperatorIsInMacro) {
+  return Node.getQuestionLoc().isMacroID() || Node.getColonLoc().isMacroID();
+}
+
+AST_MATCHER(Expr, isMacro) { return Node.getExprLoc().isMacroID(); }
+
+AST_MATCHER_P(Expr, expandedByMacro, llvm::StringSet<>, Names) {
+  const SourceManager &SM = Finder->getASTContext().getSourceManager();
+  const LangOptions &LO = Finder->getASTCon

[PATCH] D38688: [clang-tidy] Misc redundant expressions checker updated for macros

2017-11-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317570: [clang-tidy] Misc redundant expressions checker 
updated for macros (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D38688?vs=121740&id=121875#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38688

Files:
  clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-redundant-expression.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
@@ -15,69 +15,71 @@
 extern int bar(int x);
 extern int bat(int x, int y);
 
-int Test(int X, int Y) {
+int TestSimpleEquivalent(int X, int Y) {
   if (X - X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent [misc-redundant-expression]
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent [misc-redundant-expression]
   if (X / X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X % X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X & X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X | X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X ^ X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X < X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X <= X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X > X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X >= X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X && X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X || X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X != (((X return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X + 1 == X + 1) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
   if (X + 1 != X + 1) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
   if (X + 1 <= X + 1) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
   if (X + 1 >= X + 1) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
 
   if ((X != 1 || Y != 1) && (X != 1 || Y != 1)) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both sides of operator are equivalent
   if (P.a[X - P.x] != P.a[X - P.x]) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: both sides of operator are equivalent
 
   if ((int)X < (int)X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warn

[PATCH] D39537: Rename identifiers named `__output`

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



Comment at: test/support/nasty_macros.hpp:55
 
+#define __output NASTY_MACRO
+#define __input NASTY_MACRO

EricWF wrote:
> Shouldn't these not be defined when running the tests with a CHER compiler? 
> Otherwise the macro will conflict with the keyword?
It isn't being used anywhere in libcxx so that should be fine. The tests are 
still working for me since it doesn't seem like we are compiling with 
`-Werror=reserved-id-macro`.


Repository:
  rL LLVM

https://reviews.llvm.org/D39537



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


[PATCH] D39730: Enabling constructor code completion

2017-11-07 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.
Herald added a subscriber: eraman.

It seems like constructor code completion was intentionally disabled ages ago 
in this commit (and refactored later):

commit 33224e61bfca370850abae89bbd415a4dabe07fa
Author: Douglas Gregor 
Date:   Fri Sep 18 17:42:29 2009 +

  For code completion in C++ member access expressions and tag names,
  look into the current scope for anything that could start a
  nested-names-specifier. These results are ranked worse than any of the
  results actually found in the lexical scope.
  
  Perform a little more pruning of the result set, eliminating
  constructors, __va_list_tag, and any duplication of declarations in
  the result set. For the latter, implemented
  NamespaceDecl::getCanonicalDecl.

I am not sure if there is actually anything relying on the fact that 
constructors are not included in code completion results. The only test that 
seems affected is probably not really concerned about these.

rdar://problem/19190970


https://reviews.llvm.org/D39730

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-cxx-inline-methods.cpp


Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -26,6 +26,8 @@
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
 // CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText 
operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
+// CHECK-NEXT: CXXConstructor:{TypedText Vec}{LeftParen (}{RightParen )} (34)
+// CHECK-NEXT: CXXConstructor:{TypedText Vec}{LeftParen (}{Placeholder const 
MyCls::Vec &}{RightParen )} (34)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -975,10 +975,6 @@
   bool AsNestedNameSpecifier = false;
   if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
 return;
-  
-  // C++ constructors are never found by name lookup.
-  if (isa(R.Declaration))
-return;
 
   if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
 return;


Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -26,6 +26,8 @@
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
 // CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
+// CHECK-NEXT: CXXConstructor:{TypedText Vec}{LeftParen (}{RightParen )} (34)
+// CHECK-NEXT: CXXConstructor:{TypedText Vec}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -975,10 +975,6 @@
   bool AsNestedNameSpecifier = false;
   if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
 return;
-  
-  // C++ constructors are never found by name lookup.
-  if (isa(R.Declaration))
-return;
 
   if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-11-07 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

Should we keep just the version with the custom printing policy then?


https://reviews.llvm.org/D36610



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


[PATCH] D39707: [analyzer] assume bitwise arithmetic axioms

2017-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Yep, nice and clean~




Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:520
 
+  Result = applyBitwiseConstraints(BV, F, T, Result, Sym);
   return Result;

That's more and more "special case"s, i guess we'd have to make them legal. The 
`getRange()` function is not only a simple wrapper around `State->get<>()`, but 
it is also the single source of truth regarding constraints that can be assumed 
about the values by simply looking at the values, without exploring the program 
state. I think this should be reflected in the comments.



Comment at: test/Analysis/constant-folding.c:92
+  clang_analyzer_eval((b | 1) > 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval((b | 1) == 0); // expected-warning{{UNKNOWN}}
+

Can we still assume that `b | 1` is non-zero? Maybe FIXME here?


https://reviews.llvm.org/D39707



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


[clang-tools-extra] r317575 - [clangd] another try at fixing MSVC

2017-11-07 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Nov  7 06:14:58 2017
New Revision: 317575

URL: http://llvm.org/viewvc/llvm-project?rev=317575&view=rev
Log:
[clangd] another try at fixing MSVC

Modified:
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp?rev=317575&r1=317574&r2=317575&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp Tue Nov  7 
06:14:58 2017
@@ -68,7 +68,7 @@ TEST(JSONExprTests, Escaping) {
   '\xce', '\x94',   // Non-ASCII UTF-8 is not escaped.
   };
   EXPECT_EQ(R"("\u\u0008\u000c\r\n\tS\"\\)"
-u8"\x7fΔ\"",
+u8"\x7f\xce\x94\"",
 s(test));
 
   EXPECT_EQ(R"({"object keys are\nescaped":true})",


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


[PATCH] D39675: [clang-refactor] Use ClangTool more explicitly by making refaroing actions AST frontend actions.

2017-11-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 121883.
ioeric added a comment.

- Fix typos.


https://reviews.llvm.org/D39675

Files:
  tools/clang-refactor/ClangRefactor.cpp

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -25,6 +25,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -256,9 +257,9 @@
   RefactoringActionRules ActionRules,
   cl::OptionCategory &Category)
   : SubCommand(Action->getCommand(), Action->getDescription()),
-Action(std::move(Action)), ActionRules(std::move(ActionRules)) {
+Action(std::move(Action)), ActionRules(std::move(ActionRules)),
+HasSelection(false) {
 // Check if the selection option is supported.
-bool HasSelection = false;
 for (const auto &Rule : this->ActionRules) {
   if ((HasSelection = Rule->hasSelectionRequirement()))
 break;
@@ -295,6 +296,9 @@
 return false;
   }
 
+  // Whether the selection is supported by any rule in the subcommand.
+  bool hasSelection() const { return HasSelection; }
+
   SourceSelectionArgument *getSelection() const {
 assert(Selection && "selection not supported!");
 return ParsedSelection.get();
@@ -310,11 +314,13 @@
   std::unique_ptr> Selection;
   std::unique_ptr ParsedSelection;
   RefactoringActionCommandLineOptions Options;
+  // Whether the selection is supported by any rule in the subcommand.
+  bool HasSelection;
 };
 
 class ClangRefactorConsumer final : public ClangRefactorToolConsumerInterface {
 public:
-  ClangRefactorConsumer() {}
+  ClangRefactorConsumer(AtomicChanges &Changes) : SourceChanges(&Changes) {}
 
   void handleError(llvm::Error Err) override {
 Optional Diag = DiagnosticError::take(Err);
@@ -329,24 +335,23 @@
   }
 
   void handle(AtomicChanges Changes) override {
-SourceChanges.insert(SourceChanges.begin(), Changes.begin(), Changes.end());
+SourceChanges->insert(SourceChanges->begin(), Changes.begin(),
+  Changes.end());
   }
 
   void handle(SymbolOccurrences Occurrences) override {
 llvm_unreachable("symbol occurrence results are not handled yet");
   }
 
-  const AtomicChanges &getSourceChanges() const { return SourceChanges; }
-
 private:
-  AtomicChanges SourceChanges;
+  AtomicChanges *SourceChanges;
 };
 
 class ClangRefactorTool {
 public:
-  std::vector> SubCommands;
-
-  ClangRefactorTool() {
+  ClangRefactorTool()
+  : SelectedSubcommand(nullptr), MatchingRule(nullptr),
+Consumer(new ClangRefactorConsumer(Changes)), HasFailed(false) {
 std::vector> Actions =
 createRefactoringActions();
 
@@ -369,59 +374,110 @@
 }
   }
 
-  using TUCallbackType = llvm::function_ref;
+  // Initializes the selected subcommand and refactoring rule based on the
+  // command line options.
+  llvm::Error Init() {
+auto Subcommand = getSelectedSubcommand();
+if (!Subcommand)
+  return Subcommand.takeError();
+auto Rule = getMatchingRule(**Subcommand);
+if (!Rule)
+  return Rule.takeError();
+
+SelectedSubcommand = *Subcommand;
+MatchingRule = *Rule;
+
+return llvm::Error::success();
+  }
+
+  bool hasFailed() const { return HasFailed; }
+
+  using TUCallbackType = std::function;
+
+  // Callback of an AST action. This invokes the matching rule on the given AST.
+  void callback(ASTContext &AST) {
+assert(SelectedSubcommand && MatchingRule && Consumer);
+RefactoringRuleContext Context(AST.getSourceManager());
+Context.setASTContext(AST);
+
+// If the selection option is test specific, we use a test-specific
+// consumer.
+std::unique_ptr TestConsumer;
+if (SelectedSubcommand->hasSelection())
+  TestConsumer = SelectedSubcommand->getSelection()->createCustomConsumer();
+ClangRefactorToolConsumerInterface *ActiveConsumer =
+TestConsumer ? TestConsumer.get() : Consumer.get();
+ActiveConsumer->beginTU(AST);
+// FIXME (Alex L): Implement non-selection based invocation path.
+if (SelectedSubcommand->hasSelection()) {
+  assert(SelectedSubcommand->getSelection() &&
+ "Missing selection argument?");
+  if (opts::Verbose)
+SelectedSubcommand->getSelection()->print(llvm::outs());
+  if (SelectedSubcommand->getSelection()->forAllRanges(
+  Context.getSources(), [&](SourceRange R) {
+Context.setSelectionRange(R);
+if (opts::Verbose)
+  logInvocation(*SelectedSubcommand, Context);
+MatchingRule->invoke(*ActiveConsumer, Context);
+  }))
+HasFailed = true;
+  ActiveConsumer->endTU();
+  return;
+}
+ActiveConsumer->endTU();

[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 121885.
xazax.hun marked 3 inline comments as done.
xazax.hun added a comment.

- Fix review comments


https://reviews.llvm.org/D33722

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

Index: test/clang-tidy/misc-copy-constructor-init.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-copy-constructor-init.cpp
@@ -0,0 +1,188 @@
+// RUN: %check_clang_tidy %s misc-copy-constructor-init %t
+
+class NonCopyable {
+public:
+  NonCopyable() = default;
+  NonCopyable(const NonCopyable &) = delete;
+
+private:
+  int a;
+};
+
+class NonCopyable2 {
+public:
+  NonCopyable2() = default;
+
+private:
+  NonCopyable2(const NonCopyable2 &);
+  int a;
+};
+
+class Copyable {
+public:
+  Copyable() = default;
+  Copyable(const Copyable &) = default;
+
+private:
+  int a;
+};
+
+class Copyable2 {
+public:
+  Copyable2() = default;
+  Copyable2(const Copyable2 &) = default;
+
+private:
+  int a;
+};
+
+class Copyable3 : public Copyable {
+public:
+  Copyable3() = default;
+  Copyable3(const Copyable3 &) = default;
+};
+
+template 
+class Copyable4 {
+public:
+  Copyable4() = default;
+  Copyable4(const Copyable4 &) = default;
+
+private:
+  int a;
+};
+
+template 
+class Copyable5 {
+public:
+  Copyable5() = default;
+  Copyable5(const Copyable5 &) = default;
+
+private:
+  int a;
+};
+
+class EmptyCopyable {
+public:
+  EmptyCopyable() = default;
+  EmptyCopyable(const EmptyCopyable &) = default;
+};
+
+template 
+using CopyableAlias = Copyable5;
+
+typedef Copyable5 CopyableAlias2;
+
+class X : public Copyable, public EmptyCopyable {
+  X(const X &other) : Copyable(other) {}
+};
+
+class X2 : public Copyable2 {
+  X2(const X2 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor other than the copy constructor [misc-copy-constructor-init]
+  // CHECK-FIXES: X2(const X2 &other)  : Copyable2(other) {}
+};
+
+class X2_A : public Copyable2 {
+  X2_A(const X2_A &) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X2_A(const X2_A &) {}
+};
+
+class X3 : public Copyable, public Copyable2 {
+  X3(const X3 &other) : Copyable(other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X3(const X3 &other) : Copyable(other) {}
+};
+
+class X4 : public Copyable {
+  X4(const X4 &other) : Copyable() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X4(const X4 &other) : Copyable(other) {}
+};
+
+class X5 : public Copyable3 {
+  X5(const X5 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X5(const X5 &other)  : Copyable3(other) {}
+};
+
+class X6 : public Copyable2, public Copyable3 {
+  X6(const X6 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X6(const X6 &other)  : Copyable2(other), Copyable3(other) {}
+};
+
+class X7 : public Copyable, public Copyable2 {
+  X7(const X7 &other) : Copyable() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X7(const X7 &other) : Copyable(other) {}
+};
+
+class X8 : public Copyable4 {
+  X8(const X8 &other) : Copyable4(other) {}
+};
+
+class X9 : public Copyable4 {
+  X9(const X9 &other) : Copyable4() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X9(const X9 &other) : Copyable4(other) {}
+};
+
+class X10 : public Copyable4 {
+  X10(const X10 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X10(const X10 &other)  : Copyable4(other) {}
+};
+
+class X11 : public Copyable5 {
+  X11(const X11 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X11(const X11 &other)  : Copyable5(other) {}
+};
+
+class X12 : public CopyableAlias {
+  X12(const X12 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X12(const X12 &other) {}
+};
+
+template 
+class X13 : T {
+  X13(const X13 &other) {}
+};
+
+template class X13;
+template class X13;
+
+#define FROMMACRO\
+  class X14 : public Copyable2 { \
+X14(const X14 &other) {} \
+  };
+
+FROMMACRO
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: calling a base constructor
+
+class X15 : public CopyableAlias2 {
+  X15(const X15 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X15(const X15 &other) {}
+};
+
+class X16 : public NonCopyable {
+  X16(const X16 &other) {}
+};
+
+class X17 : public NonCopy

[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 121886.
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

- Fix doc comments that I overlooked earlier


https://reviews.llvm.org/D33722

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

Index: test/clang-tidy/misc-copy-constructor-init.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-copy-constructor-init.cpp
@@ -0,0 +1,188 @@
+// RUN: %check_clang_tidy %s misc-copy-constructor-init %t
+
+class NonCopyable {
+public:
+  NonCopyable() = default;
+  NonCopyable(const NonCopyable &) = delete;
+
+private:
+  int a;
+};
+
+class NonCopyable2 {
+public:
+  NonCopyable2() = default;
+
+private:
+  NonCopyable2(const NonCopyable2 &);
+  int a;
+};
+
+class Copyable {
+public:
+  Copyable() = default;
+  Copyable(const Copyable &) = default;
+
+private:
+  int a;
+};
+
+class Copyable2 {
+public:
+  Copyable2() = default;
+  Copyable2(const Copyable2 &) = default;
+
+private:
+  int a;
+};
+
+class Copyable3 : public Copyable {
+public:
+  Copyable3() = default;
+  Copyable3(const Copyable3 &) = default;
+};
+
+template 
+class Copyable4 {
+public:
+  Copyable4() = default;
+  Copyable4(const Copyable4 &) = default;
+
+private:
+  int a;
+};
+
+template 
+class Copyable5 {
+public:
+  Copyable5() = default;
+  Copyable5(const Copyable5 &) = default;
+
+private:
+  int a;
+};
+
+class EmptyCopyable {
+public:
+  EmptyCopyable() = default;
+  EmptyCopyable(const EmptyCopyable &) = default;
+};
+
+template 
+using CopyableAlias = Copyable5;
+
+typedef Copyable5 CopyableAlias2;
+
+class X : public Copyable, public EmptyCopyable {
+  X(const X &other) : Copyable(other) {}
+};
+
+class X2 : public Copyable2 {
+  X2(const X2 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor other than the copy constructor [misc-copy-constructor-init]
+  // CHECK-FIXES: X2(const X2 &other)  : Copyable2(other) {}
+};
+
+class X2_A : public Copyable2 {
+  X2_A(const X2_A &) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X2_A(const X2_A &) {}
+};
+
+class X3 : public Copyable, public Copyable2 {
+  X3(const X3 &other) : Copyable(other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X3(const X3 &other) : Copyable(other) {}
+};
+
+class X4 : public Copyable {
+  X4(const X4 &other) : Copyable() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X4(const X4 &other) : Copyable(other) {}
+};
+
+class X5 : public Copyable3 {
+  X5(const X5 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X5(const X5 &other)  : Copyable3(other) {}
+};
+
+class X6 : public Copyable2, public Copyable3 {
+  X6(const X6 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X6(const X6 &other)  : Copyable2(other), Copyable3(other) {}
+};
+
+class X7 : public Copyable, public Copyable2 {
+  X7(const X7 &other) : Copyable() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X7(const X7 &other) : Copyable(other) {}
+};
+
+class X8 : public Copyable4 {
+  X8(const X8 &other) : Copyable4(other) {}
+};
+
+class X9 : public Copyable4 {
+  X9(const X9 &other) : Copyable4() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X9(const X9 &other) : Copyable4(other) {}
+};
+
+class X10 : public Copyable4 {
+  X10(const X10 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X10(const X10 &other)  : Copyable4(other) {}
+};
+
+class X11 : public Copyable5 {
+  X11(const X11 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X11(const X11 &other)  : Copyable5(other) {}
+};
+
+class X12 : public CopyableAlias {
+  X12(const X12 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X12(const X12 &other) {}
+};
+
+template 
+class X13 : T {
+  X13(const X13 &other) {}
+};
+
+template class X13;
+template class X13;
+
+#define FROMMACRO\
+  class X14 : public Copyable2 { \
+X14(const X14 &other) {} \
+  };
+
+FROMMACRO
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: calling a base constructor
+
+class X15 : public CopyableAlias2 {
+  X15(const X15 &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X15(const X15 &other) {}
+};
+
+class X16 : public NonCopyable {
+  X16(const X16 &other) {}
+};
+
+cla

[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D33722#916990, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33722#916540, @xazax.hun wrote:
>
> > Also, bugprone might be a better module to put this?
>
>
> I don't have strong opinions on misc vs bugprone (they're both effectively 
> catch-alls for tidy checks, as best I can tell).


@alexfh, do you have an opinion here?




Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:69
+  (Ctor->getAccess() == AS_private || Ctor->isDeleted())) {
+NonCopyableBase = true;
+break;

aaron.ballman wrote:
> What if the base class is inherited privately? e.g.,
> ```
> struct Base {
>   Base(const Base&) {}
> };
> 
> struct Derived : private Base {
>   Derived(const Derived &) {}
> };
> ```
We warn in that case too. I added a test to demonstrate this. I think we still 
want to copy private bases in copy ctors if they are not empty and copyable. 


https://reviews.llvm.org/D33722



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


r317577 - [clang-refactor] Use ClangTool more explicitly by making refaroing actions AST frontend actions.

2017-11-07 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Nov  7 06:35:03 2017
New Revision: 317577

URL: http://llvm.org/viewvc/llvm-project?rev=317577&view=rev
Log:
[clang-refactor] Use ClangTool more explicitly by making refaroing actions AST 
frontend actions.

Summary: This is a refactoring change. NFC

Reviewers: arphaman, hokein

Reviewed By: arphaman, hokein

Subscribers: cfe-commits

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

Modified:
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=317577&r1=317576&r2=317577&view=diff
==
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Tue Nov  7 06:35:03 2017
@@ -25,6 +25,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -256,9 +257,9 @@ public:
   RefactoringActionRules ActionRules,
   cl::OptionCategory &Category)
   : SubCommand(Action->getCommand(), Action->getDescription()),
-Action(std::move(Action)), ActionRules(std::move(ActionRules)) {
+Action(std::move(Action)), ActionRules(std::move(ActionRules)),
+HasSelection(false) {
 // Check if the selection option is supported.
-bool HasSelection = false;
 for (const auto &Rule : this->ActionRules) {
   if ((HasSelection = Rule->hasSelectionRequirement()))
 break;
@@ -295,6 +296,9 @@ public:
 return false;
   }
 
+  // Whether the selection is supported by any rule in the subcommand.
+  bool hasSelection() const { return HasSelection; }
+
   SourceSelectionArgument *getSelection() const {
 assert(Selection && "selection not supported!");
 return ParsedSelection.get();
@@ -310,11 +314,13 @@ private:
   std::unique_ptr> Selection;
   std::unique_ptr ParsedSelection;
   RefactoringActionCommandLineOptions Options;
+  // Whether the selection is supported by any rule in the subcommand.
+  bool HasSelection;
 };
 
 class ClangRefactorConsumer final : public ClangRefactorToolConsumerInterface {
 public:
-  ClangRefactorConsumer() {}
+  ClangRefactorConsumer(AtomicChanges &Changes) : SourceChanges(&Changes) {}
 
   void handleError(llvm::Error Err) override {
 Optional Diag = DiagnosticError::take(Err);
@@ -329,24 +335,23 @@ public:
   }
 
   void handle(AtomicChanges Changes) override {
-SourceChanges.insert(SourceChanges.begin(), Changes.begin(), 
Changes.end());
+SourceChanges->insert(SourceChanges->begin(), Changes.begin(),
+  Changes.end());
   }
 
   void handle(SymbolOccurrences Occurrences) override {
 llvm_unreachable("symbol occurrence results are not handled yet");
   }
 
-  const AtomicChanges &getSourceChanges() const { return SourceChanges; }
-
 private:
-  AtomicChanges SourceChanges;
+  AtomicChanges *SourceChanges;
 };
 
 class ClangRefactorTool {
 public:
-  std::vector> SubCommands;
-
-  ClangRefactorTool() {
+  ClangRefactorTool()
+  : SelectedSubcommand(nullptr), MatchingRule(nullptr),
+Consumer(new ClangRefactorConsumer(Changes)), HasFailed(false) {
 std::vector> Actions =
 createRefactoringActions();
 
@@ -369,59 +374,110 @@ public:
 }
   }
 
-  using TUCallbackType = llvm::function_ref;
+  // Initializes the selected subcommand and refactoring rule based on the
+  // command line options.
+  llvm::Error Init() {
+auto Subcommand = getSelectedSubcommand();
+if (!Subcommand)
+  return Subcommand.takeError();
+auto Rule = getMatchingRule(**Subcommand);
+if (!Rule)
+  return Rule.takeError();
+
+SelectedSubcommand = *Subcommand;
+MatchingRule = *Rule;
+
+return llvm::Error::success();
+  }
+
+  bool hasFailed() const { return HasFailed; }
+
+  using TUCallbackType = std::function;
+
+  // Callback of an AST action. This invokes the matching rule on the given 
AST.
+  void callback(ASTContext &AST) {
+assert(SelectedSubcommand && MatchingRule && Consumer);
+RefactoringRuleContext Context(AST.getSourceManager());
+Context.setASTContext(AST);
+
+// If the selection option is test specific, we use a test-specific
+// consumer.
+std::unique_ptr TestConsumer;
+if (SelectedSubcommand->hasSelection())
+  TestConsumer = 
SelectedSubcommand->getSelection()->createCustomConsumer();
+ClangRefactorToolConsumerInterface *ActiveConsumer =
+TestConsumer ? TestConsumer.get() : Consumer.get();
+ActiveConsumer->beginTU(AST);
+// FIXME (Alex L): Implement non-selection based invocation path.
+if (SelectedSubcommand->hasSelection()) {
+  assert(SelectedSubcommand->getSelection() &&
+ "Missing sel

[PATCH] D39675: [clang-refactor] Use ClangTool more explicitly by making refaroing actions AST frontend actions.

2017-11-07 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317577: [clang-refactor] Use ClangTool more explicitly by 
making refaroing actions AST… (authored by ioeric).

Repository:
  rL LLVM

https://reviews.llvm.org/D39675

Files:
  cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Index: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
===
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
@@ -25,6 +25,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -256,9 +257,9 @@
   RefactoringActionRules ActionRules,
   cl::OptionCategory &Category)
   : SubCommand(Action->getCommand(), Action->getDescription()),
-Action(std::move(Action)), ActionRules(std::move(ActionRules)) {
+Action(std::move(Action)), ActionRules(std::move(ActionRules)),
+HasSelection(false) {
 // Check if the selection option is supported.
-bool HasSelection = false;
 for (const auto &Rule : this->ActionRules) {
   if ((HasSelection = Rule->hasSelectionRequirement()))
 break;
@@ -295,6 +296,9 @@
 return false;
   }
 
+  // Whether the selection is supported by any rule in the subcommand.
+  bool hasSelection() const { return HasSelection; }
+
   SourceSelectionArgument *getSelection() const {
 assert(Selection && "selection not supported!");
 return ParsedSelection.get();
@@ -310,11 +314,13 @@
   std::unique_ptr> Selection;
   std::unique_ptr ParsedSelection;
   RefactoringActionCommandLineOptions Options;
+  // Whether the selection is supported by any rule in the subcommand.
+  bool HasSelection;
 };
 
 class ClangRefactorConsumer final : public ClangRefactorToolConsumerInterface {
 public:
-  ClangRefactorConsumer() {}
+  ClangRefactorConsumer(AtomicChanges &Changes) : SourceChanges(&Changes) {}
 
   void handleError(llvm::Error Err) override {
 Optional Diag = DiagnosticError::take(Err);
@@ -329,24 +335,23 @@
   }
 
   void handle(AtomicChanges Changes) override {
-SourceChanges.insert(SourceChanges.begin(), Changes.begin(), Changes.end());
+SourceChanges->insert(SourceChanges->begin(), Changes.begin(),
+  Changes.end());
   }
 
   void handle(SymbolOccurrences Occurrences) override {
 llvm_unreachable("symbol occurrence results are not handled yet");
   }
 
-  const AtomicChanges &getSourceChanges() const { return SourceChanges; }
-
 private:
-  AtomicChanges SourceChanges;
+  AtomicChanges *SourceChanges;
 };
 
 class ClangRefactorTool {
 public:
-  std::vector> SubCommands;
-
-  ClangRefactorTool() {
+  ClangRefactorTool()
+  : SelectedSubcommand(nullptr), MatchingRule(nullptr),
+Consumer(new ClangRefactorConsumer(Changes)), HasFailed(false) {
 std::vector> Actions =
 createRefactoringActions();
 
@@ -369,59 +374,110 @@
 }
   }
 
-  using TUCallbackType = llvm::function_ref;
+  // Initializes the selected subcommand and refactoring rule based on the
+  // command line options.
+  llvm::Error Init() {
+auto Subcommand = getSelectedSubcommand();
+if (!Subcommand)
+  return Subcommand.takeError();
+auto Rule = getMatchingRule(**Subcommand);
+if (!Rule)
+  return Rule.takeError();
+
+SelectedSubcommand = *Subcommand;
+MatchingRule = *Rule;
+
+return llvm::Error::success();
+  }
+
+  bool hasFailed() const { return HasFailed; }
+
+  using TUCallbackType = std::function;
+
+  // Callback of an AST action. This invokes the matching rule on the given AST.
+  void callback(ASTContext &AST) {
+assert(SelectedSubcommand && MatchingRule && Consumer);
+RefactoringRuleContext Context(AST.getSourceManager());
+Context.setASTContext(AST);
+
+// If the selection option is test specific, we use a test-specific
+// consumer.
+std::unique_ptr TestConsumer;
+if (SelectedSubcommand->hasSelection())
+  TestConsumer = SelectedSubcommand->getSelection()->createCustomConsumer();
+ClangRefactorToolConsumerInterface *ActiveConsumer =
+TestConsumer ? TestConsumer.get() : Consumer.get();
+ActiveConsumer->beginTU(AST);
+// FIXME (Alex L): Implement non-selection based invocation path.
+if (SelectedSubcommand->hasSelection()) {
+  assert(SelectedSubcommand->getSelection() &&
+ "Missing selection argument?");
+  if (opts::Verbose)
+SelectedSubcommand->getSelection()->print(llvm::outs());
+  if (SelectedSubcommand->getSelection()->forAllRanges(
+  Context.getSources(), [&](SourceRange R) {
+Context.setSelectionRange(R);
+if (opts::Verbose)
+  logInvocation(*SelectedSubcommand, Context);
+  

[clang-tools-extra] r317580 - [clangd] don't crash on invalid JSON-RPC ID

2017-11-07 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Nov  7 06:45:31 2017
New Revision: 317580

URL: http://llvm.org/viewvc/llvm-project?rev=317580&view=rev
Log:
[clangd] don't crash on invalid JSON-RPC ID

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

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=317580&r1=317579&r2=317580&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Tue Nov  7 06:45:31 
2017
@@ -12,6 +12,7 @@
 #include "ProtocolHandlers.h"
 #include "Trace.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/YAMLParser.h"
 #include 
@@ -149,7 +150,8 @@ bool JSONRPCDispatcher::call(StringRef C
   ID.emplace(V.str());
 } else {
   double D;
-  if (!V.getAsDouble(D))
+  // FIXME: this is locale-sensitive.
+  if (llvm::to_float(V, D))
 ID.emplace(D);
 }
   }


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


[clang-tools-extra] r317581 - [clangd] MSVC - third time's the charm

2017-11-07 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Nov  7 06:59:21 2017
New Revision: 317581

URL: http://llvm.org/viewvc/llvm-project?rev=317581&view=rev
Log:
[clangd] MSVC - third time's the charm

Modified:
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp?rev=317581&r1=317580&r2=317581&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp Tue Nov  7 
06:59:21 2017
@@ -68,7 +68,7 @@ TEST(JSONExprTests, Escaping) {
   '\xce', '\x94',   // Non-ASCII UTF-8 is not escaped.
   };
   EXPECT_EQ(R"("\u\u0008\u000c\r\n\tS\"\\)"
-u8"\x7f\xce\x94\"",
+"\x7f\xCE\x94\"",
 s(test));
 
   EXPECT_EQ(R"({"object keys are\nescaped":true})",


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


[PATCH] D39641: [CodeGen] make cbrt and fma constant (never set errno)

2017-11-07 Thread Sanjay Patel via Phabricator via cfe-commits
spatel updated this revision to Diff 121898.
spatel added a comment.

Patch updated - no code or functional changes from the last rev.

I split the  and  test files up, so I can update those 
independently and not incur svn conflicts.


https://reviews.llvm.org/D39641

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/math-builtins.c
  test/CodeGen/math-libcalls.c

Index: test/CodeGen/math-libcalls.c
===
--- test/CodeGen/math-libcalls.c
+++ test/CodeGen/math-libcalls.c
@@ -145,9 +145,9 @@
 // NO__ERRNO: declare double @cbrt(double) [[READNONE]]
 // NO__ERRNO: declare float @cbrtf(float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @cbrt(double) [[NOT_READNONE]]
-// HAS_ERRNO: declare float @cbrtf(float) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @cbrt(double) [[READNONE]]
+// HAS_ERRNO: declare float @cbrtf(float) [[READNONE]]
+// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
 
   ceil(f);   ceilf(f);  ceill(f);
 
Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -175,9 +175,9 @@
 // NO__ERRNO: declare double @cbrt(double) [[READNONE]]
 // NO__ERRNO: declare float @cbrtf(float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @cbrt(double) [[NOT_READNONE]]
-// HAS_ERRNO: declare float @cbrtf(float) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @cbrt(double) [[READNONE]]
+// HAS_ERRNO: declare float @cbrtf(float) [[READNONE]]
+// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
 
   __builtin_ceil(f);   __builtin_ceilf(f);  __builtin_ceill(f);
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2109,15 +2109,11 @@
   case Builtin::BIfmal:
   case Builtin::BI__builtin_fma:
   case Builtin::BI__builtin_fmaf:
-  case Builtin::BI__builtin_fmal: {
-// Rewrite fma to intrinsic.
-Value *FirstArg = EmitScalarExpr(E->getArg(0));
-llvm::Type *ArgType = FirstArg->getType();
-Value *F = CGM.getIntrinsic(Intrinsic::fma, ArgType);
-return RValue::get(
-Builder.CreateCall(F, {FirstArg, EmitScalarExpr(E->getArg(1)),
-   EmitScalarExpr(E->getArg(2))}));
-  }
+  case Builtin::BI__builtin_fmal:
+// A constant libcall or builtin is equivalent to the LLVM intrinsic.
+if (FD->hasAttr())
+  return RValue::get(emitTernaryBuiltin(*this, E, Intrinsic::fma));
+break;
 
   case Builtin::BI__builtin_signbit:
   case Builtin::BI__builtin_signbitf:
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -165,9 +165,9 @@
 BUILTIN(__builtin_atanh , "dd", "Fne")
 BUILTIN(__builtin_atanhf, "ff", "Fne")
 BUILTIN(__builtin_atanhl, "LdLd", "Fne")
-BUILTIN(__builtin_cbrt , "dd", "Fne")
-BUILTIN(__builtin_cbrtf, "ff", "Fne")
-BUILTIN(__builtin_cbrtl, "LdLd", "Fne")
+BUILTIN(__builtin_cbrt , "dd", "Fnc")
+BUILTIN(__builtin_cbrtf, "ff", "Fnc")
+BUILTIN(__builtin_cbrtl, "LdLd", "Fnc")
 BUILTIN(__builtin_ceil , "dd"  , "Fnc")
 BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
@@ -198,9 +198,11 @@
 BUILTIN(__builtin_floor , "dd"  , "Fnc")
 BUILTIN(__builtin_floorf, "ff"  , "Fnc")
 BUILTIN(__builtin_floorl, "LdLd", "Fnc")
-BUILTIN(__builtin_fma, "", "Fne")
-BUILTIN(__builtin_fmaf, "", "Fne")
-BUILTIN(__builtin_fmal, "LdLdLdLd", "Fne")
+// Disregard that 'fma' could set errno. This is based on the assumption that no
+// reasonable implementation would set errno and harm performance of a basic op.
+BUILTIN(__builtin_fma, "", "Fnc")
+BUILTIN(__builtin_fmaf, "", "Fnc")
+BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc")
 BUILTIN(__builtin_fmax, "ddd", "Fnc")
 BUILTIN(__builtin_fmaxf, "fff", "Fnc")
 BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
@@ -1040,9 +1042,9 @@
 LIBBUILTIN(atanhf, "ff", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(atanhl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
 
-LIBBUILTIN(cbrt, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(cbrtf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(cbrtl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(cbrt, "dd", "fnc", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(cbrtf, "ff", "fnc", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(cbrtl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
 
 LIBBUILTIN(ceil, "dd", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(ceilf, "ff", "fnc", "math.h", ALL_LANGUAGES)
@@ -1084,9 +1086,11 @@
 LIBBUILTIN(floorf, "ff", "fnc", "math.h", ALL_LANGUAGE

[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-11-07 Thread jina via Phabricator via cfe-commits
jina.nahias updated this revision to Diff 121899.

https://reviews.llvm.org/D39719

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


Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6224,10 +6224,15 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return 
_mm512_mask_cmpneq_epu32_mask(_mm512_kunpackb(_mm512_cmpneq_epu32_mask(__A,__B),_mm512_cmpneq_epu32_mask(__C,__D)),__E,
 __F);
 }
 
 __mmask16 test_mm512_kxnor(__mmask16 __A, __mmask16 __B) {
Index: test/CodeGen/avx512bw-builtins.c
===
--- test/CodeGen/avx512bw-builtins.c
+++ test/CodeGen/avx512bw-builtins.c
@@ -1626,16 +1626,26 @@
   return _mm512_maskz_set1_epi8(__M, __A); 
 }
 
-__mmask64 test_mm512_kunpackd(__mmask64 __A, __mmask64 __B) {
+__mmask64 test_mm512_kunpackd(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackd
-  // CHECK: @llvm.x86.avx512.kunpck.dq
-  return _mm512_kunpackd(__A, __B); 
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: and i64 %{{.*}}, 4294967295
+  // CHECK: shl i64 %{{.*}}, 32
+  // CHECK: or i64 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i64 %{{.*}} to <64 x i1>
+  return 
_mm512_mask_cmpneq_epu8_mask(_mm512_kunpackd(_mm512_cmpneq_epu8_mask(__B, 
__A),_mm512_cmpneq_epu8_mask(__C, __D)), __E, __F); 
 }
 
-__mmask32 test_mm512_kunpackw(__mmask32 __A, __mmask32 __B) {
+__mmask32 test_mm512_kunpackw(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackw
-  // CHECK: @llvm.x86.avx512.kunpck.wd
-  return _mm512_kunpackw(__A, __B); 
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: and i32 %{{.*}}, 65535
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i32 %{{.*}} to <32 x i1>
+  return 
_mm512_mask_cmpneq_epu16_mask(_mm512_kunpackw(_mm512_cmpneq_epu16_mask(__B, 
__A),_mm512_cmpneq_epu16_mask(__C, __D)), __E, __F); 
 }
 
 __m512i test_mm512_mask_loadu_epi16(__m512i __W, __mmask32 __U, void const 
*__P) {
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -9011,7 +9011,7 @@
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) 
__B);
+  return (__mmask16)  (( __A  & 0xFF) | ( __B << 8));
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
Index: lib/Headers/avx512bwintrin.h
===
--- lib/Headers/avx512bwintrin.h
+++ lib/Headers/avx512bwintrin.h
@@ -2042,15 +2042,13 @@
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __A  & 0x) | ( __B << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A,
-(__mmask32) __B);
+return (__mmask32)  (( __A  & 0x) | ( __B << 16));
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS


Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6224,10 +6224,15 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return _mm512_mask_cmpneq_epu32_mask(_mm512_kunpackb(_m

[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-11-07 Thread jina via Phabricator via cfe-commits
jina.nahias added inline comments.



Comment at: lib/Headers/avx512bwintrin.h:2045
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __B  & 0x) | ((__mmask64) __A << 32));
 }

RKSimon wrote:
> Is this right? The Intel docs says it should be:
> ```
> k[31:0] := a[31:0]
> k[63:32] := b[31:0]
> k[MAX:64] := 0
> ```
> 
> Also, is the cast on __A necessary?
> 
> Same for the others.
you are right,  i fixed it.


https://reviews.llvm.org/D39719



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


[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part

2017-11-07 Thread Lama via Phabricator via cfe-commits
lsaba added inline comments.



Comment at: lib/Headers/avx512fintrin.h:7207
+  3 + imm) >> 2) & 0x3) * 4), \
+  8 + imm) >> 4) & 0x3) * 4), \
+  9 + imm) >> 4) & 0x3) * 4), \

This should start at 16 in order to get to B



Comment at: lib/Headers/avx512fintrin.h:7213
+  9 + imm) >> 6) & 0x3) * 4), \
+  10 + imm) >> 4) & 0x3) * 4), \
+  11 + imm) >> 4) & 0x3) * 4)); })

this should be >>6?



Comment at: test/CodeGen/avx512f-builtins.c:4491
   // CHECK-LABEL: @test_mm512_shuffle_f32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.f32x4
+  // CHECK: shufflevector <16 x float> %{{.*}}, <16 x float> %{{.*}}, <16 x 
i32> 
   return _mm512_shuffle_f32x4(__A, __B, 4); 

expected to be
shufflevector <16 x float> %{{.*}}, <16 x float> %{{.*}}, <16 x i32> 
See comment on 
#define _mm512_shuffle_f32x4(A, B, imm) __extension__ ({ 



Comment at: test/CodeGen/avx512f-builtins.c:4496
 __m512 test_mm512_mask_shuffle_f32x4(__m512 __W, __mmask16 __U, __m512 __A, 
__m512 __B) {
   // CHECK-LABEL: @test_mm512_mask_shuffle_f32x4
+  // CHECK: shufflevector <16 x float> %{{.*}}, <16 x float> %{{.*}}, <16 x 
i32> 

Same comment as above


https://reviews.llvm.org/D38672



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


[clang-tools-extra] r317584 - [clangd] Fix initialize capabilities response

2017-11-07 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Nov  7 07:49:35 2017
New Revision: 317584

URL: http://llvm.org/viewvc/llvm-project?rev=317584&view=rev
Log:
[clangd] Fix initialize capabilities response

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
clang-tools-extra/trunk/test/clangd/initialize-params.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=317584&r1=317583&r2=317584&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Nov  7 07:49:35 2017
@@ -36,30 +36,32 @@ replacementsToEdits(StringRef Code,
 
 void ClangdLSPServer::onInitialize(Ctx C, InitializeParams &Params) {
   C.reply(json::obj{
-  {"textDocumentSync", 1},
-  {"documentFormattingProvider", true},
-  {"documentRangeFormattingProvider", true},
-  {"documentOnTypeFormattingProvider",
-   json::obj{
-   {"firstTriggerCharacter", "}"},
-   {"moreTriggerCharacter", {}},
-   }},
-  {"codeActionProvider", true},
-  {"completionProvider",
-   json::obj{
-   {"resolveProvider", false},
-   {"triggerCharacters", {".", ">", ":"}},
-   }},
-  {"signatureHelpProvider",
-   json::obj{
-   {"triggerCharacters", {"(", ","}},
-   }},
-  {"definitionProvider", true},
-  {"executeCommandProvider",
-   json::obj{
-   {"commands", {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},
-   }},
-  });
+  {{"capabilities",
+json::obj{
+{"textDocumentSync", 1},
+{"documentFormattingProvider", true},
+{"documentRangeFormattingProvider", true},
+{"documentOnTypeFormattingProvider",
+ json::obj{
+ {"firstTriggerCharacter", "}"},
+ {"moreTriggerCharacter", {}},
+ }},
+{"codeActionProvider", true},
+{"completionProvider",
+ json::obj{
+ {"resolveProvider", false},
+ {"triggerCharacters", {".", ">", ":"}},
+ }},
+{"signatureHelpProvider",
+ json::obj{
+ {"triggerCharacters", {"(", ","}},
+ }},
+{"definitionProvider", true},
+{"executeCommandProvider",
+ json::obj{
+ {"commands", 
{ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},
+ }},
+);
   if (Params.rootUri && !Params.rootUri->file.empty())
 Server.setRootPath(Params.rootUri->file);
   else if (Params.rootPath && !Params.rootPath->empty())

Modified: clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test?rev=317584&r1=317583&r2=317584&view=diff
==
--- clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test 
(original)
+++ clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test Tue Nov  
7 07:49:35 2017
@@ -8,34 +8,36 @@ Content-Length: 142
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
-# CHECK-NEXT:"codeActionProvider": true,
-# CHECK-NEXT:"completionProvider": {
-# CHECK-NEXT:  "resolveProvider": false,
-# CHECK-NEXT:  "triggerCharacters": [
-# CHECK-NEXT:".",
-# CHECK-NEXT:">",
-# CHECK-NEXT:":"
-# CHECK-NEXT:  ]
-# CHECK-NEXT:},
-# CHECK-NEXT:"definitionProvider": true,
-# CHECK-NEXT:"documentFormattingProvider": true,
-# CHECK-NEXT:"documentOnTypeFormattingProvider": {
-# CHECK-NEXT:  "firstTriggerCharacter": "}",
-# CHECK-NEXT:  "moreTriggerCharacter": []
-# CHECK-NEXT:},
-# CHECK-NEXT:"documentRangeFormattingProvider": true,
-# CHECK-NEXT:"executeCommandProvider": {
-# CHECK-NEXT:  "commands": [
-# CHECK-NEXT:"clangd.applyFix"
-# CHECK-NEXT:  ]
-# CHECK-NEXT:},
-# CHECK-NEXT:"signatureHelpProvider": {
-# CHECK-NEXT:  "triggerCharacters": [
-# CHECK-NEXT:"(",
-# CHECK-NEXT:","
-# CHECK-NEXT:  ]
-# CHECK-NEXT:},
-# CHECK-NEXT:"textDocumentSync": 1
+# CHECK-NEXT:"capabilities": {
+# CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"resolveProvider": false,
+# CHECK-NEXT:"triggerCharacters": [
+# CHECK-NEXT:  ".",
+# CHECK-NEXT:  ">",
+# CHECK-NEXT:  ":"
+# CHECK-NEXT:]
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "definitionProvider": true,
+# CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentOnTypeFormattingProvide

[PATCH] D39735: [clangd] Fix missing 'capabilities' field in initialize

2017-11-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle abandoned this revision.
malaperle added a comment.

Already committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D39735



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


[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part

2017-11-07 Thread jina via Phabricator via cfe-commits
jina.nahias updated this revision to Diff 121908.

https://reviews.llvm.org/D38672

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

Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -5602,73 +5602,85 @@
 }
 __m256 test_mm256_shuffle_f32x4(__m256 __A, __m256 __B) {
   // CHECK-LABEL: @test_mm256_shuffle_f32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.f32x4
+  // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 
   return _mm256_shuffle_f32x4(__A, __B, 3); 
 }
 
 __m256 test_mm256_mask_shuffle_f32x4(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) {
   // CHECK-LABEL: @test_mm256_mask_shuffle_f32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.f32x4
+  // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
   return _mm256_mask_shuffle_f32x4(__W, __U, __A, __B, 3); 
 }
 
 __m256 test_mm256_maskz_shuffle_f32x4(__mmask8 __U, __m256 __A, __m256 __B) {
   // CHECK-LABEL: @test_mm256_maskz_shuffle_f32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.f32x4
+  // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
   return _mm256_maskz_shuffle_f32x4(__U, __A, __B, 3); 
 }
 
 __m256d test_mm256_shuffle_f64x2(__m256d __A, __m256d __B) {
   // CHECK-LABEL: @test_mm256_shuffle_f64x2
-  // CHECK: @llvm.x86.avx512.mask.shuf.f64x2
+  // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> 
   return _mm256_shuffle_f64x2(__A, __B, 3); 
 }
 
 __m256d test_mm256_mask_shuffle_f64x2(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) {
   // CHECK-LABEL: @test_mm256_mask_shuffle_f64x2
-  // CHECK: @llvm.x86.avx512.mask.shuf.f64x2
+  // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> 
+  // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> 
+  // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}}
   return _mm256_mask_shuffle_f64x2(__W, __U, __A, __B, 3); 
 }
 
 __m256d test_mm256_maskz_shuffle_f64x2(__mmask8 __U, __m256d __A, __m256d __B) {
   // CHECK-LABEL: @test_mm256_maskz_shuffle_f64x2
-  // CHECK: @llvm.x86.avx512.mask.shuf.f64x2
+  // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> 
+  // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> 
+  // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}}
   return _mm256_maskz_shuffle_f64x2(__U, __A, __B, 3); 
 }
 
 __m256i test_mm256_shuffle_i32x4(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_shuffle_i32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.i32x4
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
   return _mm256_shuffle_i32x4(__A, __B, 3); 
 }
 
 __m256i test_mm256_mask_shuffle_i32x4(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shuffle_i32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.i32x4
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_mask_shuffle_i32x4(__W, __U, __A, __B, 3); 
 }
 
 __m256i test_mm256_maskz_shuffle_i32x4(__mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_shuffle_i32x4
-  // CHECK: @llvm.x86.avx512.mask.shuf.i32x4
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_maskz_shuffle_i32x4(__U, __A, __B, 3); 
 }
 
 __m256i test_mm256_shuffle_i64x2(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_shuffle_i64x2
-  // CHECK: @llvm.x86.avx512.mask.shuf.i64x2
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
   return _mm256_shuffle_i64x2(__A, __B, 3); 
 }
 
 __m256i test_mm256_mask_shuffle_i64x2(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_shuffle_i64x2
-  // CHECK: @llvm.x86.avx512.mask.shuf.i64x2
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
+  // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> 
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_shuffle_i64x2(__W, __U, __A, __B, 3); 
 }
 
 __m256i test_mm256_maskz_shuffle_i64x2(__mmask8 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_shuffle_i64x2
-  // CHECK: @llvm.x86.avx512.mask.shuf.i64x2
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
+  // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> 
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*

[clang-tools-extra] r317585 - [clangd] Fix opening declarations located in non-preamble inclusion

2017-11-07 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Tue Nov  7 08:16:45 2017
New Revision: 317585

URL: http://llvm.org/viewvc/llvm-project?rev=317585&view=rev
Log:
[clangd] Fix opening declarations located in non-preamble inclusion

Summary:
When an inclusion is not processed as part of the preamble, its path is
not made into an absolute path as part of the precompiled header code
(adjustFilenameForRelocatableAST in ASTWriter.cpp). Because of this,
when we convert a Decl location to retrieve the file name with
FileEntry->getName(), it is possible for this path to be relative.
Instead, we should try to use tryGetRealPathName first which returns
an absolute path.

Fixes bug 35217.

Reviewers: sammccall, ilya-biryukov, rwols, Nebiroth

Reviewed By: sammccall

Subscribers: cfe-commits, ilya-biryukov

Tags: #clang-tools-extra

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

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=317585&r1=317584&r2=317585&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Nov  7 08:16:45 2017
@@ -965,10 +965,15 @@ private:
 End.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
 Range R = {Begin, End};
 Location L;
-L.uri = URI::fromFile(
-SourceMgr.getFilename(SourceMgr.getSpellingLoc(LocStart)));
-L.range = R;
-DeclarationLocations.push_back(L);
+if (const FileEntry *F =
+SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {
+  StringRef FilePath = F->tryGetRealPathName();
+  if (FilePath.empty())
+FilePath = F->getName();
+  L.uri = URI::fromFile(FilePath);
+  L.range = R;
+  DeclarationLocations.push_back(L);
+}
   }
 
   void finish() override {


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


[PATCH] D39705: [clangd] Fix opening declarations located in non-preamble inclusion

2017-11-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317585: [clangd] Fix opening declarations located in 
non-preamble inclusion (authored by malaperle).

Repository:
  rL LLVM

https://reviews.llvm.org/D39705

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


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -965,10 +965,15 @@
 End.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
 Range R = {Begin, End};
 Location L;
-L.uri = URI::fromFile(
-SourceMgr.getFilename(SourceMgr.getSpellingLoc(LocStart)));
-L.range = R;
-DeclarationLocations.push_back(L);
+if (const FileEntry *F =
+SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {
+  StringRef FilePath = F->tryGetRealPathName();
+  if (FilePath.empty())
+FilePath = F->getName();
+  L.uri = URI::fromFile(FilePath);
+  L.range = R;
+  DeclarationLocations.push_back(L);
+}
   }
 
   void finish() override {


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -965,10 +965,15 @@
 End.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
 Range R = {Begin, End};
 Location L;
-L.uri = URI::fromFile(
-SourceMgr.getFilename(SourceMgr.getSpellingLoc(LocStart)));
-L.range = R;
-DeclarationLocations.push_back(L);
+if (const FileEntry *F =
+SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {
+  StringRef FilePath = F->tryGetRealPathName();
+  if (FilePath.empty())
+FilePath = F->getName();
+  L.uri = URI::fromFile(FilePath);
+  L.range = R;
+  DeclarationLocations.push_back(L);
+}
   }
 
   void finish() override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317589 - SystemZ Swift TargetInfo: swifterror support in the backend is broken

2017-11-07 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Tue Nov  7 08:40:51 2017
New Revision: 317589

URL: http://llvm.org/viewvc/llvm-project?rev=317589&view=rev
Log:
SystemZ Swift TargetInfo: swifterror support in the backend is broken

Return false for swifterror support until the backend is fixed.

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=317589&r1=317588&r2=317589&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Nov  7 08:40:51 2017
@@ -6319,7 +6319,7 @@ public:
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
   bool isSwiftErrorInRegister() const override {
-return true;
+return false;
   }
 };
 


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


[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-11-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Also, I should probably validate bitfields.  The following SHOULD?! be unique?

struct S {
unsigned a : 1;
unsigned b : 2;
unsigned c : 3;
unsigned d : 2;
};

static_assert(__has_unique_object_representations(S), "error");

But without 'd', it should not be (tail padding).


https://reviews.llvm.org/D39347



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


[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-11-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Corrected version of the previous example:
struct S {
char a : 1;
char b : 2;
char c : 3;
char d : 2;
};
static_assert(sizeof(S) == 1, "size");
static_assert(__has_unique_object_representations(S), "error");

I haven't tested this patch agaainst this repro, but it should likely be in the 
tests.


https://reviews.llvm.org/D39347



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


[PATCH] D39738: [clangd] Sort completion results.

2017-11-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added a subscriber: ilya-biryukov.

This is (probably) not required by LSP, but at least one buggy client wants it.
It also simplifies some tests - changed a few completion tests to use -pretty.


https://reviews.llvm.org/D39738

Files:
  clangd/ClangdUnit.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test

Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -1,4 +1,4 @@
-# RUN: clangd -run-synchronously < %s | FileCheck %s
+# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
 # It is absolutely vital that this file has CRLF line endings.
 #
 Content-Length: 125
@@ -12,43 +12,188 @@
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
-# The order of results returned by codeComplete seems to be
-# nondeterministic, so we check regardless of order.
-#
-# CHECK: {"id":1,"jsonrpc":"2.0","result":[
-# CHECK-DAG: {"detail":"int","filterText":"a","insertText":"a","insertTextFormat":1,"kind":5,"label":"a","sortText":"35a"}
-# CHECK-DAG: {"detail":"int","filterText":"bb","insertText":"bb","insertTextFormat":1,"kind":5,"label":"bb","sortText":"35bb"}
-# CHECK-DAG: {"detail":"int","filterText":"ccc","insertText":"ccc","insertTextFormat":1,"kind":5,"label":"ccc","sortText":"35ccc"}
-# CHECK-DAG: {"detail":"fake &","filterText":"operator=","insertText":"operator=","insertTextFormat":1,"kind":2,"label":"operator=(const fake &)","sortText":"79operator="}
-# CHECK-DAG: {"detail":"void","filterText":"~fake","insertText":"~fake","insertTextFormat":1,"kind":4,"label":"~fake()","sortText":"79~fake"}
-# CHECK-DAG: {"detail":"int","filterText":"f","insertText":"f","insertTextFormat":1,"kind":2,"label":"f(int i, const float f) const","sortText":"35f"}
-# CHECK-SAME: ]}
+#  CHECK:  "id": 1
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "int",
+# CHECK-NEXT:  "filterText": "a",
+# CHECK-NEXT:  "insertText": "a",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 5,
+# CHECK-NEXT:  "label": "a",
+# CHECK-NEXT:  "sortText": "35a"
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "int",
+# CHECK-NEXT:  "filterText": "bb",
+# CHECK-NEXT:  "insertText": "bb",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 5,
+# CHECK-NEXT:  "label": "bb",
+# CHECK-NEXT:  "sortText": "35bb"
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "int",
+# CHECK-NEXT:  "filterText": "ccc",
+# CHECK-NEXT:  "insertText": "ccc",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 5,
+# CHECK-NEXT:  "label": "ccc",
+# CHECK-NEXT:  "sortText": "35ccc"
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "int",
+# CHECK-NEXT:  "filterText": "f",
+# CHECK-NEXT:  "insertText": "f",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 2,
+# CHECK-NEXT:  "label": "f(int i, const float f) const",
+# CHECK-NEXT:  "sortText": "35f"
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "filterText": "fake",
+# CHECK-NEXT:  "insertText": "fake",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 7,
+# CHECK-NEXT:  "label": "fake::",
+# CHECK-NEXT:  "sortText": "75fake"
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "fake &",
+# CHECK-NEXT:  "filterText": "operator=",
+# CHECK-NEXT:  "insertText": "operator=",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 2,
+# CHECK-NEXT:  "label": "operator=(const fake &)",
+# CHECK-NEXT:  "sortText": "79operator="
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "void",
+# CHECK-NEXT:  "filterText": "~fake",
+# CHECK-NEXT:  "insertText": "~fake",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 4,
+# CHECK-NEXT:  "label": "~fake()",
+# CHECK-NEXT:  "sortText": "79~fake"
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
-# Repeat the completion request, expect the same results.
-#
-# CHECK: {"id":2,"jsonrpc":"2.0","result":[
-# CHECK-DAG: {"detail":"int","filterText":"a","insertText":"a","insertTextFormat":1,"kind":5,"label":"a","sortText":"35a"}
-# CHECK-DAG: {"detail":"int","filterText":"bb","insertText":"bb","insertTextFormat":1,"kind":5,"label":"bb","

r317593 - [index] index field references in __builtin_offset

2017-11-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov  7 09:29:11 2017
New Revision: 317593

URL: http://llvm.org/viewvc/llvm-project?rev=317593&view=rev
Log:
[index] index field references in __builtin_offset

rdar://35109556

Modified:
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=317593&r1=317592&r2=317593&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Tue Nov  7 09:29:11 2017
@@ -427,6 +427,17 @@ public:
 
 return true;
   }
+
+  bool VisitOffsetOfExpr(OffsetOfExpr *S) {
+for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
+  const OffsetOfNode &Component = S->getComponent(I);
+  if (Component.getKind() == OffsetOfNode::Field)
+IndexCtx.handleReference(Component.getField(), Component.getLocStart(),
+ Parent, ParentDC, SymbolRoleSet(), {});
+  // FIXME: Try to resolve dependent field references.
+}
+return true;
+  }
 };
 
 } // anonymous namespace

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=317593&r1=317592&r2=317593&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Tue Nov  7 09:29:11 2017
@@ -525,3 +525,36 @@ struct rd33122110::Outer::Nested;
 // CHECK-NEXT: RelCont | Nested | c:@N@rd33122110@S@Outer@S@Nested>#I
 // CHECK: [[@LINE-3]]:20 | struct/C++ | Outer | c:@N@rd33122110@S@Outer | 
 | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont | Nested | c:@N@rd33122110@S@Outer@S@Nested>#I
+
+namespace index_offsetof {
+
+struct Struct {
+  int field;
+};
+
+struct Struct2 {
+  Struct array[4][2];
+};
+
+void foo() {
+  __builtin_offsetof(Struct, field);
+// CHECK: [[@LINE-1]]:30 | field/C | field | 
c:@N@index_offsetof@S@Struct@FI@field |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo#
+  __builtin_offsetof(Struct2, array[1][0].field);
+// CHECK: [[@LINE-1]]:31 | field/C | array | 
c:@N@index_offsetof@S@Struct2@FI@array |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo#
+// CHECK: [[@LINE-3]]:42 | field/C | field | 
c:@N@index_offsetof@S@Struct@FI@field |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo#
+}
+
+#define OFFSET_OF_(X, Y) __builtin_offsetof(X, Y)
+
+class SubclassOffsetof : public Struct {
+  void foo() {
+OFFSET_OF_(SubclassOffsetof, field);
+// CHECK: [[@LINE-1]]:34 | field/C | field | 
c:@N@index_offsetof@S@Struct@FI@field |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@S@SubclassOffsetof@F@foo#
+  }
+};
+
+}


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


[PATCH] D39455: [CodeGen] Add initial support for union members in TBAA

2017-11-07 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Colleagues, please let me know if there are any concerns about this patch. It 
was specifically designed to not cause any substantial changes, but I may be 
missing something important. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D39455



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


[PATCH] D39730: Enabling constructor code completion

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

This approach doesn't look right. We don't want to code-complete constructors 
after the `.`. Instead we want to complete the constructors/destructors in 
bodies of classes and in out-of-line declarations after `~`, right?


https://reviews.llvm.org/D39730



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


[PATCH] D39745: Clang/libomptarget map interface flag renaming - NFC patch

2017-11-07 Thread George Rokos via Phabricator via cfe-commits
grokos created this revision.
grokos added projects: OpenMP, clang.

This patch renames some of the flag names of the clang/libomptarget map 
interface. The old names are slightly misleading, whereas the new ones describe 
in a better way what each flag is about.

Only the macros within the enumeration are renamed, there is no change in 
functionality therefore there are no updated regression tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D39745

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp

Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5951,22 +5951,21 @@
 /// \brief Delete the element from the device environment, ignoring the
 /// current reference count associated with the element.
 OMP_MAP_DELETE = 0x08,
-/// \brief The element being mapped is a pointer, therefore the pointee
-/// should be mapped as well.
-OMP_MAP_IS_PTR = 0x10,
-/// \brief This flags signals that an argument is the first one relating to
-/// a map/private clause expression. For some cases a single
-/// map/privatization results in multiple arguments passed to the runtime
-/// library.
-OMP_MAP_FIRST_REF = 0x20,
+/// \brief The element being mapped is a pointer-pointee pair; both the
+/// pointer and the pointee should be mapped.
+OMP_MAP_PTR_AND_OBJ = 0x10,
+/// \brief This flags signals that the base address of an entry should be
+/// passed to the target kernel as an argument.
+OMP_MAP_TARGET_PARAM = 0x20,
 /// \brief Signal that the runtime library has to return the device pointer
-/// in the current position for the data being mapped.
-OMP_MAP_RETURN_PTR = 0x40,
+/// in the current position for the data being mapped. Used when we have the
+/// use_device_ptr clause.
+OMP_MAP_RETURN_PARAM = 0x40,
 /// \brief This flag signals that the reference being passed is a pointer to
 /// private data.
-OMP_MAP_PRIVATE_PTR = 0x80,
+OMP_MAP_PRIVATE = 0x80,
 /// \brief Pass the element to the device by value.
-OMP_MAP_PRIVATE_VAL = 0x100,
+OMP_MAP_LITERAL = 0x100,
 /// Implicit map
 OMP_MAP_IMPLICIT = 0x200,
   };
@@ -6057,7 +6056,7 @@
   /// expression.
   unsigned getMapTypeBits(OpenMPMapClauseKind MapType,
   OpenMPMapClauseKind MapTypeModifier, bool AddPtrFlag,
-  bool AddIsFirstFlag) const {
+  bool AddIsTargetParamFlag) const {
 unsigned Bits = 0u;
 switch (MapType) {
 case OMPC_MAP_alloc:
@@ -6084,9 +6083,9 @@
   break;
 }
 if (AddPtrFlag)
-  Bits |= OMP_MAP_IS_PTR;
-if (AddIsFirstFlag)
-  Bits |= OMP_MAP_FIRST_REF;
+  Bits |= OMP_MAP_PTR_AND_OBJ;
+if (AddIsTargetParamFlag)
+  Bits |= OMP_MAP_TARGET_PARAM;
 if (MapTypeModifier == OMPC_MAP_always)
   Bits |= OMP_MAP_ALWAYS;
 return Bits;
@@ -6193,28 +6192,28 @@
 //
 // map(s.p[:22], s.a s.b)
 // &s, &(s.p), sizeof(double*), noflags
-// &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag + extra_flag
+// &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag
 //
 // map(s.ps)
 // &s, &(s.ps), sizeof(S2*), noflags
 //
 // map(s.ps->s.i)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag
 //
 // map(s.ps->ps)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
 //
 // map(s.ps->ps->ps)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-// &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+// &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag
 //
 // map(s.ps->ps->s.f[:22])
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-// &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+// &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag
 //
 // map(ps)
 // &ps, &ps, sizeof(S2*), noflags
@@ -6230,29 +6229,28 @@
 //
 // map(ps->p[:22])
 // ps, &(ps->p), sizeof(double*), noflags
-// &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag + extra_flag
+// &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag
 //
 // map(ps->ps)
 // ps, &(ps->ps), sizeof(S2*), noflags
 //
 // map(ps->ps->s.i)
 // ps, &(ps->ps), sizeof(S2*), noflags
-// &(ps->ps), &(ps->ps->s.i), sizeof(int), ptr_flag + extra_flag
+// &(ps->ps), &(ps->ps->s.i), sizeof(int), ptr_flag
 //
 // map(ps->ps->ps)
 // ps, &(ps->ps), sizeof(S2

[PATCH] D39745: Clang/libomptarget map interface flag renaming - NFC patch

2017-11-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D39745



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


[PATCH] D39478: [clang-format] Handle leading comments in using declaration

2017-11-07 Thread Igor Sugak via Phabricator via cfe-commits
sugak added a comment.

@djasper: no, I do not.


https://reviews.llvm.org/D39478



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


[PATCH] D39730: Enabling constructor code completion

2017-11-07 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple added a comment.

I agree and it seems to be the case but I will upgrade my ad-hoc testing code 
snippet to a proper test as I should have done it in the first place. I also 
agree that this change looks really suspicious and I was basically surprised 
that it works.


https://reviews.llvm.org/D39730



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


r317596 - [index] __builtin_offset's field reference is located at the end location

2017-11-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov  7 10:25:36 2017
New Revision: 317596

URL: http://llvm.org/viewvc/llvm-project?rev=317596&view=rev
Log:
[index] __builtin_offset's field reference is located at the end location

The starting location is the location of the '.'

Modified:
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=317596&r1=317595&r2=317596&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Tue Nov  7 10:25:36 2017
@@ -432,7 +432,7 @@ public:
 for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
   const OffsetOfNode &Component = S->getComponent(I);
   if (Component.getKind() == OffsetOfNode::Field)
-IndexCtx.handleReference(Component.getField(), Component.getLocStart(),
+IndexCtx.handleReference(Component.getField(), Component.getLocEnd(),
  Parent, ParentDC, SymbolRoleSet(), {});
   // FIXME: Try to resolve dependent field references.
 }

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=317596&r1=317595&r2=317596&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Tue Nov  7 10:25:36 2017
@@ -543,7 +543,7 @@ void foo() {
   __builtin_offsetof(Struct2, array[1][0].field);
 // CHECK: [[@LINE-1]]:31 | field/C | array | 
c:@N@index_offsetof@S@Struct2@FI@array |  | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo#
-// CHECK: [[@LINE-3]]:42 | field/C | field | 
c:@N@index_offsetof@S@Struct@FI@field |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:43 | field/C | field | 
c:@N@index_offsetof@S@Struct@FI@field |  | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo#
 }
 


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


[PATCH] D39745: Clang/libomptarget map interface flag renaming - NFC patch

2017-11-07 Thread George Rokos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317598: Clang/libomptarget map interface flag renaming - NFC 
patch (authored by grokos).

Changed prior to commit:
  https://reviews.llvm.org/D39745?vs=121928&id=121931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39745

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

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5978,22 +5978,21 @@
 /// \brief Delete the element from the device environment, ignoring the
 /// current reference count associated with the element.
 OMP_MAP_DELETE = 0x08,
-/// \brief The element being mapped is a pointer, therefore the pointee
-/// should be mapped as well.
-OMP_MAP_IS_PTR = 0x10,
-/// \brief This flags signals that an argument is the first one relating to
-/// a map/private clause expression. For some cases a single
-/// map/privatization results in multiple arguments passed to the runtime
-/// library.
-OMP_MAP_FIRST_REF = 0x20,
+/// \brief The element being mapped is a pointer-pointee pair; both the
+/// pointer and the pointee should be mapped.
+OMP_MAP_PTR_AND_OBJ = 0x10,
+/// \brief This flags signals that the base address of an entry should be
+/// passed to the target kernel as an argument.
+OMP_MAP_TARGET_PARAM = 0x20,
 /// \brief Signal that the runtime library has to return the device pointer
-/// in the current position for the data being mapped.
-OMP_MAP_RETURN_PTR = 0x40,
+/// in the current position for the data being mapped. Used when we have the
+/// use_device_ptr clause.
+OMP_MAP_RETURN_PARAM = 0x40,
 /// \brief This flag signals that the reference being passed is a pointer to
 /// private data.
-OMP_MAP_PRIVATE_PTR = 0x80,
+OMP_MAP_PRIVATE = 0x80,
 /// \brief Pass the element to the device by value.
-OMP_MAP_PRIVATE_VAL = 0x100,
+OMP_MAP_LITERAL = 0x100,
 /// Implicit map
 OMP_MAP_IMPLICIT = 0x200,
   };
@@ -6084,7 +6083,7 @@
   /// expression.
   unsigned getMapTypeBits(OpenMPMapClauseKind MapType,
   OpenMPMapClauseKind MapTypeModifier, bool AddPtrFlag,
-  bool AddIsFirstFlag) const {
+  bool AddIsTargetParamFlag) const {
 unsigned Bits = 0u;
 switch (MapType) {
 case OMPC_MAP_alloc:
@@ -6111,9 +6110,9 @@
   break;
 }
 if (AddPtrFlag)
-  Bits |= OMP_MAP_IS_PTR;
-if (AddIsFirstFlag)
-  Bits |= OMP_MAP_FIRST_REF;
+  Bits |= OMP_MAP_PTR_AND_OBJ;
+if (AddIsTargetParamFlag)
+  Bits |= OMP_MAP_TARGET_PARAM;
 if (MapTypeModifier == OMPC_MAP_always)
   Bits |= OMP_MAP_ALWAYS;
 return Bits;
@@ -6220,28 +6219,28 @@
 //
 // map(s.p[:22], s.a s.b)
 // &s, &(s.p), sizeof(double*), noflags
-// &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag + extra_flag
+// &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag
 //
 // map(s.ps)
 // &s, &(s.ps), sizeof(S2*), noflags
 //
 // map(s.ps->s.i)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag
 //
 // map(s.ps->ps)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
 //
 // map(s.ps->ps->ps)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-// &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+// &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag
 //
 // map(s.ps->ps->s.f[:22])
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-// &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+// &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag
 //
 // map(ps)
 // &ps, &ps, sizeof(S2*), noflags
@@ -6257,29 +6256,28 @@
 //
 // map(ps->p[:22])
 // ps, &(ps->p), sizeof(double*), noflags
-// &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag + extra_flag
+// &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag
 //
 // map(ps->ps)
 // ps, &(ps->ps), sizeof(S2*), noflags
 //
 // map(ps->ps->s.i)
 // ps, &(ps->ps), sizeof(S2*), noflags
-// &(ps->ps), &(ps->ps->s.i), sizeof(int), ptr_flag + extra_flag
+// &(ps->ps), &(ps->ps->s.i), sizeof(int), ptr_flag
 //
 // map(ps->ps->ps)
 // ps, &(ps->ps), sizeof(S2*), noflags
-// &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(ps->ps

r317599 - [refactor] rename field references in __builtin_offsetof

2017-11-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov  7 10:30:23 2017
New Revision: 317599

URL: http://llvm.org/viewvc/llvm-project?rev=317599&view=rev
Log:
[refactor] rename field references in __builtin_offsetof

rdar://33875453

Added:
cfe/trunk/test/Refactor/LocalRename/BuiltinOffsetof.cpp
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h?rev=317599&r1=317598&r2=317599&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h Tue 
Nov  7 10:30:23 2017
@@ -70,6 +70,18 @@ public:
 return visit(Expr->getFoundDecl().getDecl(), Expr->getMemberLoc());
   }
 
+  bool VisitOffsetOfExpr(const OffsetOfExpr *S) {
+for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
+  const OffsetOfNode &Component = S->getComponent(I);
+  if (Component.getKind() == OffsetOfNode::Field) {
+if (!visit(Component.getField(), Component.getLocEnd()))
+  return false;
+  }
+  // FIXME: Try to resolve dependent field references.
+}
+return true;
+  }
+
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {

Added: cfe/trunk/test/Refactor/LocalRename/BuiltinOffsetof.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/LocalRename/BuiltinOffsetof.cpp?rev=317599&view=auto
==
--- cfe/trunk/test/Refactor/LocalRename/BuiltinOffsetof.cpp (added)
+++ cfe/trunk/test/Refactor/LocalRename/BuiltinOffsetof.cpp Tue Nov  7 10:30:23 
2017
@@ -0,0 +1,32 @@
+// RUN: clang-refactor local-rename -selection=test:%s -new-name=bar %s -- | 
grep -v CHECK | FileCheck %s
+
+struct Struct {
+  int /*range f=*/field;
+};
+
+struct Struct2 {
+  Struct /*range array=*/array[4][2];
+};
+
+void foo() {
+  (void)__builtin_offsetof(Struct, /*range f=*/field);
+  (void)__builtin_offsetof(Struct2, /*range array=*/array[1][0]./*range 
f=*/field);
+}
+
+#define OFFSET_OF_(X, Y) __builtin_offsetof(X, Y)
+
+class SubclassOffsetof : public Struct {
+  void foo() {
+(void)OFFSET_OF_(SubclassOffsetof, field);
+  }
+};
+
+// CHECK: 2 'array' results:
+// CHECK: Struct /*range array=*/bar[4][2];
+// CHECK: __builtin_offsetof(Struct2, /*range array=*/bar[1][0]./*range 
f=*/field);
+
+// CHECK: 3 'f' results:
+// CHECK: int /*range f=*/bar;
+// CHECK: __builtin_offsetof(Struct, /*range f=*/bar);
+// CHECK-NEXT: __builtin_offsetof(Struct2, /*range array=*/array[1][0]./*range 
f=*/bar);
+// CHECK: OFFSET_OF_(SubclassOffsetof, bar);


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


r317598 - Clang/libomptarget map interface flag renaming - NFC patch

2017-11-07 Thread George Rokos via cfe-commits
Author: grokos
Date: Tue Nov  7 10:27:04 2017
New Revision: 317598

URL: http://llvm.org/viewvc/llvm-project?rev=317598&view=rev
Log:
Clang/libomptarget map interface flag renaming - NFC patch

This patch renames some of the flag names of the clang/libomptarget map 
interface. The old names are slightly misleading, whereas the new ones describe 
in a better way what each flag is about.

Only the macros within the enumeration are renamed, there is no change in 
functionality therefore there are no updated regression tests.

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


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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=317598&r1=317597&r2=317598&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Nov  7 10:27:04 2017
@@ -5978,22 +5978,21 @@ public:
 /// \brief Delete the element from the device environment, ignoring the
 /// current reference count associated with the element.
 OMP_MAP_DELETE = 0x08,
-/// \brief The element being mapped is a pointer, therefore the pointee
-/// should be mapped as well.
-OMP_MAP_IS_PTR = 0x10,
-/// \brief This flags signals that an argument is the first one relating to
-/// a map/private clause expression. For some cases a single
-/// map/privatization results in multiple arguments passed to the runtime
-/// library.
-OMP_MAP_FIRST_REF = 0x20,
+/// \brief The element being mapped is a pointer-pointee pair; both the
+/// pointer and the pointee should be mapped.
+OMP_MAP_PTR_AND_OBJ = 0x10,
+/// \brief This flags signals that the base address of an entry should be
+/// passed to the target kernel as an argument.
+OMP_MAP_TARGET_PARAM = 0x20,
 /// \brief Signal that the runtime library has to return the device pointer
-/// in the current position for the data being mapped.
-OMP_MAP_RETURN_PTR = 0x40,
+/// in the current position for the data being mapped. Used when we have 
the
+/// use_device_ptr clause.
+OMP_MAP_RETURN_PARAM = 0x40,
 /// \brief This flag signals that the reference being passed is a pointer 
to
 /// private data.
-OMP_MAP_PRIVATE_PTR = 0x80,
+OMP_MAP_PRIVATE = 0x80,
 /// \brief Pass the element to the device by value.
-OMP_MAP_PRIVATE_VAL = 0x100,
+OMP_MAP_LITERAL = 0x100,
 /// Implicit map
 OMP_MAP_IMPLICIT = 0x200,
   };
@@ -6084,7 +6083,7 @@ private:
   /// expression.
   unsigned getMapTypeBits(OpenMPMapClauseKind MapType,
   OpenMPMapClauseKind MapTypeModifier, bool AddPtrFlag,
-  bool AddIsFirstFlag) const {
+  bool AddIsTargetParamFlag) const {
 unsigned Bits = 0u;
 switch (MapType) {
 case OMPC_MAP_alloc:
@@ -6111,9 +6110,9 @@ private:
   break;
 }
 if (AddPtrFlag)
-  Bits |= OMP_MAP_IS_PTR;
-if (AddIsFirstFlag)
-  Bits |= OMP_MAP_FIRST_REF;
+  Bits |= OMP_MAP_PTR_AND_OBJ;
+if (AddIsTargetParamFlag)
+  Bits |= OMP_MAP_TARGET_PARAM;
 if (MapTypeModifier == OMPC_MAP_always)
   Bits |= OMP_MAP_ALWAYS;
 return Bits;
@@ -6220,28 +6219,28 @@ private:
 //
 // map(s.p[:22], s.a s.b)
 // &s, &(s.p), sizeof(double*), noflags
-// &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag + extra_flag
+// &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag
 //
 // map(s.ps)
 // &s, &(s.ps), sizeof(S2*), noflags
 //
 // map(s.ps->s.i)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag
 //
 // map(s.ps->ps)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
 //
 // map(s.ps->ps->ps)
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-// &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+// &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag
 //
 // map(s.ps->ps->s.f[:22])
 // &s, &(s.ps), sizeof(S2*), noflags
-// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-// &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag + 
extra_flag
+// &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+// &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag
 //
 // map(ps)
 // &ps, &ps, sizeof(S2*), noflags
@@ -6257,29 +6256,28 @@ private:
 //
 // map(ps->p[:22])
 // ps, &(ps->p), sizeof(double*), noflags
-// &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag + extra_flag
+//

[PATCH] D39738: [clangd] Sort completion results.

2017-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D39738



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


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added a comment.
This revision is now accepted and ready to land.

BTW I'm still trying to get caught up, so if there's some review or something 
you have in flight that you want me to get to first, just let me know.


https://reviews.llvm.org/D39748



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


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Also btw I still think I want to back out the "long-double-is-f128" ABI from 
wasm. But either way it probably doesn't hurt to have these in compiler-rt.


https://reviews.llvm.org/D39748



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


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

I guess if we make that change we can revert this one?


https://reviews.llvm.org/D39748



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


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Yeah. Or not;  I think you can still use `__float128` types in clang, so if you 
did that then it would use these methods too. And as long as `long double` is 
f64 then none of these functions would get pulled into every program that uses 
printf (which is the case now), so it wouldn't impose any cost on anyone that 
doesn't actually use f128. So in that case there's not really a reason not to 
have it.


https://reviews.llvm.org/D39748



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


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

My guess was that it was "long-double-is-f128" that was causing clang to 
generate references to these symbols, but I wasn't totally sure.. its only 
aarch64 and mips64 that seem to require these thus far.


https://reviews.llvm.org/D39748



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


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317601: [WebAssembly] Include GENERIC_TF_SOURCES in wasm 
builds (authored by sbc).

Repository:
  rL LLVM

https://reviews.llvm.org/D39748

Files:
  compiler-rt/trunk/lib/builtins/CMakeLists.txt


Index: compiler-rt/trunk/lib/builtins/CMakeLists.txt
===
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt
@@ -454,8 +454,12 @@
 set(mips64el_SOURCES ${GENERIC_TF_SOURCES}
  ${mips_SOURCES})
 
-set(wasm32_SOURCES ${GENERIC_SOURCES})
-set(wasm64_SOURCES ${GENERIC_SOURCES})
+set(wasm32_SOURCES
+  ${GENERIC_TF_SOURCES}
+  ${GENERIC_SOURCES})
+set(wasm64_SOURCES
+  ${GENERIC_TF_SOURCES}
+  ${GENERIC_SOURCES})
 
 add_custom_target(builtins)
 set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")


Index: compiler-rt/trunk/lib/builtins/CMakeLists.txt
===
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt
@@ -454,8 +454,12 @@
 set(mips64el_SOURCES ${GENERIC_TF_SOURCES}
  ${mips_SOURCES})
 
-set(wasm32_SOURCES ${GENERIC_SOURCES})
-set(wasm64_SOURCES ${GENERIC_SOURCES})
+set(wasm32_SOURCES
+  ${GENERIC_TF_SOURCES}
+  ${GENERIC_SOURCES})
+set(wasm64_SOURCES
+  ${GENERIC_TF_SOURCES}
+  ${GENERIC_SOURCES})
 
 add_custom_target(builtins)
 set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39748: [WebAssembly] Include GENERIC_TF_SOURCES

2017-11-07 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Yes; in particular, musl's implementation of printf has some code where it 
promotes everything to long double, so if long double is f128, that causes 
several of these functions to get linked in to every binary, for no real 
benefit to the user.


Repository:
  rL LLVM

https://reviews.llvm.org/D39748



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


[PATCH] D39751: [libc++] Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

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

The commit r300140 changed the implementation of __compressed_pair, but didn't 
add _LIBCPP_INLINE_VISIBILITY to the constructors and `get` members of the 
__compressed_pair_elem class. This patch adds the visibility annotation.

I'm not sure how to test this (and if it's possible to test this change). Could 
you please let me know if it's possible to add libc++ test for this patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D39751

Files:
  include/memory


Index: include/memory
===
--- include/memory
+++ include/memory
@@ -2040,11 +2040,12 @@
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 


Index: include/memory
===
--- include/memory
+++ include/memory
@@ -2040,11 +2040,12 @@
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lis

[PATCH] D39332: [clang-refactor] Introduce a new rename rule for qualified symbols

2017-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 121941.
hokein added a comment.

- remove USRRenameRule
- rebase to master


https://reviews.llvm.org/D39332

Files:
  include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  lib/Tooling/Refactoring/RefactoringActions.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/QualifiedRename.cpp
  tools/clang-refactor/ClangRefactor.cpp

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -257,20 +257,19 @@
   RefactoringActionRules ActionRules,
   cl::OptionCategory &Category)
   : SubCommand(Action->getCommand(), Action->getDescription()),
-Action(std::move(Action)), ActionRules(std::move(ActionRules)),
-HasSelection(false) {
+Action(std::move(Action)), ActionRules(std::move(ActionRules)) {
 // Check if the selection option is supported.
 for (const auto &Rule : this->ActionRules) {
-  if ((HasSelection = Rule->hasSelectionRequirement()))
+  if (Rule->hasSelectionRequirement()) {
+Selection = llvm::make_unique>(
+"selection",
+cl::desc(
+"The selected source range in which the refactoring should "
+"be initiated (::-: or "
+"::)"),
+cl::cat(Category), cl::sub(*this));
 break;
-}
-if (HasSelection) {
-  Selection = llvm::make_unique>(
-  "selection",
-  cl::desc("The selected source range in which the refactoring should "
-   "be initiated (::-: or "
-   "::)"),
-  cl::cat(Category), cl::sub(*this));
+  }
 }
 // Create the refactoring options.
 for (const auto &Rule : this->ActionRules) {
@@ -284,21 +283,18 @@
 
   const RefactoringActionRules &getActionRules() const { return ActionRules; }
 
-  /// Parses the command-line arguments that are specific to this rule.
+  /// Parses the "-selection" command-line argument.
   ///
   /// \returns true on error, false otherwise.
-  bool parseArguments() {
+  bool parseSelectionArgument() {
 if (Selection) {
   ParsedSelection = SourceSelectionArgument::fromString(*Selection);
   if (!ParsedSelection)
 return true;
 }
 return false;
   }
 
-  // Whether the selection is supported by any rule in the subcommand.
-  bool hasSelection() const { return HasSelection; }
-
   SourceSelectionArgument *getSelection() const {
 assert(Selection && "selection not supported!");
 return ParsedSelection.get();
@@ -314,8 +310,6 @@
   std::unique_ptr> Selection;
   std::unique_ptr ParsedSelection;
   RefactoringActionCommandLineOptions Options;
-  // Whether the selection is supported by any rule in the subcommand.
-  bool HasSelection;
 };
 
 class ClangRefactorConsumer final : public ClangRefactorToolConsumerInterface {
@@ -403,28 +397,33 @@
 // If the selection option is test specific, we use a test-specific
 // consumer.
 std::unique_ptr TestConsumer;
-if (SelectedSubcommand->hasSelection())
+bool HasSelection = MatchingRule->hasSelectionRequirement();
+if (HasSelection)
   TestConsumer = SelectedSubcommand->getSelection()->createCustomConsumer();
 ClangRefactorToolConsumerInterface *ActiveConsumer =
 TestConsumer ? TestConsumer.get() : Consumer.get();
 ActiveConsumer->beginTU(AST);
-// FIXME (Alex L): Implement non-selection based invocation path.
-if (SelectedSubcommand->hasSelection()) {
+
+auto InvokeRule = [&](RefactoringResultConsumer &Consumer) {
+  if (opts::Verbose)
+logInvocation(*SelectedSubcommand, Context);
+  MatchingRule->invoke(*ActiveConsumer, Context);
+};
+if (HasSelection) {
   assert(SelectedSubcommand->getSelection() &&
  "Missing selection argument?");
   if (opts::Verbose)
 SelectedSubcommand->getSelection()->print(llvm::outs());
   if (SelectedSubcommand->getSelection()->forAllRanges(
   Context.getSources(), [&](SourceRange R) {
 Context.setSelectionRange(R);
-if (opts::Verbose)
-  logInvocation(*SelectedSubcommand, Context);
-MatchingRule->invoke(*ActiveConsumer, Context);
+InvokeRule(*ActiveConsumer);
   }))
 HasFailed = true;
   ActiveConsumer->endTU();
   return;
 }
+InvokeRule(*ActiveConsumer);
 ActiveConsumer->endTU();
   }
 
@@ -529,23 +528,24 @@
   }
 
   llvm::Expected
-  getMatchingRule(const RefactoringActionSubcommand &Subcommand) {
+  getMatchingRule(RefactoringActionSubcommand &Subcommand) {
 SmallVector MatchingRules;
 llvm::StringSet<> MissingOptions;
 
 for (const auto &Rule : Subcommand.getActionRules()) {
-  bool SelectionMatches = true;
-  if (Rule

[PATCH] D39332: [clang-refactor] Introduce a new rename rule for qualified symbols

2017-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:101
+  std::string NewQualifiedName) {
+  return QualifiedRenameRule(std::move(OldQualifiedName),
+ std::move(NewQualifiedName));

arphaman wrote:
> sammccall wrote:
> > hokein wrote:
> > > arphaman wrote:
> > > > ioeric wrote:
> > > > > hokein wrote:
> > > > > > arphaman wrote:
> > > > > > > It might be better to find the declaration (and report error if 
> > > > > > > needed) during in initiation, and then pass the `ND` to the 
> > > > > > > class. Maybe then both `RenameOccurrences` and 
> > > > > > > `QualifiedRenameRule` could subclass from one base class that 
> > > > > > > actually does just this:
> > > > > > > 
> > > > > > > ``` 
> > > > > > > auto USRs = getUSRsForDeclaration(ND, Context.getASTContext());
> > > > > > >   assert(!USRs.empty());
> > > > > > >   return tooling::createRenameAtomicChanges(
> > > > > > >   USRs, NewQualifiedName, 
> > > > > > > Context.getASTContext().getTranslationUnitDecl());
> > > > > > > ```
> > > > > > Done. Introduced a common interface `USRRenameRule`.
> > > > > `USRRenameRule` doesn't seem to be a very useful abstraction. I think 
> > > > > what Alex proposed is a base class that implements 
> > > > > `createSourceReplacements` which could be shared by both 
> > > > > `RenameOccurrences` and `QualifiedRenameRule`. Intuitively, 
> > > > > un-qualified rename is a special case of qualified rename (maybe?), 
> > > > > where namespace is not changed.
> > > > Yep, I meant that indeed.
> > > Ah, sorry for the misunderstanding. 
> > > 
> > > Unfortunately, `RenameOccurrences` and `QualifiedRenameRule` could not 
> > > share the same `createSourceReplacements` implementation, 
> > > 
> > > * Their supported use cases are different. `QualifiedRenameRule` only 
> > > supports renaming class, function, enums, alias and class members, which 
> > > doesn't cover all the cases of `RenameOccurrences` (like renaming local 
> > > variable in function body).
> > > 
> > > * we have separated implementations in the code 
> > > base(`createRenameAtomicChanges` for qualified rename, 
> > > `createRenameReplacements` for un-qualified rename). The implementation 
> > > of qualified rename does more things, including calculating the shortest 
> > > prefix qualifiers, getting correct range of replacement.  
> > > 
> > > 
> > That makes sense (I think), but then we should remove  `USRRenameRule` 
> > again if we're not actually reusing anything.
> > 
> > (And ideally we can hide any such future reuse as functions in the cc file, 
> > rather than a class hierarchy exposed in the header)
> ok, that's fine for now then.
Done. Reverted it back. 



Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:104
+  if (!ND)
+return llvm::make_error("Could not find symbol " +
+   OldQualifiedName,

arphaman wrote:
> You can use a refactoring diagnostic here (see `RenameOccurrences::initiate`).
I think using StringError is sufficient here -- didn't see much value using 
diagnostic:

1. we need to add a new diagnostic type `clang_refactor_no_symbol`.
2. we can't include the detailed information (`OldQualifiedName`) in the 
diagnostic, and we don't have SourceLocation in the code for the diagnostic.


https://reviews.llvm.org/D39332



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


r317605 - New clang option -fno-plt which avoids the PLT and lazy binding while making external calls.

2017-11-07 Thread Sriraman Tallam via cfe-commits
Author: tmsriram
Date: Tue Nov  7 11:37:51 2017
New Revision: 317605

URL: http://llvm.org/viewvc/llvm-project?rev=317605&view=rev
Log:
New clang option -fno-plt which avoids the PLT and lazy binding while making 
external calls.

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

Added:
cfe/trunk/test/CodeGen/noplt.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=317605&r1=317604&r2=317605&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Nov  7 11:37:51 2017
@@ -1384,6 +1384,10 @@ def fpic : Flag<["-"], "fpic">, Group, Group;
 def fpie : Flag<["-"], "fpie">, Group;
 def fno_pie : Flag<["-"], "fno-pie">, Group;
+def fplt : Flag<["-"], "fplt">, Group, Flags<[CC1Option]>,
+  HelpText<"Use the PLT to make function calls">;
+def fno_plt : Flag<["-"], "fno-plt">, Group, Flags<[CC1Option]>,
+  HelpText<"Do not use the PLT to make function calls">;
 def fropi : Flag<["-"], "fropi">, Group;
 def fno_ropi : Flag<["-"], "fno-ropi">, Group;
 def frwpi : Flag<["-"], "frwpi">, Group;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=317605&r1=317604&r2=317605&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue Nov  7 11:37:51 2017
@@ -297,6 +297,8 @@ CODEGENOPT(PreserveVec3Type, 1, 0)
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
 CODEGENOPT(GnuPubnames, 1, 0)
 
+CODEGENOPT(NoPLT, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=317605&r1=317604&r2=317605&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Nov  7 11:37:51 2017
@@ -1855,6 +1855,16 @@ void CodeGenModule::ConstructAttributeLi
   !(TargetDecl && TargetDecl->hasAttr()))
 FuncAttrs.addAttribute("split-stack");
 
+  // Add NonLazyBind attribute to function declarations when -fno-plt
+  // is used.
+  if (TargetDecl && CodeGenOpts.NoPLT) {
+if (auto *Fn = dyn_cast(TargetDecl)) {
+  if (!Fn->isDefined() && !AttrOnCallSite) {
+FuncAttrs.addAttribute(llvm::Attribute::NonLazyBind);
+  }
+}
+  }
+
   if (!AttrOnCallSite) {
 bool DisableTailCalls =
 CodeGenOpts.DisableTailCalls ||

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=317605&r1=317604&r2=317605&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Nov  7 11:37:51 2017
@@ -3423,6 +3423,10 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-mpie-copy-relocations");
   }
 
+  if (Args.hasFlag(options::OPT_fno_plt, options::OPT_fplt, false)) {
+CmdArgs.push_back("-fno-plt");
+  }
+
   // -fhosted is default.
   // TODO: Audit uses of KernelOrKext and see where it'd be more appropriate to
   // use Freestanding.

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=317605&r1=317604&r2=317605&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Nov  7 11:37:51 2017
@@ -653,6 +653,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Args.hasArg(OPT_mincremental_linker_compatible);
   Opts.PIECopyRelocations =
   Args.hasArg(OPT_mpie_copy_relocations);
+  Opts.NoPLT = Args.hasArg(OPT_fno_plt);
   Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
   Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
   Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);

Added: cfe/trunk/test/CodeGen/noplt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/noplt.c?rev=317605&view=auto
==
--- cfe/trunk/test/CodeGen/noplt.c (added)
+++ cfe/trunk/test/CodeGen/noplt.c Tue Nov  7 11:37:51 2017
@@ -0,0 +1,9 

[PATCH] D39079: New clang option -fno-plt to avoid PLT for external calls

2017-11-07 Thread Sriraman Tallam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317605: New clang option -fno-plt which avoids the PLT and 
lazy binding while making… (authored by tmsriram).

Changed prior to commit:
  https://reviews.llvm.org/D39079?vs=119950&id=121947#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39079

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/noplt.c


Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -297,6 +297,8 @@
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
 CODEGENOPT(GnuPubnames, 1, 0)
 
+CODEGENOPT(NoPLT, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1384,6 +1384,10 @@
 def fno_pic : Flag<["-"], "fno-pic">, Group;
 def fpie : Flag<["-"], "fpie">, Group;
 def fno_pie : Flag<["-"], "fno-pie">, Group;
+def fplt : Flag<["-"], "fplt">, Group, Flags<[CC1Option]>,
+  HelpText<"Use the PLT to make function calls">;
+def fno_plt : Flag<["-"], "fno-plt">, Group, Flags<[CC1Option]>,
+  HelpText<"Do not use the PLT to make function calls">;
 def fropi : Flag<["-"], "fropi">, Group;
 def fno_ropi : Flag<["-"], "fno-ropi">, Group;
 def frwpi : Flag<["-"], "frwpi">, Group;
Index: cfe/trunk/test/CodeGen/noplt.c
===
--- cfe/trunk/test/CodeGen/noplt.c
+++ cfe/trunk/test/CodeGen/noplt.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
+
+// CHECK-NOPLT: Function Attrs: nonlazybind
+// CHECK-NOPLT-NEXT: declare i32 @foo
+int foo();
+
+int bar() {
+  return foo();
+}
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -653,6 +653,7 @@
   Args.hasArg(OPT_mincremental_linker_compatible);
   Opts.PIECopyRelocations =
   Args.hasArg(OPT_mpie_copy_relocations);
+  Opts.NoPLT = Args.hasArg(OPT_fno_plt);
   Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
   Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
   Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1855,6 +1855,16 @@
   !(TargetDecl && TargetDecl->hasAttr()))
 FuncAttrs.addAttribute("split-stack");
 
+  // Add NonLazyBind attribute to function declarations when -fno-plt
+  // is used.
+  if (TargetDecl && CodeGenOpts.NoPLT) {
+if (auto *Fn = dyn_cast(TargetDecl)) {
+  if (!Fn->isDefined() && !AttrOnCallSite) {
+FuncAttrs.addAttribute(llvm::Attribute::NonLazyBind);
+  }
+}
+  }
+
   if (!AttrOnCallSite) {
 bool DisableTailCalls =
 CodeGenOpts.DisableTailCalls ||
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3423,6 +3423,10 @@
 CmdArgs.push_back("-mpie-copy-relocations");
   }
 
+  if (Args.hasFlag(options::OPT_fno_plt, options::OPT_fplt, false)) {
+CmdArgs.push_back("-fno-plt");
+  }
+
   // -fhosted is default.
   // TODO: Audit uses of KernelOrKext and see where it'd be more appropriate to
   // use Freestanding.


Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -297,6 +297,8 @@
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
 CODEGENOPT(GnuPubnames, 1, 0)
 
+CODEGENOPT(NoPLT, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1384,6 +1384,10 @@
 def fno_pic : Flag<["-"], "fno-pic">, Group;
 def fpie : Flag<["-"], "fpie">, Group;
 def fno_pie : Flag<["-"], "fno-pie">, Group;
+def fplt : Flag<["-"], "fplt">, Group, Flags<[CC1Option]>,
+  HelpText<"Use the PLT to 

[PATCH] D39611: [CodeGen] change const-ness of complex calls

2017-11-07 Thread Sanjay Patel via Phabricator via cfe-commits
spatel updated this revision to Diff 121949.
spatel retitled this revision from "[CodeGen] make cbrt and fma constant (never 
set errno); document complex calls as always constant" to "[CodeGen] change 
const-ness of complex calls".
spatel edited the summary of this revision.
spatel added a comment.

Patch updated:
I don't know if we have agreement on the behavior that we want yet, but I'm 
updating the patch/description/title to only deal with  in this patch 
and taking a shot at one interpretation, so we can see what that might look 
like.

There are really 2 changes here:

1. We had all of  marked constant all the time ('c'). I think there's 
agreement that can't be true by default (a platform could set errno on any of 
these calls based on the language in the C standard).
2. We make an exception for a GNU environment - here, the calls are always 
constant because the standard allows - and POSIX constrains - the errno setting 
behavior. This is despite the fact that glibc is known to set errno in some 
cases.


https://reviews.llvm.org/D39611

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/complex-builtins.c
  test/CodeGen/complex-libcalls.c

Index: test/CodeGen/complex-libcalls.c
===
--- test/CodeGen/complex-libcalls.c
+++ test/CodeGen/complex-libcalls.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s --check-prefix=NO__ERRNO
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm  %s | FileCheck %s --check-prefix=NO__ERRNO
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=NO__ERRNO
 
 // Test attributes and builtin codegen of complex library calls. 
 
@@ -9,98 +11,98 @@
 // NO__ERRNO: declare double @cabs(double, double) [[READNONE:#[0-9]+]]
 // NO__ERRNO: declare float @cabsf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE:#[0-9+]]]
-// HAS_ERRNO: declare double @cabs(double, double) [[READNONE:#[0-9]+]]
-// HAS_ERRNO: declare float @cabsf(<2 x float>) [[READNONE]]
-// HAS_ERRNO: declare x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE:#[0-9]+]]
+// HAS_ERRNO: declare double @cabs(double, double) [[NOT_READNONE:#[0-9]+]]
+// HAS_ERRNO: declare float @cabsf(<2 x float>) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE]]
 
   cacos(f);  cacosf(f); cacosl(f);
 
 // NO__ERRNO: declare { double, double } @cacos(double, double) [[READNONE]]
 // NO__ERRNO: declare <2 x float> @cacosf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cacosl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @cacos(double, double) [[READNONE]]
-// HAS_ERRNO: declare <2 x float> @cacosf(<2 x float>) [[READNONE]]
+// HAS_ERRNO: declare { double, double } @cacos(double, double) [[NOT_READNONE]]
+// HAS_ERRNO: declare <2 x float> @cacosf(<2 x float>) [[NOT_READNONE]]
 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cacosl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE]]
 
   cacosh(f); cacoshf(f);cacoshl(f);
 
 // NO__ERRNO: declare { double, double } @cacosh(double, double) [[READNONE]]
 // NO__ERRNO: declare <2 x float> @cacoshf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cacoshl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @cacosh(double, double) [[READNONE]]
-// HAS_ERRNO: declare <2 x float> @cacoshf(<2 x float>) [[READNONE]]
+// HAS_ERRNO: declare { double, double } @cacosh(double, double) [[NOT_READNONE]]
+// HAS_ERRNO: declare <2 x float> @cacoshf(<2 x float>) [[NOT_READNONE]]
 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cacoshl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE]]
 
   carg(f);   cargf(f);  cargl(f);
 
 // NO__ERRNO: declare double @carg(double, double) [[READNONE]]
 // NO__ERRNO: declare float @cargf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cargl({ x86_fp80, x86_fp80 }* byval align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare double @carg(double, double) [[READNONE]]
-// HAS_ERRNO: declare float @cargf(<2 x float>) [[READNONE]]
+// HAS_ERRNO: declare double @carg(double, double) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @cargf(<2 x float>) [[NOT_READNONE]]

Re: [clang-tools-extra] r317553 - [clangd] fix MSVC build errors

2017-11-07 Thread Galina Kistanova via cfe-commits
Hello Sam,

It looks like this commit broke the builder:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13313

. . .
FAILED:
tools/clang/tools/extra/unittests/clangd/CMakeFiles/ClangdTests.dir/JSONExprTests.cpp.obj

Please have a look?

Thanks

Galina


On Tue, Nov 7, 2017 at 12:57 AM, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Tue Nov  7 00:57:54 2017
> New Revision: 317553
>
> URL: http://llvm.org/viewvc/llvm-project?rev=317553&view=rev
> Log:
> [clangd] fix MSVC build errors
>
> Modified:
> clang-tools-extra/trunk/clangd/JSONExpr.cpp
> clang-tools-extra/trunk/clangd/JSONExpr.h
>
> Modified: clang-tools-extra/trunk/clangd/JSONExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/JSONExpr.cpp?rev=317553&r1=317552&r2=317553&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/JSONExpr.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONExpr.cpp Tue Nov  7 00:57:54 2017
> @@ -2,10 +2,10 @@
>
>  #include "llvm/Support/Format.h"
>
> +using namespace llvm;
>  namespace clang {
>  namespace clangd {
>  namespace json {
> -using namespace llvm;
>
>  void Expr::copyFrom(const Expr &M) {
>Type = M.Type;
>
> Modified: clang-tools-extra/trunk/clangd/JSONExpr.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/JSONExpr.h?rev=317553&r1=317552&r2=317553&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/JSONExpr.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONExpr.h Tue Nov  7 00:57:54 2017
> @@ -154,7 +154,7 @@ public:
>  ObjectKey(const llvm::formatv_object_base &V) : ObjectKey(V.str()) {}
>
>  ObjectKey(const ObjectKey &C) { *this = C; }
> -ObjectKey(ObjectKey &&C) = default;
> +ObjectKey(ObjectKey &&C) : ObjectKey(static_cast &&>(C)) {}
>  ObjectKey &operator=(const ObjectKey &C) {
>if (C.Owned) {
>  Owned.reset(new std::string(*C.Owned));
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r317610 - Change test suite to support c++17 dialect flag instead of c++1z.

2017-11-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Nov  7 12:20:58 2017
New Revision: 317610

URL: http://llvm.org/viewvc/llvm-project?rev=317610&view=rev
Log:
Change test suite to support c++17 dialect flag instead of c++1z.

This patch changes the test suite to attempt and prefer -std=c++17 over
-std=c++1z. It also fixes the REQUIRES and UNSUPPORTED lit markers
to refer to c++17 over c++1z.

Modified:
libcxx/trunk/docs/TestingLibcxx.rst

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=317610&r1=317609&r2=317610&view=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Tue Nov  7 12:20:58 2017
@@ -112,7 +112,7 @@ configuration. Passing the option on the
 
 .. option:: std=
 
-  **Values**: c++98, c++03, c++11, c++14, c++1z
+  **Values**: c++98, c++03, c++11, c++14, c++17
 
   Change the standard version used when building the tests.
 

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp?rev=317610&r1=317609&r2=317610&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 Tue Nov  7 12:20:58 2017
@@ -9,7 +9,7 @@
 
 // Usage of is_trivially_constructible is broken with these compilers.
 // See https://bugs.llvm.org/show_bug.cgi?id=31016
-// XFAIL: clang-3.7, apple-clang-7 && c++1z
+// XFAIL: clang-3.7, apple-clang-7 && c++17
 
 // 
 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp?rev=317610&r1=317609&r2=317610&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
 Tue Nov  7 12:20:58 2017
@@ -12,7 +12,7 @@
 // Note that sized delete operator definitions below are simply ignored
 // when sized deallocation is not supported, e.g., prior to C++14.
 
-// UNSUPPORTED: c++14, c++1z
+// UNSUPPORTED: c++14, c++17
 // UNSUPPORTED: sanitizer-new-delete
 
 #include 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp?rev=317610&r1=317609&r2=317610&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
 Tue Nov  7 12:20:58 2017
@@ -12,7 +12,7 @@
 // Note that sized delete operator definitions below are simply ignored
 // when sized deallocation is not supported, e.g., prior to C++14.
 
-// UNSUPPORTED: c++14, c++1z
+// UNSUPPORTED: c++14, c++17
 // UNSUPPORTED: sanitizer-new-delete
 
 #include 

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=317610&r1=317609&r2=317610&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Tue Nov  7 12:20:58 2017
@@ -517,7 +517,7 @@ class Configuration(object):
 std = self.get_lit_conf('std')
 if not std:
 # Choose the newest possible language dialect if none is given.
-possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
+possible_stds = ['c++17', 'c++1z', 'c++14', 'c++11', 'c++03']
 if self.cxx.type == 'gcc':
 maj_v, _, _ = self.cxx.version
 maj_v = int(maj_

[libcxx] r317611 - Teach test suite about C++2a dialect flag.

2017-11-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Nov  7 12:26:23 2017
New Revision: 317611

URL: http://llvm.org/viewvc/llvm-project?rev=317611&view=rev
Log:
Teach test suite about C++2a dialect flag.

This patch teaches the test suite configuration about the -std=c++2a
flag. And, since it's the newest dialect, change the test suite to
choose it, if possible, by default.

Modified:
libcxx/trunk/docs/TestingLibcxx.rst
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=317611&r1=317610&r2=317611&view=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Tue Nov  7 12:26:23 2017
@@ -112,7 +112,7 @@ configuration. Passing the option on the
 
 .. option:: std=
 
-  **Values**: c++98, c++03, c++11, c++14, c++17
+  **Values**: c++98, c++03, c++11, c++14, c++17, c++2a
 
   Change the standard version used when building the tests.
 

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=317611&r1=317610&r2=317611&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Tue Nov  7 12:26:23 2017
@@ -517,7 +517,8 @@ class Configuration(object):
 std = self.get_lit_conf('std')
 if not std:
 # Choose the newest possible language dialect if none is given.
-possible_stds = ['c++17', 'c++1z', 'c++14', 'c++11', 'c++03']
+possible_stds = ['c++2a', 'c++17', 'c++1z', 'c++14', 'c++11',
+ 'c++03']
 if self.cxx.type == 'gcc':
 maj_v, _, _ = self.cxx.version
 maj_v = int(maj_v)
@@ -888,7 +889,7 @@ class Configuration(object):
 # Turn on warnings by default for Clang based compilers when C++ >= 11
 default_enable_warnings = self.cxx.type in ['clang', 'apple-clang'] \
 and len(self.config.available_features.intersection(
-['c++11', 'c++14', 'c++17'])) != 0
+['c++11', 'c++14', 'c++17', 'c++2a'])) != 0
 enable_warnings = self.get_lit_bool('enable_warnings',
 default_enable_warnings)
 self.cxx.useWarnings(enable_warnings)


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


r317620 - [ObjC++] Don't warn about pessimizing move for __block variables

2017-11-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov  7 13:40:11 2017
New Revision: 317620

URL: http://llvm.org/viewvc/llvm-project?rev=317620&view=rev
Log:
[ObjC++] Don't warn about pessimizing move for __block variables

rdar://33316951

Added:
cfe/trunk/test/SemaObjCXX/block-variable-move.mm
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=317620&r1=317619&r2=317620&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Nov  7 13:40:11 2017
@@ -6422,6 +6422,10 @@ static void CheckMoveOnConstruction(Sema
 if (!VD || !VD->hasLocalStorage())
   return;
 
+// __block variables are not moved implicitly.
+if (VD->hasAttr())
+  return;
+
 QualType SourceType = VD->getType();
 if (!SourceType->isRecordType())
   return;

Added: cfe/trunk/test/SemaObjCXX/block-variable-move.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/block-variable-move.mm?rev=317620&view=auto
==
--- cfe/trunk/test/SemaObjCXX/block-variable-move.mm (added)
+++ cfe/trunk/test/SemaObjCXX/block-variable-move.mm Tue Nov  7 13:40:11 2017
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -verify -fblocks 
-Wpessimizing-move -Wredundant-move %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &&move(T &&t);
+}
+}
+
+class MoveOnly {
+public:
+  MoveOnly() { }
+  MoveOnly(MoveOnly &&) = default; // expected-note 2 {{copy constructor is 
implicitly deleted}}
+  MoveOnly &operator=(MoveOnly &&) = default;
+  ~MoveOnly();
+};
+
+void copyInit() {
+  __block MoveOnly temp;
+  MoveOnly temp2 = temp; // expected-error {{call to implicitly-deleted copy 
constructor of 'MoveOnly'}}
+  MoveOnly temp3 = std::move(temp); // ok
+}
+
+MoveOnly errorOnCopy() {
+  __block MoveOnly temp;
+  return temp; // expected-error {{call to implicitly-deleted copy constructor 
of 'MoveOnly'}}
+}
+
+MoveOnly dontWarnOnMove() {
+  __block MoveOnly temp;
+  return std::move(temp); // ok
+}
+
+class MoveOnlySub : public MoveOnly {};
+
+MoveOnly dontWarnOnMoveSubclass() {
+  __block MoveOnlySub temp;
+  return std::move(temp); // ok
+}


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


[PATCH] D39759: Remove x86 specific code from noplt.c

2017-11-07 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram created this revision.

https://reviews.llvm.org/D39079 breaks noplt.c for non-x86 targets.  Remove x86 
specific code from noplt.c


https://reviews.llvm.org/D39759

Files:
  test/CodeGen/noplt.c


Index: test/CodeGen/noplt.c
===
--- test/CodeGen/noplt.c
+++ test/CodeGen/noplt.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
-// CHECK-NOPLT-NEXT: declare i32 @foo
+// CHECK-NOPLT-NEXT: @foo
 int foo();
 
 int bar() {


Index: test/CodeGen/noplt.c
===
--- test/CodeGen/noplt.c
+++ test/CodeGen/noplt.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s -check-prefix=CHECK-NOPLT
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
-// CHECK-NOPLT-NEXT: declare i32 @foo
+// CHECK-NOPLT-NEXT: @foo
 int foo();
 
 int bar() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39717: Always use prctl(PR_SET_PTRACER)

2017-11-07 Thread Mike Hommey via Phabricator via cfe-commits
glandium updated this revision to Diff 121983.
glandium added a comment.

Updated wording.


https://reviews.llvm.org/D39717

Files:
  lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc


Index: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
===
--- lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -57,6 +57,14 @@
 #include "sanitizer_mutex.h"
 #include "sanitizer_placement_new.h"
 
+// Sufficiently old kernel headers don't provide this value, but we can still
+// call prctl with it. If the runtime kernel is new enough, the prctl call will
+// have the desired effect; if the kernel is too old, the call will error and 
we
+// can ignore said error.
+#ifndef PR_SET_PTRACER
+#define PR_SET_PTRACER 0x59616d61
+#endif
+
 // This module works by spawning a Linux task which then attaches to every
 // thread in the caller process with ptrace. This suspends the threads, and
 // PTRACE_GETREGS can then be used to obtain their register state. The callback
@@ -433,9 +441,7 @@
 ScopedSetTracerPID scoped_set_tracer_pid(tracer_pid);
 // On some systems we have to explicitly declare that we want to be traced
 // by the tracer thread.
-#ifdef PR_SET_PTRACER
 internal_prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
-#endif
 // Allow the tracer thread to start.
 tracer_thread_argument.mutex.Unlock();
 // NOTE: errno is shared between this thread and the tracer thread.


Index: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
===
--- lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -57,6 +57,14 @@
 #include "sanitizer_mutex.h"
 #include "sanitizer_placement_new.h"
 
+// Sufficiently old kernel headers don't provide this value, but we can still
+// call prctl with it. If the runtime kernel is new enough, the prctl call will
+// have the desired effect; if the kernel is too old, the call will error and we
+// can ignore said error.
+#ifndef PR_SET_PTRACER
+#define PR_SET_PTRACER 0x59616d61
+#endif
+
 // This module works by spawning a Linux task which then attaches to every
 // thread in the caller process with ptrace. This suspends the threads, and
 // PTRACE_GETREGS can then be used to obtain their register state. The callback
@@ -433,9 +441,7 @@
 ScopedSetTracerPID scoped_set_tracer_pid(tracer_pid);
 // On some systems we have to explicitly declare that we want to be traced
 // by the tracer thread.
-#ifdef PR_SET_PTRACER
 internal_prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
-#endif
 // Allow the tracer thread to start.
 tracer_thread_argument.mutex.Unlock();
 // NOTE: errno is shared between this thread and the tracer thread.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317623 - [NVPTX] Implement __nvvm_atom_add_gen_d builtin.

2017-11-07 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Nov  7 14:10:54 2017
New Revision: 317623

URL: http://llvm.org/viewvc/llvm-project?rev=317623&view=rev
Log:
[NVPTX] Implement __nvvm_atom_add_gen_d builtin.

Summary:
This just seems to have been an oversight.  We already supported the f64
atomic add with an explicit scope (e.g. "cta"), but not the scopeless
version.

Reviewers: tra

Subscribers: jholewinski, sanjoy, cfe-commits, llvm-commits, hiraditya

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

Added:
cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu
Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=317623&r1=317622&r2=317623&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Tue Nov  7 14:10:54 2017
@@ -481,7 +481,7 @@ TARGET_BUILTIN(__nvvm_atom_cta_add_gen_f
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n")
 BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n")
-BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n")
+TARGET_BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", "satom")
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=317623&r1=317622&r2=317623&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Nov  7 14:10:54 2017
@@ -9554,6 +9554,16 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 return Builder.CreateCall(FnALAF32, {Ptr, Val});
   }
 
+  case NVPTX::BI__nvvm_atom_add_gen_d: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+Value *Val = EmitScalarExpr(E->getArg(1));
+// atomicrmw only deals with integer arguments, so we need to use
+// LLVM's nvvm_atomic_load_add_f64 intrinsic.
+Value *FnALAF64 =
+CGM.getIntrinsic(Intrinsic::nvvm_atomic_load_add_f64, Ptr->getType());
+return Builder.CreateCall(FnALAF64, {Ptr, Val});
+  }
+
   case NVPTX::BI__nvvm_atom_inc_gen_ui: {
 Value *Ptr = EmitScalarExpr(E->getArg(0));
 Value *Val = EmitScalarExpr(E->getArg(1));

Added: cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu?rev=317623&view=auto
==
--- cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu (added)
+++ cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu Tue Nov  7 14:10:54 2017
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_60 \
+// RUN:-fcuda-is-device -S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK %s
+//
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 \
+// RUN:   -fcuda-is-device -S -o /dev/null -x cuda -verify %s
+
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+// We have to keep all builtins that depend on particular target feature in the
+// same function, because the codegen will stop after the very first function
+// that encounters an error, so -verify will not be able to find errors in
+// subsequent functions.
+
+// CHECK-LABEL: test_fn
+__device__ void test_fn(double d, double* double_ptr) {
+  // CHECK: call double @llvm.nvvm.atomic.load.add.f64.p0f64
+  // expected-error@+1 {{'__nvvm_atom_add_gen_d' needs target feature satom}}
+  __nvvm_atom_add_gen_d(double_ptr, d);
+}


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


[PATCH] D39638: [NVPTX] Implement __nvvm_atom_add_gen_d builtin.

2017-11-07 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317623: [NVPTX] Implement __nvvm_atom_add_gen_d builtin. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D39638?vs=121620&id=121984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39638

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu
  llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
  llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/trunk/test/CodeGen/NVPTX/atomics-sm60.ll

Index: llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
+++ llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
@@ -683,10 +683,15 @@
   Intrinsic<[llvm_i64_ty], [llvm_double_ty], [IntrNoMem]>;
 
 
-// Atomic not available as an llvm intrinsic.
+// Atomics not available as llvm intrinsics.
   def int_nvvm_atomic_load_add_f32 : Intrinsic<[llvm_float_ty],
   [LLVMAnyPointerType, llvm_float_ty],
   [IntrArgMemOnly, NoCapture<0>]>;
+  // Atomic add of f64 requires sm_60.
+  def int_nvvm_atomic_load_add_f64 : Intrinsic<[llvm_double_ty],
+  [LLVMAnyPointerType, llvm_double_ty],
+  [IntrArgMemOnly, NoCapture<0>]>;
+
   def int_nvvm_atomic_load_inc_32 : Intrinsic<[llvm_i32_ty],
   [LLVMAnyPointerType, llvm_i32_ty],
   [IntrArgMemOnly, NoCapture<0>]>;
Index: llvm/trunk/test/CodeGen/NVPTX/atomics-sm60.ll
===
--- llvm/trunk/test/CodeGen/NVPTX/atomics-sm60.ll
+++ llvm/trunk/test/CodeGen/NVPTX/atomics-sm60.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s -march=nvptx -mcpu=sm_60 | FileCheck %s
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_60 | FileCheck %s
+
+; CHECK-LABEL .func test(
+define void @test(double* %dp0, double addrspace(1)* %dp1, double addrspace(3)* %dp3, double %d) {
+; CHECK: atom.add.f64
+  %r1 = call double @llvm.nvvm.atomic.load.add.f64.p0f64(double* %dp0, double %d)
+; CHECK: atom.global.add.f64
+  %r2 = call double @llvm.nvvm.atomic.load.add.f64.p1f64(double addrspace(1)* %dp1, double %d)
+; CHECK: atom.shared.add.f64
+  %ret = call double @llvm.nvvm.atomic.load.add.f64.p3f64(double addrspace(3)* %dp3, double %d)
+  ret void
+}
+
+declare double @llvm.nvvm.atomic.load.add.f64.p0f64(double* nocapture, double) #1
+declare double @llvm.nvvm.atomic.load.add.f64.p1f64(double addrspace(1)* nocapture, double) #1
+declare double @llvm.nvvm.atomic.load.add.f64.p3f64(double addrspace(3)* nocapture, double) #1
+
+attributes #1 = { argmemonly nounwind }
Index: llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -1095,6 +1095,12 @@
   (int_nvvm_atomic_load_add_f32 node:$a, node:$b)>;
 def atomic_load_add_f32_gen: ATOMIC_GENERIC_CHK<(ops node:$a, node:$b),
   (int_nvvm_atomic_load_add_f32 node:$a, node:$b)>;
+def atomic_load_add_f64_g: ATOMIC_GLOBAL_CHK<(ops node:$a, node:$b),
+  (int_nvvm_atomic_load_add_f64 node:$a, node:$b)>;
+def atomic_load_add_f64_s: ATOMIC_SHARED_CHK<(ops node:$a, node:$b),
+  (int_nvvm_atomic_load_add_f64 node:$a, node:$b)>;
+def atomic_load_add_f64_gen: ATOMIC_GENERIC_CHK<(ops node:$a, node:$b),
+  (int_nvvm_atomic_load_add_f64 node:$a, node:$b)>;
 
 defm INT_PTX_ATOM_ADD_G_32 : F_ATOMIC_2;
@@ -1121,6 +1127,13 @@
 defm INT_PTX_ATOM_ADD_GEN_F32 : F_ATOMIC_2;
 
+defm INT_PTX_ATOM_ADD_G_F64 : F_ATOMIC_2;
+defm INT_PTX_ATOM_ADD_S_F64 : F_ATOMIC_2;
+defm INT_PTX_ATOM_ADD_GEN_F64 : F_ATOMIC_2;
+
 // atom_sub
 
 def atomic_load_sub_32_g: ATOMIC_GLOBAL_CHK<(ops node:$a, node:$b),
Index: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -3449,6 +3449,7 @@
   }
 
   case Intrinsic::nvvm_atomic_load_add_f32:
+  case Intrinsic::nvvm_atomic_load_add_f64:
   case Intrinsic::nvvm_atomic_load_inc_32:
   case Intrinsic::nvvm_atomic_load_dec_32:
 
Index: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
@@ -481,7 +481,7 @@
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n")
 BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n")
-BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n")
+TARGET_BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_a

[PATCH] D39762: [ObjC] Boxed strings should use the nullability from stringWithUTF8String's return type

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

Objective-C NSString has a class method `stringWithUTF8String` that creates a 
new NSString from a C string. Objective-C box expression `@(...)` can be used 
to create an NSString instead of invoking the `stringWithUTF8String` method 
directly (The compiler lowers it down to the invocation though). This patch 
ensures that the type of `@(string-value)` gets the same nullability attributes 
as the return type of `stringWithUTF8String` to ensure that the diagnostics are 
consistent between the two.

rdar://33847186


Repository:
  rL LLVM

https://reviews.llvm.org/D39762

Files:
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjC/transfer-boxed-string-nullability.m


Index: test/SemaObjC/transfer-boxed-string-nullability.m
===
--- /dev/null
+++ test/SemaObjC/transfer-boxed-string-nullability.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fblocks -fobjc-arc -Wnullable-to-nonnull-conversion 
-fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fblocks -fobjc-arc -Wnullable-to-nonnull-conversion 
-fsyntax-only -verify -Wno-objc-root-class -DNOWARN %s
+
+@interface NSString
+
++ (NSString*
+#ifndef NOWARN
+  _Nullable
+#else
+  _Nonnull
+#endif
+) stringWithUTF8String:(const char*)x;
+
+@end
+
+void takesNonNull(NSString * _Nonnull ptr);
+
+void testBoxedString() {
+  const char *str = "hey";
+  takesNonNull([NSString stringWithUTF8String:str]);
+  takesNonNull(@(str));
+#ifndef NOWARN
+  // expected-warning@-3 {{implicit conversion from nullable pointer 'NSString 
* _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
+  // expected-warning@-3 {{implicit conversion from nullable pointer 'NSString 
* _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -564,6 +564,13 @@
   
   BoxingMethod = StringWithUTF8StringMethod;
   BoxedType = NSStringPointer;
+  // Transfer the nullability from method's return type.
+  Optional Nullability =
+  BoxingMethod->getReturnType()->getNullability(Context);
+  if (Nullability)
+BoxedType = Context.getAttributedType(
+AttributedType::getNullabilityAttrKind(*Nullability), BoxedType,
+BoxedType);
 }
   } else if (ValueType->isBuiltinType()) {
 // The other types we support are numeric, char and BOOL/bool. We could 
also


Index: test/SemaObjC/transfer-boxed-string-nullability.m
===
--- /dev/null
+++ test/SemaObjC/transfer-boxed-string-nullability.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fblocks -fobjc-arc -Wnullable-to-nonnull-conversion -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fblocks -fobjc-arc -Wnullable-to-nonnull-conversion -fsyntax-only -verify -Wno-objc-root-class -DNOWARN %s
+
+@interface NSString
+
++ (NSString*
+#ifndef NOWARN
+  _Nullable
+#else
+  _Nonnull
+#endif
+) stringWithUTF8String:(const char*)x;
+
+@end
+
+void takesNonNull(NSString * _Nonnull ptr);
+
+void testBoxedString() {
+  const char *str = "hey";
+  takesNonNull([NSString stringWithUTF8String:str]);
+  takesNonNull(@(str));
+#ifndef NOWARN
+  // expected-warning@-3 {{implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
+  // expected-warning@-3 {{implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -564,6 +564,13 @@
   
   BoxingMethod = StringWithUTF8StringMethod;
   BoxedType = NSStringPointer;
+  // Transfer the nullability from method's return type.
+  Optional Nullability =
+  BoxingMethod->getReturnType()->getNullability(Context);
+  if (Nullability)
+BoxedType = Context.getAttributedType(
+AttributedType::getNullabilityAttrKind(*Nullability), BoxedType,
+BoxedType);
 }
   } else if (ValueType->isBuiltinType()) {
 // The other types we support are numeric, char and BOOL/bool. We could also
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

2017-11-07 Thread Cameron via Phabricator via cfe-commits
cameron314 added a comment.

I'll rebase the patch and add a test. Thanks for looking at this!


Repository:
  rL LLVM

https://reviews.llvm.org/D20124



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


[PATCH] D39759: Remove x86 specific code from noplt.c

2017-11-07 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram added a comment.

More information here.  This breaks non-x86 builds like PPC because:

/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/tools/clang/test/CodeGen/noplt.c:4:22:
 error: expected string not found in input
// CHECK-NOPLT-NEXT: declare i32 @foo

  ^

:14:1: note: scanning from here
declare signext i32 @foo(...) #1

removing i32 from the test solves this problem.


https://reviews.llvm.org/D39759



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


[PATCH] D39711: [analyzer] ObjCGenerics: Don't warn on cast conversions involving explicit cast

2017-11-07 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:587
   if (TrackedType &&
+  !isa(CE) &&
   !ASTCtxt.canAssignObjCInterfaces(DestObjectPtrType, *TrackedType) &&

xazax.hun wrote:
> george.karpenkov wrote:
> > Should it check that we are actually casting to the right type? Also it's a 
> > bit strange that isa<> check on line 569 did not catch this case, maybe 
> > that if- branch should be generalized instead?
> I agree, line 569 supposed to handle this case and also update the state 
> accordingly.
For suppressive casts, I am worried about updating the state to reflect 
destination type.

Programmers use a suppressive cast when they know a better invariant about the 
contents of a collection -- at a particular point in time -- than the analysis 
infers. It is not a promise that the invariant will hold at all later program 
points. I'm particularly worried that adding one suppressive cast would require 
the programmer to add other, different suppressive casts later in the program. 
For this reason I don't think it make sense to update the specialized type args 
map with the destination type of the cast.

Gabor: what do you think about the alternative of always removing the inferred 
specialized type args information for an unspecialized symbol on an explicit 
cast? After an explicit cast we would essentially treat the value as 
unspecialized and so not warn about later uses until the analyzer infers more 
information. Essentially this would be an acknowledgement that an explicit cast 
means the programmer had an invariant in mind that couldn't be represented in 
the type system and so the analyzer should back off.


https://reviews.llvm.org/D39711



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


[PATCH] D39759: Remove x86 specific code from noplt.c

2017-11-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Please search for `declare {{.*}}i32 @foo`, and then commit. Otherwise this 
could match `call i32 @foo` or something like that.


https://reviews.llvm.org/D39759



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


r317627 - Change noplt.c to work for non-x86 targets.

2017-11-07 Thread Sriraman Tallam via cfe-commits
Author: tmsriram
Date: Tue Nov  7 14:34:55 2017
New Revision: 317627

URL: http://llvm.org/viewvc/llvm-project?rev=317627&view=rev
Log:
Change noplt.c to work for non-x86 targets.

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

Modified:
cfe/trunk/test/CodeGen/noplt.c

Modified: cfe/trunk/test/CodeGen/noplt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/noplt.c?rev=317627&r1=317626&r2=317627&view=diff
==
--- cfe/trunk/test/CodeGen/noplt.c (original)
+++ cfe/trunk/test/CodeGen/noplt.c Tue Nov  7 14:34:55 2017
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
-// CHECK-NOPLT-NEXT: declare i32 @foo
+// CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
 int foo();
 
 int bar() {


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


[PATCH] D39759: Remove x86 specific code from noplt.c

2017-11-07 Thread Sriraman Tallam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317627: Change noplt.c to work for non-x86 targets. 
(authored by tmsriram).

Changed prior to commit:
  https://reviews.llvm.org/D39759?vs=121977&id=121987#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39759

Files:
  cfe/trunk/test/CodeGen/noplt.c


Index: cfe/trunk/test/CodeGen/noplt.c
===
--- cfe/trunk/test/CodeGen/noplt.c
+++ cfe/trunk/test/CodeGen/noplt.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
-// CHECK-NOPLT-NEXT: declare i32 @foo
+// CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
 int foo();
 
 int bar() {


Index: cfe/trunk/test/CodeGen/noplt.c
===
--- cfe/trunk/test/CodeGen/noplt.c
+++ cfe/trunk/test/CodeGen/noplt.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s -check-prefix=CHECK-NOPLT
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
-// CHECK-NOPLT-NEXT: declare i32 @foo
+// CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
 int foo();
 
 int bar() {
___
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-07 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:205
+
+  if (!(H.contents[0].codeBlockLanguage == "" &&
+H.contents[0].markdownString == "" &&

I think we should just always call unparse and handle the various cases in 
there, because we always have to return a Hover anyway (see comment below).



Comment at: clangd/ClangdLSPServer.cpp:210
+  else
+C.reply("[]");
+}

This is an invalid response because we still have to return a Hover, it is not 
optional. We can return a empty "contents" array though, so I think it would 
look like: { contents: [] }



Comment at: clangd/ClangdServer.cpp:360
+
+  auto FileContents = DraftMgr.getDraft(File);
+  assert(FileContents.Draft &&

Why are you adding this? Is this coming from another commit?
It looks like it makes tests fail:
<-- 
{"jsonrpc":"2.0","id":2,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///doesnotexist.cpp"},"position":{"line":4,"character":7}}}
clangd: ../tools/clang/tools/extra/clangd/ClangdServer.cpp:362: 
llvm::Expected > > > 
clang::clangd::ClangdServer::findDefinitions(clang::clangd::PathRef, 
clang::clangd::Position): Assertion `FileContents.Draft && "findDefinitions is 
called for non-added document"' failed.
/home/emalape/git/llvm/tools/clang/tools/extra/test/clangd/definitions.test:169:10:
 error: expected string not found in input




Comment at: clangd/ClangdServer.cpp:445
+
+  std::vector Contents;
+  MarkedString MS = MarkedString("", "");

I would just remove all this initialization code and leave only Hover 
FinalHover;
The default constructor of Hover should be equivalent to "empty" result (but 
still valid). More below.



Comment at: clangd/ClangdServer.cpp:446
+  std::vector Contents;
+  MarkedString MS = MarkedString("", "");
+  Contents.push_back(MS);

This is the same as the default contructor, so just 
MarkedString MS;
would have been OK.



Comment at: clangd/ClangdServer.cpp:449
+  Range R;
+  // Hover FinalHover(MS, R);
+  Hover FinalHover(Contents, R);

remove commented line



Comment at: clangd/ClangdServer.cpp:450
+  // Hover FinalHover(MS, R);
+  Hover FinalHover(Contents, R);
+  auto TaggedFS = FSProvider.getTaggedFileSystem(File);

I actually think you should leave it with the default contructor, so that 
"contents" is an empty array, which is what should be returned when there is no 
hover.



Comment at: clangd/ClangdServer.cpp:454
+  std::shared_ptr Resources = Units.getFile(File);
+  assert(Resources && "Calling findDefinitions on non-added file");
+

findDefinitions -> findHover



Comment at: clangd/ClangdServer.cpp:456
+
+  std::vector> Result;
+

You can move this inside the lambda.



Comment at: clangd/ClangdServer.cpp:459
+  Resources->getAST().get()->runUnderLock(
+  [Pos, &Result, &FinalHover, this](ParsedAST *AST) {
+if (!AST)

Don't need to capture Result if it's declared inside the lambda (previous 
comment)



Comment at: clangd/ClangdServer.cpp:464
+if (!Result.empty()) {
+  FinalHover = clangd::getHover(*AST, Result[0]);
+}

Maybe we should put a comment here that we only show the hover for the first 
"definition" here and that perhaps more could be shown in the future.



Comment at: clangd/ClangdServer.h:67
+
+  // template 
 

remove



Comment at: clangd/ClangdServer.h:281
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
-  llvm::Expected>> findDefinitions(PathRef File,
+  llvm::Expected>>> 
findDefinitions(PathRef File,
 Position Pos);

Location can be deduced from Decl*. I don't think this should be a pair. I also 
think we need a more general finder that just gets either the Decl* or 
MacroDef* at the "cursor". I think CXCursor does something similar in that it 
stores either Decl* or MacroDef*. I'm not sure it would be worth moving 
CXCursor from libclang but perhaps something stripped down for Clangd would be 
OK. This new finder will be able to be reused by findDefinition, highlights, 
hover, references and more.
We can make one patch that refactors the existing code so that findDefinitions 
uses this new finder class.



Comment at: clangd/ClangdUnit.cpp:941
+
+// Keep default value.
+SourceRange SR = D->getSourceRange();

This code doesn't belong here. The hover feature and "find definition" do not 
need the same range. The hover basically wants everything

r317616 - Update SanitizerSpecialCaseList to use renamed functions in base class.

2017-11-07 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Tue Nov  7 13:16:37 2017
New Revision: 317616

URL: http://llvm.org/viewvc/llvm-project?rev=317616&view=rev
Log:
Update SanitizerSpecialCaseList to use renamed functions in base class.

Note: This change has a cyclical dependency on D39485. Both these changes must 
be submitted at the same time to avoid a build breakage.

Reviewers: vlad.tsyrklevich

Subscribers: llvm-commits

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

Modified:
cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp

Modified: cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp?rev=317616&r1=317615&r2=317616&view=diff
==
--- cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp (original)
+++ cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp Tue Nov  7 13:16:37 2017
@@ -57,7 +57,7 @@ bool SanitizerSpecialCaseList::inSection
  StringRef Category) const {
   for (auto &S : SanitizerSections)
 if ((S.Mask & Mask) &&
-SpecialCaseList::inSection(S.Entries, Prefix, Query, Category))
+SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
   return true;
 
   return false;


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


[PATCH] D39332: [clang-refactor] Introduce a new rename rule for qualified symbols

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

lgtm


https://reviews.llvm.org/D39332



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


[PATCH] D39682: [analyzer] Fix a crash on logical operators with vectors.

2017-11-07 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.

Interesting bug! The workaround looks good to me.


https://reviews.llvm.org/D39682



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


[PATCH] D39763: [clang] [python] [tests] Rewrite to use standard unittest module

2017-11-07 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

The diffs aren't very useful since I had to add a class for each test unit and 
so everything needed reindenting. You can take my word that changes boil down 
to:

- adding `unittest` import,
- adding class for each test unit and converting the functions into methods 
(except for some generic utility funcs and vars which I left global scope),
- replacing assertions and other checks with appropriate `self.assert*` methods 
(especially improving exception checks).

I get the same results (3 failures) with the change as I got before it.


Repository:
  rL LLVM

https://reviews.llvm.org/D39763



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


[PATCH] D39763: [clang] [python] [tests] Rewrite to use standard unittest module

2017-11-07 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Before:

  ==
  FAIL: tests.cindex.test_code_completion.test_code_complete_availability
  --
  Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/nose/case.py", line 197, in runTest
  self.test(*self.arg)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_code_completion.py",
 line 75, in test_code_complete_availability
  check_completion_results(cr, expected)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_code_completion.py",
 line 10, in check_completion_results
  assert c in completions
  AssertionError
  
  ==
  FAIL: Ensure that linkage specifers are available on cursors
  --
  Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/nose/case.py", line 197, in runTest
  self.test(*self.arg)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_linkage.py", line 
26, in test_linkage
  assert unique_external.linkage == LinkageKind.UNIQUE_EXTERNAL
  AssertionError
  
  ==
  FAIL: Ensure that thread-local storage kinds are available on cursors.
  --
  Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/nose/case.py", line 197, in runTest
  self.test(*self.arg)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_tls_kind.py", line 
36, in test_tls_kind
  assert tls_declspec.tls_kind == TLSKind.STATIC
  AssertionError
  
  --
  Ran 117 tests in 1.460s
  
  FAILED (failures=3)

After:

  ==
  FAIL: test_code_complete_availability 
(tests.cindex.test_code_completion.TestCodeCompletion)
  --
  Traceback (most recent call last):
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_code_completion.py",
 line 79, in test_code_complete_availability
  self.check_completion_results(cr, expected)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_code_completion.py",
 line 14, in check_completion_results
  self.assertIn(c, completions)
  AssertionError: "{'P &', ResultType} | {'operator=', TypedText} | {'(', 
LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 34 || 
Availability: Available || Brief comment: None" not found in ["{'void', 
ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || 
Priority: 79 || Availability: Available || Brief comment: None", "{'P &', 
ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', 
Placeholder} | {')', RightParen} || Priority: 79 || Availability: Available || 
Brief comment: None", "{'P', TypedText} | {'::', Text} || Priority: 75 || 
Availability: Available || Brief comment: None", "{'int', ResultType} | 
{'member', TypedText} || Priority: 35 || Availability: NotAccessible || Brief 
comment: None"]
  
  ==
  FAIL: Ensure that linkage specifers are available on cursors
  --
  Traceback (most recent call last):
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_linkage.py", line 
29, in test_linkage
  self.assertEqual(unique_external.linkage, LinkageKind.UNIQUE_EXTERNAL)
  AssertionError: LinkageKind.INTERNAL != LinkageKind.UNIQUE_EXTERNAL
  
  ==
  FAIL: Ensure that thread-local storage kinds are available on cursors.
  --
  Traceback (most recent call last):
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/cindex/test_tls_kind.py", line 
39, in test_tls_kind
  self.assertEqual(tls_declspec.tls_kind, TLSKind.STATIC)
  AssertionError: TLSKind.DYNAMIC != TLSKind.STATIC
  
  --
  Ran 117 tests in 1.471s
  
  FAILED (failures=3)


Repository:
  rL LLVM

https://reviews.llvm.org/D39763



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


[PATCH] D39611: [CodeGen] change const-ness of complex calls

2017-11-07 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39611#918275, @spatel wrote:

> Patch updated:
>  I don't know if we have agreement on the behavior that we want yet,


I just sent a note to the Austin group mailing list to see if the POSIX folks 
agree with my reading. I'll follow up.

> but I'm updating the patch/description/title to only deal with  in 
> this patch and taking a shot at one interpretation, so we can see what that 
> might look like.
> 
> There are really 2 changes here:
> 
> 1. We had all of  marked constant all the time ('c'). I think 
> there's agreement that can't be true by default (a platform could set errno 
> on any of these calls based on the language in the C standard).
> 2. We make an exception for a GNU environment - here, the calls are always 
> constant because the standard allows - and POSIX constrains - the errno 
> setting behavior. This is despite the fact that glibc is known to set errno 
> in some cases.




https://reviews.llvm.org/D39611



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


  1   2   >