[clang] 37fa9d6 - [CodeGen][ObjC] Don't extend lifetime of ObjC pointers passed to calls

2020-03-10 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-03-10T22:10:32-07:00
New Revision: 37fa9d65eaa7d8fae7e5b787c4e8ef0a982cead5

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

LOG: [CodeGen][ObjC] Don't extend lifetime of ObjC pointers passed to calls
to __builtin_os_log_format if ARC isn't enabled

Fixes a bug introduced in this commit:
https://github.com/llvm/llvm-project/commit/f4d791f8332c2bb7e89849d0fe4ef48cb0a23229

rdar://problem/60301219

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGenObjC/os_log.m

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 090efaadc4c6..e2cd0f8814cc 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1325,7 +1325,8 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr ) {
   // enclosing block scope.
   // FIXME: We only have to do this if the argument is a temporary, which
   //gets released after the full expression.
-  if (TheExpr->getType()->isObjCRetainableType()) {
+  if (TheExpr->getType()->isObjCRetainableType() &&
+  getLangOpts().ObjCAutoRefCount) {
 assert(getEvaluationKind(TheExpr->getType()) == TEK_Scalar &&
"Only scalar can be a ObjC retainable type");
 if (!isa(ArgVal)) {

diff  --git a/clang/test/CodeGenObjC/os_log.m b/clang/test/CodeGenObjC/os_log.m
index 1dd39eebf383..4e70ef3e7574 100644
--- a/clang/test/CodeGenObjC/os_log.m
+++ b/clang/test/CodeGenObjC/os_log.m
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc 
-O2 -fno-experimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-LEGACY
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc 
-O2 -fexperimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-NEWPM
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc 
-O0 | FileCheck %s -check-prefix=CHECK-O0
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -O2 
-disable-llvm-passes | FileCheck %s -check-prefix=CHECK-MRR
 
 // Make sure we emit clang.arc.use before calling objc_release as part of the
 // cleanup. This way we make sure the object will not be released until the
@@ -137,6 +138,9 @@
 // CHECK-O0: call void @llvm.objc.storeStrong(i8** %[[V13]], i8* null)
 // CHECK-O0: call void @llvm.objc.storeStrong(i8** %[[A_ADDR]], i8* null)
 
+// CHECK-MRR: define void @test_builtin_os_log2(
+// CHECK-MRR-NOT: call {{.*}} @llvm.objc
+
 void test_builtin_os_log2(void *buf, id a) {
   __builtin_os_log_format(buf, "capabilities: %@ %@", GenString(), a);
   os_log_pack_send(buf);



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


[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 249550.
skan marked an inline comment as done.
skan added a comment.

Make the variale name in macro start with 2 underscores


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723

Files:
  clang/lib/Headers/ia32intrin.h
  clang/test/CodeGen/bitscan-builtins.c


Index: clang/test/CodeGen/bitscan-builtins.c
===
--- clang/test/CodeGen/bitscan-builtins.c
+++ clang/test/CodeGen/bitscan-builtins.c
@@ -5,6 +5,32 @@
 
 #include 
 
+unsigned char test_BitScanForward(unsigned *index, unsigned mask) {
+  return _BitScanForward(index, mask);
+  // CHECK: @test_BitScanForward
+  // CHECK: %{{.*}} = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse(unsigned *index, unsigned mask) {
+  return _BitScanReverse(index, mask);
+  // CHECK: @test_BitScanReverse
+  // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 31, %[[call]]
+}
+
+unsigned char test_BitScanForward64(unsigned *index, unsigned long long mask) {
+  return _BitScanForward64(index, mask);
+  // CHECK: @test_BitScanForward64
+  // CHECK: %{{.*}} = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse64(unsigned *index, unsigned long long mask) {
+  return _BitScanReverse64(index, mask);
+  // CHECK: @test_BitScanReverse64
+  // CHECK:  %{{.*}} = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 63, %{{.*}}
+}
+
 int test_bit_scan_forward(int a) {
   return _bit_scan_forward(a);
 // CHECK: @test_bit_scan_forward
Index: clang/lib/Headers/ia32intrin.h
===
--- clang/lib/Headers/ia32intrin.h
+++ clang/lib/Headers/ia32intrin.h
@@ -413,6 +413,58 @@
 
 #ifndef _MSC_VER
 /* These are already provided as builtins for MSVC. */
+#define _BitScanForward(a, b)  
\
+  __extension__({  
\
+int __c = (int)(b);
\
+unsigned char __d; 
\
+if (__c != 0) {
\
+  *(a) = (unsigned)__bsfd(__c);
\
+  __d = 1; 
\
+} else {   
\
+  __d = 0; 
\
+}  
\
+__d;   
\
+  })
+#define _BitScanReverse(a, b)  
\
+  __extension__({  
\
+int __c = (int)(b);
\
+unsigned char __d; 
\
+if (__c != 0) {
\
+  *(a) = (unsigned)__bsrd(__c);
\
+  __d = 1; 
\
+} else {   
\
+  __d = 0; 
\
+}  
\
+__d;   
\
+  })
+
+#ifdef __x86_64__
+#define _BitScanForward64(a, b)
\
+  __extension__({  
\
+long long __c = (long long)(b);
\
+unsigned char __d; 
\
+if (__c != 0) {
\
+  *(a) = (unsigned)__bsfq(__c);
\
+  __d = 1; 
\
+} else {   
\
+  __d = 0; 
\
+}  
\
+__d;   
\
+  })
+#define _BitScanReverse64(a, b)
\
+  __extension__({  
\
+long long __c = (long long)(b);   

[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: clang/lib/Headers/ia32intrin.h:456
+  __extension__({  
\
+long long c = (long long)(b);  
\
+unsigned char d;   
\

craig.topper wrote:
> Variable name in macro needs to start with 2 underscores to avoid conflicts 
> with user variable names. I need to think about whether that’s enough to 
> avoid problems.
The variable shadowing problem when using statement expression is a known 
issue. 

https://patches-gcc.linaro.org/patch/17303/
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

 In general, user variable names should not start with  2 underscores, so I 
think it's safe enough. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723



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


[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/ia32intrin.h:417
+#define _BitScanForward(a, b)  
\
+  __extension__({  
\
+int c = (int)(b);  
\

craig.topper wrote:
> Is __extension__ needed?
Nevermind it probably is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-10 Thread James Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

I believe my previous comments have indeed been addressed.




Comment at: clang/docs/ClangCommandLineReference.rst:2958
+
+Put global and static data smaller than the limitation into a special section 
(RISCV only)
+

lenary wrote:
> "(RISC-V only)" please
This seems like needless noise; it's already in the RISCV section, we don't 
need to say it's RISC-V only in the body too. Other architectures are 
inconsistent about this but I see it as a waste of time?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D75971: Should not need the second predicate.If `II->hasMacroDefinition()` is true, then the whole expr is always true.

2020-03-10 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo created this revision.
oontvoo added a reviewer: jyknight.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

remove redundant pred


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75971

Files:
  clang/include/clang/Lex/Preprocessor.h


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -1042,8 +1042,7 @@
 return isMacroDefined((Id));
   }
   bool isMacroDefined(const IdentifierInfo *II) {
-return II->hasMacroDefinition() &&
-   (!getLangOpts().Modules || (bool)getMacroDefinition(II));
+return II->hasMacroDefinition();
   }
 
   /// Determine whether II is defined as a macro within the module M,


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -1042,8 +1042,7 @@
 return isMacroDefined((Id));
   }
   bool isMacroDefined(const IdentifierInfo *II) {
-return II->hasMacroDefinition() &&
-   (!getLangOpts().Modules || (bool)getMacroDefinition(II));
+return II->hasMacroDefinition();
   }
 
   /// Determine whether II is defined as a macro within the module M,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75896: [X86] Support intrinsic _mm_cldemote

2020-03-10 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75896



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


[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/ia32intrin.h:417
+#define _BitScanForward(a, b)  
\
+  __extension__({  
\
+int c = (int)(b);  
\

Is __extension__ needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723



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


[PATCH] D75894: [X86] Support intrinsics _bextr2*

2020-03-10 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75894



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


[PATCH] D75896: [X86] Support intrinsic _mm_cldemote

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 249548.
skan added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75896

Files:
  clang/lib/Headers/cldemoteintrin.h
  clang/test/CodeGen/cldemote.c


Index: clang/test/CodeGen/cldemote.c
===
--- clang/test/CodeGen/cldemote.c
+++ clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }
Index: clang/lib/Headers/cldemoteintrin.h
===
--- clang/lib/Headers/cldemoteintrin.h
+++ clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDEMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif


Index: clang/test/CodeGen/cldemote.c
===
--- clang/test/CodeGen/cldemote.c
+++ clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }
Index: clang/lib/Headers/cldemoteintrin.h
===
--- clang/lib/Headers/cldemoteintrin.h
+++ clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDEMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/ia32intrin.h:456
+  __extension__({  
\
+long long c = (long long)(b);  
\
+unsigned char d;   
\

Variable name in macro needs to start with 2 underscores to avoid conflicts 
with user variable names. I need to think about whether that’s enough to avoid 
problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723



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


[PATCH] D75894: [X86] Support intrinsics _bextr2*

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 249547.
skan added a comment.

Address review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75894

Files:
  clang/lib/Headers/bmiintrin.h
  clang/test/CodeGen/bmi-builtins.c


Index: clang/test/CodeGen/bmi-builtins.c
===
--- clang/test/CodeGen/bmi-builtins.c
+++ clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}
Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -192,6 +192,28 @@
   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned integer used to specify which bits are extracted. Bits [7:0]
+///specify the index of the least significant bit. Bits [15:8] specify the
+///number of bits to be extracted.
+/// \returns An unsigned integer whose least significant bits contain the
+///extracted bits.
+/// \see __bextr_u32
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  return __builtin_ia32_bextr_u32(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///
@@ -321,6 +343,28 @@
   return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned 64-bit integer used to specify which bits are extracted. 
Bits
+///[7:0] specify the index of the least significant bit. Bits [15:8] 
specify
+///the number of bits to be extracted.
+/// \returns An unsigned 64-bit integer whose least significant bits contain 
the
+///extracted bits.
+/// \see __bextr_u64
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+_bextr2_u64(unsigned long long __X, unsigned long long __Y) {
+  return __builtin_ia32_bextr_u64(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///


Index: clang/test/CodeGen/bmi-builtins.c
===
--- clang/test/CodeGen/bmi-builtins.c
+++ clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}
Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -192,6 +192,28 @@
   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | 

[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 249546.
skan added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723

Files:
  clang/lib/Headers/ia32intrin.h
  clang/test/CodeGen/bitscan-builtins.c


Index: clang/test/CodeGen/bitscan-builtins.c
===
--- clang/test/CodeGen/bitscan-builtins.c
+++ clang/test/CodeGen/bitscan-builtins.c
@@ -5,6 +5,32 @@
 
 #include 
 
+unsigned char test_BitScanForward(unsigned *index, unsigned mask) {
+  return _BitScanForward(index, mask);
+  // CHECK: @test_BitScanForward
+  // CHECK: %{{.*}} = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse(unsigned *index, unsigned mask) {
+  return _BitScanReverse(index, mask);
+  // CHECK: @test_BitScanReverse
+  // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 31, %[[call]]
+}
+
+unsigned char test_BitScanForward64(unsigned *index, unsigned long long mask) {
+  return _BitScanForward64(index, mask);
+  // CHECK: @test_BitScanForward64
+  // CHECK: %{{.*}} = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse64(unsigned *index, unsigned long long mask) {
+  return _BitScanReverse64(index, mask);
+  // CHECK: @test_BitScanReverse64
+  // CHECK:  %{{.*}} = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 63, %{{.*}}
+}
+
 int test_bit_scan_forward(int a) {
   return _bit_scan_forward(a);
 // CHECK: @test_bit_scan_forward
Index: clang/lib/Headers/ia32intrin.h
===
--- clang/lib/Headers/ia32intrin.h
+++ clang/lib/Headers/ia32intrin.h
@@ -413,6 +413,58 @@
 
 #ifndef _MSC_VER
 /* These are already provided as builtins for MSVC. */
+#define _BitScanForward(a, b)  
\
+  __extension__({  
\
+int c = (int)(b);  
\
+unsigned char d;   
\
+if (c != 0) {  
\
+  *(a) = (unsigned)__bsfd(c);  
\
+  d = 1;   
\
+} else {   
\
+  d = 0;   
\
+}  
\
+d; 
\
+  })
+#define _BitScanReverse(a, b)  
\
+  __extension__({  
\
+int c = (int)(b);  
\
+unsigned char d;   
\
+if (c != 0) {  
\
+  *(a) = (unsigned)__bsrd(c);  
\
+  d = 1;   
\
+} else {   
\
+  d = 0;   
\
+}  
\
+d; 
\
+  })
+
+#ifdef __x86_64__
+#define _BitScanForward64(a, b)
\
+  __extension__({  
\
+long long c = (long long)(b);  
\
+unsigned char d;   
\
+if (c != 0) {  
\
+  *(a) = (unsigned)__bsfq(c);  
\
+  d = 1;   
\
+} else {   
\
+  d = 0;   
\
+}  
\
+d; 
\
+  })
+#define _BitScanReverse64(a, b)
\
+  __extension__({  
\
+long long c = (long long)(b);  
\
+unsigned char d;  

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-10 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 249545.
shiva0217 added a comment.

Update patch to address @evandro's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/riscv-sdata-module-flag.c
  clang/test/Driver/riscv-G-warning.c
  clang/test/Driver/riscv-sdata-warning.c

Index: clang/test/Driver/riscv-sdata-warning.c
===
--- /dev/null
+++ clang/test/Driver/riscv-sdata-warning.c
@@ -0,0 +1,8 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -S -target riscv32-unknown-elf -fpic -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIC-SDATA %s
+// CHECK-PIC-SDATA: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64
+
+// RUN: %clang -S -target riscv64-unknown-elf -mcmodel=large -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-RV64-LARGE-SDATA %s
+// CHECK-RV64-LARGE-SDATA: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64
Index: clang/test/Driver/riscv-G-warning.c
===
--- /dev/null
+++ clang/test/Driver/riscv-G-warning.c
@@ -0,0 +1,4 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -S -target riscv32-unknown-elf -G4 -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-G %s
+// CHECK-G: warning: ignoring '-G' with -msmall-data-limit= in the command line
Index: clang/test/CodeGen/riscv-sdata-module-flag.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-sdata-module-flag.c
@@ -0,0 +1,31 @@
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-DEFAULT
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -G4 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-G4
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -msmall-data-limit=0 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-S0
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -fpic -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-PIC
+
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-DEFAULT
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -G4 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-G4
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -msmall-data-limit=0 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-S0
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -fpic -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-PIC
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -mcmodel=large -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-LARGE
+
+
+// RV32-DEFAULT: !{i32 1, !"SmallDataLimit", i32 8}
+// RV32-G4:  !{i32 1, !"SmallDataLimit", i32 4}
+// RV32-S0:  !{i32 1, !"SmallDataLimit", i32 0}
+// RV32-PIC: !{i32 1, !"SmallDataLimit", i32 0}
+
+// RV64-DEFAULT: !{i32 1, !"SmallDataLimit", i32 8}
+// RV64-G4:  !{i32 1, !"SmallDataLimit", i32 4}
+// RV64-S0:  !{i32 1, !"SmallDataLimit", i32 0}
+// RV64-PIC: !{i32 1, !"SmallDataLimit", i32 0}
+// RV64-LARGE:   !{i32 1, !"SmallDataLimit", i32 0}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -923,6 +923,8 @@
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
+  Opts.SmallDataLimit =
+  getLastArgIntValue(Args, OPT_msmall_data_limit, 0, Diags);
   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
   Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
   Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1960,6 +1960,42 @@
   }
 }
 
+static void SetRISCVSmallDataLimit(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  const Driver  = TC.getDriver();
+  const llvm::Triple  = TC.getTriple();
+  // Default small data limitation is eight.
+  const char *SmallDataLimit = "8";
+  

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-03-10 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

The commit summary needs improvement. The syntax is not really necessary there, 
but instead this needs a better explanation of how this builtin fits in with 
the overall scheme of language-specific and target-specific details of an 
atomic operation. For example, is this meant only for OpenCL? Does it work with 
CUDA? Or HIP? What is the behaviour for scope in C++?




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7860-7863
+def err_memory_fence_has_invalid_memory_order : Error<
+  "memory order argument to fence operation is invalid">;
+def err_memory_fence_has_invalid_synch_scope : Error<
+  "synchronization scope argument to fence operation is invalid">;

Just above this addition, atomic op seems to emit a warning for invalid memory 
order. Should that be the case with fence too?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3707
+Value *Scope = EmitScalarExpr(E->getArg(1));
+auto ScopeModel = AtomicScopeModel::create(AtomicScopeModelKind::OpenCL);
+

The proposed builtin does not claim to be an OpenCL builtin, so it's probably 
not correct to simply assume the OpenCL model. Should the model be chosen based 
on the source language specified?


Repository:
  rC Clang

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

https://reviews.llvm.org/D75917



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-10 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast updated this revision to Diff 249544.
PaulkaToast added a comment.

Addressed @Eugene.Zelenko comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
@@ -0,0 +1,14 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t
+// We dont know which headers are provided on each system.
+// Therefore, we only test on linux.
+// UNSUPPORTED: !linux
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdio.h not allowed
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdlib.h not allowed
+#include "string.h"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header string.h not allowed
+#include "stdatomic.h"
+#include 
+// Compiler provided headers should not throw warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t \
+// RUN:   -- -header-filter=.* \
+// RUN:   -- -I %S/Inputs/llvmlibc
+// We dont know which headers are provided on each system.
+// Therefore, we only test on linux.
+// UNSUPPORTED: !linux
+
+#include "transitive.h"
+// CHECK-MESSAGES: :1:1: warning: system libc header math.h not allowed, transitively included from {{.*}}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -68,6 +68,7 @@
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
+``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.
 ``modernize-`` Checks that advocate usage of modern (currently "modern"
means "C++11") language constructs.
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - llvmlibc-restrict-system-libc-headers
+
+llvmlibc-restrict-system-libc-headers
+=
+
+Finds includes of system libc headers not provided by the compiler within
+llvm-libc implementations.
+
+.. code-block:: c++
+
+   #include // Not allowed because it is part of system libc.
+   #include// Allowed because it is provided by the compiler.
+   #include "internal/stdio.h"   // Allowed because it is NOT part of system libc.
+
+
+This check is necessary because accidentally including system libc headers can
+lead to subtle and hard to detect bugs. For example consider a system libc
+whose ``dirent`` struct has slightly different field ordering than llvm-libc.
+While this will compile successfully, this can cause issues during runtime
+because they are ABI incompatible.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst

[PATCH] D75901: [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode

2020-03-10 Thread Alex Cameron via Phabricator via cfe-commits
tetsuo-cpp marked an inline comment as done.
tetsuo-cpp added a comment.

@njames93 @MaskRay 
Thanks for helping me with testing. I'll remember this for next time.

I also saw this pattern of retrieving `LangOptions` from an `ASTContext` in 
some other checks (`RedundantExpressionCheck` and `StaticAssertCheck`) but I 
didn't change them to use `getLangOpts` since the `ASTContext` is used for 
other stuff.


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

https://reviews.llvm.org/D75901



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


[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c70dec18c7e: [libunwind] Remove __FILE__ and __LINE__ from 
error reporting (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890

Files:
  libunwind/src/config.h


Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -122,8 +122,7 @@
 #else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
-__LINE__, msg);
\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)


Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -122,8 +122,7 @@
 #else
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  \
-__LINE__, msg);\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);\
 fflush(stderr);\
 abort();   \
   } while (0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75901: [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode

2020-03-10 Thread Alex Cameron via Phabricator via cfe-commits
tetsuo-cpp updated this revision to Diff 249538.
tetsuo-cpp added a comment.

Address review comments.


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

https://reviews.llvm.org/D75901

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator-precxx11.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator-precxx11.cpp
@@ -0,0 +1,6 @@
+// RUN: %check_clang_tidy -std=c++98,c++03 %s 
misc-unconventional-assign-operator %t
+
+struct BadArgument {
+  BadArgument =(BadArgument &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 
'BadArgument const&' or 'BadArgument'
+};
Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -75,7 +75,10 @@
   } else {
 static const char *const Messages[][2] = {
 {"ReturnType", "operator=() should return '%0&'"},
-{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or 
'%0'"},
+{"ArgumentType",
+ getLangOpts().CPlusPlus11
+ ? "operator=() should take '%0 const&', '%0&&' or '%0'"
+ : "operator=() should take '%0 const&' or '%0'"},
 {"cv", "operator=() should not be marked '%1'"}};
 
 const auto *Method = Result.Nodes.getNodeAs("method");


Index: clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator-precxx11.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator-precxx11.cpp
@@ -0,0 +1,6 @@
+// RUN: %check_clang_tidy -std=c++98,c++03 %s misc-unconventional-assign-operator %t
+
+struct BadArgument {
+  BadArgument =(BadArgument &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&' or 'BadArgument'
+};
Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -75,7 +75,10 @@
   } else {
 static const char *const Messages[][2] = {
 {"ReturnType", "operator=() should return '%0&'"},
-{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or '%0'"},
+{"ArgumentType",
+ getLangOpts().CPlusPlus11
+ ? "operator=() should take '%0 const&', '%0&&' or '%0'"
+ : "operator=() should take '%0 const&' or '%0'"},
 {"cv", "operator=() should not be marked '%1'"}};
 
 const auto *Method = Result.Nodes.getNodeAs("method");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-10 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
+
+  Finds includes of sytem libc headers in llvm-libc implementation.
+

Please synchronize with first statement in documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332



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


[libunwind] 1c70dec - [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-03-10T18:58:41-07:00
New Revision: 1c70dec18c7e530264cc70841cc60f385259b9e0

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

LOG: [libunwind] Remove __FILE__ and __LINE__ from error reporting

We were seeing non-deterministic binary size differences depending on which
toolchain was used to build fuchsia. This is because libunwind embeded the
FILE path into a logging macro, even for release builds, which makes the code
dependent on the build directory.

This removes the file and line number from the error message. This is
consistent with how other runtimes report error, e.g.
https://github.com/llvm/llvm-project/blob/master/libcxxabi/src/abort_message.cpp#L30.

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

Added: 


Modified: 
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/config.h b/libunwind/src/config.h
index dcd3cef94552..5658b3210cf3 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -122,8 +122,7 @@
 #else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
-__LINE__, msg);
\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)



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


[PATCH] D75969: [clangd] Link libClangDaemonTweaks to libClangFormat

2020-03-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Thanks for the prompt response. It seems our fix attempts happened 
"concurrently" and we ended up with pretty much the same fix. I had committed 
rG48121a5743b684def33d158391c5424626de28e2 
 before 
seeing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75969



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


[PATCH] D75969: [clangd] Link libClangDaemonTweaks to libClangFormat

2020-03-10 Thread Hubert Tong via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG48121a5743b6 (authored by hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75969

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt


Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -29,6 +29,7 @@
   clangAST
   clangBasic
   clangDaemon
+  clangFormat
   clangLex
   clangToolingCore
   clangToolingRefactoring


Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -29,6 +29,7 @@
   clangAST
   clangBasic
   clangDaemon
+  clangFormat
   clangLex
   clangToolingCore
   clangToolingRefactoring
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75969: [clangd] Link libClangDaemonTweaks to libClangFormat

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.
hubert.reinterpretcast added a comment.

Thanks for the prompt response. It seems our fix attempts happened 
"concurrently" and we ended up with pretty much the same fix. I had committed 
rG48121a5743b684def33d158391c5424626de28e2 
 before 
seeing this.


This fixes bustage from https://reviews.llvm.org/D75716.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75969

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt


Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -29,6 +29,7 @@
   clangAST
   clangBasic
   clangDaemon
+  clangFormat
   clangLex
   clangToolingCore
   clangToolingRefactoring


Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -29,6 +29,7 @@
   clangAST
   clangBasic
   clangDaemon
+  clangFormat
   clangLex
   clangToolingCore
   clangToolingRefactoring
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75716: [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle

2020-03-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D75716#1916032 , 
@hubert.reinterpretcast wrote:

> It looks like this is causing bot failures 
> (http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1881/steps/build%20stage%201/logs/stdio):


Fix attempted in rG48121a5743b684def33d158391c5424626de28e2 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75716



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


[PATCH] D75716: [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D75716#1916032 , 
@hubert.reinterpretcast wrote:

> It looks like this is causing bot failures 
> (http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1881/steps/build%20stage%201/logs/stdio):


Sorry about that. Fix here: https://reviews.llvm.org/D75969


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75716



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-10 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp:66-67
+const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  SmallString<128> CompilerIncudeDir =
+  StringRef(PP->getHeaderSearchInfo().getHeaderSearchOpts().ResourceDir);
+  llvm::sys::path::append(CompilerIncudeDir, "include");

aaron.ballman wrote:
> The user can control this path -- is that an issue? You're using it to 
> determine what a compiler-provided header file is, and this seems like an 
> escape hatch for users to get around that. If that's reasonable to you, then 
> I'm okay with it, but you had mentioned you want to remove human error as a 
> factor and this seems like it could be a subtle human error situation.
Ah, thanks for pointing this out! I didn't consider this. I feel like scenario 
is a more unlikely then situations I mentioned. Probably not something to be 
too concerned about unless you know of a way to get the default resource path?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-10 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast updated this revision to Diff 249530.
PaulkaToast marked 4 inline comments as done.
PaulkaToast added a comment.

Addressed @aaron.ballman comments (:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdio.h not allowed
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdlib.h not allowed
+#include "string.h"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header string.h not allowed
+#include "stdatomic.h"
+#include 
+// Compiler provided headers should not throw warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
@@ -0,0 +1,6 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t \
+// RUN:   -- -header-filter=.* \
+// RUN:   -- -I %S/Inputs/llvmlibc
+
+#include "transitive.h"
+// CHECK-MESSAGES: :1:1: warning: system libc header math.h not allowed, transitively included from {{.*}}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -68,6 +68,7 @@
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
+``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.
 ``modernize-`` Checks that advocate usage of modern (currently "modern"
means "C++11") language constructs.
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - llvmlibc-restrict-system-libc-headers
+
+llvmlibc-restrict-system-libc-headers
+=
+
+Finds includes of system libc headers not provided by the compiler within
+llvm-libc implementations.
+
+.. code-block:: c++
+
+   #include // Not allowed because it is part of system libc.
+   #include// Allowed because it is provided by the compiler.
+   #include "internal/stdio.h"   // Allowed because it is NOT part of system libc.
+
+
+This check is necessary because accidentally including system libc headers can
+lead to subtle and hard to detect bugs. For example consider a system libc
+whose ``dirent`` struct has slightly different field ordering than llvm-libc.
+While this will compile successfully, this can cause issues during runtime
+because they are ABI incompatible.
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
@@ -187,6 +187,7 @@
`llvm-prefer-isa-or-dyn-cast-in-conditionals `_, "Yes"
`llvm-prefer-register-over-unsigned `_, "Yes"

[clang-tools-extra] 48121a5 - [cmake] Link libclangDaemonTweaks with clangFormat

2020-03-10 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-03-10T21:31:10-04:00
New Revision: 48121a5743b684def33d158391c5424626de28e2

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

LOG: [cmake] Link libclangDaemonTweaks with clangFormat

Speculative fix for buildbot failure in
http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1881/steps/build%20stage%201/logs/stdio

Cause appears to be D75716.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 6f6ef4a2ace2..5817830b7ea3 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -29,6 +29,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   clangAST
   clangBasic
   clangDaemon
+  clangFormat
   clangLex
   clangToolingCore
   clangToolingRefactoring



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


[PATCH] D75716: [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle

2020-03-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

It looks like this is causing bot failures 
(http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1881/steps/build%20stage%201/logs/stdio):

  : && /home/buildbots/clang.9.0.0/bin/clang++ 
--gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC 
-fvisibility-inlines-hidden -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections 
-fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3  -Wl,-z,defs 
-Wl,-z,nodelete   
-Wl,-rpath-link,/home/docker/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/stage1/./lib
  -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libclangDaemonTweaks.so.11git 
-o lib/libclangDaemonTweaks.so.11git 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/AnnotateHighlightings.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DumpAST.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineInline.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineOutline.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandAutoType.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandMacro.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractFunction.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractVariable.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ObjCLocalizeStringLiteral.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RawStringLiteral.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RemoveUsingNamespace.cpp.o
 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o
  -Wl,-rpath,"\$ORIGIN/../lib" lib/libclangAST.so.11git 
lib/libclangBasic.so.11git lib/libclangDaemon.so.11git lib/libclangLex.so.11git 
lib/libclangToolingCore.so.11git lib/libclangToolingRefactoring.so.11git 
lib/libclangToolingSyntax.so.11git lib/libLLVMSupport.so.11git && :
  
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineOutline.cpp.o:
 In function `clang::clangd::(anonymous 
namespace)::DefineOutline::apply(clang::clangd::Tweak::Selection const&)':
  
DefineOutline.cpp:(.text._ZN5clang6clangd12_GLOBAL__N_113DefineOutline5applyERKNS0_5Tweak9SelectionE+0x450):
 undefined reference to 
`clang::format::getFormattingLangOpts(clang::format::FormatStyle const&)'
  clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75716



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


Re: [clang] d052a57 - [c++2a] Allow comparison functions to be explicitly defaulted.

2020-03-10 Thread Hubert Tong via cfe-commits
On Tue, Mar 10, 2020 at 7:35 PM Richard Smith  wrote:

> Should be fixed in llvmorg-11-init-5426-g4cba668ac13.
>
Thanks. We're also seeing a failure on valid code where a template class
explicitly deletes a function that is an override of an explicitly deleted
virtual function in a (non-templated) base class.

:7:16: error: non-deleted function 'f' cannot override a deleted
function
  virtual void f() = delete;
   ^
:10:8: note: in instantiation of template class 'B' requested
here
B b() { return {}; }
   ^
:2:16: note: overridden virtual function is here
  virtual void f() = delete;
   ^
1 error generated.


>
> On Sat, 7 Mar 2020 at 08:05, Hubert Tong via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Following this commit, the error recovery for invalid cases that
>> explicitly define (out-of-line) a member function template as deleted and
>> attempts to instantiate said function appears broken.
>>
>> :4:35: error: deleted definition must be first declaration
>> template  void A::f() = delete;
>>   ^
>> :2:35: note: previous declaration is here
>>   template  static void f();
>>   ^
>> clang:
>> /src_d052a578de58cbbb638cbe2dba05242d1ff443b9/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4288:
>> void clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
>> clang::FunctionDecl *, bool, bool, bool): Assertion `(Pattern ||
>> PatternDecl->isDefaulted() || PatternDecl->hasSkippedBody()) && "unexpected
>> kind of function template definition"' failed.
>> Stack dump:
>> 0.  Program arguments:
>> /build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/clang -cc1 -std=c++11
>> -xc++ -
>> 1.  :5:26: current parser token ';'
>>  #0 0x3fff7fe6a024 PrintStackTraceSignalHandler(void*)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1ea024)
>>  #1 0x3fff7fe670c8 llvm::sys::RunSignalHandlers()
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1e70c8)
>>  #2 0x3fff7fe6a49c SignalHandler(int)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1ea49c)
>>  #3 0x3fff82030478  0x478 abort
>>  #4 0x3fff82030478
>>  #5 0x3fff82030478 __assert_fail_base (+0x478)
>>  #6 0x3fff7e0a1f94 __assert_fail (/lib64/libc.so.6+0x41f94)
>>  #7 0x3fff7e0955d4
>> clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
>> clang::FunctionDecl*, bool, bool, bool) (/lib64/libc.so.6+0x355d4)
>>  #8 0x3fff7e0956c4
>> clang::Sema::ActOnExplicitInstantiation(clang::Scope*,
>> clang::SourceLocation, clang::SourceLocation, clang::Declarator&)
>> (/lib64/libc.so.6+0x356c4)
>>  #9 0x3fff7c28d604
>> clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
>> clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangSema.so.10svn+0x8ad604)
>> #10 0x3fff7c15c2b0
>> clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&,
>> clang::Parser::ParsedTemplateInfo const&)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangSema.so.10svn+0x77c2b0)
>> #11 0x3fff7c4cc8f8
>> clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
>> clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
>> clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x4c8f8)
>> #12 0x3fff7c4cdf48
>> clang::Parser::ParseExplicitInstantiation(clang::DeclaratorContext,
>> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&,
>> clang::ParsedAttributes&, clang::AccessSpecifier)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x4df48)
>> #13 0x3fff7c57c1f0
>> clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
>> clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfc1f0)
>> #14 0x3fff7c57a6c0
>> clang::Parser::ParseDeclaration(clang::DeclaratorContext,
>> clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
>> clang::SourceLocation*)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfa6c0)
>> #15 0x3fff7c57a4f8
>> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
>> clang::ParsingDeclSpec*)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfa4f8)
>> #16 0x3fff7c4c5db0
>> clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&,
>> bool)
>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x45db0)
>> #17 0x3fff7c58fffc 

[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/ia32intrin.h:418
+  __extension__({  
\
+*(a) = (unsigned)__bsfd((int)(b)); 
\
+(unsigned char)((b) != 0); 
\

This store also needs to be conditional on b being non-zero


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723



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


[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.cpp:17
+
+Matcher hasAnyListedName(std::vector Names) {
+  return Matcher(new HasNameMatcher(std::move(Names)));

gribozavr2 wrote:
> njames93 wrote:
> > gribozavr2 wrote:
> > > This matcher sounds generally useful. I think it would be better placed 
> > > in ASTMatchers.h, WDYT? Can we make it an overload of `hasAnyName`?
> > `hasAnyName` is a const variable who's type is `VariadicFunction` so it 
> > can't be overloaded unfortunately. I personally didn't want it in 
> > ASTMatchers.h as its mainly useful for `clang-tidy` checks that load in 
> > configurations. It doesn't have a place in say `clang-query`.
> > hasAnyName is a const variable who's type is VariadicFunction so it can't 
> > be overloaded unfortunately.
> 
> I thought we had facilities to declare polymorphic matchers that could help 
> here.
> 
> > I personally didn't want it in ASTMatchers.h as its mainly useful for 
> > clang-tidy checks that load in configurations.
> 
> A lot of user-defined tools are quite similar.
Polymorphic matchers are matchers that can match against different types of 
nodes, what we want here is match against one type of node, but different 
overloads. I am thinking though that With some nifty retooling of 
`VariadicFunction` you could possible change it so that you can call its 
`operator()` with types that are convertible to its `ArgT`. However that is a 
deep rabbit hole to go down for the purpose of what this patch is trying to do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75911



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


[PATCH] D75406: Avoid including FileManager.h from SourceManager.h

2020-03-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75406



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


[PATCH] D45805: [libcxx] Remove redundant specializations in type_traits.

2020-03-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay abandoned this revision.
MaskRay added a comment.

Thanks for review! However, I am abandoning this change because rL364160 
 deleted these traits.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D45805



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


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Yay!


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

https://reviews.llvm.org/D75171



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


[PATCH] D75784: Avoid including Module.h from ExternalASTSource.h

2020-03-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D75784#1910688 , @aprantl wrote:

> This will no doubt also need some patches to the Swift compiler, but given 
> the NFC-ness this hopefully should be fine.


True. I could leave behind a typedef for the ASTSourceDescriptor if it matters.

Any concerns, or does someone mind approving?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75784



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


[clang-tools-extra] 54928ba - [clang-tidy] Use more widely available headers for protability-restrict-system-includes-check's test

2020-03-10 Thread Paula Toth via cfe-commits

Author: Paula Toth
Date: 2020-03-10T16:54:11-07:00
New Revision: 54928ba0ec8355edbbdb31c7b01bb45eb2d384b6

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

LOG: [clang-tidy] Use more widely available headers for 
protability-restrict-system-includes-check's test

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
index faab977ad340..e3a9376a8638 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
@@ -1,9 +1,9 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '*,-stdio.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}"
 
-// Test block-list functionality: allow all but stdio.h.
+// Test block-list functionality: allow all but stddef.h.
 
-#include 
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include stdio.h not allowed
-#include 
-#include 
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include stddef.h not allowed
+#include 
+#include 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
index 58c1d4396ee5..f73cbbfc816d 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
@@ -1,10 +1,10 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '-*,stdio.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '-*,stddef.h'}]}"
 
-// Test allow-list functionality: disallow all but stdio.h.
+// Test allow-list functionality: disallow all but stddef.h.
 
-#include 
-#include 
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include stdlib.h not allowed
-#include 
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include string.h not allowed
+#include 
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include stdint.h not allowed
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include float.h not allowed

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
index ccde9438d93c..bee7ec73438c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
@@ -4,7 +4,7 @@
 // Test glob functionality: disallow all headers except those that match
 // pattern "std*.h".
 
-#include 
-#include 
-#include 
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include string.h not allowed
+#include 
+#include 
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include float.h not allowed



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


Re: [clang] d052a57 - [c++2a] Allow comparison functions to be explicitly defaulted.

2020-03-10 Thread Richard Smith via cfe-commits
Should be fixed in llvmorg-11-init-5426-g4cba668ac13.

On Sat, 7 Mar 2020 at 08:05, Hubert Tong via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Following this commit, the error recovery for invalid cases that
> explicitly define (out-of-line) a member function template as deleted and
> attempts to instantiate said function appears broken.
>
> :4:35: error: deleted definition must be first declaration
> template  void A::f() = delete;
>   ^
> :2:35: note: previous declaration is here
>   template  static void f();
>   ^
> clang:
> /src_d052a578de58cbbb638cbe2dba05242d1ff443b9/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4288:
> void clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
> clang::FunctionDecl *, bool, bool, bool): Assertion `(Pattern ||
> PatternDecl->isDefaulted() || PatternDecl->hasSkippedBody()) && "unexpected
> kind of function template definition"' failed.
> Stack dump:
> 0.  Program arguments:
> /build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/clang -cc1 -std=c++11
> -xc++ -
> 1.  :5:26: current parser token ';'
>  #0 0x3fff7fe6a024 PrintStackTraceSignalHandler(void*)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1ea024)
>  #1 0x3fff7fe670c8 llvm::sys::RunSignalHandlers()
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1e70c8)
>  #2 0x3fff7fe6a49c SignalHandler(int)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1ea49c)
>  #3 0x3fff82030478  0x478 abort
>  #4 0x3fff82030478
>  #5 0x3fff82030478 __assert_fail_base (+0x478)
>  #6 0x3fff7e0a1f94 __assert_fail (/lib64/libc.so.6+0x41f94)
>  #7 0x3fff7e0955d4
> clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
> clang::FunctionDecl*, bool, bool, bool) (/lib64/libc.so.6+0x355d4)
>  #8 0x3fff7e0956c4
> clang::Sema::ActOnExplicitInstantiation(clang::Scope*,
> clang::SourceLocation, clang::SourceLocation, clang::Declarator&)
> (/lib64/libc.so.6+0x356c4)
>  #9 0x3fff7c28d604
> clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
> clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangSema.so.10svn+0x8ad604)
> #10 0x3fff7c15c2b0
> clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&,
> clang::Parser::ParsedTemplateInfo const&)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangSema.so.10svn+0x77c2b0)
> #11 0x3fff7c4cc8f8
> clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
> clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
> clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x4c8f8)
> #12 0x3fff7c4cdf48
> clang::Parser::ParseExplicitInstantiation(clang::DeclaratorContext,
> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&,
> clang::ParsedAttributes&, clang::AccessSpecifier)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x4df48)
> #13 0x3fff7c57c1f0
> clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
> clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfc1f0)
> #14 0x3fff7c57a6c0
> clang::Parser::ParseDeclaration(clang::DeclaratorContext,
> clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
> clang::SourceLocation*)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfa6c0)
> #15 0x3fff7c57a4f8
> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
> clang::ParsingDeclSpec*)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfa4f8)
> #16 0x3fff7c4c5db0
> clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&,
> bool)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x45db0)
> #17 0x3fff7c58fffc clang::ParseAST(clang::Sema&, bool, bool)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x10fffc)
> #18 0x3fff7c58def4 clang::ASTFrontendAction::ExecuteAction()
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x10def4)
> #19 0x3fff7c4b01e0 clang::FrontendAction::Execute()
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x301e0)
> #20 0x3fff7e93d57c
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libclangFrontend.so.10svn+0x10d57c)
> #21 

[clang] 4cba668 - Fix crash-on-invalid when trying to recover from a function template

2020-03-10 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-10T16:34:27-07:00
New Revision: 4cba668ac13433ce295ee101a920365fba6f20de

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

LOG: Fix crash-on-invalid when trying to recover from a function template
being deleted on its second or subsequent declaration.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 7331c3369744..2dfefa386e65 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16349,9 +16349,16 @@ void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation 
DelLoc) {
   Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
Prev->isImplicit() ? diag::note_previous_implicit_declaration
   : diag::note_previous_declaration);
+  // We can't recover from this; the declaration might have already
+  // been used.
+  Fn->setInvalidDecl();
+  return;
 }
-// If the declaration wasn't the first, we delete the function anyway for
-// recovery.
+
+// To maintain the invariant that functions are only deleted on their first
+// declaration, mark the implicitly-instantiated declaration of the
+// explicitly-specialized function as deleted instead of marking the
+// instantiated redeclaration.
 Fn = Fn->getCanonicalDecl();
   }
 

diff  --git a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp 
b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
index 7a581fd519a9..1ec484ab1e5e 100644
--- a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -199,3 +199,15 @@ S::S() __attribute((pure)) = default;
 using size_t = decltype(sizeof(0));
 void *operator new(size_t) = delete; // expected-error {{deleted definition 
must be first declaration}} expected-note {{implicit}}
 void operator delete(void *) noexcept = delete; // expected-error {{deleted 
definition must be first declaration}} expected-note {{implicit}}
+
+// FIXME: Diagnosing the call as "no matching function" due to substitution
+// failure is not ideal.
+template void delete_template_too_late(); // expected-note 
{{previous}}
+template void delete_template_too_late() = delete; // 
expected-error {{must be first decl}} expected-note {{substitution failure}}
+void use_template_deleted_too_late() { delete_template_too_late(); } // 
expected-error {{no matching function}}
+
+struct DeletedMemberTemplateTooLate {
+  template static void f(); // expected-note {{previous}}
+};
+template void DeletedMemberTemplateTooLate::f() = delete; // 
expected-error {{must be first decl}} expected-note {{substitution failure}}
+void use_member_template_deleted_too_late() { 
DeletedMemberTemplateTooLate::f(); } // expected-error {{no matching 
function}}



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


[PATCH] D75922: [ASTImporter] Compare the DC of the underlying type of a FriendDecl

2020-03-10 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a subscriber: rsmith.
shafik added a comment.

I believe that your main example violates basic.scope.class p2 
:

> A name N used in a class S shall refer to the same declaration in its context 
> and when re-evaluated in the completed scope of S.
>  No diagnostic is required for a violation of this rule.

Although it is ill-formed no diagnostic required.

CC @rsmith




Comment at: clang/lib/AST/ASTImporter.cpp:3637
+// is a dependent type then the returned optional does not have a value.
+static Optional getDCOfUnderlyingDecl(FriendDecl *FrD) {
+  if (NamedDecl *ND = FrD->getFriendDecl())

It looks like we use `FriendDecl *D` in other places, we should try to be 
consistent across the file. 

I would not be against changing it but perhaps in a different PR?



Comment at: clang/lib/AST/ASTImporter.cpp:3656
+  // DependentType
+  return Optional();
+}

`return {}`;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75922



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


[PATCH] D45805: [libcxx] Remove redundant specializations in type_traits.

2020-03-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: libcxx-commits, dexonsmith.

LGTM, but you'll need to rebase this


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D45805



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


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I've started to update the patch to be in line with the direction discussed in 
the issue.

@sammccall, how would you like to proceed logistically:

- Do you plan to land (a possibly modified version of) D75479 
?
- Or should I combine that patch into this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72874



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


[clang] 218dd33 - Add triple for non-x86 environments.

2020-03-10 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2020-03-10T15:26:03-07:00
New Revision: 218dd339541f574f76d7310f6c3269bfe3262d08

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

LOG: Add triple for non-x86 environments.

Added: 


Modified: 
clang/test/Analysis/uninit-asm-goto.cpp

Removed: 




diff  --git a/clang/test/Analysis/uninit-asm-goto.cpp 
b/clang/test/Analysis/uninit-asm-goto.cpp
index 136b210b8866..43438dc589be 100644
--- a/clang/test/Analysis/uninit-asm-goto.cpp
+++ b/clang/test/Analysis/uninit-asm-goto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wuninitialized -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++11 -Wuninitialized 
-verify %s
 
 // test1: Expect no diagnostics
 int test1(int x) {



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


[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

You've sold me on `AnyError`, we should have something like that with the 
addition of `NoteTags`. With that said, I feel uneasy about adding it in this 
patch and not testing it properly. I can also sympathize with your anxiety 
against bloating the `fseek` patch further by simply moving the code there, but 
I'm just not sure there is a good way to avoid it. I have a suggestion:

1. Remove the code that adds and handles `AnyError`. Merge the two enums in the 
`StreamState`, and make `ensureSteamOpened` emit a warning if the stream is 
either `feof()` or `ferror()`. Add `NoteTags` saying something along the lines 
of:

  if (feof(F)) { // note: Assuming the condition is true
 // note: Stream 'F' has the EOF flag set
fgets(F); // warning: Illegal stream operation on a stream that has EOF set
  }

I think that would make this a very neat, self contained patch.

2. Add the removed code to the fseek patch (preferably with the name 
`UnknownError`). Make `ensureSteamOpened` emit a warning on this enum value as 
well. I don't think it would bloat the patch too much -- we just simply need 
that much to make sense of it.

What do you think?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:33-45
+  enum KindTy {
+Opened, /// Stream is opened.
+Closed, /// Closed stream (an invalid stream pointer after it was closed).
+OpenFailed /// The last open operation has failed.
+  } State;
+
+  /// The error state of a stream.

balazske wrote:
> Szelethus wrote:
> > Hmm, now that I think of it, could we just merge these 2 enums? Also, I 
> > fear that indexers would accidentally assign the comment to the enum after 
> > the comma:
> > 
> > ```lang=cpp
> > Opened, /// Stream is opened.
> > Closed, /// Closed stream (an invalid stream pointer after it was 
> > closed).
> > OpenFailed /// The last open operation has failed.
> > ```
> > ` /// Stream is opened` might be assigned to `Closed`. How about this:
> > ```lang=cpp
> > /// Stream is opened.
> > Opened,
> > /// Closed stream (an invalid stream pointer after it was closed).
> > Closed,
> > /// The last open operation has failed.
> > OpenFailed
> > ```
> Probably these can be merged, it is used for a stream that is in an 
> indeterminate state after failed `freopen`, but practically it is handled the 
> same way as a closed stream. But this change would be done in another 
> revision.
I meant to merge the two enums (`StreamState` and `ErrorKindTy`) and the fields 
associated with them (`State` and `ErrorState`). We could however merge 
`Closed` and `OpenFailed`, granted that we put a `NoteTag` to `evalFreopen`. 
But I agree, that should be another revision's topic :)



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:44
+OtherError, /// Other (non-EOF) error (`ferror` is true).
+AnyError/// EofError or OtherError, used if exact error is unknown.
+  } ErrorState = NoError;

balazske wrote:
> Szelethus wrote:
> > When do we know that the stream is in an error state, but not precisely 
> > know what that error is within the context of this patch?  `fseek` would 
> > indeed introduce such a state, as described in D75356#inline-689287, but 
> > that should introduce its own error `ErrorKind`. I still don't really get 
> > why we would ever need `AnyError`.
> This is the problem is the change is too small: The next part of it 
> introduces functions where the new error flags are used. In this patch the 
> AnyError feature is not used (the feof and ferror read it but nothing sets 
> it).
Okay, after your comment in the other revision, I see how such a kind should be 
left, and the bug report should rather be enriched by `NoteTags`. With that 
said, `AnyError` is still a bit confusing as a name -- how abour `UnknownError`?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:51
+
+  bool isNoError() const { return ErrorState == NoError; }
+  bool isEofError() const { return ErrorState == EofError; }

If a stream's opening failed, its still an error, yet this getter would return 
true for it. I think this is yet another reason to just merge the 2 enums :)



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:54
+  bool isOtherError() const { return ErrorState == OtherError; }
+  bool isAnyError() const { return ErrorState == AnyError; }
+

balazske wrote:
> Szelethus wrote:
> > This is confusing -- I would expect a method called `isAnyError()` to 
> > return true when `isNoError()` is false.
> The error state kinds are not mutually exclusive. The "any error" means we 
> know that there is some error but we do not know what the error is (it is not 
> relevant because nothing was done that depends on it). If a function is 
> called that needs to know if "ferror" or "feof" is the error, the 

RE: [clang-tools-extra] ebdb98f - [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.

2020-03-10 Thread Voss, Matthew via cfe-commits
Hi Paula,

The tests in this commit are failing on the PS4 Windows bot and our internal 
CI. Could you take a look?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

Thanks,
Matthew

> -Original Message-
> From: cfe-commits  On Behalf Of Paula
> Toth via cfe-commits
> Sent: Tuesday, March 10, 2020 1:34 PM
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] ebdb98f - [clang-tidy] Move fuchsia-restrict-
> system-includes to portability module for general use.
> 
> 
> Author: Paula Toth
> Date: 2020-03-10T13:33:06-07:00
> New Revision: ebdb98f254f632b506109b9d20c6e8e19697765f
> 
> URL: https://github.com/llvm/llvm-
> project/commit/ebdb98f254f632b506109b9d20c6e8e19697765f
> DIFF: https://github.com/llvm/llvm-
> project/commit/ebdb98f254f632b506109b9d20c6e8e19697765f.diff
> 
> LOG: [clang-tidy] Move fuchsia-restrict-system-includes to portability
> module for general use.
> 
> Summary:
> Created a general check for restrict-system-includes under portability as
> recommend in the comments under D75332. I also fleshed out the user facing
> documentation to show examples for common use-cases such as allow-list,
> block-list, and wild carding.
> 
> Removed fuchsia's check as per phosek sugguestion.
> 
> Reviewers: aaron.ballman, phosek, alexfh, hokein, njames93
> 
> Reviewed By: phosek
> 
> Subscribers: Eugene.Zelenko, mgorny, xazax.hun, phosek, cfe-commits,
> MaskRay
> 
> Tags: #clang-tools-extra, #clang
> 
> Differential Revision: https://reviews.llvm.org/D75786
> 
> Added:
> clang-tools-extra/clang-
> tidy/portability/RestrictSystemIncludesCheck.cpp
> clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
> clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-
> includes.rst
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/a.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/cstdarg.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/cstdlib.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/j.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/r.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/s.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/t.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/system/transitive.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-
> restrict-system-includes/transitive2.h
> clang-tools-extra/test/clang-tidy/checkers/portability-restrict-
> system-includes-allow.cpp
> clang-tools-extra/test/clang-tidy/checkers/portability-restrict-
> system-includes-disallow.cpp
> clang-tools-extra/test/clang-tidy/checkers/portability-restrict-
> system-includes-glob.cpp
> clang-tools-extra/test/clang-tidy/checkers/portability-restrict-
> system-includes-transitive.cpp
> 
> Modified:
> clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
> clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
> clang-tools-extra/clang-tidy/portability/CMakeLists.txt
> clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
> clang-tools-extra/docs/ReleaseNotes.rst
> clang-tools-extra/docs/clang-tidy/checks/list.rst
> 
> Removed:
> clang-tools-extra/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
> clang-tools-extra/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h
> clang-tools-extra/docs/clang-tidy/checks/fuchsia-restrict-system-
> includes.rst
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/a.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/cstdarg.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/cstdlib.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/j.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/r.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/s.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/t.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/system/transitive.h
> clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-
> system-includes/transitive2.h
> clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-
> includes-all.cpp
> clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-
> includes-glob.cpp
> 

[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D75890#1915493 , @thakis wrote:

> `__FILE__` only expands to an absolute path if you pass an absolute path to 
> clang (ctrl-f "__FILE__" on 
> http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html).


Yes, but unfortunately that's what CMake does by default (that is using 
absolute paths) so we have to deal with that somehow since CMake is still the 
official build system.

> It feels like this is working around a deficiency in the compiler. Maybe 
> fixing whatever's going wrong in the compiler might be better? (There's also 
> -ffile-file-prefix map, but using that makes your _commandline_ depend on the 
> name of the build dir, and (in clang) `__FILE_NAME__ `.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890



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


[PATCH] D75934: Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI)

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2295
   Group, Flags<[CoreOption]>;
+def mlvi_cfi : Flag<["-"], "mlvi-cfi">, Group, 
Flags<[CoreOption,DriverOption]>;
+def mno_lvi_cfi : Flag<["-"], "mno-lvi-cfi">, Group, 
Flags<[CoreOption,DriverOption]>;

Please add HelpText to these. It seems we've been bad about this and the lack 
of HelpText prevents the options from showing up in clang -help


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

https://reviews.llvm.org/D75934



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


[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D75890#1915493 , @thakis wrote:

> `__FILE__` only expands to an absolute path if you pass an absolute path to 
> clang (ctrl-f "__FILE__" on 
> http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html).
>
> It feels like this is working around a deficiency in the compiler. Maybe 
> fixing whatever's going wrong in the compiler might be better? (There's also 
> -ffile-file-prefix map, but using that makes your _commandline_ depend on the 
> name of the build dir, and (in clang) `__FILE_NAME__ `.


Using `-ffile-prefix-map` for LLVM builds in general seems to be the better 
option, but we thought this was simpler since it seemed to only be libunwind 
that had this non-determinism.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890



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


[clang] 5c845c1 - PR45083: Mark statement expressions as being dependent if they appear in

2020-03-10 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-10T14:45:04-07:00
New Revision: 5c845c1c50ac89a6f12557d1571678f3d1432478

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

LOG: PR45083: Mark statement expressions as being dependent if they appear in
a dependent context.

This matches the GCC behavior.

We track the enclosing template depth when determining whether a
statement expression is within a dependent context; there doesn't appear
to be any other reliable way to determine this.

We previously assumed they were neither value- nor
instantiation-dependent under any circumstances, which would lead to
crashes and other misbehavior.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Stmt.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/AST/ASTImporter.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 7271dbb830a2..b1f17631c892 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3959,14 +3959,18 @@ class StmtExpr : public Expr {
   Stmt *SubStmt;
   SourceLocation LParenLoc, RParenLoc;
 public:
-  // FIXME: Does type-dependence need to be computed 
diff erently?
-  // FIXME: Do we need to compute instantiation instantiation-dependence for
-  // statements? (ugh!)
-  StmtExpr(CompoundStmt *substmt, QualType T,
-   SourceLocation lp, SourceLocation rp) :
-Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
- T->isDependentType(), false, false, false),
-SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
+  StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParenLoc,
+   SourceLocation RParenLoc, unsigned TemplateDepth)
+  : // We treat a statement-expression in a dependent context as
+// always being value- and instantiation-dependent. This matches the
+// behavior of lambda-expressions and GCC.
+Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),
+ TemplateDepth != 0, TemplateDepth != 0, false),
+SubStmt(SubStmt), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
+// FIXME: A templated statement expression should have an associated
+// DeclContext so that nested declarations always have a dependent context.
+StmtExprBits.TemplateDepth = TemplateDepth;
+  }
 
   /// Build an empty statement expression.
   explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
@@ -3983,6 +3987,8 @@ class StmtExpr : public Expr {
   SourceLocation getRParenLoc() const { return RParenLoc; }
   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
 
+  unsigned getTemplateDepth() const { return StmtExprBits.TemplateDepth; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == StmtExprClass;
   }

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 5191a8261f86..dd1084623e9c 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -589,6 +589,18 @@ class alignas(void *) Stmt {
 unsigned Kind : 2;
   };
 
+  class StmtExprBitfields {
+friend class ASTStmtReader;
+friend class StmtExpr;
+
+unsigned : NumExprBits;
+
+/// The number of levels of template parameters enclosing this statement
+/// expression. Used to determine if a statement expression remains
+/// dependent after instantiation.
+unsigned TemplateDepth;
+  };
+
   //===--- C++ Expression bitfields classes ---===//
 
   class CXXOperatorCallExprBitfields {
@@ -997,6 +1009,9 @@ class alignas(void *) Stmt {
 PseudoObjectExprBitfields PseudoObjectExprBits;
 SourceLocExprBitfields SourceLocExprBits;
 
+// GNU Extensions.
+StmtExprBitfields StmtExprBits;
+
 // C++ Expressions
 CXXOperatorCallExprBitfields CXXOperatorCallExprBits;
 CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d24dfe563bd2..cf02362e86ba 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -630,6 +630,15 @@ class Sema final {
   /// function, block, and method scopes that are currently active.
   SmallVector FunctionScopes;
 
+  /// The index of the first FunctionScope that corresponds to the current
+  /// context.
+  unsigned FunctionScopesStart = 0;
+
+  ArrayRef getFunctionScopes() 

[clang] 75af694 - [CodeGenObjC] Place property names in __objc_methname

2020-03-10 Thread Erik Pilkington via cfe-commits

Author: Erik Pilkington
Date: 2020-03-10T14:31:00-07:00
New Revision: 75af694a6da5157cc6a688c2fa77ff5200f46e11

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

LOG: [CodeGenObjC] Place property names in __objc_methname

This allows the property name to deduplicate with the accessor method name.
rdar://58927964

Added: 


Modified: 
clang/lib/CodeGen/CGObjCMac.cpp
clang/test/CodeGenObjC/metadata-symbols-64.m

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index d6cfe41a9c87..0ab4fd8e224c 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -4225,7 +4225,8 @@ CGObjCCommonMac::CreateCStringLiteral(StringRef Name, 
ObjCLabelType Type,
  : "__TEXT,__cstring,cstring_literals";
 break;
   case ObjCLabelType::PropertyName:
-Section = "__TEXT,__cstring,cstring_literals";
+Section = NonFragile ? "__TEXT,__objc_methname,cstring_literals"
+ : "__TEXT,__cstring,cstring_literals";
 break;
   }
 

diff  --git a/clang/test/CodeGenObjC/metadata-symbols-64.m 
b/clang/test/CodeGenObjC/metadata-symbols-64.m
index bf02053013ab..3ff3261053a8 100644
--- a/clang/test/CodeGenObjC/metadata-symbols-64.m
+++ b/clang/test/CodeGenObjC/metadata-symbols-64.m
@@ -17,7 +17,7 @@
 // CHECK: @"_OBJC_METACLASS_RO_$_A" = internal global {{.*}} section "__DATA, 
__objc_const", align 8
 // CHECK: @"_OBJC_$_INSTANCE_METHODS_A" = internal global {{.*}} section 
"__DATA, __objc_const", align 8
 // CHECK: @"_OBJC_$_INSTANCE_VARIABLES_A" = internal global {{.*}} section 
"__DATA, __objc_const", align 8
-// CHECK: @OBJC_PROP_NAME_ATTR_{{[0-9]*}} = private unnamed_addr constant 
{{.*}} section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK: @OBJC_PROP_NAME_ATTR_{{[0-9]*}} = private unnamed_addr constant 
{{.*}} section "__TEXT,__objc_methname,cstring_literals", align 1
 // CHECK: @"_OBJC_$_PROP_LIST_A" = internal global {{.*}} section "__DATA, 
__objc_const", align 8
 // CHECK: @"_OBJC_CLASS_RO_$_A" = internal global {{.*}} section "__DATA, 
__objc_const", align 8
 // CHECK: @"_OBJC_$_CATEGORY_INSTANCE_METHODS_A_$_Cat" = internal global 
{{.*}} section "__DATA, __objc_const", align 8



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


[clang] 9769e1e - [Concepts] Fix incorrect DeclContext for transformed RequiresExprBodyDecl

2020-03-10 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-03-10T23:17:00+02:00
New Revision: 9769e1ee9acc33638449b50ac394b5ee2d4efb60

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

LOG: [Concepts] Fix incorrect DeclContext for transformed RequiresExprBodyDecl

We would assign the incorrect DeclContext when transforming the 
RequiresExprBodyDecl, causing incorrect
handling of 'this' inside RequiresExprBodyDecls (bug #45162).

Assign the current context as the DeclContext of the transformed decl.

Added: 


Modified: 
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/instantiate-requires-expr.cpp

Removed: 




diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 002b73c3a1dd..0497a0df149a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11380,7 +11380,7 @@ 
TreeTransform::TransformRequiresExpr(RequiresExpr *E) {
   SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
 
   RequiresExprBodyDecl *Body = RequiresExprBodyDecl::Create(
-  getSema().Context, E->getBody()->getDeclContext(),
+  getSema().Context, getSema().CurContext,
   E->getBody()->getBeginLoc());
 
   Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);

diff  --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp 
b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index 927bc1bf8f12..ba82fc1313fc 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -164,6 +164,19 @@ namespace expr_requirement {
   struct r3 {};
 
   using r3i = r3; // expected-error{{constraints not 
satisfied for class template 'r3' [with Ts = ]}}
+
+  template
+  struct r4 {
+  constexpr int foo() {
+if constexpr (requires { this->invalid(); })
+  return 1;
+else
+  return 0;
+  }
+
+  constexpr void invalid() requires false { }
+  };
+  static_assert(r4{}.foo() == 0);
 }
 
 namespace nested_requirement {



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


[PATCH] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-10 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ahatanak marked an inline comment as done.
Closed by commit rG40568fec7e3e: [CodeGen] Emit destructor calls to destruct 
compound literals (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D64464?vs=249173=249500#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64464

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-objc-arc-json.m
  clang/test/AST/ast-dump-stmt.m
  clang/test/CodeGenObjC/arc-ternary-op.m
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/strong-in-c-struct.m
  clang/test/Import/objc-arc/Inputs/cleanup-objects.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/PCH/non-trivial-c-compound-literal.m
  clang/test/SemaObjC/strong-in-c-struct.m
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -64,6 +64,9 @@
   llvm::cl::desc("The language to parse (default: c++)"),
   llvm::cl::init("c++"));
 
+static llvm::cl::opt ObjCARC("objc-arc", llvm::cl::init(false),
+   llvm::cl::desc("Emable ObjC ARC"));
+
 static llvm::cl::opt DumpAST("dump-ast", llvm::cl::init(false),
llvm::cl::desc("Dump combined AST"));
 
@@ -183,6 +186,8 @@
   Inv->getLangOpts()->ObjC = 1;
 }
   }
+  Inv->getLangOpts()->ObjCAutoRefCount = ObjCARC;
+
   Inv->getLangOpts()->Bool = true;
   Inv->getLangOpts()->WChar = true;
   Inv->getLangOpts()->Blocks = true;
Index: clang/test/SemaObjC/strong-in-c-struct.m
===
--- clang/test/SemaObjC/strong-in-c-struct.m
+++ clang/test/SemaObjC/strong-in-c-struct.m
@@ -54,3 +54,21 @@
   func(^{ func2(x); });
   goto *ips; // expected-error {{cannot jump}}
 }
+
+void test_compound_literal0(int cond, id x) {
+  switch (cond) {
+  case 0:
+(void)(Strong){ .a = x }; // expected-note {{jump enters lifetime of a compound literal that is non-trivial to destruct}}
+break;
+  default: // expected-error {{cannot jump from switch statement to this case label}}
+break;
+  }
+}
+
+void test_compound_literal1(id x) {
+  static void *ips[] = { & };
+L0:  // expected-note {{possible target of indirect goto}}
+  ;
+  (void)(Strong){ .a = x }; // expected-note {{jump exits lifetime of a compound literal that is non-trivial to destruct}}
+  goto *ips; // expected-error {{cannot jump}}
+}
Index: clang/test/PCH/non-trivial-c-compound-literal.m
===
--- /dev/null
+++ clang/test/PCH/non-trivial-c-compound-literal.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -fobjc-arc -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -fobjc-arc -include-pch %t -emit-llvm -o - %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef struct {
+  id f;
+} S;
+
+static inline id getObj(id a) {
+  S *p = &(S){ .f = a };
+  return p->f;
+}
+
+#else
+
+// CHECK: %[[STRUCT_S:.*]] = type { i8* }
+
+// CHECK: define internal i8* @getObj(
+// CHECK: %[[_COMPOUNDLITERAL:.*]] = alloca %[[STRUCT_S]],
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_S]]* %[[_COMPOUNDLITERAL]] to i8**
+// CHECK: call void @__destructor_8_s0(i8** %[[V5]])
+
+id test(id a) {
+  return getObj(a);
+}
+
+#endif
Index: clang/test/Import/objc-arc/test-cleanup-object.m
===
--- /dev/null
+++ clang/test/Import/objc-arc/test-cleanup-object.m
@@ -0,0 +1,10 @@
+// RUN: clang-import-test -x objective-c -objc-arc -import %S/Inputs/cleanup-objects.m -dump-ast -expression %s | FileCheck %s
+
+// CHECK: FunctionDecl {{.*}} getObj '
+// CHECK: ExprWithCleanups
+// CHECK-NEXT: cleanup CompoundLiteralExpr
+
+void test(int c, id a) {
+  (void)getObj(c, a);
+}
+
Index: clang/test/Import/objc-arc/Inputs/cleanup-objects.m
===
--- /dev/null
+++ clang/test/Import/objc-arc/Inputs/cleanup-objects.m
@@ -0,0 

[PATCH] D75959: [clangd] Run clang-format on CodeComplete.cpp and SourceCodeTests.cpp

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG484402abaca2: [clangd] Run clang-format on CodeComplete.cpp 
and SourceCodeTests.cpp (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75959

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -215,8 +215,9 @@
 for (unsigned I = 0; I <= L.Length; ++I)
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, I)),
llvm::HasValue(L.Offset + I));
-EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, 
L.Length+1)),
- llvm::HasValue(L.Offset + L.Length));
+EXPECT_THAT_EXPECTED(
+positionToOffset(File, position(L.Number, L.Length + 1)),
+llvm::HasValue(L.Offset + L.Length));
 EXPECT_THAT_EXPECTED(
 positionToOffset(File, position(L.Number, L.Length + 1), false),
 llvm::Failed()); // out of range
@@ -413,7 +414,7 @@
   {""},
   },
   };
-  for (const auto& Case : Cases) {
+  for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
   visibleNamespaces(Case.first, format::getLLVMStyle()))
 << Case.first;
@@ -450,7 +451,7 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
-TEST(SourceCodeTests, IsInsideMainFile){
+TEST(SourceCodeTests, IsInsideMainFile) {
   TestTU TU;
   TU.HeaderCode = R"cpp(
 #define DEFINE_CLASS(X) class X {};
@@ -471,7 +472,7 @@
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
   auto DeclLoc = [](llvm::StringRef Name) {
 return findDecl(AST, Name).getLocation();
   };
@@ -574,7 +575,7 @@
   TU.AdditionalFiles["foo.inc"] = "int foo;\n";
   TU.AdditionalFiles["bar.inc"] = "int bar;\n";
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
 
   FileID Foo = SM.getFileID(findDecl(AST, "foo").getLocation());
   EXPECT_EQ(SM.getFileOffset(includeHashLoc(Foo, SM)),
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1776,8 +1776,7 @@
   Options.IncludeBriefComments = false;
   IncludeStructure PreambleInclusions; // Unused for signatureHelp
   semaCodeComplete(
-  std::make_unique(Options, Index, Result),
-  Options,
+  std::make_unique(Options, Index, Result), 
Options,
   {FileName, Command, Preamble, Contents, *Offset, std::move(VFS)});
   return Result;
 }


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -215,8 +215,9 @@
 for (unsigned I = 0; I <= L.Length; ++I)
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, I)),
llvm::HasValue(L.Offset + I));
-EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, L.Length+1)),
- llvm::HasValue(L.Offset + L.Length));
+EXPECT_THAT_EXPECTED(
+positionToOffset(File, position(L.Number, L.Length + 1)),
+llvm::HasValue(L.Offset + L.Length));
 EXPECT_THAT_EXPECTED(
 positionToOffset(File, position(L.Number, L.Length + 1), false),
 llvm::Failed()); // out of range
@@ -413,7 +414,7 @@
   {""},
   },
   };
-  for (const auto& Case : Cases) {
+  for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
   visibleNamespaces(Case.first, format::getLLVMStyle()))
 << Case.first;
@@ -450,7 +451,7 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
-TEST(SourceCodeTests, IsInsideMainFile){
+TEST(SourceCodeTests, IsInsideMainFile) {
   TestTU TU;
   TU.HeaderCode = R"cpp(
 #define DEFINE_CLASS(X) class X {};
@@ -471,7 +472,7 @@
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
   auto DeclLoc = [](llvm::StringRef Name) {
 return findDecl(AST, Name).getLocation();
   };
@@ -574,7 +575,7 @@
   TU.AdditionalFiles["foo.inc"] = "int foo;\n";
   TU.AdditionalFiles["bar.inc"] = "int bar;\n";
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
 
   FileID Foo = 

[PATCH] D71314: Warn of uninitialized variables on asm goto's indirect branch

2020-03-10 Thread Bill Wendling via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG72aa619a7fe0: Warn of uninitialized variables on asm 
gotos indirect branch (authored by void).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71314

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Analysis/uninit-asm-goto.cpp

Index: clang/test/Analysis/uninit-asm-goto.cpp
===
--- clang/test/Analysis/uninit-asm-goto.cpp
+++ clang/test/Analysis/uninit-asm-goto.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -Wuninitialized -verify %s
-// expected-no-diagnostics
 
+// test1: Expect no diagnostics
 int test1(int x) {
 int y;
 asm goto("nop" : "=r"(y) : "r"(x) : : err);
@@ -8,3 +8,52 @@
   err:
 return -1;
 }
+
+int test2(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  if (x < 42)
+asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
+  else
+asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2);
+  return x + y;
+indirect_1:
+  return -42;
+indirect_2:
+  return y; // expected-note {{uninitialized use occurs here}}
+}
+
+int test3(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  asm goto("xorl %1, %0; jmp %l2" : "="(y) : "r"(x) : : fail);
+normal:
+  y += x;
+  return y;
+  if (x) {
+fail:
+return y; // expected-note {{uninitialized use occurs here}}
+  }
+  return 0;
+}
+
+int test4(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  goto forward;
+backward:
+  return y; // expected-note {{uninitialized use occurs here}}
+forward:
+  asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : backward);
+  return y;
+}
+
+// test5: Expect no diagnostics
+int test5(int x) {
+  int y;
+  asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough);
+fallthrough:
+  return y;
+indirect:
+  return -2;
+}
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -576,6 +576,28 @@
   continue;
 }
 
+if (AtPredExit == MayUninitialized) {
+  // If the predecessor's terminator is an "asm goto" that initializes
+  // the variable, then it won't be counted as "initialized" on the
+  // non-fallthrough paths.
+  CFGTerminator term = Pred->getTerminator();
+  if (const auto *as = dyn_cast_or_null(term.getStmt())) {
+const CFGBlock *fallthrough = *Pred->succ_begin();
+if (as->isAsmGoto() &&
+llvm::any_of(as->outputs(), [&](const Expr *output) {
+return vd == findVar(output).getDecl() &&
+llvm::any_of(as->labels(),
+ [&](const AddrLabelExpr *label) {
+  return label->getLabel()->getStmt() == B->Label &&
+  B != fallthrough;
+});
+})) {
+  Use.setUninitAfterDecl();
+  continue;
+}
+  }
+}
+
 unsigned  = SuccsVisited[Pred->getBlockID()];
 if (!SV) {
   // When visiting the first successor of a block, mark all NULL
@@ -768,7 +790,11 @@
 
   for (const Expr *o : as->outputs())
 if (const VarDecl *VD = findVar(o).getDecl())
-  vals[VD] = Initialized;
+  if (vals[VD] != Initialized)
+// If the variable isn't initialized by the time we get here, then we
+// mark it as potentially uninitialized for those cases where it's used
+// on an indirect path, where it's not guaranteed to be defined.
+vals[VD] = MayUninitialized;
 }
 
 void TransferFunctions::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
@@ -809,7 +835,7 @@
   tf.Visit(const_cast(cs->getStmt()));
   }
   CFGTerminator terminator = block->getTerminator();
-  if (GCCAsmStmt *as = dyn_cast_or_null(terminator.getStmt()))
+  if (auto *as = dyn_cast_or_null(terminator.getStmt()))
 if (as->isAsmGoto())
   tf.Visit(as);
   return vals.updateValueVectorWithScratch(block);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75716: [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG445195ba6cee: [clangd] Have visibleNamespaces() and 
getEligiblePoints() take a LangOptions… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75716

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -416,7 +416,8 @@
   };
   for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
-  visibleNamespaces(Case.first, format::getLLVMStyle()))
+  visibleNamespaces(Case.first, format::getFormattingLangOpts(
+format::getLLVMStyle(
 << Case.first;
   }
 }
@@ -639,8 +640,9 @@
   for (auto Case : Cases) {
 Annotations Test(Case.Code);
 
-auto Res = getEligiblePoints(Test.code(), Case.FullyQualifiedName,
- format::getLLVMStyle());
+auto Res = getEligiblePoints(
+Test.code(), Case.FullyQualifiedName,
+format::getFormattingLangOpts(format::getLLVMStyle()));
 EXPECT_THAT(Res.EligiblePoints, testing::ElementsAreArray(Test.points()))
 << Test.code();
 EXPECT_EQ(Res.EnclosingNamespace, Case.EnclosingNamespace) << Test.code();
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -284,10 +284,10 @@
 // should also try to follow ordering of declarations. For example, if decls
 // come in order `foo, bar, baz` then this function should return some point
 // between foo and baz for inserting bar.
-llvm::Expected
-getInsertionPoint(llvm::StringRef Contents, llvm::StringRef QualifiedName,
-  const format::FormatStyle ) {
-  auto Region = getEligiblePoints(Contents, QualifiedName, Style);
+llvm::Expected getInsertionPoint(llvm::StringRef Contents,
+ llvm::StringRef QualifiedName,
+ const LangOptions ) {
+  auto Region = getEligiblePoints(Contents, QualifiedName, LangOpts);
 
   assert(!Region.EligiblePoints.empty());
   // FIXME: This selection can be made smarter by looking at the definition
@@ -416,9 +416,10 @@
   return llvm::createStringError(Buffer.getError(),
  Buffer.getError().message());
 auto Contents = Buffer->get()->getBuffer();
-auto InsertionPoint =
-getInsertionPoint(Contents, Source->getQualifiedNameAsString(),
-  getFormatStyleForFile(*CCFile, Contents, ));
+auto LangOpts = format::getFormattingLangOpts(
+getFormatStyleForFile(*CCFile, Contents, ));
+auto InsertionPoint = getInsertionPoint(
+Contents, Source->getQualifiedNameAsString(), LangOpts);
 if (!InsertionPoint)
   return InsertionPoint.takeError();
 
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -250,7 +250,7 @@
 ///
 /// visibleNamespaces are {"foo::", "", "a::", "b::", "foo::b::"}, not "a::b::".
 std::vector visibleNamespaces(llvm::StringRef Code,
-   const format::FormatStyle );
+   const LangOptions );
 
 /// Represents locations that can accept a definition.
 struct EligibleRegion {
@@ -271,7 +271,7 @@
 /// \p FullyQualifiedName should not contain anonymous namespaces.
 EligibleRegion getEligiblePoints(llvm::StringRef Code,
  llvm::StringRef FullyQualifiedName,
- const format::FormatStyle );
+ const LangOptions );
 
 struct DefinedMacro {
   llvm::StringRef Name;
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -654,8 +654,7 @@
   Position Pos;
 };
 // Scans C++ source code for constructs that change the visible namespaces.
-void parseNamespaceEvents(llvm::StringRef Code,
-  const format::FormatStyle ,
+void parseNamespaceEvents(llvm::StringRef Code, const LangOptions ,
   llvm::function_ref Callback) {
 
  

[PATCH] D75716: [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 249495.
nridge marked 6 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75716

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -416,7 +416,8 @@
   };
   for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
-  visibleNamespaces(Case.first, format::getLLVMStyle()))
+  visibleNamespaces(Case.first, format::getFormattingLangOpts(
+format::getLLVMStyle(
 << Case.first;
   }
 }
@@ -639,8 +640,9 @@
   for (auto Case : Cases) {
 Annotations Test(Case.Code);
 
-auto Res = getEligiblePoints(Test.code(), Case.FullyQualifiedName,
- format::getLLVMStyle());
+auto Res = getEligiblePoints(
+Test.code(), Case.FullyQualifiedName,
+format::getFormattingLangOpts(format::getLLVMStyle()));
 EXPECT_THAT(Res.EligiblePoints, testing::ElementsAreArray(Test.points()))
 << Test.code();
 EXPECT_EQ(Res.EnclosingNamespace, Case.EnclosingNamespace) << Test.code();
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -284,10 +284,10 @@
 // should also try to follow ordering of declarations. For example, if decls
 // come in order `foo, bar, baz` then this function should return some point
 // between foo and baz for inserting bar.
-llvm::Expected
-getInsertionPoint(llvm::StringRef Contents, llvm::StringRef QualifiedName,
-  const format::FormatStyle ) {
-  auto Region = getEligiblePoints(Contents, QualifiedName, Style);
+llvm::Expected getInsertionPoint(llvm::StringRef Contents,
+ llvm::StringRef QualifiedName,
+ const LangOptions ) {
+  auto Region = getEligiblePoints(Contents, QualifiedName, LangOpts);
 
   assert(!Region.EligiblePoints.empty());
   // FIXME: This selection can be made smarter by looking at the definition
@@ -416,9 +416,10 @@
   return llvm::createStringError(Buffer.getError(),
  Buffer.getError().message());
 auto Contents = Buffer->get()->getBuffer();
-auto InsertionPoint =
-getInsertionPoint(Contents, Source->getQualifiedNameAsString(),
-  getFormatStyleForFile(*CCFile, Contents, ));
+auto LangOpts = format::getFormattingLangOpts(
+getFormatStyleForFile(*CCFile, Contents, ));
+auto InsertionPoint = getInsertionPoint(
+Contents, Source->getQualifiedNameAsString(), LangOpts);
 if (!InsertionPoint)
   return InsertionPoint.takeError();
 
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -250,7 +250,7 @@
 ///
 /// visibleNamespaces are {"foo::", "", "a::", "b::", "foo::b::"}, not "a::b::".
 std::vector visibleNamespaces(llvm::StringRef Code,
-   const format::FormatStyle );
+   const LangOptions );
 
 /// Represents locations that can accept a definition.
 struct EligibleRegion {
@@ -271,7 +271,7 @@
 /// \p FullyQualifiedName should not contain anonymous namespaces.
 EligibleRegion getEligiblePoints(llvm::StringRef Code,
  llvm::StringRef FullyQualifiedName,
- const format::FormatStyle );
+ const LangOptions );
 
 struct DefinedMacro {
   llvm::StringRef Name;
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -654,8 +654,7 @@
   Position Pos;
 };
 // Scans C++ source code for constructs that change the visible namespaces.
-void parseNamespaceEvents(llvm::StringRef Code,
-  const format::FormatStyle ,
+void parseNamespaceEvents(llvm::StringRef Code, const LangOptions ,
   llvm::function_ref Callback) {
 
   // Stack of enclosing namespaces, e.g. {"clang", "clangd"}
@@ -674,114 

[PATCH] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked 3 inline comments as done.
ahatanak added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:4100
+  if (E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+pushDestroy(QualType::DK_nontrivial_c_struct, DeclPtr, E->getType());
+

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > ahatanak wrote:
> > > > rjmccall wrote:
> > > > > ahatanak wrote:
> > > > > > rjmccall wrote:
> > > > > > > ahatanak wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > rjmccall wrote:
> > > > > > > > > > Unfortunately, the lifetime of compound literals in C is 
> > > > > > > > > > not this simple; they're like blocks in that they're 
> > > > > > > > > > destroyed at the end of the enclosing scope rather than at 
> > > > > > > > > > the end of the current statement. (The cleanup here will be 
> > > > > > > > > > popped at the end of the full-expression if we've entered 
> > > > > > > > > > an `ExprWithCleanups`.) And the l-value case is exactly the 
> > > > > > > > > > case where this matters.
> > > > > > > > > > 
> > > > > > > > > > I think you need to do something like what we do with 
> > > > > > > > > > blocks, where we record all the blocks in the 
> > > > > > > > > > full-expression on the `ExprWithCleanups` so that we can 
> > > > > > > > > > push an inactive cleanup for them and then activate it when 
> > > > > > > > > > we emit the block.
> > > > > > > > > Can we make the check here something like (1) this is a 
> > > > > > > > > block-scope compound literal and (2) it has a 
> > > > > > > > > non-trivially-destructed type (of any kind)?  That way we're 
> > > > > > > > > not conflating two potentially unrelated elements, the 
> > > > > > > > > lifetime of the object and the kinds of types that can be 
> > > > > > > > > constructed by the literal.
> > > > > > > > > 
> > > > > > > > > Oh, actually, there's a concrete reason to do this: C99 
> > > > > > > > > compound literals are not required to have struct type; they 
> > > > > > > > > can have any object type, including arrays but also scalars.  
> > > > > > > > > So we could, even without non-trivial C structs, have a 
> > > > > > > > > block-scope compound of type `__strong id[]`; I guess we've 
> > > > > > > > > always just gotten this wrong.  Please add tests for this 
> > > > > > > > > case. :)
> > > > > > > > There is a check `E->isFileScope()` above this. Is that 
> > > > > > > > sufficient to check for block-scoped compound literals?
> > > > > > > That plus the C/C++ difference; compound literals in C++ are just 
> > > > > > > temporaries.
> > > > > > I haven't been able to come up with a piece of C++ code that 
> > > > > > executes `EmitCompoundLiteralLValue`. The following code gets 
> > > > > > rejected because you can't take the address of a temporary object 
> > > > > > in C++:
> > > > > > 
> > > > > > ```
> > > > > > StrongSmall *p = &(StrongSmall){ 1, 0 };
> > > > > > ```
> > > > > > 
> > > > > > If a bind a reference to it, 
> > > > > > `AggExprEmitter::VisitCompoundLiteralExpr` is called.
> > > > > That makes sense; they're not gl-values in C++.  It would be 
> > > > > reasonable to assert that.  But the C++ point does apply elsewhere.
> > > > It turns out this function is called in C++ when the compound literal 
> > > > is a vector type, so I've just added a check for C++ instead of an 
> > > > assert.
> > > Really?  Is the expression actually an l-value in this case somehow?
> > I see this function being called when 
> > `ScalarExprEmitter::VisitCompoundLiteralExpr` calls `EmitLoadOfLValue`.
> Okay.  As a general rule, nothing should be calling `EmitLValue` on an 
> expression that isn't actually an l-value.  It's a little more reasonable 
> here because it's more like a helper routine.  If this is the cleanest way to 
> handle this in C++, it's okay, but please leave a comment explaining that 
> here.
I added a comment in `ScalarExprEmitter::VisitCompoundLiteralExpr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64464



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:17
+  "expected 'volatile', 'inline', 'goto', or '('">, CatInlineAsm;
+def err_global_asm_qualifier_ignored : Error<
+  "meaningless '%0' on asm outside function">, CatInlineAsm;

If we know of any compilers that support asm statements with qualifiers other 
than what Clang supports, it may make sense for these diagnostics to be 
warnings that are treated as an error by default so that users can disable the 
warning when compiling with Clang. I don't know of any such compilers off the 
top of my head, but perhaps you know of some.



Comment at: clang/include/clang/Parse/Parser.h:3215
+GNUAsmQualifiers() : Qualifiers(0) {}
+static const char *getSpecifierName(const AQ AQ);
+static AQ getQualifierForTokenKind(const tok::TokenKind K);

nickdesaulniers wrote:
> Now that we're not using `DeclSpec`, maybe we could drop this in preference 
> of `operator<<`.
I prefer the named function to a streaming operator given how little this will 
be used -- it's easier to call the named function from within a debugger than 
to use a streaming operator.

Please don't use a type name as a parameter identifier. Also, drop the 
top-level const.



Comment at: clang/include/clang/Parse/Parser.h:3206
+  class GNUAsmQualifiers {
+unsigned Qualifiers : 3; // Bitwise OR of AQ.
+  public:

There's really no benefit to using a bit-field here, so I'd just store an 
`unsigned`.



Comment at: clang/include/clang/Parse/Parser.h:3214
+};
+GNUAsmQualifiers() : Qualifiers(0) {}
+static const char *getSpecifierName(const AQ AQ);

I think you should use an in-class initializer for `Qualifiers` and then can 
drop the constructor entirely.



Comment at: clang/include/clang/Parse/Parser.h:3216
+static const char *getSpecifierName(const AQ AQ);
+bool setAsmQualifier(const AQ AQ);
+inline bool isVolatile() const { return Qualifiers & AQ_volatile; };

Please don't use a type name as a parameter identifier. Also, drop the 
top-level `const`.



Comment at: clang/include/clang/Parse/Parser.h:3224
+  GNUAsmQualifiers::AQ getGNUAsmQualifier(const Token ) const;
+  bool ParseGNUAsmQualifierListOpt(GNUAsmQualifiers *AQ);
 };

This should be taking a reference rather than a pointer. It should also be 
named `parseGNUAsmQualifierListOpt()` with a lowercase `p`.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:358
+bool Parser::isGNUAsmQualifier(const Token ) const {
+  return !!getGNUAsmQualifier(TokAfterAsm);
 }

This is too clever for my tastes -- I'd prefer an explicit test against 
`AQ_unspecified`.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:932
+
+const char *Parser::GNUAsmQualifiers::getSpecifierName(const AQ AQ) {
+  switch (AQ) {

type vs param name and top-level `const`.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:937
+case AQ_goto: return "goto";
+case AQ_unspecified:;
+  }

This looks wrong to me -- it flows through to an unreachable despite being 
reachable. I think this should `return "unspecified";`.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:951
+}
+bool Parser::GNUAsmQualifiers::setAsmQualifier(const AQ AQ) {
+  bool IsDuplicate = Qualifiers & AQ;

type vs param name and top-level `const`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

LGTM with the changes for #import.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D75959: [clangd] Run clang-format on CodeComplete.cpp and SourceCodeTests.cpp

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

I assume I can self-approve this kind of change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75959

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -215,8 +215,9 @@
 for (unsigned I = 0; I <= L.Length; ++I)
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, I)),
llvm::HasValue(L.Offset + I));
-EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, 
L.Length+1)),
- llvm::HasValue(L.Offset + L.Length));
+EXPECT_THAT_EXPECTED(
+positionToOffset(File, position(L.Number, L.Length + 1)),
+llvm::HasValue(L.Offset + L.Length));
 EXPECT_THAT_EXPECTED(
 positionToOffset(File, position(L.Number, L.Length + 1), false),
 llvm::Failed()); // out of range
@@ -413,7 +414,7 @@
   {""},
   },
   };
-  for (const auto& Case : Cases) {
+  for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
   visibleNamespaces(Case.first, format::getLLVMStyle()))
 << Case.first;
@@ -450,7 +451,7 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
-TEST(SourceCodeTests, IsInsideMainFile){
+TEST(SourceCodeTests, IsInsideMainFile) {
   TestTU TU;
   TU.HeaderCode = R"cpp(
 #define DEFINE_CLASS(X) class X {};
@@ -471,7 +472,7 @@
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
   auto DeclLoc = [](llvm::StringRef Name) {
 return findDecl(AST, Name).getLocation();
   };
@@ -574,7 +575,7 @@
   TU.AdditionalFiles["foo.inc"] = "int foo;\n";
   TU.AdditionalFiles["bar.inc"] = "int bar;\n";
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
 
   FileID Foo = SM.getFileID(findDecl(AST, "foo").getLocation());
   EXPECT_EQ(SM.getFileOffset(includeHashLoc(Foo, SM)),
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1776,8 +1776,7 @@
   Options.IncludeBriefComments = false;
   IncludeStructure PreambleInclusions; // Unused for signatureHelp
   semaCodeComplete(
-  std::make_unique(Options, Index, Result),
-  Options,
+  std::make_unique(Options, Index, Result), 
Options,
   {FileName, Command, Preamble, Contents, *Offset, std::move(VFS)});
   return Result;
 }


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -215,8 +215,9 @@
 for (unsigned I = 0; I <= L.Length; ++I)
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, I)),
llvm::HasValue(L.Offset + I));
-EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, L.Length+1)),
- llvm::HasValue(L.Offset + L.Length));
+EXPECT_THAT_EXPECTED(
+positionToOffset(File, position(L.Number, L.Length + 1)),
+llvm::HasValue(L.Offset + L.Length));
 EXPECT_THAT_EXPECTED(
 positionToOffset(File, position(L.Number, L.Length + 1), false),
 llvm::Failed()); // out of range
@@ -413,7 +414,7 @@
   {""},
   },
   };
-  for (const auto& Case : Cases) {
+  for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
   visibleNamespaces(Case.first, format::getLLVMStyle()))
 << Case.first;
@@ -450,7 +451,7 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
-TEST(SourceCodeTests, IsInsideMainFile){
+TEST(SourceCodeTests, IsInsideMainFile) {
   TestTU TU;
   TU.HeaderCode = R"cpp(
 #define DEFINE_CLASS(X) class X {};
@@ -471,7 +472,7 @@
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
   auto DeclLoc = [](llvm::StringRef Name) {
 return findDecl(AST, Name).getLocation();
   };
@@ -574,7 +575,7 @@
   TU.AdditionalFiles["foo.inc"] = "int foo;\n";
   TU.AdditionalFiles["bar.inc"] = "int bar;\n";
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = 

[PATCH] D75959: [clangd] Run clang-format on CodeComplete.cpp and SourceCodeTests.cpp

2020-03-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

I assume I can self-approve this kind of change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75959



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


[clang] 40568fe - [CodeGen] Emit destructor calls to destruct compound literals

2020-03-10 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-03-10T14:08:28-07:00
New Revision: 40568fec7e3eb51554cbdaf63a8044830be93fa4

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

LOG: [CodeGen] Emit destructor calls to destruct compound literals

Fix a bug in IRGen where it wasn't destructing compound literals in C
that are ObjC pointer arrays or non-trivial structs. Also diagnose jumps
that enter or exit the lifetime of the compound literals.

rdar://problem/51867864

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

Added: 
clang/test/AST/ast-dump-objc-arc-json.m
clang/test/Import/objc-arc/Inputs/cleanup-objects.m
clang/test/Import/objc-arc/test-cleanup-object.m
clang/test/PCH/non-trivial-c-compound-literal.m

Modified: 
clang/include/clang/AST/ASTImporter.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Sema/JumpDiagnostics.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-stmt.m
clang/test/CodeGenObjC/arc-ternary-op.m
clang/test/CodeGenObjC/arc.m
clang/test/CodeGenObjC/strong-in-c-struct.m
clang/test/SemaObjC/strong-in-c-struct.m
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTImporter.h 
b/clang/include/clang/AST/ASTImporter.h
index 490b34bf95e8..205d7ec67754 100644
--- a/clang/include/clang/AST/ASTImporter.h
+++ b/clang/include/clang/AST/ASTImporter.h
@@ -16,6 +16,7 @@
 
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -349,6 +350,10 @@ class TypeSourceInfo;
   return ToOrErr.takeError();
 }
 
+/// Import cleanup objects owned by ExprWithCleanup.
+llvm::Expected
+Import(ExprWithCleanups::CleanupObject From);
+
 /// Import the given type from the "from" context into the "to"
 /// context. A null type is imported as a null type (no error).
 ///

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 2bd68eec175a..694575790f48 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -3321,13 +3321,15 @@ class DependentScopeDeclRefExpr final
 /// literal is the extent of the enclosing scope.
 class ExprWithCleanups final
 : public FullExpr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects<
+  ExprWithCleanups,
+  llvm::PointerUnion> {
 public:
   /// The type of objects that are kept in the cleanup.
-  /// It's useful to remember the set of blocks;  we could also
-  /// remember the set of temporaries, but there's currently
-  /// no need.
-  using CleanupObject = BlockDecl *;
+  /// It's useful to remember the set of blocks and block-scoped compound
+  /// literals; we could also remember the set of temporaries, but there's
+  /// currently no need.
+  using CleanupObject = llvm::PointerUnion;
 
 private:
   friend class ASTStmtReader;

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 5dc5022ed697..b08d1e482be8 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -184,6 +184,7 @@ class TextNodeDumper
   void dumpBareDeclRef(const Decl *D);
   void dumpName(const NamedDecl *ND);
   void dumpAccessSpecifier(AccessSpecifier AS);
+  void dumpCleanupObject(const ExprWithCleanups::CleanupObject );
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d8b43519dd3e..4193b0390ce0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5543,6 +5543,8 @@ def note_enters_block_captures_weak : Note<
 def note_enters_block_captures_non_trivial_c_struct : Note<
   "jump enters lifetime of block which captures a C struct that is non-trivial 
"
   "to destroy">;
+def note_enters_compound_literal_scope : Note<
+  "jump enters lifetime of a compound literal that is non-trivial to 
destruct">;
 
 def note_exits_cleanup : Note<
   "jump exits scope of variable with 

[clang-tools-extra] ddfcda0 - [clang-tidy] Fix warning from my previous patch in ReleaseNotes.txt

2020-03-10 Thread Paula Toth via cfe-commits

Author: Paula Toth
Date: 2020-03-10T14:01:23-07:00
New Revision: ddfcda0256ca231499614742cce1b66db056dc2a

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

LOG: [clang-tidy] Fix warning from my previous patch in ReleaseNotes.txt

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 68ca5f61a4fa..aa777ce50cf5 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -134,7 +134,7 @@ Renamed checks
 ^^
 
 - The 'fuchsia-restrict-system-headers' check was renamed to 
:doc:`portability-restrict-system-includes
-  
+  `
 
 Improvements to include-fixer
 -



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


[clang] 72aa619 - Warn of uninitialized variables on asm goto's indirect branch

2020-03-10 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2020-03-10T13:48:48-07:00
New Revision: 72aa619a7fe0e2f90959b0614f6388c09aba8913

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

LOG: Warn of uninitialized variables on asm goto's indirect branch

Summary:
Outputs from an asm goto block cannot be used on the indirect branch.
It's not supported and may result in invalid code generation.

Reviewers: jyknight, nickdesaulniers, hfinkel

Reviewed By: nickdesaulniers

Subscribers: martong, cfe-commits, rnk, craig.topper, hiraditya, rsmith

Tags: #clang

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

Added: 


Modified: 
clang/lib/Analysis/UninitializedValues.cpp
clang/test/Analysis/uninit-asm-goto.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index 16d17de599f2..ba64fbb81884 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -576,6 +576,28 @@ class TransferFunctions : public 
StmtVisitor {
   continue;
 }
 
+if (AtPredExit == MayUninitialized) {
+  // If the predecessor's terminator is an "asm goto" that initializes
+  // the variable, then it won't be counted as "initialized" on the
+  // non-fallthrough paths.
+  CFGTerminator term = Pred->getTerminator();
+  if (const auto *as = dyn_cast_or_null(term.getStmt())) {
+const CFGBlock *fallthrough = *Pred->succ_begin();
+if (as->isAsmGoto() &&
+llvm::any_of(as->outputs(), [&](const Expr *output) {
+return vd == findVar(output).getDecl() &&
+llvm::any_of(as->labels(),
+ [&](const AddrLabelExpr *label) {
+  return label->getLabel()->getStmt() == B->Label &&
+  B != fallthrough;
+});
+})) {
+  Use.setUninitAfterDecl();
+  continue;
+}
+  }
+}
+
 unsigned  = SuccsVisited[Pred->getBlockID()];
 if (!SV) {
   // When visiting the first successor of a block, mark all NULL
@@ -768,7 +790,11 @@ void TransferFunctions::VisitGCCAsmStmt(GCCAsmStmt *as) {
 
   for (const Expr *o : as->outputs())
 if (const VarDecl *VD = findVar(o).getDecl())
-  vals[VD] = Initialized;
+  if (vals[VD] != Initialized)
+// If the variable isn't initialized by the time we get here, then we
+// mark it as potentially uninitialized for those cases where it's used
+// on an indirect path, where it's not guaranteed to be defined.
+vals[VD] = MayUninitialized;
 }
 
 void TransferFunctions::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
@@ -809,7 +835,7 @@ static bool runOnBlock(const CFGBlock *block, const CFG 
,
   tf.Visit(const_cast(cs->getStmt()));
   }
   CFGTerminator terminator = block->getTerminator();
-  if (GCCAsmStmt *as = dyn_cast_or_null(terminator.getStmt()))
+  if (auto *as = dyn_cast_or_null(terminator.getStmt()))
 if (as->isAsmGoto())
   tf.Visit(as);
   return vals.updateValueVectorWithScratch(block);

diff  --git a/clang/test/Analysis/uninit-asm-goto.cpp 
b/clang/test/Analysis/uninit-asm-goto.cpp
index 1d573b90016e..136b210b8866 100644
--- a/clang/test/Analysis/uninit-asm-goto.cpp
+++ b/clang/test/Analysis/uninit-asm-goto.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -Wuninitialized -verify %s
-// expected-no-diagnostics
 
+// test1: Expect no diagnostics
 int test1(int x) {
 int y;
 asm goto("nop" : "=r"(y) : "r"(x) : : err);
@@ -8,3 +8,52 @@ int test1(int x) {
   err:
 return -1;
 }
+
+int test2(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its 
declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  if (x < 42)
+asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) 
: "r"(x) :: indirect_1, indirect_2);
+  else
+asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) 
: "r"(x), "r"(y) :: indirect_1, indirect_2);
+  return x + y;
+indirect_1:
+  return -42;
+indirect_2:
+  return y; // expected-note {{uninitialized use occurs here}}
+}
+
+int test3(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its 
declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  asm goto("xorl %1, %0; jmp %l2" : "="(y) : "r"(x) : : fail);
+normal:
+  y += x;
+  return y;
+  if (x) {
+fail:
+return y; // expected-note {{uninitialized use occurs here}}
+  }
+  return 0;
+}
+
+int test4(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized 

[clang-tools-extra] 445195b - [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle

2020-03-10 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-03-10T16:45:41-04:00
New Revision: 445195ba6cee029852193e3f2a12cf9356fac308

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

LOG: [clangd] Have visibleNamespaces() and getEligiblePoints() take a 
LangOptions rather than a FormatStyle

Summary:
These functions only use the FormatStyle to obtain a LangOptions via
format::getFormattingLangOpts(), and some callers can more easily obtain
a LangOptions more directly.

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b38b33fa4930..344b90ecaa32 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1373,8 +1373,8 @@ class CodeCompleteFlow {
 //  - accessible scopes are determined heuristically.
 //  - all-scopes query if no qualifier was typed (and it's allowed).
 SpecifiedScope Scopes;
-Scopes.AccessibleScopes =
-visibleNamespaces(Content.take_front(Offset), Style);
+Scopes.AccessibleScopes = visibleNamespaces(
+Content.take_front(Offset), format::getFormattingLangOpts(Style));
 for (std::string  : Scopes.AccessibleScopes)
   if (!S.empty())
 S.append("::"); // visibleNamespaces doesn't include trailing ::.

diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 75154723bb72..a722ae9b0663 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -654,8 +654,7 @@ struct NamespaceEvent {
   Position Pos;
 };
 // Scans C++ source code for constructs that change the visible namespaces.
-void parseNamespaceEvents(llvm::StringRef Code,
-  const format::FormatStyle ,
+void parseNamespaceEvents(llvm::StringRef Code, const LangOptions ,
   llvm::function_ref Callback) {
 
   // Stack of enclosing namespaces, e.g. {"clang", "clangd"}
@@ -674,114 +673,113 @@ void parseNamespaceEvents(llvm::StringRef Code,
   std::string NSName;
 
   NamespaceEvent Event;
-  lex(Code, format::getFormattingLangOpts(Style),
-  [&](const syntax::Token , const SourceManager ) {
-Event.Pos = sourceLocToPosition(SM, Tok.location());
-switch (Tok.kind()) {
-case tok::kw_using:
-  State = State == Default ? Using : Default;
-  break;
-case tok::kw_namespace:
-  switch (State) {
-  case Using:
-State = UsingNamespace;
-break;
-  case Default:
-State = Namespace;
-break;
-  default:
-State = Default;
-break;
-  }
-  break;
-case tok::identifier:
-  switch (State) {
-  case UsingNamespace:
-NSName.clear();
-LLVM_FALLTHROUGH;
-  case UsingNamespaceName:
-NSName.append(Tok.text(SM).str());
-State = UsingNamespaceName;
-break;
-  case Namespace:
-NSName.clear();
-LLVM_FALLTHROUGH;
-  case NamespaceName:
-NSName.append(Tok.text(SM).str());
-State = NamespaceName;
-break;
-  case Using:
-  case Default:
-State = Default;
-break;
-  }
-  break;
-case tok::coloncolon:
-  // This can come at the beginning or in the middle of a namespace
-  // name.
-  switch (State) {
-  case UsingNamespace:
-NSName.clear();
-LLVM_FALLTHROUGH;
-  case UsingNamespaceName:
-NSName.append("::");
-State = UsingNamespaceName;
-break;
-  case NamespaceName:
-NSName.append("::");
-State = NamespaceName;
-break;
-  case Namespace: // Not legal here.
-  case Using:
-  case Default:
-State = Default;
-break;
-  }
-  break;
-case tok::l_brace:
-  // Record which { started a namespace, so we know when } ends one.
-  if (State == NamespaceName) {
-// Parsed: namespace  {
-BraceStack.push_back(true);
-Enclosing.push_back(NSName);
-Event.Trigger = 

[clang-tools-extra] 484402a - [clangd] Run clang-format on CodeComplete.cpp and SourceCodeTests.cpp

2020-03-10 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-03-10T16:45:14-04:00
New Revision: 484402abaca2b2523487b564c7d5173404b448af

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

LOG: [clangd] Run clang-format on CodeComplete.cpp and SourceCodeTests.cpp

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b2e97729ee6d..b38b33fa4930 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1776,8 +1776,7 @@ SignatureHelp signatureHelp(PathRef FileName,
   Options.IncludeBriefComments = false;
   IncludeStructure PreambleInclusions; // Unused for signatureHelp
   semaCodeComplete(
-  std::make_unique(Options, Index, Result),
-  Options,
+  std::make_unique(Options, Index, Result), 
Options,
   {FileName, Command, Preamble, Contents, *Offset, std::move(VFS)});
   return Result;
 }

diff  --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 49f6a73cec48..59c4dd60add2 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -215,8 +215,9 @@ TEST(SourceCodeTests, PositionToOffset) {
 for (unsigned I = 0; I <= L.Length; ++I)
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, I)),
llvm::HasValue(L.Offset + I));
-EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, 
L.Length+1)),
- llvm::HasValue(L.Offset + L.Length));
+EXPECT_THAT_EXPECTED(
+positionToOffset(File, position(L.Number, L.Length + 1)),
+llvm::HasValue(L.Offset + L.Length));
 EXPECT_THAT_EXPECTED(
 positionToOffset(File, position(L.Number, L.Length + 1), false),
 llvm::Failed()); // out of range
@@ -413,7 +414,7 @@ TEST(SourceCodeTests, VisibleNamespaces) {
   {""},
   },
   };
-  for (const auto& Case : Cases) {
+  for (const auto  : Cases) {
 EXPECT_EQ(Case.second,
   visibleNamespaces(Case.first, format::getLLVMStyle()))
 << Case.first;
@@ -450,7 +451,7 @@ TEST(SourceCodeTests, WorksAtBeginOfFile) {
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
-TEST(SourceCodeTests, IsInsideMainFile){
+TEST(SourceCodeTests, IsInsideMainFile) {
   TestTU TU;
   TU.HeaderCode = R"cpp(
 #define DEFINE_CLASS(X) class X {};
@@ -471,7 +472,7 @@ TEST(SourceCodeTests, IsInsideMainFile){
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
   auto DeclLoc = [](llvm::StringRef Name) {
 return findDecl(AST, Name).getLocation();
   };
@@ -574,7 +575,7 @@ TEST(SourceCodeTests, IncludeHashLoc) {
   TU.AdditionalFiles["foo.inc"] = "int foo;\n";
   TU.AdditionalFiles["bar.inc"] = "int bar;\n";
   auto AST = TU.build();
-  const auto& SM = AST.getSourceManager();
+  const auto  = AST.getSourceManager();
 
   FileID Foo = SM.getFileID(findDecl(AST, "foo").getLocation());
   EXPECT_EQ(SM.getFileOffset(includeHashLoc(Foo, SM)),



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


[PATCH] D75786: [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.

2020-03-10 Thread Paula Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
PaulkaToast marked an inline comment as done.
Closed by commit rGebdb98f254f6: [clang-tidy] Move 
fuchsia-restrict-system-includes to portability module for… (authored by 
PaulkaToast).

Changed prior to commit:
  https://reviews.llvm.org/D75786?vs=248900=249492#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75786

Files:
  clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h
  clang-tools-extra/clang-tidy/portability/CMakeLists.txt
  clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
  clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/j.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/r.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/s.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/t.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/transitive.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/transitive2.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/r.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/s.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/t.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/transitive.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/transitive2.h
  
clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes-all.cpp
  
clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes-glob.cpp
  
clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes-headers.cpp
  
clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
@@ -1,11 +1,11 @@
 // RUN: rm -rf %T/Headers
 // RUN: mkdir %T/Headers
-// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes %T/Headers/fuchsia-restrict-system-includes
-// RUN: %check_clang_tidy -std=c++11 %s fuchsia-restrict-system-includes %t \
-// RUN:   -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 'transitive.h,s.h'}]}" \
+// RUN: cp -r %S/Inputs/portability-restrict-system-includes %T/Headers/portability-restrict-system-includes
+// RUN: %check_clang_tidy -std=c++11 %s portability-restrict-system-includes %t \
+// RUN:   -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: 'transitive.h,s.h'}]}" \
 // RUN:   -system-headers -header-filter=.* \
-// RUN:   -- -I %T/Headers/fuchsia-restrict-system-includes -isystem 

[PATCH] D75786: [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.

2020-03-10 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast marked 2 inline comments as done.
PaulkaToast added a comment.






Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst:48
+
+   A string containing a comma separated glob list of allowed include
+   filenames. Similar to the -checks glob list for running clang-tidy itself,

aaron.ballman wrote:
> This is not something you have to fix (and certainly not as part of this 
> patch), but is a note of a bug... we typically use semicolon-delimited lists, 
> and I think that may be especially important here as comma can be a valid 
> character in a file name on many file systems. I notice that we're using 
> `GlobList` which still seems to use comma-separated values. We may want to 
> consider allowing both semi-colon and commas in `GlobList` and then updating 
> the docs to suggest semicolons instead of commas.
thanks, I'll send a patch out for this as its own change. (:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75786



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


[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:362
+def TargetAArch64 : TargetArch<["aarch64"]>;
+def TargetARM_AArch64 : TargetArch;
 def TargetAVR : TargetArch<["avr"]>;

nit: don't thin we use underscores in names, and looking at examples below, I 
guess this should be `TargetAnyARM`



Comment at: clang/utils/TableGen/SveEmitter.cpp:105
 
+  std::string str() const;
+

nit: add a comment here too (for consistency)



Comment at: clang/utils/TableGen/SveEmitter.cpp:634
 " *\n"
 " * Permission is hereby granted, free of charge, to any person "
 "obtaining "

Unrelated to this change, I just spotted it because it looked a bit messy, but 
is this the old copyright header? While we are at it, replace this with the new 
one? Looks like e.g. in arm_mve.h, we do use the new one. 


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

https://reviews.llvm.org/D75861



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:55-71
+  if (const auto *Reference =
+  Result.Nodes.getNodeAs("reference_to_non-const")) {
+diag(Reference->getLocation(),
+ "variable %0 provides global access to non-const type, consider "
+ "making the referenced data const")
+<< Reference; // FIXME: Add fix-it hint to Reference
+return;

vingeldal wrote:
> aaron.ballman wrote:
> > I think these cases should be combined to avoid duplication.
> > ```
> > if (const auto *VD = Result.Nodes.getNodeAs("whatever")) {
> >   diag(VD->getLocation(), "variable %0 provides global access to a 
> > non-const object; considering making the %select{referenced|pointed-to}1 
> > data 'const'") << VD << VD->getType()->isReferenceType();
> >   return;
> > }
> > ```
> > the matcher needs to be changed to bind to the same id for both cases.
> > 
> > Note, this rewords the diagnostic slightly to avoid type/object confusion 
> > (the variable provides access to an object of a non-const type, not to the 
> > type itself).
> You mean just the pointer and reference cases right? That matcher seems to 
> get much more complicated, I'm having some trouble accomplishing that. Are 
> you sure that's necessary? What would the cases of duplication be?
> You mean just the pointer and reference cases right? 

Yup!

> Are you sure that's necessary? What would the cases of duplication be?

Not strictly necessary, so if this turns out to be hard, I'm fine skipping it. 
However, I was thinking it would be something like:
```
// Registering checks
Finder->addMatcher(GlobalReferenceToNonConst.bind("qual-non-const"), this);
Finder->addMatcher(GlobalPointerToNonConst.bind("qual-non-const"), this);

// In check
if (const auto *VD = Result.Nodes.getNodeAs("qual-non-const")) {
  diag(VD->getLocation(),
  "variable %0 provides global access to a non-const object; 
considering making the %select{pointed-to|referenced}1 data 'const'") << VD << 
VD->getType()->isReferenceType();
  return;
  }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp:52
+if (!SM.isInMainFile(HashLoc)) {
+  DiagnosticBuilder D = Check.diag(
+  HashLoc,

No need for the local DiagnosticBuilder object, you can stream into the 
Check.diag() call.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp:57
+} else {
+  DiagnosticBuilder D =
+  Check.diag(HashLoc, "system libc header %0 not allowed");

No need for the local `DiagnosticBuilder` object, you can stream into the 
`Check.diag()` call.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp:66-67
+const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  SmallString<128> CompilerIncudeDir =
+  StringRef(PP->getHeaderSearchInfo().getHeaderSearchOpts().ResourceDir);
+  llvm::sys::path::append(CompilerIncudeDir, "include");

The user can control this path -- is that an issue? You're using it to 
determine what a compiler-provided header file is, and this seems like an 
escape hatch for users to get around that. If that's reasonable to you, then 
I'm okay with it, but you had mentioned you want to remove human error as a 
factor and this seems like it could be a subtle human error situation.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst:16
+
+This check is necesary because accidentally including sytem libc headers can
+lead to subtle and hard to detect bugs. For example consider a system libc

necesary -> necessary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332



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


[PATCH] D75786: [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.

2020-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst:48
+
+   A string containing a comma separated glob list of allowed include
+   filenames. Similar to the -checks glob list for running clang-tidy itself,

This is not something you have to fix (and certainly not as part of this 
patch), but is a note of a bug... we typically use semicolon-delimited lists, 
and I think that may be especially important here as comma can be a valid 
character in a file name on many file systems. I notice that we're using 
`GlobList` which still seems to use comma-separated values. We may want to 
consider allowing both semi-colon and commas in `GlobList` and then updating 
the docs to suggest semicolons instead of commas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75786



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


[clang-tools-extra] ebdb98f - [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.

2020-03-10 Thread Paula Toth via cfe-commits

Author: Paula Toth
Date: 2020-03-10T13:33:06-07:00
New Revision: ebdb98f254f632b506109b9d20c6e8e19697765f

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

LOG: [clang-tidy] Move fuchsia-restrict-system-includes to portability module 
for general use.

Summary:
Created a general check for restrict-system-includes under portability as 
recommend in the comments under D75332. I also fleshed out the user facing 
documentation to show examples for common use-cases such as allow-list, 
block-list, and wild carding.

Removed fuchsia's check as per phosek sugguestion.

Reviewers: aaron.ballman, phosek, alexfh, hokein, njames93

Reviewed By: phosek

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, phosek, cfe-commits, MaskRay

Tags: #clang-tools-extra, #clang

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

Added: 
clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h

clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/r.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/s.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/t.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/transitive.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/transitive2.h

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp

Modified: 
clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
clang-tools-extra/clang-tidy/portability/CMakeLists.txt
clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
clang-tools-extra/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
clang-tools-extra/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h

clang-tools-extra/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/a.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/j.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/r.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/s.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/t.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/system/transitive.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/fuchsia-restrict-system-includes/transitive2.h

clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes-all.cpp

clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes-glob.cpp

clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes-headers.cpp

clang-tools-extra/test/clang-tidy/checkers/fuchsia-restrict-system-includes.cpp



diff  --git a/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
index 30b319e7e5aa..26e6719a6475 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
@@ -6,7 +6,6 @@ add_clang_library(clangTidyFuchsiaModule
   FuchsiaTidyModule.cpp
   MultipleInheritanceCheck.cpp
   OverloadedOperatorCheck.cpp
-  RestrictSystemIncludesCheck.cpp
   StaticallyConstructedObjectsCheck.cpp
   

[clang] 7fb562c - [Concepts] Add constraints checks to isSameEntity

2020-03-10 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-03-10T22:05:36+02:00
New Revision: 7fb562c1ab373a3d4e14003e40556791ec032bab

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

LOG: [Concepts] Add constraints checks to isSameEntity

isSameEntity was missing constraints checking, causing constrained overloads
to not travel well accross serialization. (bug #45115)

Add constraints checking to isSameEntity.

Added: 
clang/test/PCH/cxx2a-constraints.cpp

Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 362d3eaebdd2..828f4a172b05 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2870,7 +2870,8 @@ uint64_t ASTReader::getGlobalBitOffset(ModuleFile , 
uint32_t LocalOffset) {
   return LocalOffset + M.GlobalBitOffset;
 }
 
-static bool isSameTemplateParameterList(const TemplateParameterList *X,
+static bool isSameTemplateParameterList(const ASTContext ,
+const TemplateParameterList *X,
 const TemplateParameterList *Y);
 
 /// Determine whether two template parameters are similar enough
@@ -2882,7 +2883,32 @@ static bool isSameTemplateParameter(const NamedDecl *X,
 
   if (const auto *TX = dyn_cast(X)) {
 const auto *TY = cast(Y);
-return TX->isParameterPack() == TY->isParameterPack();
+if (TX->isParameterPack() != TY->isParameterPack())
+  return false;
+if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
+  return false;
+if (TX->hasTypeConstraint()) {
+  const TypeConstraint *TXTC = TX->getTypeConstraint();
+  const TypeConstraint *TYTC = TY->getTypeConstraint();
+  if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
+return false;
+  if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())
+return false;
+  if (TXTC->hasExplicitTemplateArgs()) {
+const auto *TXTCArgs = TXTC->getTemplateArgsAsWritten();
+const auto *TYTCArgs = TYTC->getTemplateArgsAsWritten();
+if (TXTCArgs->NumTemplateArgs != TYTCArgs->NumTemplateArgs)
+  return false;
+llvm::FoldingSetNodeID XID, YID;
+for (const auto  : TXTCArgs->arguments())
+  ArgLoc.getArgument().Profile(XID, X->getASTContext());
+for (const auto  : TYTCArgs->arguments())
+  ArgLoc.getArgument().Profile(YID, Y->getASTContext());
+if (XID != YID)
+  return false;
+  }
+}
+return true;
   }
 
   if (const auto *TX = dyn_cast(X)) {
@@ -2894,7 +2920,8 @@ static bool isSameTemplateParameter(const NamedDecl *X,
   const auto *TX = cast(X);
   const auto *TY = cast(Y);
   return TX->isParameterPack() == TY->isParameterPack() &&
- isSameTemplateParameterList(TX->getTemplateParameters(),
+ isSameTemplateParameterList(TX->getASTContext(),
+ TX->getTemplateParameters(),
  TY->getTemplateParameters());
 }
 
@@ -2947,7 +2974,8 @@ static bool isSameQualifier(const NestedNameSpecifier *X,
 
 /// Determine whether two template parameter lists are similar enough
 /// that they may be used in declarations of the same template.
-static bool isSameTemplateParameterList(const TemplateParameterList *X,
+static bool isSameTemplateParameterList(const ASTContext ,
+const TemplateParameterList *X,
 const TemplateParameterList *Y) {
   if (X->size() != Y->size())
 return false;
@@ -2956,6 +2984,18 @@ static bool isSameTemplateParameterList(const 
TemplateParameterList *X,
 if (!isSameTemplateParameter(X->getParam(I), Y->getParam(I)))
   return false;
 
+  const Expr *XRC = X->getRequiresClause();
+  const Expr *YRC = Y->getRequiresClause();
+  if (!XRC != !YRC)
+return false;
+  if (XRC) {
+llvm::FoldingSetNodeID XRCID, YRCID;
+XRC->Profile(XRCID, C, /*Canonical=*/true);
+YRC->Profile(YRCID, C, /*Canonical=*/true);
+if (XRCID != YRCID)
+  return false;
+  }
+
   return true;
 }
 
@@ -2992,7 +3032,7 @@ static bool hasSameOverloadableAttrs(const FunctionDecl 
*A,
   return true;
 }
 
-/// Determine whether the two declarations refer to the same entity.
+/// Determine whether the two declarations refer to the same entity.pr
 static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
   assert(X->getDeclName() == Y->getDeclName() && "Declaration name mismatch!");
 
@@ -3067,6 +3107,19 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
 }
 
 ASTContext  = FuncX->getASTContext();
+
+const Expr *XRC = FuncX->getTrailingRequiresClause();
+

[clang] f9e6389 - [Concepts] Add FoundDecl to ConceptSpecializationExpr serialization

2020-03-10 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-03-10T22:04:11+02:00
New Revision: f9e63891597630405a4655298f06b193e4ceb384

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

LOG: [Concepts] Add FoundDecl to ConceptSpecializationExpr serialization

FoundDecl was missing from ConceptSpecializationExpr serialization - add it.

Added: 


Modified: 
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp 
b/clang/lib/Serialization/ASTReaderStmt.cpp
index 42803b1a3918..975b7580d861 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -768,6 +768,7 @@ void ASTStmtReader::VisitConceptSpecializationExpr(
   E->TemplateKWLoc = Record.readSourceLocation();
   E->ConceptName = Record.readDeclarationNameInfo();
   E->NamedConcept = readDeclAs();
+  E->FoundDecl = Record.readDeclAs();
   E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
   llvm::SmallVector Args;
   for (unsigned I = 0; I < NumTemplateArgs; ++I)

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index d2b1fc2becf1..0aadeaa9a615 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -429,6 +429,7 @@ void ASTStmtWriter::VisitConceptSpecializationExpr(
   Record.AddSourceLocation(E->getTemplateKWLoc());
   Record.AddDeclarationNameInfo(E->getConceptNameInfo());
   Record.AddDeclRef(E->getNamedConcept());
+  Record.AddDeclRef(E->getFoundDecl());
   Record.AddASTTemplateArgumentListInfo(E->getTemplateArgsAsWritten());
   for (const TemplateArgument  : TemplateArgs)
 Record.AddTemplateArgument(Arg);



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D75850#1915198 , @miyuki wrote:

> Should compile without warnings now.


LGTM, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75850



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


[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine accepted this revision.
saugustine added a comment.

This looks fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890



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


[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

`__FILE__` only expands to an absolute path if you pass an absolute path to 
clang (ctrl-f "__FILE__" on 
http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html).

It feels like this is working around a deficiency in the compiler. Maybe fixing 
whatever's going wrong in the compiler might be better? (There's also 
-ffile-file-prefix map, but using that makes your _commandline_ depend on the 
name of the build dir, and (in clang) `__FILE_NAME__ `.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-10 Thread Evandro Menezes via Phabricator via cfe-commits
evandro added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2958
+
+Put global and static data smaller than the limitation into a special section 
(RISC-V only)
+

```
s/arg/limit/
s/limitation/limit/
```



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:403
+def warn_drv_unsupported_g : Warning<
+  "ignoring '-G' option as -msmall-data-limit= in the command line">,
+  InGroup;

Rather:

```
"ignoring '-G' with '-msmall-data-limit'"
```



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:406
+def warn_drv_unsupported_sdata : Warning<
+  "ignoring '-msmall-data-limit=' for -fpic or RV64 with -mcmodel=large">,
+  InGroup;

Rather:

```
"ignoring '-msmall-data-limit=' with '-mcmodel=large' for PIC or RV64"
```



Comment at: clang/include/clang/Driver/CC1Options.td:317
+def msmall_data_limit : Separate<["-"], "msmall-data-limit">,
+  HelpText<"Put global and static data smaller than the limitation into a 
special section">;
 def munwind_tables : Flag<["-"], "munwind-tables">,

```
s/limitation/limit/
```



Comment at: clang/include/clang/Driver/Options.td:2302
+def msmall_data_limit_EQ : Joined<["-"], "msmall-data-limit=">, 
Group,
+  HelpText<"Put global and static data smaller than the limitation into a 
special section">;
 def msave_restore : Flag<["-"], "msave-restore">, 
Group,

```
s/limitation/limit/
```






Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM but you might want to wait a few more hours for other reviewers to see if 
anyone has objections.




Comment at: libunwind/src/config.h:125
   do { 
\
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
-__LINE__, msg);
\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);
\
 fflush(stderr);
\

I'd consider dropping `__func__` as well but I'm fine with keeping it as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890



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


[PATCH] D72635: Allow arbitrary capability name in Thread Safety Analysis

2020-03-10 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D72635#1912501 , @aaron.ballman 
wrote:

> In D72635#1911844 , @aaronpuchert 
> wrote:
>
> > In D72635#1911671 , @aaron.ballman 
> > wrote:
> >
> > > However, do we want to diagnose when the capability strings are different?
> >
> >
> > Now if I acquire capabilities of different types, then the order also has 
> > to incorporate these different types. So my answer would be no, I think we 
> > have to allow this.
>
>
> Okay, I think that makes sense, but is probably something we should mention 
> explicitly in the thread safety documentation so we don't lose track of why 
> this is the way it is. WDYT?


Yes, the documentation could use an overhaul, the behavior of scoped 
capabilities could also be documented better 
.

I have this on my agenda, and I hope I can carve out time for that soon.


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

https://reviews.llvm.org/D72635



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


[PATCH] D75890: [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 249468.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890

Files:
  libunwind/src/config.h


Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -122,8 +122,7 @@
 #else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
-__LINE__, msg);
\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)


Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -122,8 +122,7 @@
 #else
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  \
-__LINE__, msg);\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);\
 fflush(stderr);\
 abort();   \
   } while (0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75951: draft

2020-03-10 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
oontvoo retitled this revision from "Make a distinction between import and 
pragma-once, and keep tracked of already-included pragma-once files." to "draft 
".
oontvoo edited the summary of this revision.
oontvoo added a reviewer: jyknight.

Make a distinction between import and pragma-once, and keep tracked of 
already-included pragma-once files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp


Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1253,8 +1253,6 @@
   // Get information about this file.
   HeaderFileInfo  = getFileInfo(File);
 
-  // FIXME: this is a workaround for the lack of proper modules-aware support
-  // for #import / #pragma once
   auto TryEnterImported = [&]() -> bool {
 if (!ModulesEnabled)
   return false;
@@ -1300,13 +1298,24 @@
 FileInfo.isImport = true;
 
 // Has this already been #import'ed or #include'd?
+bool try_enter = TryEnterImported();
 if (FileInfo.NumIncludes && !TryEnterImported())
   return false;
   } else {
-// Otherwise, if this is a #include of a file that was previously #import'd
-// or if this is the second #include of a #pragma once file, ignore it.
-if (FileInfo.isImport && !TryEnterImported())
+// If the file has #pragma once guard and if it's been included
+// then skip it.
+if (FileInfo.isPragmaOnce) {
+  auto  = included_pragma_files.find(FileEntry);
+  if (it != included_pragma_files.end() && it->second) {
+return false;
+  } else {
+it->second = true;
+  }
+} else if (FileInfo.isImport && !TryEnterImported) {
+  // Otherwise, if this is a #include of a file that was previously
+  // #import'd ignore it.
   return false;
+}
   }
 
   // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -250,6 +250,9 @@
   /// Entity used to look up stored header file information.
   ExternalHeaderFileInfoSource *ExternalSource = nullptr;
 
+  // Set of #pragma_once file already seen.
+  llvm::DenseMap included_pragma_files;
+
 public:
   HeaderSearch(std::shared_ptr HSOpts,
SourceManager , DiagnosticsEngine ,


Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1253,8 +1253,6 @@
   // Get information about this file.
   HeaderFileInfo  = getFileInfo(File);
 
-  // FIXME: this is a workaround for the lack of proper modules-aware support
-  // for #import / #pragma once
   auto TryEnterImported = [&]() -> bool {
 if (!ModulesEnabled)
   return false;
@@ -1300,13 +1298,24 @@
 FileInfo.isImport = true;
 
 // Has this already been #import'ed or #include'd?
+bool try_enter = TryEnterImported();
 if (FileInfo.NumIncludes && !TryEnterImported())
   return false;
   } else {
-// Otherwise, if this is a #include of a file that was previously #import'd
-// or if this is the second #include of a #pragma once file, ignore it.
-if (FileInfo.isImport && !TryEnterImported())
+// If the file has #pragma once guard and if it's been included
+// then skip it.
+if (FileInfo.isPragmaOnce) {
+  auto  = included_pragma_files.find(FileEntry);
+  if (it != included_pragma_files.end() && it->second) {
+return false;
+  } else {
+it->second = true;
+  }
+} else if (FileInfo.isImport && !TryEnterImported) {
+  // Otherwise, if this is a #include of a file that was previously
+  // #import'd ignore it.
   return false;
+}
   }
 
   // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -250,6 +250,9 @@
   /// Entity used to look up stored header file information.
   ExternalHeaderFileInfoSource *ExternalSource = nullptr;
 
+  // Set of #pragma_once file already seen.
+  llvm::DenseMap included_pragma_files;
+
 public:
   HeaderSearch(std::shared_ptr HSOpts,
SourceManager , DiagnosticsEngine ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75851: [Analyzer][StreamChecker] Added evaluation of fseek.

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D75851#1915014 , @Szelethus wrote:

> In D75851#1914874 , @balazske wrote:
>
> > After a failed file operation we do not know if it was feof or ferror kind 
> > of error.
>
>
> Is this true for that many stream operations?


I looked it up, and it totally is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75851



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D74935#1915311 , @jeroen.dobbelaere 
wrote:

> In D74935#1909909 , @jdoerfert wrote:
>
> > I would say that once we get modeling for indirect restrict we can adapt 
> > the lang ref accordingly. For now there is only have outer level 
> > restrict/noalias.
>
>
> Why not try to get right now ? The first reason that you give for the change 
> in wording is
>
> > '1. To match the restrict semantics when we lower it to noalias.'


Right. Match the semantics of what we lower to noalias, not of everything we do 
not lower yet.

> Currently there is no mechanism to accurately describe nested restrict 
> pointers in LLVM-IR. imho, that means that
>  we should adapt the wording in a more specific way. Something like:

We also have no restrict on nested pointers. Since we only model (=use) 
restrict on the outermost level I don't see a problem not to talk about the 
inner levels.
That said, we have to add wording as we add support.

> This guarantee only holds for memory locations that are *modified*, by 
> any means, during the execution the function.
>   + Note that, just like C99 restrict, in this context, memory locations 
> whose content is used as a pointer value to modify a memory location,
>   + are also considered to modify the former memory locations.
> The attribute
>

The reason is that we need to come up and agree on clear, non-confusing, 
wording.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-10 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal marked an inline comment as done.
vingeldal added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:55-71
+  if (const auto *Reference =
+  Result.Nodes.getNodeAs("reference_to_non-const")) {
+diag(Reference->getLocation(),
+ "variable %0 provides global access to non-const type, consider "
+ "making the referenced data const")
+<< Reference; // FIXME: Add fix-it hint to Reference
+return;

aaron.ballman wrote:
> I think these cases should be combined to avoid duplication.
> ```
> if (const auto *VD = Result.Nodes.getNodeAs("whatever")) {
>   diag(VD->getLocation(), "variable %0 provides global access to a non-const 
> object; considering making the %select{referenced|pointed-to}1 data 'const'") 
> << VD << VD->getType()->isReferenceType();
>   return;
> }
> ```
> the matcher needs to be changed to bind to the same id for both cases.
> 
> Note, this rewords the diagnostic slightly to avoid type/object confusion 
> (the variable provides access to an object of a non-const type, not to the 
> type itself).
You mean just the pointer and reference cases right? That matcher seems to get 
much more complicated, I'm having some trouble accomplishing that. Are you sure 
that's necessary? What would the cases of duplication be?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-10 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D74935#1909909 , @jdoerfert wrote:

> I would say that once we get modeling for indirect restrict we can adapt the 
> lang ref accordingly. For now there is only have outer level restrict/noalias.


Why not try to get right now ? The first reason that you give for the change in 
wording is

> '1. To match the restrict semantics when we lower it to noalias.'

Currently there is no mechanism to accurately describe nested restrict pointers 
in LLVM-IR. imho, that means that
we should adapt the wording in a more specific way. Something like:

This guarantee only holds for memory locations that are *modified*, by any 
means, during the execution the function.
  + Note that, just like C99 restrict, in this context, memory locations whose 
content is used as a pointer value to modify a memory location,
  + are also considered to modify the former memory locations.
The attribute

> 
> 
>>> 2. The extended `noalias` deduction D73428 
>>> .

[..]

>> That sounds good. Is there also a testcase (similar to D74935#1907100 
>>  or D74935#1907939 
>>  ) that explicitly checks that 
>> 'noalias' is not deduced ?
> 
> I'll add one :)

thanks !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D75569: [clang-tidy] New check for methods marked __attribute__((unavailable)) that do not override a method from a superclass.

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp:34
+// Matches Objective-C methods that are not overriding a superclass method.
+AST_MATCHER(ObjCMethodDecl, isNotOverriding) { return !Node.isOverriding(); }
+

Not a point for this patch, but maybe this should be made into an actual 
matcher, though not complimented, or better yet the `CXXMethodDecl` 
`isOverride` matcher be extended for `ObjCMethodDecl`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75569



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


[clang] 4a0267e - Convert a reachable llvm_unreachable into an assert.

2020-03-10 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-03-10T14:22:21-04:00
New Revision: 4a0267e3ad8c4d47f267d7d960f127e099fb4818

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

LOG: Convert a reachable llvm_unreachable into an assert.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp 
b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 01ac2bc83bb6..99e16752b51a 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -134,9 +134,9 @@ StringRef AnalyzerOptions::getCheckerStringOption(StringRef 
CheckerName,
 CheckerName = CheckerName.substr(0, Pos);
   } while (!CheckerName.empty() && SearchInParents);
 
-  llvm_unreachable("Unknown checker option! Did you call getChecker*Option "
-   "with incorrect parameters? User input must've been "
-   "verified by CheckerRegistry.");
+  assert(false && "Unknown checker option! Did you call getChecker*Option "
+  "with incorrect parameters? User input must've been "
+  "verified by CheckerRegistry.");
 
   return "";
 }



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


[clang] 9624beb - [docs] Regenerate ClangCommandLineReference.rst

2020-03-10 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-03-10T11:10:18-07:00
New Revision: 9624beb38a46037f69362650a52e06d8be4fd006

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

LOG: [docs] Regenerate ClangCommandLineReference.rst

Just ran clang-tblgen -gen-opt-docs ClangOptionDocs.td

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 5af9d64ae0fc..74e831c36eb9 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -90,7 +90,7 @@ Run the static analyzer
 
 .. option:: --analyzer-output
 
-Static analyzer report output format 
(html\|plist\|plist-multi-file\|plist-html\|text).
+Static analyzer report output format 
(html\|plist\|plist-multi-file\|plist-html\|sarif\|text).
 
 .. option:: -ansi, --ansi
 
@@ -122,14 +122,6 @@ Output path for the plist report
 .. option:: -bundle\_loader 
 .. program:: clang
 
-.. option:: -cfguard
-
-Emit tables and checks for Windows Control Flow Guard.
-
-.. option:: -cfguard-no-checks
-
-Emit tables required for Windows Control Flow Guard without checks.
-
 .. option:: -client\_name
 
 .. option:: -compatibility\_version
@@ -200,6 +192,10 @@ Filename (or -) to write dependency output to
 
 Emit Clang AST files for source inputs
 
+.. option:: 
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+
+Trivial automatic variable initialization to zero is only here for benchmarks, 
it'll eventually be removed, and I'm OK with that because I'm only using it to 
benchmark
+
 .. option:: -exported\_symbols\_list 
 
 .. option:: -faligned-new=
@@ -212,10 +208,6 @@ Use approximate transcendental functions
 
 Flush denormal floating point values to zero in CUDA device mode.
 
-.. option:: -fcuda-rdc, -fno-cuda-rdc
-
-Generate relocatable device code, also known as separate compilation mode.
-
 .. option:: -fcuda-short-ptr, -fno-cuda-short-ptr
 
 Use 32-bit pointers for accessing const/local/shared address spaces.
@@ -224,8 +216,20 @@ Use 32-bit pointers for accessing const/local/shared 
address spaces.
 
 Reserve register r19 (Hexagon only)
 
+.. option:: -fgpu-allow-device-init, -fno-gpu-allow-device-init
+
+Allow device side init function in HIP
+
+.. option:: -fgpu-rdc, -fcuda-rdc, -fno-gpu-rdc
+
+Generate relocatable device code, also known as separate compilation mode.
+
 .. option:: -fheinous-gnu-extensions
 
+.. option:: -fhip-new-launch-api, -fno-hip-new-launch-api
+
+Use new kernel launching API for HIP.
+
 .. option:: -flat\_namespace
 
 .. option:: -fopenmp-targets=,...
@@ -248,6 +252,14 @@ Specify comma-separated list of triples OpenMP offloading 
targets to be supporte
 
 Add -rpath with architecture-specific resource directory to the linker flags
 
+.. option:: -fsanitize-system-blacklist=
+
+Path to system blacklist file for sanitizers
+
+.. option:: -fsystem-module
+
+Build this module as a system module. Only used with -emit-module
+
 .. option:: --gcc-toolchain=, -gcc-toolchain 
 
 Use the gcc toolchain at the given directory
@@ -256,6 +268,16 @@ Use the gcc toolchain at the given directory
 
 Generate CodeView debug information
 
+.. option:: -gcodeview-ghash, -gno-codeview-ghash
+
+Emit type record hashes in a .debug$H section
+
+.. option:: -ginline-line-tables, -gno-inline-line-tables
+
+.. option:: --gpu-max-threads-per-block=
+
+Default max threads per block for kernel launch bounds for HIP
+
 .. option:: -headerpad\_max\_install\_names
 
 .. option:: -help, --help
@@ -270,6 +292,10 @@ Display help for hidden options
 
 Link clang-offload-bundler bundles for HIP
 
+.. option:: -ibuiltininc
+
+Enable builtin #include directories even when -nostdinc is used before or 
after -ibuiltininc. Using -nobuiltininc after the option disables it
+
 .. option:: -image\_base 
 
 .. option:: -index-header-map
@@ -280,6 +306,8 @@ Make the next included directory (-I or -F) an indexer 
header map
 
 .. option:: -install\_name 
 
+.. option:: -interface-stub-version=
+
 .. option:: -keep\_private\_externs
 
 .. option:: -lazy\_framework 
@@ -290,6 +318,10 @@ Make the next included directory (-I or -F) an indexer 
header map
 
 .. option:: -mbig-endian, -EB
 
+.. option:: -mbranch-protection=
+
+Enforce targets of indirect branches and function returns
+
 .. option:: --migrate
 
 Run the migrator
@@ -334,12 +366,14 @@ Disable builtin #include directories
 
 .. option:: -nocudainc
 
-.. option:: -nocudalib
-
 .. option:: -nodefaultlibs
 
 .. option:: -nofixprebinding
 
+.. option:: -nogpulib, -nocudalib
+
+Do not link device library for CUDA/HIP device compilation
+
 .. option:: -nolibc
 
 .. option:: -nomultidefs
@@ -594,6 +628,12 @@ Statically link the sanitizer runtime
 

[clang] 57a2eaf - Revert "[modules] Do not cache invalid state for modules that we attempted to load."

2020-03-10 Thread Rumeet Dhindsa via cfe-commits

Author: Rumeet Dhindsa
Date: 2020-03-10T10:59:26-07:00
New Revision: 57a2eaf3c1aa1a08e9b474b873064e075c52daef

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

LOG: Revert "[modules] Do not cache invalid state for modules that we attempted 
to load."
As per comment on https://reviews.llvm.org/D72860, it is suggested to
revert this change in the meantime, since it has introduced regression.

This reverts commit 83f4c3af021cd5322ea10fd1c4e839874c1dae49.

Added: 
clang/test/Modules/Inputs/implicit-invalidate-chain/A.h
clang/test/Modules/Inputs/implicit-invalidate-chain/B.h
clang/test/Modules/Inputs/implicit-invalidate-chain/C.h
clang/test/Modules/Inputs/implicit-invalidate-chain/module.modulemap
clang/test/Modules/implicit-invalidate-chain.c

Modified: 
clang/include/clang/Serialization/InMemoryModuleCache.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/InMemoryModuleCache.cpp
clang/lib/Serialization/ModuleManager.cpp
clang/unittests/Frontend/FrontendActionTest.cpp
clang/unittests/Serialization/InMemoryModuleCacheTest.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/InMemoryModuleCache.h 
b/clang/include/clang/Serialization/InMemoryModuleCache.h
index c4814c40e1df..7b5b5c1cf1be 100644
--- a/clang/include/clang/Serialization/InMemoryModuleCache.h
+++ b/clang/include/clang/Serialization/InMemoryModuleCache.h
@@ -45,35 +45,61 @@ class InMemoryModuleCache : public 
llvm::RefCountedBase {
   llvm::StringMap PCMs;
 
 public:
+  /// There are four states for a PCM.  It must monotonically increase.
+  ///
+  ///  1. Unknown: the PCM has neither been read from disk nor built.
+  ///  2. Tentative: the PCM has been read from disk but not yet imported or
+  /// built.  It might work.
+  ///  3. ToBuild: the PCM read from disk did not work but a new one has not
+  /// been built yet.
+  ///  4. Final: indicating that the current PCM was either built in this
+  /// process or has been successfully imported.
+  enum State { Unknown, Tentative, ToBuild, Final };
+
+  /// Get the state of the PCM.
+  State getPCMState(llvm::StringRef Filename) const;
+
   /// Store the PCM under the Filename.
   ///
-  /// \pre PCM for the same Filename shouldn't be in cache already.
+  /// \pre state is Unknown
+  /// \post state is Tentative
   /// \return a reference to the buffer as a convenience.
   llvm::MemoryBuffer (llvm::StringRef Filename,
  std::unique_ptr Buffer);
 
-  /// Store a final PCM under the Filename.
+  /// Store a just-built PCM under the Filename.
   ///
-  /// \pre PCM for the same Filename shouldn't be in cache already.
+  /// \pre state is Unknown or ToBuild.
+  /// \pre state is not Tentative.
   /// \return a reference to the buffer as a convenience.
-  llvm::MemoryBuffer (llvm::StringRef Filename,
+  llvm::MemoryBuffer (llvm::StringRef Filename,
   std::unique_ptr Buffer);
 
-  /// Try to remove a PCM from the cache.  No effect if it is Final.
+  /// Try to remove a buffer from the cache.  No effect if state is Final.
   ///
-  /// \return false on success.
-  bool tryToRemovePCM(llvm::StringRef Filename);
+  /// \pre state is Tentative/Final.
+  /// \post Tentative => ToBuild or Final => Final.
+  /// \return false on success, i.e. if Tentative => ToBuild.
+  bool tryToDropPCM(llvm::StringRef Filename);
 
   /// Mark a PCM as final.
+  ///
+  /// \pre state is Tentative or Final.
+  /// \post state is Final.
   void finalizePCM(llvm::StringRef Filename);
 
-  /// Get a pointer to the PCM if it exists; else nullptr.
+  /// Get a pointer to the pCM if it exists; else nullptr.
   llvm::MemoryBuffer *lookupPCM(llvm::StringRef Filename) const;
 
   /// Check whether the PCM is final and has been shown to work.
   ///
   /// \return true iff state is Final.
   bool isPCMFinal(llvm::StringRef Filename) const;
+
+  /// Check whether the PCM is waiting to be built.
+  ///
+  /// \return true iff state is ToBuild.
+  bool shouldBuildPCM(llvm::StringRef Filename) const;
 };
 
 } // end namespace clang

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index b5ca1e1841ac..63c817b02bf1 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4502,7 +4502,7 @@ ASTReader::ReadASTCore(StringRef FileName,
 if (ShouldFinalizePCM)
   MC.finalizePCM(FileName);
 else
-  MC.tryToRemovePCM(FileName);
+  MC.tryToDropPCM(FileName);
   });
   ModuleFile  = *M;
   BitstreamCursor  = F.Stream;

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index bf893c7ff3bf..1278841a15a2 100644

[PATCH] D75896: [X86] Support intrinsic _mm_cldemote

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/cldemoteintrin.h:27
+///
+/// This intrinsic corresponds to the  CLDRMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS

CLDRMOTE->CLDEMOTE


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75896



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


[PATCH] D75897: [X86] Support intrinsic _mm_broadcastsi128_si256

2020-03-10 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75897



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66945b62f42f: Add Optional overload to DiagnosticBuilder 
operator  (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang/include/clang/Basic/Diagnostic.h

Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -1288,6 +1289,29 @@
   return DB;
 }
 
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder ,
+   const llvm::Optional ) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+}
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder ,
+   const llvm::Optional ) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+}
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder , const llvm::Optional ) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+}
+
 /// A nullability kind paired with a bit indicating whether it used a
 /// context-sensitive keyword.
 using DiagNullabilityKind = std::pair;
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -429,11 +429,9 @@
   if (MakeSmartPtrFunctionHeader.empty()) {
 return;
   }
-  if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
-  FD, MakeSmartPtrFunctionHeader,
-  /*IsAngled=*/MakeSmartPtrFunctionHeader == StdMemoryHeader)) {
-Diag << *IncludeFixit;
-  }
+  Diag << Inserter->CreateIncludeInsertion(
+  FD, MakeSmartPtrFunctionHeader,
+  /*IsAngled=*/MakeSmartPtrFunctionHeader == StdMemoryHeader);
 }
 
 } // namespace modernize
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -86,13 +86,10 @@
   SourceRange(BaseRange.getEnd().getLocWithOffset(1),
   IndexRange.getBegin().getLocWithOffset(-1)),
   ", ")
-   << FixItHint::CreateReplacement(Matched->getEndLoc(), ")");
-
-  Optional Insertion = Inserter->CreateIncludeInsertion(
-  Result.SourceManager->getMainFileID(), GslHeader,
-  /*IsAngled=*/false);
-  if (Insertion)
-Diag << Insertion.getValue();
+   << FixItHint::CreateReplacement(Matched->getEndLoc(), ")")
+   << Inserter->CreateIncludeInsertion(
+  Result.SourceManager->getMainFileID(), GslHeader,
+  /*IsAngled=*/false);
 }
 return;
   }
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -96,10 +96,8 @@
MatchedDecl->getName().size()),
InitializationString);
 if (AddMathInclude) {
-  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
+  Diagnostic << IncludeInserter->CreateIncludeInsertion(
   Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader, false);
-  if (IncludeHint)
-Diagnostic << *IncludeHint;
 }
   }
 }
Index: clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -105,12 +105,9 @@
 
   // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
   // whether this already exists).
-  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
+  Diagnostic << IncludeInserter->CreateIncludeInsertion(
   Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader,
   false);
-  if (IncludeHint) {
-Diagnostic << *IncludeHint;
-  }
 }
 
 

[PATCH] D75927: [clangd] Use a separate RunningTask flag instead of leaving a broken request on top of the queue

2020-03-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39eebe68b599: [clangd] Use a separate RunningTask flag 
instead of leaving a broken request on… (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75927

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -367,6 +367,30 @@
   << "All reads other than R2B were cancelled";
 }
 
+TEST_F(TUSchedulerTests, InvalidationNoCrash) {
+  auto Path = testPath("foo.cpp");
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  Notification StartedRunning;
+  Notification ScheduledChange;
+  // We expect invalidation logic to not crash by trying to invalidate a running
+  // request.
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Auto);
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+  S.runWithAST(
+  "invalidatable-but-running", Path,
+  [&](llvm::Expected AST) {
+StartedRunning.notify();
+ScheduledChange.wait();
+ASSERT_TRUE(bool(AST));
+  },
+  TUScheduler::InvalidateOnUpdate);
+  StartedRunning.wait();
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Auto);
+  ScheduledChange.notify();
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
+
 TEST_F(TUSchedulerTests, Invalidation) {
   auto Path = testPath("foo.cpp");
   TUScheduler S(CDB, optsForTest(), captureDiags());
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -274,8 +274,9 @@
   /// Becomes ready when the first preamble build finishes.
   Notification PreambleWasBuilt;
   /// Set to true to signal run() to finish processing.
-  bool Done;/* GUARDED_BY(Mutex) */
-  std::deque Requests; /* GUARDED_BY(Mutex) */
+  bool Done;  /* GUARDED_BY(Mutex) */
+  std::deque Requests;   /* GUARDED_BY(Mutex) */
+  llvm::Optional CurrentRequest; /* GUARDED_BY(Mutex) */
   mutable std::condition_variable RequestsCV;
   /// Guards the callback that publishes results of AST-related computations
   /// (diagnostics, highlightings) and file statuses.
@@ -370,7 +371,8 @@
 #ifndef NDEBUG
   std::lock_guard Lock(Mutex);
   assert(Done && "handle was not destroyed");
-  assert(Requests.empty() && "unprocessed requests when destroying ASTWorker");
+  assert(Requests.empty() && !CurrentRequest &&
+ "unprocessed requests when destroying ASTWorker");
 #endif
 }
 
@@ -606,8 +608,10 @@
   auto LastUpdate =
   std::find_if(Requests.rbegin(), Requests.rend(),
[](const Request ) { return R.UpdateType.hasValue(); });
-  // If there were no writes in the queue, the preamble is ready now.
-  if (LastUpdate == Requests.rend()) {
+  // If there were no writes in the queue, and CurrentRequest is not a write,
+  // the preamble is ready now.
+  if (LastUpdate == Requests.rend() &&
+  (!CurrentRequest || CurrentRequest->UpdateType.hasValue())) {
 Lock.unlock();
 return Callback(getPossiblyStalePreamble());
   }
@@ -714,9 +718,9 @@
 
 void ASTWorker::run() {
   while (true) {
-Request Req;
 {
   std::unique_lock Lock(Mutex);
+  assert(!CurrentRequest && "A task is already running, multiple workers?");
   for (auto Wait = scheduleLocked(); !Wait.expired();
Wait = scheduleLocked()) {
 if (Done) {
@@ -734,7 +738,7 @@
   Tracer.emplace("Debounce");
   SPAN_ATTACH(*Tracer, "next_request", Requests.front().Name);
   if (!(Wait == Deadline::infinity())) {
-emitTUStatus({TUAction::Queued, Req.Name});
+emitTUStatus({TUAction::Queued, Requests.front().Name});
 SPAN_ATTACH(*Tracer, "sleep_ms",
 std::chrono::duration_cast(
 Wait.time() - steady_clock::now())
@@ -744,26 +748,28 @@
 
 wait(Lock, RequestsCV, Wait);
   }
-  Req = std::move(Requests.front());
-  // Leave it on the queue for now, so waiters don't see an empty queue.
+  CurrentRequest = std::move(Requests.front());
+  Requests.pop_front();
 } // unlock Mutex
 
+// It is safe to perform reads to CurrentRequest without holding the lock as
+// only writer is also this thread.
 {
   std::unique_lock Lock(Barrier, std::try_to_lock);
   if (!Lock.owns_lock()) {
-emitTUStatus({TUAction::Queued, Req.Name});
+emitTUStatus({TUAction::Queued, CurrentRequest->Name});
 Lock.lock();
   }
-  WithContext 

[PATCH] D75901: [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

If you need help for the test case. Create a file in the 
`clang-tools-extra/test/clang-tidy/checkers`. 
Name it something like `misc-unconventional-assign-operator-pre11.cpp` and 
paste this in

  // RUN: %check_clang_tidy -std=c++98,c++03 %s 
misc-unconventional-assign-operator %t
  
  struct BadArgument {
BadArgument& operator=(BadArgument&);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 
'BadArgument const&' or 'BadArgument'
  };


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75901



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


[PATCH] D69903: [Basic] Introduce PODSourceLocation, NFCI

2020-03-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 249447.
miyuki added a comment.

Rebased


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

https://reviews.llvm.org/D69903

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclarationName.h
  clang/include/clang/AST/DependentDiagnostic.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/Token.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Designator.h
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclarationName.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/clang-refactor/TestSupport.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3293,9 +3293,9 @@
 Pieces.push_back(*TemplateArgsLoc);
 
   if (Kind == DeclarationName::CXXOperatorName) {
-Pieces.push_back(SourceLocation::getFromRawEncoding(
+Pieces.push_back(SourceLocation::getFromPOD(
NI.getInfo().CXXOperatorName.BeginOpNameLoc));
-Pieces.push_back(SourceLocation::getFromRawEncoding(
+Pieces.push_back(SourceLocation::getFromPOD(
NI.getInfo().CXXOperatorName.EndOpNameLoc));
   }
   
Index: clang/tools/clang-refactor/TestSupport.cpp
===
--- clang/tools/clang-refactor/TestSupport.cpp
+++ clang/tools/clang-refactor/TestSupport.cpp
@@ -313,7 +313,9 @@
   LangOptions LangOpts;
   LangOpts.CPlusPlus = 1;
   LangOpts.CPlusPlus11 = 1;
-  Lexer Lex(SourceLocation::getFromRawEncoding(0), LangOpts, Source.begin(),
+  PODSourceLocation BeginLoc;
+  BeginLoc.clear();
+  Lexer Lex(SourceLocation::getFromPOD(BeginLoc), LangOpts, Source.begin(),
 Source.begin(), Source.end());
   Lex.SetCommentRetentionState(true);
   Token Tok;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -5380,14 +5380,14 @@
 break;
 
   case DeclarationName::CXXOperatorName:
-AddSourceLocation(SourceLocation::getFromRawEncoding(
+AddSourceLocation(SourceLocation::getFromPOD(
 DNLoc.CXXOperatorName.BeginOpNameLoc));
 AddSourceLocation(
-SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.EndOpNameLoc));
+SourceLocation::getFromPOD(DNLoc.CXXOperatorName.EndOpNameLoc));
 break;
 
   case DeclarationName::CXXLiteralOperatorName:
-AddSourceLocation(SourceLocation::getFromRawEncoding(
+AddSourceLocation(SourceLocation::getFromPOD(
 DNLoc.CXXLiteralOperatorName.OpNameLoc));
 break;
 
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8582,14 +8582,14 @@
 
   case DeclarationName::CXXOperatorName:
 DNLoc.CXXOperatorName.BeginOpNameLoc
-  = readSourceLocation().getRawEncoding();
+  = readSourceLocation().getPOD();
 DNLoc.CXXOperatorName.EndOpNameLoc
-  = readSourceLocation().getRawEncoding();
+  = readSourceLocation().getPOD();
 break;
 
   case DeclarationName::CXXLiteralOperatorName:
 DNLoc.CXXLiteralOperatorName.OpNameLoc
-  = readSourceLocation().getRawEncoding();
+  = readSourceLocation().getPOD();
 break;
 
   case DeclarationName::Identifier:
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -13686,9 +13686,9 @@
 
 if (DeclRefExpr *DRE = dyn_cast(Callee)) {
 DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo();
-LBrace = SourceLocation::getFromRawEncoding(
+LBrace = SourceLocation::getFromPOD(
 NameLoc.CXXOperatorName.BeginOpNameLoc);
-RBrace = SourceLocation::getFromRawEncoding(
+RBrace = SourceLocation::getFromPOD(
 NameLoc.CXXOperatorName.EndOpNameLoc);
 } else {
   LBrace = Callee->getBeginLoc();
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2909,11 

[PATCH] D69844: [Basic] Integrate SourceLocation and SourceRange with FoldingSet, NFCI

2020-03-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 249444.
miyuki retitled this revision from "[Basic] Integrate SourceLocation with 
FoldingSet, NFCI" to "[Basic] Integrate SourceLocation and SourceRange with 
FoldingSet, NFCI".
miyuki added a comment.
Herald added a subscriber: martong.

Rebased, added similar integration for SourceRange


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

https://reviews.llvm.org/D69844

Files:
  clang/include/clang/Basic/SourceLocation.h
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2144,8 +2144,7 @@
   for (SourceRange range : Ranges) {
 if (!range.isValid())
   continue;
-hash.AddInteger(range.getBegin().getRawEncoding());
-hash.AddInteger(range.getEnd().getRawEncoding());
+hash.Add(range);
   }
 }
 
@@ -2167,8 +2166,7 @@
   for (SourceRange range : Ranges) {
 if (!range.isValid())
   continue;
-hash.AddInteger(range.getBegin().getRawEncoding());
-hash.AddInteger(range.getEnd().getRawEncoding());
+hash.Add(range);
   }
 }
 
Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -74,11 +75,20 @@
   return OS.str();
 }
 
+void SourceLocation::Profile(llvm::FoldingSetNodeID ) const {
+  Node.AddInteger(ID);
+}
+
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager ) const {
   print(llvm::errs(), SM);
   llvm::errs() << '\n';
 }
 
+void SourceRange::Profile(llvm::FoldingSetNodeID ) const {
+  B.Profile(Node);
+  E.Profile(Node);
+}
+
 LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager ) const {
   print(llvm::errs(), SM);
   llvm::errs() << '\n';
Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -1067,9 +1067,8 @@
 //===--===//
 
 void PathDiagnosticLocation::Profile(llvm::FoldingSetNodeID ) const {
-  ID.AddInteger(Range.getBegin().getRawEncoding());
-  ID.AddInteger(Range.getEnd().getRawEncoding());
-  ID.AddInteger(Loc.getRawEncoding());
+  ID.Add(Range);
+  ID.Add(Loc);
 }
 
 void PathDiagnosticPiece::Profile(llvm::FoldingSetNodeID ) const {
@@ -1078,10 +1077,8 @@
   // FIXME: Add profiling support for code hints.
   ID.AddInteger((unsigned) getDisplayHint());
   ArrayRef Ranges = getRanges();
-  for (const auto  : Ranges) {
-ID.AddInteger(I.getBegin().getRawEncoding());
-ID.AddInteger(I.getEnd().getRawEncoding());
-  }
+  for (const auto  : Ranges)
+ID.Add(I);
 }
 
 void PathDiagnosticCallPiece::Profile(llvm::FoldingSetNodeID ) const {
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -26,6 +26,8 @@
 
 template  struct DenseMapInfo;
 
+class FoldingSetNodeID;
+
 } // namespace llvm
 
 namespace clang {
@@ -179,6 +181,9 @@
 return ID * 37U;
   }
 
+  /// Write this source location to a FoldingSetNodeID
+  void Profile(llvm::FoldingSetNodeID ) const;
+
   void print(raw_ostream , const SourceManager ) const;
   std::string printToString(const SourceManager ) const;
   void dump(const SourceManager ) const;
@@ -239,6 +244,9 @@
 return B <= other.B && E >= other.E;
   }
 
+  /// Write this source range to a FoldingSetNodeID
+  void Profile(llvm::FoldingSetNodeID ) const;
+
   void print(raw_ostream , const SourceManager ) const;
   std::string printToString(const SourceManager ) const;
   void dump(const SourceManager ) const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75894: [X86] Support intrinsics _bextr2*

2020-03-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/bmiintrin.h:367
+}
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.

Add a blank line here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75894



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


  1   2   3   >