[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-19 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 234674.
AlexeySotkin added a comment.

Rename `color` to `depth`


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

https://reviews.llvm.org/D71460

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image_writes
+#error "Missing cl_khr_mipmap_image_writes define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 
'cl_khr_mipmap_image_writes' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14682,7 +14682,8 @@
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image1d_t image, int coord, int lod, 
uint4 color);
@@ -14699,15 +14700,17 @@
 void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, 
int lod, int4 color);
 void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, 
int lod, uint4 color);
 
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float color);
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float color);
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float depth);
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float depth);
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
+#endif //defined(cl_khr_mipmap_image_writes)
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
@@ -14756,7 +14759,8 @@
 #endif //cl_khr_depth_images
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#ifdef cl_khr_mipmap_image_writes
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image1d_t image, int coord, int lod, 
uint4 color);
@@ -14780,8 +14784,10 @@
 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
+#endif //cl_khr_mipmap_image_writes
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -70,6 +70,7 @@
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: clang/test/SemaOpenCL/extension-version.cl
=

[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2019-12-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Thanks for the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder created this revision.
MadCoder added reviewers: rjmccall, dexonsmith, erik.pilkington, ahatanak, 
arphaman.
MadCoder added a project: clang.
Herald added a subscriber: cfe-commits.

Because the name of a direct method must be agreed upon by the caller and the 
implementation, certain bad practices that one can get away with when using 
dynamism are fatal with direct methods.

To avoid really weird and unscruttable linker error, tighten the front-end 
error reporting.

Rule 1:

  Direct methods can only have at most one declaration in an @interface 
container. Any redeclaration is strictly forbidden.
  Today some amount of redeclaration is tolerated between the main interface 
and categories for dynamic methods, but we can't have that.

Rule 2:

  Direct method implementations can only be declared in a matching @interface 
container: when implemented in the primary @implementation then the declaration 
must be in the primary @interface or an extension, and when implemented in a 
category, the declaration must be in the @interface for the same category.

Also fix another issue with ObjCMethod::getCanonicalDecl(): when an 
implementation lives in the primary @interface, then its canonical declaration 
can be in any extension, even when it's not an accessor.

Add Sema tests to cover the new errors, and CG tests to beef up testing around 
function names for categories and extensions.

Radar-Id: rdar://problem/58054563


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/direct-method.m
  clang/test/SemaObjC/method-direct-one-definition.m

Index: clang/test/SemaObjC/method-direct-one-definition.m
===
--- /dev/null
+++ clang/test/SemaObjC/method-direct-one-definition.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-protocol-method-implementation %s
+
+__attribute__((objc_root_class))
+@interface A
+@end
+
+@interface A (Cat)
+- (void)A_Cat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation A
+- (void)A_Cat {
+} // expected-error {{direct method was declared in a category but is implemented in the primary interface}}
+@end
+
+__attribute__((objc_root_class))
+@interface B
+- (void)B_primary __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B ()
+- (void)B_extension __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B (Cat)
+- (void)B_Cat __attribute__((objc_direct));
+@end
+
+@interface B (OtherCat)
+- (void)B_OtherCat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation B (Cat)
+- (void)B_primary { // expected-error {{direct method was declared in the primary interface but is implemented in a category}}
+}
+- (void)B_extension { // expected-error {{direct method was declared in an extension but is implemented in a different category}}
+}
+- (void)B_Cat {
+}
+- (void)B_OtherCat { // expected-error {{direct method was declared in a category but is implemented in a different category}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface C
+- (void)C1 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+- (void)C2;  // expected-note {{previous declaration is here}}
+@end
+
+@interface C (Cat)
+- (void)C1;  // expected-error {{method declaration conflicts with previous direct declaration of method 'C1'}}
+- (void)C2 __attribute__((objc_direct)); // expected-error {{direct method declaration conflicts with previous declaration of method 'C2'}}
+@end
Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -172,10 +172,19 @@
 @interface Foo ()
 @property(nonatomic, readwrite) int getDirect_setDynamic;
 @property(nonatomic, readwrite, direct) int getDynamic_setDirect;
+- (int)directMethodInExtension __attribute__((objc_direct));
+@end
+
+@interface Foo (Cat)
+- (int)directMethodInCategory __attribute__((objc_direct));
 @end
 
 __attribute__((objc_direct_members))
 @implementation Foo
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]"(
+- (int)directMethodInExtension {
+  return 42;
+}
 // CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]"(
 // CHECK-LABEL: define internal void @"\01-[Foo setGetDirect_setDynamic:]"(
 // CHECK-LABEL: define internal i32 @"\01-[Foo getDynamic_setDirect]"(
@@ -183,6 +192,17 @@
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
 
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMe

[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-19 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf20fc65887e2: [clang] Fix compilation with GCC < 8 for 
MinGW (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650

Files:
  clang/include/clang/AST/Decl.h


Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -873,6 +873,8 @@
 DAK_Normal
   };
 
+  enum { NumScopeDepthOrObjCQualsBits = 7 };
+
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -895,8 +897,6 @@
 /// Whether this parameter is an ObjC method parameter or not.
 unsigned IsObjCMethodParam : 1;
 
-enum { NumScopeDepthOrObjCQualsBits = 7 };
-
 /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
 /// Otherwise, the number of function parameter scopes enclosing
 /// the function parameter scope in which this parameter was
@@ -1627,7 +1627,7 @@
   }
 
   static constexpr unsigned getMaxFunctionScopeDepth() {
-return (1u << ParmVarDeclBitfields::NumScopeDepthOrObjCQualsBits) - 1;
+return (1u << NumScopeDepthOrObjCQualsBits) - 1;
   }
 
   /// Returns the index of this parameter in its prototype or method scope.


Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -873,6 +873,8 @@
 DAK_Normal
   };
 
+  enum { NumScopeDepthOrObjCQualsBits = 7 };
+
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -895,8 +897,6 @@
 /// Whether this parameter is an ObjC method parameter or not.
 unsigned IsObjCMethodParam : 1;
 
-enum { NumScopeDepthOrObjCQualsBits = 7 };
-
 /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
 /// Otherwise, the number of function parameter scopes enclosing
 /// the function parameter scope in which this parameter was
@@ -1627,7 +1627,7 @@
   }
 
   static constexpr unsigned getMaxFunctionScopeDepth() {
-return (1u << ParmVarDeclBitfields::NumScopeDepthOrObjCQualsBits) - 1;
+return (1u << NumScopeDepthOrObjCQualsBits) - 1;
   }
 
   /// Returns the index of this parameter in its prototype or method scope.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder updated this revision to Diff 234684.
MadCoder added a comment.

Small update because I uploaded before the full completion of the test-suite 
and somehow it's sentient and punished me... (some diagnostics were too verbose 
and stuttering things with `Sema::CheckObjCMethodOverrides`).


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

https://reviews.llvm.org/D71694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/direct-method.m
  clang/test/SemaObjC/method-direct-one-definition.m

Index: clang/test/SemaObjC/method-direct-one-definition.m
===
--- /dev/null
+++ clang/test/SemaObjC/method-direct-one-definition.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-protocol-method-implementation %s
+
+__attribute__((objc_root_class))
+@interface A
+@end
+
+@interface A (Cat)
+- (void)A_Cat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation A
+- (void)A_Cat { // expected-error {{direct method was declared in a category but is implemented in the primary interface}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface B
+- (void)B_primary __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B ()
+- (void)B_extension __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B (Cat)
+- (void)B_Cat __attribute__((objc_direct));
+@end
+
+@interface B (OtherCat)
+- (void)B_OtherCat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation B (Cat)
+- (void)B_primary { // expected-error {{direct method was declared in the primary interface but is implemented in a category}}
+}
+- (void)B_extension { // expected-error {{direct method was declared in an extension but is implemented in a different category}}
+}
+- (void)B_Cat {
+}
+- (void)B_OtherCat { // expected-error {{direct method was declared in a category but is implemented in a different category}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface C
+- (void)C1 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+- (void)C2;  // expected-note {{previous declaration is here}}
+@end
+
+@interface C (Cat)
+- (void)C1;  // expected-error {{method declaration conflicts with previous direct declaration of method 'C1'}}
+- (void)C2 __attribute__((objc_direct)); // expected-error {{direct method declaration conflicts with previous declaration of method 'C2'}}
+@end
Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -172,10 +172,19 @@
 @interface Foo ()
 @property(nonatomic, readwrite) int getDirect_setDynamic;
 @property(nonatomic, readwrite, direct) int getDynamic_setDirect;
+- (int)directMethodInExtension __attribute__((objc_direct));
+@end
+
+@interface Foo (Cat)
+- (int)directMethodInCategory __attribute__((objc_direct));
 @end
 
 __attribute__((objc_direct_members))
 @implementation Foo
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]"(
+- (int)directMethodInExtension {
+  return 42;
+}
 // CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]"(
 // CHECK-LABEL: define internal void @"\01-[Foo setGetDirect_setDynamic:]"(
 // CHECK-LABEL: define internal i32 @"\01-[Foo getDynamic_setDirect]"(
@@ -183,6 +192,17 @@
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
 
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMethodInCategory {
+  return 42;
+}
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategoryNoDecl]"(
+- (int)directMethodInCategoryNoDecl __attribute__((objc_direct)) {
+  return 42;
+}
+@end
+
 int useRoot(Root *r) {
   // CHECK-LABEL: define i32 @useRoot
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Root getInt]"
@@ -195,8 +215,14 @@
   // CHECK-LABEL: define i32 @useFoo
   // CHECK: call void bitcast {{.*}} @"\01-[Foo setGetDynamic_setDirect:]"
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo getDirect_setDynamic]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo directMethodInExtension]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo(Cat) directMethodInCategory]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo(Cat) directMethodInCategoryNoDecl]"
   [f setGetDynamic_setDirect:1];
-  return [f getDirect_setDynamic];
+  return [f getDirect_setDynamic] +
+ [f directMethodInExtension] +
+ [f directMethodInCategory] +
+ [f directMethodInCategoryNoDecl];
 }
 
 __attribute__((objc_root_class))
Index: clang/lib/S

[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder added a subscriber: aprantl.
MadCoder added inline comments.



Comment at: clang/test/CodeGenObjC/direct-method.m:196
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMethodInCategory {

this may be questionable as a chosen mangling. it's exactly what dynamic 
dispatch does, but because a direct method cannot have clashes on the same 
class, this extra namespacing is not useful and is likely making the life of 
debuggers harder for expression evaluation.

@aprantl should I generate `@"\01-[Foo directMethodInCategory]"` instead? if 
yes I'd rather do it in this review


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

https://reviews.llvm.org/D71694



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


[clang-tools-extra] ac3f9e4 - [clangd] Improve documentation for auto and implicit specs

2019-12-19 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-12-19T11:55:22+01:00
New Revision: ac3f9e48421712168884d59cbfe8b294dd76a19b

URL: 
https://github.com/llvm/llvm-project/commit/ac3f9e48421712168884d59cbfe8b294dd76a19b
DIFF: 
https://github.com/llvm/llvm-project/commit/ac3f9e48421712168884d59cbfe8b294dd76a19b.diff

LOG: [clangd] Improve documentation for auto and implicit specs

Summary:
Clangd didn't fill documentation for `auto` when it wasn't available in
index. Also it wasn't showing any documentations for implicit instantiations.

This patch ensures auto and normal decl case behaves in the same way and also
makes use of the explicit template specialization while fetching comments for
implicit instantiations.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/FindTarget.h
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 81d4e93ed3c2..55bb8a0b70ea 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -438,17 +438,8 @@ targetDecl(const ast_type_traits::DynTypedNode &N, 
DeclRelationSet Mask) {
   return Result;
 }
 
-namespace {
-/// Find declarations explicitly referenced in the source code defined by \p N.
-/// For templates, will prefer to return a template instantiation whenever
-/// possible. However, can also return a template pattern if the specialization
-/// cannot be picked, e.g. in dependent code or when there is no corresponding
-/// Decl for a template instantitation, e.g. for templated using decls:
-///template  using Ptr = T*;
-///Ptr x;
-///^~~ there is no Decl for 'Ptr', so we return the template pattern.
 llvm::SmallVector
-explicitReferenceTargets(DynTypedNode N, DeclRelationSet Mask = {}) {
+explicitReferenceTargets(DynTypedNode N, DeclRelationSet Mask) {
   assert(!(Mask & (DeclRelation::TemplatePattern |
DeclRelation::TemplateInstantiation)) &&
  "explicitRefenceTargets handles templates on its own");
@@ -478,6 +469,7 @@ explicitReferenceTargets(DynTypedNode N, DeclRelationSet 
Mask = {}) {
   return Targets;
 }
 
+namespace {
 llvm::SmallVector refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {
 llvm::SmallVector Refs;

diff  --git a/clang-tools-extra/clangd/FindTarget.h 
b/clang-tools-extra/clangd/FindTarget.h
index bd5d7690ceed..39c00b0f6df0 100644
--- a/clang-tools-extra/clangd/FindTarget.h
+++ b/clang-tools-extra/clangd/FindTarget.h
@@ -182,6 +182,18 @@ inline DeclRelationSet operator&(DeclRelation L, 
DeclRelation R) {
 inline DeclRelationSet operator~(DeclRelation R) { return ~DeclRelationSet(R); 
}
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelationSet);
 
+/// Find declarations explicitly referenced in the source code defined by \p N.
+/// For templates, will prefer to return a template instantiation whenever
+/// possible. However, can also return a template pattern if the specialization
+/// cannot be picked, e.g. in dependent code or when there is no corresponding
+/// Decl for a template instantitation, e.g. for templated using decls:
+///template  using Ptr = T*;
+///Ptr x;
+///^~~ there is no Decl for 'Ptr', so we return the template pattern.
+/// \p Mask should not contain TemplatePattern or TemplateInstantiation.
+llvm::SmallVector
+explicitReferenceTargets(ast_type_traits::DynTypedNode N,
+ DeclRelationSet Mask = {});
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 623aa962b85a..94a532b1ac47 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -25,6 +25,7 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -183,15 +184,29 @@ const FunctionDecl *getUnderlyingFunction(const Decl *D) {
   return D->getAsFunction();
 }
 
+// Returns the decl that should be used for querying comments, either from 
index
+// or AST.
+const NamedDecl *getDeclForComment(const NamedDecl *D) {
+  if (auto *CTSD = llvm::dyn_cast(D))
+if (!CTSD->isExplicitInstantiationOrSpecialization())
+  return CTSD->getTemplateInstantiationPattern();
+  if (auto *VTSD = llvm::dyn_cast(D))
+if (!VTSD->isExplicitInstantiationOrSpecialization())
+  return VTSD->getTemplateInstantiationPattern();
+  if (auto *FD = D->getAsFunction())
+if (FD->isTemplateInstantiation())
+  return FD->getTemplateSpeci

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

2019-12-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac3f9e484217: [clangd] Improve documentation for auto and 
implicit specs (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "AST.h"
 #include "Annotations.h"
 #include "Hover.h"
 #include "TestIndex.h"
@@ -130,12 +131,9 @@
   )cpp",
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
- HI.Name = "vector";
+ HI.Name = "vector";
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},
   // Class template
   {R"cpp(
@@ -181,21 +179,10 @@
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = index::SymbolKind::Function;
- HI.Definition =
- R"cpp(template  class C, typename = char, int = 0,
-  bool Q = false, class... Ts>
-void foo())cpp";
+ HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
  HI.Type = "void ()";
  HI.Parameters.emplace();
- HI.TemplateParameters = {
- {std::string("template  class"),
-  std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
- };
}},
   // Function decl
   {R"cpp(
@@ -464,8 +451,6 @@
  HI.Type = "enum Color";
  HI.Value = "GREEN (1)"; // Symbolic when hovering on an expression.
}},
-  // FIXME: We should use the Decl referenced, even if from an implicit
-  // instantiation. Then the scope would be Add<1, 2>.
   {R"cpp(
 template struct Add {
   static constexpr int result = a + b;
@@ -474,11 +459,11 @@
 )cpp",
[](HoverInfo &HI) {
  HI.Name = "result";
- HI.Definition = "static constexpr int result = a + b";
+ HI.Definition = "static constexpr int result = 1 + 2";
  HI.Kind = index::SymbolKind::StaticProperty;
  HI.Type = "const int";
  HI.NamespaceScope = "";
- HI.LocalScope = "Add::";
+ HI.LocalScope = "Add<1, 2>::";
  HI.Value = "3";
}},
   {R"cpp(
@@ -1116,14 +1101,13 @@
 HI.Name = "foo";
 HI.Kind = index::SymbolKind::Function;
 HI.NamespaceScope = "";
-HI.Type = "T ()";
-HI.Definition = "template  T foo()";
+HI.Type = "int ()";
+HI.Definition = "template <> int foo()";
 HI.Documentation = "Templated function";
-HI.ReturnType = "T";
+HI.ReturnType = "int";
 HI.Parameters = std::vector{};
-HI.TemplateParameters = {
-{std::string("typename"), std::string("T"), llvm::None},
-};
+// FIXME: We should populate template parameters with arguments in
+// case of instantiations.
   }},
   {
   R"cpp(// Anonymous union
@@ -1271,6 +1255,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto function return with trailing type";
   }},
   {
   R"cpp(// trailing return type
@@ -1282,6 +1267,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "trailing return type";
   }},
   {
   R"cpp(// auto in function return
@@ -1293,6 +1279,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto in function return";
   }},
   {
   R"cpp(// auto& in function return
@@ -1305,6 +1292,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto& in function return";
   }},
   {
  

[PATCH] D71533: [clangd] Show template arguments in type hierarchy when possible

2019-12-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:687
 
-  const Decl *D = Decls[0];
+  const Decl *D = nullptr;
+  for (const Decl *Candidate : Decls) {

kadircet wrote:
> maybe just
> ```
> const Decl *D = Decls.front()
> for(const auto *C : Decls) {
>   if(isa(C)) {
> D = C;
> break;
>   }
> }
> ```
now you can use `explicitReferenceTargets` instead, with only 
`DeclRelation::Underlying` set in the mask.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71533



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


[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-19 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 234697.
skan added a comment.

Add more comment


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

https://reviews.llvm.org/D70157

Files:
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCAssembler.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-64-1a.s
  llvm/test/MC/X86/align-branch-64-1b.s
  llvm/test/MC/X86/align-branch-64-1c.s
  llvm/test/MC/X86/align-branch-64-1d.s
  llvm/test/MC/X86/align-branch-64-2a.s
  llvm/test/MC/X86/align-branch-64-2b.s
  llvm/test/MC/X86/align-branch-64-2c.s
  llvm/test/MC/X86/align-branch-64-3a.s
  llvm/test/MC/X86/align-branch-64-4a.s
  llvm/test/MC/X86/align-branch-64-5a.s

Index: llvm/test/MC/X86/align-branch-64-5a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5a.s
@@ -0,0 +1,63 @@
+# Check no nop or prefix is inserted if no branch cross or is against the boundary
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret  %s | llvm-objdump -d  - > %t1
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t2
+# RUN: cmp %t1 %t2
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:3: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:6: 89 d1movl%edx, %ecx
+# CHECK-NEXT:8: 31 c0xorl%eax, %eax
+# CHECK-NEXT:a: 31 c8xorl%ecx, %eax
+# CHECK-NEXT:c: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:f: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   12: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   15: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   18: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   1b: f3 abrep stosl%eax, %es:(%rdi)
+# CHECK-NEXT:   1d: 75 e4jne {{.*}}
+# CHECK-NEXT:   1f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   21: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   24: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   27: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   2a: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   2c: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   2e: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   31: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   34: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   37: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   3a: e8 00 00 00 00   callq   {{.*}}
+# CHECK-NEXT:   3f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   41: 75 e1jne {{.*}}
+
+.text
+.p2align 4,,15
+foo:
+shrl$2, %ecx
+.L1:
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+xorl%ecx, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+rep stosl
+jne.L1
+xorl%eax, %eax
+shrl$2, %ecx
+.L2:
+shrl$2, %ecx
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+callbar
+xorl%eax, %eax
+jne.L2
Index: llvm/test/MC/X86/align-branch-64-4a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-4a.s
@@ -0,0 +1,63 @@
+# Check rets are not aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %s | llvm-objdump -d  - >%t2
+# RUN: cmp %t %t2
+
+# Check only rets are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=ret
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d  - | FileCheck %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:8: 55

[PATCH] D71556: [AArch64][SVE] Implement intrinsic for non-faulting loads

2019-12-19 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin planned changes to this revision.
kmclaughlin added a comment.

Thanks for the feedback on this patch, @efriedma & @sdesmalen!
I think there is still value in adding a NonFaulting flag to MachineMemOperand 
so that we can benefit from legalisation, but as this is not a requirement for 
the ACLE I have created a new patch which implements the non-faulting load 
intrinsic explicitly: https://reviews.llvm.org/D71698
I will leave this patch in the 'plan changes' state so that it can be referred 
to in future discussions on the mailing list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71556



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


[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2019-12-19 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, efriedma, andwar, dancgr, mgudim.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

This patch adds the llvm.aarch64.sve.ldnf1 intrinsic, plus
DAG combine rules for non-faulting loads and sign/zero extends


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71698

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+define  @ldnf1b( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b:
+; CHECK: ldnf1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldnf1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_h:
+; CHECK: ldnf1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_h:
+; CHECK: ldnf1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldnf1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldnf1h_f16:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+define  @ldnf1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_s:
+; CHECK: ldnf1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_s:
+; CHECK: ldnf1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_s:
+; CHECK: ldnf1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_s:
+; CHECK: ldnf1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldnf1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldnf1w_f32:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldnf1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_d:
+; CHECK: ldnf1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_d:
+; CHECK: ldnf1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_d:
+; CHECK: ldnf1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_d:
+; CHECK: ldnf1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w_d:
+; CHECK: ldnf1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sw_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1sw_d:
+; CHECK: ldnf1sw { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1d( %pg, i64* %a) {
+; CHECK-LABEL: ldnf1d:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i64( %pg, i64* %a)
+

[clang] dde7b6b - Re-land "Add an -fno-temp-file flag for compilation"

2019-12-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2019-12-19T13:34:52+01:00
New Revision: dde7b6bcda9d8cf874fd77b98d0d62d6aeaed049

URL: 
https://github.com/llvm/llvm-project/commit/dde7b6bcda9d8cf874fd77b98d0d62d6aeaed049
DIFF: 
https://github.com/llvm/llvm-project/commit/dde7b6bcda9d8cf874fd77b98d0d62d6aeaed049.diff

LOG: Re-land "Add an -fno-temp-file flag for compilation"

This time making sure to initialize FrontendOptions::UseTemporary.

Patch by Zachary Henkel!

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 38504d6330da..2a72b87355d0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1563,6 +1563,9 @@ def fno_strict_enums : Flag<["-"], "fno-strict-enums">, 
Group;
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
+def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<
+  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 70eb3425b0da..09969b596d63 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -294,6 +294,9 @@ class FrontendOptions {
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
+  /// Should a temporary file be used during compilation.
+  unsigned UseTemporary : 1;
+
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.
@@ -442,7 +445,7 @@ class FrontendOptions {
 UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true),
 ASTDumpDecls(false), ASTDumpLookups(false),
 BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
-IncludeTimestamps(true), TimeTraceGranularity(500) {}
+IncludeTimestamps(true), UseTemporary(true), TimeTraceGranularity(500) 
{}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
   /// extension. For example, "c" would return Language::C.

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3dbe78c5b10f..a79c96d25d98 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5005,6 +5005,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 05ecc3f447cc..688f21dd0908 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@ CompilerInstance::createDefaultOutputFile(bool Binary, 
StringRef InFile,
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  /*UseTemporary=*/true);
+  getFrontendOpts().UseTemporary);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8631536e8f60..d68244dce5c4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1887,6 +1887,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
+  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeComplete

[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-19 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdde7b6bcda9d: Re-land "Add an -fno-temp-file flag for 
compilation" (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70615

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -588,3 +588,6 @@
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
 // CHECK-TRIVIAL-ZERO-GOOD-NOT: hasn't been enabled
 // CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled
+
+// RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-TEMP-FILE %s
+// CHECK-NO-TEMP-FILE: "-fno-temp-file"
\ No newline at end of file
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@
   std::unique_ptr OS =
   CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
   /*RemoveFileOnSignal=*/false, InFile,
-  /*Extension=*/"", /*UseTemporary=*/true);
+  /*Extension=*/"", CI.getFrontendOpts().UseTemporary);
   if (!OS)
 return nullptr;
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1887,6 +1887,7 @@
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
+  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  /*UseTemporary=*/true);
+  getFrontendOpts().UseTemporary);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5005,6 +5005,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -294,6 +294,9 @@
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
+  /// Should a temporary file be used during compilation.
+  unsigned UseTemporary : 1;
+
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.
@@ -442,7 +445,7 @@
 UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true),
 ASTDumpDecls(false), ASTDumpLookups(false),
 BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
-IncludeTimestamps(true), TimeTraceGranularity(500) {}
+IncludeTimestamps(true), UseTemporary(true), TimeTraceGranularity(500) 
{}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
   /// extension. For example, "c" would return Language::C.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1563,6 +1563,9 @@
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
+def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<
+  "Directly 

[PATCH] D71686: Fix false positive in magic number checker

2019-12-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention fix in Release Notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71686



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


[PATCH] D71598: [clangd] Filter implicit references from index while renaming

2019-12-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 234720.
kbobyrev added a comment.

Move helper function back to the anonymous namespace.


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

https://reviews.llvm.org/D71598

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -868,6 +868,22 @@
 }
   )cpp",
   },
+  {
+  // Macros and implicit references.
+  R"cpp(
+class [[Fo^o]] {};
+#define FooFoo Foo
+#define FOO Foo
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void bar() {
+  [[Foo]] x;
+  FOO y;
+  FooFoo z;
+}
+  )cpp",
+  },
   };
 
   for (const auto& T : Cases) {
@@ -1013,11 +1029,6 @@
 llvm::StringRef IndexedCode;
 llvm::StringRef LexedCode;
   } Tests[] = {
-{
-  // no lexed ranges.
-  "[[]]",
-  "",
-},
 {
   // both line and column are changed, not a near miss.
   R"([[]])",
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -77,6 +77,7 @@
 /// Exposed for testing only.
 ///
 /// REQUIRED: Indexed and Lexed are sorted.
+/// REQUIRED: Indexed.size() > Lexed.size().
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed);
 /// Evaluates how good the mapped result is. 0 indicates a perfect match.
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -425,6 +425,23 @@
LexedIndex + 1, Fuel, MatchedCB);
 }
 
+// Assume that index is stale/has returned invalid results that can be filtered
+// by finding the intersection between both sets.
+// REQUIRES: Indexed and Lexed are sorted.
+// REQUIRES: Indexed and Lexed are sorted.
+llvm::Optional> filterIndexResults(ArrayRef Indexed,
+  ArrayRef Lexed) {
+  assert(std::is_sorted(Indexed.begin(), Indexed.end()));
+  assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  assert(Indexed.size() > Lexed.size());
+  std::vector Result;
+  std::set_intersection(Lexed.begin(), Lexed.end(), Indexed.begin(),
+Indexed.end(), std::back_inserter(Result));
+  if (Result.empty())
+return llvm::None;
+  return Result;
+}
+
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
@@ -571,8 +588,14 @@
 }
 
 // Details:
-//  - lex the draft code to get all rename candidates, this yields a superset
-//of candidates.
+//  - lex the draft code to get all rename candidates, this yields a set of
+//candidates. It may be a superset of candidates returned from the index
+//in case index is stale and there are new references to the renamed entity.
+//It may also be a subset of candidates from the index in case when index
+//returns some incorrect results (such as implicit references) or when some
+//references to the renamed entity have been removed.
+//  - if the lexed ranges are subset of index candidates, try to filter the
+//results from index by exactly matching existing ranges from lexer.
 //  - apply range patching heuristics to generate "authoritative" occurrences,
 //cases we consider:
 //  (a) index returns a subset of candidates, we use the indexed results.
@@ -591,7 +614,8 @@
   std::vector Lexed =
   collectIdentifierRanges(Identifier, DraftCode, LangOpts);
   llvm::sort(Lexed);
-  return getMappedRanges(Indexed, Lexed);
+  return Indexed.size() <= Lexed.size() ? getMappedRanges(Indexed, Lexed)
+: filterIndexResults(Indexed, Lexed);
 }
 
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
@@ -599,11 +623,8 @@
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  +assert(Indexed.size() <= Lexed.size());
 
-  if (Indexed.size() > Lexed.size()) {
-vlog("The number of lexed occurrences is less than indexed occurrences");
-return llvm::None;
-  }
   // Fast check for the special subset case.
   if (std::includes(Indexed.begin(), Indexed.end(), Lexed.begin(), Lexed.end()))
 return Indexed.vec();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71598: [clangd] Filter implicit references from index while renaming

2019-12-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 234719.
kbobyrev marked 7 inline comments as done.
kbobyrev added a comment.

Sorry for a delay: I was trying to work with range patching heuristics and get 
it to work in generic case of "stale index returns more results than lexer", 
but in the end I converged to the simplest possible version of the intended 
change.


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

https://reviews.llvm.org/D71598

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -868,6 +868,22 @@
 }
   )cpp",
   },
+  {
+  // Macros and implicit references.
+  R"cpp(
+class [[Fo^o]] {};
+#define FooFoo Foo
+#define FOO Foo
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void bar() {
+  [[Foo]] x;
+  FOO y;
+  FooFoo z;
+}
+  )cpp",
+  },
   };
 
   for (const auto& T : Cases) {
@@ -1013,11 +1029,6 @@
 llvm::StringRef IndexedCode;
 llvm::StringRef LexedCode;
   } Tests[] = {
-{
-  // no lexed ranges.
-  "[[]]",
-  "",
-},
 {
   // both line and column are changed, not a near miss.
   R"([[]])",
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -77,6 +77,7 @@
 /// Exposed for testing only.
 ///
 /// REQUIRED: Indexed and Lexed are sorted.
+/// REQUIRED: Indexed.size() > Lexed.size().
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed);
 /// Evaluates how good the mapped result is. 0 indicates a perfect match.
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -571,8 +571,14 @@
 }
 
 // Details:
-//  - lex the draft code to get all rename candidates, this yields a superset
-//of candidates.
+//  - lex the draft code to get all rename candidates, this yields a set of
+//candidates. It may be a superset of candidates returned from the index
+//in case index is stale and there are new references to the renamed entity.
+//It may also be a subset of candidates from the index in case when index
+//returns some incorrect results (such as implicit references) or when some
+//references to the renamed entity have been removed.
+//  - if the lexed ranges are subset of index candidates, try to filter the
+//results from index by exactly matching existing ranges from lexer.
 //  - apply range patching heuristics to generate "authoritative" occurrences,
 //cases we consider:
 //  (a) index returns a subset of candidates, we use the indexed results.
@@ -591,7 +597,8 @@
   std::vector Lexed =
   collectIdentifierRanges(Identifier, DraftCode, LangOpts);
   llvm::sort(Lexed);
-  return getMappedRanges(Indexed, Lexed);
+  return Indexed.size() <= Lexed.size() ? getMappedRanges(Indexed, Lexed)
+: filterIndexResults(Indexed, Lexed);
 }
 
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
@@ -599,11 +606,8 @@
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  +assert(Indexed.size() <= Lexed.size());
 
-  if (Indexed.size() > Lexed.size()) {
-vlog("The number of lexed occurrences is less than indexed occurrences");
-return llvm::None;
-  }
   // Fast check for the special subset case.
   if (std::includes(Indexed.begin(), Indexed.end(), Lexed.begin(), Lexed.end()))
 return Indexed.vec();
@@ -677,5 +681,22 @@
   return Cost;
 }
 
+// Assume that index is stale/has returned invalid results that can be filtered
+// by finding the intersection between both sets.
+// REQUIRES: Indexed and Lexed are sorted.
+// REQUIRES: Indexed and Lexed are sorted.
+llvm::Optional> filterIndexResults(ArrayRef Indexed,
+  ArrayRef Lexed) {
+  assert(std::is_sorted(Indexed.begin(), Indexed.end()));
+  assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  assert(Indexed.size() > Lexed.size());
+  std::vector Result;
+  std::set_intersection(Lexed.begin(), Lexed.end(), Indexed.begin(),
+Indexed.end(), std::back_inserter(Result));
+  if (Result.empty())
+return llvm::None;
+  return Result;
+}
+
 } // namespace clangd
 } // namespace clang
__

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, alexfh, lebedev.ri.
jankratochvil added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, kristof.beyls, mgorny.
Herald added a project: clang.

Check for cast of a pointer to wider (even unsigned) integer. This will 
sign-extend the pointer which happens on 32-bit hosts for 64-bit integers:

  void *p=(void *)0x8000;
  printf(  "%p""\n",p ); // 0x8000
  printf("0x%" PRIxPTR "\n", (uintptr_t)p ); // 0x8000
  printf("0x%" PRIx64  "\n",
 reinterpret_cast(p)); // 0x8000
  printf("0x%" PRIx64  "\n", (uint64_t) p ); // 0x8000
  printf("0x%" PRIx64  "\n",   (uint64_t)(uintptr_t)p ); // 0x8000

It has caught a bug on ARM32: D71498  (and 
D71514 )


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71707

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s bugprone-pointer-cast-widening %t
+
+#include 
+
+void test(void) {
+  void *p = 0;
+  uint64_t u64 = (uint64_t)p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  uint64_t u64r = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  intptr_t ip = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend [bugprone-pointer-cast-widening]
+  uintptr_t up = (uintptr_t)p;
+  typedef uintptr_t t1;
+  typedef t1 t2;
+  t2 t = (t2)p;
+}
Index: clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
@@ -0,0 +1,42 @@
+//===--- PointerCastWideningCheck.h - clang-tidy-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_POINTER_CAST_WIDENING_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_POINTER_CAST_WIDENING_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Check for cast of a pointer to wider (even unsigned) integer. This will
+/// sign-extend the pointer which happens on 32-bit hosts for 64-bit integers.
+///
+/// \code
+/// void *p=(void *)0x8000;
+/// printf(  "%p""\n",p ); // 0x8000
+/// printf("0x%" PRIxPTR "\n", (uintptr_t)p ); // 0x8000
+/// printf("0x%" PRIx64  "\n",
+///reinterpret_cast(p)); // 0x8000
+/// printf("0x%" PRIx64  "\n", (uint64_t) p ); // 0x8000
+/// printf("0x%" PRIx64  "\n",   (uint64_t)(uintptr_t)p ); // 0x8000
+/// \endcode
+class PointerCastWideningCheck : public ClangTidyCheck {
+public:
+  PointerCastWideningCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_POINTER_CAST_WIDENING_H
Index: clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp
@@ -0,0 +1,54 @@
+//===--- PointerCastWideningCheck.cpp - clang-tidy-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil added a comment.

Example output:

  PATH="$PWD/bin:$PATH" 
~/redhat/llvm-monorepo/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
-checks='-*,bugprone-pointer-cast-widening' 
/home/jkratoch/redhat/llvm-monorepo/lldb/source/
  
  Enabled checks:
  bugprone-pointer-cast-widening
  
  /home/jkratoch/redhat/llvm-monorepo/lldb/source/Core/PluginManager.cpp:89:35: 
warning: do not use cast of a pointer 'void *' to non-uintptr_t 'intptr_t' (aka 
'long') which may sign-extend [bugprone-pointer-cast-widening]
return reinterpret_cast(reinterpret_cast(VPtr));
^
   - What is the use of intptr_t?
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRMemoryMap.cpp:333:29:
 warning: do not use cast of a pointer 
'std::__shared_ptr::element_type 
*' (aka 'lldb_private::Process *') to non-uintptr_t 'lldb::addr_t' (aka 
'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
__FUNCTION__, (lldb::addr_t)process_sp.get(),
  ^
   - A bug, submitted as: D71514
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRMemoryMap.cpp:582:42:
 warning: do not use cast of a pointer 'const uint8_t *' (aka 'const unsigned 
char *') to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may 
sign-extend [bugprone-pointer-cast-widening]
(uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
   ^
   - A bug, not yet submitted.
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRMemoryMap.cpp:713:42:
 warning: do not use cast of a pointer 'uint8_t *' (aka 'unsigned char *') to 
non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend 
[bugprone-pointer-cast-widening]
(uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
   ^
   - A bug, not yet submitted.
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Host/common/HostInfoBase.cpp:252:32:
 warning: do not use cast of a pointer 'bool (*)(lldb_private::FileSpec &)' to 
non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend 
[bugprone-pointer-cast-widening]
reinterpret_cast(reinterpret_cast(
 ^
   - What is the use of intptr_t?
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Host/posix/DomainSocket.cpp:48:20:
 warning: do not use cast of a pointer 'char *' to non-uintptr_t 'size_t' (aka 
'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
  saddr_un_len = SUN_LEN(saddr_un);
 ^
  /usr/include/sys/un.h:40:24: note: expanded from macro 'SUN_LEN'
  # define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)
\
 ^
   - False positive?
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRExecutionUnit.cpp:351:53:
 warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' 
(aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
  function.getName().str().c_str(), external, (lldb::addr_t)fun_ptr));
  ^
   - A bug, submitted as: D71498
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp:358:24:
 warning: do not use cast of a pointer 'clang::NamedDecl *' to non-uintptr_t 
'uint64_t' (aka 'unsigned long') which may sign-extend 
[bugprone-pointer-cast-widening]
 reinterpret_cast(result_decl), false);
 ^
   - A bug, not yet submitted.
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:139:23:
 warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' 
(aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
  AppendBounds(str, reinterpret_cast(info.si_lower),
^
   - A bug, submitted as: D71514
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:140:18:
 warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' 
(aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
   reinterpret_cast(info.si_upper),
   ^
   - A bug, submitted as: D71514
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:141:18:
 warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' 
(aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
   reinterpret_cast(info.si_addr));
   ^
   - A bug, submitted as: D71514
  
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:147:31:
 warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' 
(aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]

[PATCH] D71598: [clangd] Filter implicit references from index while renaming

2019-12-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:431
+// REQUIRES: Indexed and Lexed are sorted.
+// REQUIRES: Indexed and Lexed are sorted.
+llvm::Optional> filterIndexResults(ArrayRef Indexed,

duplication



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:591
 // Details:
-//  - lex the draft code to get all rename candidates, this yields a superset
-//of candidates.
+//  - lex the draft code to get all rename candidates, this yields a set of
+//candidates. It may be a superset of candidates returned from the index

i believe lexing might yield a superset even if index is up-to-date,

```
void foo() { int bar; }
void baz() { int ba^r; }

```



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:595
+//It may also be a subset of candidates from the index in case when index
+//returns some incorrect results (such as implicit references) or when some
+//references to the renamed entity have been removed.

exactly for the same reason above, it might not be a subset even in those 
circumstances.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:597
+//references to the renamed entity have been removed.
+//  - if the lexed ranges are subset of index candidates, try to filter the
+//results from index by exactly matching existing ranges from lexer.

i believe we should do that even if it is not a subset.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:626
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  +assert(Indexed.size() <= Lexed.size());
 

`+`



Comment at: clang-tools-extra/clangd/refactor/Rename.h:80
 /// REQUIRED: Indexed and Lexed are sorted.
+/// REQUIRED: Indexed.size() > Lexed.size().
 llvm::Optional> getMappedRanges(ArrayRef Indexed,

assertion below says
`assert(Indexed.size() <= Lexed.size());`


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

https://reviews.llvm.org/D71598



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: rjmccall, hfinkel.
Herald added subscribers: arphaman, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Basic codegen for the declarations marked as nontemporal. Also, if the
base declaration in the member expression is marked as nontemporal,
lvalue for member decl access inherits nonteporal flag from the base
lvalue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71708

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2458,6 +2458,8 @@
 void OMPClauseEnqueue::VisitOMPNontemporalClause(
 const OMPNontemporalClause *C) {
   VisitOMPClauseList(C);
+  for (const auto *E : C->private_refs())
+Visitor->AddStmt(E);
 }
 }
 
Index: clang/test/OpenMP/teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_simd_codegen.cpp
@@ -177,16 +177,16 @@
   // CK3: define {{.*}}i32 @{{.+}}foo{{.+}}(
   int foo(void) {
 
-  // CK3: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* %{{.+}}, i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 1)
+  // CK3: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 3, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* %{{.+}}, i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 1)
   // CK3: call void @[[OFFL1:.+]]([[SSI]]* %{{.+}})
 #pragma omp target
 #ifdef OMP5
-#pragma omp teams distribute simd if(b)
+#pragma omp teams distribute simd if(b) nontemporal(a, b)
 #else
 #pragma omp teams distribute simd
 #endif // OMP5
 for(int i = 0; i < X; i++) {
-  a[i] = (T)0;
+  a[i] = (T)b;
 }
 
   // outlined target region
@@ -197,6 +197,8 @@
 
   // CK3: define internal void @[[OUTL1]]({{.+}})
   // CK3: call void @__kmpc_for_static_init_4(
+  // OMP3_45-NOT: !nontemporal
+  // OMP3_50: load float,{{.*}}!nontemporal
   // CK3: call void @__kmpc_for_static_fini(
   // CK3: ret void
 
Index: clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
@@ -165,7 +165,7 @@
 
   // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}})
 #ifdef OMP5
-  #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a) if(simd: 1)
+  #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a) if(simd: 1) nontemporal(a)
 #else
   #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a)
 #endif // OMP5
@@ -395,6 +395,8 @@
 // CHECK:   [[AA_ADDR:%.+]] = alloca i[[SZ]], align
 // CHECK:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[AA_ADDR]], align
 // CHECK-64:[[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i32*
+// OMP45-NOT:   !nontemporal
+// OMP50:   load i32,{{.*}}!nontemporal
 // CHECK-64:store i32 10, i32* [[AA_CADDR]], align
 // CHECK-32:store i32 10, i32* [[AA_ADDR]], align
 // CHECK:   ret void
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
@@ -35,20 +35,25 @@
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 #ifdef OMP5
-#pragma omp target teams distribute parallel for simd if(simd: true)
+#pragma omp target teams distribute parallel for simd if(simd: true) nontemporal(Arg)
 #else
 #pragma omp target teams distribute parallel for simd
 #endif // OMP5
-  for(int i = 0 ; i < 100; i++) {}
+  for (int i = 0; i < 100; i++) {
+Arg = 0;
+  }
   // CHECK: define internal void [[OFFLOADING_FUN_0]](
-  // CHECK: call {{.*

[PATCH] D71709: Give frontend dump flags consistent names (*-dump instead of dump-*)

2019-12-19 Thread David Herzka via Phabricator via cfe-commits
herzka created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
herzka added a reviewer: modocache.
herzka added a comment.

@modocache, should I add a unit test for these aliases or would that be too 
trivial? I don't see unit tests for all the existing flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71709

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


Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -272,8 +272,10 @@
   HelpText<"Four-byte version string for gcov files.">;
 def test_coverage : Flag<["-"], "test-coverage">,
   HelpText<"Do not generate coverage files or remove coverage changes from 
IR">;
-def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
+def coverage_mapping_dump : Flag<["-"], "coverage-mapping-dump">,
   HelpText<"Dump the coverage mapping records, for testing">;
+def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
+  Alias;
 def fuse_register_sized_bitfield_access: Flag<["-"], 
"fuse-register-sized-bitfield-access">,
   HelpText<"Use register sized accesses to bit-fields, when possible.">;
 def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
@@ -559,12 +561,16 @@
 
 def Eonly : Flag<["-"], "Eonly">,
   HelpText<"Just run preprocessor, no output (for timings)">;
-def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">,
+def raw_tokens_dump : Flag<["-"], "raw-tokens-dump">,
   HelpText<"Lex file in raw mode and dump raw tokens">;
+def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">,
+  Alias;
 def analyze : Flag<["-"], "analyze">,
   HelpText<"Run static analysis engine">;
-def dump_tokens : Flag<["-"], "dump-tokens">,
+def tokens_dump : Flag<["-"], "tokens-dump">,
   HelpText<"Run preprocessor, dump internal rep of tokens">;
+def dump_tokens : Flag<["-"], "dump-tokens">,
+  Alias;
 def init_only : Flag<["-"], "init-only">,
   HelpText<"Only execute frontend initialization">;
 def fixit : Flag<["-"], "fixit">,
@@ -726,8 +732,10 @@
   HelpText<"Disable validation of precompiled headers">;
 def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">,
   HelpText<"Accept a PCH file that was created with compiler errors">;
-def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
+def deserialized_pch_decls_dump : Flag<["-"], "deserialized-decls-dump">,
   HelpText<"Dump declarations that are deserialized from PCH, for testing">;
+def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
+  Alias;
 def error_on_deserialized_pch_decl : Separate<["-"], 
"error-on-deserialized-decl">,
   HelpText<"Emit error if a specific declaration is deserialized from PCH, for 
testing">;
 def error_on_deserialized_pch_decl_EQ : Joined<["-"], 
"error-on-deserialized-decl=">,


Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -272,8 +272,10 @@
   HelpText<"Four-byte version string for gcov files.">;
 def test_coverage : Flag<["-"], "test-coverage">,
   HelpText<"Do not generate coverage files or remove coverage changes from IR">;
-def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
+def coverage_mapping_dump : Flag<["-"], "coverage-mapping-dump">,
   HelpText<"Dump the coverage mapping records, for testing">;
+def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
+  Alias;
 def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfield-access">,
   HelpText<"Use register sized accesses to bit-fields, when possible.">;
 def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
@@ -559,12 +561,16 @@
 
 def Eonly : Flag<["-"], "Eonly">,
   HelpText<"Just run preprocessor, no output (for timings)">;
-def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">,
+def raw_tokens_dump : Flag<["-"], "raw-tokens-dump">,
   HelpText<"Lex file in raw mode and dump raw tokens">;
+def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">,
+  Alias;
 def analyze : Flag<["-"], "analyze">,
   HelpText<"Run static analysis engine">;
-def dump_tokens : Flag<["-"], "dump-tokens">,
+def tokens_dump : Flag<["-"], "tokens-dump">,
   HelpText<"Run preprocessor, dump internal rep of tokens">;
+def dump_tokens : Flag<["-"], "dump-tokens">,
+  Alias;
 def init_only : Flag<["-"], "init-only">,
   HelpText<"Only execute frontend initialization">;
 def fixit : Flag<["-"], "fixit">,
@@ -726,8 +732,10 @@
   HelpText<"Disable validation of precompiled headers">;
 def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">,
   HelpText<"Accept a PCH file that was created with compiler errors">;
-def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
+def deserialized_pch_decls_dump : Flag<["-"], "deserialized-decls

[PATCH] D71709: Give frontend dump flags consistent names (*-dump instead of dump-*)

2019-12-19 Thread David Herzka via Phabricator via cfe-commits
herzka added a comment.

@modocache, should I add a unit test for these aliases or would that be too 
trivial? I don't see unit tests for all the existing flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71709



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


[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Pavel Labath via Phabricator via cfe-commits
labath resigned from this revision.
labath added a comment.

Though this *was* my idea, I don't really feel qualified to review code here.

However, some things to consider:

- disallowing casts to intptr_t seems too restrictive -- I doubt many people 
are doing that, but I guess this type exists for a reason, and since the type 
(and it's signedness) is spelled out in the source, it shouldn't be too 
surprising that sign-extension can happen later
- requiring a literal uintptr_t (or a typedef of it) may be also problematic -- 
the user could obtain an integer type of the same bit width through some other 
means (e.g. `#ifdef`). OTOH, without that (and just checking the bit width for 
instance), one would have to actually compile for a 32-bit target to get this 
warning. I don't know what's the practice for this in clang-tidy...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


[PATCH] D71598: [clangd] Filter implicit references from index while renaming

2019-12-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 234727.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

Addressed a bunch of comments to cleanup the patch and replied to ask for 
clarification of several unresolved comments.


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

https://reviews.llvm.org/D71598

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -868,6 +868,22 @@
 }
   )cpp",
   },
+  {
+  // Macros and implicit references.
+  R"cpp(
+class [[Fo^o]] {};
+#define FooFoo Foo
+#define FOO Foo
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void bar() {
+  [[Foo]] x;
+  FOO y;
+  FooFoo z;
+}
+  )cpp",
+  },
   };
 
   for (const auto& T : Cases) {
@@ -1013,11 +1029,6 @@
 llvm::StringRef IndexedCode;
 llvm::StringRef LexedCode;
   } Tests[] = {
-{
-  // no lexed ranges.
-  "[[]]",
-  "",
-},
 {
   // both line and column are changed, not a near miss.
   R"([[]])",
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -77,6 +77,7 @@
 /// Exposed for testing only.
 ///
 /// REQUIRED: Indexed and Lexed are sorted.
+/// REQUIRED: Indexed.size() <= Lexed.size().
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed);
 /// Evaluates how good the mapped result is. 0 indicates a perfect match.
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -425,6 +425,22 @@
LexedIndex + 1, Fuel, MatchedCB);
 }
 
+// Assume that index is stale/has returned invalid results that can be filtered
+// by finding the intersection between both sets.
+// REQUIRES: Indexed and Lexed are sorted.
+llvm::Optional> filterIndexResults(ArrayRef Indexed,
+  ArrayRef Lexed) {
+  assert(std::is_sorted(Indexed.begin(), Indexed.end()));
+  assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  assert(Indexed.size() > Lexed.size());
+  std::vector Result;
+  std::set_intersection(Lexed.begin(), Lexed.end(), Indexed.begin(),
+Indexed.end(), std::back_inserter(Result));
+  if (Result.empty())
+return llvm::None;
+  return Result;
+}
+
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
@@ -571,8 +587,16 @@
 }
 
 // Details:
-//  - lex the draft code to get all rename candidates, this yields a superset
-//of candidates.
+//  - lex the draft code to get all rename candidates, this yields a set of
+//candidates. It may be a superset of candidates returned from the index
+//in case index is stale and there are new references to the renamed entity.
+//It may also be a subset of candidates from the index in case when index
+//returns some incorrect results (such as implicit references), when some
+//references to the renamed entity have been removed or simply when
+//local variables (references to which are not stored in index) have the
+//same identifier name.
+//  - if the lexed ranges are subset of index candidates, try to filter the
+//results from index by exactly matching existing ranges from lexer.
 //  - apply range patching heuristics to generate "authoritative" occurrences,
 //cases we consider:
 //  (a) index returns a subset of candidates, we use the indexed results.
@@ -591,7 +615,8 @@
   std::vector Lexed =
   collectIdentifierRanges(Identifier, DraftCode, LangOpts);
   llvm::sort(Lexed);
-  return getMappedRanges(Indexed, Lexed);
+  return Indexed.size() <= Lexed.size() ? getMappedRanges(Indexed, Lexed)
+: filterIndexResults(Indexed, Lexed);
 }
 
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
@@ -599,11 +624,8 @@
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  assert(Indexed.size() <= Lexed.size());
 
-  if (Indexed.size() > Lexed.size()) {
-vlog("The number of lexed occurrences is less than indexed occurrences");
-return llvm::None;
-  }
   // Fast check for the special subset case.
   if (std::includes(Indexed.begin(), Indexed.end(), Lexed.begin(), Lexed.end()))
 return Indexed.vec();

[PATCH] D71598: [clangd] Filter implicit references from index while renaming

2019-12-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:591
 // Details:
-//  - lex the draft code to get all rename candidates, this yields a superset
-//of candidates.
+//  - lex the draft code to get all rename candidates, this yields a set of
+//candidates. It may be a superset of candidates returned from the index

kadircet wrote:
> i believe lexing might yield a superset even if index is up-to-date,
> 
> ```
> void foo() { int bar; }
> void baz() { int ba^r; }
> 
> ```
Good point. Any local variable (IIRC we don't store local variables in index, 
so it's not there) having the same identifier as the renamed symbol might cause 
the indexed ranges to be a subset of lexed ranges.

However, 

> i believe lexing might yield a superset even if index is up-to-date
> exactly for the same reason above, it might not be a subset even in those 
> circumstances.

I tried to describe the case when lexer will return a _subset_ of indexed 
results, which happens in practice. Is the suggestion to change the comments 
you think are misleading?



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:597
+//references to the renamed entity have been removed.
+//  - if the lexed ranges are subset of index candidates, try to filter the
+//results from index by exactly matching existing ranges from lexer.

kadircet wrote:
> i believe we should do that even if it is not a subset.
Maybe my understanding of `getMappedRanges` is incorrect, but I suppose this 
will happen in case indexed ranges are subset of lexed ranges in some form 
(i.e. no need to find exact matches explicitly). Am I missing something?


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

https://reviews.llvm.org/D71598



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-19 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61027 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[PATCH] D71572: [ItaniumCXXABI] Make tls wrappers comdat on Windows

2019-12-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D71572#1788786 , @rnk wrote:

> Looks like @rsmith did this here:
>  
> https://github.com/llvm/llvm-project/commit/fbe2369f1a514423e4c25417ab3532502fde6f2a
>
> I see that it was replacing a CHECK for a specific comdat group with no 
> comdat at all. I *think* that's not correct, we should be checking for the 
> trivial comdat group, the one for the wrapper function, not the comdat group 
> of the TLS variable. Let's get input from Richard, though.


@rsmith?


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

https://reviews.llvm.org/D71572



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


[PATCH] D71510: [clang][checkers] Added new checker 'error-return-checker'. (WIP)

2019-12-19 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 234730.
balazske added a comment.

Adding a new diff over the previous one.
(The commit was amended accidentally.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71510

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/error-return.c

Index: clang/test/Analysis/error-return.c
===
--- /dev/null
+++ clang/test/Analysis/error-return.c
@@ -0,0 +1,470 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.ErrorReturn -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+/*
+Functions from CERT ERR33-C that should be checked for error:
+
+void *aligned_alloc( size_t alignment, size_t size );
+errno_t asctime_s(char *buf, rsize_t bufsz, const struct tm *time_ptr);
+int at_quick_exit( void (*func)(void) );
+int atexit( void (*func)(void) );
+void* bsearch( const void *key, const void *ptr, size_t count, size_t size,
+   int (*comp)(const void*, const void*) );
+void* bsearch_s( const void *key, const void *ptr, rsize_t count, rsize_t size,
+ int (*comp)(const void *, const void *, void *),
+ void *context );
+wint_t btowc( int c );
+size_t c16rtomb( char * restrict s, char16_t c16, mbstate_t * restrict ps );
+size_t c32rtomb( char * restrict s, char32_t c32, mbstate_t * restrict ps );
+void* calloc( size_t num, size_t size );
+clock_t clock(void);
+int cnd_broadcast( cnd_t *cond );
+int cnd_init( cnd_t* cond );
+int cnd_signal( cnd_t *cond );
+int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex,
+   const struct timespec* restrict time_point );
+int cnd_wait( cnd_t* cond, mtx_t* mutex );
+errno_t ctime_s(char *buffer, rsize_t bufsz, const time_t *time);
+int fclose( FILE *stream );
+int fflush( FILE *stream );
+int fgetc( FILE *stream );
+int fgetpos( FILE *restrict stream, fpos_t *restrict pos );
+char *fgets( char *restrict str, int count, FILE *restrict stream );
+wint_t fgetwc( FILE *stream );
+FILE *fopen( const char *restrict filename, const char *restrict mode );
+errno_t fopen_s(FILE *restrict *restrict streamptr,
+const char *restrict filename,
+const char *restrict mode);
+int fprintf( FILE *restrict stream, const char *restrict format, ... );
+int fprintf_s(FILE *restrict stream, const char *restrict format, ...);
+int fputc( int ch, FILE *stream );
+int fputs( const char *restrict str, FILE *restrict stream );
+wint_t fputwc( wchar_t ch, FILE *stream );
+int fputws( const wchar_t * restrict str, FILE * restrict stream );
+size_t fread( void *restrict buffer, size_t size, size_t count,
+  FILE *restrict stream );
+FILE *freopen( const char *restrict filename, const char *restrict mode,
+   FILE *restrict stream );
+errno_t freopen_s(FILE *restrict *restrict newstreamptr,
+  const char *restrict filename, const char *restrict mode,
+  FILE *restrict stream);
+int fscanf( FILE *restrict stream, const char *restrict format, ... );
+int fscanf_s(FILE *restrict stream, const char *restrict format, ...);
+int fseek( FILE *stream, long offset, int origin );
+int fsetpos( FILE *stream, const fpos_t *pos );
+long ftell( FILE *stream );
+int fwprintf( FILE *restrict stream,
+  const wchar_t *restrict format, ... );
+int fwprintf_s( FILE *restrict stream,
+const wchar_t *restrict format, ...);
+size_t fwrite( const void *restrict buffer, size_t size, size_t count,
+   FILE *restrict stream ); // more exact error return: < count
+int fwscanf( FILE *restrict stream,
+ const wchar_t *restrict format, ... );
+int fwscanf_s( FILE *restrict stream,
+   const wchar_t *restrict format, ...);
+int getc( FILE *stream );
+int getchar(void);
+char *getenv( const char *name );
+errno_t getenv_s( size_t *restrict len, char *restrict value,
+  rsize_t valuesz, const char *restrict name );
+char *gets_s( char *str, rsize_t n );
+wint_t getwc( FILE *stream );
+wint_t getwchar(void);
+struct tm *gmtime( const time_t *time );
+struct tm *gmtime_s(const time_t *restrict time, struct tm *restrict result);
+struct tm *localtime( const time_t *time );
+struct tm *localtime_s(const time_t *restrict time, struct tm *restrict result);
+void* malloc( size_t size );
+int mblen( const char* s, size_t n );
+size_t mbrlen( const char *restrict s, size_t n, mbstate_t *restrict ps );
+size_t mbrtoc16( char16_t * restrict pc16, const char * restrict s,
+ size_t n, mbstate_t * restrict ps );
+size_t mbrtoc32( char32_t restrict * pc32, const char * restrict s,
+   

[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2019-12-19 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 added a comment.

>> @Jac1494 - have you made any measurements of the size increase of this 
>> change? Perhaps a self-host build of clang?

With change(default) and without change size diffrence given below ,in that 
only debug section size is changed.

Without change:-(default)
$size -A -d  build_debug_withoutfix/bin/clang-10 


.comment 159 0
.debug_str   3999832 0
.debug_loc   941 0
.debug_abbrev  12754 0
.debug_info  2225482 0
.debug_ranges  46672 0
.debug_line   153741 0
.note.gnu.gold-version28 0
Total6835098

With change:-

$size -A -d  build_debug_withfix/bin/clang-10 
.
.
.comment 159 0
.debug_str   3999775 0
.debug_loc   941 0
.debug_abbrev  12746 0
.debug_info  2225458 0
.debug_ranges  46672 0
.debug_line   153717 0
.note.gnu.gold-version28 0
Total6834985


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

https://reviews.llvm.org/D71451



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


[clang] 2520bef - [Clang FE, SystemZ] Recognize -mrecord-mcount CL option.

2019-12-19 Thread Jonas Paulsson via cfe-commits

Author: Jonas Paulsson
Date: 2019-12-19T08:51:55-08:00
New Revision: 2520bef865329d4c04e2de30c222ad0d5ad13ccc

URL: 
https://github.com/llvm/llvm-project/commit/2520bef865329d4c04e2de30c222ad0d5ad13ccc
DIFF: 
https://github.com/llvm/llvm-project/commit/2520bef865329d4c04e2de30c222ad0d5ad13ccc.diff

LOG: [Clang FE, SystemZ]  Recognize -mrecord-mcount CL option.

Recognize -mrecord-mcount from the command line and add a function attribute
"mrecord-mcount" when passed.

Only valid on SystemZ (when used with -mfentry).

Review: Ulrich Weigand
https://reviews.llvm.org/D71627

Added: 
clang/test/CodeGen/mrecord-mcount.c

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index c6700333c13a..7f26ca8b4d61 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -113,6 +113,7 @@ VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)
 CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled.
 CODEGENOPT(CallFEntry , 1, 0) ///< Set when -mfentry is enabled.
 CODEGENOPT(MNopMCount , 1, 0) ///< Set when -mnop-mcount is enabled.
+CODEGENOPT(RecordMCount , 1, 0) ///< Set when -mrecord-mcount is enabled.
 CODEGENOPT(PackedStack , 1, 0) ///< Set when -mpacked-stack is enabled.
 CODEGENOPT(LessPreciseFPMAD  , 1, 0) ///< Enable less precise MAD instructions 
to
  ///< be generated.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2a72b87355d0..86aee334436a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2477,6 +2477,8 @@ def mfentry : Flag<["-"], "mfentry">, HelpText<"Insert 
calls to fentry at functi
   Flags<[CC1Option]>, Group;
 def mnop_mcount : Flag<["-"], "mnop-mcount">, HelpText<"Generate 
mcount/__fentry__ calls as nops. To activate they need to be patched in.">,
   Flags<[CC1Option]>, Group;
+def mrecord_mcount : Flag<["-"], "mrecord-mcount">, HelpText<"Generate a 
__mcount_loc section entry for each __fentry__ call.">,
+  Flags<[CC1Option]>, Group;
 def mpacked_stack : Flag<["-"], "mpacked-stack">, HelpText<"Use packed stack 
layout (SystemZ only).">,
   Flags<[CC1Option]>, Group;
 def mips16 : Flag<["-"], "mips16">, Group;

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 89ce31e9b450..6f7e06b773dc 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -968,6 +968,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
 << "-mnop-mcount" << "-mfentry";
 Fn->addFnAttr("mnop-mcount");
   }
+
+  if (CGM.getCodeGenOpts().RecordMCount) {
+if (getContext().getTargetInfo().getTriple().getArch() !=
+llvm::Triple::systemz)
+  CGM.getDiags().Report(diag::err_opt_not_valid_on_target)
+<< "-mrecord-mcount";
+if (!CGM.getCodeGenOpts().CallFEntry)
+  CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
+<< "-mrecord-mcount" << "-mfentry";
+Fn->addFnAttr("mrecord-mcount");
+  }
 }
   }
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a79c96d25d98..6b93dc2939e1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4990,6 +4990,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (TC.SupportsProfiling())
 Args.AddLastArg(CmdArgs, options::OPT_mnop_mcount);
 
+  if (TC.SupportsProfiling())
+Args.AddLastArg(CmdArgs, options::OPT_mrecord_mcount);
+
   Args.AddLastArg(CmdArgs, options::OPT_mpacked_stack);
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d68244dce5c4..93193edff9c9 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1104,6 +1104,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, 
ArgList &Args, InputKind IK,
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.MNopMCount = Args.hasArg(OPT_mnop_mcount);
+  Opts.RecordMCount = Args.hasArg(OPT_mrecord_mcount);
   Opts.PackedStack = Args.hasArg(OPT_mpacked_stack);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
 

diff  --git a/clang/test/CodeGen/mrecord-mcount.c 
b/clang/test/CodeGen/mrecord-mcount.c
new file mode 100644
index ..eecee0e24cdc
--- /dev/null
+++ b/clang/test/CodeGen/m

[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-19 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

In D70157#1789159 , @skan wrote:

> In D70157#1788445 , @reames wrote:
>
> > Specifically on the revised patch, I remain confused by the need for 
> > multiple subtypes.  The need for fragments *between* the potentially fused 
> > instructions doesn't make sense to me.  What I was expecting to see was the 
> > following:
> >  BoundaryAlign w/target=the branch fragment
> >  .. some possibly empty sequence of fragments (i.e. the test/cmp/etc..) ...
> >  the branch fragment
> >  a new data fragment if the branch fragment was a DF
> >
> > (i.e. a single BounaryAlign fragment which aligns a payload which is 
> > defined as "next fragment to target fragment inclusive".)
> >
> > To be specific, I'd expect to see the following for an example fused 
> > sequence:
> >
> > 1. BoundaryAlign w/Target = 3
> > 2. DataFragment containing TEST RAX, RAX
> > 3. RelaxeableFragment containing JNE symbo
> >
> >   Why do we need anything between the two fragments of the fused pair?
> >
> >   (As a reminder, I am new to this code.  If I'm missing the obvious, 
> > please just point it out.)
>
>
> JUMP is not always emiteed into `MCRelaxableFragment`, it also can be emitted 
> into `MCDataFragment` and  arithmetic ops with constant arguments of unknown 
> value (e.g. ADD,AND) can be emitted into `MCRelaxableFragment` ,  you can 
> find related code in `MCObjectStreamer::EmitInstructionImpl`, 
> `X86AsmBackend::mayNeedRelaxation`.  Let's say JCC is fused with TEST,  there 
> are four possible positions for JCC and CMP
>
> 1. JCC and CMP are in same `MCDataFragment`
> 2. JCC and CMP are in  two different `MCDataFragment`
> 3. JCC and CMP are in two different `MCRelaxableFragment`
> 4. JCC in a `MCRelaxableFragment`, CMP is in a `MCDataFragment`
>
>   and since `MCCompactEncodedInstFragment` is not applicable yet, i don't 
> what's its behaviour.
>
>   In order to compute the total size of CMP and JCC in 
> `MCAssembler::relaxBoundaryAlign`, I insert a `FusedJccSplit` to force CMP 
> and JCC in two fragments. Do you have any better idea?


I agree there are multiple cases here, see the original generic description 
instead of the specific example.  The general question is why a *range* of 
fragments can't be defined.  Computing the instruction size for the entire 
range then just requires walking from first to last fragment in the range 
summing the size of each.  If both instructions are within the same data 
fragment, then no relaxation is needed, and the size of both is simply the size 
of the data fragment.

Unless I'm missing something here?


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

https://reviews.llvm.org/D70157



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


[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please add documentation and mention new check in Release Notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


[PATCH] D71714: [Sema] NFC: Remove trailing spaces and fix a typo in a test file

2019-12-19 Thread Ilya Mirsky via Phabricator via cfe-commits
ilya created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array 
item

Fixes: http://llvm.org/PR44343


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71714

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/array-bounds.cpp


Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -27,7 +27,7 @@
 };
 
 void f1(int a[1]) {
-  int val = a[3]; // no warning for function argumnet
+  int val = a[3]; // no warning for function argument
 }
 
 void f2(const int (&a)[2]) { // expected-note {{declared here}}
@@ -133,7 +133,7 @@
 
 int test_sizeof_as_condition(int flag) {
   int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}}
-  if (flag) 
+  if (flag)
 return sizeof(char) != sizeof(char) ? arr[2] : arr[1];
   return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning 
{{array index 2 is past the end of the array (which contains 2 elements)}}
 }
@@ -241,7 +241,7 @@
 }
 
 int test_pr11007_aux(const char * restrict, ...);
-  
+
 // Test checking with varargs.
 void test_pr11007() {
   double a[5]; // expected-note {{array 'a' declared here}}
@@ -309,3 +309,23 @@
 foo(); // expected-note 1{{in instantiation of function template 
specialization}}
   };
 }
+
+namespace PR44343 {
+  const unsigned int array[2] = {0, 1}; // expected-note 4{{array 'array' 
declared here}}
+
+  const int i1 = (const int)array[2]; // expected-warning {{array index 2 is 
past the end of the array (which contains 2 elements)}}
+  const int i2 = static_cast(array[2]); // expected-warning {{array 
index 2 is past the end of the array (which contains 2 elements)}}
+  const int &i3 = reinterpret_cast(array[2]); // expected-warning 
{{array index 2 is past the end of the array (which contains 2 elements)}}
+  unsigned int &i4 = const_cast(array[2]); // expected-warning 
{{array index 2 is past the end of the array (which contains 2 elements)}}
+
+  struct Base {
+virtual ~Base();
+  };
+
+  struct Derived : Base {
+  };
+
+  Base baseArr[2]; // expected-note {{array 'baseArr' declared here}}
+  Derived *d1 = dynamic_cast(&baseArr[2]); // no warning for 
one-past-end element's address retrieval
+  Derived &d2 = dynamic_cast(baseArr[2]); // expected-warning 
{{array index 2 is past the end of the array (which contains 2 elements)}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13421,6 +13421,15 @@
   CheckArrayAccess(Arg);
 return;
   }
+  case Stmt::CStyleCastExprClass:
+  case Stmt::CXXStaticCastExprClass:
+  case Stmt::CXXDynamicCastExprClass:
+  case Stmt::CXXReinterpretCastExprClass:
+  case Stmt::CXXConstCastExprClass: {
+const auto *ECE = cast(expr);
+expr = ECE->getSubExpr();
+break;
+  }
   default:
 return;
 }


Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -27,7 +27,7 @@
 };
 
 void f1(int a[1]) {
-  int val = a[3]; // no warning for function argumnet
+  int val = a[3]; // no warning for function argument
 }
 
 void f2(const int (&a)[2]) { // expected-note {{declared here}}
@@ -133,7 +133,7 @@
 
 int test_sizeof_as_condition(int flag) {
   int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}}
-  if (flag) 
+  if (flag)
 return sizeof(char) != sizeof(char) ? arr[2] : arr[1];
   return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
 }
@@ -241,7 +241,7 @@
 }
 
 int test_pr11007_aux(const char * restrict, ...);
-  
+
 // Test checking with varargs.
 void test_pr11007() {
   double a[5]; // expected-note {{array 'a' declared here}}
@@ -309,3 +309,23 @@
 foo(); // expected-note 1{{in instantiation of function template specialization}}
   };
 }
+
+namespace PR44343 {
+  const unsigned int array[2] = {0, 1}; // expected-note 4{{array 'array' declared here}}
+
+  const int i1 = (const int)array[2]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+  const int i2 = static_cast(array[2]); // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+  const int &i3 = reinterpret_cast(array[2]); // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+  unsigned int &i4 = const_cast(array[2]); // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+
+  struct Base {
+virtual ~Base();
+  };

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil added a subscriber: labath.
jankratochvil added a comment.

In D71707#1791280 , @labath wrote:

> - disallowing casts to intptr_t seems too restrictive -- I doubt many people 
> are doing that, but I guess this type exists for a reason, and since the type 
> (and it's signedness) is spelled out in the source, it shouldn't be too 
> surprising that sign-extension can happen later


I was trying to find what is `intptr_t` good for and I haven't found any valid 
reason. It seems to me nobody knows that either. Which is why I find correct to 
report it. This checker has many false positives (or "not really a bug") anyway.

> - requiring a literal uintptr_t (or a typedef of it) may be also problematic 
> -- the user could obtain an integer type of the same bit width through some 
> other means (e.g. `#ifdef`). OTOH, without that (and just checking the bit 
> width for instance), one would have to actually compile for a 32-bit target 
> to get this warning. I don't know what's the practice for this in 
> clang-tidy...

Yes, I wanted first to check the widths but then I realized user would need a 
32-bit host for that which is too difficult to (1) get nowadays and (2) 
primarily to build there LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


[PATCH] D71314: Emit a warning if a variable is uninitialized in indirect ASM goto destination.

2019-12-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

> Use -Wuninitialized.

D'oh!




Comment at: clang/lib/Analysis/UninitializedValues.cpp:856
   if (!as->isAsmGoto())
 return;
 

nickdesaulniers wrote:
> Should we mark the vals `MayUninitialized` here, rather than below? Then I 
> think we can remove the `isAsmGoto` check you added in `getUninitUse`?
Bumping comment.



Comment at: clang/test/Analysis/uninit-asm-goto.cpp:57
+  return y;
+indirect:
+  return -2;

I think if you left out `indirect`, it would be clearer what this test is 
testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71314



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


[PATCH] D71716: [ItaniumCXXABI] Don't mark an extern_weak init function as dso_local on windows

2019-12-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, smeenai, rsmith.
Herald added a project: clang.

Since 6bf108d77a3c, we try to not mark extern_weak symbols as dso_local, to 
allow using COFF stubs for references to those symbols (as the symbol may be 
missing, resolving to an absolute address zero, outside of the current DSO).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71716

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/mingw-thread-local.cpp


Index: clang/test/CodeGenCXX/mingw-thread-local.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mingw-thread-local.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-w64-mingw32 | 
FileCheck %s
+
+extern thread_local int var;
+
+int get() {
+  return var;
+}
+
+// CHECK: declare extern_weak void @_ZTH3var()
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2690,7 +2690,9 @@
 
 if (Init) {
   Init->setVisibility(Var->getVisibility());
-  Init->setDSOLocal(Var->isDSOLocal());
+  // Don't mark an extern_weak function DSO local on windows.
+  if (!CGM.getTriple().isOSWindows() || !Init->hasExternalWeakLinkage())
+Init->setDSOLocal(Var->isDSOLocal());
 }
 
 llvm::LLVMContext &Context = CGM.getModule().getContext();


Index: clang/test/CodeGenCXX/mingw-thread-local.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mingw-thread-local.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-w64-mingw32 | FileCheck %s
+
+extern thread_local int var;
+
+int get() {
+  return var;
+}
+
+// CHECK: declare extern_weak void @_ZTH3var()
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2690,7 +2690,9 @@
 
 if (Init) {
   Init->setVisibility(Var->getVisibility());
-  Init->setDSOLocal(Var->isDSOLocal());
+  // Don't mark an extern_weak function DSO local on windows.
+  if (!CGM.getTriple().isOSWindows() || !Init->hasExternalWeakLinkage())
+Init->setDSOLocal(Var->isDSOLocal());
 }
 
 llvm::LLVMContext &Context = CGM.getModule().getContext();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71314: Emit a warning if a variable is uninitialized in indirect ASM goto destination.

2019-12-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Analysis/UninitializedValues.cpp:856
   if (!as->isAsmGoto())
 return;
 

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > Should we mark the vals `MayUninitialized` here, rather than below? Then I 
> > think we can remove the `isAsmGoto` check you added in `getUninitUse`?
> Bumping comment.
Ah, I see this was added in https://reviews.llvm.org/D69876.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71314



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


[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

2019-12-19 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

These are not the only AST nodes representing cast expressions (there is also 
`CXXFunctionalCastExpr`, ...). What about replacing the `IgnoreParenImpCasts()` 
above by `IgnoreParenCasts()` ? Incidentally doing this uncovers another test 
(`Parser/cxx-ambig-decl-expr.cpp )` where this diagnostic is triggered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71714



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


[PATCH] D71709: Give frontend dump flags consistent names (*-dump instead of dump-*)

2019-12-19 Thread Brian Gesiak via Phabricator via cfe-commits
modocache requested changes to this revision.
modocache added subscribers: jroelofs, echristo.
modocache added a comment.
This revision now requires changes to proceed.

Grepping for "dump-tokens", I can see one regression test that exercises this 
option: clang/test/Lexer/dollar-idents.c. "dump-coverage-mapping" also shows up 
in a few regression tests. One way to exercise the new option names is to 
modify these tests to use both the new and old option names. I think this would 
test that they can be used interchangeably.

As for the unit tests in llvm/unittests or clang/unittests, I agree, I don't 
think this diff requires any new tests in there.

I'll request changes on this diff because some `switch` statements in Clang 
need to be updated to handle the new option names. Also I'll suggest some 
additional reviewers: @jroelofs (who suggested we create aliases for these), 
and @echristo (because these options were last modified over 7 years ago and 
Eric has a long tenure in this codebase).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71709



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


[PATCH] D71709: Give frontend dump flags consistent names (*-dump instead of dump-*)

2019-12-19 Thread David Herzka via Phabricator via cfe-commits
herzka updated this revision to Diff 234746.
herzka added a comment.

Update argument parsing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71709

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -851,7 +851,7 @@
 
   Opts.CoverageMapping =
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
-  Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
+  Opts.DumpCoverageMapping = Args.hasArg(OPT_coverage_mapping_dump);
   Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
   Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
   Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
@@ -1725,9 +1725,9 @@
   Opts.ProgramAction = frontend::ASTView; break;
 case OPT_compiler_options_dump:
   Opts.ProgramAction = frontend::DumpCompilerOptions; break;
-case OPT_dump_raw_tokens:
+case OPT_raw_tokens_dump:
   Opts.ProgramAction = frontend::DumpRawTokens; break;
-case OPT_dump_tokens:
+case OPT_tokens_dump:
   Opts.ProgramAction = frontend::DumpTokens; break;
 case OPT_S:
   Opts.ProgramAction = frontend::EmitAssembly; break;
@@ -3340,7 +3340,7 @@
   Opts.DisablePCHValidation = Args.hasArg(OPT_fno_validate_pch);
   Opts.AllowPCHWithCompilerErrors = Args.hasArg(OPT_fallow_pch_with_errors);
 
-  Opts.DumpDeserializedPCHDecls = Args.hasArg(OPT_dump_deserialized_pch_decls);
+  Opts.DumpDeserializedPCHDecls = Args.hasArg(OPT_deserialized_pch_decls_dump);
   for (const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
 Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
 
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -272,8 +272,10 @@
   HelpText<"Four-byte version string for gcov files.">;
 def test_coverage : Flag<["-"], "test-coverage">,
   HelpText<"Do not generate coverage files or remove coverage changes from 
IR">;
-def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
+def coverage_mapping_dump : Flag<["-"], "coverage-mapping-dump">,
   HelpText<"Dump the coverage mapping records, for testing">;
+def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
+  Alias;
 def fuse_register_sized_bitfield_access: Flag<["-"], 
"fuse-register-sized-bitfield-access">,
   HelpText<"Use register sized accesses to bit-fields, when possible.">;
 def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
@@ -559,12 +561,16 @@
 
 def Eonly : Flag<["-"], "Eonly">,
   HelpText<"Just run preprocessor, no output (for timings)">;
-def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">,
+def raw_tokens_dump : Flag<["-"], "raw-tokens-dump">,
   HelpText<"Lex file in raw mode and dump raw tokens">;
+def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">,
+  Alias;
 def analyze : Flag<["-"], "analyze">,
   HelpText<"Run static analysis engine">;
-def dump_tokens : Flag<["-"], "dump-tokens">,
+def tokens_dump : Flag<["-"], "tokens-dump">,
   HelpText<"Run preprocessor, dump internal rep of tokens">;
+def dump_tokens : Flag<["-"], "dump-tokens">,
+  Alias;
 def init_only : Flag<["-"], "init-only">,
   HelpText<"Only execute frontend initialization">;
 def fixit : Flag<["-"], "fixit">,
@@ -726,8 +732,10 @@
   HelpText<"Disable validation of precompiled headers">;
 def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">,
   HelpText<"Accept a PCH file that was created with compiler errors">;
-def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
+def deserialized_pch_decls_dump : Flag<["-"], "deserialized-decls-dump">,
   HelpText<"Dump declarations that are deserialized from PCH, for testing">;
+def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
+  Alias;
 def error_on_deserialized_pch_decl : Separate<["-"], 
"error-on-deserialized-decl">,
   HelpText<"Emit error if a specific declaration is deserialized from PCH, for 
testing">;
 def error_on_deserialized_pch_decl_EQ : Joined<["-"], 
"error-on-deserialized-decl=">,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -851,7 +851,7 @@
 
   Opts.CoverageMapping =
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
-  Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
+  Opts.DumpCoverageMapping = Args.hasArg(OPT_coverage_mapping_dump);
   Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose

[PATCH] D69876: Allow output constraints on "asm goto"

2019-12-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers requested changes to this revision.
nickdesaulniers added a comment.
This revision now requires changes to proceed.

Thinking hard about this, I think there's four cases we really need to think 
hard about:

1. asm redirects control flow BEFORE assigning to output. ie.

  int foo(void) {
int y;
asm volatile goto ("ja %l1" : "=r"(y) ::: err);
return y;
  err:
return y;
  }

I think we can chalk this up to user error; stupid asm in, stupid asm out.  If 
the inline asm never assigns to the output, regardless of how the assembly 
block is exited, there's nothing we can do.  Your child patch 
(https://reviews.llvm.org/D71314) warns in the second return, though the first 
return is equally invalid.

2. asm redirects control flow AFTER assigning to output. ie.

  int foo(void) {
int y;
asm volatile goto ("mov 42, %0; ja %l1" : "=r"(y) ::: err);
return y;
  err:
return y;
  }

Why is this not valid in the case the indirect branch is taken?

The two other cases I can think of are in regards to conflicting constraints.  
Consider for example the x86 machine specific output constraints 
(https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints):

3. shared indirect destinations with differing/conflicting constraints

  void foo(void) {
  int y;
  asm volatile ("mov 42, %0" : "=d"(y));
  }
  void bar(void) {
  int y;
  asm volatile ("mov 42, %0" : "=c"(y));
  }
  void baz(void) {
  int y;
  asm volatile goto ("mov 42, %0; ja %1": "=d"(y) ::: quux);
  asm volatile goto ("mov 42, %0; ja %1": "=c"(y) ::: quux);
  return;
  quux:
  return;
  }

`foo` puts `42` in `%edx`. `bar` puts `42` in `%ecx`.  Where should `baz` put 
`42`? Your current patch set produces: `error: Undefined temporary symbol`.

4. conflicts between `register` variables and output constraints.

  void foo(void) {
  register int y asm("edx") = 0;
  asm volatile goto ("mov 42, %0; ja %l1" : "=c"(y) ::: bar);
  bar:
  return;
  }
  void baz(void) {
  register int y asm("edx") = 0;
  asm volatile ("mov 42, %0" : "=c"(y));
  }

The output constraint for `asm goto` says put the output in `%ecx`, yet the 
variable was declared as having register storage in `%edx`.

Looks like Clang already has bugs or at least disagrees with GCC (for the 
simpler case of `baz`, but the problem still exists for `foo`). Filed 
https://bugs.llvm.org/show_bug.cgi?id=44328.

I need to think more about this, but I feel like people may see #2 as a reason 
to not use this feature and I have serious concerns about that.




Comment at: clang/docs/LanguageExtensions.rst:1275
+It's important to note that outputs are valid only on the "fallthrough" branch.
+For example, the value assigned to `y` is not valid in the above `err` block.
+

Would you mind removing the `above` in this sentence. I initially parsed this 
as `the block above err`, which is not correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69876



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


[PATCH] D71718: [X86] Mark various pointer arguments in builtins as const

2019-12-19 Thread Warren Ristow via Phabricator via cfe-commits
wristow created this revision.
wristow added a reviewer: craig.topper.

Enabling `-Wcast-qual` identified many casts in various system headers
that were dropping the `const` qualifier.  Fixing those missing
qualifiers pointed out that a few of the definitions of the builtins
did not properly identify their arguments as 'const' pointers.  This
commit fixes those builtin definitions, and the system header files
so that they no longer drop the qualifier.


https://reviews.llvm.org/D71718

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/avxintrin.h
  clang/lib/Headers/emmintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/mwaitxintrin.h
  clang/lib/Headers/pmmintrin.h
  clang/lib/Headers/xmmintrin.h
  clang/test/Headers/x86-intrinsics-headers-clean.cpp
  clang/test/Headers/x86intrin-2.c

Index: clang/test/Headers/x86intrin-2.c
===
--- clang/test/Headers/x86intrin-2.c
+++ clang/test/Headers/x86intrin-2.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wcast-qual %s -verify
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=none -Wcast-qual %s -verify
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wcast-qual -x c++ %s -verify
 // expected-no-diagnostics
 
 #if defined(i386) || defined(__x86_64__)
@@ -16,6 +16,10 @@
   return _mm_add_ss(a, b);
 }
 
+void __attribute__((__target__("sse"))) mm_prefetch_wrap(const void *p) {
+  _mm_prefetch(p, 0x3);
+}
+
 __m128d __attribute__((__target__("sse2"))) mm_sqrt_sd_wrap(__m128d a, __m128d b) {
   return _mm_sqrt_sd(a, b);
 }
Index: clang/test/Headers/x86-intrinsics-headers-clean.cpp
===
--- clang/test/Headers/x86-intrinsics-headers-clean.cpp
+++ clang/test/Headers/x86-intrinsics-headers-clean.cpp
@@ -1,7 +1,7 @@
 // Make sure the intrinsic headers compile cleanly with no warnings or errors.
 
 // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -Wsystem-headers \
-// RUN:   -fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
+// RUN:   -Wcast-qual -fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // expected-no-diagnostics
 
Index: clang/lib/Headers/xmmintrin.h
===
--- clang/lib/Headers/xmmintrin.h
+++ clang/lib/Headers/xmmintrin.h
@@ -1627,7 +1627,7 @@
   struct __mm_loadh_pi_struct {
 __mm_loadh_pi_v2f32 __u;
   } __attribute__((__packed__, __may_alias__));
-  __mm_loadh_pi_v2f32 __b = ((struct __mm_loadh_pi_struct*)__p)->__u;
+  __mm_loadh_pi_v2f32 __b = ((const struct __mm_loadh_pi_struct*)__p)->__u;
   __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
   return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
 }
@@ -1654,7 +1654,7 @@
   struct __mm_loadl_pi_struct {
 __mm_loadl_pi_v2f32 __u;
   } __attribute__((__packed__, __may_alias__));
-  __mm_loadl_pi_v2f32 __b = ((struct __mm_loadl_pi_struct*)__p)->__u;
+  __mm_loadl_pi_v2f32 __b = ((const struct __mm_loadl_pi_struct*)__p)->__u;
   __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
   return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3);
 }
@@ -1680,7 +1680,7 @@
   struct __mm_load_ss_struct {
 float __u;
   } __attribute__((__packed__, __may_alias__));
-  float __u = ((struct __mm_load_ss_struct*)__p)->__u;
+  float __u = ((const struct __mm_load_ss_struct*)__p)->__u;
   return __extension__ (__m128){ __u, 0, 0, 0 };
 }
 
@@ -1702,7 +1702,7 @@
   struct __mm_load1_ps_struct {
 float __u;
   } __attribute__((__packed__, __may_alias__));
-  float __u = ((struct __mm_load1_ps_struct*)__p)->__u;
+  float __u = ((const struct __mm_load1_ps_struct*)__p)->__u;
   return __extension__ (__m128){ __u, __u, __u, __u };
 }
 
@@ -1722,7 +1722,7 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_load_ps(const float *__p)
 {
-  return *(__m128*)__p;
+  return *(const __m128*)__p;
 }
 
 /// Loads a 128-bit floating-point vector of [4 x float] from an
@@ -1742,7 +1742,7 @@
   struct __loadu_ps {
 __m128_u __v;
   } __attribute__((__packed__, __may_alias__));
-  return ((struct __loadu_ps*)__p)->__v;
+  return ((const struct __loadu_ps*)__p)->__v;
 }
 
 /// Loads four packed float values, in reverse order, from an aligned
@@ -2100,7 +2100,7 @@
 ///be generated. \n
 ///_MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
 ///be generated.
-#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), \
+#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
   

[PATCH] D71718: [X86] Mark various pointer arguments in builtins as const

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

LGTM


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

https://reviews.llvm.org/D71718



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2019-12-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D71451#1791314 , @Jac1494 wrote:

> >> @Jac1494 - have you made any measurements of the size increase of this 
> >> change? Perhaps a self-host build of clang?
>
> With change(default) and without change size diffrence given below ,in that 
> only debug section size is changed.
>
> Without change:-(default)
>  $size -A -d  build_debug_withoutfix/bin/clang-10 
>  
>  
>  .comment 159 0
>  .debug_str   3999832 0
>  .debug_loc   941 0
>  .debug_abbrev  12754 0
>  .debug_info  2225482 0
>  .debug_ranges  46672 0
>  .debug_line   153741 0
>  .note.gnu.gold-version28 0
>  Total6835098
>
> With change:-
>
> $size -A -d  build_debug_withfix/bin/clang-10 
>  .
>  .
>  .comment 159 0
>  .debug_str   3999775 0
>  .debug_loc   941 0
>  .debug_abbrev  12746 0
>  .debug_info  2225458 0
>  .debug_ranges  46672 0
>  .debug_line   153717 0
>  .note.gnu.gold-version28 0
>  Total6834985


Am I reading this right that the data would suggest that enabling this feature 
/reduces/ the size of debug info sections? That doesn't sound right - can you 
explain why that would be the case? (perhaps the data is incorrect/it wasn't 
built with -fstandalone-debug?)


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

https://reviews.llvm.org/D71451



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


[clang] 6a7df3a - [ASTImporter][LLDB] Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-19 Thread via cfe-commits

Author: shafik
Date: 2019-12-19T11:16:54-08:00
New Revision: 6a7df3a3f940473088b1db1ccadafe52bb274b62

URL: 
https://github.com/llvm/llvm-project/commit/6a7df3a3f940473088b1db1ccadafe52bb274b62
DIFF: 
https://github.com/llvm/llvm-project/commit/6a7df3a3f940473088b1db1ccadafe52bb274b62.diff

LOG: [ASTImporter][LLDB] Modifying ImportDeclContext(...) to ensure that we 
complete each FieldDecl of a RecordDecl when we are importing the definiton

This fix was motivated by a crashes in expression parsing during code 
generation in which we had a RecordDecl that had incomplete FieldDecl. During 
code generation when computing the layout for the RecordDecl we crash because 
we have several incomplete FieldDecl.

This fixes the issue by assuring that during ImportDefinition(...) for a 
RecordDecl we also import the definitions for each FieldDecl.

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

Added: 

lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py

lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp

Modified: 
clang/lib/AST/ASTImporter.cpp

lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index b75a689ec275..f495c48803d1 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1734,7 +1734,34 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, 
bool ForceImport) {
   Error ChildErrors = Error::success();
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
-if (!ImportedOrErr) {
+
+// If we are in the process of ImportDefinition(...) for a RecordDecl we
+// want to make sure that we are also completing each FieldDecl. There
+// are currently cases where this does not happen and this is correctness
+// fix since operations such as code generation will expect this to be so.
+if (ImportedOrErr) {
+  FieldDecl *FieldFrom = dyn_cast_or_null(From);
+  Decl *ImportedDecl = (Decl*)*ImportedOrErr;
+  FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
+  if (FieldFrom && FieldTo) {
+const RecordType *RecordFrom = 
FieldFrom->getType()->getAs();
+const RecordType *RecordTo = FieldTo->getType()->getAs();
+if (RecordFrom && RecordTo) {
+  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
+  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+
+  if (FromRecordDecl->isCompleteDefinition() &&
+  !ToRecordDecl->isCompleteDefinition()) {
+Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);
+
+if (Err && AccumulateChildErrors)
+  ChildErrors =  joinErrors(std::move(ChildErrors), 
std::move(Err));
+else
+  consumeError(std::move(Err));
+  }
+}
+  }
+} else {
   if (AccumulateChildErrors)
 ChildErrors =
 joinErrors(std::move(ChildErrors), ImportedOrErr.takeError());

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
new file mode 100644
index ..f08c0dcbda98
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
new file mode 100644
index ..e4f6600eab2c
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
@@ -0,0 +1,39 @@
+// This is a reproducer for a crash in codegen. It happens when we have a
+// RecordDecl used in an expression and one of the FieldDecl are not complete.
+// This case happens when:
+// - A RecordDecl (E) has a FieldDecl which is a reference member variable
+// - The underlying type of the FieldDec is a TypedefDecl
+// - The typedef refers to a ClassTemplateSpecialization (DWrapper)
+// - The typedef is not present in the DeclContext of B
+// - The typedef shows up as a return value of a member function of E (f())
+template  struct DWrapper {};
+
+str

[PATCH] D71378: Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-19 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a7df3a3f940: [ASTImporter][LLDB] Modifying 
ImportDeclContext(...) to ensure that we complete… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71378

Files:
  clang/lib/AST/ASTImporter.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py

Index: lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
@@ -1,4 +1,4 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIf(bugnumber="rdar://53756116")])
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
@@ -0,0 +1,39 @@
+// This is a reproducer for a crash in codegen. It happens when we have a
+// RecordDecl used in an expression and one of the FieldDecl are not complete.
+// This case happens when:
+// - A RecordDecl (E) has a FieldDecl which is a reference member variable
+// - The underlying type of the FieldDec is a TypedefDecl
+// - The typedef refers to a ClassTemplateSpecialization (DWrapper)
+// - The typedef is not present in the DeclContext of B
+// - The typedef shows up as a return value of a member function of E (f())
+template  struct DWrapper {};
+
+struct D {};
+
+namespace NS {
+typedef DWrapper DW;
+}
+
+struct B {
+  NS::DW spd;
+  int a = 0;
+};
+
+struct E {
+  E(B &b) : b_ref(b) {}
+  NS::DW f() { return {}; };
+  void g() {
+return; //%self.expect("p b_ref", substrs=['(B) $0 =', '(spd = NS::DW', 'a = 0)'])
+  }
+
+  B &b_ref;
+};
+
+int main() {
+  B b;
+  E e(b);
+
+  e.g();
+
+  return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1734,7 +1734,34 @@
   Error ChildErrors = Error::success();
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
-if (!ImportedOrErr) {
+
+// If we are in the process of ImportDefinition(...) for a RecordDecl we
+// want to make sure that we are also completing each FieldDecl. There
+// are currently cases where this does not happen and this is correctness
+// fix since operations such as code generation will expect this to be so.
+if (ImportedOrErr) {
+  FieldDecl *FieldFrom = dyn_cast_or_null(From);
+  Decl *ImportedDecl = (Decl*)*ImportedOrErr;
+  FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
+  if (FieldFrom && FieldTo) {
+const RecordType *RecordFrom = FieldFrom->getType()->getAs();
+const RecordType *RecordTo = FieldTo->getType()->getAs();
+if (RecordFrom && RecordTo) {
+  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
+  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+
+  if (FromRecordDecl->isCompleteDefinition() &&
+  !ToRecordDecl->isCompleteDefinition()) {
+Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);
+
+if (Err && AccumulateChildErrors)
+  ChildErrors =  joinErrors(std::move(ChildErrors), std::move(Err));
+else
+  consumeError(std::move(Err));
+  }
+}
+  }
+} else {
   if (AccumulateChildErrors)
 ChildErr

[PATCH] D71623: [compiler-rt] [test] Add missing %run to fread_fwrite MSAN test

2019-12-19 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20345707b2c9: [compiler-rt] [test] Add missing %run to 
fread_fwrite MSAN test (authored by mgorny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71623

Files:
  compiler-rt/test/msan/fread_fwrite.cpp


Index: compiler-rt/test/msan/fread_fwrite.cpp
===
--- compiler-rt/test/msan/fread_fwrite.cpp
+++ compiler-rt/test/msan/fread_fwrite.cpp
@@ -1,5 +1,5 @@
 // RUN: %clangxx_msan -g %s -o %t
-// RUN: not %t 2>&1 | FileCheck %s
+// RUN: not %run %t 2>&1 | FileCheck %s
 // RUN: %t 1
 
 #include 


Index: compiler-rt/test/msan/fread_fwrite.cpp
===
--- compiler-rt/test/msan/fread_fwrite.cpp
+++ compiler-rt/test/msan/fread_fwrite.cpp
@@ -1,5 +1,5 @@
 // RUN: %clangxx_msan -g %s -o %t
-// RUN: not %t 2>&1 | FileCheck %s
+// RUN: not %run %t 2>&1 | FileCheck %s
 // RUN: %t 1
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-12-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert resigned from this revision.
jdoerfert added a comment.

This has enough active reviewers as it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[clang] 7fcd9e3 - [X86] Mark various pointer arguments in builtins as const

2019-12-19 Thread Warren Ristow via cfe-commits

Author: Warren Ristow
Date: 2019-12-19T11:42:11-08:00
New Revision: 7fcd9e3f70830a9c4bf631a602c2764180b5c3a8

URL: 
https://github.com/llvm/llvm-project/commit/7fcd9e3f70830a9c4bf631a602c2764180b5c3a8
DIFF: 
https://github.com/llvm/llvm-project/commit/7fcd9e3f70830a9c4bf631a602c2764180b5c3a8.diff

LOG: [X86] Mark various pointer arguments in builtins as const

Enabling `-Wcast-qual` identified many casts in various system headers
that were dropping the `const` qualifier.  Fixing those missing
qualifiers pointed out that a few of the definitions of the builtins
did not properly identify their arguments as `const` pointers.  This
commit fixes those builtin definitions, and the system header files
so that they no longer drop the qualifier.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsX86.def
clang/lib/Headers/avx512bwintrin.h
clang/lib/Headers/avx512fintrin.h
clang/lib/Headers/avx512vlbwintrin.h
clang/lib/Headers/avx512vlintrin.h
clang/lib/Headers/avxintrin.h
clang/lib/Headers/emmintrin.h
clang/lib/Headers/immintrin.h
clang/lib/Headers/mwaitxintrin.h
clang/lib/Headers/pmmintrin.h
clang/lib/Headers/xmmintrin.h
clang/test/Headers/x86-intrinsics-headers-clean.cpp
clang/test/Headers/x86intrin-2.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 5ab9dc1c3ac3..d6aa46de02f9 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -365,7 +365,7 @@ TARGET_BUILTIN(__builtin_ia32_pmaddwd128, "V4iV8sV8s", 
"ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pslldqi128_byteshift, "V2OiV2OiIi", "ncV:128:", 
"sse2")
 TARGET_BUILTIN(__builtin_ia32_psrldqi128_byteshift, "V2OiV2OiIi", "ncV:128:", 
"sse2")
 
-TARGET_BUILTIN(__builtin_ia32_monitor, "vv*UiUi", "n", "sse3")
+TARGET_BUILTIN(__builtin_ia32_monitor, "vvC*UiUi", "n", "sse3")
 TARGET_BUILTIN(__builtin_ia32_mwait, "vUiUi", "n", "sse3")
 TARGET_BUILTIN(__builtin_ia32_lddqu, "V16ccC*", "nV:128:", "sse3")
 
@@ -1396,8 +1396,8 @@ TARGET_BUILTIN(__builtin_ia32_psrlw512, "V32sV32sV8s", 
"ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlwi512, "V32sV32si", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pslldqi512_byteshift, "V8OiV8OiIi", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrldqi512_byteshift, "V8OiV8OiIi", "ncV:512:", 
"avx512bw")
-TARGET_BUILTIN(__builtin_ia32_movdqa32load128_mask, "V4iV4i*V4iUc", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_movdqa32load256_mask, "V8iV8i*V8iUc", "nV:256:", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_movdqa32load128_mask, "V4iV4iC*V4iUc", 
"nV:128:", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_movdqa32load256_mask, "V8iV8iC*V8iUc", 
"nV:256:", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load512_mask, "V16iV16iC*V16iUs", 
"nV:512:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_movdqa32store512_mask, "vV16i*V16iUs", 
"nV:512:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_movdqa64load512_mask, "V8OiV8OiC*V8OiUc", 
"nV:512:", "avx512f")
@@ -1418,8 +1418,8 @@ TARGET_BUILTIN(__builtin_ia32_vcomisd, "iV2dV2dIiIi", 
"ncV:128:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcomiss, "iV4fV4fIiIi", "ncV:128:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_kunpckdi, "UOiUOiUOi", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_kunpcksi, "UiUiUi", "nc", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_loaddquhi512_mask, "V32sV32s*V32sUi", "nV:512:", 
"avx512bw")
-TARGET_BUILTIN(__builtin_ia32_loaddquqi512_mask, "V64cV64c*V64cUOi", 
"nV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_loaddquhi512_mask, "V32sV32sC*V32sUi", 
"nV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_loaddquqi512_mask, "V64cV64cC*V64cUOi", 
"nV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_fixupimmpd512_mask, "V8dV8dV8dV8OiIiUcIi", 
"ncV:512:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_fixupimmpd512_maskz, "V8dV8dV8dV8OiIiUcIi", 
"ncV:512:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_fixupimmps512_mask, "V16fV16fV16fV16iIiUsIi", 
"ncV:512:", "avx512f")
@@ -1432,10 +1432,10 @@ TARGET_BUILTIN(__builtin_ia32_getexpsd128_round_mask, 
"V2dV2dV2dV2dUcIi", "ncV:1
 TARGET_BUILTIN(__builtin_ia32_getexpss128_round_mask, "V4fV4fV4fV4fUcIi", 
"ncV:128:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_getmantsd_round_mask, "V2dV2dV2dIiV2dUcIi", 
"ncV:128:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_getmantss_round_mask, "V4fV4fV4fIiV4fUcIi", 
"ncV:128:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_loaddquhi128_mask, "V8sV8s*V8sUc", "nV:128:", 
"avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_loaddquhi256_mask, "V16sV16s*V16sUs", "nV:256:", 
"avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_loaddquqi128_mask, "V16cV16c*V16cUs", "nV:128:", 
"avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_loaddquqi256_mask, "V32cV32c*V32cUi", "nV:2

[PATCH] D71718: [X86] Mark various pointer arguments in builtins as const

2019-12-19 Thread Warren Ristow via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7fcd9e3f7083: [X86] Mark various pointer arguments in 
builtins as const (authored by wristow).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71718

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/avxintrin.h
  clang/lib/Headers/emmintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/mwaitxintrin.h
  clang/lib/Headers/pmmintrin.h
  clang/lib/Headers/xmmintrin.h
  clang/test/Headers/x86-intrinsics-headers-clean.cpp
  clang/test/Headers/x86intrin-2.c

Index: clang/test/Headers/x86intrin-2.c
===
--- clang/test/Headers/x86intrin-2.c
+++ clang/test/Headers/x86intrin-2.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wcast-qual %s -verify
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=none -Wcast-qual %s -verify
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wcast-qual -x c++ %s -verify
 // expected-no-diagnostics
 
 #if defined(i386) || defined(__x86_64__)
@@ -16,6 +16,10 @@
   return _mm_add_ss(a, b);
 }
 
+void __attribute__((__target__("sse"))) mm_prefetch_wrap(const void *p) {
+  _mm_prefetch(p, 0x3);
+}
+
 __m128d __attribute__((__target__("sse2"))) mm_sqrt_sd_wrap(__m128d a, __m128d b) {
   return _mm_sqrt_sd(a, b);
 }
Index: clang/test/Headers/x86-intrinsics-headers-clean.cpp
===
--- clang/test/Headers/x86-intrinsics-headers-clean.cpp
+++ clang/test/Headers/x86-intrinsics-headers-clean.cpp
@@ -1,7 +1,7 @@
 // Make sure the intrinsic headers compile cleanly with no warnings or errors.
 
 // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -Wsystem-headers \
-// RUN:   -fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
+// RUN:   -Wcast-qual -fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // expected-no-diagnostics
 
Index: clang/lib/Headers/xmmintrin.h
===
--- clang/lib/Headers/xmmintrin.h
+++ clang/lib/Headers/xmmintrin.h
@@ -1627,7 +1627,7 @@
   struct __mm_loadh_pi_struct {
 __mm_loadh_pi_v2f32 __u;
   } __attribute__((__packed__, __may_alias__));
-  __mm_loadh_pi_v2f32 __b = ((struct __mm_loadh_pi_struct*)__p)->__u;
+  __mm_loadh_pi_v2f32 __b = ((const struct __mm_loadh_pi_struct*)__p)->__u;
   __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
   return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
 }
@@ -1654,7 +1654,7 @@
   struct __mm_loadl_pi_struct {
 __mm_loadl_pi_v2f32 __u;
   } __attribute__((__packed__, __may_alias__));
-  __mm_loadl_pi_v2f32 __b = ((struct __mm_loadl_pi_struct*)__p)->__u;
+  __mm_loadl_pi_v2f32 __b = ((const struct __mm_loadl_pi_struct*)__p)->__u;
   __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
   return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3);
 }
@@ -1680,7 +1680,7 @@
   struct __mm_load_ss_struct {
 float __u;
   } __attribute__((__packed__, __may_alias__));
-  float __u = ((struct __mm_load_ss_struct*)__p)->__u;
+  float __u = ((const struct __mm_load_ss_struct*)__p)->__u;
   return __extension__ (__m128){ __u, 0, 0, 0 };
 }
 
@@ -1702,7 +1702,7 @@
   struct __mm_load1_ps_struct {
 float __u;
   } __attribute__((__packed__, __may_alias__));
-  float __u = ((struct __mm_load1_ps_struct*)__p)->__u;
+  float __u = ((const struct __mm_load1_ps_struct*)__p)->__u;
   return __extension__ (__m128){ __u, __u, __u, __u };
 }
 
@@ -1722,7 +1722,7 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_load_ps(const float *__p)
 {
-  return *(__m128*)__p;
+  return *(const __m128*)__p;
 }
 
 /// Loads a 128-bit floating-point vector of [4 x float] from an
@@ -1742,7 +1742,7 @@
   struct __loadu_ps {
 __m128_u __v;
   } __attribute__((__packed__, __may_alias__));
-  return ((struct __loadu_ps*)__p)->__v;
+  return ((const struct __loadu_ps*)__p)->__v;
 }
 
 /// Loads four packed float values, in reverse order, from an aligned
@@ -2100,7 +2100,7 @@
 ///be generated. \n
 ///_MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
 ///be generated.
-#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), \
+#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
  ((sel) >> 2) & 1, (sel) & 0x3))
 #endif
 
Index: clang/lib/Headers/pmmintrin.h
==

[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

2019-12-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang-tools-extra/clangd/FormattedString.cpp:110
+// Separate from next block.
+*WritePtr++ = ' ';
+  }

There's an issue at this line, the iterator might go past the end of the string 
(if running the `Document.Separators` test). This fails when running a Debug 
build with VS 2019. The code fails with this assert (in `xstring`):
```
_STL_VERIFY(_Unfancy(_Ptr) < _Mycont->_Myptr() + _Mycont->_Mysize, "cannot 
increment string iterator past end");
```
I changed the code such as: {F11108172}
(sorry, Phabricator throws an exception when uploading this patch as a 
differential)

I can commit it if you're fine with the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248



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


[PATCH] D71723: ConstrainedFP: use API compatible with opaque pointers.

2019-12-19 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: kpn.
Herald added a subscriber: mcrosier.
Herald added projects: clang, LLVM.

This just updates an IRBuilder interface to take Functions instead of Values so 
the type can be derived, and fixes some callsites in Clang to call the updated 
API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71723

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/IRBuilder.h


Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -2421,18 +2421,16 @@
 Args, OpBundles, Name, FPMathTag);
   }
 
-  // Deprecated [opaque pointer types]
   CallInst *CreateConstrainedFPCall(
-  Value *Callee, ArrayRef Args, const Twine &Name = "",
+  Function *Callee, ArrayRef Args, const Twine &Name = "",
   Optional Rounding = None,
   Optional Except = None) {
 llvm::SmallVector UseArgs;
 
 for (auto *OneArg : Args)
   UseArgs.push_back(OneArg);
-Function *F = cast(Callee);
 bool HasRoundingMD = false;
-switch (F->getIntrinsicID()) {
+switch (Callee->getIntrinsicID()) {
 default:
   break;
 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)  \
@@ -2445,9 +2443,7 @@
   UseArgs.push_back(getConstrainedFPRounding(Rounding));
 UseArgs.push_back(getConstrainedFPExcept(Except));
 
-CallInst *C = CreateCall(
-cast(Callee->getType()->getPointerElementType()), Callee,
-UseArgs, Name);
+CallInst *C = CreateCall(Callee, UseArgs, Name);
 setConstrainedFPCallAttr(C);
 return C;
   }
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -368,10 +368,10 @@
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, Src0);
   }
 }
@@ -385,10 +385,10 @@
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, { Src0, Src1 });
   }
 }
@@ -403,10 +403,10 @@
   llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
 }


Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -2421,18 +2421,16 @@
 Args, OpBundles, Name, FPMathTag);
   }
 
-  // Deprecated [opaque pointer types]
   CallInst *CreateConstrainedFPCall(
-  Value *Callee, ArrayRef Args, const Twine &Name = "",
+  Function *Callee, ArrayRef Args, const Twine &Name = "",
   Optional Rounding = None,
   Optional Except = None) {
 llvm::SmallVector UseArgs;
 
 for (auto *OneArg : Args)
   UseArgs.push_back(OneArg);
-Function *F = cast(Callee);
 bool HasRoundingMD = false;
-switch (F->getIntrinsicID()) {
+switch (Callee->getIntrinsicID()) {
 default:
   break;
 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)  \
@@ -2445,9 +2443,7 @@
   UseArgs.push_back(getConstrainedFPRounding(Rounding));
 UseArgs.push_back(getConstrainedFPExcept(Except));
 
-CallInst *C = CreateCall(
-cast(Callee->getType()->getPointerElementType()), Callee,
-UseArgs, Name);
+CallInst *C = CreateCall(Callee, UseArgs, Name);
 setConstrainedFPCallAttr(C);
 return C;
   }
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3

[PATCH] D69876: Allow output constraints on "asm goto"

2019-12-19 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D69876#1791475 , @nickdesaulniers 
wrote:

> Thinking hard about this, I think there's four cases we really need to think 
> hard about:
>
> 1. asm redirects control flow BEFORE assigning to output. ie.
>
>   ``` int foo(void) { int y; asm volatile goto ("ja %l1" : "=r"(y) ::: err); 
> return y; err: return y; } ```
>
>   I think we can chalk this up to user error; stupid asm in, stupid asm out.  
> If the inline asm never assigns to the output, regardless of how the assembly 
> block is exited, there's nothing we can do.  Your child patch 
> (https://reviews.llvm.org/D71314) warns in the second return, though the 
> first return is equally invalid.


Right. This is human error. Unless we can parse the inline assembly (not 
something I'm suggesting) we won't be able to help them here.

> 2. asm redirects control flow AFTER assigning to output. ie. ``` int 
> foo(void) { int y; asm volatile goto ("mov 42, %0; ja %l1" : "=d"(y) ::: 
> err); return y; err: return y; } ``` Why is this not valid in the case the 
> indirect branch is taken?

I'm not saying that it's *always* invalid, but we won't be able to guarantee 
correctness during code gen. For example, if you have something like:

  int foo(int x) {
int y;
if (x < 42)
  asm volatile goto ("mov 42, %0; ja %l1" : "=D"(y) ::: err);
else
  asm volatile goto ("mov 0, %0; ja %l1" : "=S"(y) ::: err);
return y;
  err:
return y;
  }

we can't necessarily code gen this correctly for the `err` block. There was a 
long thread on ways we could try to do this, but they were all very 
sub-standard.

> The two other cases I can think of are in regards to conflicting constraints. 
>  Consider for example the x86 machine specific output constraints 
> (https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints):
> 
> 3. shared indirect destinations with differing/conflicting constraints ``` 
> void foo(void) { int y; asm volatile ("mov 42, %0" : "=d"(y)); } void 
> bar(void) { int y; asm volatile ("mov 42, %0" : "=c"(y)); } void baz(void) { 
> int y; asm volatile goto ("mov 42, %0; ja %1": "=d"(y) ::: quux); asm 
> volatile goto ("mov 42, %0; ja %1": "=c"(y) ::: quux); return; quux: return; 
> } ``` `foo` puts `42` in `%edx`. `bar` puts `42` in `%ecx`.  Where should 
> `baz` put `42`? Your current patch set produces: `error: Undefined temporary 
> symbol`.

Whatever is done for inline assembly that's not "goto" is done here. Or at 
least should be. I'll fix the error message. But in essence it will move the 
correct value into the correct register. In this case, it should move 42 into 
both `%edx` and `%ecx`. The temporary symbol issue is most likely unrelated.

> 4. conflicts between `register` variables and output constraints. ``` void 
> foo(void) { register int y asm("edx") = 0; asm volatile goto ("mov 42, %0; ja 
> %l1" : "=c"(y) ::: bar); bar: return; } void baz(void) { register int y 
> asm("edx") = 0; asm volatile ("mov 42, %0" : "=c"(y)); } ``` The output 
> constraint for `asm goto` says put the output in `%ecx`, yet the variable was 
> declared as having register storage in `%edx`.
> 
>   Looks like Clang already has bugs or at least disagrees with GCC (for the 
> simpler case of `baz`, but the problem still exists for `foo`). Filed 
> https://bugs.llvm.org/show_bug.cgi?id=44328.
> 
>   I need to think more about this, but I feel like people may see #2 as a 
> reason to not use this feature and I have serious concerns about that.

Both functions generate the same output for me:

  foo:# @foo
.cfi_startproc
  # %bb.0:# %entry
#APP
movl42, %edx
ja  .Ltmp0
#NO_APP
  .Ltmp0: # Block address taken
  .LBB0_1:# %bar
retq
  .Lfunc_end0:
.size   foo, .Lfunc_end0-foo
.cfi_endproc
  # -- End function
.globl  baz # -- Begin function baz
.p2align4, 0x90
.type   baz,@function
  baz:# @baz
.cfi_startproc
  # %bb.0:# %entry
#APP
movl42, %edx
#NO_APP
retq

Note that we're not going to be able to fix all of clang's inline assembly bugs 
with this feature. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69876



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


[PATCH] D69876: Allow output constraints on "asm goto"

2019-12-19 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

I'm not getting the `Undefined temporary symbol` in your example (even with 
optimizations):

  [morbo@fawn:llvm-project] cat ../bug.c
  void baz(void) {
  int y;
  asm volatile goto ("mov 42, %0; ja %1": "=d"(y) ::: quux);
  asm volatile goto ("mov 42, %0; ja %1": "=c"(y) ::: quux);
  return;
  quux:
  return;
  }
  [morbo@fawn:llvm-project] clang -o - -S ../bug.c
.text
.file   "bug.c"
.globl  baz # -- Begin function baz
.p2align4, 0x90
.type   baz,@function
  baz:# @baz
.cfi_startproc
  # %bb.0:# %entry
pushq   %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq%rsp, %rbp
.cfi_def_cfa_register %rbp
#APP
movl42, %edx
ja  .Ltmp00
#NO_APP
movl%edx, -8(%rbp)  # 4-byte Spill
jmp .LBB0_1
  .LBB0_1:# %asm.fallthrough
movl-8(%rbp), %eax  # 4-byte Reload
movl%eax, -4(%rbp)
#APP
movl42, %ecx
ja  .Ltmp00
#NO_APP
movl%ecx, -12(%rbp) # 4-byte Spill
jmp .LBB0_2
  .LBB0_2:# %asm.fallthrough1
movl-12(%rbp), %eax # 4-byte Reload
movl%eax, -4(%rbp)
jmp .LBB0_4
  .Ltmp0: # Block address taken
  .LBB0_3:# %quux
jmp .LBB0_4
  .LBB0_4:# %return
popq%rbp
.cfi_def_cfa %rsp, 8
retq
  .Lfunc_end0:
.size   baz, .Lfunc_end0-baz
.cfi_endproc
  # -- End function
.ident  "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 
5b71b09a54edbb20900e6d13de35d2592f788330)"
.section".note.GNU-stack","",@progbits
.addrsig
.addrsig_sym baz


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69876



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Added superficial LLVM coding style comments.




Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4735
 
+// Merge directness from the canonical declaration upfront
+if (!ObjCMethod->isDirectMethod()) {

missing `.` at end of sentence.

"Upfront" as opposed to? It would be helpful to add a ", because ..." here



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4754
+
+  // if the match is from the same Class (not super),
+  // validate that there is no declaration/implementation

// If

Is there a better way to express `Class (not super)`?



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4777
+
+  if (directContainerMismatch) {
+int decl = 0, impl = 0;

how about factoring this into a diagContainerMismatch lambda?



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4829
+  // There can be a single declaration in any @interface container
+  // for a given direct method, look for clashes as we add them
+  //

`.`



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4845
+// diag::err_objc_direct_on_protocol is already emitted for these
+// with a better diagnostic, so don't do it twice
+  } else if (ObjCMethod->isDirectMethod() || IMD->isDirectMethod()) {

full sentence please


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

https://reviews.llvm.org/D71694



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


[PATCH] D71723: ConstrainedFP: use API compatible with opaque pointers.

2019-12-19 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn accepted this revision.
kpn added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71723



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/lib/AST/DeclObjC.cpp:963
 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) {
-  if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
-  isInstanceMethod()))
+  // When the container is the principal @implementation,
+  // the canonical Decl is either in an @interface, or in an extension.

What does "principal" mean here?



Comment at: clang/lib/AST/DeclObjC.cpp:966
+  //
+  // So when we don't find it in the principal @interface,
+  // sift through extensions too.

Does principal mean the ObjCInterfaceDecl of ImplD? Should we say that instead?


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

https://reviews.llvm.org/D71694



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


[clang-tools-extra] 3346cec - [clangd] Fix write past end pointer

2019-12-19 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-12-19T21:50:32+01:00
New Revision: 3346cecd4c0c960377b441606b6382a684daf061

URL: 
https://github.com/llvm/llvm-project/commit/3346cecd4c0c960377b441606b6382a684daf061
DIFF: 
https://github.com/llvm/llvm-project/commit/3346cecd4c0c960377b441606b6382a684daf061.diff

LOG: [clangd] Fix write past end pointer

Added: 


Modified: 
clang-tools-extra/clangd/FormattedString.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FormattedString.cpp 
b/clang-tools-extra/clangd/FormattedString.cpp
index 5c225139de23..a7a63a476c3c 100644
--- a/clang-tools-extra/clangd/FormattedString.cpp
+++ b/clang-tools-extra/clangd/FormattedString.cpp
@@ -104,13 +104,12 @@ std::string canonicalizeSpaces(std::string Input) {
 return "";
   // Go over each word and add it to the string.
   for (llvm::StringRef Word : Words) {
+if (WritePtr > Input.begin())
+  *WritePtr++ = ' '; // Separate from previous block.
 llvm::for_each(Word, [&WritePtr](const char C) { *WritePtr++ = C; });
-// Separate from next block.
-*WritePtr++ = ' ';
   }
-  // Get rid of extra spaces, -1 is for the trailing space introduced with last
-  // word.
-  Input.resize(WritePtr - Input.begin() - 1);
+  // Get rid of extra spaces.
+  Input.resize(WritePtr - Input.begin());
   return Input;
 }
 



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder marked an inline comment as done.
MadCoder added inline comments.



Comment at: clang/lib/AST/DeclObjC.cpp:963
 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) {
-  if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
-  isInstanceMethod()))
+  // When the container is the principal @implementation,
+  // the canonical Decl is either in an @interface, or in an extension.

aprantl wrote:
> What does "principal" mean here?
primary sorry, will fix


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

https://reviews.llvm.org/D71694



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


[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

2019-12-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FormattedString.cpp:110
+// Separate from next block.
+*WritePtr++ = ' ';
+  }

aganea wrote:
> There's an issue at this line, the iterator might go past the end of the 
> string (if running the `Document.Separators` test). This fails when running a 
> Debug build with VS 2019. The code fails with this assert (in `xstring`):
> ```
> _STL_VERIFY(_Unfancy(_Ptr) < _Mycont->_Myptr() + _Mycont->_Mysize, "cannot 
> increment string iterator past end");
> ```
> I changed the code such as: {F11108172}
> (sorry, Phabricator throws an exception when uploading this patch as a 
> differential)
> 
> I can commit it if you're fine with the change.
thanks for reporting this!

sent out rG3346cecd4c0c960377b441606b6382a684daf061


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248



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


[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil updated this revision to Diff 234772.
jankratochvil added a comment.

Wrote the documentation and Release Notes entry, thanks for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s bugprone-pointer-cast-widening %t
+
+#include 
+
+void test(void) {
+  void *p = 0;
+  uint64_t u64 = (uint64_t)p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  uint64_t u64r = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  intptr_t ip = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend [bugprone-pointer-cast-widening]
+  uintptr_t up = (uintptr_t)p;
+  typedef uintptr_t t1;
+  typedef t1 t2;
+  t2 t = (t2)p;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -62,6 +62,7 @@
bugprone-multiple-statement-macro
bugprone-not-null-terminated-result
bugprone-parent-virtual-call
+   bugprone-pointer-cast-widening
bugprone-posix-return
bugprone-sizeof-container
bugprone-sizeof-expression
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - bugprone-pointer-cast-widening
+
+bugprone-pointer-cast-widening
+==
+
+Check for cast of a pointer to wider (even unsigned) integer. This will
+sign-extend the pointer which happens on 32-bit hosts for 64-bit integers.
+The buggy behavior are 32-bit addresses printed like ``0xd56b5d60``.
+
+Casting from 32-bit ``void *`` to ``uint64_t`` requires an intermediate cast to
+``uintptr_t`` otherwise the pointer gets sign-extended:
+
+.. code-block:: c++
+
+  void *p=(void *)0x8000;
+  printf(  "%p""\n",p );//0x8000
+  printf("0x%" PRIxPTR "\n",(uintptr_t) p );//0x8000
+  printf("0x%" PRIxPTR "\n",reinterpret_cast(p));//0x8000
+^^^ recommended
+  printf("0x%" PRIx64  "\n",reinterpret_cast(p));//0x8000
+  printf("0x%" PRIx64  "\n",(uint64_t ) p );//0x8000
+  printf("0x%" PRIx64  "\n",  (uint64_t)(uintptr_t) p );//0x8000
+
+The only supported cast from a pointer to integer is ``uintptr_t``.
+
+Casting to ``int64_t`` is discouraged as it leads to the sign-extensions again.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@
   Without the null terminator it can result in undefined behaviour when the
   string is read.
 
+- New :doc:`bugprone-pointer-cast-widening
+  ` check
+
+  Check for cast of a pointer to wider (even unsigned) integer. This will
+  sign-extend the pointer which happens on 32-bit hosts for 64-bit integers.
+
 - New :doc:`cert-mem57-cpp
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
@@ -0,0 +1,42 @@
+//===--- PointerCastWideningCheck.h - clang-tidy-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WIT

[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

2019-12-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In addition to @riccibruno's comment, I found a couple of other suspicious 
things nearby (unrelated to the fix in this patch). No need to address them in 
this patch unless you feel motivated :)




Comment at: clang/lib/Sema/SemaChecking.cpp:13384
   case Stmt::MemberExprClass: {
 expr = cast(expr)->getBase();
 break;

Hmm, don't we need to do different things for dot and arrow in this case?



Comment at: clang/lib/Sema/SemaChecking.cpp:13413
 if (const Expr *lhs = cond->getLHS())
   CheckArrayAccess(lhs);
 if (const Expr *rhs = cond->getRHS())

Doesn't this need to preserve the `AllowOnePastEnd` value to avoid a false 
positive for `&(cond ? arr1[N] : arr2[N])`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71714



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


[clang] df2e2ab - Implement latest C++ feature test macro recommendations.

2019-12-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-12-19T12:59:13-08:00
New Revision: df2e2ab07b48b81fb440e3522c6e639e8ef8f2e9

URL: 
https://github.com/llvm/llvm-project/commit/df2e2ab07b48b81fb440e3522c6e639e8ef8f2e9
DIFF: 
https://github.com/llvm/llvm-project/commit/df2e2ab07b48b81fb440e3522c6e639e8ef8f2e9.diff

LOG: Implement latest C++ feature test macro recommendations.

We don't yet advertise init capture packs, because I found some bugs
while testing it. We reject-valid and then crash on both of these:

template auto x = [...y = a] {};
template auto x = [y = a...] {};

Added: 


Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Lexer/cxx-features.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 79360f89fc82..14c9ccd8a663 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -484,6 +484,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
 LangOpts.CPlusPlus2a ? "201907L" :
 LangOpts.CPlusPlus17 ? "201603L" :
 LangOpts.CPlusPlus14 ? "201304L" : "200704");
+Builder.defineMacro("__cpp_constexpr_in_decltype", "201711L");
 Builder.defineMacro("__cpp_range_based_for",
 LangOpts.CPlusPlus17 ? "201603L" : "200907");
 Builder.defineMacro("__cpp_static_assert",
@@ -506,8 +507,9 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
   if (LangOpts.CPlusPlus14) {
 Builder.defineMacro("__cpp_binary_literals", "201304L");
 Builder.defineMacro("__cpp_digit_separators", "201309L");
-Builder.defineMacro("__cpp_init_captures", "201304L");
-Builder.defineMacro("__cpp_generic_lambdas", "201304L");
+Builder.defineMacro("__cpp_init_captures", "201304L"); // (not latest)
+Builder.defineMacro("__cpp_generic_lambdas",
+LangOpts.CPlusPlus2a ? "201707L" : "201304L");
 Builder.defineMacro("__cpp_decltype_auto", "201304L");
 Builder.defineMacro("__cpp_return_type_deduction", "201304L");
 Builder.defineMacro("__cpp_aggregate_nsdmi", "201304L");
@@ -523,7 +525,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
 Builder.defineMacro("__cpp_noexcept_function_type", "201510L");
 Builder.defineMacro("__cpp_capture_star_this", "201603L");
 Builder.defineMacro("__cpp_if_constexpr", "201606L");
-Builder.defineMacro("__cpp_deduction_guides", "201703L");
+Builder.defineMacro("__cpp_deduction_guides", "201703L"); // (not latest)
 Builder.defineMacro("__cpp_template_auto", "201606L"); // (old name)
 Builder.defineMacro("__cpp_namespace_attributes", "201411L");
 Builder.defineMacro("__cpp_enumerator_attributes", "201411L");
@@ -531,7 +533,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
 Builder.defineMacro("__cpp_variadic_using", "201611L");
 Builder.defineMacro("__cpp_aggregate_bases", "201603L");
 Builder.defineMacro("__cpp_structured_bindings", "201606L");
-Builder.defineMacro("__cpp_nontype_template_args", "201411L");
+Builder.defineMacro("__cpp_nontype_template_args",
+"201411L"); // (not latest)
 Builder.defineMacro("__cpp_fold_expressions", "201603L");
 Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L");
 Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L");
@@ -543,10 +546,17 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
 
   // C++20 features.
   if (LangOpts.CPlusPlus2a) {
+//Builder.defineMacro("__cpp_aggregate_paren_init", "201902L");
+//Builder.defineMacro("__cpp_concepts", "201907L");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
+//Builder.defineMacro("__cpp_consteval", "201811L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
 Builder.defineMacro("__cpp_constinit", "201907L");
+//Builder.defineMacro("__cpp_coroutines", "201902L");
+Builder.defineMacro("__cpp_designated_initializers", "201707L");
 Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L");
+//Builder.defineMacro("__cpp_modules", "201907L");
+//Builder.defineMacro("__cpp_using_enum", "201907L");
   }
   if (LangOpts.Char8)
 Builder.defineMacro("__cpp_char8_t", "201811L");

diff  --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index 077f3155fee9..e771d891a14b 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -34,14 +34,30 @@
 #error "wrong value for __cpp_char8_t"
 #endif
 
+#if check(conditional_explicit, 0, 0, 0, 0, 201806)
+#error "wrong value for __cpp_conditional_explicit"
+#endif
+
+// constexpr checked below
+
 #if

[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Seems fine to me. @aaron.ballman, want to take a look?


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

https://reviews.llvm.org/D71619



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


[PATCH] D71725: [OpenCL] Fix inconsistency between opencl and c11 atomic fetch max/min

2019-12-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, rjmccall.
Herald added a subscriber: jfb.

There is some inconsistency between opencl and c11 atomic fetch max/min after

https://reviews.llvm.org/D46386

https://reviews.llvm.org/D55562

It is not reasonable to have such inconsistencies. This patch fixes that.


https://reviews.llvm.org/D71725

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaOpenCL/atomic-ops.cl


Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -77,8 +77,8 @@
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, 
memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, 
memory_scope_work_group);
-  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, 
memory_scope_work_group); // expected-error {{address argument to atomic 
operation must be a pointer to atomic integer or pointer ('__generic 
atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
-  __opencl_atomic_fetch_max(d, 1, memory_order_seq_cst, 
memory_scope_work_group); // expected-error {{address argument to atomic 
operation must be a pointer to atomic integer or pointer ('__generic 
atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, 
memory_scope_work_group); // expected-error {{address argument to atomic 
operation must be a pointer to atomic integer ('__generic atomic_float *' (aka 
'__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_max(d, 1, memory_order_seq_cst, 
memory_scope_work_group); // expected-error {{address argument to atomic 
operation must be a pointer to atomic integer ('__generic atomic_float *' (aka 
'__generic _Atomic(float) *') invalid)}}
 
   bool cmpexch_1 = __opencl_atomic_compare_exchange_strong(i, I, 1, 
memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
   bool cmpexch_2 = __opencl_atomic_compare_exchange_strong(p, P, 1, 
memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4642,8 +4642,6 @@
   case AtomicExpr::AO__c11_atomic_fetch_sub:
   case AtomicExpr::AO__opencl_atomic_fetch_add:
   case AtomicExpr::AO__opencl_atomic_fetch_sub:
-  case AtomicExpr::AO__opencl_atomic_fetch_min:
-  case AtomicExpr::AO__opencl_atomic_fetch_max:
   case AtomicExpr::AO__atomic_fetch_add:
   case AtomicExpr::AO__atomic_fetch_sub:
   case AtomicExpr::AO__atomic_add_fetch:
@@ -4666,6 +4664,8 @@
   case AtomicExpr::AO__atomic_nand_fetch:
   case AtomicExpr::AO__c11_atomic_fetch_min:
   case AtomicExpr::AO__c11_atomic_fetch_max:
+  case AtomicExpr::AO__opencl_atomic_fetch_min:
+  case AtomicExpr::AO__opencl_atomic_fetch_max:
   case AtomicExpr::AO__atomic_min_fetch:
   case AtomicExpr::AO__atomic_max_fetch:
   case AtomicExpr::AO__atomic_fetch_min:


Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -77,8 +77,8 @@
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
-  __opencl_atomic_fetch_max(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_max(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
 
   bool cmpexch_1 = __opencl_atomic_compare_exchange_strong(i, I, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
   bool cmpexch_2 = __opencl_atomic_compare_exchange_strong(p, P, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4642,8 +4642,6 @@
   case AtomicExpr::AO__c11_a

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2019-12-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, b-sumner.
Herald added a subscriber: jfb.

Recently atomicrmw started to support fadd/fsub:

https://reviews.llvm.org/D53965

However clang atomic builtins fetch add/sub still does not support emitting 
atomicrmw fadd/fsub.

This patch adds that.


https://reviews.llvm.org/D71726

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Sema/atomic-ops.c
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -70,7 +70,7 @@
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -166,13 +166,13 @@
 
   __c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
   __c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
-  __c11_atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
+  __c11_atomic_fetch_add(d, 1, memory_order_seq_cst);
 
-  __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer or pointer}}
+  __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer, pointer or floating point type}}
   __atomic_fetch_sub(I, 3, memory_order_seq_cst);
   __atomic_fetch_sub(P, 3, memory_order_seq_cst);
-  __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
-  __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+  __atomic_fetch_sub(D, 3, memory_order_seq_cst);
+  __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer, pointer or floating point type}}
   __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
   __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
   __atomic_fetch_max(p, 3);   // expected-error {{too few arguments to function call, expected 3, have 2}}
Index: clang/test/CodeGenOpenCL/atomic-ops.cl
===
--- clang/test/CodeGenOpenCL/atomic-ops.cl
+++ clang/test/CodeGenOpenCL/atomic-ops.cl
@@ -185,6 +185,12 @@
   return __opencl_atomic_exchange(d, 2, memory_order_seq_cst, memory_scope_work_group);
 }
 
+float ff4(global atomic_float *d, float a) {
+  // CHECK-LABEL: @ff4
+  // CHECK: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("workgroup-one-as") monotonic
+  return __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_work_group);
+}
+
 // CHECK-LABEL: @atomic_init_foo
 void atomic_init_foo()
 {
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -283,6 +283,19 @@
   return __c11_atomic_fetch_add(p, 1, memory_order_relaxed);
 }
 
+float ffp1(_Atomic(float) *p) {
+  // CHECK-LABEL: @ffp1
+  // CHECK: atomicrmw fadd {{.*}} monotonic
+  return __c11_atomic_fetch_add(p, 1.0f, memory_order_relaxed);
+}
+
+float ffp2(float *p) {
+  // CHECK-LABEL: @ffp2
+  // CHECK: atomicrmw fsub {{.*}} monotonic
+  // CHECK: fsub
+  return __atomic_sub_fetch(p, 1.0, memory_order_relaxed);
+}
+
 int *fp2a(int **p) {
   // CHECK-LABEL: @fp2a
   // CHECK: store i32 4
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4755,9 +4755,9 @@
   // For an arithmetic operation, the implied arithmetic must be well-formed.
   if (Form == Arithmetic) {
 // gcc does not enforce these rules for GNU atom

[PATCH] D71644: [clangd] Heuristically resolve dependent call through smart pointer type

2019-12-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Shopping around to other reviewers while Sam's OOO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71644



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


[clang-tools-extra] 918d393 - Fix some typos in the clang-tools-extra doc

2019-12-19 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-12-19T22:23:35+01:00
New Revision: 918d393972237fe2f9c0f4c7cd14ed4ec4ba706a

URL: 
https://github.com/llvm/llvm-project/commit/918d393972237fe2f9c0f4c7cd14ed4ec4ba706a
DIFF: 
https://github.com/llvm/llvm-project/commit/918d393972237fe2f9c0f4c7cd14ed4ec4ba706a.diff

LOG: Fix some typos in the clang-tools-extra doc

Added: 


Modified: 
clang-tools-extra/docs/clang-doc.rst
clang-tools-extra/docs/clang-include-fixer.rst
clang-tools-extra/docs/clang-tidy/checks/abseil-duration-factory-scale.rst
clang-tools-extra/docs/clang-tidy/checks/abseil-duration-subtraction.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-branch-clone.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-exception-escape.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-fold-init-type.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-unused-return-value.rst
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
clang-tools-extra/docs/clang-tidy/checks/google-runtime-int.rst
clang-tools-extra/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-deprecated-headers.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst

clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-algorithm.rst

clang-tools-extra/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
clang-tools-extra/docs/clangd/Installation.rst
clang-tools-extra/docs/pp-trace.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-doc.rst 
b/clang-tools-extra/docs/clang-doc.rst
index 0c47405fb5a9..93a6f67e2c8f 100644
--- a/clang-tools-extra/docs/clang-doc.rst
+++ b/clang-tools-extra/docs/clang-doc.rst
@@ -7,7 +7,7 @@ Clang-Doc
 .. toctree::
:maxdepth: 1
 
-:program:`clang-doc` is a tool for generating C and C++ documenation from 
+:program:`clang-doc` is a tool for generating C and C++ documentation from 
 source code and comments. 
 
 The tool is in a very early development stage, so you might encounter bugs and
@@ -100,7 +100,7 @@ Options
   generated if the file is in this dir.
 --stylesheets=  - CSS stylesheets to extend the default styles.
 
-The following flags shoud only be used if ``format`` is set to ``html``:
+The following flags should only be used if ``format`` is set to ``html``:
 - ``repository``
 - ``source-root``
 - ``stylesheets``

diff  --git a/clang-tools-extra/docs/clang-include-fixer.rst 
b/clang-tools-extra/docs/clang-include-fixer.rst
index 783f45efe5f2..b934095d8e74 100644
--- a/clang-tools-extra/docs/clang-include-fixer.rst
+++ b/clang-tools-extra/docs/clang-include-fixer.rst
@@ -105,7 +105,7 @@ Customized settings in `.vimrc`:
 
   Set to 1 if you want to insert ``#include`` for the symbol under the cursor.
   Default is 0. Compared to normal mode, this mode won't parse the source file
-  and only search the sysmbol from database, which is faster than normal mode.
+  and only search the symbol from database, which is faster than normal mode.
 
 See ``clang-include-fixer.py`` for more details.
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-factory-scale.rst 
b/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-factory-scale.rst
index 8b99d4685f3c..cba520295746 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-factory-scale.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-factory-scale.rst
@@ -5,7 +5,7 @@ abseil-duration-factory-scale
 
 Checks for cases where arguments to ``absl::Duration`` factory functions are
 scaled internally and could be changed to a 
diff erent factory function. This
-check also looks for arguements with a zero value and suggests using
+check also looks for arguments with a zero value and suggests using
 ``absl::ZeroDuration()`` instead.
 
 Examples:

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-subtraction.rst 
b/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-subtraction.rst
index b570931b92b0..3dfd32656208 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-subtraction.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-subtraction.rst
@@ -30,7 +30,7 @@ Examples:
 
 
 Note: As with other ``clang-tidy`` checks, it is possible that multiple fixes
-may overlap (as in the case of nested expressions), so not all occurences can
+may overlap (as in the case of nested expressions), so not all occurrences can
 be transformed in one run. In particular, this may occur for nested subtraction
 expressions. Running ``clang-tidy`` multiple times will find and fix these
 overlaps.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-branch-clone.rst 
b/cl

[clang-tools-extra] dac98cf - Fix the links to clang analyzers checkers

2019-12-19 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-12-19T22:31:24+01:00
New Revision: dac98cfa03e9c87a57bd47dfb9880fb01999fbff

URL: 
https://github.com/llvm/llvm-project/commit/dac98cfa03e9c87a57bd47dfb9880fb01999fbff
DIFF: 
https://github.com/llvm/llvm-project/commit/dac98cfa03e9c87a57bd47dfb9880fb01999fbff.diff

LOG: Fix the links to clang analyzers checkers

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 1bd1a55bc791..565fe7a03c09 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -109,87 +109,87 @@ Clang-Tidy Checks
cert-oop54-cpp (redirects to bugprone-unhandled-self-assignment) 

cert-oop58-cpp
cert-pos44-c (redirects to bugprone-bad-signal-to-kill-thread) 

-   clang-analyzer-core.CallAndMessage (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.DivideZero (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.CallAndMessage (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.DivideZero (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

clang-analyzer-core.DynamicTypePropagation
-   clang-analyzer-core.NonNullParamChecker (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.NullDereference (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.StackAddressEscape (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.UndefinedBinaryOperatorResult (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.VLASize (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 
-   clang-analyzer-core.uninitialized.ArraySubscript (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.uninitialized.Assign (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-core.uninitialized.Branch (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

+   clang-analyzer-core.NonNullParamChecker (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.NullDereference (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.StackAddressEscape (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.UndefinedBinaryOperatorResult (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.VLASize (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.uninitialized.ArraySubscript (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.uninitialized.Assign (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-core.uninitialized.Branch (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

clang-analyzer-core.uninitialized.CapturedBlockVariable
-   clang-analyzer-core.uninitialized.UndefReturn (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

+   clang-analyzer-core.uninitialized.UndefReturn (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

clang-analyzer-cplusplus.InnerPointer
-   clang-analyzer-cplusplus.Move (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 
-   clang-analyzer-cplusplus.NewDelete (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-cplusplus.NewDeleteLeaks (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-deadcode.DeadStores (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-nullability.NullPassedToNonnull (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-nullability.NullReturnedFromNonnull (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-nullability.NullableDereferenced (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

-   clang-analyzer-nullability.NullablePassedToNonnull (redirects to 
https://clang.llvm.org/docs/analyzer/checkers) 

+   clang-analyzer-cplusplus.Move (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-cplusplus.NewDelete (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-cplusplus.NewDeleteLeaks (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-deadcode.DeadStores (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+   clang-analyzer-nullability.NullPassedToNonnull (redirects to 
https://clang.llvm.org/docs/analyzer/checkers.html) 

+

[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder updated this revision to Diff 234777.
MadCoder added a comment.

Addressed @aprantl review feedback.


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

https://reviews.llvm.org/D71694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/direct-method.m
  clang/test/SemaObjC/method-direct-one-definition.m

Index: clang/test/SemaObjC/method-direct-one-definition.m
===
--- /dev/null
+++ clang/test/SemaObjC/method-direct-one-definition.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-protocol-method-implementation %s
+
+__attribute__((objc_root_class))
+@interface A
+@end
+
+@interface A (Cat)
+- (void)A_Cat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation A
+- (void)A_Cat { // expected-error {{direct method was declared in a category but is implemented in the primary interface}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface B
+- (void)B_primary __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B ()
+- (void)B_extension __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B (Cat)
+- (void)B_Cat __attribute__((objc_direct));
+@end
+
+@interface B (OtherCat)
+- (void)B_OtherCat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation B (Cat)
+- (void)B_primary { // expected-error {{direct method was declared in the primary interface but is implemented in a category}}
+}
+- (void)B_extension { // expected-error {{direct method was declared in an extension but is implemented in a different category}}
+}
+- (void)B_Cat {
+}
+- (void)B_OtherCat { // expected-error {{direct method was declared in a category but is implemented in a different category}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface C
+- (void)C1 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+- (void)C2;  // expected-note {{previous declaration is here}}
+@end
+
+@interface C (Cat)
+- (void)C1;  // expected-error {{method declaration conflicts with previous direct declaration of method 'C1'}}
+- (void)C2 __attribute__((objc_direct)); // expected-error {{direct method declaration conflicts with previous declaration of method 'C2'}}
+@end
Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -172,10 +172,19 @@
 @interface Foo ()
 @property(nonatomic, readwrite) int getDirect_setDynamic;
 @property(nonatomic, readwrite, direct) int getDynamic_setDirect;
+- (int)directMethodInExtension __attribute__((objc_direct));
+@end
+
+@interface Foo (Cat)
+- (int)directMethodInCategory __attribute__((objc_direct));
 @end
 
 __attribute__((objc_direct_members))
 @implementation Foo
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]"(
+- (int)directMethodInExtension {
+  return 42;
+}
 // CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]"(
 // CHECK-LABEL: define internal void @"\01-[Foo setGetDirect_setDynamic:]"(
 // CHECK-LABEL: define internal i32 @"\01-[Foo getDynamic_setDirect]"(
@@ -183,6 +192,17 @@
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
 
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMethodInCategory {
+  return 42;
+}
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategoryNoDecl]"(
+- (int)directMethodInCategoryNoDecl __attribute__((objc_direct)) {
+  return 42;
+}
+@end
+
 int useRoot(Root *r) {
   // CHECK-LABEL: define i32 @useRoot
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Root getInt]"
@@ -195,8 +215,14 @@
   // CHECK-LABEL: define i32 @useFoo
   // CHECK: call void bitcast {{.*}} @"\01-[Foo setGetDynamic_setDirect:]"
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo getDirect_setDynamic]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo directMethodInExtension]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo(Cat) directMethodInCategory]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo(Cat) directMethodInCategoryNoDecl]"
   [f setGetDynamic_setDirect:1];
-  return [f getDirect_setDynamic];
+  return [f getDirect_setDynamic] +
+ [f directMethodInExtension] +
+ [f directMethodInCategory] +
+ [f directMethodInCategoryNoDecl];
 }
 
 __attribute__((objc_root_class))
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -4508,12 +4508,6 @@
 

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
+
+  Check for cast of a pointer to wider (even unsigned) integer. This will
+  sign-extend the pointer which happens on 32-bit hosts for 64-bit integers.

Checks. One sentence should be enough.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:5
+
+void test(void) {
+  void *p = 0;

void is unnecessary. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder updated this revision to Diff 234778.
MadCoder added a comment.

I had forgotten to clang format and left some tabs here... some day I'll fix my 
vim config


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

https://reviews.llvm.org/D71694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/direct-method.m
  clang/test/SemaObjC/method-direct-one-definition.m

Index: clang/test/SemaObjC/method-direct-one-definition.m
===
--- /dev/null
+++ clang/test/SemaObjC/method-direct-one-definition.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-protocol-method-implementation %s
+
+__attribute__((objc_root_class))
+@interface A
+@end
+
+@interface A (Cat)
+- (void)A_Cat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation A
+- (void)A_Cat { // expected-error {{direct method was declared in a category but is implemented in the primary interface}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface B
+- (void)B_primary __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B ()
+- (void)B_extension __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B (Cat)
+- (void)B_Cat __attribute__((objc_direct));
+@end
+
+@interface B (OtherCat)
+- (void)B_OtherCat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation B (Cat)
+- (void)B_primary { // expected-error {{direct method was declared in the primary interface but is implemented in a category}}
+}
+- (void)B_extension { // expected-error {{direct method was declared in an extension but is implemented in a different category}}
+}
+- (void)B_Cat {
+}
+- (void)B_OtherCat { // expected-error {{direct method was declared in a category but is implemented in a different category}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface C
+- (void)C1 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+- (void)C2;  // expected-note {{previous declaration is here}}
+@end
+
+@interface C (Cat)
+- (void)C1;  // expected-error {{method declaration conflicts with previous direct declaration of method 'C1'}}
+- (void)C2 __attribute__((objc_direct)); // expected-error {{direct method declaration conflicts with previous declaration of method 'C2'}}
+@end
Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -172,10 +172,19 @@
 @interface Foo ()
 @property(nonatomic, readwrite) int getDirect_setDynamic;
 @property(nonatomic, readwrite, direct) int getDynamic_setDirect;
+- (int)directMethodInExtension __attribute__((objc_direct));
+@end
+
+@interface Foo (Cat)
+- (int)directMethodInCategory __attribute__((objc_direct));
 @end
 
 __attribute__((objc_direct_members))
 @implementation Foo
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]"(
+- (int)directMethodInExtension {
+  return 42;
+}
 // CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]"(
 // CHECK-LABEL: define internal void @"\01-[Foo setGetDirect_setDynamic:]"(
 // CHECK-LABEL: define internal i32 @"\01-[Foo getDynamic_setDirect]"(
@@ -183,6 +192,17 @@
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
 
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMethodInCategory {
+  return 42;
+}
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategoryNoDecl]"(
+- (int)directMethodInCategoryNoDecl __attribute__((objc_direct)) {
+  return 42;
+}
+@end
+
 int useRoot(Root *r) {
   // CHECK-LABEL: define i32 @useRoot
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Root getInt]"
@@ -195,8 +215,14 @@
   // CHECK-LABEL: define i32 @useFoo
   // CHECK: call void bitcast {{.*}} @"\01-[Foo setGetDynamic_setDirect:]"
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo getDirect_setDynamic]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo directMethodInExtension]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo(Cat) directMethodInCategory]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo(Cat) directMethodInCategoryNoDecl]"
   [f setGetDynamic_setDirect:1];
-  return [f getDirect_setDynamic];
+  return [f getDirect_setDynamic] +
+ [f directMethodInExtension] +
+ [f directMethodInCategory] +
+ [f directMethodInCategoryNoDecl];
 }
 
 __attribute__((objc_root_class))
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ 

[PATCH] D71718: [X86] Mark various pointer arguments in builtins as const

2019-12-19 Thread Warren Ristow via Phabricator via cfe-commits
wristow added a comment.

Thanks for the quick review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71718



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


[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

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

LGTM!




Comment at: clang/test/AST/pr43983.cpp:1
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+

You can drop the `-std=c++11` here (we default to > c++11 anyway).


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

https://reviews.llvm.org/D71619



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


[PATCH] D71727: [clang][Tooling] Prefer -x over -std when interpolating

2019-12-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, ilya-biryukov.
Herald added a project: clang.

Currently interpolation logic prefers -std over -x. But the latter is a
more strong signal, so this patch inverts the order and only makes use of -std
if -x didn't exist.

Fixes https://github.com/clangd/clangd/issues/185

Thanks @sammccall for tracking this down!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71727

Files:
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -749,6 +749,7 @@
   add("dir/foo.cpp", "-std=c++17");
   add("dir/bar.c", "");
   add("dir/baz.cee", "-x c");
+  add("dir/aux.cpp", "-std=c++17 -x objective-c++");
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
@@ -767,6 +768,9 @@
   Entries.erase(path(StringRef("dir/bar.c")));
   // Now we transfer across languages, so drop -std too.
   EXPECT_EQ(getCommand("foo.c"), "clang -D dir/foo.cpp");
+  // Prefer -x over -std when overriding language.
+  EXPECT_EQ(getCommand("aux.h"),
+"clang -D dir/aux.cpp -x objective-c++-header -std=c++17");
 }
 
 TEST_F(InterpolateTest, Strip) {
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,7 +191,8 @@
  OldArgs.data() + OldPos, OldArgs.data() + Pos);
 }
 
-if (Std != LangStandard::lang_unspecified) // -std take precedence over -x
+// Make use of -std iff -x was missing.
+if (Type == types::TY_INVALID && Std != LangStandard::lang_unspecified)
   Type = toType(LangStandard::getLangStandardForKind(Std).getLanguage());
 Type = foldType(*Type);
 // The contract is to store None instead of TY_INVALID.


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -749,6 +749,7 @@
   add("dir/foo.cpp", "-std=c++17");
   add("dir/bar.c", "");
   add("dir/baz.cee", "-x c");
+  add("dir/aux.cpp", "-std=c++17 -x objective-c++");
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
@@ -767,6 +768,9 @@
   Entries.erase(path(StringRef("dir/bar.c")));
   // Now we transfer across languages, so drop -std too.
   EXPECT_EQ(getCommand("foo.c"), "clang -D dir/foo.cpp");
+  // Prefer -x over -std when overriding language.
+  EXPECT_EQ(getCommand("aux.h"),
+"clang -D dir/aux.cpp -x objective-c++-header -std=c++17");
 }
 
 TEST_F(InterpolateTest, Strip) {
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,7 +191,8 @@
  OldArgs.data() + OldPos, OldArgs.data() + Pos);
 }
 
-if (Std != LangStandard::lang_unspecified) // -std take precedence over -x
+// Make use of -std iff -x was missing.
+if (Type == types::TY_INVALID && Std != LangStandard::lang_unspecified)
   Type = toType(LangStandard::getLangStandardForKind(Std).getLanguage());
 Type = foldType(*Type);
 // The contract is to store None instead of TY_INVALID.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D71080



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


[PATCH] D71221: [HIP] Add option --gpu-max-threads-per-block=n

2019-12-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D71221



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


[clang] 85cb560 - ConstrainedFP: use API compatible with opaque pointers.

2019-12-19 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-12-19T21:50:47Z
New Revision: 85cb560b8a421d950ccea593b4ee0569249dc136

URL: 
https://github.com/llvm/llvm-project/commit/85cb560b8a421d950ccea593b4ee0569249dc136
DIFF: 
https://github.com/llvm/llvm-project/commit/85cb560b8a421d950ccea593b4ee0569249dc136.diff

LOG: ConstrainedFP: use API compatible with opaque pointers.

This just updates an IRBuilder interface to take Functions instead of
Values so the type can be derived, and fixes some callsites in Clang to
call the updated API.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 37aca09bff5b..3b35fc23a1b9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -368,10 +368,10 @@ static Value 
*emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, Src0);
   }
 }
@@ -385,10 +385,10 @@ static Value 
*emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, { Src0, Src1 });
   }
 }
@@ -403,10 +403,10 @@ static Value 
*emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
 }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 5d5f12d2c7c6..1abdf2242b58 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -2421,18 +2421,16 @@ class IRBuilder : public IRBuilderBase, public Inserter 
{
 Args, OpBundles, Name, FPMathTag);
   }
 
-  // Deprecated [opaque pointer types]
   CallInst *CreateConstrainedFPCall(
-  Value *Callee, ArrayRef Args, const Twine &Name = "",
+  Function *Callee, ArrayRef Args, const Twine &Name = "",
   Optional Rounding = None,
   Optional Except = None) {
 llvm::SmallVector UseArgs;
 
 for (auto *OneArg : Args)
   UseArgs.push_back(OneArg);
-Function *F = cast(Callee);
 bool HasRoundingMD = false;
-switch (F->getIntrinsicID()) {
+switch (Callee->getIntrinsicID()) {
 default:
   break;
 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)  \
@@ -2445,9 +2443,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
   UseArgs.push_back(getConstrainedFPRounding(Rounding));
 UseArgs.push_back(getConstrainedFPExcept(Except));
 
-CallInst *C = CreateCall(
-cast(Callee->getType()->getPointerElementType()), Callee,
-UseArgs, Name);
+CallInst *C = CreateCall(Callee, UseArgs, Name);
 setConstrainedFPCallAttr(C);
 return C;
   }



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


[PATCH] D71723: ConstrainedFP: use API compatible with opaque pointers.

2019-12-19 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover closed this revision.
t.p.northover added a comment.

Thanks Kevin. Committed as 85cb560b8a4 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71723



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


[PATCH] D71727: [clang][Tooling] Prefer -x over -std when interpolating

2019-12-19 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61035 tests passed, 0 failed 
and 728 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71727



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a subscriber: teemperor.
aprantl added inline comments.



Comment at: clang/test/CodeGenObjC/direct-method.m:196
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMethodInCategory {

MadCoder wrote:
> this may be questionable as a chosen mangling. it's exactly what dynamic 
> dispatch does, but because a direct method cannot have clashes on the same 
> class, this extra namespacing is not useful and is likely making the life of 
> debuggers harder for expression evaluation.
> 
> @aprantl should I generate `@"\01-[Foo directMethodInCategory]"` instead? if 
> yes I'd rather do it in this review
@teemperor implemented the LLDB support. I would assume that changing it to Foo 
without the category will be necessary for LLDB to find it. @teemperor Can you 
add an LLDB test for this scenario?


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

https://reviews.llvm.org/D71694



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


[PATCH] D71221: [HIP] Add option --gpu-max-threads-per-block=n

2019-12-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

What's the use case for this flag?




Comment at: clang/lib/CodeGen/TargetInfo.cpp:8067
+unsigned MaxThreadsPerBlock =
+IsHIPKernel ? M.getLangOpts().GPUMaxThreadsPerBlock : 256;
+std::string AttrVal = std::string("1,") + llvm::utostr(MaxThreadsPerBlock);

The magic value of 256 should be defined as a constant or macro somewhere -- 
you're using it in multiple places.
Alternatively, always set LangOpts.GPUMaxThreadsPerBlock to something and skip 
figuring out the default everywhere else.



Comment at: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu:19
+
 __attribute__((amdgpu_flat_work_group_size(32, 64))) // expected-no-diagnostics
 __global__ void flat_work_group_size_32_64() {

Is this the attribute that `__launch_bounds__()` expands to in HIP?
If __launch_bounds__ is a separate attribute, then, I guess, it should be 
tested, too.


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

https://reviews.llvm.org/D71221



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-19 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder marked an inline comment as done.
MadCoder added inline comments.



Comment at: clang/test/CodeGenObjC/direct-method.m:196
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo(Cat) directMethodInCategory]"(
+- (int)directMethodInCategory {

aprantl wrote:
> MadCoder wrote:
> > this may be questionable as a chosen mangling. it's exactly what dynamic 
> > dispatch does, but because a direct method cannot have clashes on the same 
> > class, this extra namespacing is not useful and is likely making the life 
> > of debuggers harder for expression evaluation.
> > 
> > @aprantl should I generate `@"\01-[Foo directMethodInCategory]"` instead? 
> > if yes I'd rather do it in this review
> @teemperor implemented the LLDB support. I would assume that changing it to 
> Foo without the category will be necessary for LLDB to find it. @teemperor 
> Can you add an LLDB test for this scenario?
that was my expectation as well, let me update the code to do so then :)


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

https://reviews.llvm.org/D71694



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


[PATCH] D71475: [WIP][OPENMP] Try to fix linear clause crash by emitting alloca for step

2019-12-19 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In D71475#1788187 , @ABataev wrote:

> The fixed patch. Several codegen tests require some adjustment.


@Abataev, thanks for the reply. However, for adjusting the codegen, I found it 
really hard to update the tests by reading the diagnostic message. Can I 
refactor the test a bit (like separate each openmp portion to be CK1, CK2...) 
so that I can modify the test easier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71475



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


[PATCH] D71533: [clangd] Show template arguments in type hierarchy when possible

2019-12-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 234784.
nridge marked 4 inline comments as done.
nridge added a comment.

Address most review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71533

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -409,17 +409,13 @@
   ASSERT_TRUE(!AST.getDiagnostics().empty());
 
   // Make sure getTypeHierarchy() doesn't get into an infinite recursion.
-  // FIXME(nridge): It would be preferable if the type hierarchy gave us type
-  // names (e.g. "S<0>" for the child and "S<1>" for the parent) rather than
-  // template names (e.g. "S").
+  // Here, we actually don't get any parents, because the unbounded hierarchy
+  // causes instantiation of the base specifier to fail.
   llvm::Optional Result = getTypeHierarchy(
   AST, Source.points()[0], 0, TypeHierarchyDirection::Parents);
   ASSERT_TRUE(bool(Result));
-  EXPECT_THAT(
-  *Result,
-  AllOf(WithName("S"), WithKind(SymbolKind::Struct),
-Parents(AllOf(WithName("S"), WithKind(SymbolKind::Struct),
-  SelectionRangeIs(Source.range("SDef")), Parents();
+  EXPECT_THAT(*Result,
+  AllOf(WithName("S<0>"), WithKind(SymbolKind::Struct), Parents()));
 }
 
 TEST(TypeHierarchy, RecursiveHierarchyBounded) {
@@ -449,9 +445,12 @@
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("S"), WithKind(SymbolKind::Struct),
-Parents(AllOf(WithName("S"), WithKind(SymbolKind::Struct),
-  SelectionRangeIs(Source.range("SDef")), Parents();
+  AllOf(WithName("S<2>"), WithKind(SymbolKind::Struct),
+Parents(AllOf(
+WithName("S<1>"), WithKind(SymbolKind::Struct),
+SelectionRangeIs(Source.range("SDef")),
+Parents(AllOf(WithName("S<0>"), WithKind(SymbolKind::Struct),
+  Parents()));
   Result = getTypeHierarchy(AST, Source.point("SRefDependent"), 0,
 TypeHierarchyDirection::Parents);
   ASSERT_TRUE(bool(Result));
@@ -462,6 +461,83 @@
   SelectionRangeIs(Source.range("SDef")), Parents();
 }
 
+TEST(TypeHierarchy, DeriveFromImplicitSpec) {
+  Annotations Source(R"cpp(
+  template 
+  struct Parent {};
+
+  struct Child : Parent {};
+
+  Parent Fo^o;
+  )cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  ASSERT_TRUE(AST.getDiagnostics().empty());
+
+  llvm::Optional Result = getTypeHierarchy(
+  AST, Source.points()[0], 2, TypeHierarchyDirection::Children, Index.get(),
+  testPath(TU.Filename));
+  ASSERT_TRUE(bool(Result));
+  EXPECT_THAT(*Result,
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+Children(AllOf(WithName("Child"),
+   WithKind(SymbolKind::Struct), Children();
+}
+
+TEST(TypeHierarchy, DeriveFromPartialSpec) {
+  Annotations Source(R"cpp(
+  template  struct Parent {};
+  template  struct Parent {};
+
+  struct Child : Parent {};
+
+  Parent Fo^o;
+  )cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  ASSERT_TRUE(AST.getDiagnostics().empty());
+
+  llvm::Optional Result = getTypeHierarchy(
+  AST, Source.points()[0], 2, TypeHierarchyDirection::Children, Index.get(),
+  testPath(TU.Filename));
+  ASSERT_TRUE(bool(Result));
+  EXPECT_THAT(*Result, AllOf(WithName("Parent"),
+ WithKind(SymbolKind::Struct), Children()));
+}
+
+TEST(TypeHierarchy, DeriveFromTemplate) {
+  Annotations Source(R"cpp(
+  template 
+  struct Parent {};
+
+  template 
+  struct Child : Parent {};
+
+  Parent Fo^o;
+  )cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  ASSERT_TRUE(AST.getDiagnostics().empty());
+
+  // FIXME: We'd like this to return the implicit specialization Child,
+  //but currently libIndex does not expose relationships between
+  //implicit specializations.
+  llvm::Optional Result = getTypeHierarchy(
+  AST, Source.points()[0], 2, TypeHierarchyDirection::Children, Index.get(),
+  testPath(TU.Filename));
+  ASSERT_TRUE(bool(Result));
+  EXPECT_THAT(*Result,
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+Children(AllOf(WithName("Child"),
+   WithKind(SymbolKind::Struct), Children();
+}
+
 SymbolID findSymbolIDByName(SymbolIndex *Index, llvm::StringRef Name,
   

[PATCH] D71533: [clangd] Show template arguments in type hierarchy when possible

2019-12-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp:418
+  EXPECT_THAT(*Result,
+  AllOf(WithName("S<0>"), WithKind(SymbolKind::Struct), 
Parents()));
 }

kadircet wrote:
> what about making use of template pattern in case of invalid instantiations?
> 
> as type hierarchy tries to provide information regarding `bases` and 
> `children`, I think it is more important to show those instead of template 
> instantiation arguments.
Is there a way to query a `ClassTemplateSpecializationDecl` for whether 
instantiating its base specifier failed?

Or, should we fall back on the template pattern any time `bases()` is empty?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71533



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


[PATCH] D71728: [analyzer] Add a syntactic security check for ObjC NSCoder API.

2019-12-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Method `-[NSCoder decodeValueOfObjCType:at:]` is not only deprecated but also a 
security hazard, hence a loud check.


Repository:
  rC Clang

https://reviews.llvm.org/D71728

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/test/Analysis/security-syntax-checks-nscoder.m
  clang/www/analyzer/available_checks.html

Index: clang/www/analyzer/available_checks.html
===
--- clang/www/analyzer/available_checks.html
+++ clang/www/analyzer/available_checks.html
@@ -1446,6 +1446,22 @@
 }
 
 
+
+
+security.insecureAPI.decodeValueOfObjCType
+(ObjC)
+Warn on uses of the -[NSCoder decodeValueOfObjCType:at:] method.
+The safe alternative is -[NSCoder decodeValueOfObjCType:at:size:].
+
+
+void test(NSCoder *decoder) {
+  // This would be a vulnerability on 64-bit platforms
+  // but not on 32-bit platforms.
+  NSUInteger x;
+  [decoder decodeValueOfObjCType:"I" at:&x]; // warn
+}
+
+
 
 
 
Index: clang/test/Analysis/security-syntax-checks-nscoder.m
===
--- /dev/null
+++ clang/test/Analysis/security-syntax-checks-nscoder.m
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin12 -verify %s\
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType
+
+typedef unsigned long NSUInteger;
+
+@interface NSCoder
+- (void)decodeValueOfObjCType:(const char *)type
+   at:(void *)data;
+- (void)decodeValueOfObjCType:(const char *)type
+   at:(void *)data
+ size:(NSUInteger)size;
+@end
+
+void test(NSCoder *decoder) {
+  // This would be a vulnerability on 64-bit platforms
+  // but not on 32-bit platforms.
+  NSUInteger x;
+  [decoder decodeValueOfObjCType:"I" at:&x]; // expected-warning{{Deprecated method '-decodeValueOfObjCType:at:' is insecure as it can lead to potential buffer overflows. Use the safer '-decodeValueOfObjCType:at:size:' method}}
+  [decoder decodeValueOfObjCType:"I" at:&x size:sizeof(x)]; // no-warning
+}
Index: clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -49,6 +49,7 @@
   DefaultBool check_vfork;
   DefaultBool check_FloatLoopCounter;
   DefaultBool check_UncheckedReturn;
+  DefaultBool check_decodeValueOfObjCType;
 
   CheckerNameRef checkName_bcmp;
   CheckerNameRef checkName_bcopy;
@@ -63,6 +64,7 @@
   CheckerNameRef checkName_vfork;
   CheckerNameRef checkName_FloatLoopCounter;
   CheckerNameRef checkName_UncheckedReturn;
+  CheckerNameRef checkName_decodeValueOfObjCType;
 };
 
 class WalkAST : public StmtVisitor {
@@ -83,6 +85,7 @@
 
   // Statement visitor methods.
   void VisitCallExpr(CallExpr *CE);
+  void VisitObjCMessageExpr(ObjCMessageExpr *CE);
   void VisitForStmt(ForStmt *S);
   void VisitCompoundStmt (CompoundStmt *S);
   void VisitStmt(Stmt *S) { VisitChildren(S); }
@@ -93,6 +96,7 @@
   bool checkCall_strCommon(const CallExpr *CE, const FunctionDecl *FD);
 
   typedef void (WalkAST::*FnCheck)(const CallExpr *, const FunctionDecl *);
+  typedef void (WalkAST::*MsgCheck)(const ObjCMessageExpr *);
 
   // Checker-specific methods.
   void checkLoopConditionForFloat(const ForStmt *FS);
@@ -110,6 +114,7 @@
   void checkCall_rand(const CallExpr *CE, const FunctionDecl *FD);
   void checkCall_random(const CallExpr *CE, const FunctionDecl *FD);
   void checkCall_vfork(const CallExpr *CE, const FunctionDecl *FD);
+  void checkMsg_decodeValueOfObjCType(const ObjCMessageExpr *ME);
   void checkUncheckedReturnValue(CallExpr *CE);
 };
 } // end anonymous namespace
@@ -182,6 +187,20 @@
   VisitChildren(CE);
 }
 
+void WalkAST::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
+  MsgCheck evalFunction =
+  llvm::StringSwitch(ME->getSelector().getAsString())
+  .Case("decodeValueOfObjCType:at:",
+&WalkAST::checkMsg_decodeValueOfObjCType)
+  .Default(nullptr);
+
+  if (evalFunction)
+(this->*evalFunction)(ME);
+
+  // Recurse and check children.
+  VisitChildren(ME);
+}
+
 void WalkAST::VisitCompoundStmt(CompoundStmt *S) {
   for (Stmt *Child : S->children())
 if (Child) {
@@ -923,6 +942,27 @@
  CELoc, CE->getCallee()->getSourceRange());
 }
 
+//===--===//
+// Check: '-decodeValueOfObjCType:at:' should not be used.
+// It is deprecated in favor of '-decodeValueOfObjCType:at:size:' 

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil updated this revision to Diff 234787.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s bugprone-pointer-cast-widening %t
+
+#include 
+
+void test() {
+  void *p = 0;
+  uint64_t u64 = (uint64_t)p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  uint64_t u64r = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  intptr_t ip = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend [bugprone-pointer-cast-widening]
+  uintptr_t up = (uintptr_t)p;
+  typedef uintptr_t t1;
+  typedef t1 t2;
+  t2 t = (t2)p;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -62,6 +62,7 @@
bugprone-multiple-statement-macro
bugprone-not-null-terminated-result
bugprone-parent-virtual-call
+   bugprone-pointer-cast-widening
bugprone-posix-return
bugprone-sizeof-container
bugprone-sizeof-expression
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - bugprone-pointer-cast-widening
+
+bugprone-pointer-cast-widening
+==
+
+Checks for cast of a pointer to wider (even unsigned) integer as it
+sign-extends the pointer which happens on 32-bit hosts for 64-bit integers.
+The buggy behavior are 32-bit addresses printed like ``0xd56b5d60``.
+
+Casting from 32-bit ``void *`` to ``uint64_t`` requires an intermediate cast to
+``uintptr_t`` otherwise the pointer gets sign-extended:
+
+.. code-block:: c++
+
+  void *p=(void *)0x8000;
+  printf(  "%p""\n",p );//0x8000
+  printf("0x%" PRIxPTR "\n",(uintptr_t) p );//0x8000
+  printf("0x%" PRIxPTR "\n",reinterpret_cast(p));//0x8000
+  //^^^ recommended
+  printf("0x%" PRIx64  "\n",reinterpret_cast(p));//0x8000
+  printf("0x%" PRIx64  "\n",(uint64_t ) p );//0x8000
+  printf("0x%" PRIx64  "\n",  (uint64_t)(uintptr_t) p );//0x8000
+
+The only supported cast from a pointer to integer is ``uintptr_t``.
+
+Casting to ``int64_t`` is discouraged as it leads to the sign-extensions again.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@
   Without the null terminator it can result in undefined behaviour when the
   string is read.
 
+- New :doc:`bugprone-pointer-cast-widening
+  ` check
+
+  Checks for cast of a pointer to wider (even unsigned) integer as it
+  sign-extends the pointer which happens on 32-bit hosts for 64-bit integers.
+
 - New :doc:`cert-mem57-cpp
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
@@ -0,0 +1,32 @@
+//===--- PointerCastWideningCheck.h - clang-tidy-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef L

[PATCH] D71728: [analyzer] Add a syntactic security check for ObjC NSCoder API.

2019-12-19 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me, but I think we need a deployment target check on the 
diagnostic since the safe API is only available in iOS 11+, macOS 10.13+, tvOS 
11+, and watchOS 4.0+. If the deployment target is early than those versions 
then we should not diagnose.


Repository:
  rC Clang

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

https://reviews.llvm.org/D71728



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


[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-19 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil marked 3 inline comments as done.
jankratochvil added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
+
+  Check for cast of a pointer to wider (even unsigned) integer. This will
+  sign-extend the pointer which happens on 32-bit hosts for 64-bit integers.

Eugene.Zelenko wrote:
> Checks. One sentence should be enough.
Not sure if the wording is OK in such a long sentence (non-native English here).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


LLVM lab network works today

2019-12-19 Thread Galina Kistanova via cfe-commits
Hello All,

LLVM master will be unavailable Thursday, December 19th at 5:30 pm PST due
to network maintenance.
The planned maintenance duration is 20 minutes but will be performed as
soon as possible.

Thanks

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


[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

2019-12-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Summary of an off-line discussion with Ilya:

- The current situation where Clang can do delayed typo correction for C++ but 
not for C is not a good long-term position. The reason for that situation is 
that we use a dependent type to represent a type with errors. There are two 
natural paths out of this situation: (1) use something other than a dependent 
type, such as an error type, for this purpose, and (2) support dependence in C. 
Of these, (1) is pretty much strictly more expensive than (2): whatever work we 
need to do for the C-only parts of Clang in (2), we will need to do the same 
work in the C-only parts of Clang for (1), and much more work in addition. It's 
also worth noting that we will in fact want all the different flavors of 
dependence for error tracking too: we will ideally want to distinguish between 
"this expression can't be evaluated because its value depends on an error" and 
"this expression doesn't have a meaningful type because its type depends on an 
error". Conclusions: **1. we should support delayed typo-correction in C by 
supporting dependence in C**, and **2. we should generalize what we mean by 
"dependent" to mean "depends on a template parameter or an error**.
- Computing 4 (with this patch, 5) bits of status summarizing properties of 
subexpressions is highly undesirable: it's error-prone, repetitive, and 
expensive. It would be better if we packed these five bits into an enum and had 
a single consistent mechanism for computing them based on the corresponding 
properties of subexpressions, and if we had some way to do that that didn't 
require complexity in every constructor for every AST node. (We could, for 
example, set the bits from the `FooExpr::Create` functions by calling one 
centralized function that walks the children and accumulates properties from 
them -- with all exceptions to that general pattern in a single place.) 
Conclusions: **3. it's time to refactor these bits; the proof that we've done 
this right will be that adding the fifth such bit is easy**.
- A transitive "does this or anything within it contain errors" flag has value. 
It may not be exactly the right information for any particular query, but 
finer-grained information (eg, "do we know the type of this expression?") can 
be obtained using the various dependence bits. Example: this bit lets us 
determine whether dependence means "depends on a template parameter" (bit is 
false) or whether it means "don't know what this depends on, suppress follow-on 
errors" (bit is true). Eg, we could stop producing a bogus diagnostic for a 
missing `template` keyword in `typo.function()`. Example: this bit will 
permit us to distinguish between "function has a body and as far as we know 
it's valid" and "function has a body that contained errors", and suppress 
errors for (eg) missing return statements in a constexpr function, and likewise 
suppress control-flow-based warnings on function granularity rather than 
whole-compilation granularity. (These examples are all cases where we have a 
significant diagnostic quality problem today.)

Here's the plan we came up with:

1. (Notionally) generalize what we mean by "dependent" to mean "depends on a 
template parameter or on an error".
2. Refactor and centralize the computation and propagation of the dependence 
and "contains pack" bits.
3. Add the `containsErrors` bit (after (2) this should be easy) to all 
statements (not only expressions)
4. (Asynchronously) add support for dependent constructs to Clang's C-only 
codepaths and start doing delayed typo-correction (and preserving invalid 
subexpressions) even in C.

@ilya-biryukov Did I forget anything?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591



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


[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-19 Thread Philip Reames via Phabricator via cfe-commits
reames accepted this revision.
reames added a comment.

LGTM.  The patch isn't perfect, but this has reached the point where landing 
and iterating in tree is the fastest way to convergence.  To be clear, this 
LGTM *only* applies to the current patch contents, and the *internal only* flag 
names this introduces.  These may change before we expose this publicly.

Warts with the current patch we should iterate to address:

- Stylistic issues w.r.t. comments, naming, static vs member functions remain.  
None are show stoppers.
- Many of the tests can probably be simplified and condensed.
- The bundling scheme used is probably more complicated than needed (see 
previous suggestions).
- This patch doesn't include anyway to locally disable padding, and thus is 
*known incorrect* in some cases.  As this remains off by default, this is not a 
blocker for commit.

p.s. I spoke w/James this morning, and we came up with some revisions in 
approach he's going to suggest separately.  We did explicitly discuss the 
status of the current patch, and whether it needed further review cycles or 
could be iterated in tree.  Normally, I'd wait for him to summarize that 
conversation publicly, but given the time delay and vacation schedules 
involved, I want to avoid loosing another day cycle.




Comment at: llvm/include/llvm/MC/MCFragment.h:570
+private:
+  /// The size of the MCBoundaryAlignFragment.
+  uint64_t Size = 0;

Please add a note that the size is lazily set during relaxation, and is not 
meaningful before that.  



Comment at: llvm/test/MC/X86/align-branch-32-1a.s:34
+foo:
+  movl  %eax, %fs:0x1
+  pushl  %ebp

For testing alignment functionality, we can probably use a repl int3 pattern 
here.  It would make the tests much more concise, and shouldn't effect the 
logic being (currently) tested.  



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

https://reviews.llvm.org/D70157



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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2019-12-19 Thread JF Bastien via Phabricator via cfe-commits
jfb added subscribers: ldionne, EricWF, mclow.lists.
jfb added a comment.

This generally seems fine. Does it work on most backends? I want to make sure 
it doesn't fail in backends :)

Also, @ldionne / @EricWF / @mclow.lists do you need this in libc++ for 
floating-point atomic support?


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

https://reviews.llvm.org/D71726



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


[clang] b284005 - [analyzer] Add a syntactic security check for ObjC NSCoder API.

2019-12-19 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-19T14:54:29-08:00
New Revision: b284005072122fe4af879725e3c8090009f89ca0

URL: 
https://github.com/llvm/llvm-project/commit/b284005072122fe4af879725e3c8090009f89ca0
DIFF: 
https://github.com/llvm/llvm-project/commit/b284005072122fe4af879725e3c8090009f89ca0.diff

LOG: [analyzer] Add a syntactic security check for ObjC NSCoder API.

Method '-[NSCoder decodeValueOfObjCType:at:]' is not only deprecated
but also a security hazard, hence a loud check.

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

Added: 
clang/test/Analysis/security-syntax-checks-nscoder.m

Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
clang/www/analyzer/available_checks.html

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 43632e801d2b..5b23de418999 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -773,6 +773,11 @@ def DeprecatedOrUnsafeBufferHandling :
   Dependencies<[SecuritySyntaxChecker]>,
   Documentation;
 
+def decodeValueOfObjCType : Checker<"decodeValueOfObjCType">,
+  HelpText<"Warn on uses of the '-decodeValueOfObjCType:at:' method">,
+  Dependencies<[SecuritySyntaxChecker]>,
+  Documentation;
+
 } // end "security.insecureAPI"
 
 let ParentPackage = Security in {

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6b93dc2939e1..1347c3de913e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2789,8 +2789,11 @@ static void RenderAnalyzerOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
   CmdArgs.push_back("-analyzer-disable-checker=unix.Vfork");
 }
 
-if (Triple.isOSDarwin())
+if (Triple.isOSDarwin()) {
   CmdArgs.push_back("-analyzer-checker=osx");
+  CmdArgs.push_back(
+  "-analyzer-checker=security.insecureAPI.decodeValueOfObjCType");
+}
 
 CmdArgs.push_back("-analyzer-checker=deadcode");
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
index 260a2896e78c..d9ffa562c0aa 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -49,6 +49,7 @@ struct ChecksFilter {
   DefaultBool check_vfork;
   DefaultBool check_FloatLoopCounter;
   DefaultBool check_UncheckedReturn;
+  DefaultBool check_decodeValueOfObjCType;
 
   CheckerNameRef checkName_bcmp;
   CheckerNameRef checkName_bcopy;
@@ -63,6 +64,7 @@ struct ChecksFilter {
   CheckerNameRef checkName_vfork;
   CheckerNameRef checkName_FloatLoopCounter;
   CheckerNameRef checkName_UncheckedReturn;
+  CheckerNameRef checkName_decodeValueOfObjCType;
 };
 
 class WalkAST : public StmtVisitor {
@@ -83,6 +85,7 @@ class WalkAST : public StmtVisitor {
 
   // Statement visitor methods.
   void VisitCallExpr(CallExpr *CE);
+  void VisitObjCMessageExpr(ObjCMessageExpr *CE);
   void VisitForStmt(ForStmt *S);
   void VisitCompoundStmt (CompoundStmt *S);
   void VisitStmt(Stmt *S) { VisitChildren(S); }
@@ -93,6 +96,7 @@ class WalkAST : public StmtVisitor {
   bool checkCall_strCommon(const CallExpr *CE, const FunctionDecl *FD);
 
   typedef void (WalkAST::*FnCheck)(const CallExpr *, const FunctionDecl *);
+  typedef void (WalkAST::*MsgCheck)(const ObjCMessageExpr *);
 
   // Checker-specific methods.
   void checkLoopConditionForFloat(const ForStmt *FS);
@@ -110,6 +114,7 @@ class WalkAST : public StmtVisitor {
   void checkCall_rand(const CallExpr *CE, const FunctionDecl *FD);
   void checkCall_random(const CallExpr *CE, const FunctionDecl *FD);
   void checkCall_vfork(const CallExpr *CE, const FunctionDecl *FD);
+  void checkMsg_decodeValueOfObjCType(const ObjCMessageExpr *ME);
   void checkUncheckedReturnValue(CallExpr *CE);
 };
 } // end anonymous namespace
@@ -182,6 +187,20 @@ void WalkAST::VisitCallExpr(CallExpr *CE) {
   VisitChildren(CE);
 }
 
+void WalkAST::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
+  MsgCheck evalFunction =
+  llvm::StringSwitch(ME->getSelector().getAsString())
+  .Case("decodeValueOfObjCType:at:",
+&WalkAST::checkMsg_decodeValueOfObjCType)
+  .Default(nullptr);
+
+  if (evalFunction)
+(this->*evalFunction)(ME);
+
+  // Recurse and check children.
+  VisitChildren(ME);
+}
+
 void WalkAST::VisitCompoundStmt(CompoundStmt *S) {
   for (Stmt *Child : S->children())
 if (Child) {
@@ -923,6 +942,54 @@ void WalkAST::checkCall_vfork(const CallExpr *CE, const 
FunctionDecl *FD) {
  CELoc, CE->getCallee()->getSourceRange());
 }
 
+//===-

[PATCH] D71475: [WIP][OPENMP] Try to fix linear clause crash by emitting alloca for step

2019-12-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D71475#1791825 , @cchen wrote:

> [...] I found it really hard to update the tests by reading the diagnostic 
> message. Can I refactor the test a bit (like separate each openmp portion to 
> be CK1, CK2...) so that I can modify the test easier.


This is a concern multiple people have raised already. Anything that helps 
making tests easier to read and update is good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71475



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


[PATCH] D71728: [analyzer] Add a syntactic security check for ObjC NSCoder API.

2019-12-19 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb28400507212: [analyzer] Add a syntactic security check for 
ObjC NSCoder API. (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D71728?vs=234786&id=234794#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71728

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/test/Analysis/security-syntax-checks-nscoder.m
  clang/www/analyzer/available_checks.html

Index: clang/www/analyzer/available_checks.html
===
--- clang/www/analyzer/available_checks.html
+++ clang/www/analyzer/available_checks.html
@@ -1446,6 +1446,22 @@
 }
 
 
+
+
+security.insecureAPI.decodeValueOfObjCType
+(ObjC)
+Warn on uses of the -[NSCoder decodeValueOfObjCType:at:] method.
+The safe alternative is -[NSCoder decodeValueOfObjCType:at:size:].
+
+
+void test(NSCoder *decoder) {
+  // This would be a vulnerability on 64-bit platforms
+  // but not on 32-bit platforms.
+  NSUInteger x;
+  [decoder decodeValueOfObjCType:"I" at:&x]; // warn
+}
+
+
 
 
 
Index: clang/test/Analysis/security-syntax-checks-nscoder.m
===
--- /dev/null
+++ clang/test/Analysis/security-syntax-checks-nscoder.m
@@ -0,0 +1,36 @@
+// RUN: %clang_analyze_cc1 -triple thumbv7-apple-ios11.0 -verify=available \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-apple-ios10.0 -verify=notavailable \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-macos10.13 -verify=available \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-macos10.12 -verify=notavailable \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-apple-watchos4.0 -verify=available \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-apple-watchos3.0 -verify=notavailable \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-apple-tvos11.0 -verify=available \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-apple-tvos10.0 -verify=notavailable \
+// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s
+
+// notavailable-no-diagnostics
+
+typedef unsigned long NSUInteger;
+
+@interface NSCoder
+- (void)decodeValueOfObjCType:(const char *)type
+   at:(void *)data;
+- (void)decodeValueOfObjCType:(const char *)type
+   at:(void *)data
+ size:(NSUInteger)size;
+@end
+
+void test(NSCoder *decoder) {
+  // This would be a vulnerability on 64-bit platforms
+  // but not on 32-bit platforms.
+  NSUInteger x;
+  [decoder decodeValueOfObjCType:"I" at:&x]; // available-warning{{Deprecated method '-decodeValueOfObjCType:at:' is insecure as it can lead to potential buffer overflows. Use the safer '-decodeValueOfObjCType:at:size:' method}}
+  [decoder decodeValueOfObjCType:"I" at:&x size:sizeof(x)]; // no-warning
+}
Index: clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -49,6 +49,7 @@
   DefaultBool check_vfork;
   DefaultBool check_FloatLoopCounter;
   DefaultBool check_UncheckedReturn;
+  DefaultBool check_decodeValueOfObjCType;
 
   CheckerNameRef checkName_bcmp;
   CheckerNameRef checkName_bcopy;
@@ -63,6 +64,7 @@
   CheckerNameRef checkName_vfork;
   CheckerNameRef checkName_FloatLoopCounter;
   CheckerNameRef checkName_UncheckedReturn;
+  CheckerNameRef checkName_decodeValueOfObjCType;
 };
 
 class WalkAST : public StmtVisitor {
@@ -83,6 +85,7 @@
 
   // Statement visitor methods.
   void VisitCallExpr(CallExpr *CE);
+  void VisitObjCMessageExpr(ObjCMessageExpr *CE);
   void VisitForStmt(ForStmt *S);
   void VisitCompoundStmt (CompoundStmt *S);
   void VisitStmt(Stmt *S) { VisitChildren(S); }
@@ -93,6 +96,7 @@
   bool checkCall_strCommon(const CallExpr *CE, const FunctionDecl *FD);
 
   typedef void (WalkAST::*FnCheck)(const CallExpr *, const FunctionDecl *);
+  typedef void (WalkAST::*MsgCheck)(const ObjCMessageExpr *);
 
   // Checker-specific methods.
   void checkLoopConditionForFloat(const ForStmt *FS);
@@ -110,6 +114,7 @@
   void checkCall_rand(const CallExpr *CE, const F

[clang] f4a45c2 - Fix crash on init-capture packs where the type of the initializer is non-dependent.

2019-12-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-12-19T15:20:10-08:00
New Revision: f4a45c2ce4ce2a7a33d5773048682e65f348a486

URL: 
https://github.com/llvm/llvm-project/commit/f4a45c2ce4ce2a7a33d5773048682e65f348a486
DIFF: 
https://github.com/llvm/llvm-project/commit/f4a45c2ce4ce2a7a33d5773048682e65f348a486.diff

LOG: Fix crash on init-capture packs where the type of the initializer is 
non-dependent.

Added: 


Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
clang/test/Lexer/cxx-features.cpp

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 14c9ccd8a663..2c7e3a56c043 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -507,7 +507,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
   if (LangOpts.CPlusPlus14) {
 Builder.defineMacro("__cpp_binary_literals", "201304L");
 Builder.defineMacro("__cpp_digit_separators", "201309L");
-Builder.defineMacro("__cpp_init_captures", "201304L"); // (not latest)
+Builder.defineMacro("__cpp_init_captures",
+LangOpts.CPlusPlus2a ? "201803L" : "201304L");
 Builder.defineMacro("__cpp_generic_lambdas",
 LangOpts.CPlusPlus2a ? "201707L" : "201304L");
 Builder.defineMacro("__cpp_decltype_auto", "201304L");

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 327447746c39..46d923138271 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4453,7 +4453,8 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *&Init, QualType 
&Result,
   /*.IsPack = */ (bool)Type.getAs()};
 
   if (!DependentDeductionDepth &&
-  (Type.getType()->isDependentType() || Init->isTypeDependent())) {
+  (Type.getType()->isDependentType() || Init->isTypeDependent() ||
+   Init->containsUnexpandedParameterPack())) {
 Result = SubstituteDeducedTypeTransform(*this, 
DependentResult).Apply(Type);
 assert(!Result.isNull() && "substituting DependentTy can't fail");
 return DAR_Succeeded;

diff  --git a/clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp 
b/clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
index 4d5b6b47459c..ce2fccc8fe6f 100644
--- a/clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
@@ -37,3 +37,11 @@ template void f(T ...t) {
   }...   // expected-error {{does not contain any unexpanded}}
   );
 }
+
+template constexpr auto x = [...z = a] (auto F) { return F(z...); };
+static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; 
}) == 123);
+static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; 
}) == 124); // expected-error {{failed}}
+
+template constexpr auto y = [z = a...] (auto F) { return F(z...); }; 
// expected-error {{must appear before the name of the capture}}
+static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; 
}) == 123);
+static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; 
}) == 124); // expected-error {{failed}}

diff  --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index e771d891a14b..05f77991fa34 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -66,6 +66,8 @@
 #error "wrong value for __cpp_impl_three_way_comparison"
 #endif
 
+// init_captures checked below
+
 // --- C++17 features ---
 
 #if check(hex_float, 0, 0, 0, 201603, 201603)
@@ -170,7 +172,7 @@
 #error "wrong value for __cpp_digit_separators"
 #endif
 
-#if check(init_captures, 0, 0, 201304, 201304, 201304)
+#if check(init_captures, 0, 0, 201304, 201304, 201803)
 #error "wrong value for __cpp_init_captures"
 #endif
 



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


[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2019-12-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/AArch64/SVEInstrFormats.td:5333
+  // We need a layer of indirection because early machine code passes balk at
+  // physical register (i.e. FFR) uses that have no previous definition.
+  let hasSideEffects = 1, hasNoSchedulingInfo = 1, mayLoad = 1 in {

This is depending on hasSideEffects to preserve the correct ordering with 
instructions that read/write FFR?  That probably works.  I guess the 
alternative is to insert an IMPLICIT_DEF of FFR in the entry block of each 
function.

What are the calling convention rules for FFR?  Is it callee-save?  If not, we 
might need to do some work to make FFR reads/writes do something sane across 
calls inserted by the compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71698



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


  1   2   >