[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350768: [ObjC] Allow the use of implemented unavailable 
methods from within (authored by arphaman, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56469/new/

https://reviews.llvm.org/D56469

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/call-unavailable-init-in-self.m

Index: test/SemaObjC/call-unavailable-init-in-self.m
===
--- test/SemaObjC/call-unavailable-init-in-self.m
+++ test/SemaObjC/call-unavailable-init-in-self.m
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
+
+@interface NSObject
+
++ (instancetype)new;
++ (instancetype)alloc;
+
+@end
+
+@interface Sub: NSObject
+
+- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
+
+- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}
+
+@end
+
+@implementation Sub
+
++ (Sub *)create {
+  return [[self alloc] init];
+}
+
++ (Sub *)create2 {
+  return [self new];
+}
+
++ (Sub *)create3 {
+  return [Sub new];
+}
+
+- (instancetype) init {
+  return self;
+}
+
+- (void)reportUseOfUnimplemented {
+  [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+}
+
+@end
+
+@interface SubClassContext: Sub
+@end
+
+@implementation SubClassContext
+
+- (void)subClassContext {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@end
+
+void unrelatedContext() {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@interface X @end
+
+@interface X (Foo)
+-(void)meth __attribute__((unavailable));
+@end
+
+@implementation X (Foo)
+-(void)meth {}
+-(void)call_it { [self meth]; }
+@end
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7269,9 +7269,10 @@
 /// whether we should emit a diagnostic for \c K and \c DeclVersion in
 /// the context of \c Ctx. For example, we should emit an unavailable diagnostic
 /// in a deprecated context, but not the other way around.
-static bool ShouldDiagnoseAvailabilityInContext(Sema , AvailabilityResult K,
-VersionTuple DeclVersion,
-Decl *Ctx) {
+static bool
+ShouldDiagnoseAvailabilityInContext(Sema , AvailabilityResult K,
+VersionTuple DeclVersion, Decl *Ctx,
+const NamedDecl *OffendingDecl) {
   assert(K != AR_Available && "Expected an unavailable declaration here!");
 
   // Checks if we should emit the availability diagnostic in the context of C.
@@ -7280,9 +7281,22 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, C))
 if (AA->getIntroduced() >= DeclVersion)
   return true;
-} else if (K == AR_Deprecated)
+} else if (K == AR_Deprecated) {
   if (C->isDeprecated())
 return true;
+} else if (K == AR_Unavailable) {
+  // It is perfectly fine to refer to an 'unavailable' Objective-C method
+  // when it's actually defined and is referenced from within the
+  // @implementation itself. In this context, we interpret unavailable as a
+  // form of access control.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(C)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&
+  MD->isDefined())
+return true;
+}
+  }
+}
 
 if (C->isUnavailable())
   return true;
@@ -7471,7 +7485,8 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, OffendingDecl))
 DeclVersion = AA->getIntroduced();
 
-  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx))
+  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx,
+   OffendingDecl))
 return;
 
   SourceLocation Loc = Locs.front();
@@ -7955,7 +7970,8 @@
 
 // If the context of this function is less available than D, we should not
 // emit a diagnostic.
-if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx))
+if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx,
+ OffendingDecl))
   return;
 
 // We would like to emit the diagnostic even if -Wunguarded-availability is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350768 - [ObjC] Allow the use of implemented unavailable methods from within

2019-01-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jan  9 14:31:37 2019
New Revision: 350768

URL: http://llvm.org/viewvc/llvm-project?rev=350768=rev
Log:
[ObjC] Allow the use of implemented unavailable methods from within
the @implementation context

In Objective-C, it's common for some frameworks to mark some methods like init
as unavailable in the @interface to prohibit their usage. However, these
frameworks then often implemented said method and refer to it in another method
that acts as a factory for that object. The recent change to how messages to
self are type checked in clang (r349841) introduced a regression which started
to prohibit this pattern with an X is unavailable error. This commit addresses
the aforementioned regression.

rdar://47134898

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

Added:
cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=350768=350767=350768=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  9 14:31:37 2019
@@ -7269,9 +7269,10 @@ ShouldDiagnoseAvailabilityOfDecl(Sema 
 /// whether we should emit a diagnostic for \c K and \c DeclVersion in
 /// the context of \c Ctx. For example, we should emit an unavailable 
diagnostic
 /// in a deprecated context, but not the other way around.
-static bool ShouldDiagnoseAvailabilityInContext(Sema , AvailabilityResult K,
-VersionTuple DeclVersion,
-Decl *Ctx) {
+static bool
+ShouldDiagnoseAvailabilityInContext(Sema , AvailabilityResult K,
+VersionTuple DeclVersion, Decl *Ctx,
+const NamedDecl *OffendingDecl) {
   assert(K != AR_Available && "Expected an unavailable declaration here!");
 
   // Checks if we should emit the availability diagnostic in the context of C.
@@ -7280,9 +7281,22 @@ static bool ShouldDiagnoseAvailabilityIn
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, C))
 if (AA->getIntroduced() >= DeclVersion)
   return true;
-} else if (K == AR_Deprecated)
+} else if (K == AR_Deprecated) {
   if (C->isDeprecated())
 return true;
+} else if (K == AR_Unavailable) {
+  // It is perfectly fine to refer to an 'unavailable' Objective-C method
+  // when it's actually defined and is referenced from within the
+  // @implementation itself. In this context, we interpret unavailable as a
+  // form of access control.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(C)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&
+  MD->isDefined())
+return true;
+}
+  }
+}
 
 if (C->isUnavailable())
   return true;
@@ -7471,7 +7485,8 @@ static void DoEmitAvailabilityWarning(Se
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, 
OffendingDecl))
 DeclVersion = AA->getIntroduced();
 
-  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx))
+  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx,
+   OffendingDecl))
 return;
 
   SourceLocation Loc = Locs.front();
@@ -7955,7 +7970,8 @@ void DiagnoseUnguardedAvailability::Diag
 
 // If the context of this function is less available than D, we should not
 // emit a diagnostic.
-if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx))
+if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx,
+ OffendingDecl))
   return;
 
 // We would like to emit the diagnostic even if -Wunguarded-availability is

Added: cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m?rev=350768=auto
==
--- cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m (added)
+++ cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m Wed Jan  9 14:31:37 
2019
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
+
+@interface NSObject
+
++ (instancetype)new;
++ (instancetype)alloc;
+
+@end
+
+@interface Sub: NSObject
+
+- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' 
has been explicitly marked unavailable here}}
+
+- (void)notImplemented __attribute__((unavailable)); // expected-note 
{{'notImplemented' has been explicitly marked unavailable here}}
+
+@end
+
+@implementation Sub
+
++ (Sub *)create {
+  return [[self alloc] init];
+}
+
++ (Sub *)create2 {
+  

r350779 - In nothrow new-expressions, null-check the result if we're going to

2019-01-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  9 16:03:29 2019
New Revision: 350779

URL: http://llvm.org/viewvc/llvm-project?rev=350779=rev
Log:
In nothrow new-expressions, null-check the result if we're going to
apply sanitizers to it.

This avoids a sanitizer false positive that we are initializing a null
pointer.

Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=350779=350778=350779=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Jan  9 16:03:29 2019
@@ -1656,9 +1656,10 @@ llvm::Value *CodeGenFunction::EmitCXXNew
   // Emit a null check on the allocation result if the allocation
   // function is allowed to return null (because it has a non-throwing
   // exception spec or is the reserved placement new) and we have an
-  // interesting initializer.
+  // interesting initializer will be running sanitizers on the initialization.
   bool nullCheck = E->shouldNullCheckAllocation() &&
-   (!allocType.isPODType(getContext()) || E->hasInitializer());
+   (!allocType.isPODType(getContext()) || E->hasInitializer() 
||
+sanitizePerformTypeCheck());
 
   llvm::BasicBlock *nullCheckBB = nullptr;
   llvm::BasicBlock *contBB = nullptr;

Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=350779=350778=350779=diff
==
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Wed Jan  9 16:03:29 2019
@@ -520,6 +520,49 @@ void upcast_to_vbase() {
 }
 }
 
+struct nothrow {};
+void *operator new[](__SIZE_TYPE__, nothrow) noexcept;
+
+namespace NothrowNew {
+  struct X { X(); };
+
+  // CHECK-LABEL: define{{.*}}nothrow_new_trivial
+  void *nothrow_new_trivial() {
+// CHECK: %[[is_null:.*]] = icmp eq i8*{{.*}}, null
+// CHECK: br i1 %[[is_null]], label %[[null:.*]], label %[[nonnull:.*]]
+
+// CHECK: [[nonnull]]:
+// CHECK: llvm.objectsize
+// CHECK: br i1
+//
+// CHECK: call {{.*}}__ubsan_handle_type_mismatch
+//
+// CHECK: [[null]]:
+// CHECK-NOT: {{ }}br{{ }}
+// CHECK: ret
+return new (nothrow{}) char[123456];
+  }
+
+  // CHECK-LABEL: define{{.*}}nothrow_new_nontrivial
+  void *nothrow_new_nontrivial() {
+// CHECK: %[[is_null:.*]] = icmp eq i8*{{.*}}, null
+// CHECK: br i1 %[[is_null]], label %[[null:.*]], label %[[nonnull:.*]]
+
+// CHECK: [[nonnull]]:
+// CHECK: llvm.objectsize
+// CHECK: br i1
+//
+// CHECK: call {{.*}}__ubsan_handle_type_mismatch
+//
+// CHECK: call {{.*}}_ZN10NothrowNew1XC1Ev
+//
+// CHECK: [[null]]:
+// CHECK-NOT: {{ }}br{{ }}
+// CHECK: ret
+return new (nothrow{}) X[123456];
+  }
+}
+
 struct ThisAlign {
   void this_align_lambda();
   void this_align_lambda_2();


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


[PATCH] D55844: [Fixed Point Arithmetic] Fixed Point Subtraction

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3451
+  case BO_Comma:
+llvm_unreachable("Found unimplemented fixed point binary operation");
   }

Please create a separate case for the non-arithmetic operators 
(pointer-to-member, assignment, comma) that will obviously never end up in this 
function.

Otherwise, LGTM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55844/new/

https://reviews.llvm.org/D55844



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


[PATCH] D56523: Improve a -Wunguarded-availability note

2019-01-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: arphaman.
Herald added subscribers: dexonsmith, jkorous.

Mention the deployment target, and don't say "partial" which doesn't really 
mean anything to users.

rdar://problem/33601513


Repository:
  rC Clang

https://reviews.llvm.org/D56523

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-availability.c
  clang/test/Sema/availability-guard-format.mm
  clang/test/SemaObjC/attr-availability.m
  clang/test/SemaObjC/property-deprecated-warning.m
  clang/test/SemaObjC/unguarded-availability-new.m
  clang/test/SemaObjC/unguarded-availability.m

Index: clang/test/SemaObjC/unguarded-availability.m
===
--- clang/test/SemaObjC/unguarded-availability.m
+++ clang/test/SemaObjC/unguarded-availability.m
@@ -5,14 +5,14 @@
 #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
 #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
 
-typedef int AVAILABLE_10_12 new_int; // expected-note + {{marked partial here}}
+typedef int AVAILABLE_10_12 new_int; // expected-note + {{'new_int' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
-int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been explicitly marked partial here}}
+int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}}
 
 #ifdef OBJCPP
-// expected-note@+2 6 {{marked partial here}}
+// expected-note@+2 6 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been explicitly marked partial here}}
+int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -61,11 +61,11 @@
   }
 }
 
-typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been explicitly marked partial here}}
+typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}}
 #ifdef OBJCPP
-// expected-note@+2 {{marked partial here}}
+// expected-note@+2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 #endif
-typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been explicitly marked partial here}}
+typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
 void use_typedef() {
   int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}}
@@ -106,10 +106,10 @@
 
 struct S {
   int m1;
-  int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{marked partial here}}
+  int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
   struct Nested {
-int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{marked partial here}}
+int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{'nested_member' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
   } n;
 };
 
@@ -139,9 +139,9 @@
 
 AVAILABLE_10_12
 __attribute__((objc_root_class))
-@interface InterWithProp // expected-note 2 {{marked partial here}}
+@interface InterWithProp // expected-note 2 {{'InterWithProp' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 @property(class) int x;
-+ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{marked partial here}}
++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{'setX:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 @end
 void test_property(void) {
   int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}}
@@ -150,7 +150,7 @@
 
 __attribute__((objc_root_class))
 @interface Subscriptable
-- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{marked partial here}}
+- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{'objectAtIndexedSubscript:' has been marked as being introduced in macOS 10.12 

r350785 - [X86] Really make the pointer arguments to avx512 gather/scatter intrinsics 'void*' to match gcc and Intel's documentation.

2019-01-09 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jan  9 16:47:25 2019
New Revision: 350785

URL: http://llvm.org/viewvc/llvm-project?rev=350785=rev
Log:
[X86] Really make the pointer arguments to avx512 gather/scatter intrinsics 
'void*' to match gcc and Intel's documentation.

The avx2 gather intrinsics are documented to use 'int', 'long long', 'float', 
or 'double' *. So I'm leaving those. This matches gcc.

I tried to do this in r350696, but I only updated the header not the builtin 
definition.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=350785=350784=350785=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jan  9 16:47:25 2019
@@ -968,47 +968,47 @@ TARGET_BUILTIN(__builtin_ia32_vpdpwssds1
 TARGET_BUILTIN(__builtin_ia32_vpdpwssds256, "V8iV8iV8iV8i", "ncV:256:", 
"avx512vl,avx512vnni")
 TARGET_BUILTIN(__builtin_ia32_vpdpwssds512, "V16iV16iV16iV16i", "ncV:512:", 
"avx512vnni")
 
-TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2ddC*V2LLiUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div2di, "V2LLiV2LLiLLiC*V2LLiUcIi", 
"nV:128:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4df, "V4dV4ddC*V4LLiUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4di, "V4LLiV4LLiLLiC*V4LLiUcIi", 
"nV:256:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4sf, "V4fV4ffC*V2LLiUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4si, "V4iV4iiC*V2LLiUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div8sf, "V4fV4ffC*V4LLiUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div8si, "V4iV4iiC*V4LLiUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv2df, "V2dV2ddC*V4iUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv2di, "V2LLiV2LLiLLiC*V4iUcIi", 
"nV:128:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4df, "V4dV4ddC*V4iUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4di, "V4LLiV4LLiLLiC*V4iUcIi", 
"nV:256:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4sf, "V4fV4ffC*V4iUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4si, "V4iV4iiC*V4iUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv8sf, "V8fV8ffC*V8iUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv8si, "V8iV8iiC*V8iUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8ddC*V8iUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16ffC*V16fUsIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv8df, "V8dV8ddC*V8LLiUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv16sf, "V8fV8ffC*V8LLiUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv8di, "V8LLiV8LLiLLiC*V8iUcIi", 
"nV:512:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16si, "V16iV16iiC*V16iUsIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv8di, "V8LLiV8LLiLLiC*V8LLiUcIi", 
"nV:512:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv16si, "V8iV8iiC*V8LLiUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv8df, "vd*UcV8iV8dIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv16sf, "vf*UsV16iV16fIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv8df,  "vd*UcV8LLiV8dIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv16sf, "vf*UcV8LLiV8fIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv8di,  "vLLi*UcV8iV8LLiIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv16si, "vi*UsV16iV16iIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv8di,  "vLLi*UcV8LLiV8LLiIi", 
"nV:512:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv16si, "vi*UcV8LLiV8iIi", "nV:512:", 
"avx512f")
-
-TARGET_BUILTIN(__builtin_ia32_gatherpfdpd,  "vUcV8iLLiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_gatherpfdps,  "vUsV16iiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_gatherpfqpd,  "vUcV8LLiLLiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_gatherpfqps,  "vUcV8LLiiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfdpd, "vUcV8iLLi*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfdps, "vUsV16ii*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfqpd, "vUcV8LLiLLi*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfqps, "vUcV8LLii*IiIi", "nV:512:", 
"avx512pf")
+TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2dvC*V2LLiUcIi", "nV:128:", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div2di, "V2LLiV2LLivC*V2LLiUcIi", 
"nV:128:", 

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber marked an inline comment as done.
bernhardmgruber added a comment.

I spent some time now to get member pointers as return values working and I am 
afraid but it seems there is a problem with the clang AST. Given the following 
code in my check (where `F` is a `FunctionDecl`):

  const TypeSourceInfo *TSI = F.getTypeSourceInfo();
  const FunctionTypeLoc FTL = 
TSI->getTypeLoc().IgnoreParens().getAs();
  auto rl = FTL.getReturnLoc();
  rl.getSourceRange().dump(SM);
  rl.getLocalSourceRange().dump(SM);
  rl.castAs().getSourceRange().dump(SM);
  rl.castAs().getLocalSourceRange().dump(SM);
  rl.castAs().getBeginLoc().dump(SM);
  rl.castAs().getStarLoc().dump(SM);

with the following input:

  namespace std {
  template 
  class vector;
  
  class string;
  }
  
  int std::vector::* e6();
  }

yields these source locations:

  <...\aa.cpp:8:1, col:5>
  <...\aa.cpp:8:5>
  <...\aa.cpp:8:1, col:5>
  <...\aa.cpp:8:5>
  ...\aa.cpp:8:1
  ...\aa.cpp:8:5

The first is the value I usually obtain via `F.getReturnTypeSourceRange()`. The 
following lines are what I saw in my debugger when I stepped into the 
implementation. I believe that `getStarLoc()` should point at the asterisk at 
column 31, not at std at column 5.

I did not find an easy workaround and I would like to avoid manual lexing 
because of the interference with macros. For now, I will just disable the check 
for member pointers.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 180973.
bernhardmgruber marked 8 inline comments as done.
bernhardmgruber added a comment.

- Removed detailed diagnostic messages why FixIts could not be generated
- Excluded functions returning member pointers for now
- All tests run now


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-trailing-return.rst
  test/clang-tidy/modernize-use-trailing-return.cpp

Index: test/clang-tidy/modernize-use-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-trailing-return.cpp
@@ -0,0 +1,269 @@
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14
+
+namespace std {
+template 
+class vector;
+
+class string;
+}
+
+//
+// Functions
+//
+
+int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
+int f(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
+int f(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
+int f(int arg1, int arg2, int arg3);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
+int f(int arg1, int arg2, int arg3, ...);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
+template  int f(T t);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}template  auto f(T t) -> int;{{$}}
+
+//
+// Functions with formatting
+//
+
+int a1() { return 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
+int a2() {
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
+int a3()
+{
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
+int a4(int   arg   )   ;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a4(int   arg   ) -> int   ;{{$}}
+int a5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a5{{$}}
+(int arg);
+// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
+
+//
+// Functions with qualifiers and specifiers
+//
+
+inline int d1(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
+extern "C" int d2(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
+inline int d3(int arg) noexcept(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d3(int arg) -> int noexcept(true);{{$}}
+inline int d4(int arg) try { } catch(...) { }
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d4(int arg) -> int try { } catch(...) { }{{$}}
+
+//
+// Functions in namespaces
+//
+
+namespace N {
+int e1();
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto e1() -> int;{{$}}
+int N::e1() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto N::e1() -> int {}{{$}}
+
+//
+// Functions with complex return types
+//
+
+inline volatile const std::vector e2();
+// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing 

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber added inline comments.



Comment at: clang-tidy/modernize/UseTrailingReturnCheck.cpp:45
+std::string(Message) +
+" (no FixIt provided, function argument list end is inside 
macro)");
+return {};

Eugene.Zelenko wrote:
> MyDeveloperDay wrote:
> > bernhardmgruber wrote:
> > > JonasToth wrote:
> > > > I think you can ellide that extra message. Not emitting the fixit is 
> > > > clear already.
> > > I actually like having a reason why my check could not provide a FixIt. 
> > > Especially because there are multiple reasons why this might happen.
> > @bernhardmgruber I had the same comment given to me on a review recently 
> > with regard to diag message, let me try and help you with what I though was 
> > the rational... I think the premise is something like:
> > 
> > 1) "no FixIt provided" is implied by the fact it isn't fixed
> > 2) "function type source info is missing"  doesn't tell the developer what 
> > they have to do to have it be fixed
> > 
> > sure it helps you as the checker developer but probably that isn't much use 
> > to a developer using the checker on their code and so might confuse them.
> > 
> > It also makes grepping for messages in a log file difficult because it 
> > means multiple messages coming from your checker have a different pattern 
> > (although there might be a common sub pattern)
> > 
> > For the most part where a fixit is not supplied where it should someone 
> > would create a test case which you could consume in your tests
> > 
> > To be honest as a general observation as a newbie myself, what I've noticed 
> > is that a lot of checker review comments are very similar, 
> > 
> > 
> > 
> >   - 80 characters in rst files
> >   - clang-format
> >   - alphabetic order
> >   - Comments with proper puncuation
> >   - code in comments in ``XXX``
> >   - don't overly use auto
> >   - don't use anonymous namespace functions use static functions
> >   - run it on a big C++ project
> >   - run it over all of LLVM
> >   - consistency of coding style (elide unnecessary const)
> >   - elide unnecessary braces/brackets/code/etc..
> > 
> > 
> > 
> > We really should try and write a "Writing a clang checker, and getting it 
> > though review" primer, because I really feel for these "gaints" that we ask 
> > to review all this code, they must go over the same thing and have to 
> > present the same reasons time and time again...
> > 
> > which is why If you don't mind I'd like to try to help give something back 
> > by filling in some of the reasoning gaps here to a fellow new starter
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> I would say that we should eat own dog food :-)
> 
> I'd love to see your documentation validation scripts as part of build!
> 
> We also should regularly run Clang-tidy on BuildBot. But first we must fix 
> existing warnings and no everybody happy if such cleanups performed by 
> outsiders.
> 
> See PR27267 for anonymous namespaces usage.
> 
> Clang-tidy has modernize-use-auto, but not check for LLVM guidelines 
> conformance.
> 
> Braces should be checked by readability-braces-around-statements, but proper 
> setup is needed.
> 
> Conformance to readability-else-after-return is another typical newbies 
> problem.
Thank you @MyDeveloperDay for the list of tips and rational behind the 
diagnostic messages. I will check this list in the future before I send new 
patches. Maybe it is really a good idea to put this list somewhere!



Comment at: test/clang-tidy/modernize-use-trailing-return.cpp:1
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14
+

MyDeveloperDay wrote:
> bernhardmgruber wrote:
> > MyDeveloperDay wrote:
> > > nit: is there a reason here why you say C++14 when the code checks for 
> > > C++11? 
> > Yes. The tests contain functions with deduced return types, such as `auto 
> > f();`. Those require C++14. The check itself is fine with C++11.
> I kind of half guessed it would be something like that after I hit submit,  I 
> noticed some checks add secondary test files which test the various versions 
> of C++, to be honest I found this useful for the checker I'm developing, 
> especially as the checker has some slightly different behavior with C++11 to 
> C++17, but maybe yours doesn't
> 
> to be honest i'm also fairly new here so don't know exactly the convention
> 
> examples where this is already done in other peoples checkers
> 
> modernize-deprecated-headers-cxx03.cpp
> modernize-deprecated-headers-cxx11.cpp
> 
> ```
> // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- 
> -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers -- 
> -std=c++03 -v
> 
> // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- 
> -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers -- 
> -std=c++11 -v
> 
> ```
> 
Thank you for the hint! I just split my tests into C++11 and C++14 versions, 
but then I 

[PATCH] D56530: [X86] Add versions of the avx512 gather intrinsics that take the mask as a vXi1 vector instead of a scalar (clang side)

2019-01-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.

This is the clang equivalent of D56527 


https://reviews.llvm.org/D56530

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  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
@@ -9280,97 +9280,97 @@
 
 __m128d test_mm_mmask_i64gather_pd(__m128d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_pd
-  // CHECK: @llvm.x86.avx512.gather3div2.df
+  // CHECK: @llvm.x86.avx512.mask.gather3div2.df
   return _mm_mmask_i64gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mmask_i64gather_epi64(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3div2.di
+  // CHECK: @llvm.x86.avx512.mask.gather3div2.di
   return _mm_mmask_i64gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256d test_mm256_mmask_i64gather_pd(__m256d __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_pd
-  // CHECK: @llvm.x86.avx512.gather3div4.df
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.df
   return _mm256_mmask_i64gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256i test_mm256_mmask_i64gather_epi64(__m256i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3div4.di
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.di
   return _mm256_mmask_i64gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128 test_mm_mmask_i64gather_ps(__m128 __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_ps
-  // CHECK: @llvm.x86.avx512.gather3div4.sf
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.sf
   return _mm_mmask_i64gather_ps(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mmask_i64gather_epi32(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_epi32
-  // CHECK: @llvm.x86.avx512.gather3div4.si
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.si
   return _mm_mmask_i64gather_epi32(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128 test_mm256_mmask_i64gather_ps(__m128 __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_ps
-  // CHECK: @llvm.x86.avx512.gather3div8.sf
+  // CHECK: @llvm.x86.avx512.mask.gather3div8.sf
   return _mm256_mmask_i64gather_ps(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm256_mmask_i64gather_epi32(__m128i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_epi32
-  // CHECK: @llvm.x86.avx512.gather3div8.si
+  // CHECK: @llvm.x86.avx512.mask.gather3div8.si
   return _mm256_mmask_i64gather_epi32(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128d test_mm_mask_i32gather_pd(__m128d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mask_i32gather_pd
-  // CHECK: @llvm.x86.avx512.gather3siv2.df
+  // CHECK: @llvm.x86.avx512.mask.gather3siv2.df
   return _mm_mmask_i32gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mask_i32gather_epi64(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mask_i32gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3siv2.di
+  // CHECK: @llvm.x86.avx512.mask.gather3siv2.di
   return _mm_mmask_i32gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256d test_mm256_mask_i32gather_pd(__m256d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mask_i32gather_pd
-  // CHECK: @llvm.x86.avx512.gather3siv4.df
+  // CHECK: @llvm.x86.avx512.mask.gather3siv4.df
   return _mm256_mmask_i32gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256i test_mm256_mask_i32gather_epi64(__m256i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mask_i32gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3siv4.di
+  // CHECK: @llvm.x86.avx512.mask.gather3siv4.di
   return _mm256_mmask_i32gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128 test_mm_mask_i32gather_ps(__m128 __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mask_i32gather_ps
-  // CHECK: @llvm.x86.avx512.gather3siv4.sf
+  // CHECK: @llvm.x86.avx512.mask.gather3siv4.sf
   return _mm_mmask_i32gather_ps(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mask_i32gather_epi32(__m128i __v1_old, __mmask8 __mask, 

[PATCH] D56529: [X86] Add versions of the avx512 gather intrinsics that take the mask as a vXi1 vector instead of a scalar (clang side)

2019-01-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper abandoned this revision.
craig.topper added a comment.

Abandoning because i sent it to llvm-commits instead of cfe-commits. Will redo 
to get the right mailing list


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56529/new/

https://reviews.llvm.org/D56529



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


[PATCH] D56530: [X86] Add versions of the avx512 gather intrinsics that take the mask as a vXi1 vector instead of a scalar (clang side)

2019-01-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper marked an inline comment as done.
craig.topper added inline comments.



Comment at: include/clang/Basic/BuiltinsX86.def:988
 TARGET_BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8dvC*V8iUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*V16fUsIi", "nV:512:", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*V16iUsIi", "nV:512:", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gatherdiv8df, "V8dV8dvC*V8LLiUcIi", "nV:512:", 
"avx512f")

This was a bug that seems to have been hidden because generic builtin to 
intrinsic handling blindly inserted a bitcast to match the type. I'll probably 
pre-commit this


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56530/new/

https://reviews.llvm.org/D56530



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


[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
nickdesaulniers marked an inline comment as done.
Closed by commit rL350776: [Sema] Mark target of 
__attribute__((alias(target))) used for C (authored by 
nickdesaulniers, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/alias-unused.c


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1898,7 +1898,16 @@
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target((Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));
Index: cfe/trunk/test/Sema/alias-unused.c
===
--- cfe/trunk/test/Sema/alias-unused.c
+++ cfe/trunk/test/Sema/alias-unused.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x 
c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1898,7 +1898,16 @@
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target((Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));
Index: cfe/trunk/test/Sema/alias-unused.c
===
--- cfe/trunk/test/Sema/alias-unused.c
+++ cfe/trunk/test/Sema/alias-unused.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350776 - [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Wed Jan  9 15:54:55 2019
New Revision: 350776

URL: http://llvm.org/viewvc/llvm-project?rev=350776=rev
Log:
[Sema] Mark target of __attribute__((alias("target"))) used for C

Summary:
Prevents -Wunneeded-internal-delcaration warnings when the target has no
other references. This occurs frequently in device drivers in the Linux
kernel.

Sema would need to invoke the demangler on the target, since in C++ the
target name is mangled:

int f() { return 42; }
int g() __attribute__((alias("_Z1fv")));

Sema does not have the ability to demangle names at this time.

https://bugs.llvm.org/show_bug.cgi?id=39088
https://github.com/ClangBuiltLinux/linux/issues/232

Reviewers: rsmith, rjmccall

Reviewed By: rsmith

Subscribers: erik.pilkington, cfe-commits, pirama, srhines

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

Added:
cfe/trunk/test/Sema/alias-unused.c
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=350776=350775=350776=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  9 15:54:55 2019
@@ -1898,7 +1898,16 @@ static void handleAliasAttr(Sema , Dec
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target((Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));

Added: cfe/trunk/test/Sema/alias-unused.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-unused.c?rev=350776=auto
==
--- cfe/trunk/test/Sema/alias-unused.c (added)
+++ cfe/trunk/test/Sema/alias-unused.c Wed Jan  9 15:54:55 2019
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x 
c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));


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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 180960.
yaxunl added a comment.

disable the check for more general cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCUDA/kernel-template-with-func-arg.cu

Index: test/SemaCUDA/kernel-template-with-func-arg.cu
===
--- /dev/null
+++ test/SemaCUDA/kernel-template-with-func-arg.cu
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+struct C {
+  __device__ void devfun() {}
+  void hostfun() {}
+  template __device__ void devtempfun() {}
+  __device__ __host__ void devhostfun() {}
+};
+
+__device__ void devfun() {}
+__host__ void hostfun() {}
+template __device__ void devtempfun() {}
+__device__ __host__ void devhostfun() {}
+
+template  __global__ void kernel() { devF();}
+template  __global__ void kernel2(T *p) { (p->*devF)(); }
+
+template<> __global__ void kernel();
+template<> __global__ void kernel(); // expected-error {{no function template matches function template specialization 'kernel'}}
+  // expected-note@-5 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel >();
+template<> __global__ void kernel();
+
+template<> __global__ void kernel<>();
+template<> __global__ void kernel<>(); // expected-error {{no function template matches function template specialization 'kernel'}}
+   // expected-note@-11 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel< >();
+template<> __global__ void kernel<>();
+
+template<> __global__ void kernel2(C *p);
+template<> __global__ void kernel2(C *p); // expected-error {{no function template matches function template specialization 'kernel2'}}
+  // expected-note@-16 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel2 >(C *p);
+template<> __global__ void kernel2(C *p);
+
+void fun() {
+  kernel<><<<1,1>>>();
+  kernel<><<<1,1>>>(); // expected-error {{no matching function for call to 'kernel'}}
+   // expected-note@-24 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel< ><<<1,1>>>();
+  kernel<><<<1,1>>>();
+
+  kernel<<<1,1>>>();
+  kernel<<<1,1>>>(); // expected-error {{no matching function for call to 'kernel'}}
+  // expected-note@-30 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel ><<<1,1>>>();
+  kernel<<<1,1>>>();
+
+  C a;
+  kernel2<<<1,1>>>();
+  kernel2<<<1,1>>>(); // expected-error {{no matching function for call to 'kernel2'}}
+// expected-note@-36 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel2 ><<<1,1>>>();
+  kernel2<<<1,1>>>();
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -4534,6 +4534,7 @@
 
   EnterExpressionEvaluationContext ConstantEvaluated(
   SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+  SemaRef.ExprEvalContexts.back().Template = Template;
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 }
 
@@ -4784,8 +4785,8 @@
   TemplateArgument Result;
   unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
-CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
-  Result, CTAK);
+  CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
+Result, CTAK, dyn_cast(Template));
   if (Res.isInvalid())
 return true;
   // If the current template argument causes an error, give up now.
@@ -6154,6 +6155,22 @@
   return true;
 }
 
+namespace {
+FunctionDecl *GetFunctionDecl(Expr *Arg) {
+  Expr *E = Arg;
+  if (UnaryOperator *UO = dyn_cast(E)) {
+E = UO ? UO->getSubExpr() : nullptr;
+  }
+  if (DeclRefExpr *DRE = dyn_cast_or_null(E)) {
+ValueDecl *Entity = DRE ? DRE->getDecl() : nullptr;
+if (Entity) {
+  if (auto Callee = dyn_cast(Entity))
+return Callee;
+}
+  }
+  return nullptr;
+}
+} // namespace
 /// Check a template argument against its corresponding
 /// non-type template parameter.
 ///
@@ -6164,7 +6181,8 @@
 ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
QualType ParamType, Expr *Arg,
 

[PATCH] D56525: [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec created this revision.
rampitec added reviewers: b-sumner, kzhuravl, msearles.
Herald added subscribers: cfe-commits, t-tye, tpr, dstuttard, yaxunl, nhaehnle, 
wdng, jvesely.

clang part


Repository:
  rC Clang

https://reviews.llvm.org/D56525

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/Basic/Targets/AMDGPU.cpp
  test/CodeGenOpenCL/amdgpu-features.cl
  test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl


Index: test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
@@ -12,24 +12,24 @@
 half2 v2hA, half2 v2hB, float fC,
 short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
 ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC) {
-  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
-  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
+  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
+  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
 
-  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
-  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
+  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
+  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
 
-  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
-  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
+  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
+  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
 
-  siOut[2] = __builtin_amdgcn_sdot4(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
-  siOut[3] = __builtin_amdgcn_sdot4(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
+  siOut[2] = __builtin_amdgcn_sdot4(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dot-insts}}
+  siOut[3] = __builtin_amdgcn_sdot4(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dot-insts}}
 
-  uiOut[2] = __builtin_amdgcn_udot4(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dl-insts}}
-  uiOut[3] = __builtin_amdgcn_udot4(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dl-insts}}
+  uiOut[2] = __builtin_amdgcn_udot4(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dot-insts}}
+  uiOut[3] = __builtin_amdgcn_udot4(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dot-insts}}
 
-  siOut[4] = __builtin_amdgcn_sdot8(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dl-insts}}
-  siOut[5] = __builtin_amdgcn_sdot8(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dl-insts}}
+  siOut[4] = __builtin_amdgcn_sdot8(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dot-insts}}
+  siOut[5] = __builtin_amdgcn_sdot8(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dot-insts}}
 
-  uiOut[4] = __builtin_amdgcn_udot8(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dl-insts}}
-  uiOut[5] = __builtin_amdgcn_udot8(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dl-insts}}
+  uiOut[4] = __builtin_amdgcn_udot8(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dot-insts}}
+  uiOut[5] = __builtin_amdgcn_udot8(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dot-insts}}
 }
Index: test/CodeGenOpenCL/amdgpu-features.cl
===
--- 

[PATCH] D50106: [libc++] Fix tuple assignment from type derived from a tuple-like

2019-01-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.
Herald added subscribers: libcxx-commits, jkorous.

Ping! It would be nice to land this in LLVM 8


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50106/new/

https://reviews.llvm.org/D50106



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


[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

2019-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 180971.
jdoerfert added a comment.

Allow to use names in the callback metadata


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55483/new/

https://reviews.llvm.org/D55483

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Analysis/retain-release.m
  test/CodeGen/attr-callback.c
  test/CodeGen/callback_annotated.c
  test/CodeGen/callback_openmp.c
  test/CodeGen/callback_pthread_create.c
  test/CodeGenCXX/attr-callback.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/OpenMP/parallel_codegen.cpp
  test/Sema/attr-callback-broken.c
  test/Sema/attr-callback.c
  test/SemaCXX/attr-callback-broken.cpp
  test/SemaCXX/attr-callback.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -775,6 +775,11 @@
 }
   };
 
+  struct VariadicParamOrParamIdxArgument : public VariadicArgument {
+VariadicParamOrParamIdxArgument(const Record , StringRef Attr)
+: VariadicArgument(Arg, Attr, "int") {}
+  };
+
   // Unique the enums, but maintain the original declaration ordering.
   std::vector
   uniqueEnumsInOrder(const std::vector ) {
@@ -1283,6 +1288,8 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VariadicParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr);
+  else if (ArgName == "VariadicParamOrParamIdxArgument")
+Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "ParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr, "ParamIdx");
   else if (ArgName == "VariadicIdentifierArgument")
@@ -2116,6 +2123,7 @@
  llvm::StringSwitch(
  Arg->getSuperClasses().back().first->getName())
  .Case("VariadicIdentifierArgument", true)
+ .Case("VariadicParamOrParamIdxArgument", true)
  .Default(false);
 }
 
Index: test/SemaCXX/attr-callback.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+class C_in_class {
+#include "../Sema/attr-callback.c"
+};
+
+struct Base {
+
+  void no_args_1(void (*callback)(void));
+  __attribute__((callback(1))) void no_args_2(void (*callback)(void));
+  __attribute__((callback(callback))) void no_args_3(void (*callback)(void)) {}
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *));
+
+  __attribute__((callback(1, __this, __, __this))) virtual void
+  this_unknown_this(void (*callback)(Base *, Base *, Base *));
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void));
+
+  __attribute__((callback(callback))) virtual void
+  virtual_2(void (*callback)(void));
+
+  __attribute__((callback(1))) virtual void
+  virtual_3(void (*callback)(void));
+};
+
+__attribute__((callback(1))) void
+Base::no_args_1(void (*callback)(void)) {
+}
+
+void Base::no_args_2(void (*callback)(void)) {
+}
+
+struct Derived_1 : public Base {
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *)) override;
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void)) override {}
+
+  virtual void
+  virtual_3(void (*callback)(void)) override {}
+};
+
+struct Derived_2 : public Base {
+
+  __attribute__((callback(callback))) virtual void
+  virtual_1(void (*callback)(void)) override;
+
+  virtual void
+  virtual_2(void (*callback)(void)) override;
+
+  virtual void
+  virtual_3(void (*callback)(void)) override;
+};
+
+void Derived_2::virtual_1(void (*callback)(void)) {}
+
+__attribute__((callback(1))) void
+Derived_2::virtual_2(void (*callback)(void)) {}
+
+void Derived_2::virtual_3(void (*callback)(void)) {}
Index: test/SemaCXX/attr-callback-broken.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback-broken.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+class C_in_class {
+#define HAS_THIS
+#include "../Sema/attr-callback-broken.c"
+#undef HAS_THIS
+};
Index: test/Sema/attr-callback.c
===
--- /dev/null
+++ test/Sema/attr-callback.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+__attribute__((callback(1))) void no_args(void (*callback)(void));
+__attribute__((callback(1, 2, 3)))   void args_1(void (*callback)(int, double), int a, double b);

[PATCH] D56525: [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350794: [AMDGPU] Separate feature dot-insts (authored by 
rampitec, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56525?vs=180969=180991#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56525/new/

https://reviews.llvm.org/D56525

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
  cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
  cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
  cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl


Index: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
===
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
@@ -137,6 +137,7 @@
 switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
 case GK_GFX906:
   Features["dl-insts"] = true;
+  Features["dot-insts"] = true;
   LLVM_FALLTHROUGH;
 case GK_GFX909:
 case GK_GFX904:
Index: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
@@ -135,13 +135,13 @@
 // Deep learning builtins.
 
//===--===//
 
-TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot-insts")
 
 
//===--===//
 // Special builtins.
Index: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
===
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
@@ -12,24 +12,24 @@
 half2 v2hA, half2 v2hB, float fC,
 short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
 ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC) {
-  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
-  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
+  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
+  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
 
-  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
-  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
+  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
+  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
 
-  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
-  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
+  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
+  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
 
-  siOut[2] = __builtin_amdgcn_sdot4(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
-  siOut[3] = __builtin_amdgcn_sdot4(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
+  siOut[2] = 

[PATCH] D56532: [clang-tidy] Add the abseil-duration-conversion-cast check

2019-01-09 Thread Hyrum Wright via Phabricator via cfe-commits
hwright created this revision.
hwright added reviewers: hokein, aaron.ballman.
hwright added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

This suggests simplifying expressions which are casting conversion functions, 
such as `static_cast(absl::ToDoubleSeconds(...))`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56532

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationComparisonCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.h
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-conversion-cast.cpp

Index: test/clang-tidy/abseil-duration-conversion-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-conversion-cast.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s abseil-duration-conversion-cast %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1;
+  double x;
+  int i;
+
+  i = static_cast(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = static_cast(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleHours(d1);
+  i = static_cast(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Minutes(d1);
+  x = static_cast(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMinutes(d1);
+  i = static_cast(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Seconds(d1);
+  x = static_cast(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleSeconds(d1);
+  i = static_cast(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Milliseconds(d1);
+  x = static_cast(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMilliseconds(d1);
+  i = static_cast(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Microseconds(d1);
+  x = static_cast(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+  i = static_cast(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Nanoseconds(d1);
+  x = static_cast(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleNanoseconds(d1);
+
+  // Functional-style casts
+  i = int(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = float(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // C-style casts
+  i = (int) absl::ToDoubleHours(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = (float) absl::ToInt64Microseconds(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // Macro handling
+  // We want to transform things in macro arguments
+#define EXTERNAL(x) (x) + 5
+  i = EXTERNAL(static_cast(absl::ToDoubleSeconds(d1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: 

[PATCH] D56504: [WebAssembly] Add simd128-unimplemented feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 180989.
tlively marked 3 inline comments as done.
tlively added a comment.

- Fix formatting, fix and test macro name


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/CodeGen/builtins-wasm.c
  test/Preprocessor/wasm-target-features.c

Index: test/Preprocessor/wasm-target-features.c
===
--- test/Preprocessor/wasm-target-features.c
+++ test/Preprocessor/wasm-target-features.c
@@ -8,6 +8,15 @@
 // SIMD128:#define __wasm_simd128__ 1{{$}}
 //
 // RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msimd128-unimplemented \
+// RUN:   | FileCheck %s -check-prefix=SIMD128-UNIMPLEMENTED
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msimd128-unimplemented \
+// RUN:   | FileCheck %s -check-prefix=SIMD128-UNIMPLEMENTED
+//
+// SIMD128-UNIMPLEMENTED:#define __wasm_simd128_unimplemented__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target wasm32-unknown-unknown -mcpu=mvp \
 // RUN:   | FileCheck %s -check-prefix=MVP
 // RUN: %clang -E -dM %s -o - 2>&1 \
Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -1,9 +1,6 @@
-// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: not %clang_cc1 -triple wasm64-unknown-unknown -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes MISSING-SIMD
 
 // SIMD convenience types
 typedef char i8x16 __attribute((vector_size(16)));
@@ -158,6 +155,7 @@
 
 int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
+  // MISSING-SIMD: error: '__builtin_wasm_extract_lane_s_i8x16' needs target feature simd128
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -28,7 +28,8 @@
   enum SIMDEnum {
 NoSIMD,
 SIMD128,
-  } SIMDLevel;
+SIMD128Unimplemented,
+  } SIMDLevel = NoSIMD;
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
@@ -59,18 +60,12 @@
 MacroBuilder ) const override;
 
 private:
+  static void setSIMDLevel(llvm::StringMap , SIMDEnum Level);
+
   bool
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
- const std::vector ) const override {
-if (CPU == "bleeding-edge") {
-  Features["simd128"] = true;
-  Features["nontrapping-fptoint"] = true;
-  Features["sign-ext"] = true;
-}
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
-  }
-
+ const std::vector ) const override;
   bool hasFeature(StringRef Feature) const final;
 
   bool handleTargetFeatures(std::vector ,
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -24,6 +24,8 @@
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
 #include "clang/Basic/BuiltinsWebAssembly.def"
@@ -35,6 +37,7 @@
 bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
   return 

[PATCH] D56504: [WebAssembly] Add simd128-unimplemented feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: lib/Basic/Targets/WebAssembly.cpp:89
+// features control availability of builtins
+setSIMDLevel(Features, SIMDLevel);
+if (HasNontrappingFPToInt)

aheejin wrote:
> Minor thing, but should we extract this as a function? It is gonna be a 
> couple line anyway, like
> 
> ```
> if (CPU == "bleeding-edge") {
>   ...
>   Features["unimplemented-simd128"] = Features["simd128"] = true;
> }
> 
> if (SIMDLevel >= SIMD128)
>   Features["simd128"] = true;
> if (SIMDLevel >= UnimplementedSIMD128)
>   Features["unimplemented-simd128"] = true;
> ...
> 
> And to me it is more readable to see all `Features` setting in one place. But 
> I'm not too opinionated either.
The structure of basically all this code is pulled from X86.cpp, which is 
obviously has a lot more features to wrangle. This particular function is 
similar to `setSSELevel` in X86.cpp. I agree that it probably doesn't need to 
be separate now, but as we explore possible extensions to the SIMD proposal in 
the future I think it will be useful to have this function.



Comment at: lib/Basic/Targets/WebAssembly.cpp:98
+return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+  }
+

aheejin wrote:
> The indentation of these functions looks weird and there are lines that 
> exceeds 80 cols. clang-format?
Done, and copied my pre-commit git hooks from the main LLVM repo so it won't be 
an issue again.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504



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


[PATCH] D56518: Change the symbol for the default Swift CFString class.

2019-01-09 Thread Lily Vulcano via Phabricator via cfe-commits
millenomi created this revision.
Herald added a subscriber: cfe-commits.

Required for the work in 
https://github.com/apple/swift-corelibs-foundation/pull/1799


Repository:
  rC Clang

https://reviews.llvm.org/D56518

Files:
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4235,8 +4235,8 @@
 case LangOptions::CoreFoundationABI::Swift: LLVM_FALLTHROUGH;
 case LangOptions::CoreFoundationABI::Swift5_0:
   CFConstantStringClassName =
-  Triple.isOSDarwin() ? "$s15SwiftFoundation19_NSCFConstantStringCN"
-  : "$s10Foundation19_NSCFConstantStringCN";
+  Triple.isOSDarwin() ? 
"$s19SwiftFoundationBase19_NSCFConstantStringCN"
+  : "$s14FoundationBase19_NSCFConstantStringCN";
   Ty = IntPtrTy;
   break;
 case LangOptions::CoreFoundationABI::Swift4_2:


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4235,8 +4235,8 @@
 case LangOptions::CoreFoundationABI::Swift: LLVM_FALLTHROUGH;
 case LangOptions::CoreFoundationABI::Swift5_0:
   CFConstantStringClassName =
-  Triple.isOSDarwin() ? "$s15SwiftFoundation19_NSCFConstantStringCN"
-  : "$s10Foundation19_NSCFConstantStringCN";
+  Triple.isOSDarwin() ? "$s19SwiftFoundationBase19_NSCFConstantStringCN"
+  : "$s14FoundationBase19_NSCFConstantStringCN";
   Ty = IntPtrTy;
   break;
 case LangOptions::CoreFoundationABI::Swift4_2:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Don't worry, that's a familiar mistake. :)

LGTM.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


[PATCH] D55492: Implement Attr dumping in terms of visitors

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180943.
steveire added a comment.

Updates


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55492/new/

https://reviews.llvm.org/D55492

Files:
  include/clang/AST/AttrVisitor.h
  include/clang/AST/CMakeLists.txt
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp
  utils/TableGen/ClangAttrEmitter.cpp
  utils/TableGen/TableGen.cpp
  utils/TableGen/TableGenBackends.h

Index: utils/TableGen/TableGenBackends.h
===
--- utils/TableGen/TableGenBackends.h
+++ utils/TableGen/TableGenBackends.h
@@ -45,7 +45,10 @@
 void EmitClangAttrParsedAttrList(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitClangAttrParsedAttrImpl(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitClangAttrParsedAttrKinds(llvm::RecordKeeper , llvm::raw_ostream );
-void EmitClangAttrDump(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitClangAttrTextNodeDump(llvm::RecordKeeper ,
+   llvm::raw_ostream );
+void EmitClangAttrNodeTraverse(llvm::RecordKeeper ,
+   llvm::raw_ostream );
 
 void EmitClangDiagsDefs(llvm::RecordKeeper , llvm::raw_ostream ,
 const std::string );
Index: utils/TableGen/TableGen.cpp
===
--- utils/TableGen/TableGen.cpp
+++ utils/TableGen/TableGen.cpp
@@ -40,7 +40,8 @@
   GenClangAttrParsedAttrList,
   GenClangAttrParsedAttrImpl,
   GenClangAttrParsedAttrKinds,
-  GenClangAttrDump,
+  GenClangAttrTextNodeDump,
+  GenClangAttrNodeTraverse,
   GenClangDiagsDefs,
   GenClangDiagGroups,
   GenClangDiagsIndexName,
@@ -112,8 +113,10 @@
 clEnumValN(GenClangAttrParsedAttrKinds,
"gen-clang-attr-parsed-attr-kinds",
"Generate a clang parsed attribute kinds"),
-clEnumValN(GenClangAttrDump, "gen-clang-attr-dump",
-   "Generate clang attribute dumper"),
+clEnumValN(GenClangAttrTextNodeDump, "gen-clang-attr-text-node-dump",
+   "Generate clang attribute text node dumper"),
+clEnumValN(GenClangAttrNodeTraverse, "gen-clang-attr-node-traverse",
+   "Generate clang attribute traverser"),
 clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs",
"Generate Clang diagnostics definitions"),
 clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups",
@@ -221,8 +224,11 @@
   case GenClangAttrParsedAttrKinds:
 EmitClangAttrParsedAttrKinds(Records, OS);
 break;
-  case GenClangAttrDump:
-EmitClangAttrDump(Records, OS);
+  case GenClangAttrTextNodeDump:
+EmitClangAttrTextNodeDump(Records, OS);
+break;
+  case GenClangAttrNodeTraverse:
+EmitClangAttrNodeTraverse(Records, OS);
 break;
   case GenClangDiagsDefs:
 EmitClangDiagsDefs(Records, OS, ClangComponent);
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -603,14 +603,15 @@
   OS << "OS << \"";
 }
 
-void writeDump(raw_ostream ) const override {}
+void writeDump(raw_ostream ) const override {
+  OS << "if (!SA->is" << getUpperName() << "Expr())\n";
+  OS << "  dumpType(SA->get" << getUpperName()
+ << "Type()->getType());\n";
+}
 
 void writeDumpChildren(raw_ostream ) const override {
   OS << "if (SA->is" << getUpperName() << "Expr())\n";
   OS << "  dumpStmt(SA->get" << getUpperName() << "Expr());\n";
-  OS << "else\n";
-  OS << "  dumpType(SA->get" << getUpperName()
- << "Type()->getType());\n";
 }
 
 void writeHasChildren(raw_ostream ) const override {
@@ -2932,15 +2933,15 @@
 OS << "case AttrSyntax::" << Variety << ": {\n";
 // C++11-style attributes are further split out based on the Scope.
 for (auto I = List.cbegin(), E = List.cend(); I != E; ++I) {
-  if (I != List.cbegin())
-OS << " else ";
-  if (I->first.empty())
-OS << "if (ScopeName == \"\") {\n";
-  else
-OS << "if (ScopeName == \"" << I->first << "\") {\n";
-  OS << "  return llvm::StringSwitch(Name)\n";
-  GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first);
-  OS << "}";
+  if (I != List.cbegin())
+OS << " else ";
+  if (I->first.empty())
+OS << "if (ScopeName == \"\") {\n";
+  else
+OS << "if (ScopeName == \"" << I->first << "\") {\n";
+  OS << "  return llvm::StringSwitch(Name)\n";
+  GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first);
+  OS << "}";
 }
 OS << "\n} break;\n";
   };
@@ -3697,39 +3698,67 @@
 }
 
 // Emits the code to dump an attribute.
-void EmitClangAttrDump(RecordKeeper , raw_ostream ) {
-  emitSourceFileHeader("Attribute dumper", 

[PATCH] D56522: [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Basic/DiagnosticGroups.td:364
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;

Please note that this is for GCC compatibility in this comment.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56522/new/

https://reviews.llvm.org/D56522



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


[PATCH] D56504: [WebAssembly] Add unimplemented-simd128 feature, gate builtins

2019-01-09 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:53
 // Saturating fp-to-int conversions
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc")
-
-// Floating point min/max
-BUILTIN(__builtin_wasm_min_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_max_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_min_f64, "ddd", "nc")
-BUILTIN(__builtin_wasm_max_f64, "ddd", "nc")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc", 
"nontrapping-fptoint")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc", 
"nontrapping-fptoint")

clang-format this file



Comment at: lib/Basic/Targets/WebAssembly.cpp:89
+// features control availability of builtins
+setSIMDLevel(Features, SIMDLevel);
+if (HasNontrappingFPToInt)

Minor thing, but should we extract this as a function? It is gonna be a couple 
line anyway, like

```
if (CPU == "bleeding-edge") {
  ...
  Features["unimplemented-simd128"] = Features["simd128"] = true;
}

if (SIMDLevel >= SIMD128)
  Features["simd128"] = true;
if (SIMDLevel >= UnimplementedSIMD128)
  Features["unimplemented-simd128"] = true;
...

And to me it is more readable to see all `Features` setting in one place. But 
I'm not too opinionated either.



Comment at: lib/Basic/Targets/WebAssembly.cpp:98
+return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+  }
+

The indentation of these functions looks weird and there are lines that exceeds 
80 cols. clang-format?



Comment at: test/CodeGen/builtins-wasm.c:2
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature 
+unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature 
+exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature 
+unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature 
+exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
 

Maybe we can add a line that disables one of the target features and make sure 
it fails? You can do something like
```
RUN: not %clang_cc1 ...
```
to see if it fails.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504



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


[PATCH] D55492: Implement Attr dumping in terms of visitors

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:3726
+functionContent = SS.str();
+if (SS.tell()) {
+  OS << "  void Visit" << R.getName() << "Attr(const " << R.getName()

aaron.ballman wrote:
> Wouldn't this be `!FunctionContent.empty()`?
I would have thought so, but apparently that's not how `raw_string_ostream` 
works. I get an empty file from this if I do that.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55492/new/

https://reviews.llvm.org/D55492



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


[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180947.
steveire added a comment.

Rebase


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55491/new/

https://reviews.llvm.org/D55491

Files:
  include/clang/AST/TemplateArgumentVisitor.h
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -64,6 +64,19 @@
   ConstAttrVisitor::Visit(A);
 }
 
+void TextNodeDumper::Visit(const TemplateArgument , SourceRange R,
+   const Decl *From, const char *label) {
+  OS << "TemplateArgument";
+  if (R.isValid())
+dumpSourceRange(R);
+
+  if (From) {
+dumpDeclRef(From, label);
+  }
+
+  ConstTemplateArgumentVisitor::Visit(TA);
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
@@ -317,3 +330,45 @@
 const comments::VerbatimLineComment *C, const comments::FullComment *) {
   OS << " Text=\"" << C->getText() << "\"";
 }
+
+void TextNodeDumper::VisitNullTemplateArgument(const TemplateArgument &) {
+  OS << " null";
+}
+
+void TextNodeDumper::VisitTypeTemplateArgument(const TemplateArgument ) {
+  OS << " type";
+  dumpType(TA.getAsType());
+}
+
+void TextNodeDumper::VisitDeclarationTemplateArgument(
+const TemplateArgument ) {
+  OS << " decl";
+  dumpDeclRef(TA.getAsDecl());
+}
+
+void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &) {
+  OS << " nullptr";
+}
+
+void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument ) {
+  OS << " integral " << TA.getAsIntegral();
+}
+
+void TextNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument ) {
+  OS << " template ";
+  TA.getAsTemplate().dump(OS);
+}
+
+void TextNodeDumper::VisitTemplateExpansionTemplateArgument(
+const TemplateArgument ) {
+  OS << " template expansion ";
+  TA.getAsTemplateOrTemplatePattern().dump(OS);
+}
+
+void TextNodeDumper::VisitExpressionTemplateArgument(const TemplateArgument &) {
+  OS << " expr";
+}
+
+void TextNodeDumper::VisitPackTemplateArgument(const TemplateArgument &) {
+  OS << " pack";
+}
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/LocInfoType.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
 #include "clang/AST/TextNodeDumper.h"
 #include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/Builtins.h"
@@ -44,7 +45,8 @@
 public ConstStmtVisitor,
 public ConstCommentVisitor,
 public TypeVisitor,
-public ConstAttrVisitor {
+public ConstAttrVisitor,
+public ConstTemplateArgumentVisitor {
 
 TextNodeDumper NodeDumper;
 
@@ -440,6 +442,16 @@
 // Comments.
 void dumpComment(const Comment *C, const FullComment *FC);
 
+void VisitExpressionTemplateArgument(const TemplateArgument ) {
+  dumpStmt(TA.getAsExpr());
+}
+void VisitPackTemplateArgument(const TemplateArgument ) {
+  for (TemplateArgument::pack_iterator I = TA.pack_begin(),
+   E = TA.pack_end();
+   I != E; ++I)
+dumpTemplateArgument(*I);
+}
+
 // Implements Visit methods for Attrs
 #include "clang/AST/AttrNodeTraverse.inc"
   };
@@ -670,50 +682,8 @@
 void ASTDumper::dumpTemplateArgument(const TemplateArgument , SourceRange R,
  const Decl *From, const char *Label) {
   dumpChild([=] {
-OS << "TemplateArgument";
-if (R.isValid())
-  NodeDumper.dumpSourceRange(R);
-
-if (From)
-  NodeDumper.dumpDeclRef(From, Label);
-
-switch (A.getKind()) {
-case TemplateArgument::Null:
-  OS << " null";
-  break;
-case TemplateArgument::Type:
-  OS << " type";
-  NodeDumper.dumpType(A.getAsType());
-  break;
-case TemplateArgument::Declaration:
-  OS << " decl";
-  NodeDumper.dumpDeclRef(A.getAsDecl());
-  break;
-case TemplateArgument::NullPtr:
-  OS << " nullptr";
-  break;
-case TemplateArgument::Integral:
-  OS << " integral " << A.getAsIntegral();
-  break;
-case TemplateArgument::Template:
-  OS << " template ";
-  A.getAsTemplate().dump(OS);
-  break;
-case TemplateArgument::TemplateExpansion:
-  OS << " template expansion ";
-  A.getAsTemplateOrTemplatePattern().dump(OS);
-  break;
-case TemplateArgument::Expression:
-  OS << " expr";
-  dumpStmt(A.getAsExpr());
-  break;
-case TemplateArgument::Pack:
-  OS << " pack";
-  for (TemplateArgument::pack_iterator I = A.pack_begin(), E = A.pack_end();
-   I != E; ++I)
-dumpTemplateArgument(*I);
-  break;
-}
+  

[PATCH] D56522: [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

https://bugs.llvm.org/show_bug.cgi?id=40251
https://github.com/ClangBuiltLinux/linux/issues/307


Repository:
  rC Clang

https://reviews.llvm.org/D56522

Files:
  docs/DiagnosticsReference.rst
  include/clang/Basic/DiagnosticGroups.td
  test/SemaCXX/designated-initializers.cpp


Index: test/SemaCXX/designated-initializers.cpp
===
--- test/SemaCXX/designated-initializers.cpp
+++ test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -361,6 +361,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: docs/DiagnosticsReference.rst
===
--- docs/DiagnosticsReference.rst
+++ docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |  
 |+-+|
 
+---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -


Index: test/SemaCXX/designated-initializers.cpp
===
--- test/SemaCXX/designated-initializers.cpp
+++ test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -361,6 +361,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: docs/DiagnosticsReference.rst
===
--- docs/DiagnosticsReference.rst
+++ docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |   |+-+|
 +---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

2019-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 3 inline comments as done.
jdoerfert added inline comments.



Comment at: include/clang/Basic/Attr.td:1204
+  VariadicUnsignedArgument<"PayloadIndices">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];

jdoerfert wrote:
> aaron.ballman wrote:
> > jdoerfert wrote:
> > > aaron.ballman wrote:
> > > > Should this also apply to Objective-C methods?
> > > > 
> > > > Why should the user specify this attribute on the function as opposed 
> > > > to on the parameter? e.g.,
> > > > ```
> > > > // Why this:
> > > > __attribute__((callback (1, 2, 3)))
> > > > void* broker0(void* (*callee)(void *), void *payload, int otherPayload) 
> > > > {
> > > >   return callee(payload);
> > > > }
> > > > 
> > > > // Instead of this:
> > > > void* broker0(void* (*callee)(void *) __attribute__((callback (2, 3))), 
> > > > void *payload, int otherPayload) {
> > > >   return callee(payload);
> > > > }
> > > > 
> > > > // Or this:
> > > > void* broker0(void* (*callee)(void *) __attribute__((callback (payload, 
> > > > otherPayload))), void *payload, int otherPayload) {
> > > >   return callee(payload);
> > > > }
> > > > ```
> > > > I ask because these "use an index" attributes are really hard for users 
> > > > to use in practice. They have to account for 0-vs-1 based indexing, 
> > > > implicit this parameters, etc and if we can avoid that, it may be worth 
> > > > the effort.
> > > > Should this also apply to Objective-C methods?
> > > 
> > > I don't need it to and unless somebody does, I'd say no.
> > > 
> > > 
> > > > I ask because these "use an index" attributes are really hard for users 
> > > > to use in practice. They have to account for 0-vs-1 based indexing, 
> > > > implicit this parameters, etc and if we can avoid that, it may be worth 
> > > > the effort.
> > > 
> > > I was thinking that the function notation makes it clear that there is 
> > > *only one callback per function* allowed right now. I don't expect many 
> > > manual users of this feature until we improve the middle-end support, so 
> > > it is unclear to me if this requirement needs to be removed as well.
> > > 
> > > Other than that, some thoughts: 
> > > - I do not feel strongly about this.
> > > - The middle requirement seems not much better n the first, we would 
> > > still need to deal with index numbers (callbacks without arguments are 
> > > not really interesting for now). 
> > > - The last encoding requires us to define a symbol for "unknown argument" 
> > > (maybe _ or ?).
> > > I was thinking that the function notation makes it clear that there is 
> > > *only one callback per function* allowed right now.
> > 
> > I don't see how that follows. Users may still try writing:
> > ```
> > __attribute__((callback (1, 3, 4)))
> > __attribute__((callback (2, 3, 4)))
> > void broker0(void (*cb1)(void *, int), void (*cb2)(void *, int), void 
> > *payload, int otherPayload) {
> >   cb1(payload, otherPayload);
> >   cb2(payload, otherPayload);
> > }
> > ```
> > and reasonably expect that to work (we should have this as a test case, and 
> > probably warn on it).
> > 
> > I'm not strongly opposed to the current way this is exposed to users, just 
> > wondering if we can find a better way to surface the feature.
> > 
> > > The last encoding requires us to define a symbol for "unknown argument" 
> > > (maybe _ or ?).
> > 
> > Ah, I wasn't aware that this was part of the feature, but the documentation 
> > you wrote helped to clarify for me. Personal preference is for `?`, but any 
> > symbol will do (so long as we aren't hoping users can count commas, e.g., 
> > `callback(frobble,,,foo)`).
> > and reasonably expect that to work (we should have this as a test case, and 
> > probably warn on it).
> 
> We have a test case and we'll spit out an error. (Sema/attr-callback-broken.c 
> line 21 & 22)
> 
> 
> > I'm not strongly opposed to the current way this is exposed to users, just 
> > wondering if we can find a better way to surface the feature.
> 
> I can change it to the inlined style if nobody disagrees:
> 
> ```
>void broker(int foo, void (*callback)(int, int, int, int) 
> __attribute__((callback(foo, ?, bar, ?))), int bar);
> 
> ```
> 
> As I mentioned, I don't have a strong opinion on this but I just don't want 
> to change it back and forth :)
> 
You can now use parameter names or indices in the callback attribute. The 
special identifiers "__" (double underscore) and "__this" can be used to 
specify an unknown (-1 in the index notation) and the implicit "this" (0 in the 
index notation) argument.



Comment at: test/CodeGen/callback_qsort_r.c:1
+// RUN: %clang %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -D_GNU_SOURCE %s -S -c -emit-llvm -o - -O1 | FileCheck %s 
--check-prefix=IR

arichardson wrote:
> This should use a linux triple otherwise the qsort_r declaration is wrong. 
> Ideally it should also handle 

[PATCH] D56525: [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56525/new/

https://reviews.llvm.org/D56525



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


r350794 - [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Stanislav Mekhanoshin via cfe-commits
Author: rampitec
Date: Wed Jan  9 19:25:47 2019
New Revision: 350794

URL: http://llvm.org/viewvc/llvm-project?rev=350794=rev
Log:
[AMDGPU] Separate feature dot-insts

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=350794=350793=350794=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Wed Jan  9 19:25:47 2019
@@ -135,13 +135,13 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h,
 // Deep learning builtins.
 
//===--===//
 
-TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot-insts")
 
 
//===--===//
 // Special builtins.

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=350794=350793=350794=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Jan  9 19:25:47 2019
@@ -137,6 +137,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
 case GK_GFX906:
   Features["dl-insts"] = true;
+  Features["dot-insts"] = true;
   LLVM_FALLTHROUGH;
 case GK_GFX909:
 case GK_GFX904:

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl?rev=350794=350793=350794=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl Wed Jan  9 19:25:47 2019
@@ -11,7 +11,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
 
 // GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
-// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
+// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
 // GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+s-memrealtime,+vi-insts"
 // GFX700: "target-features"="+ci-insts,+fp64-fp16-denormals,-fp32-denormals"
 // GFX600: "target-features"="+fp64-fp16-denormals,-fp32-denormals"

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl?rev=350794=350793=350794=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl Wed Jan  9 
19:25:47 2019
@@ -12,24 +12,24 @@ kernel void builtins_amdgcn_dl_insts_err
 half2 v2hA, half2 v2hB, float fC,
 short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
 ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC) {
-  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
-  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature 

[PATCH] D47819: [compiler-rt] [test] Support using libtirpc on Linux

2019-01-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

Need to update this for the new idea of not using libtirpc at all.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47819/new/

https://reviews.llvm.org/D47819



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1351824 , @rjmccall wrote:

> But why?  Why do you want to limit this to just template arguments instead of 
> all sorts of similar contexts?


I updated the patch to disable the check for unevaluated expr context and const 
evaluated context, except the deferred check.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D55488: Add utility for dumping a label with child nodes

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180935.
steveire added a comment.

Nits


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55488/new/

https://reviews.llvm.org/D55488

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  test/AST/ast-dump-stmt.cpp

Index: test/AST/ast-dump-stmt.cpp
===
--- test/AST/ast-dump-stmt.cpp
+++ test/AST/ast-dump-stmt.cpp
@@ -91,8 +91,7 @@
   U us[3] = {1};
 // CHECK: VarDecl {{.+}}  col:5 us 'U [3]' cinit
 // CHECK-NEXT: `-InitListExpr {{.+}}  'U [3]'
-// CHECK-NEXT:   |-array filler
-// CHECK-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
+// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
 // CHECK-NEXT:   `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
 // CHECK-NEXT: `-IntegerLiteral {{.+}}  'int' 1
 }
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -61,6 +61,9 @@
 template void dumpChild(Fn doDumpChild) {
   NodeDumper.addChild(doDumpChild);
 }
+template  void dumpChild(StringRef Label, Fn doDumpChild) {
+  NodeDumper.addChild(Label, doDumpChild);
+}
 
   public:
 ASTDumper(raw_ostream , const CommandTraits *Traits,
@@ -80,7 +83,7 @@
 void setDeserialize(bool D) { Deserialize = D; }
 
 void dumpDecl(const Decl *D);
-void dumpStmt(const Stmt *S);
+void dumpStmt(const Stmt *S, StringRef Label = {});
 
 // Utilities
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
@@ -1685,8 +1688,8 @@
 //  Stmt dumping methods.
 //===--===//
 
-void ASTDumper::dumpStmt(const Stmt *S) {
-  dumpChild([=] {
+void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
+  dumpChild(Label, [=] {
 if (!S) {
   ColorScope Color(OS, ShowColors, NullColor);
   OS << "<<>>";
@@ -1957,10 +1960,7 @@
 NodeDumper.dumpBareDeclRef(Field);
   }
   if (auto *Filler = ILE->getArrayFiller()) {
-dumpChild([=] {
-  OS << "array filler";
-  dumpStmt(Filler);
-});
+dumpStmt(Filler, "array_filler");
   }
 }
 
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -27,7 +27,7 @@
   const bool ShowColors;
 
   /// Pending[i] is an action to dump an entity at level i.
-  llvm::SmallVector, 32> Pending;
+  llvm::SmallVector, 32> Pending;
 
   /// Indicates whether we're at the top level.
   bool TopLevel = true;
@@ -39,13 +39,19 @@
   std::string Prefix;
 
 public:
-  /// Add a child of the current node.  Calls doAddChild without arguments
-  template  void addChild(Fn doAddChild) {
+  /// Add a child of the current node. Calls DoAddChild without arguments.
+  template  void addChild(Fn DoAddChild) {
+return addChild("", DoAddChild);
+  }
+
+  /// Add a child of the current node with an optional label.
+  /// Calls DoAddChild without arguments.
+  template  void addChild(StringRef Label, Fn DoAddChild) {
 // If we're at the top level, there's nothing interesting to do; just
 // run the dumper.
 if (TopLevel) {
   TopLevel = false;
-  doAddChild();
+  DoAddChild();
   while (!Pending.empty()) {
 Pending.back()(true);
 Pending.pop_back();
@@ -56,7 +62,10 @@
   return;
 }
 
-auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
+// We need to capture an owning-string in the lambda because the lambda
+// is invoked in a deferred manner.
+std::string LabelStr = Label;
+auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) {
   // Print out the appropriate tree structure and work out the prefix for
   // children of this node. For instance:
   //
@@ -72,15 +81,18 @@
   {
 OS << '\n';
 ColorScope Color(OS, ShowColors, IndentColor);
-OS << Prefix << (isLastChild ? '`' : '|') << '-';
-this->Prefix.push_back(isLastChild ? ' ' : '|');
+OS << Prefix << (IsLastChild ? '`' : '|') << '-';
+if (!LabelStr.empty())
+  OS << LabelStr << ": ";
+
+this->Prefix.push_back(IsLastChild ? ' ' : '|');
 this->Prefix.push_back(' ');
   }
 
   FirstChild = true;
   unsigned Depth = Pending.size();
 
-  doAddChild();
+  DoAddChild();
 
   // If any children are left, they're the last at their nesting level.
   // Dump those ones out now.
@@ -94,10 +106,10 @@
 };
 
 if (FirstChild) {
-  Pending.push_back(std::move(dumpWithIndent));
+  Pending.push_back(std::move(DumpWithIndent));
 } else {
   Pending.back()(false);
-  Pending.back() = std::move(dumpWithIndent);
+  Pending.back() = std::move(DumpWithIndent);
 }
 FirstChild = false;
 

[libunwind] r350787 - Revert "[Sparc] Add Sparc V8 support"

2019-01-09 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Wed Jan  9 17:08:31 2019
New Revision: 350787

URL: http://llvm.org/viewvc/llvm-project?rev=350787=rev
Log:
Revert "[Sparc] Add Sparc V8 support"

This reverts commit r350705.

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=350787=350786=350787=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Wed Jan  9 17:08:31 2019
@@ -23,7 +23,6 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
-#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__i386__)
@@ -114,11 +113,6 @@
 #error "Unsupported MIPS ABI and/or environment"
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
-# elif defined(__sparc__)
-  #define _LIBUNWIND_TARGET_SPARC 1
-  #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
-  #define _LIBUNWIND_CONTEXT_SIZE 16
-  #define _LIBUNWIND_CURSOR_SIZE 23
 # else
 #  error "Unsupported architecture."
 # endif
@@ -132,7 +126,6 @@
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
-# define _LIBUNWIND_TARGET_SPARC 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=350787=350786=350787=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed Jan  9 17:08:31 2019
@@ -823,40 +823,4 @@ enum {
   UNW_MIPS_LO = 65,
 };
 
-// SPARC registers
-enum {
-  UNW_SPARC_G0 = 0,
-  UNW_SPARC_G1 = 1,
-  UNW_SPARC_G2 = 2,
-  UNW_SPARC_G3 = 3,
-  UNW_SPARC_G4 = 4,
-  UNW_SPARC_G5 = 5,
-  UNW_SPARC_G6 = 6,
-  UNW_SPARC_G7 = 7,
-  UNW_SPARC_O0 = 8,
-  UNW_SPARC_O1 = 9,
-  UNW_SPARC_O2 = 10,
-  UNW_SPARC_O3 = 11,
-  UNW_SPARC_O4 = 12,
-  UNW_SPARC_O5 = 13,
-  UNW_SPARC_O6 = 14,
-  UNW_SPARC_O7 = 15,
-  UNW_SPARC_L0 = 16,
-  UNW_SPARC_L1 = 17,
-  UNW_SPARC_L2 = 18,
-  UNW_SPARC_L3 = 19,
-  UNW_SPARC_L4 = 20,
-  UNW_SPARC_L5 = 21,
-  UNW_SPARC_L6 = 22,
-  UNW_SPARC_L7 = 23,
-  UNW_SPARC_I0 = 24,
-  UNW_SPARC_I1 = 25,
-  UNW_SPARC_I2 = 26,
-  UNW_SPARC_I3 = 27,
-  UNW_SPARC_I4 = 28,
-  UNW_SPARC_I5 = 29,
-  UNW_SPARC_I6 = 30,
-  UNW_SPARC_I7 = 31,
-};
-
 #endif

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=350787=350786=350787=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Wed Jan  9 17:08:31 2019
@@ -223,14 +223,6 @@ int DwarfInstructions::stepWithDwa
   }
 #endif
 
-#if defined(_LIBUNWIND_TARGET_SPARC)
-  // Skip call site instruction and delay slot
-  returnAddress += 8;
-  // Skip unimp instruction if function returns a struct
-  if ((addressSpace.get32(returnAddress) & 0xC1C0) == 0)
-returnAddress += 4;
-#endif
-
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=350787=350786=350787=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Wed Jan  9 17:08:31 2019
@@ -685,22 +685,6 @@ bool CFI_Parser::parseInstructions(A
   break;
 #endif
 
-#if defined(_LIBUNWIND_TARGET_SPARC)
-case DW_CFA_GNU_window_save:
-  _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save()\n");
-  for (reg = UNW_SPARC_O0; reg <= UNW_SPARC_O7; reg++) {
-results->savedRegisters[reg].location = kRegisterInRegister;
-results->savedRegisters[reg].value =
-(reg - UNW_SPARC_O0) + UNW_SPARC_I0;
-  }
-
-  for (reg = UNW_SPARC_L0; reg <= UNW_SPARC_I7; reg++) {
-

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber added a comment.

I am satisfied with the proposed feature set for now. I will try to run the 
check on LLVM itself in the next days as a final test. Are there anymore 
feature requests or changes from your sides?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160



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


[PATCH] D56504: [WebAssembly] Add unimplemented-simd128 feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 180984.
tlively added a comment.

- Match the new naming scheme from rL350791 


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -1,9 +1,5 @@
-// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
 
 // SIMD convenience types
 typedef char i8x16 __attribute((vector_size(16)));
Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -28,7 +28,8 @@
   enum SIMDEnum {
 NoSIMD,
 SIMD128,
-  } SIMDLevel;
+SIMD128Unimplemented,
+  } SIMDLevel = NoSIMD;
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
@@ -59,18 +60,12 @@
 MacroBuilder ) const override;
 
 private:
+  static void setSIMDLevel(llvm::StringMap , SIMDEnum Level);
+
   bool
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
- const std::vector ) const override {
-if (CPU == "bleeding-edge") {
-  Features["simd128"] = true;
-  Features["nontrapping-fptoint"] = true;
-  Features["sign-ext"] = true;
-}
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
-  }
-
+ const std::vector ) const override;
   bool hasFeature(StringRef Feature) const final;
 
   bool handleTargetFeatures(std::vector ,
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -24,6 +24,8 @@
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
 #include "clang/Basic/BuiltinsWebAssembly.def"
@@ -35,6 +37,7 @@
 bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch(Feature)
   .Case("simd128", SIMDLevel >= SIMD128)
+  .Case("simd128-unimplemented", SIMDLevel >= SIMD128Unimplemented)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
   .Case("exception-handling", HasExceptionHandling)
@@ -55,8 +58,46 @@
   defineCPUMacros(Builder, "wasm", /*Tuning=*/false);
   if (SIMDLevel >= SIMD128)
 Builder.defineMacro("__wasm_simd128__");
+  if (SIMDLevel >= SIMD128Unimplemented)
+Builder.defineMacro("__wasm_unimplemented_simd128__");
 }
 
+void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap , SIMDEnum Level) {
+  switch (Level) {
+  case SIMD128Unimplemented:
+Features["simd128-unimplemented"] = true;
+LLVM_FALLTHROUGH;
+  case SIMD128:
+Features["simd128"] = true;
+LLVM_FALLTHROUGH;
+  case NoSIMD:
+break;
+  }
+}
+
+bool WebAssemblyTargetInfo::initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
+ StringRef CPU,
+ const std::vector ) const {
+if (CPU == "bleeding-edge") {
+  Features["nontrapping-fptoint"] = true;
+  Features["sign-ext"] = true;
+  setSIMDLevel(Features, SIMD128);
+}
+// Other targets do not consider user-configured features here, but while we
+// are actively developing new features it is useful to let user-configured
+// features control availability of builtins
+setSIMDLevel(Features, SIMDLevel);
+if 

r350792 - Refactor declarations of ASTContext allocate functions into its own header.

2019-01-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  9 19:23:25 2019
New Revision: 350792

URL: http://llvm.org/viewvc/llvm-project?rev=350792=rev
Log:
Refactor declarations of ASTContext allocate functions into its own header.

Forward declarations of the allocate functions combine with the forward
declaration of the ASTContext class is enough information for some headers
without pulling in ASTContext.h in its entirety.  Pull the existing
declarations from AttrIterator.h into a new header.  Also place the default
alignment size into this header.  Previously, new had its default in
AttrIterator.h while new[] had its default in ASTContext.h.  Add new header
includes where it is needed.  Specifically to ASTVector.h to make it a
standalone header, unlike previously which it was standalone as long as
none of its functions were called.

Added:
cfe/trunk/include/clang/AST/ASTContextAllocate.h
  - copied, changed from r350683, cfe/trunk/include/clang/AST/AttrIterator.h
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ASTVector.h
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/AST/AttrIterator.h
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=350792=350791=350792=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jan  9 19:23:25 2019
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_AST_ASTCONTEXT_H
 #define LLVM_CLANG_AST_ASTCONTEXT_H
 
+#include "clang/AST/ASTContextAllocate.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CommentCommandTraits.h"
@@ -2969,8 +2970,8 @@ inline Selector GetUnarySelector(StringR
 /// This placement form of operator new uses the ASTContext's allocator for
 /// obtaining memory.
 ///
-/// IMPORTANT: These are also declared in clang/AST/AttrIterator.h! Any changes
-/// here need to also be made there.
+/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
+/// Any changes here need to also be made there.
 ///
 /// We intentionally avoid using a nothrow specification here so that the calls
 /// to this operator will not perform a null check on the result -- the
@@ -2993,7 +2994,7 @@ inline Selector GetUnarySelector(StringR
 ///  allocator supports it).
 /// @return The allocated memory. Could be nullptr.
 inline void *operator new(size_t Bytes, const clang::ASTContext ,
-  size_t Alignment) {
+  size_t Alignment /* = 8 */) {
   return C.Allocate(Bytes, Alignment);
 }
 
@@ -3031,7 +3032,7 @@ inline void operator delete(void *Ptr, c
 ///  allocator supports it).
 /// @return The allocated memory. Could be nullptr.
 inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
-size_t Alignment = 8) {
+size_t Alignment /* = 8 */) {
   return C.Allocate(Bytes, Alignment);
 }
 

Copied: cfe/trunk/include/clang/AST/ASTContextAllocate.h (from r350683, 
cfe/trunk/include/clang/AST/AttrIterator.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContextAllocate.h?p2=cfe/trunk/include/clang/AST/ASTContextAllocate.h=cfe/trunk/include/clang/AST/AttrIterator.h=350683=350792=350792=diff
==
--- cfe/trunk/include/clang/AST/AttrIterator.h (original)
+++ cfe/trunk/include/clang/AST/ASTContextAllocate.h Wed Jan  9 19:23:25 2019
@@ -1,4 +1,4 @@
-//===- AttrIterator.h - Classes for attribute iteration -*- C++ 
-*-===//
+//===- ASTContextAllocate.h - ASTContext allocate functions -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,35 +7,27 @@
 //
 
//===--===//
 //
-//  This file defines the Attr vector and specific_attr_iterator interfaces.
+//  This file declares ASTContext allocation functions separate from the main
+//  code in ASTContext.h.
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_AST_ATTRITERATOR_H
-#define LLVM_CLANG_AST_ATTRITERATOR_H
+#ifndef LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H
+#define LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H
 
-#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Casting.h"
-#include 
 #include 
-#include 
 
 namespace clang {
 
 class ASTContext;
-class Attr;
 
 } // namespace clang
 
 // Defined in ASTContext.h
 void *operator new(size_t Bytes, const clang::ASTContext ,
size_t Alignment = 8);
-
-// FIXME: Being forced to not have a default argument here due to redeclaration
-//rules on default arguments sucks
 void *operator new[](size_t 

[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the

2019-01-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added a comment.

In D55662#1349329 , @rjmccall wrote:

> Oh, and please update the commit message to primarily talk about the changes 
> to placeholder checking.  You can discuss the impact on the 
> repeated-use-of-weak warning in a follow-up paragraph.


This patch has three parts:

1. Use the expression that was rewritten during auto type deduction to perform 
auto variable initialization.
2. Call `CheckPlaceholderExpr` while an unevaluated context is still on the 
stack.
3. Check whether we are in an unevaluated context before calling 
`recordUseOfWeak` in `Sema::BuildInstanceMessage`.

I think I should commit 1 separately from 2 and 3.




Comment at: lib/Sema/SemaLambda.cpp:793
+  else
+Args = Init;
+

rjmccall wrote:
> Please maintain the original order here, even though I suspect it doesn't 
> matter: if this is direct-initialization, use the arguments, otherwise use 
> either `DeducedAutoInit` or `Init`.  Although really, consider just 
> reassigning `Init` immediately after the `deduceVarType...` call.
The code that assigns `CXXDirectInit`'s expressions to `Arg` is no longer 
needed since `Sema::deduceVarTypeFromInitializer` removes the `ParenListExpr`.

If we move the code that declares the `InitializedEntity` variable up, we can 
reassign `Init` immediately after the call to `deduceVarTypeFromInitializer`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This patch still doesn't make any sense.  You don't need to do any special 
validation when passing a function as a template argument.  When Sema 
instantiates the template definition, it'll rebuild the expressions that refer 
to the template parameter, which will trigger the normal checking for whether 
those expressions are illegally referencing a host function from the device, 
etc.  All you need to do is suppress that checking (whether it happens in a 
template definition or not) for references from non-potentially-evaluated 
contexts.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56504: [WebAssembly] Add simd128-unimplemented feature, gate builtins

2019-01-09 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:53
 // Saturating fp-to-int conversions
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc")
-
-// Floating point min/max
-BUILTIN(__builtin_wasm_min_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_max_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_min_f64, "ddd", "nc")
-BUILTIN(__builtin_wasm_max_f64, "ddd", "nc")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc", 
"nontrapping-fptoint")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc", 
"nontrapping-fptoint")

aheejin wrote:
> clang-format this file
This file still does not look like clang-formatted; I guess your script misses 
this file because its extension is `def`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504



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


[clang-tools-extra] r350797 - Remove unnecessary include.

2019-01-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  9 20:53:10 2019
New Revision: 350797

URL: http://llvm.org/viewvc/llvm-project?rev=350797=rev
Log:
Remove unnecessary include.

QuerySession.h does not need anything from Query.h, so it does not need to
include it.

Modified:
clang-tools-extra/trunk/clang-query/QuerySession.h

Modified: clang-tools-extra/trunk/clang-query/QuerySession.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QuerySession.h?rev=350797=350796=350797=diff
==
--- clang-tools-extra/trunk/clang-query/QuerySession.h (original)
+++ clang-tools-extra/trunk/clang-query/QuerySession.h Wed Jan  9 20:53:10 2019
@@ -10,7 +10,6 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
-#include "Query.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"


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


[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-01-09 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Good point :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54996/new/

https://reviews.llvm.org/D54996



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


[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Sounds good.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662



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


[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the

2019-01-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 180993.
ahatanak retitled this revision from "[Sema][ObjC] Do not warn about repeated 
uses of weak variables when the variables are accessed in an unevaluated 
context." to "[Sema] If CheckPlaceholderExpr rewrites a placeholder expression 
when the type of an auto variable is being deduced, use the rewritten 
expression when performing initialization of the variable.".
ahatanak edited the summary of this revision.
ahatanak added a comment.

Pass `Init` by reference and use the rewritten expression returned in it to 
perform variable initialization. Add a test case that tests new expression with 
auto types.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaType.cpp
  test/SemaObjC/arc-repeated-weak.mm

Index: test/SemaObjC/arc-repeated-weak.mm
===
--- test/SemaObjC/arc-repeated-weak.mm
+++ test/SemaObjC/arc-repeated-weak.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -std=c++14 -verify %s
 
 @interface Test {
 @public
@@ -462,6 +462,21 @@
   NSString * t2 = NSBundle.foo2.prop;
   use(NSBundle.foo2.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}}
   use(NSBundle2.foo2.weakProp); // expected-note{{also accessed here}}
+  decltype([NSBundle2.foo2 weakProp]) t3;
+  decltype(NSBundle2.foo2.weakProp) t4;
+  __typeof__(NSBundle2.foo2.weakProp) t5;
+}
+
+void testAuto() {
+  auto __weak wp = NSBundle2.foo2.weakProp;
+}
+
+void testLambdaCaptureInit() {
+  [capture(NSBundle2.foo2.weakProp)] {} ();
+}
+
+void testAutoNew() {
+  auto p = new auto(NSBundle2.foo2.weakProp);
 }
 
 // This used to crash in the constructor of WeakObjectProfileTy when a
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -8056,9 +8056,7 @@
 }
 
 QualType Sema::BuildTypeofExprType(Expr *E, SourceLocation Loc) {
-  ExprResult ER = CheckPlaceholderExpr(E);
-  if (ER.isInvalid()) return QualType();
-  E = ER.get();
+  assert(!E->hasPlaceholderType() && "unexpected placeholder");
 
   if (!getLangOpts().CPlusPlus && E->refersToBitField())
 Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 2;
@@ -8143,9 +8141,7 @@
 
 QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc,
  bool AsUnevaluated) {
-  ExprResult ER = CheckPlaceholderExpr(E);
-  if (ER.isInvalid()) return QualType();
-  E = ER.get();
+  assert(!E->hasPlaceholderType() && "unexpected placeholder");
 
   if (AsUnevaluated && CodeSynthesisContexts.empty() &&
   E->HasSideEffects(Context, false)) {
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -4429,6 +4429,10 @@
 return DAR_FailedAlreadyDiagnosed;
   }
 
+  ExprResult ER = CheckPlaceholderExpr(Init);
+  if (ER.isInvalid())
+return DAR_FailedAlreadyDiagnosed;
+  Init = ER.get();
   QualType Deduced = BuildDecltypeType(Init, Init->getBeginLoc(), false);
   if (Deduced.isNull())
 return DAR_FailedAlreadyDiagnosed;
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -759,14 +759,15 @@
   TypeSourceInfo *TSI = TLB.getTypeSourceInfo(Context, DeductType);
 
   // Deduce the type of the init capture.
+  Expr *DeduceInit = Init;
   QualType DeducedType = deduceVarTypeFromInitializer(
   /*VarDecl*/nullptr, DeclarationName(Id), DeductType, TSI,
-  SourceRange(Loc, Loc), IsDirectInit, Init);
+  SourceRange(Loc, Loc), IsDirectInit, DeduceInit);
   if (DeducedType.isNull())
 return QualType();
 
   // Are we a non-list direct initialization?
-  ParenListExpr *CXXDirectInit = dyn_cast(Init);
+  bool CXXDirectInit = isa(Init);
 
   // Perform initialization analysis and ensure any implicit conversions
   // (such as lvalue-to-rvalue) are enforced.
@@ -779,10 +780,7 @@
: 

[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-01-09 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik requested changes to this revision.
nik added inline comments.
This revision now requires changes to proceed.



Comment at: test/Index/print-type.cpp:202
 // CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] 
[canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= 
[outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3]
+// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at 
D:\code\qt_llvm\tools\clang\test\Index\print-type.cpp:84:3)] [typekind=Record] 
[isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at 
D:\code\qt_llvm\tools\clang\test\Index\print-type.cpp:85:3)] [typekind=Record] 
[isPOD=1] [nbFields=1] [isAnon=1]

Hard coded paths will probably only work on your machine ;)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54996/new/

https://reviews.llvm.org/D54996



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


[PATCH] D56488: clang-cl: Align help texts for /O1 and O2

2019-01-09 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.

Makes it a bit easier to see what exactly the difference is.

Also use "same as" instead of "equivalent to", because that's faster to read.


https://reviews.llvm.org/D56488

Files:
  clang/include/clang/Driver/CLCompatOptions.td


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -121,9 +121,9 @@
 // FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
 def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
-  HelpText<"Optimize for size (equivalent to /Og /Os /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
-  HelpText<"Optimize for speed (equivalent to /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for speed (same as /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>,
   HelpText<"Disable function inlining">;
 def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>,
@@ -143,7 +143,7 @@
 def : CLFlag<"Ot">, Alias<_SLASH_O>, AliasArgs<["t"]>,
   HelpText<"Optimize for speed">;
 def : CLFlag<"Ox">, Alias<_SLASH_O>, AliasArgs<["x"]>,
-  HelpText<"Deprecated (equivalent to /Og /Oi /Ot /Oy /Ob2); use /O2 instead">;
+  HelpText<"Deprecated (same as /Og /Oi /Ot /Oy /Ob2); use /O2 instead">;
 def : CLFlag<"Oy">, Alias<_SLASH_O>, AliasArgs<["y"]>,
   HelpText<"Enable frame pointer omission (x86 only)">;
 def : CLFlag<"Oy-">, Alias<_SLASH_O>, AliasArgs<["y-"]>,


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -121,9 +121,9 @@
 // FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
 def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
-  HelpText<"Optimize for size (equivalent to /Og /Os /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
-  HelpText<"Optimize for speed (equivalent to /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for speed (same as /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>,
   HelpText<"Disable function inlining">;
 def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>,
@@ -143,7 +143,7 @@
 def : CLFlag<"Ot">, Alias<_SLASH_O>, AliasArgs<["t"]>,
   HelpText<"Optimize for speed">;
 def : CLFlag<"Ox">, Alias<_SLASH_O>, AliasArgs<["x"]>,
-  HelpText<"Deprecated (equivalent to /Og /Oi /Ot /Oy /Ob2); use /O2 instead">;
+  HelpText<"Deprecated (same as /Og /Oi /Ot /Oy /Ob2); use /O2 instead">;
 def : CLFlag<"Oy">, Alias<_SLASH_O>, AliasArgs<["y"]>,
   HelpText<"Enable frame pointer omission (x86 only)">;
 def : CLFlag<"Oy-">, Alias<_SLASH_O>, AliasArgs<["y-"]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56489: clang-cl: Fix help text for /O: '/O2y-' means '/O2 /Oy-', not '/O2 /y-'

2019-01-09 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.

https://reviews.llvm.org/D56489

Files:
  clang/include/clang/Driver/CLCompatOptions.td


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -116,7 +116,7 @@
 // The _SLASH_O option handles all the /O flags, but we also provide separate
 // aliased options to provide separate help messages.
 def _SLASH_O : CLJoined<"O">,
-  HelpText<"Set multiple /O flags at once; e.g. '/O2y-' is the same as '/O2 
/y-'">,
+  HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
 // FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
 def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -116,7 +116,7 @@
 // The _SLASH_O option handles all the /O flags, but we also provide separate
 // aliased options to provide separate help messages.
 def _SLASH_O : CLJoined<"O">,
-  HelpText<"Set multiple /O flags at once; e.g. '/O2y-' is the same as '/O2 /y-'">,
+  HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
 // FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
 def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.

LGTM again :-) I bet the savings are less now that we're always storing the 
comments in the static index, so the numbers in the description might be 
outdated.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56314/new/

https://reviews.llvm.org/D56314



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D56444#1351056 , @aaron.ballman 
wrote:

> Given that, I kind of think we should have functionDecl() match only 
> functions, and give users some other way to match the semantic declarations 
> in a consistent manner. Alternatively, we could decide semantics are what we 
> want to match (because it's what the AST encodes) and instead we give users a 
> way to request to only match syntax.


I believe matching the implied semantic nodes is how closer to how matchers 
behave in general (corresponding to the fact that the ASTMatcher 
RecursiveASTVisitor sets `shouldVisitImplicitCode` to true). e.g.

  $ cat ~/test.cc
  void foo() { for (char c : "abc") {} }
  $ bin/clang-query ~/test.cc --
  clang-query> set output detailed-ast
  clang-query> match binaryOperator()
  
  Match #1:
  
  Binding for "root":
  BinaryOperator 0x471f038  
'_Bool' '!='
  |-ImplicitCastExpr 0x471f008  'const char *':'const char *' 

  | `-DeclRefExpr 0x471efc8  'const char *':'const char *' lvalue Var 
0x471ed48 '__begin1' 'const char *':'const char *'
  `-ImplicitCastExpr 0x471f020  'const char *':'const char *' 

`-DeclRefExpr 0x471efe8  'const char *':'const char *' lvalue Var 
0x471edb8 '__end1' 'const char *':'const char *'
  etc

Obviously this is only true when such nodes are present in the AST at the time 
of matching (if I'm understanding Manuel's comment correctly).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56326: [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive

2019-01-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/AST/DeclOpenMP.cpp:164
+  if (NumClauses) {
+Clauses = (OMPClause **)C.Allocate(sizeof(OMPClause *) * NumClauses);
+setClauses(CL);

No, bad idea. Use tail allocation for the clauses. Check the implementation of 
`OMPRequiresDecl`



Comment at: lib/CodeGen/CodeGenModule.h:1249
+  void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
+   CodeGenFunction *CGF = nullptr);
+

Formatting.



Comment at: lib/Parse/ParseOpenMP.cpp:503
+} else
+  MapperId = DeclNames.getIdentifier(Tok.getIdentifierInfo());
+ConsumeToken();

Enclose substatement in braces.



Comment at: lib/Parse/ParseOpenMP.cpp:589
+
+TypeResult Parser::parseOpenMPDeclareMapperVarDecl(SourceRange *Range,
+   DeclarationName ,

Pass `Range` by reference rather than as a pointer



Comment at: lib/Sema/SemaOpenMP.cpp:13587
   // OpenMP [2.13.2, critical construct, Description]
-  // ... where hint-expression is an integer constant expression that evaluates
-  // to a valid lock hint.
+  // ... where hint-expression is an integer constant expression that
+  // evaluates to a valid lock hint.

Restore this comment.



Comment at: lib/Sema/SemaOpenMP.cpp:13624
   // OpenMP [2.7.1, Restrictions]
-  //  chunk_size must be a loop invariant integer expression with a 
positive
-  //  value.
+  //  chunk_size must be a loop invariant integer expression with a
+  //  positive value.

Restore original comment



Comment at: lib/Sema/SemaOpenMP.cpp:13919
 
-// We need to add a data sharing attribute for this variable to make sure 
it
-// is correctly captured. A variable that shows up in a use_device_ptr has
-// similar properties of a first private variable.
+// We need to add a data sharing attribute for this variable to make sure
+// it is correctly captured. A variable that shows up in a use_device_ptr

Restore al the comments that are not related to the patch itself.



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2868
+TemplateDeclInstantiator::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
+  assert(!D->getType()->isDependentType() &&
+ !D->getType()->isInstantiationDependentType() &&

Why?



Comment at: lib/Serialization/ASTReader.cpp:12304
   for (unsigned i = 0; i != NumVars; ++i)
-Vars.push_back(Record.readSubExpr());
+Vars.push_back(Record.readExpr());
   C->setVarRefs(Vars);

Restore original



Comment at: lib/Serialization/ASTReader.cpp:12328
   for (unsigned i = 0; i < TotalComponents; ++i) {
-Expr *AssociatedExpr = Record.readSubExpr();
+Expr *AssociatedExpr = Record.readExpr();
 auto *AssociatedDecl = Record.readDeclAs();

Restore original


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56326/new/

https://reviews.llvm.org/D56326



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56444#1351067 , @klimek wrote:

> In D56444#1351056 , @aaron.ballman 
> wrote:
>
> > In D56444#1350849 , @JonasToth 
> > wrote:
> >
> > > In D56444#1350746 , @sammccall 
> > > wrote:
> > >
> > > > @klimek: would it be better to preserve the odd behavior of the 
> > > > `functionDecl()` matcher, and add a new `functionOrLambdaDecl()`? It 
> > > > seems too surprising to me.
> > >
> > >
> > > We can change the clang-tidy check as well. I think lambdas should be 
> > > considered functionDecls, shouldnt they? WDYT @aaron.ballman ?
> >
> >
> > I think it depends on whether we want the AST matchers to match what the 
> > user wrote (syntax) or how the program behaves (semantics). If the user 
> > writes a lambda, they did not syntactically write a function declaration 
> > and so it makes sense for `functionDecl()` to not match. However, the 
> > semantics of a lambda are that they act as a functor (in effect) which 
> > includes a class declaration, a function declaration for the function call 
> > operator, conversion operators, etc and so it does make sense for users to 
> > want to match those semantic components. Given that, I kind of think we 
> > should have functionDecl() match only functions, and give users some other 
> > way to match the semantic declarations in a consistent manner. 
> > Alternatively, we could decide semantics are what we want to match (because 
> > it's what the AST encodes) and instead we give users a way to request to 
> > only match syntax.
>
>
> The problem is that while I agree it would be nice if we matched either 
> exactly the semantic or syntactic form of the code, the reality is that we 
> match whatever the AST represents when we visit all nodes. Instead o f 
> promising folks something that we can't hold (because nobody has time to 
> fully check which matchers will match which form), I think telling people 
> that we match the AST is the more honest and less surprising result in the 
> end.


I both agree and disagree. I think being able to point users to the concrete 
thing we're matching against is really useful (and honest). I also think 
surprising is subjective -- the current behavior with lambdas is baffling to me 
because it's an inconsistent mixture of syntax and semantics that we match 
against and that can be hard to remember when writing matchers. Also, it's hard 
to say we're matching the exact AST for lambdas.

  int main() {
auto l = [](){ return 12; };
int (*fp)() = l;
  }

gives us this AST

  TranslationUnitDecl 0x2c3521ed618 <> 
  |-TypedefDecl 0x2c3521edef0 <>  implicit 
__int128_t '__int128'
  | `-BuiltinType 0x2c3521edbb0 '__int128'
  |-TypedefDecl 0x2c3521edf58 <>  implicit 
__uint128_t 'unsigned __int128'
  | `-BuiltinType 0x2c3521edbd0 'unsigned __int128'
  |-TypedefDecl 0x2c3521ee2a8 <>  implicit 
__NSConstantString '__NSConstantString_tag'
  | `-RecordType 0x2c3521ee030 '__NSConstantString_tag'
  |   `-CXXRecord 0x2c3521edfa8 '__NSConstantString_tag'
  |-TypedefDecl 0x2c3521ee340 <>  implicit 
__builtin_ms_va_list 'char *'
  | `-PointerType 0x2c3521ee300 'char *'
  |   `-BuiltinType 0x2c3521ed6b0 'char'
  |-TypedefDecl 0x2c3521ee3a8 <>  implicit 
__builtin_va_list 'char *'
  | `-PointerType 0x2c3521ee300 'char *'
  |   `-BuiltinType 0x2c3521ed6b0 'char'
  `-FunctionDecl 0x2c3521ee450 
 line:1:5 main 
'int ()'
`-CompoundStmt 0x2c3524c1d00 
  |-DeclStmt 0x2c3524c1a40 
  | `-VarDecl 0x2c3521ee590  col:8 used l '(lambda at 
C:\Users\aballman.GRAMMATECH\Desktop\test.cpp:2:12)':'(lambda at 
C:\Users\aballman.GRAMMATECH\Desktop\test.cpp:2:12)' cinit
  |   `-LambdaExpr 0x2c3524c1830  '(lambda at 
C:\Users\aballman.GRAMMATECH\Desktop\test.cpp:2:12)'
  | |-CXXRecordDecl 0x2c3524c1228  col:12 implicit class 
definition
  | | |-DefinitionData lambda pass_in_registers empty standard_layout 
trivially_copyable literal can_const_default_init
  | | | |-DefaultConstructor defaulted_is_constexpr
  | | | |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
  | | | |-MoveConstructor exists simple trivial needs_implicit
  | | | |-CopyAssignment trivial has_const_param needs_implicit 
implicit_has_const_param
  | | | |-MoveAssignment
  | | | `-Destructor simple irrelevant trivial
  | | |-CXXMethodDecl 0x2c3524c1360  col:12 used 
constexpr operator() 'int () const' inline
  | | | `-CompoundStmt 0x2c3524c1568 
  | | |   `-ReturnStmt 0x2c3524c1558 
  | | | `-IntegerLiteral 0x2c3524c1408  'int' 12
  | | |-CXXConversionDecl 0x2c3524c16e0  col:12 implicit used 
constexpr operator int (*)() 'int (*() const)()' inline
  | | | `-CompoundStmt 0x2c3524c1c98 
  | | |   `-ReturnStmt 0x2c3524c1c88 
  

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56444#1351096 , @sammccall wrote:

> In D56444#1351056 , @aaron.ballman 
> wrote:
>
> > Given that, I kind of think we should have functionDecl() match only 
> > functions, and give users some other way to match the semantic declarations 
> > in a consistent manner. Alternatively, we could decide semantics are what 
> > we want to match (because it's what the AST encodes) and instead we give 
> > users a way to request to only match syntax.
>
>
> I believe matching the implied semantic nodes is how closer to how matchers 
> behave in general (corresponding to the fact that the ASTMatcher 
> RecursiveASTVisitor sets `shouldVisitImplicitCode` to true). e.g.


I agree that we more closely match on semantics than we do on syntax and I 
think that's the correct default (as it will match the nodes in the AST that 
the user can see through dumping).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D55488: Add utility for dumping a label with child nodes

2019-01-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

@rsmith -- do you have opinions on the new format for how we display the child 
node? I think this is a more clear approach, but a second opinion would be nice.




Comment at: include/clang/AST/TextNodeDumper.h:43
+  /// Add a child of the current node.
+  /// Calls doAddChild without arguments
+  template 

Why move this comment down a line? Might as well leave it where it was before 
(feel free to add a full stop to the end of the comment though).



Comment at: include/clang/AST/TextNodeDumper.h:45
+  template 
+  void addChild(Fn doAddChild) {
+return addChild("", doAddChild);

doAddChild -> DoAddChild



Comment at: include/clang/AST/TextNodeDumper.h:48
+  }
+  /// Add a child of the current node with an optional label.
+  /// Calls doAddChild without arguments.

Can you add a newline above this comment to give it some visual space?



Comment at: include/clang/AST/TextNodeDumper.h:51
+  template 
+  void addChild(StringRef Label, Fn doAddChild) {
 // If we're at the top level, there's nothing interesting to do; just

doAddChild -> DoAddChild



Comment at: include/clang/AST/TextNodeDumper.h:68
+// We need to capture an owning-string in the lambda because the lambda 
+// is invoked in a deffered manner.
+std::string LabelStr = Label;

deffered -> deferred



Comment at: include/clang/AST/TextNodeDumper.h:70
+std::string LabelStr = Label;
+auto dumpWithIndent = [this, doAddChild, LabelStr](bool isLastChild) {
   // Print out the appropriate tree structure and work out the prefix for

dumpWithIndent -> DumpWithIndent
isLastChild -> IsLastChild



Comment at: include/clang/AST/TextNodeDumper.h:87
 OS << Prefix << (isLastChild ? '`' : '|') << '-';
+if (!LabelStr.empty()) {
+  OS << LabelStr << ": ";

Elide braces


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55488/new/

https://reviews.llvm.org/D55488



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1351145 , @sammccall wrote:

> In D56444#1351128 , @aaron.ballman 
> wrote:
>
> > In D56444#1351127 , @steveire 
> > wrote:
> >
> > > I suggest not trying to make any such drastic changes for 8.0, try to fix 
> > > the bug in a minimal way if possible, and have a more considered approach 
> > > to the future of AST Matchers for after the release.
> >
> >
> > +1
>
>
> Can you elaborate?
>
> This patch is an attempt to solve the problem "some nodes associated with 
> lambdas have no parents".


This is not a new kind of issue. I reported a variant of it too months ago: 
https://bugs.llvm.org/show_bug.cgi?id=37629.

As such I do think that this is not so urgent and can be fixed after the 
traverser class is extracted.

One of the problems is that visually tracking through parents/children of an 
AST dump does not represent the same relationships as can be expressed with 
hasParent() AST Matcher, because AST Matchers use the RAV and AST dumps do not.

However, we can make both use the same class (the generic traverser I am 
extracting from ASTDumper), and then that class of bug will be solved as I 
understand it.

> This manifests as assertion failures (or with assertions off, incorrect 
> results) for some matchers, on some code - people have encountered several 
> examples where this happens, it's hard to know where to target a more 
> targeted fix.
>  The invariant violated is "RAV traverses every AST node (when implicit 
> traversal is enabled)" - is there a way to fix this issue sufficiently 
> without addressing that?

Yes - don't use RAV to traverse parents when AST-matching.

> Is the suggestion to make that change, but then modify the semantics of the 
> `functionDecl()` etc matchers to hide it? Or something else?

My suggestion is to extract the traverser from ASTDumper first, then fix this 
issue.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56492: [clangd] Add Documentations for member completions.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.

We are missing docs for class member completion -- we don't store
comments in the preamble, so Sema doesn't return any docs. To get docs
for class members, we rely on the index (mostly dynamic index).

Tried it on llvm, didn't get noticeble delay for the completion.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56492

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

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -729,6 +729,62 @@
 Doc("Doooc"), ReturnType("void";
 }
 
+TEST(CompletionTest, DocumentationFromIndex) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  FS.Files[testPath("foo.h")] = R"cpp(
+  class Foo {
+  public:
+// Doc for foo
+int foo();
+
+// Doc for foo int
+int foo2(int);
+// Doc for foo bool
+int foo2(bool);
+  };
+  )cpp";
+
+  auto File = testPath("bar.cpp");
+  Annotations Test(R"cpp(
+  #include "foo.h"
+  void test() {
+Foo f;
+f.^
+  }
+  )cpp");
+  auto Opts = ClangdServer::optsForTest();
+  {
+Opts.BuildDynamicSymbolIndex = false;
+ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+runAddDocument(Server, File, Test.code());
+auto Results = cantFail(runCodeComplete(Server, File, Test.point(), {}));
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo"), Kind(CompletionItemKind::Method), Doc("";
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo2"), Kind(CompletionItemKind::Method), Doc("";
+  }
+  {
+Opts.BuildDynamicSymbolIndex = true;
+ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+runAddDocument(Server, File, Test.code());
+clangd::CodeCompleteOptions CCOpts;
+CCOpts.BundleOverloads = true;
+auto Results =
+cantFail(runCodeComplete(Server, File, Test.point(), CCOpts));
+EXPECT_THAT(Results.Completions,
+Contains((Named("foo"), Kind(CompletionItemKind::Method),
+  Doc("Doc for foo";
+// No doc for overload bundle.
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo2"), Kind(CompletionItemKind::Method), Doc("";
+  }
+}
+
 TEST(CompletionTest, Documentation) {
   auto Results = completions(
   R"cpp(
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1366,11 +1366,45 @@
 auto Top = mergeResults(Recorder->Results, IndexResults);
 CodeCompleteResult Output;
 
+// Keys are indices into Output vector.
+llvm::DenseMap OutputIndex;
+LookupRequest DocIndexRequest;
 // Convert the results to final form, assembling the expensive strings.
-for (auto  : Top) {
-  Output.Completions.push_back(toCodeCompletion(C.first));
-  Output.Completions.back().Score = C.second;
+for (size_t i = 0; i < Top.size(); ++i) {
+  const ScoredBundle  = Top[i];
+  const CompletionCandidate::Bundle  = BundleAndScope.first;
+  Output.Completions.push_back(toCodeCompletion(CandidateBundle));
+  Output.Completions.back().Score = BundleAndScope.second;
   Output.Completions.back().CompletionTokenRange = TextEditRange;
+
+  if (Opts.IncludeComments &&
+  Output.Completions.back().Documentation.empty()) {
+if (CandidateBundle.size() == 1) {
+  if (const CodeCompletionResult *SemaR =
+  CandidateBundle.front().SemaResult) {
+if (auto ID =
+getSymbolID(*SemaR, Recorder->CCSema->getSourceManager())) {
+  OutputIndex[i] = *ID;
+  DocIndexRequest.IDs.insert(*ID);
+}
+  }
+}
+  }
+}
+// Sema doesn't load docs from the preamble, so we get the docs from the
+// index and assemble them for the final results.
+if (!DocIndexRequest.IDs.empty() && Opts.Index) {
+  llvm::DenseMap FetchedDocs;
+  Opts.Index->lookup(DocIndexRequest, [&](const Symbol ) {
+if (!S.Documentation.empty())
+  FetchedDocs[S.ID] = S.Documentation;
+  });
+  for (auto IndexAndID : OutputIndex) {
+auto FetchDocsIt = FetchedDocs.find(IndexAndID.second);
+if (FetchDocsIt != FetchedDocs.end())
+  Output.Completions[IndexAndID.first].Documentation =
+  FetchDocsIt->second;
+  }
 }
 Output.HasMore = Incomplete;
 Output.Context = Recorder->CCContext.getKind();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1351150 , @sammccall wrote:

> In D56444#1351130 , @steveire wrote:
>
> > In D56444#1351125 , @aaron.ballman 
> > wrote:
> >
> > > if the location isn't somewhere in user code, then don't consider the 
> > > node or its children for traversal. However, that may be insufficient and 
> > > equally as mysterious behavior.
> >
> >
> > That is exactly what I've implemented. I skip invisible nodes in matching 
> > and dumping: 
> > http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/EuYjAn
>
>
> So what happens when someone asks about the parent of an invisible node?
>
> e.g. `match(hasParent(decl().bind("parent")), X, Ctx)` where X is the 
> `operator()` function of a lambda class. (This is basically the case in the 
> bug that this patch fixes)


Assuming that whether to skip invisible nodes is part of the `Ctx`, the `X` 
would simply not be in context, just like if the `X` were not in the 
`TraversalScope` of the `Ctx`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D56444#1351056 , @aaron.ballman 
wrote:

> In D56444#1350849 , @JonasToth wrote:
>
> > In D56444#1350746 , @sammccall 
> > wrote:
> >
> > > @klimek: would it be better to preserve the odd behavior of the 
> > > `functionDecl()` matcher, and add a new `functionOrLambdaDecl()`? It 
> > > seems too surprising to me.
> >
> >
> > We can change the clang-tidy check as well. I think lambdas should be 
> > considered functionDecls, shouldnt they? WDYT @aaron.ballman ?
>
>
> I think it depends on whether we want the AST matchers to match what the user 
> wrote (syntax) or how the program behaves (semantics). If the user writes a 
> lambda, they did not syntactically write a function declaration and so it 
> makes sense for `functionDecl()` to not match. However, the semantics of a 
> lambda are that they act as a functor (in effect) which includes a class 
> declaration, a function declaration for the function call operator, 
> conversion operators, etc and so it does make sense for users to want to 
> match those semantic components. Given that, I kind of think we should have 
> functionDecl() match only functions, and give users some other way to match 
> the semantic declarations in a consistent manner. Alternatively, we could 
> decide semantics are what we want to match (because it's what the AST 
> encodes) and instead we give users a way to request to only match syntax.


The problem is that while I agree it would be nice if we matched either exactly 
the semantic or syntactic form of the code, the reality is that we match 
whatever the AST represents when we visit all nodes. Instead o f promising 
folks something that we can't hold (because nobody has time to fully check 
which matchers will match which form), I think telling people that we match the 
AST is the more honest and less surprising result in the end.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D55433#1350999 , @JonasToth wrote:

> LGTM!
>  You verified that your fixes, fix the issues in LLVM? But it looks good to 
> go.


They look good, you asked before...

> P.S. did you request commit rights already?

I do not have commit rights. I'm not sure what constitutes someone who can 
commit, but let me contribute a little more before taking that step,  I have 
another idea for a checker I'd like to try after this one, I just wanted to get 
one under my belt first.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433



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


r350727 - Remove dependency-related arguments in clang-check.

2019-01-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Jan  9 07:00:06 2019
New Revision: 350727

URL: http://llvm.org/viewvc/llvm-project?rev=350727=rev
Log:
Remove dependency-related arguments in clang-check.

This is the default behavior of clang tools, but clang-check overrides default
argument adjusters for some reason.

Modified:
cfe/trunk/tools/clang-check/ClangCheck.cpp

Modified: cfe/trunk/tools/clang-check/ClangCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-check/ClangCheck.cpp?rev=350727=350726=350727=diff
==
--- cfe/trunk/tools/clang-check/ClangCheck.cpp (original)
+++ cfe/trunk/tools/clang-check/ClangCheck.cpp Wed Jan  9 07:00:06 2019
@@ -167,6 +167,7 @@ int main(int argc, const char **argv) {
   // Clear adjusters because -fsyntax-only is inserted by the default chain.
   Tool.clearArgumentsAdjusters();
   Tool.appendArgumentsAdjuster(getClangStripOutputAdjuster());
+  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
 
   // Running the analyzer requires --analyze. Other modes can work with the
   // -fsyntax-only option.


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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1351096 , @sammccall wrote:

> In D56444#1351056 , @aaron.ballman 
> wrote:
>
> > Given that, I kind of think we should have functionDecl() match only 
> > functions, and give users some other way to match the semantic declarations 
> > in a consistent manner. Alternatively, we could decide semantics are what 
> > we want to match (because it's what the AST encodes) and instead we give 
> > users a way to request to only match syntax.
>
>
> I believe matching the implied semantic nodes is how closer to how matchers 
> behave in general (corresponding to the fact that the ASTMatcher 
> RecursiveASTVisitor sets `shouldVisitImplicitCode` to true). e.g.
>
>   $ cat ~/test.cc
>   void foo() { for (char c : "abc") {} }
>   $ bin/clang-query ~/test.cc --
>   clang-query> set output detailed-ast
>   clang-query> match binaryOperator()
>  
>   Match #1:
>  
>   Binding for "root":
>   BinaryOperator 0x471f038  
> '_Bool' '!='
>   |-ImplicitCastExpr 0x471f008  'const char *':'const char *' 
> 
>   | `-DeclRefExpr 0x471efc8  'const char *':'const char *' lvalue Var 
> 0x471ed48 '__begin1' 'const char *':'const char *'
>   `-ImplicitCastExpr 0x471f020  'const char *':'const char *' 
> 
> `-DeclRefExpr 0x471efe8  'const char *':'const char *' lvalue Var 
> 0x471edb8 '__end1' 'const char *':'const char *'
>   etc
>
>
> Obviously this is only true when such nodes are present in the AST at the 
> time of matching (if I'm understanding Manuel's comment correctly).


Note that I've fixed that too,

http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/7sLs34

but both the matcher and the dumper need to get the new behavior at the same 
time. I agree that we shouldn't match on implicit nodes. See also

http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/sNny36

See how Manuel had to explain this here years ago: 
https://youtu.be/VqCkCDFLSsc?t=1748

There's more that we should do to simplify AST dumping and matching: 
http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/uBshw1

My point being that we shouldn't try to rush some way of treating lambdas like 
functionDecl()s or anything like that.

I suggest not trying to make any such drastic changes for 8.0, try to fix the 
bug in a minimal way if possible, and have a more considered approach to the 
future of AST Matchers for after the release.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1351125 , @aaron.ballman 
wrote:

> if the location isn't somewhere in user code, then don't consider the node or 
> its children for traversal. However, that may be insufficient and equally as 
> mysterious behavior.


That is exactly what I've implemented. I skip invisible nodes in matching and 
dumping: http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/EuYjAn

This requires the ast dump traverser to be extracted so that the 
'IgnoreInvisble' state can be set when it is dumping, so that it skips over 
such nodes. Currently there is no public API for ASTDumper. That can be changed.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D56444#1351128 , @aaron.ballman 
wrote:

> In D56444#1351127 , @steveire wrote:
>
> > I suggest not trying to make any such drastic changes for 8.0, try to fix 
> > the bug in a minimal way if possible, and have a more considered approach 
> > to the future of AST Matchers for after the release.
>
>
> +1


Can you elaborate?

This patch is an attempt to solve the problem "some nodes associated with 
lambdas have no parents".
This manifests as assertion failures (or with assertions off, incorrect 
results) for some matchers, on some code - people have encountered several 
examples where this happens, it's hard to know where to target a more targeted 
fix.
The invariant violated is "RAV traverses every AST node (when implicit 
traversal is enabled)" - is there a way to fix this issue sufficiently without 
addressing that?

Is the suggestion to make that change, but then modify the semantics of the 
`functionDecl()` etc matchers to hide it? Or something else?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56492: [clangd] Add Documentations for member completions.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 180843.
hokein added a comment.

Add a comment.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56492/new/

https://reviews.llvm.org/D56492

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

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -729,6 +729,64 @@
 Doc("Doooc"), ReturnType("void";
 }
 
+TEST(CompletionTest, DocumentationFromIndex) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  FS.Files[testPath("foo.h")] = R"cpp(
+  class Foo {
+  public:
+// Doc for foo
+int foo();
+
+// Doc for foo int
+int foo2(int);
+// Doc for foo bool
+int foo2(bool);
+  };
+  )cpp";
+
+  auto File = testPath("bar.cpp");
+  Annotations Test(R"cpp(
+  #include "foo.h"
+  void test() {
+Foo f;
+f.^
+  }
+  )cpp");
+  auto Opts = ClangdServer::optsForTest();
+  {
+// Run code completion without index, verify that we don't get any docs from
+// Sema.
+Opts.BuildDynamicSymbolIndex = false;
+ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+runAddDocument(Server, File, Test.code());
+auto Results = cantFail(runCodeComplete(Server, File, Test.point(), {}));
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo"), Kind(CompletionItemKind::Method), Doc("";
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo2"), Kind(CompletionItemKind::Method), Doc("";
+  }
+  {
+Opts.BuildDynamicSymbolIndex = true;
+ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+runAddDocument(Server, File, Test.code());
+clangd::CodeCompleteOptions CCOpts;
+CCOpts.BundleOverloads = true;
+auto Results =
+cantFail(runCodeComplete(Server, File, Test.point(), CCOpts));
+EXPECT_THAT(Results.Completions,
+Contains((Named("foo"), Kind(CompletionItemKind::Method),
+  Doc("Doc for foo";
+// No doc for overload bundle.
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo2"), Kind(CompletionItemKind::Method), Doc("";
+  }
+}
+
 TEST(CompletionTest, Documentation) {
   auto Results = completions(
   R"cpp(
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1366,11 +1366,45 @@
 auto Top = mergeResults(Recorder->Results, IndexResults);
 CodeCompleteResult Output;
 
+// Keys are indices into Output vector.
+llvm::DenseMap OutputIndex;
+LookupRequest DocIndexRequest;
 // Convert the results to final form, assembling the expensive strings.
-for (auto  : Top) {
-  Output.Completions.push_back(toCodeCompletion(C.first));
-  Output.Completions.back().Score = C.second;
+for (size_t i = 0; i < Top.size(); ++i) {
+  const ScoredBundle  = Top[i];
+  const CompletionCandidate::Bundle  = BundleAndScope.first;
+  Output.Completions.push_back(toCodeCompletion(CandidateBundle));
+  Output.Completions.back().Score = BundleAndScope.second;
   Output.Completions.back().CompletionTokenRange = TextEditRange;
+
+  if (Opts.IncludeComments &&
+  Output.Completions.back().Documentation.empty()) {
+if (CandidateBundle.size() == 1) {
+  if (const CodeCompletionResult *SemaR =
+  CandidateBundle.front().SemaResult) {
+if (auto ID =
+getSymbolID(*SemaR, Recorder->CCSema->getSourceManager())) {
+  OutputIndex[i] = *ID;
+  DocIndexRequest.IDs.insert(*ID);
+}
+  }
+}
+  }
+}
+// Sema doesn't load docs from the preamble, so we get the docs from the
+// index and assemble them for the final results.
+if (!DocIndexRequest.IDs.empty() && Opts.Index) {
+  llvm::DenseMap FetchedDocs;
+  Opts.Index->lookup(DocIndexRequest, [&](const Symbol ) {
+if (!S.Documentation.empty())
+  FetchedDocs[S.ID] = S.Documentation;
+  });
+  for (auto IndexAndID : OutputIndex) {
+auto FetchDocsIt = FetchedDocs.find(IndexAndID.second);
+if (FetchDocsIt != FetchedDocs.end())
+  Output.Completions[IndexAndID.first].Documentation =
+  FetchDocsIt->second;
+  }
 }
 Output.HasMore = Incomplete;
 Output.Context = Recorder->CCContext.getKind();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 180827.
hokein marked an inline comment as done.
hokein added a comment.

address review comments


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56314/new/

https://reviews.llvm.org/D56314

Files:
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -654,10 +654,15 @@
 void Foo::ssf() {}
   )";
   runSymbolCollector(Header, Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
-   QName("Foo::g"), QName("Foo::sf"),
-   QName("Foo::ssf"), QName("Foo::x")));
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  QName("Foo"),
+  AllOf(QName("Foo::f"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::g"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::sf"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::ssf"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::x"), ReturnType(""), ForCodeCompletion(false;
 }
 
 TEST_F(SymbolCollectorTest, Scopes) {
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -530,6 +530,10 @@
   getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
 S.CanonicalDeclaration = *DeclLoc;
 
+  S.Origin = Opts.Origin;
+  if (ND.getAvailability() == AR_Deprecated)
+S.Flags |= Symbol::Deprecated;
+
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
@@ -539,13 +543,28 @@
   *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
   *CompletionTUInfo,
   /*IncludeBriefComments*/ false);
-  std::string Signature;
-  std::string SnippetSuffix;
-  getSignature(*CCS, , );
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
+  // For symbols not indexed for completion (class members), we also store their
+  // docs in the index, because Sema doesn't load the docs from the preamble, we
+  // rely on the index to get the docs.
+  // FIXME: this can be optimized by only storing the docs in dynamic index --
+  // dynamic index should index these symbols when Sema completes a member
+  // completion.
+  S.Documentation = Documentation;
+  if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
+Symbols.insert(S);
+return Symbols.find(S.ID);
+  }
+
+  std::string Signature;
+  std::string SnippetSuffix;
+  getSignature(*CCS, , );
+  S.Signature = Signature;
+  S.CompletionSnippetSuffix = SnippetSuffix;
   std::string ReturnType = getReturnType(*CCS);
+  S.ReturnType = ReturnType;
 
   std::string Include;
   if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
@@ -555,10 +574,6 @@
 QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
   Include = std::move(*Header);
   }
-  S.Signature = Signature;
-  S.CompletionSnippetSuffix = SnippetSuffix;
-  S.Documentation = Documentation;
-  S.ReturnType = ReturnType;
   if (!Include.empty())
 S.IncludeHeaders.emplace_back(Include, 1);
 
@@ -569,9 +584,6 @@
   S.Type = TypeStorage->raw();
   }
 
-  S.Origin = Opts.Origin;
-  if (ND.getAvailability() == AR_Deprecated)
-S.Flags |= Symbol::Deprecated;
   Symbols.insert(S);
   return Symbols.find(S.ID);
 }
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -185,19 +185,23 @@
   SymbolOrigin Origin = SymbolOrigin::Unknown;
   /// A brief description of the symbol that can be appended in the completion
   /// candidate list. For example, "(X x, Y y) const" is a function signature.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef Signature;
   /// What to insert when completing this symbol, after the symbol name.
   /// This is in LSP snippet syntax (e.g. "({$0})" for a no-args function).
   /// (When snippets are disabled, the symbol name alone is used).
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef CompletionSnippetSuffix;
   /// Documentation including comment for the symbol declaration.
   llvm::StringRef Documentation;
   /// Type when this symbol is used in an expression. (Short display form).
   /// e.g. return type of a function, or type of a variable.
+  /// Only set when the symbol is 

[PATCH] D56446: [Driver] Fix libcxx detection on Darwin with clang run as ./clang

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry about the delay.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56446/new/

https://reviews.llvm.org/D56446



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56444#1350849 , @JonasToth wrote:

> In D56444#1350746 , @sammccall wrote:
>
> > @klimek: would it be better to preserve the odd behavior of the 
> > `functionDecl()` matcher, and add a new `functionOrLambdaDecl()`? It seems 
> > too surprising to me.
>
>
> We can change the clang-tidy check as well. I think lambdas should be 
> considered functionDecls, shouldnt they? WDYT @aaron.ballman ?


I think it depends on whether we want the AST matchers to match what the user 
wrote (syntax) or how the program behaves (semantics). If the user writes a 
lambda, they did not syntactically write a function declaration and so it makes 
sense for `functionDecl()` to not match. However, the semantics of a lambda are 
that they act as a functor (in effect) which includes a class declaration, a 
function declaration for the function call operator, conversion operators, etc 
and so it does make sense for users to want to match those semantic components. 
Given that, I kind of think we should have functionDecl() match only functions, 
and give users some other way to match the semantic declarations in a 
consistent manner. Alternatively, we could decide semantics are what we want to 
match (because it's what the AST encodes) and instead we give users a way to 
request to only match syntax.

It's always bothered me that tools like clang-query have behavior like this 
around lambdas, given:

  int main() {
auto l = [](){};
  }

you get behavior like:

  clang-query> m cxxRecordDecl()
  
  Match #1:
  
  1 match.
  clang-query>

> Should still be fixed for 8.0 (probably with this patch). The refactoring is 
> more realistic to land in 9.0 i guess?

9.0, IMO.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56444#1351127 , @steveire wrote:

> I suggest not trying to make any such drastic changes for 8.0, try to fix the 
> bug in a minimal way if possible, and have a more considered approach to the 
> future of AST Matchers for after the release.


+1


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1351130 , @steveire wrote:

> In D56444#1351125 , @aaron.ballman 
> wrote:
>
> > if the location isn't somewhere in user code, then don't consider the node 
> > or its children for traversal. However, that may be insufficient and 
> > equally as mysterious behavior.
>
>
> That is exactly what I've implemented. I skip invisible nodes in matching and 
> dumping: http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/EuYjAn


Just pasting the AST for comparison with the one Aaron posted:

  int main() {
auto l = [](){ return 12; };
int (*fp)() = l;
  }



  TranslationUnitDecl 0x5604ea6343e8 <> 
  `-FunctionDecl 0x5604ea670470 <:1:1, line:4:1> line:1:5 main 'int 
(void)'
`-CompoundStmt 0x5604ea69b0e0 
  |-DeclStmt 0x5604ea671260 
  | `-VarDecl 0x5604ea6705b0  col:8 used l 'class (lambda at 
:2:12)':'class (lambda at :2:12)' cinit
  |   `-LambdaExpr 0x5604ea670c60  'class (lambda at 
:2:12)'
  | `-CompoundStmt 0x5604ea670990 
  |   `-ReturnStmt 0x5604ea670978 
  | `-IntegerLiteral 0x5604ea670838  'int' 12
  `-DeclStmt 0x5604ea69b0c8 
`-VarDecl 0x5604ea671310  col:9 fp 'int (*)(void)' cinit
  `-DeclRefExpr 0x5604ea69af00  'class (lambda at 
:2:12)':'class (lambda at :2:12)' lvalue Var 0x5604ea6705b0 'l' 
'class (lambda at :2:12)':'class (lambda at :2:12)'




Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D55781: Make CC mangling conditional on the ABI version

2019-01-09 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.
Herald added a subscriber: mstorsjo.

Sorry for not noticing this sooner.  The TL;DR is, the current patch does not 
affect PS4, so go ahead; but see the long version for other considerations.

First, the general point: The PS4 ABI does not fit neatly into the sequential 
ClangABI versioning scheme. We forked a while back, and adopted a few 
subsequent changes and didn't adopt other changes. Just to make everyone's life 
less boring. And give me migraines. So, whenever ABI-related things happen, we 
need to be conscious of that (not fitting neatly; my headaches are not a 
consideration).

Second, IIUC the PS4 ABI ignores all the calling-convention attributes that are 
handled specially by this patch. So to that degree, PS4 doesn't care.  We don't 
support the MS-specific ones, in particular.

That said, I've discovered that there are at least a few of these 
non-target-specific CC attributes that we fail to ignore, such as vectorcall, 
and there's internal discussion to sort out what to do about that.  None of 
which should prevent this patch from going forward.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55781/new/

https://reviews.llvm.org/D55781



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D56444#1351130 , @steveire wrote:

> In D56444#1351125 , @aaron.ballman 
> wrote:
>
> > if the location isn't somewhere in user code, then don't consider the node 
> > or its children for traversal. However, that may be insufficient and 
> > equally as mysterious behavior.
>
>
> That is exactly what I've implemented. I skip invisible nodes in matching and 
> dumping: http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/EuYjAn


So what happens when someone asks about the parent of an invisible node?

e.g. `match(hasParent(decl().bind("parent")), X, Ctx)` where X is the 
`operator()` function of a lambda class. (This is basically the case in the bug 
that this patch fixes)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-09 Thread Keane, Erich via cfe-commits
Thank you for that!

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 4:48 PM
To: David Majnemer 
Cc: Keane, Erich ; cfe-commits@lists.llvm.org; Martin 
Storsjo 
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

I sent out https://reviews.llvm.org/D56466 to clarify the comment accordingly.

From: David Majnemer mailto:david.majne...@gmail.com>>
Date: Tuesday, January 8, 2019 at 3:21 PM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: "Keane, Erich" mailto:erich.ke...@intel.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, Martin Storsjo 
mailto:mar...@martin.st>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Yes, the MinGW toolchain can handle this by specifying the alignment of a 
common symbol using the aligncomm directive. The MSVC toolchain has no such 
mechanism.

This is why the check uses isKnownWindowsMSVCEnvironment.

On Tue, Jan 8, 2019 at 1:09 PM Shoaib Meenai 
mailto:smee...@fb.com>> wrote:
It checks for both OS=Win32 and Environment=MSVC, so that wouldn't cover other 
COFF environments. wbs (Martin Storsjo) mentioned on IRC that MinGW adds an 
aligncomm directive to specify alignment for common symbols, so perhaps that's 
part of it?

From: "Keane, Erich" mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 1:04 PM
To: Shoaib Meenai mailto:smee...@fb.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, David Majnemer 
mailto:david.majne...@gmail.com>>
Subject: RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for OS=Win32, 
which I believe would be different for other architectures.

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 12:41 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>; 
cfe-commits@lists.llvm.org; David Majnemer 
mailto:david.majne...@gmail.com>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Ah, looks like you were originally checking for COFF, and then David suggested 
checking for MSVC instead? I'm curious about why, although I'm sure the 
suggestion is legit :)

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Shoaib Meenai via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Shoaib Meenai mailto:smee...@fb.com>>
Date: Tuesday, January 8, 2019 at 12:39 PM
To: Erich Keane mailto:erich.ke...@intel.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Erich Keane mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

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

[PATCH] D56430: Incorrect implicit data-sharing for nested tasks

2019-01-09 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.

In D56430#1350706 , @smateo wrote:

> Renaming the `isParallelRegion` function to `isImplicitTaskingRegion`.
>
> Shall we rename the `isParallelOrTaskRegion`to 
> `isImplicitOrExplicitTaskingRegion`? It is only called 4 times.
>
> Thanks!


Yes, go ahead and do this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56430/new/

https://reviews.llvm.org/D56430



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


r350724 - Fix typo in comment

2019-01-09 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Jan  9 06:19:16 2019
New Revision: 350724

URL: http://llvm.org/viewvc/llvm-project?rev=350724=rev
Log:
Fix typo in comment

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350724=350723=350724=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan  9 06:19:16 2019
@@ -4819,7 +4819,7 @@ public:
   ImplicitExceptionSpecification
   ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD);
 
-  /// Determine what sort of exception specification a defautled
+  /// Determine what sort of exception specification a defaulted
   /// copy assignment operator of a class will have, and whether the
   /// parameter will be const.
   ImplicitExceptionSpecification


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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/SourceCode.h:21
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/SHA1.h"

Looks redundant. Remove?



Comment at: clangd/index/Background.cpp:197
+Cmd.CommandLine.push_back("-resource-dir=" + ResourceDir);
+const std::string FileName = Cmd.Filename;
+if (auto Error = index(std::move(Cmd), Storage))

kadircet wrote:
> ilya-biryukov wrote:
> > use `llvm::StringRef`
> If the command fails we want to show the filename but we are moving the Cmd, 
> so we need to keep a copy of the filename.
Ah, we're moving out of `Cmd` here... I'd say `index` should accept a `const 
CompileCommand&`? If the goal was to optimize for less copies, then we failed - 
now we need to copy the filename string. `index()` is not part of this patch, 
though, so let's not change it.

Could you add a comment that we can't use `StringRef` because we move from Cmd? 
It's easy to miss.



Comment at: clangd/index/Background.cpp:312
+  // Skip if file is already up to date.
+  auto DigestIt = IndexedFileDigests.try_emplace(Path);
+  if (!DigestIt.second && DigestIt.first->second == Hash)

We still update digests and symbols non-atomically in that case. Could we do 
both under the same lock, similar to how it's done in `loadShards`?



Comment at: clangd/index/Background.cpp:259
+  // if this thread sees the older version but finishes later. This should
+  // be rare in practice.
+  DigestIt.first->second = Hash;

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > ilya-biryukov wrote:
> > > > kadircet wrote:
> > > > > ilya-biryukov wrote:
> > > > > > > "should be rare in practice"
> > > > > > And yet, can we avoid this altogether?
> > > > > > 
> > > > > > Also, I believe it won't be rare. When processing multiple 
> > > > > > different TUs, we can easily run into the same header multiple 
> > > > > > times, possibly with the different contents.
> > > > > > E.g. imagine the index for the whole of clang is being built and 
> > > > > > the user is editing `Sema.h` at the same time. We'll definitely be 
> > > > > > running into this case over and over again.
> > > > > Well I am open to ideas, but currently there is no way of knowing 
> > > > > whether this is the newer version for the file. Because only 
> > > > > information we have is the digest is different than what we currently 
> > > > > have and this doesn't yield any chronological information.
> > > > Do we know which request is "newer" when scheduling it?
> > > > If so, we could keep the map of the **latest** hashes of the files 
> > > > we've seen (in addition to the `IndexedFileDigests`, which correspond 
> > > > to the digest for which we built the index IIUC).
> > > > 
> > > > This would give us a simple invariant of the final state we want to 
> > > > bring the index to: `IndexedFileDigests` should correspond to the 
> > > > latest hashes seen so far. If not, we have to rebuild the index for the 
> > > > corresponding files. That, in turn, gives us a way to resolve 
> > > > conflicts: we should never replace with symbols built for the latest 
> > > > version (hash) of the file we've seen.
> > > > 
> > > > Would that work?
> > > I am not sure if it would work for non-main files. We update the Hash for 
> > > the main files at each indexing action, so we can safely keep track of 
> > > the latest versions. But we collect hashes for dependencies while 
> > > performing the indexing which happens in parallel. Therefore an indexing 
> > > action triggered earlier might get an up-to-date version of a dependency 
> > > than an action triggered later-on.
> > If updates for each TU are atomic (i.e. all files included in the TU are 
> > updated in a single go) we would get the up-to-date index eventually, 
> > assuming we rebuild the index when TU dependencies change (we don't 
> > schedule rebuilds on changes to included header now, but we're planning to 
> > do so at some point).
> Sure, that assumption seems more relaxed than the previous one, just wanna 
> make sure I got it right:
> Your suggested solution assumes: Dependencies of a TU won't change during 
> indexing of that TU
> Whereas the previous assumption was: Files won't change between close 
> indexing actions
Exactly. The idea is that eventually we'll start tracking changes and will be 
able to detect even those cases and rebuild the index accordingly. Just trying 
to keep us from drifting away from that model too much.

> files won't change between close indexing actions
This assumption worked fine for indexing actions running right away, but I 
think the situation with loading shards is different: the shards we are loading 
might be old and if we don't want a stale shard (which might be arbitrarily 
old) to overwrite results of the 

[libunwind] r350705 - [Sparc] Add Sparc V8 support

2019-01-09 Thread Daniel Cederman via cfe-commits
Author: dcederman
Date: Wed Jan  9 04:06:05 2019
New Revision: 350705

URL: http://llvm.org/viewvc/llvm-project?rev=350705=rev
Log:
[Sparc] Add Sparc V8 support

Summary:
Adds the register class implementation for Sparc.
Adds support for DW_CFA_GNU_window_save.
Adds save and restore context functionality.

On Sparc the return address is the address of the call instruction,
so an offset needs to be added when returning to skip the call instruction
and its delay slot. If the function returns a struct it is also necessary
to skip one extra instruction.

Reviewers: jyknight, mclow.lists, mstorsjo, compnerd

Reviewed By: compnerd

Subscribers: fedor.sergeev, JDevlieghere, ldionne, libcxx-commits

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

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=350705=350704=350705=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Wed Jan  9 04:06:05 2019
@@ -23,6 +23,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__i386__)
@@ -113,6 +114,11 @@
 #error "Unsupported MIPS ABI and/or environment"
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
+# elif defined(__sparc__)
+  #define _LIBUNWIND_TARGET_SPARC 1
+  #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
+  #define _LIBUNWIND_CONTEXT_SIZE 16
+  #define _LIBUNWIND_CURSOR_SIZE 23
 # else
 #  error "Unsupported architecture."
 # endif
@@ -126,6 +132,7 @@
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
+# define _LIBUNWIND_TARGET_SPARC 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=350705=350704=350705=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed Jan  9 04:06:05 2019
@@ -823,4 +823,40 @@ enum {
   UNW_MIPS_LO = 65,
 };
 
+// SPARC registers
+enum {
+  UNW_SPARC_G0 = 0,
+  UNW_SPARC_G1 = 1,
+  UNW_SPARC_G2 = 2,
+  UNW_SPARC_G3 = 3,
+  UNW_SPARC_G4 = 4,
+  UNW_SPARC_G5 = 5,
+  UNW_SPARC_G6 = 6,
+  UNW_SPARC_G7 = 7,
+  UNW_SPARC_O0 = 8,
+  UNW_SPARC_O1 = 9,
+  UNW_SPARC_O2 = 10,
+  UNW_SPARC_O3 = 11,
+  UNW_SPARC_O4 = 12,
+  UNW_SPARC_O5 = 13,
+  UNW_SPARC_O6 = 14,
+  UNW_SPARC_O7 = 15,
+  UNW_SPARC_L0 = 16,
+  UNW_SPARC_L1 = 17,
+  UNW_SPARC_L2 = 18,
+  UNW_SPARC_L3 = 19,
+  UNW_SPARC_L4 = 20,
+  UNW_SPARC_L5 = 21,
+  UNW_SPARC_L6 = 22,
+  UNW_SPARC_L7 = 23,
+  UNW_SPARC_I0 = 24,
+  UNW_SPARC_I1 = 25,
+  UNW_SPARC_I2 = 26,
+  UNW_SPARC_I3 = 27,
+  UNW_SPARC_I4 = 28,
+  UNW_SPARC_I5 = 29,
+  UNW_SPARC_I6 = 30,
+  UNW_SPARC_I7 = 31,
+};
+
 #endif

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=350705=350704=350705=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Wed Jan  9 04:06:05 2019
@@ -223,6 +223,14 @@ int DwarfInstructions::stepWithDwa
   }
 #endif
 
+#if defined(_LIBUNWIND_TARGET_SPARC)
+  // Skip call site instruction and delay slot
+  returnAddress += 8;
+  // Skip unimp instruction if function returns a struct
+  if ((addressSpace.get32(returnAddress) & 0xC1C0) == 0)
+returnAddress += 4;
+#endif
+
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=350705=350704=350705=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Wed 

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1350946 , @JonasToth wrote:

> Should still be fixed for 8.0 (probably with this patch). The refactoring is 
> more realistic to land in 9.0 i guess?


That's why I said timing is unfortunate :).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


Re: r346652 - Make clang-based tools find libc++ on MacOS

2019-01-09 Thread Ilya Biryukov via cfe-commits
Glad to help. The fix has landed. Let me know if the problem persists after
it's integrated.

On Tue, Jan 8, 2019 at 7:36 PM Nico Weber  wrote:

> That looks like it should help. Thanks for the quick fix!
>
> On Tue, Jan 8, 2019 at 1:11 PM Ilya Biryukov  wrote:
>
>> Hi Nico,
>>
>> This is clearly a bug, it's supposed to search in a sibling directory.
>> Are you running clang as './clang' in the scripts?  The code seems to
>> break in that case, https://reviews.llvm.org/D56446 should fix this.
>>
>> On Tue, Jan 8, 2019 at 5:12 PM Nico Weber  wrote:
>>
>>> It looks like clang now looks for libc++ headers in -internal-isystem
>>> Release+Asserts/bin/include/c++/v1 , compared to -internal-isystem
>>> Release+Asserts/include/c++/v1. `make install` puts the libc++ headers in
>>> Release+Asserts/include, the old location. Was this an intentional change?
>>>
>>> As-is, this seems to break chromium's clang ability to find libc++
>>> headers (https://crbug.com/919761) because we bundle libc++ headers in
>>> an "include" directory that's a sibling to the "bin" directory (and have
>>> been doing so for 4.5 years, since
>>> https://codereview.chromium.org/281753002).
>>>
>>> On Mon, Nov 12, 2018 at 8:58 AM Ilya Biryukov via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ibiryukov
 Date: Mon Nov 12 05:55:55 2018
 New Revision: 346652

 URL: http://llvm.org/viewvc/llvm-project?rev=346652=rev
 Log:
 Make clang-based tools find libc++ on MacOS

 Summary:
 When they read compiler args from compile_commands.json.
 This change allows to run clang-based tools, like clang-tidy or clangd,
 built from head using the compile_commands.json file produced for XCode
 toolchains.

 On MacOS clang can find the C++ standard library relative to the
 compiler installation dir.

 The logic to do this was based on resource dir as an approximation of
 where the compiler is installed. This broke the tools that read
 'compile_commands.json' and don't ship with the compiler, as they
 typically change resource dir.

 To workaround this, we now use compiler install dir detected by the
 driver
 to better mimic the behavior of the original compiler when replaying the
 compilations using other tools.

 Reviewers: sammccall, arphaman, EricWF

 Reviewed By: sammccall

 Subscribers: ioeric, christof, kadircet, cfe-commits

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

 Added:
 cfe/trunk/test/Tooling/Inputs/mock-libcxx/
 cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/
 cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/
 cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/
 cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
 cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
 cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
 Modified:
 cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
 cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
 cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
 cfe/trunk/lib/Tooling/Tooling.cpp

 Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346652=346651=346652=diff

 ==
 --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
 +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12
 05:55:55 2018
 @@ -108,6 +108,13 @@ public:
/// etc.).
std::string ResourceDir;

 +  /// Compiler install dir as detected by the Driver.
 +  /// This is typically the directory that contains the clang
 executable, i.e.
 +  /// the 'bin/' subdir of a clang distribution.
 +  /// Only used to add include dirs for libc++ on Darwin. Please avoid
 relying
 +  /// on this field for other purposes.
 +  std::string InstallDir;
 +
/// The directory used for the module cache.
std::string ModuleCachePath;


 Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346652=346651=346652=diff

 ==
 --- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
 (original)
 +++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Mon Nov
 12 05:55:55 2018
 @@ -11,17 +11,18 @@
  //

  
 //===--===//

 -#include "clang/Frontend/Utils.h"
  #include "clang/Basic/DiagnosticOptions.h"
 +#include 

[PATCH] D56323: [clang-tidy] Handle member variables in readability-simplify-boolean-expr

2019-01-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@LegalizeAdulthood your stuck on the commit right things right? If you want I 
can commit for you (maybe even later) as you said you are limited on time.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56323/new/

https://reviews.llvm.org/D56323



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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:27
+static bool isGoogletestTestMacro(StringRef MacroName) {
+  static const llvm::StringSet<> MacroNames = {"TEST", "TEST_F", "TEST_P",
+   "TYPED_TEST", "TYPED_TEST_P"};

MyDeveloperDay wrote:
> karepker wrote:
> > MyDeveloperDay wrote:
> > > Is there value in making the list of macros and option?, I've worked with 
> > > other unit testing packages (some inhouse) that use the same format as 
> > > google test, but don't use TEST() itself
> > > 
> > > e.g.  (to name a few)
> > > 
> > > ```
> > > TEST_CASE(testclass, testname)
> > > BOOST_TEST(statement, floating_point_comparison_manipulation);
> > > BOOST_DATA_TEST_CASE(test_case_name, dataset)
> > > BOOST_FIXTURE_TEST_CASE( test_case2, F )
> > > BOOST_AUTO_TEST_CASE( test_case3 )
> > > 
> > > ```
> > > 
> > > too many for you to capture in the checker...but a nice addition for 
> > > those who use alternative frameworks and would like to benefit from 
> > > similar  "no underscore" naming conventions
> > > 
> > I'm not familiar with, e.g. the boost testing framework, so I don't know 
> > how closely it mirrors Googletest, but I think my preference would be to 
> > have a separate check for other testing frameworks.
> > 
> > While the testing frameworks might share some high-level similarities, 
> > there could be some different corner cases which would make having a 
> > separate check worth it as opposed to making this code more complex by 
> > trying to generalize it for several cases. At the very least, a different 
> > diagnostic message would be required. Factoring out similar functionality 
> > into some utility functions might reduce some of the boilerplate from 
> > implementing separate checks.
> Maybe, but a shame as the code for a different check would be almost 
> identical and unlikely to be able to support seperate in house systems that 
> work on the same principle, of combining the testcase and testname as a macro 
> and the presense of _ at the start or in the middle generating invalid 
> symbols or ambiguities.
> 
> So perhaps even the
> 
> > "according to Googletest FAQ"
> 
> might be unnecessary text anyway for the warning, its easily something that 
> can go in the documentation for the justification for the checker, I'm not 
> sure everyone needs to see this every time they look at a warning..
> 
> most checks just say what to do, not why its a bad idea or where to find the 
> justification.
> 
> e.g.
> 
> 
> ```
> diag(Loc, "do not use unnamed namespaces in header files");
> ```
> 
> 
> Maybe, but a shame as the code for a different check would be almost 
> identical and unlikely to be able to support seperate in house systems that 
> work on the same principle, of combining the testcase and testname as a macro 
> and the presense of _ at the start or in the middle generating invalid 
> symbols or ambiguities.

I agree that we should reuse the code as much as possible. As @karepker 
mentioned, we don't know the details about other testing frameworks (they may 
use the same principle), it is unsafe to make this assumption.

Note that the original motivation of this check is for google test framework, I 
think we should focus on this scope in this patch, rather than trying to make 
this check fit everything. And we could always find a way to reuse the code 
(either by making this check more general, configurable or by creating a base 
class) if in the future we want to support other test frameworks.


> So perhaps even the
> 
> "according to Googletest FAQ"
> 
> might be unnecessary text anyway for the warning, its easily something that 
> can go in the documentation for the justification for the checker, I'm not 
> sure everyone needs to see this every time they look at a warning..

As a user not familiar with gtest internal implementation, I found the 
diagnostic "avoid using \"_\" in test case name \"%0\"" a bit confusing, I 
don't know why `_` is not allowed, adding `according to Googletest FAQ` words 
would make it clearer to users, at least given them a clue ;)




Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56424/new/

https://reviews.llvm.org/D56424



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


[PATCH] D55948: Modify DeclaratorChuck::getFunction to use DeclSpec for qualifiers

2019-01-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350703: Use DeclSpec for quals in 
DeclaratorChunk::FunctionTypeInfo. (authored by stulova, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55948/new/

https://reviews.llvm.org/D55948

Files:
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp

Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -1206,12 +1206,8 @@
   /*hasProto=*/true,
   /*isAmbiguous=*/false, LParenLoc, ParamInfo.data(),
   ParamInfo.size(), EllipsisLoc, RParenLoc,
-  DS.getTypeQualifiers(),
   /*RefQualifierIsLValueRef=*/true,
-  /*RefQualifierLoc=*/NoLoc,
-  /*ConstQualifierLoc=*/NoLoc,
-  /*VolatileQualifierLoc=*/NoLoc,
-  /*RestrictQualifierLoc=*/NoLoc, MutableLoc, ESpecType,
+  /*RefQualifierLoc=*/NoLoc, MutableLoc, ESpecType,
   ESpecRange, DynamicExceptions.data(),
   DynamicExceptionRanges.data(), DynamicExceptions.size(),
   NoexceptExpr.isUsable() ? NoexceptExpr.get() : nullptr,
@@ -1273,12 +1269,8 @@
   /*NumParams=*/0,
   /*EllipsisLoc=*/NoLoc,
   /*RParenLoc=*/NoLoc,
-  /*TypeQuals=*/0,
   /*RefQualifierIsLValueRef=*/true,
-  /*RefQualifierLoc=*/NoLoc,
-  /*ConstQualifierLoc=*/NoLoc,
-  /*VolatileQualifierLoc=*/NoLoc,
-  /*RestrictQualifierLoc=*/NoLoc, MutableLoc, EST_None,
+  /*RefQualifierLoc=*/NoLoc, MutableLoc, EST_None,
   /*ESpecRange=*/SourceRange(),
   /*Exceptions=*/nullptr,
   /*ExceptionRanges=*/nullptr,
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2346,32 +2346,22 @@
   if (D.isFunctionDeclarator()) {
 auto  = D.getFunctionTypeInfo();
 if (DS.getTypeQualifiers() != DeclSpec::TQ_unspecified) {
-  auto DeclSpecCheck = [&] (DeclSpec::TQ TypeQual,
-const char *FixItName,
-SourceLocation SpecLoc,
-unsigned* QualifierLoc) {
+  auto DeclSpecCheck = [&](DeclSpec::TQ TypeQual, StringRef FixItName,
+   SourceLocation SpecLoc) {
 FixItHint Insertion;
-if (DS.getTypeQualifiers() & TypeQual) {
-  if (!(Function.TypeQuals & TypeQual)) {
-std::string Name(FixItName);
-Name += " ";
-Insertion = FixItHint::CreateInsertion(VS.getFirstLocation(), Name);
-Function.TypeQuals |= TypeQual;
-*QualifierLoc = SpecLoc.getRawEncoding();
-  }
-  Diag(SpecLoc, diag::err_declspec_after_virtspec)
+auto  = Function.getOrCreateMethodQualifiers();
+if (!(MQ.getTypeQualifiers() & TypeQual)) {
+  std::string Name(FixItName.data());
+  Name += " ";
+  Insertion = FixItHint::CreateInsertion(VS.getFirstLocation(), Name);
+  MQ.SetTypeQual(TypeQual, SpecLoc);
+}
+Diag(SpecLoc, diag::err_declspec_after_virtspec)
 << FixItName
 << VirtSpecifiers::getSpecifierName(VS.getLastSpecifier())
-<< FixItHint::CreateRemoval(SpecLoc)
-<< Insertion;
-}
+<< FixItHint::CreateRemoval(SpecLoc) << Insertion;
   };
-  DeclSpecCheck(DeclSpec::TQ_const, "const", DS.getConstSpecLoc(),
-);
-  DeclSpecCheck(DeclSpec::TQ_volatile, "volatile", DS.getVolatileSpecLoc(),
-);
-  DeclSpecCheck(DeclSpec::TQ_restrict, "restrict", DS.getRestrictSpecLoc(),
-);
+  DS.forEachQualifier(DeclSpecCheck);
 }
 
 // Parse ref-qualifiers.
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -3012,12 +3012,8 @@
  /*NumArgs=*/0,
  /*EllipsisLoc=*/NoLoc,
  /*RParenLoc=*/NoLoc,
- /*TypeQuals=*/0,
  /*RefQualifierIsLvalueRef=*/true,
  

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D56444#1350897 , @steveire wrote:

> The timing of this is unfortunate because the change will not be needed soon. 
> Refactoring is underway to extract a generic traverser from ASTDumper. Then 
> the parent/child traversal of ASTMatchFinder can be implemented in terms of 
> it without any of these kinds of problems. See
>
> http://clang-developers.42468.n3.nabble.com/Dumping-AST-information-to-other-formats-tp4062988p4063004.html


Should still be fixed for 8.0 (probably with this patch). The refactoring is 
more realistic to land in 9.0 i guess?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56446: [Driver] Fix libcxx detection on Darwin with clang run as ./clang

2019-01-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350714: [Driver] Fix libcxx detection on Darwin with clang 
run as ./clang (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56446?vs=180691=180822#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56446/new/

https://reviews.llvm.org/D56446

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/darwin-stdlib.cpp
  test/Tooling/Inputs/mock-libcxx/bin/clang


Index: test/Driver/darwin-stdlib.cpp
===
--- test/Driver/darwin-stdlib.cpp
+++ test/Driver/darwin-stdlib.cpp
@@ -14,7 +14,7 @@
 // optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
 
 // CHECK-LIBCXX: "-stdlib=libc++"
-// CHECK-LIBCXX: "-internal-isystem" 
"{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK-LIBCXX: "-internal-isystem" 
"{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1"
 
 // CHECK-LIBSTDCXX-NOT: -stdlib=libc++
 // CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++
Index: test/Tooling/Inputs/mock-libcxx/bin/clang
===
--- test/Tooling/Inputs/mock-libcxx/bin/clang
+++ test/Tooling/Inputs/mock-libcxx/bin/clang
@@ -0,0 +1 @@
+This file is a placeholder to keep its parent directory in git.
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1752,10 +1752,11 @@
   break;
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-// Get from 'foo/bin' to 'foo'.
-SmallString<128> P = llvm::sys::path::parent_path(InstallDir);
-// Get to 'foo/include/c++/v1'.
-llvm::sys::path::append(P, "include", "c++", "v1");
+// Get from 'foo/bin' to 'foo/include/c++/v1'.
+SmallString<128> P = InstallDir;
+// Note that InstallDir can be relative, so we have to '..' and not
+// parent_path.
+llvm::sys::path::append(P, "..", "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, P);
 break;
   }


Index: test/Driver/darwin-stdlib.cpp
===
--- test/Driver/darwin-stdlib.cpp
+++ test/Driver/darwin-stdlib.cpp
@@ -14,7 +14,7 @@
 // optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
 
 // CHECK-LIBCXX: "-stdlib=libc++"
-// CHECK-LIBCXX: "-internal-isystem" "{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK-LIBCXX: "-internal-isystem" "{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1"
 
 // CHECK-LIBSTDCXX-NOT: -stdlib=libc++
 // CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++
Index: test/Tooling/Inputs/mock-libcxx/bin/clang
===
--- test/Tooling/Inputs/mock-libcxx/bin/clang
+++ test/Tooling/Inputs/mock-libcxx/bin/clang
@@ -0,0 +1 @@
+This file is a placeholder to keep its parent directory in git.
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1752,10 +1752,11 @@
   break;
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-// Get from 'foo/bin' to 'foo'.
-SmallString<128> P = llvm::sys::path::parent_path(InstallDir);
-// Get to 'foo/include/c++/v1'.
-llvm::sys::path::append(P, "include", "c++", "v1");
+// Get from 'foo/bin' to 'foo/include/c++/v1'.
+SmallString<128> P = InstallDir;
+// Note that InstallDir can be relative, so we have to '..' and not
+// parent_path.
+llvm::sys::path::append(P, "..", "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, P);
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r350715 - Fix clang-tidy test after r350714. NFC

2019-01-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jan  9 05:08:31 2019
New Revision: 350715

URL: http://llvm.org/viewvc/llvm-project?rev=350715=rev
Log:
Fix clang-tidy test after r350714. NFC

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/bin/
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/bin/clang

Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/bin/clang
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/bin/clang?rev=350715=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/bin/clang (added)
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/bin/clang Wed 
Jan  9 05:08:31 2019
@@ -0,0 +1 @@
+This file is a placeholder to keep its parent directory in git.


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


[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clangd/index/Index.h:188
   /// candidate list. For example, "(X x, Y y) const" is a function signature.
+  /// This field is only meaningful when the symbol is indexed for completion.
   llvm::StringRef Signature;

NIT: Maybe change to `only set when the symbol...`?  "Meaningful" might create 
confusion.



Comment at: clangd/index/SymbolCollector.cpp:543
+
+  if (!(S.Flags & Symbol::IndexedForCodeCompletion))
+return Insert(S);

hokein wrote:
> ilya-biryukov wrote:
> > hokein wrote:
> > > ilya-biryukov wrote:
> > > > Most of the fields updated at the bottom aren't useful. However, I feel 
> > > > the documentation is actually important, since Sema only has doc 
> > > > comments for the **current** file and the rest are currently expected 
> > > > to be provided by the index.
> > > > 
> > > > I'm not sure if we already have the code to query the doc comments via 
> > > > index for member completions. If not, it's an oversight.
> > > > In any case, I suggest we **always** store the comments in **dynamic** 
> > > > index. Not storing the comments in the static index is fine, since any 
> > > > data for member completions should be provided by the dynamic index (we 
> > > > see a member in completion ⇒ sema has processed the headers ⇒ the 
> > > > dynamic index should know about those members)
> > > This is a good point.
> > > 
> > > For class member completions, we rely solely on Sema completions (no 
> > > query being queried). I'm not sure it is practical to query the index for 
> > > member completions.
> > > - this means for **every** code completion, we query the index, it may 
> > > slow down completions
> > > - `fuzzyFind` is not supported for class members in our internal index 
> > > service (due to the large number of them)
> > > 
> > > So it turns two possibilities:
> > > 
> > > 1) always store comments (`SymbolCollector` doesn't know whether it is 
> > > used in static index or dynamic index)
> > > 2) or drop them for now, this wouldn't break anything, and add it back 
> > > when we actually use them for class completions
> > > 
> > > I slightly prefer 2) at the moment. WDYT?
> > Yeah, instead of using `fuzzyFind()`, we'll call  `lookup()` to get details 
> > of the symbols we've discovered.
> > It's true that this is going to add some latency, but I hope we have the 
> > latency budget to handle this (these queries should be fast, e.g. we're 
> > doing this for signature help and I haven't seen any noticeable latency 
> > there from the index query, most of the running time is parsing C++).
> > 
> > I also like option 2, but unfortunately we already rely on this to get the 
> > comments in signature help, so this change would actually introduce 
> > regressions there (less used than code completion, but still not nice to 
> > break it)
> > Would the third option of having a config option (e.g. 
> > `SymbolCollector::Options::StoreAllComments`) work?  `clangd-indexer` and 
> > auto-indexer would set the option to false, `indexSymbols` would set the 
> > option to true. We'll both get the optimizations and avoid introducing any 
> > regressions. The plumbing should be no more than a few lines of code.
> Sounds fair. I totally missed `signature help`, it is unfortunate that our 
> test case doesn't find this regression (added one!)
> 
> > Would the third option of having a config option (e.g. 
> > SymbolCollector::Options::StoreAllComments) work?  clangd-indexer and 
> > auto-indexer would set the option to false, indexSymbols would set the 
> > option to true. We'll both get the optimizations and avoid introducing any 
> > regressions. The plumbing should be no more than a few lines of code.
> 
> This is a reasonable solution, but I prefer to do it in a separated patch. 
> Now I make this patch always store docs, which should not introduce any 
> regressions. There is another optimization opportunity here -- unlike header 
> symbols, docs from main-file symbols can be dropped from the index, we can 
> retrieve them from Sema.
Totally, the main file symbol docs are not necessary. OTOH, the savings for the 
main files should be almost negligible, since there are not that many main 
files open at a time and comments is just a small fraction of the information 
we store for each file (preabmles, source code contents, etc.)



Comment at: clangd/index/SymbolCollector.cpp:538
+
+  auto Insert = [this](const Symbol& S) {
+Symbols.insert(S);

NIT: consider inlining the lamda, the code inside it is simple enough.
Up to you, though.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56314/new/

https://reviews.llvm.org/D56314



___
cfe-commits mailing list

[PATCH] D56483: [clangd] Add a test for SignatureHelp on dynamic index.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350720: [clangd] Add a test for SignatureHelp on dynamic 
index. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56483/new/

https://reviews.llvm.org/D56483

Files:
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1793,6 +1793,37 @@
 SigDoc("Doc from sema";
 }
 
+TEST(SignatureHelpTest, DynamicIndexDocumentation) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true;
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+  FS.Files[testPath("foo.h")] = R"cpp(
+struct Foo {
+   // Member doc
+   int foo();
+};
+  )cpp";
+  Annotations FileContent(R"cpp(
+#include "foo.h"
+void test() {
+  Foo f;
+  f.foo(^);
+}
+  )cpp");
+  auto File = testPath("test.cpp");
+  Server.addDocument(File, FileContent.code());
+  // Wait for the dynamic index being built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(
+  llvm::cantFail(runSignatureHelp(Server, File, FileContent.point()))
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Member doc";
+}
+
 TEST(CompletionTest, CompletionFunctionArgsDisabled) {
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1793,6 +1793,37 @@
 SigDoc("Doc from sema";
 }
 
+TEST(SignatureHelpTest, DynamicIndexDocumentation) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true;
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+  FS.Files[testPath("foo.h")] = R"cpp(
+struct Foo {
+   // Member doc
+   int foo();
+};
+  )cpp";
+  Annotations FileContent(R"cpp(
+#include "foo.h"
+void test() {
+  Foo f;
+  f.foo(^);
+}
+  )cpp");
+  auto File = testPath("test.cpp");
+  Server.addDocument(File, FileContent.code());
+  // Wait for the dynamic index being built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(
+  llvm::cantFail(runSignatureHelp(Server, File, FileContent.point()))
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Member doc";
+}
+
 TEST(CompletionTest, CompletionFunctionArgsDisabled) {
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r350720 - [clangd] Add a test for SignatureHelp on dynamic index.

2019-01-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jan  9 05:42:03 2019
New Revision: 350720

URL: http://llvm.org/viewvc/llvm-project?rev=350720=rev
Log:
[clangd] Add a test for SignatureHelp on dynamic index.

Summary: This would catch regressions caused by future changes of the index.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

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

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=350720=350719=350720=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Wed Jan  9 
05:42:03 2019
@@ -1793,6 +1793,37 @@ TEST(SignatureHelpTest, IndexDocumentati
 SigDoc("Doc from sema";
 }
 
+TEST(SignatureHelpTest, DynamicIndexDocumentation) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true;
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+  FS.Files[testPath("foo.h")] = R"cpp(
+struct Foo {
+   // Member doc
+   int foo();
+};
+  )cpp";
+  Annotations FileContent(R"cpp(
+#include "foo.h"
+void test() {
+  Foo f;
+  f.foo(^);
+}
+  )cpp");
+  auto File = testPath("test.cpp");
+  Server.addDocument(File, FileContent.code());
+  // Wait for the dynamic index being built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(
+  llvm::cantFail(runSignatureHelp(Server, File, FileContent.point()))
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Member doc";
+}
+
 TEST(CompletionTest, CompletionFunctionArgsDisabled) {
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;


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


[PATCH] D56483: [clangd] Add a test for SignatureHelp on dynamic index.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.

This would catch regressions caused by future changes of the index.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56483

Files:
  unittests/clangd/CodeCompleteTests.cpp


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1793,6 +1793,37 @@
 SigDoc("Doc from sema";
 }
 
+TEST(SignatureHelpTest, DynamicIndexDocumentation) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true;
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+  FS.Files[testPath("foo.h")] = R"cpp(
+struct Foo {
+   // Member doc
+   int foo();
+};
+  )cpp";
+  Annotations FileContent(R"cpp(
+#include "foo.h"
+void test() {
+  Foo f;
+  f.foo(^);
+}
+  )cpp");
+  auto File = testPath("test.cpp");
+  Server.addDocument(File, FileContent.code());
+  // Wait for the dynamic index being built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(
+  llvm::cantFail(runSignatureHelp(Server, File, FileContent.point()))
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Member doc";
+}
+
 TEST(CompletionTest, CompletionFunctionArgsDisabled) {
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1793,6 +1793,37 @@
 SigDoc("Doc from sema";
 }
 
+TEST(SignatureHelpTest, DynamicIndexDocumentation) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true;
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+  FS.Files[testPath("foo.h")] = R"cpp(
+struct Foo {
+   // Member doc
+   int foo();
+};
+  )cpp";
+  Annotations FileContent(R"cpp(
+#include "foo.h"
+void test() {
+  Foo f;
+  f.foo(^);
+}
+  )cpp");
+  auto File = testPath("test.cpp");
+  Server.addDocument(File, FileContent.code());
+  // Wait for the dynamic index being built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(
+  llvm::cantFail(runSignatureHelp(Server, File, FileContent.point()))
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Member doc";
+}
+
 TEST(CompletionTest, CompletionFunctionArgsDisabled) {
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/index/Background.cpp:259
+  // if this thread sees the older version but finishes later. This should
+  // be rare in practice.
+  DigestIt.first->second = Hash;

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > ilya-biryukov wrote:
> > > > > "should be rare in practice"
> > > > And yet, can we avoid this altogether?
> > > > 
> > > > Also, I believe it won't be rare. When processing multiple different 
> > > > TUs, we can easily run into the same header multiple times, possibly 
> > > > with the different contents.
> > > > E.g. imagine the index for the whole of clang is being built and the 
> > > > user is editing `Sema.h` at the same time. We'll definitely be running 
> > > > into this case over and over again.
> > > Well I am open to ideas, but currently there is no way of knowing whether 
> > > this is the newer version for the file. Because only information we have 
> > > is the digest is different than what we currently have and this doesn't 
> > > yield any chronological information.
> > Do we know which request is "newer" when scheduling it?
> > If so, we could keep the map of the **latest** hashes of the files we've 
> > seen (in addition to the `IndexedFileDigests`, which correspond to the 
> > digest for which we built the index IIUC).
> > 
> > This would give us a simple invariant of the final state we want to bring 
> > the index to: `IndexedFileDigests` should correspond to the latest hashes 
> > seen so far. If not, we have to rebuild the index for the corresponding 
> > files. That, in turn, gives us a way to resolve conflicts: we should never 
> > replace with symbols built for the latest version (hash) of the file we've 
> > seen.
> > 
> > Would that work?
> I am not sure if it would work for non-main files. We update the Hash for the 
> main files at each indexing action, so we can safely keep track of the latest 
> versions. But we collect hashes for dependencies while performing the 
> indexing which happens in parallel. Therefore an indexing action triggered 
> earlier might get an up-to-date version of a dependency than an action 
> triggered later-on.
If updates for each TU are atomic (i.e. all files included in the TU are 
updated in a single go) we would get the up-to-date index eventually, assuming 
we rebuild the index when TU dependencies change (we don't schedule rebuilds on 
changes to included header now, but we're planning to do so at some point).



Comment at: clangd/index/Background.cpp:468
+if (!Shard || !Shard->Sources) {
+  vlog("Failed to load shard: {0}", CurDependencyPath);
+  continue;

kadircet wrote:
> ilya-biryukov wrote:
> > Should we mark the file as requiring re-indexing at this point?
> > Not sure how that might happen in practice, but still...
> All files are marked as requiring re-indexing by default 
> `Dependencies.push_back({AbsolutePath, true})`. The second element is always 
> true, and we only mark it as false if we are sure file is up-to-date.
My confusion is coming from the fact that I'm constantly forgetting that we 
return the queue we're processing afterwards.
Could you put a small comment that file will be returned to the caller as 
requiring a reindex here?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55224/new/

https://reviews.llvm.org/D55224



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/SourceCode.h:107
+// "/tmp/build/foo.h"
+std::string makeCanonicalPath(llvm::StringRef AbsolutePath,
+  const SourceManager );

This changes should go away after the rebase, right?
Could you please run the rebase to make sure the patch is in its final state.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55224/new/

https://reviews.llvm.org/D55224



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


[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 180808.
hokein marked 2 inline comments as done.
hokein added a comment.

Address comments, store docs.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56314/new/

https://reviews.llvm.org/D56314

Files:
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -655,10 +655,15 @@
 void Foo::ssf() {}
   )";
   runSymbolCollector(Header, Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
-   QName("Foo::g"), QName("Foo::sf"),
-   QName("Foo::ssf"), QName("Foo::x")));
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  QName("Foo"),
+  AllOf(QName("Foo::f"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::g"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::sf"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::ssf"), ReturnType(""), ForCodeCompletion(false)),
+  AllOf(QName("Foo::x"), ReturnType(""), ForCodeCompletion(false;
 }
 
 TEST_F(SymbolCollectorTest, Scopes) {
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -531,6 +531,15 @@
   getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
 S.CanonicalDeclaration = *DeclLoc;
 
+  S.Origin = Opts.Origin;
+  if (ND.getAvailability() == AR_Deprecated)
+S.Flags |= Symbol::Deprecated;
+
+  auto Insert = [this](const Symbol& S) {
+Symbols.insert(S);
+return Symbols.find(S.ID);
+  };
+
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
@@ -540,13 +549,26 @@
   *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
   *CompletionTUInfo,
   /*IncludeBriefComments*/ false);
-  std::string Signature;
-  std::string SnippetSuffix;
-  getSignature(*CCS, , );
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
+  // For symbols not indexed for completion (class members), we also store their
+  // docs in the index, because Sema doesn't load the docs from the preamble, we
+  // rely on the index to get the docs.
+  // FIXME: this can be optimized by only storing the docs in dynamic index --
+  // dynamic index should index these symbols when Sema completes a member
+  // completion.
+  S.Documentation = Documentation;
+  if (!(S.Flags & Symbol::IndexedForCodeCompletion))
+return Insert(S);
+
+  std::string Signature;
+  std::string SnippetSuffix;
+  getSignature(*CCS, , );
+  S.Signature = Signature;
+  S.CompletionSnippetSuffix = SnippetSuffix;
   std::string ReturnType = getReturnType(*CCS);
+  S.ReturnType = ReturnType;
 
   std::string Include;
   if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
@@ -556,10 +578,6 @@
 QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
   Include = std::move(*Header);
   }
-  S.Signature = Signature;
-  S.CompletionSnippetSuffix = SnippetSuffix;
-  S.Documentation = Documentation;
-  S.ReturnType = ReturnType;
   if (!Include.empty())
 S.IncludeHeaders.emplace_back(Include, 1);
 
@@ -569,12 +587,7 @@
 if (TypeStorage)
   S.Type = TypeStorage->raw();
   }
-
-  S.Origin = Opts.Origin;
-  if (ND.getAvailability() == AR_Deprecated)
-S.Flags |= Symbol::Deprecated;
-  Symbols.insert(S);
-  return Symbols.find(S.ID);
+  return Insert(S);
 }
 
 void SymbolCollector::addDefinition(const NamedDecl ,
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -185,19 +185,23 @@
   SymbolOrigin Origin = SymbolOrigin::Unknown;
   /// A brief description of the symbol that can be appended in the completion
   /// candidate list. For example, "(X x, Y y) const" is a function signature.
+  /// This field is only meaningful when the symbol is indexed for completion.
   llvm::StringRef Signature;
   /// What to insert when completing this symbol, after the symbol name.
   /// This is in LSP snippet syntax (e.g. "({$0})" for a no-args function).
   /// (When snippets are disabled, the symbol name alone is used).
+  /// This field is only meaningful when the symbol is indexed for completion.
   llvm::StringRef CompletionSnippetSuffix;
   /// Documentation including comment for the symbol 

[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:543
+
+  if (!(S.Flags & Symbol::IndexedForCodeCompletion))
+return Insert(S);

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > Most of the fields updated at the bottom aren't useful. However, I feel 
> > > the documentation is actually important, since Sema only has doc comments 
> > > for the **current** file and the rest are currently expected to be 
> > > provided by the index.
> > > 
> > > I'm not sure if we already have the code to query the doc comments via 
> > > index for member completions. If not, it's an oversight.
> > > In any case, I suggest we **always** store the comments in **dynamic** 
> > > index. Not storing the comments in the static index is fine, since any 
> > > data for member completions should be provided by the dynamic index (we 
> > > see a member in completion ⇒ sema has processed the headers ⇒ the dynamic 
> > > index should know about those members)
> > This is a good point.
> > 
> > For class member completions, we rely solely on Sema completions (no query 
> > being queried). I'm not sure it is practical to query the index for member 
> > completions.
> > - this means for **every** code completion, we query the index, it may slow 
> > down completions
> > - `fuzzyFind` is not supported for class members in our internal index 
> > service (due to the large number of them)
> > 
> > So it turns two possibilities:
> > 
> > 1) always store comments (`SymbolCollector` doesn't know whether it is used 
> > in static index or dynamic index)
> > 2) or drop them for now, this wouldn't break anything, and add it back when 
> > we actually use them for class completions
> > 
> > I slightly prefer 2) at the moment. WDYT?
> Yeah, instead of using `fuzzyFind()`, we'll call  `lookup()` to get details 
> of the symbols we've discovered.
> It's true that this is going to add some latency, but I hope we have the 
> latency budget to handle this (these queries should be fast, e.g. we're doing 
> this for signature help and I haven't seen any noticeable latency there from 
> the index query, most of the running time is parsing C++).
> 
> I also like option 2, but unfortunately we already rely on this to get the 
> comments in signature help, so this change would actually introduce 
> regressions there (less used than code completion, but still not nice to 
> break it)
> Would the third option of having a config option (e.g. 
> `SymbolCollector::Options::StoreAllComments`) work?  `clangd-indexer` and 
> auto-indexer would set the option to false, `indexSymbols` would set the 
> option to true. We'll both get the optimizations and avoid introducing any 
> regressions. The plumbing should be no more than a few lines of code.
Sounds fair. I totally missed `signature help`, it is unfortunate that our test 
case doesn't find this regression (added one!)

> Would the third option of having a config option (e.g. 
> SymbolCollector::Options::StoreAllComments) work?  clangd-indexer and 
> auto-indexer would set the option to false, indexSymbols would set the option 
> to true. We'll both get the optimizations and avoid introducing any 
> regressions. The plumbing should be no more than a few lines of code.

This is a reasonable solution, but I prefer to do it in a separated patch. Now 
I make this patch always store docs, which should not introduce any 
regressions. There is another optimization opportunity here -- unlike header 
symbols, docs from main-file symbols can be dropped from the index, we can 
retrieve them from Sema.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56314/new/

https://reviews.llvm.org/D56314



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


r350703 - Use DeclSpec for quals in DeclaratorChunk::FunctionTypeInfo.

2019-01-09 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Jan  9 03:25:09 2019
New Revision: 350703

URL: http://llvm.org/viewvc/llvm-project?rev=350703=rev
Log:
Use DeclSpec for quals in DeclaratorChunk::FunctionTypeInfo.

Rather than duplicating data fields, use DeclSpec directly to store
the qualifiers for the functions/methods. This change doesn't handle
attributes yet and has to be extended further.

Differential revision: https://reviews.llvm.org/D55948


Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=350703=350702=350703=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Wed Jan  9 03:25:09 2019
@@ -593,6 +593,18 @@ public:
 FS_noreturnLoc = SourceLocation();
   }
 
+  /// This method calls the passed in handler on each CVRU qual being
+  /// set.
+  /// Handle - a handler to be invoked.
+  void forEachCVRUQualifier(
+  llvm::function_ref Handle);
+
+  /// This method calls the passed in handler on each qual being
+  /// set.
+  /// Handle - a handler to be invoked.
+  void forEachQualifier(
+  llvm::function_ref Handle);
+
   /// Return true if any type-specifier has been found.
   bool hasTypeSpecifier() const {
 return getTypeSpecType() != DeclSpec::TST_unspecified ||
@@ -683,6 +695,8 @@ public:
 ExprRep = Rep;
   }
 
+  bool SetTypeQual(TQ T, SourceLocation Loc);
+
   bool SetTypeQual(TQ T, SourceLocation Loc, const char *,
unsigned , const LangOptions );
 
@@ -1250,10 +1264,6 @@ struct DeclaratorChunk {
 /// Otherwise, it's an rvalue reference.
 unsigned RefQualifierIsLValueRef : 1;
 
-/// The type qualifiers: const/volatile/restrict/__unaligned
-/// The qualifier bitmask values are the same as in QualType.
-unsigned TypeQuals : 4;
-
 /// ExceptionSpecType - An ExceptionSpecificationType value.
 unsigned ExceptionSpecType : 4;
 
@@ -1287,21 +1297,6 @@ struct DeclaratorChunk {
 /// If this is an invalid location, there is no ref-qualifier.
 unsigned RefQualifierLoc;
 
-/// The location of the const-qualifier, if any.
-///
-/// If this is an invalid location, there is no const-qualifier.
-unsigned ConstQualifierLoc;
-
-/// The location of the volatile-qualifier, if any.
-///
-/// If this is an invalid location, there is no volatile-qualifier.
-unsigned VolatileQualifierLoc;
-
-/// The location of the restrict-qualifier, if any.
-///
-/// If this is an invalid location, there is no restrict-qualifier.
-unsigned RestrictQualifierLoc;
-
 /// The location of the 'mutable' qualifer in a lambda-declarator, if
 /// any.
 unsigned MutableLoc;
@@ -1317,6 +1312,12 @@ struct DeclaratorChunk {
 /// there are no parameters specified.
 ParamInfo *Params;
 
+/// DeclSpec for the function with the qualifier related info.
+DeclSpec *MethodQualifiers;
+
+/// AtttibuteFactory for the MethodQualifiers.
+AttributeFactory *QualAttrFactory;
+
 union {
   /// Pointer to a new[]'d array of TypeAndRange objects that
   /// contain the types in the function's dynamic exception specification
@@ -1356,6 +1357,8 @@ struct DeclaratorChunk {
 
 void destroy() {
   freeParams();
+  delete QualAttrFactory;
+  delete MethodQualifiers;
   switch (getExceptionSpecType()) {
   default:
 break;
@@ -1372,6 +1375,14 @@ struct DeclaratorChunk {
   }
 }
 
+DeclSpec () {
+  if (!MethodQualifiers) {
+QualAttrFactory = new AttributeFactory();
+MethodQualifiers = new DeclSpec(*QualAttrFactory);
+  }
+  return *MethodQualifiers;
+}
+
 /// isKNRPrototype - Return true if this is a K style identifier list,
 /// like "void foo(a,b,c)".  In a function definition, this will be 
followed
 /// by the parameter type definitions.
@@ -1406,19 +1417,22 @@ struct DeclaratorChunk {
   return SourceLocation::getFromRawEncoding(RefQualifierLoc);
 }
 
-/// Retrieve the location of the 'const' qualifier, if any.
+/// Retrieve the location of the 'const' qualifier.
 SourceLocation getConstQualifierLoc() const {
-  return SourceLocation::getFromRawEncoding(ConstQualifierLoc);
+  assert(MethodQualifiers);
+  return MethodQualifiers->getConstSpecLoc();
 }
 
-/// Retrieve the location of the 'volatile' qualifier, if any.
+/// Retrieve the location of the 'volatile' qualifier.
 

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D56444#1350897 , @steveire wrote:

> The timing of this is unfortunate because the change will not be needed soon.


RecursiveASTVisitor should be fixed (even if it won't be used for the parent 
map) unless it's going away entirely - it's supposed to traverse the whole AST.

> Refactoring is underway to extract a generic traverser from ASTDumper. Then 
> the parent/child traversal of ASTMatchFinder can be implemented in terms of 
> it without any of these kinds of problems.

That sounds interesting (though it's not obvious to me why ASTDumper's 
traversal is inherently less prone to these issues than RecursiveASTVisitor).
I'm not inclined to hold off fixing this bug though, because:

- it's blocking other patches, and the changes you're talking about seem likely 
to be quite involved and need some details worked out
- if we are going to switch from the RAV parent map to an 
ASTDumper-traverser-derived map, then the closer that switch is to a no-op, the 
easier it will be to land.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D56444#1350935 , @sammccall wrote:

> In D56444#1350897 , @steveire wrote:
>
> >
>
>
> I'm not inclined to hold off fixing this bug though, because:
>
> - it's blocking other patches, and the changes you're talking about seem 
> likely to be quite involved and need some details worked out
> - if we are going to switch from the RAV parent map to an 
> ASTDumper-traverser-derived map, then the closer that switch is to a no-op, 
> the easier it will be to land.


That makes sense to me, but I wanted to draw your attention to the refactoring 
effort.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

There seems to be no unexpected changes after rebase




Comment at: clangd/index/Background.cpp:259
+  // if this thread sees the older version but finishes later. This should
+  // be rare in practice.
+  DigestIt.first->second = Hash;

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > kadircet wrote:
> > > > ilya-biryukov wrote:
> > > > > > "should be rare in practice"
> > > > > And yet, can we avoid this altogether?
> > > > > 
> > > > > Also, I believe it won't be rare. When processing multiple different 
> > > > > TUs, we can easily run into the same header multiple times, possibly 
> > > > > with the different contents.
> > > > > E.g. imagine the index for the whole of clang is being built and the 
> > > > > user is editing `Sema.h` at the same time. We'll definitely be 
> > > > > running into this case over and over again.
> > > > Well I am open to ideas, but currently there is no way of knowing 
> > > > whether this is the newer version for the file. Because only 
> > > > information we have is the digest is different than what we currently 
> > > > have and this doesn't yield any chronological information.
> > > Do we know which request is "newer" when scheduling it?
> > > If so, we could keep the map of the **latest** hashes of the files we've 
> > > seen (in addition to the `IndexedFileDigests`, which correspond to the 
> > > digest for which we built the index IIUC).
> > > 
> > > This would give us a simple invariant of the final state we want to bring 
> > > the index to: `IndexedFileDigests` should correspond to the latest hashes 
> > > seen so far. If not, we have to rebuild the index for the corresponding 
> > > files. That, in turn, gives us a way to resolve conflicts: we should 
> > > never replace with symbols built for the latest version (hash) of the 
> > > file we've seen.
> > > 
> > > Would that work?
> > I am not sure if it would work for non-main files. We update the Hash for 
> > the main files at each indexing action, so we can safely keep track of the 
> > latest versions. But we collect hashes for dependencies while performing 
> > the indexing which happens in parallel. Therefore an indexing action 
> > triggered earlier might get an up-to-date version of a dependency than an 
> > action triggered later-on.
> If updates for each TU are atomic (i.e. all files included in the TU are 
> updated in a single go) we would get the up-to-date index eventually, 
> assuming we rebuild the index when TU dependencies change (we don't schedule 
> rebuilds on changes to included header now, but we're planning to do so at 
> some point).
Sure, that assumption seems more relaxed than the previous one, just wanna make 
sure I got it right:
Your suggested solution assumes: Dependencies of a TU won't change during 
indexing of that TU
Whereas the previous assumption was: Files won't change between close indexing 
actions



Comment at: clangd/index/Background.cpp:197
+Cmd.CommandLine.push_back("-resource-dir=" + ResourceDir);
+const std::string FileName = Cmd.Filename;
+if (auto Error = index(std::move(Cmd), Storage))

ilya-biryukov wrote:
> use `llvm::StringRef`
If the command fails we want to show the filename but we are moving the Cmd, so 
we need to keep a copy of the filename.



Comment at: clangd/index/Background.h:111
+bool NeedsReIndexing;
+Source(llvm::StringRef Path, bool NeedsReIndexing = true)
+: Path(Path), NeedsReIndexing(NeedsReIndexing) {}

ilya-biryukov wrote:
> NIT: maybe remove the constructor? plain structs can easily be initialized 
> with init lists and adding a constructor forbids per-field assignment, which 
> is a bit nicer in some cases.
> Not very important, since it's a private API, but still.
Once I assign a default value for NeedsReIndexing, I cannot construct Source 
objects with init lists, therefore I've added a constructor instead.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55224/new/

https://reviews.llvm.org/D55224



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


[PATCH] D56483: [clangd] Add a test for SignatureHelp on dynamic index.

2019-01-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

Many thanks! Should've been there from the start, sorry about the inconvenience


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56483/new/

https://reviews.llvm.org/D56483



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


[PATCH] D56062: [compiler-rt] [test] Detect glibc-2.27+ and XFAIL appropriate tests

2019-01-09 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT350717: [test] Detect glibc-2.27+ and XFAIL appropriate 
tests (authored by mgorny, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56062?vs=179456=180824#toc

Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56062/new/

https://reviews.llvm.org/D56062

Files:
  test/lit.common.cfg
  test/lsan/TestCases/Linux/use_tls_dynamic.cc
  test/msan/dtls_test.c


Index: test/lit.common.cfg
===
--- test/lit.common.cfg
+++ test/lit.common.cfg
@@ -289,6 +289,21 @@
   if android_api_level >= 28:
 config.available_features.add('android-28')
 
+if config.host_os == 'Linux':
+  # detect whether we are using glibc, and which version
+  # NB: 'ldd' is just one of the tools commonly installed as part of glibc
+  ldd_ver_cmd = subprocess.Popen(['ldd', '--version'],
+ stdout=subprocess.PIPE,
+ env={'LANG': 'C'})
+  sout, _ = ldd_ver_cmd.communicate()
+  ver_line = sout.splitlines()[0]
+  if ver_line.startswith(b"ldd "):
+from distutils.version import LooseVersion
+ver = LooseVersion(ver_line.split()[-1].decode())
+# 2.27 introduced some incompatibilities
+if ver >= LooseVersion("2.27"):
+  config.available_features.add("glibc-2.27")
+
 sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov")
 if os.path.exists(sancovcc_path):
   config.available_features.add("has_sancovcc")
Index: test/msan/dtls_test.c
===
--- test/msan/dtls_test.c
+++ test/msan/dtls_test.c
@@ -11,6 +11,11 @@
 
// Reports use-of-uninitialized-value, not analyzed
XFAIL: netbsd
+
+   // This is known to be broken with glibc-2.27+
+   // https://bugs.llvm.org/show_bug.cgi?id=37804
+   XFAIL: glibc-2.27
+
 */
 
 #ifndef BUILD_SO
Index: test/lsan/TestCases/Linux/use_tls_dynamic.cc
===
--- test/lsan/TestCases/Linux/use_tls_dynamic.cc
+++ test/lsan/TestCases/Linux/use_tls_dynamic.cc
@@ -1,4 +1,9 @@
 // Test that dynamically allocated TLS space is included in the root set.
+
+// This is known to be broken with glibc-2.27+
+// https://bugs.llvm.org/show_bug.cgi?id=37804
+// XFAIL: glibc-2.27
+
 // RUN: 
LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0:use_ld_allocations=0"
 // RUN: %clangxx %s -DBUILD_DSO -fPIC -shared -o %t-so.so
 // RUN: %clangxx_lsan %s -o %t


Index: test/lit.common.cfg
===
--- test/lit.common.cfg
+++ test/lit.common.cfg
@@ -289,6 +289,21 @@
   if android_api_level >= 28:
 config.available_features.add('android-28')
 
+if config.host_os == 'Linux':
+  # detect whether we are using glibc, and which version
+  # NB: 'ldd' is just one of the tools commonly installed as part of glibc
+  ldd_ver_cmd = subprocess.Popen(['ldd', '--version'],
+ stdout=subprocess.PIPE,
+ env={'LANG': 'C'})
+  sout, _ = ldd_ver_cmd.communicate()
+  ver_line = sout.splitlines()[0]
+  if ver_line.startswith(b"ldd "):
+from distutils.version import LooseVersion
+ver = LooseVersion(ver_line.split()[-1].decode())
+# 2.27 introduced some incompatibilities
+if ver >= LooseVersion("2.27"):
+  config.available_features.add("glibc-2.27")
+
 sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov")
 if os.path.exists(sancovcc_path):
   config.available_features.add("has_sancovcc")
Index: test/msan/dtls_test.c
===
--- test/msan/dtls_test.c
+++ test/msan/dtls_test.c
@@ -11,6 +11,11 @@
 
// Reports use-of-uninitialized-value, not analyzed
XFAIL: netbsd
+
+   // This is known to be broken with glibc-2.27+
+   // https://bugs.llvm.org/show_bug.cgi?id=37804
+   XFAIL: glibc-2.27
+
 */
 
 #ifndef BUILD_SO
Index: test/lsan/TestCases/Linux/use_tls_dynamic.cc
===
--- test/lsan/TestCases/Linux/use_tls_dynamic.cc
+++ test/lsan/TestCases/Linux/use_tls_dynamic.cc
@@ -1,4 +1,9 @@
 // Test that dynamically allocated TLS space is included in the root set.
+
+// This is known to be broken with glibc-2.27+
+// https://bugs.llvm.org/show_bug.cgi?id=37804
+// XFAIL: glibc-2.27
+
 // RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0:use_ld_allocations=0"
 // RUN: %clangxx %s -DBUILD_DSO -fPIC -shared -o %t-so.so
 // RUN: %clangxx_lsan %s -o %t
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >