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

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

Can objc instance methods be redeclared, the AST suggests so, if so you should 
probably only warm on the first occurrence but create fix its for each.


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


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

2020-03-06 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast updated this revision to Diff 248900.

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 %T/Headers/fuchsia-restrict-system-includes/system
-// RUN: FileCheck -input-file=%T/Headers/fuchsia-restrict-system-includes/transitive2.h %s -check-prefix=CHECK-FIXES
+// RUN:   -- -I %T/Headers/portability-restrict-system-includes -isystem 

[PATCH] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

2020-03-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

In D75788#1910743 , @JonChesterfield 
wrote:

> That's less invasive than I feared. Nicely done.


We need to run some more tests to make sure it works as expected but I hope we 
can completely piggy back on the underlying "language" support.

> It may worth keeping the openmp header wrapper to do architecture dispatch. 
> Something like:

We can do that or adjust the pipeline based on the target, either is fine with 
me.




Comment at: clang/lib/Headers/cuda_wrappers/new:36
 
+#ifdef _OPENMP
+#define __DEVICE__

JonChesterfield wrote:
> macros look off here - should it be `#define DEVICE`, or the following uses 
> `__DEVICE__`?
Yes.

Furthermore I think I want to introduce the effect of `__device__` as an 
attribute, basically `match(device={arch(nvptx)}` on a single function. That 
would make the declare variant go away and allow us to piggy back on the 
`__DEVICE__` directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788



___
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-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:130
 ^^
+- The 'fuchsia-restrict-system-headers' check was renamed to 
:doc:`portability-restrict-system-includes
+  

Please insert empty line above.


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] D75723: [X86] Make intrinsics _BitScan* not limited to Windows

2020-03-06 Thread Kan Shengchen via Phabricator via cfe-commits
skan marked an inline comment as done.
skan added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsX86.def:1904
+// BITSCAN
+TARGET_BUILTIN(_BitScanForward, "UcUNi*UNi", "n", "")
+TARGET_BUILTIN(_BitScanReverse, "UcUNi*UNi", "n", "")

rnk wrote:
> craig.topper wrote:
> > skan wrote:
> > > craig.topper wrote:
> > > > The N specifier here is sort of MSVC mode specific. I need to think 
> > > > about this.
> > > > 
> > > > This also makes this available without including a header file which 
> > > > isn't good if it doesn't start with __builtin.
> > > I think we can define a new builtin `__builtin_ia32_BitScanForward` in 
> > > BuiltinsX86.def. And when macro `_MSC_VER` is not defined, define 
> > > `_BitScanForward` in ia32intrin.h by calling the 
> > > `__builtin_ia32_BitScanForward`. Then we can avoid the N specifier and 
> > > the name issue. Do you think it's appropriate?
> > Instead of new builtins, can we use  __builtin_clz, __builtin_clzl, 
> > __builin_ctz, __builtin_ctzl?
> Right, even though _BitScan* is in the implementers namespace, we want to be 
> careful about adding builtins that don't start with `__builtin_`. Unless we 
> set some dramatically new direction of making all the implementer's namespace 
> MSVC builtins available everywhere, I don't see why we would do this when we 
> already have equivalent builtins.
> 
> Is there some particular motivation as to why you want to make these 
> available everywhere? `-fms-extensions` is kind of already available 
> everywhere. This compiles on Linux with `-fms-extensions`:
> ```
> extern unsigned char _BitScanReverse64(unsigned int *, unsigned long long);
> unsigned char test_BitScanReverse64(unsigned int *index, unsigned long long 
> mask) {
>   return _BitScanReverse64(index, mask);
> }
> ```
My thought is that the page [[ 
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=408,410,404,460,404,405,408=BitScan
 | intel intrinsic guide ]] says we can use the intrinsics _BitScan* as long as 
we include the header file  immintrin.h, so we need support them on linux for 
user convenience even though similar intrinsics _bit_scan_* are available.

Since the purpose is to support **intrinsics** _BitScan* on linux rather than 
**builtin** _BitScan*, I think we can wrap the intrinsiscs with existing 
builtin as craig suggested. 


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] D75786: [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.

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

Thanks for the heads up phosek, I removed the check from fuchsia's directory. 
Also addressed Eurgene.Zelenko's comments. (:


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 %T/Headers/fuchsia-restrict-system-includes/system
-// RUN: FileCheck 

[PATCH] D75700: [NFC] Let mangler accept GlobalDecl

2020-03-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/AST/Expr.cpp:693
 else
-  MC->mangleName(ND, Out);
+  GD = GlobalDecl(ND);
+MC->mangleName(GD, Out);

This will need an extension for your case, right?  Maybe there should be 
comments in `GlobalDecl` pointing out all the places where we need to go from 
an arbitrary `Decl*` to a `GlobalDecl` so that someone adding a new kind of 
discriminated declaration will know to update them all.



Comment at: clang/lib/AST/ItaniumMangle.cpp:1563
+  else
+GD = GlobalDecl(dyn_cast(DC));
+  return GD;

`cast`?  But I'm not sure this is true, local entities can be in non-function 
declarations: blocks, ObjC methods, and captured statements.  You can just 
`cast(DC)`.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1028
 else
-  MC.mangleName(ND, Out);
+  MC.mangleName(GD, Out);
   } else {

yaxunl wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > What would be necessary in order for this to turn into just 
> > > `mangleName(GD, Out)`?   I suspect there are a lot of subtle assumptions 
> > > between the different mangling methods today that could probably be 
> > > broken down a bit and we'd end up with something much cleaner.
> > It seems to be just API changes. I will try changing them.
> I got one issue. When I tried to create `GlobalDecl(CD, Ctor_DefaultClosure)` 
> I got assertion
> 
> include/llvm/ADT/PointerIntPair.h:186: static intptr_t 
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits >::updateInt(intptr_t, 
> intptr_t) [PointerT = const clang::Decl *, IntBits = 2, PtrTraits = 
> llvm::PointerLikeTypeTraits]: Assertion `(IntWord & 
> ~IntMask) == 0 && "Integer too large for field"' failed.
> CXXConstructor=v:7:25 (default constructor) (converting constructor)
> 
> This is because Ctor_DefaultClosure has value 4, which exceeds the value that 
> can be put into PointerIntPairInfo
It looks like `Decl` is declared with alignment 8, so yeah, it's safe to make 
that a 3-bit field.


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

https://reviews.llvm.org/D75700



___
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-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:107
+
+  Moved fuchsia's restrict-system-includes check to portability to allow for
+  general use.

I don't think that this statement is necessary.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst:10
+
+In order to **only** allow zlib.h from the system you would set the options to
+`-*,zlib.h`.

Please highlight zlib.h with single back-ticks.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst:20
+
+In order to allow everything **except** zlib.h from the system you would set
+the options to `*,-zlib.h`.

Please highlight zlib.h with single back-ticks.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst:50
+   filenames. Similar to the -checks glob list for running clang-tidy itself,
+   the two wildcard characters are '*' and '-', to include and exclude globs,
+   respectively. The default is '*', which allows all includes.

Please use single back-ticks for highlighting options values. Same above.


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] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

2020-03-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

That's less invasive than I feared. Nicely done.

It may worth keeping the openmp header wrapper to do architecture dispatch. 
Something like:

  #ifndef __CLANG_OPENMP_MATH_DECLARES_H__
  #define __CLANG_OPENMP_MATH_DECLARES_H__
  
  #ifndef _OPENMP
  #error "This file is for OpenMP compilation only."
  #endif
  
  #if defined(__AMDGCN__)
  #pragma omp begin declare variant match(device = {arch(amdgcn)})
  #include "equivalent_header.h"
  #pragma omp end declare variant
  #endif // __AMDGCN__
  
  #if defined(__NVPTX__)
  #define __CUDA__
  #pragma omp begin declare variant match(device = {arch(nvptx)})
  
  #if defined(__cplusplus)
  #include <__clang_cuda_math_forward_declares.h>
  #endif
  
  /// Include declarations for libdevice functions.
  #include <__clang_cuda_libdevice_declares.h>
  /// Provide definitions for these functions.
  #include <__clang_cuda_device_functions.h>
  
  #pragma omp end declare variant
  #undef __CUDA__
  #endif // __NVPTX__
  
  
  #endif // __CLANG_OPENMP_MATH_DECLARES_H__




Comment at: clang/lib/Headers/cuda_wrappers/new:36
 
+#ifdef _OPENMP
+#define __DEVICE__

macros look off here - should it be `#define DEVICE`, or the following uses 
`__DEVICE__`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788



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


[PATCH] D75700: [NFC] Let mangler accept GlobalDecl

2020-03-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 248873.
yaxunl added a comment.

Remove mangleCXXCtor/Dtor.


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

https://reviews.llvm.org/D75700

Files:
  clang/include/clang/AST/GlobalDecl.h
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3922,7 +3922,7 @@
   // Calculate the mangled name.
   SmallString<256> ThunkName;
   llvm::raw_svector_ostream Out(ThunkName);
-  getMangleContext().mangleCXXCtor(CD, CT, Out);
+  getMangleContext().mangleName(GlobalDecl(CD, CT), Out);
 
   // If the thunk has been generated previously, just return it.
   if (llvm::GlobalValue *GV = CGM.getModule().getNamedValue(ThunkName))
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1019,22 +1019,15 @@
   SmallString<256> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
   MangleContext  = CGM.getCXXABI().getMangleContext();
-  if (MC.shouldMangleDeclName(ND)) {
-llvm::raw_svector_ostream Out(Buffer);
-if (const auto *D = dyn_cast(ND))
-  MC.mangleCXXCtor(D, GD.getCtorType(), Out);
-else if (const auto *D = dyn_cast(ND))
-  MC.mangleCXXDtor(D, GD.getDtorType(), Out);
-else
-  MC.mangleName(ND, Out);
-  } else {
+  if (MC.shouldMangleDeclName(ND))
+MC.mangleName(GD.getWithDecl(ND), Out);
+  else {
 IdentifierInfo *II = ND->getIdentifier();
 assert(II && "Attempt to mangle unnamed decl.");
 const auto *FD = dyn_cast(ND);
 
 if (FD &&
 FD->getType()->castAs()->getCallConv() == CC_X86RegCall) {
-  llvm::raw_svector_ostream Out(Buffer);
   Out << "__regcall3__" << II->getName();
 } else {
   Out << II->getName();
@@ -4473,7 +4466,7 @@
 
   maybeSetTrivialComdat(*D, *Fn);
 
-  CodeGenFunction(*this).GenerateCode(D, Fn, FI);
+  CodeGenFunction(*this).GenerateCode(GD, Fn, FI);
 
   setNonAliasAttributes(GD, Fn);
   SetLLVMFunctionAttributesForDefinition(D, Fn);
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2412,13 +2412,14 @@
 }
 
 static llvm::Constant *EmitFunctionDeclPointer(CodeGenModule ,
-   const FunctionDecl *FD) {
+   GlobalDecl GD) {
+  const FunctionDecl *FD = cast(GD.getDecl());
   if (FD->hasAttr()) {
 ConstantAddress aliasee = CGM.GetWeakRefReference(FD);
 return aliasee.getPointer();
   }
 
-  llvm::Constant *V = CGM.GetAddrOfFunction(FD);
+  llvm::Constant *V = CGM.GetAddrOfFunction(GD);
   if (!FD->hasPrototype()) {
 if (const FunctionProtoType *Proto =
 FD->getType()->getAs()) {
@@ -2435,9 +2436,10 @@
   return V;
 }
 
-static LValue EmitFunctionDeclLValue(CodeGenFunction ,
- const Expr *E, const FunctionDecl *FD) {
-  llvm::Value *V = EmitFunctionDeclPointer(CGF.CGM, FD);
+static LValue EmitFunctionDeclLValue(CodeGenFunction , const Expr *E,
+ GlobalDecl GD) {
+  const FunctionDecl *FD = cast(GD.getDecl());
+  llvm::Value *V = EmitFunctionDeclPointer(CGF.CGM, GD);
   CharUnits Alignment = CGF.getContext().getDeclAlign(FD);
   return CGF.MakeAddrLValue(V, E->getType(), Alignment,
 AlignmentSource::Decl);
@@ -4637,7 +4639,8 @@
   return EmitCall(E->getCallee()->getType(), Callee, E, ReturnValue);
 }
 
-static CGCallee EmitDirectCallee(CodeGenFunction , const FunctionDecl *FD) {
+static CGCallee EmitDirectCallee(CodeGenFunction , GlobalDecl GD) {
+  const FunctionDecl *FD = cast(GD.getDecl());
 
   if (auto builtinID = FD->getBuiltinID()) {
 // Replaceable builtin provide their own implementation of a builtin. Unless
@@ -4649,8 +4652,8 @@
   return CGCallee::forBuiltin(builtinID, FD);
   }
 
-  llvm::Constant *calleePtr = EmitFunctionDeclPointer(CGF.CGM, FD);
-  return CGCallee::forDirect(calleePtr, GlobalDecl(FD));
+  llvm::Constant *calleePtr = EmitFunctionDeclPointer(CGF.CGM, GD);
+  return CGCallee::forDirect(calleePtr, GD);
 }
 
 CGCallee CodeGenFunction::EmitCallee(const Expr *E) {
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -135,7 +135,7 @@
   MicrosoftMangleContextImpl(ASTContext , DiagnosticsEngine );
   bool shouldMangleCXXName(const NamedDecl *D) 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-03-06 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7003f64c1eb2: [clang-doc] Improving Markdown Output 
(authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D72954?vs=248338=248875#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- 

[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-06 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 created this revision.
MarcusJohnson91 added a reviewer: cfe-commits.
Herald added a project: clang.

and refactored the BraceWrapping.AfterExternBlock code so that it only deals 
with wrapping the brace after an extern block.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75791

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -27,7 +27,8 @@
 
 FormatStyle getGoogleStyle() { return getGoogleStyle(FormatStyle::LK_Cpp); }
 
-class FormatTest : public ::testing::Test {
+class FormatTest
+: public ::testing::Test { // FormatTest is a Fixture, data is reused
 protected:
   enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
 
@@ -2436,14 +2437,14 @@
 }
 
 TEST_F(FormatTest, FormatsExternC) {
-  verifyFormat("extern \"C\" {\nint a;");
-  verifyFormat("extern \"C\" {}");
+  verifyFormat("extern \"C\" {\nint a; /*2.1*/");
+  verifyFormat("extern \"C\" { /*2.2*/\n}");
   verifyFormat("extern \"C\" {\n"
-   "int foo();\n"
+   "int FormatsExternC_1();\n"
"}");
-  verifyFormat("extern \"C\" int foo() {}");
-  verifyFormat("extern \"C\" int foo();");
-  verifyFormat("extern \"C\" int foo() {\n"
+  verifyFormat("extern \"C\" int FormatsExternC_2() {}");
+  verifyFormat("extern \"C\" int FormatsExternC_3();");
+  verifyFormat("extern \"C\" int FormatsExternC_4() {\n"
"  int i = 42;\n"
"  return i;\n"
"}");
@@ -2451,9 +2452,9 @@
   FormatStyle Style = getLLVMStyle();
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterFunction = true;
-  verifyFormat("extern \"C\" int foo() {}", Style);
-  verifyFormat("extern \"C\" int foo();", Style);
-  verifyFormat("extern \"C\" int foo()\n"
+  verifyFormat("extern \"C\" int FormatsExternC_5() {}", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_6();", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_7()\n"
"{\n"
"  int i = 42;\n"
"  return i;\n"
@@ -2462,20 +2463,41 @@
 
   Style.BraceWrapping.AfterExternBlock = true;
   Style.BraceWrapping.SplitEmptyRecord = false;
-  verifyFormat("extern \"C\" {}", Style);
-  verifyFormat("extern \"C\" {\n"
-   "  int foo();\n"
-   "}",
-   Style);
+  verifyFormat("extern \"C\"\n{ /*2.2*/\n}", Style);
+  verifyFormat("extern \"C\"\n{\nint FormatsExternC_8();\n}", Style);
 
   Style.BraceWrapping.AfterExternBlock = false;
-  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" { /*2.3*/\n}", Style);
   verifyFormat("extern \"C\" {\n"
-   "int foo();\n"
+   "int FormatsExternC_9();\n"
"}",
Style);
 }
 
+TEST_F(FormatTest, FormatsExternBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentWidth = 2;
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" { /*1.1*/\n}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_1();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" { /*1.2*/\n}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_2();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" { /*1.3*/\n}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_3();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" { /*1.4*/\n}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_4();\n}", Style);
+}
+
 TEST_F(FormatTest, FormatsInlineASM) {
   verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
   verifyFormat("asm(\"nop\" ::: \"memory\");");
@@ -12640,6 +12662,7 @@
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
+  CHECK_PARSE_BOOL(IndentExternBlock);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,10 +1085,21 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock) {
-  parseBlock(/*MustBeDeclaration=*/true);
-} 

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

2020-03-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:123
 
+- New alias :doc:`fuchsia-restrict-system-includes
+  ` to

Delete `fuchsia-restrict-system-includes`


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] 7003f64 - [clang-doc] Improving Markdown Output

2020-03-06 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-03-06T17:37:08-08:00
New Revision: 7003f64c1eb25e6a0dd10a4beabc3ca7bcaef7eb

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

LOG: [clang-doc] Improving Markdown Output

This change has two components. The moves the generated file
for a namespace to the directory named after the namespace in
a file named 'index.'. This greatly improves the browsing
experience since the index page is shown by default for a directory.

The second improves the markdown output by adding the links to the
referenced pages for children objects and the link back to the source
code.

Patch By: Clayton

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

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/assets/index.js
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/test/clang-doc/single-file.cpp
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 249d577e8580..dc569e2a482c 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -314,9 +314,9 @@ genReference(const Reference , StringRef 
CurrentDirectory,
 else
   return genLink(Type.Name, "#" + JumpToSection.getValue());
   }
-  llvm::SmallString<128> Path =
-  computeRelativePath(Type.Path, CurrentDirectory);
-  llvm::sys::path::append(Path, Type.Name + ".html");
+  llvm::SmallString<64> Path = Type.getRelativeFilePath(CurrentDirectory);
+  llvm::sys::path::append(Path, Type.getFileBaseName() + ".html");
+
   // Paths in HTML must be in posix-style
   llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
   if (JumpToSection)
@@ -730,15 +730,17 @@ genHTML(const NamespaceInfo , Index , const 
ClangDocContext ,
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
+  llvm::SmallString<64> BasePath = I.getRelativeFilePath("");
+
   std::vector> ChildNamespaces =
-  genReferencesBlock(I.ChildNamespaces, "Namespaces", I.Path);
+  genReferencesBlock(I.ChildNamespaces, "Namespaces", BasePath);
   AppendVector(std::move(ChildNamespaces), Out);
   std::vector> ChildRecords =
-  genReferencesBlock(I.ChildRecords, "Records", I.Path);
+  genReferencesBlock(I.ChildRecords, "Records", BasePath);
   AppendVector(std::move(ChildRecords), Out);
 
   std::vector> ChildFunctions =
-  genFunctionsBlock(I.ChildFunctions, CDCtx, I.Path);
+  genFunctionsBlock(I.ChildFunctions, CDCtx, BasePath);
   AppendVector(std::move(ChildFunctions), Out);
   std::vector> ChildEnums =
   genEnumsBlock(I.ChildEnums, CDCtx);
@@ -860,8 +862,8 @@ llvm::Error HTMLGenerator::generateDocForInfo(Info *I, 
llvm::raw_ostream ,
"unexpected info type");
   }
 
-  HTMLFile F =
-  genInfoFile(InfoTitle, I->Path, MainContentNodes, InfoIndex, CDCtx);
+  HTMLFile F = genInfoFile(InfoTitle, I->getRelativeFilePath(""),
+   MainContentNodes, InfoIndex, CDCtx);
   F.Render(OS);
 
   return llvm::Error::success();
@@ -902,7 +904,7 @@ static llvm::Error SerializeIndex(ClangDocContext ) {
   J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
   J.attribute("Name", I.Name);
   J.attribute("RefType", getRefType(I.RefType));
-  J.attribute("Path", I.Path);
+  J.attribute("Path", I.getRelativeFilePath(""));
   J.attributeArray("Children", [&] {
 for (const Index  : I.Children)
   IndexToJSON(C);

diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index ff99c9001349..9ad71e435a70 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -50,10 +50,20 @@ static void writeHeader(const Twine , unsigned int 
Num, raw_ostream ) {
   OS << std::string(Num, '#') + " " + Text << "\n\n";
 }
 
-static void writeFileDefinition(const Location , raw_ostream ) {
-  OS << genItalic("Defined at line " + std::to_string(L.LineNumber) + " of " +
-  L.Filename)
- << "\n\n";
+static void writeFileDefinition(const ClangDocContext , const Location 
,
+raw_ostream ) {
+
+  if (!CDCtx.RepositoryUrl) {
+OS << "*Defined at " << L.Filename << "#" << std::to_string(L.LineNumber)
+   << "*";
+  } else {
+OS << "*Defined at [" << L.Filename << "#" << std::to_string(L.LineNumber)
+   << 

[PATCH] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

2020-03-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, 
gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman.
Herald added subscribers: guansong, bollu, mgorny.
Herald added a project: clang.

This is a WIP patch to show one way of implementing math support (and
support for `new`, `algorithm`, ...) in OpenMP target regions by piggy
backing on the CUDA implementation. All CUDA "code" should be in
`omp begin/end declare variant match(device={arch(nvptx)})` at the end
of the day while the "host" code is not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75788

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_libdevice_declares.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/cuda_wrappers/new
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/OpenMP/target_nvptx_math_fp_macro.cpp
  clang/test/OpenMP/target_nvptx_math_sin.c

Index: clang/test/OpenMP/target_nvptx_math_sin.c
===
--- /dev/null
+++ clang/test/OpenMP/target_nvptx_math_sin.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -x c++ -emit-llvm %s -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+// TODO: How to include a "mock systme cmath" here for testing?
+
+double math(short s, int i, float f, double d, double ld) {
+  double r = 0;
+  r += sin(s);
+  r += sin(i);
+  r += sin(f);
+  r += sin(d);
+  return r;
+}
+
+long double foo(short s, int i, float f, double d, long double ld) {
+  double r = sin(ld);
+  r += math(s, i, f, d, ld);
+#pragma omp target map(r)
+  { r += math(s, i, f, d, ld); }
+  return r;
+}
Index: clang/test/OpenMP/target_nvptx_math_fp_macro.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_nvptx_math_fp_macro.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -x c++ -emit-llvm %s -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+// TODO: How to include a "mock systme cmath" here for testing?
+
+int main() {
+  double a(0);
+  return (std::fpclassify(a) != FP_ZERO);
+}
Index: clang/lib/Headers/openmp_wrappers/math.h
===
--- clang/lib/Headers/openmp_wrappers/math.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*===- math.h - Alternative math.h header --===
- *
- * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
- * See https://llvm.org/LICENSE.txt for license information.
- * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- *
- *===---===
- */
-
-#include <__clang_openmp_math.h>
-
-#ifndef __CLANG_NO_HOST_MATH__
-#include_next 
-#else
-#undef __CLANG_NO_HOST_MATH__
-#endif
-
Index: clang/lib/Headers/openmp_wrappers/cmath
===
--- clang/lib/Headers/openmp_wrappers/cmath
+++ /dev/null
@@ -1,16 +0,0 @@
-/*===-- cmath - Alternative cmath header ---===
- *
- * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
- * See https://llvm.org/LICENSE.txt for license information.
- * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- *
- *===---===
- */
-
-#include <__clang_openmp_math.h>
-
-#ifndef __CLANG_NO_HOST_MATH__
-#include_next 
-#else
-#undef __CLANG_NO_HOST_MATH__
-#endif
Index: clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
===
--- clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*=== __clang_openmp_math_declares.h - OpenMP math declares ===
- *
- * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
- * See https://llvm.org/LICENSE.txt for license information.
- * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- *
- *===---===
- */
-
-#ifndef __CLANG_OPENMP_MATH_DECLARES_H__
-#define __CLANG_OPENMP_MATH_DECLARES_H__
-
-#ifndef _OPENMP
-#error "This file is for OpenMP compilation only."
-#endif
-
-#if defined(__NVPTX__) && defined(_OPENMP)
-
-#define __CUDA__

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

2020-03-06 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.

We're not using this module in Fuchsia at the moment, so I'd be fine not having 
an alias at all, if we start using it again in the future we'll use the new 
name.


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] D75784: Avoid including Module.h from ExternalASTSource.h

2020-03-06 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

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


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


[PATCH] D75323: Support relative dest paths in headermap files

2020-03-06 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

What use case are you trying to support? Currently the added test 
`headermap_relpath.cpp` is passing without the changes to `HeaderSearch.cpp`, 
so it's not entirely clear what problem it should address.


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

https://reviews.llvm.org/D75323



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


[clang] f4d791f - [CodeGen][ObjC] Extend lifetime of ObjC pointers passed to calls to

2020-03-06 Thread via cfe-commits

Author: Akira Hatanaka
Date: 2020-03-06T16:46:50-08:00
New Revision: f4d791f8332c2bb7e89849d0fe4ef48cb0a23229

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

LOG: [CodeGen][ObjC] Extend lifetime of ObjC pointers passed to calls to
__builtin_os_log_format

This is needed to keep all the objects, including temporaries returned
by function calls, written to the buffer alive until os_log_pack_send is
called.

rdar://problem/60105410

Added: 


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

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 417b308d7a22..952cc3f0c9b8 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1320,14 +1320,30 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr ) {
 } else if (const Expr *TheExpr = Item.getExpr()) {
   ArgVal = EmitScalarExpr(TheExpr, /*Ignore*/ false);
 
-  // Check if this is a retainable type.
+  // If this is a retainable type, push a lifetime-extended cleanup to
+  // ensure the lifetime of the argument is extended to the end of the
+  // 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()) {
 assert(getEvaluationKind(TheExpr->getType()) == TEK_Scalar &&
"Only scalar can be a ObjC retainable type");
-// Check if the object is constant, if not, save it in
-// RetainableOperands.
-if (!isa(ArgVal))
-  RetainableOperands.push_back(ArgVal);
+if (!isa(ArgVal)) {
+  CleanupKind Cleanup = getARCCleanupKind();
+  QualType Ty = TheExpr->getType();
+  Address Alloca = Address::invalid();
+  Address Addr = CreateMemTemp(Ty, "os.log.arg", );
+  ArgVal = EmitARCRetain(Ty, ArgVal);
+  Builder.CreateStore(ArgVal, Addr);
+  pushLifetimeExtendedDestroy(Cleanup, Alloca, Ty,
+  CodeGenFunction::destroyARCStrongPrecise,
+  Cleanup & EHCleanup);
+
+  // Push a clang.arc.use call to ensure ARC optimizer knows that the
+  // argument has to be alive.
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+pushCleanupAfterFullExpr(Cleanup, ArgVal);
+}
   }
 } else {
   ArgVal = Builder.getInt32(Item.getConstValue().getQuantity());
@@ -1349,18 +1365,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr ) {
   llvm::Function *F = CodeGenFunction(CGM).generateBuiltinOSLogHelperFunction(
   Layout, BufAddr.getAlignment());
   EmitCall(FI, CGCallee::forDirect(F), ReturnValueSlot(), Args);
-
-  // Push a clang.arc.use cleanup for each object in RetainableOperands. The
-  // cleanup will cause the use to appear after the final log call, keeping
-  // the object valid while it’s held in the log buffer.  Note that if there’s
-  // a release cleanup on the object, it will already be active; since
-  // cleanups are emitted in reverse order, the use will occur before the
-  // object is released.
-  if (!RetainableOperands.empty() && getLangOpts().ObjCAutoRefCount &&
-  CGM.getCodeGenOpts().OptimizationLevel != 0)
-for (llvm::Value *Object : RetainableOperands)
-  pushFullExprCleanup(getARCCleanupKind(), Object);
-
   return RValue::get(BufAddr.getPointer());
 }
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index cda6910364e5..106e90f4c44c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1843,6 +1843,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   return ExprError();
 break;
   case Builtin::BI__builtin_os_log_format:
+Cleanup.setExprNeedsCleanups(true);
+LLVM_FALLTHROUGH;
   case Builtin::BI__builtin_os_log_format_buffer_size:
 if (SemaBuiltinOSLogFormat(TheCall))
   return ExprError();

diff  --git a/clang/test/CodeGenObjC/os_log.m b/clang/test/CodeGenObjC/os_log.m
index d41a4ce346db..1dd39eebf383 100644
--- a/clang/test/CodeGenObjC/os_log.m
+++ b/clang/test/CodeGenObjC/os_log.m
@@ -24,7 +24,8 @@
   // CHECK: %[[V0:.*]] = bitcast %[[TY0]]* %[[CALL]] to i8*
   // CHECK: %[[V1:.*]] = notail call i8* 
@llvm.objc.retainAutoreleasedReturnValue(i8* %[[V0]])
   // CHECK-LEGACY: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
-  // CHECK-NEWPM: %[[V2:.*]] = ptrtoint i8* %[[V1]] to i64
+  // CHECK-NEWPM: %[[RETAINED:.*]] = tail call i8* @llvm.objc.retain(i8* 
%[[V1]])
+  // CHECK-NEWPM: %[[V2:.*]] = ptrtoint i8* %[[RETAINED]] to 

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

2020-03-06 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast created this revision.
PaulkaToast added a reviewer: aaron.ballman.
PaulkaToast added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, phosek, xazax.hun, mgorny.
Herald added a project: clang.

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.

In the documentation I noted that this new check was moved out from fuchsia and 
an alias was created from the old name to the new name to keep everything 
working. I'm wondering if this is correctly formatted in the release notes.

Nothing should change on fuchsia's end, although feel free to add them if a 
check off is required. (:


Repository:
  rG LLVM Github Monorepo

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/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst
  
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

Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
+// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}"
+
+// 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
Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
+// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,stdio.h'}]}"
+
+// Test allow-list functionality: disallow all but stdio.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
Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
+// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '*,-stdio.h'}]}"
+
+// Test block-list functionality: allow all but stdio.h.
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include stdio.h not allowed
+#include 
+#include 
Index: clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/portability-restrict-system-includes.rst
@@ -0,0 +1,51 @@
+.. title:: clang-tidy - portability-restrict-system-includes
+
+portability-restrict-system-includes
+
+
+Checks to selectively allow or disallow a configurable list of system headers.
+
+For example:
+
+In order to **only** allow zlib.h from the system you would set the options to
+`-*,zlib.h`.
+
+.. code-block:: c++
+
+  #include// Bad: disallowed system header.
+  #include   // Bad: disallowed system header.
+  #include  // Good: allowed system header.
+  #include "src/myfile.h"   // Good: non-system header always allowed.
+
+In order to allow everything **except** zlib.h from the system you would set
+the options to `*,-zlib.h`.
+
+.. 

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

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

Thanks for the suggestions, the general check sounds like a great idea. I can 
see the use case for this as it can be used by anyone. I took the time to port 
out fuchsia's check and flesh out the user facing documentation. Here is the 
patch for that D75786 .

Keeping that in mind, I believe using the general check with a list of headers 
in llvm-libc's case is a bad idea due the following edge cases:

1. The compiler stops providing an include
--

If we had a list that specifically allowed stdbool.h and imagine the compiler 
used stopped providing this header, then we may accidentally pick up the system 
stdbool.h. Having to change the `.clang-tidy` file in llvm-libc's tree when the 
compiler provided includes changes is a maintenance burden and can quickly 
become stale.

2. Platform differences
---

The compiler provided headers may not be the same from operating system to 
operating system. This introduces the need for multiple lists for each system 
supported, where each list suffers from the above problem.

3. Accidental changes to the include order
--

In situations where a mistake is made in the build system and higher priority 
is given to the system includes over the compiler includes. A hand maintained 
list would not be able to catch this.

---

Above all else this test needs to be as strict as possible since many of these 
situations would allow libc to continue to compile, maybe even pass the tests 
but at run-time it could introduce bad behavior due to possible differences in 
implementation details. It is important to us to not have a human-point of 
failure on this check in my opinion.


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 

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

2020-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: aaron.ballman, hans.
Herald added projects: clang, LLDB.
Herald added a subscriber: lldb-commits.

Module.h takes 86ms to parse, mostly parsing the class itself. Avoid it
if possible. ASTContext.h depends on ExternalASTSource.h.

A few NFC changes were needed to make this possible:

- Move ASTSourceDescriptor to Module.h. This needs Module to be complete, and 
seems more related to modules and AST files than external AST sources.
- Move "import complete" bit from Module* pointer int pair to NextLocalImport 
pointer. Required because PointerIntPair requires Module to be 
complete, and now it may not be.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75784

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/Basic/Module.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Basic/Module.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -40,6 +40,10 @@
 class DWARFASTParserClang;
 class PDBASTParser;
 
+namespace clang {
+class FileManager;
+}
+
 namespace lldb_private {
 
 class ClangASTMetadata;
Index: lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
 #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
 
+#include "clang/Basic/Module.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/MultiplexExternalSemaSource.h"
 #include "clang/Sema/Sema.h"
@@ -71,7 +72,7 @@
 return m_Source->getModule(ID);
   }
 
-  llvm::Optional
+  llvm::Optional
   getSourceDescriptor(unsigned ID) override {
 return m_Source->getSourceDescriptor(ID);
   }
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1968,8 +1968,8 @@
 
 void ASTDeclReader::VisitImportDecl(ImportDecl *D) {
   VisitDecl(D);
-  D->ImportedAndComplete.setPointer(readModule());
-  D->ImportedAndComplete.setInt(Record.readInt());
+  D->ImportedModule = readModule();
+  D->setImportComplete(Record.readInt());
   auto *StoredLocs = D->getTrailingObjects();
   for (unsigned I = 0, N = Record.back(); I != N; ++I)
 StoredLocs[I] = readSourceLocation();
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8491,10 +8491,10 @@
   return (I - PCHModules.end()) << 1;
 }
 
-llvm::Optional
+llvm::Optional
 ASTReader::getSourceDescriptor(unsigned ID) {
   if (const Module *M = getSubmodule(ID))
-return ExternalASTSource::ASTSourceDescriptor(*M);
+return ASTSourceDescriptor(*M);
 
   // If there is only a single PCH, return it instead.
   // Chained PCH are not supported.
@@ -8503,8 +8503,8 @@
 ModuleFile  = ModuleMgr.getPrimaryModule();
 StringRef ModuleName = llvm::sys::path::filename(MF.OriginalSourceFileName);
 StringRef FileName = llvm::sys::path::filename(MF.FileName);
-return ASTReader::ASTSourceDescriptor(ModuleName, MF.OriginalDir, FileName,
-  MF.Signature);
+return ASTSourceDescriptor(ModuleName, MF.OriginalDir, FileName,
+   MF.Signature);
   }
   return None;
 }
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -20,6 +20,7 @@
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/CodeGenOptions.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -60,7 +61,7 @@
   llvm::DIBuilder DBuilder;
   llvm::DICompileUnit *TheCU = nullptr;
   ModuleMap *ClangModuleMap = nullptr;
-  ExternalASTSource::ASTSourceDescriptor PCHDescriptor;
+  ASTSourceDescriptor PCHDescriptor;
   SourceLocation CurLoc;
   llvm::MDNode *CurInlinedAt = 

[PATCH] D75700: [NFC] Let mangler accept GlobalDecl

2020-03-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1028
 else
-  MC.mangleName(ND, Out);
+  MC.mangleName(GD, Out);
   } else {

yaxunl wrote:
> rjmccall wrote:
> > What would be necessary in order for this to turn into just `mangleName(GD, 
> > Out)`?   I suspect there are a lot of subtle assumptions between the 
> > different mangling methods today that could probably be broken down a bit 
> > and we'd end up with something much cleaner.
> It seems to be just API changes. I will try changing them.
I got one issue. When I tried to create `GlobalDecl(CD, Ctor_DefaultClosure)` I 
got assertion

include/llvm/ADT/PointerIntPair.h:186: static intptr_t 
llvm::PointerIntPairInfo >::updateInt(intptr_t, 
intptr_t) [PointerT = const clang::Decl *, IntBits = 2, PtrTraits = 
llvm::PointerLikeTypeTraits]: Assertion `(IntWord & 
~IntMask) == 0 && "Integer too large for field"' failed.
CXXConstructor=v:7:25 (default constructor) (converting constructor)

This is because Ctor_DefaultClosure has value 4, which exceeds the value that 
can be put into PointerIntPairInfo


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

https://reviews.llvm.org/D75700



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


[PATCH] D75643: [Sema] Don't emit pointer to int cast warnings under -Wmicrosoft-cast

2020-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

I re-read Richard's comment:

> Would it make sense to put the MS extension warning into the 
> -Wpointer-to-int-cast group so that we can control this warning consistently 
> across platforms? You could get that effect by introducing a new warning 
> group (eg, "-Wmicrosoft-pointer-to-int-cast") containing just the ExtWarn 
> warning, and putting that group in both MicrosoftCast and PointerToIntCast.

My interpretation is that he was **suggesting** the change that you are making 
here. So, let's continue without his additional approval.

I'll go ahead and push this in a minute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75643



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


Re: [clang] 8e4a867 - Revert "PR45083: Mark statement expressions as being dependent if they contain"

2020-03-06 Thread Richard Smith via cfe-commits
On Fri, 6 Mar 2020 at 02:11, Stephan Herhut via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: Stephan Herhut
> Date: 2020-03-06T11:09:45+01:00
> New Revision: 8e4a8677be3061317056335d298d85ce60c23dff
>
> URL:
> https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff
> DIFF:
> https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff.diff
>
> LOG: Revert "PR45083: Mark statement expressions as being dependent if
> they contain"
>
> This reverts commit a95cc77be154433c37a3110ac9af394b7447fcba.
>
> Causes an internal build failure. I followed up with the author by mail.
>

The internal build failure is on invalid code that Clang incorrectly
accepted previously. Unreverting...


> Added:
>
>
> Modified:
> clang/include/clang/AST/Expr.h
> clang/lib/AST/Expr.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 75b7a5f6ecd3..7271dbb830a2 100644
> --- a/clang/include/clang/AST/Expr.h
> +++ b/clang/include/clang/AST/Expr.h
> @@ -3959,8 +3959,14 @@ class StmtExpr : public Expr {
>Stmt *SubStmt;
>SourceLocation LParenLoc, RParenLoc;
>  public:
> -  StmtExpr(CompoundStmt *SubStmt, QualType T,
> -   SourceLocation LParen, SourceLocation RParen);
> +  // 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) { }
>
>/// Build an empty statement expression.
>explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
>
> diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
> index 78fd96fd76e6..79f9f42224d0 100644
> --- a/clang/lib/AST/Expr.cpp
> +++ b/clang/lib/AST/Expr.cpp
> @@ -4097,53 +4097,6 @@ void ExtVectorElementExpr::getEncodedElementAccess(
>}
>  }
>
> -StmtExpr::StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation
> LParen,
> -   SourceLocation RParen)
> -: Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),
> -   false, false, false),
> -  SubStmt(SubStmt), LParenLoc(LParen), RParenLoc(RParen) {
> -  llvm::SmallVector Queue(1, SubStmt);
> -  while (!Queue.empty()) {
> -Stmt *S = Queue.pop_back_val();
> -if (!S)
> -  continue;
> -
> -// If any subexpression is dependent, the statement expression is
> dependent
> -// in the same way.
> -if (Expr *E = dyn_cast(S)) {
> -  addDependence(E->getDependence());
> -  continue;
> -}
> -
> -// FIXME: Need to properly compute whether DeclStmts contain
> unexpanded
> -// parameter packs.
> -if (DeclStmt *DS = dyn_cast(S)) {
> -  for (Decl *D : DS->decls()) {
> -// If any contained declaration is in a dependent context, then it
> -// needs to be instantiated, so the statement expression itself is
> -// instantiation-dependent.
> -//
> -// Note that we don't need to worry about the case where the
> context is
> -// non-dependent but contains dependent entities here (eg, inside
> a
> -// variable template or alias template): that can only happen at
> file
> -// scope, where statement expressions are prohibited.
> -if (D->getLexicalDeclContext()->isDependentContext())
> -  addDependence(ExprDependence::Instantiation);
> -
> -// If any contained variable declaration has a dependent type, we
> can't
> -// evaluate that declaration.
> -if (auto *VD = dyn_cast(D))
> -  if (VD->getType()->isDependentType())
> -addDependence(ExprDependence::Value);
> -  }
> -}
> -
> -// Recurse to substatements.
> -// FIXME: Should we skip the unchosen side of 'if constexpr' if known?
> -Queue.insert(Queue.end(), S->child_begin(), S->child_end());
> -  }
> -}
> -
>  ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext , ArrayRef
> args,
>   QualType Type, SourceLocation BLoc,
>   SourceLocation RP)
>
> diff  --git a/clang/test/SemaTemplate/dependent-expr.cpp
> b/clang/test/SemaTemplate/dependent-expr.cpp
> index 12a99acc21cd..bb1e239c3490 100644
> --- a/clang/test/SemaTemplate/dependent-expr.cpp
> +++ b/clang/test/SemaTemplate/dependent-expr.cpp
> @@ -1,4 +1,5 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +// expected-no-diagnostics
>
>  // PR5908
>  template 
> @@ -107,42 +108,3 @@ namespace PR18152 {
>};
>template 

[PATCH] D75210: [Attr] Allow ParsedAttr to be constructor for any Attribute

2020-03-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 248845.
jdoerfert added a comment.

Pass parsed attribute kind explicitly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75210

Files:
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/ParsedAttr.cpp

Index: clang/lib/Sema/ParsedAttr.cpp
===
--- clang/lib/Sema/ParsedAttr.cpp
+++ clang/lib/Sema/ParsedAttr.cpp
@@ -42,10 +42,10 @@
   else if (HasParsedType)
 return totalSizeToAlloc(0, 0, 0, 1, 0);
+detail::PropertyData, Attr *>(0, 0, 0, 1, 0, 0);
   return totalSizeToAlloc(NumArgs, 0, 0, 0, 0);
+  detail::PropertyData, Attr *>(NumArgs, 0, 0, 0, 0, 0);
 }
 
 AttributeFactory::AttributeFactory() {
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_SEMA_ATTRIBUTELIST_H
 #define LLVM_CLANG_SEMA_ATTRIBUTELIST_H
 
+#include "clang/AST/Attr.h"
 #include "clang/Basic/AttrSubjectMatchRules.h"
 #include "clang/Basic/AttributeCommonInfo.h"
 #include "clang/Basic/Diagnostic.h"
@@ -116,9 +117,10 @@
 ///
 class ParsedAttr final
 : public AttributeCommonInfo,
-  private llvm::TrailingObjects<
-  ParsedAttr, ArgsUnion, detail::AvailabilityData,
-  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
+  private llvm::TrailingObjects {
   friend TrailingObjects;
 
   size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
@@ -135,6 +137,7 @@
   size_t numTrailingObjects(OverloadToken) const {
 return IsProperty;
   }
+  size_t numTrailingObjects(OverloadToken) const { return HasAttrPtr; }
 
 private:
   IdentifierInfo *MacroII = nullptr;
@@ -143,7 +146,7 @@
 
   /// The number of expression arguments this attribute has.
   /// The expressions themselves are stored after the object.
-  unsigned NumArgs : 16;
+  unsigned NumArgs : 15;
 
   /// True if already diagnosed as invalid.
   mutable unsigned Invalid : 1;
@@ -166,6 +169,9 @@
   /// True if this has a ParsedType
   unsigned HasParsedType : 1;
 
+  /// True if this has an attribute pointer.
+  unsigned HasAttrPtr : 1;
+
   /// True if the processing cache is valid.
   mutable unsigned HasProcessingCache : 1;
 
@@ -207,7 +213,8 @@
 EllipsisLoc(ellipsisLoc), NumArgs(numArgs), Invalid(false),
 UsedAsTypeAttr(false), IsAvailability(false),
 IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
-HasProcessingCache(false), IsPragmaClangAttribute(false) {
+HasAttrPtr(false), HasProcessingCache(false),
+IsPragmaClangAttribute(false) {
 if (numArgs)
   memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion));
   }
@@ -224,8 +231,9 @@
 syntaxUsed),
 NumArgs(1), Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
 IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
-HasProcessingCache(false), IsPragmaClangAttribute(false),
-UnavailableLoc(unavailable), MessageExpr(messageExpr) {
+HasAttrPtr(false), HasProcessingCache(false),
+IsPragmaClangAttribute(false), UnavailableLoc(unavailable),
+MessageExpr(messageExpr) {
 ArgsUnion PVal(Parm);
 memcpy(getArgsBuffer(), , sizeof(ArgsUnion));
 new (getAvailabilityData()) detail::AvailabilityData(
@@ -241,7 +249,7 @@
 syntaxUsed),
 NumArgs(3), Invalid(false), UsedAsTypeAttr(false),
 IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
-HasParsedType(false), HasProcessingCache(false),
+HasParsedType(false), HasAttrPtr(false), HasProcessingCache(false),
 IsPragmaClangAttribute(false) {
 ArgsUnion *Args = getArgsBuffer();
 Args[0] = Parm1;
@@ -258,7 +266,7 @@
 syntaxUsed),
 NumArgs(1), Invalid(false), UsedAsTypeAttr(false),
 IsAvailability(false), IsTypeTagForDatatype(true), IsProperty(false),
-HasParsedType(false), HasProcessingCache(false),
+HasParsedType(false), HasAttrPtr(false), HasProcessingCache(false),
 IsPragmaClangAttribute(false) {
 ArgsUnion PVal(ArgKind);
 memcpy(getArgsBuffer(), , sizeof(ArgsUnion));
@@ -276,7 +284,7 @@
 syntaxUsed),
 NumArgs(0), Invalid(false), UsedAsTypeAttr(false),
 IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
-HasParsedType(true), HasProcessingCache(false),
+HasParsedType(true), HasAttrPtr(false), HasProcessingCache(false),
 IsPragmaClangAttribute(false) {
 new (()) ParsedType(typeArg);
   }
@@ -290,11 +298,26 @@
 syntaxUsed),
 

[PATCH] D75770: [WebAssembly] Add SIMD integer min/max builtins

2020-03-06 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd43fcd0c0410: [WebAssembly] Add SIMD integer min/max 
builtins (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75770

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c

Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -338,6 +338,90 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 min_s_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_min_s_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp slt <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i8x16 min_u_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_min_u_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp ult <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i8x16 max_s_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_max_s_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp sgt <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i8x16 max_u_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_max_u_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp ugt <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i16x8 min_s_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_min_s_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp slt <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i16x8 min_u_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_min_u_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp ult <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i16x8 max_s_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_max_s_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp sgt <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i16x8 max_u_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_max_u_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp ugt <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i32x4 min_s_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_min_s_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp slt <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
+i32x4 min_u_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_min_u_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp ult <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
+i32x4 max_s_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_max_s_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp sgt <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
+i32x4 max_u_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_max_u_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp ugt <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
 i16x8 sub_saturate_s_i16x8(i16x8 x, i16x8 y) {
   return __builtin_wasm_sub_saturate_s_i16x8(x, y);
   // WEBASSEMBLY: call <8 x i16> @llvm.wasm.sub.saturate.signed.v8i16(
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -14900,6 +14900,47 @@
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_min_s_i8x16:
+  case WebAssembly::BI__builtin_wasm_min_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_max_s_i8x16:
+  case WebAssembly::BI__builtin_wasm_max_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_min_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_min_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_max_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_max_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_min_s_i32x4:
+  case WebAssembly::BI__builtin_wasm_min_u_i32x4:
+  case WebAssembly::BI__builtin_wasm_max_s_i32x4:
+  case WebAssembly::BI__builtin_wasm_max_u_i32x4: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Value *ICmp;
+

[clang] d43fcd0 - [WebAssembly] Add SIMD integer min/max builtins

2020-03-06 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-03-06T14:28:52-08:00
New Revision: d43fcd0c0410d474a947cf51a3c67aa2e8d5a711

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

LOG: [WebAssembly] Add SIMD integer min/max builtins

Summary:
Although SIMD integer min/max operations can be expressed using the ?:
operator in C++, that operator is disallowed for vectors in C. As a
workaround, this change introduces new WebAssembly-specific builtin
functions that lower to the desired vector icmp/select sequences.

Reviewers: aheejin, dschuff, kripken

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 0574af395f7b..b544e3b42137 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -98,6 +98,19 @@ TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, 
"V16cV16cV16c", "nc", "simd1
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 
+TARGET_BUILTIN(__builtin_wasm_min_s_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_u_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_s_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_u_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_s_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_u_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_s_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_u_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_s_i32x4, "V4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_u_i32x4, "V4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_s_i32x4, "V4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_u_i32x4, "V4iV4iV4i", "nc", "simd128")
+
 TARGET_BUILTIN(__builtin_wasm_avgr_u_i8x16, "V16cV16cV16c", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8sV8sV8s", "nc", "simd128")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fbb397ba3cfe..417b308d7a22 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14900,6 +14900,47 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_min_s_i8x16:
+  case WebAssembly::BI__builtin_wasm_min_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_max_s_i8x16:
+  case WebAssembly::BI__builtin_wasm_max_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_min_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_min_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_max_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_max_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_min_s_i32x4:
+  case WebAssembly::BI__builtin_wasm_min_u_i32x4:
+  case WebAssembly::BI__builtin_wasm_max_s_i32x4:
+  case WebAssembly::BI__builtin_wasm_max_u_i32x4: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Value *ICmp;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_min_s_i8x16:
+case WebAssembly::BI__builtin_wasm_min_s_i16x8:
+case WebAssembly::BI__builtin_wasm_min_s_i32x4:
+  ICmp = Builder.CreateICmpSLT(LHS, RHS);
+  break;
+case WebAssembly::BI__builtin_wasm_min_u_i8x16:
+case WebAssembly::BI__builtin_wasm_min_u_i16x8:
+case WebAssembly::BI__builtin_wasm_min_u_i32x4:
+  ICmp = Builder.CreateICmpULT(LHS, RHS);
+  break;
+case WebAssembly::BI__builtin_wasm_max_s_i8x16:
+case WebAssembly::BI__builtin_wasm_max_s_i16x8:
+case WebAssembly::BI__builtin_wasm_max_s_i32x4:
+  ICmp = Builder.CreateICmpSGT(LHS, RHS);
+  break;
+case WebAssembly::BI__builtin_wasm_max_u_i8x16:
+case WebAssembly::BI__builtin_wasm_max_u_i16x8:
+case WebAssembly::BI__builtin_wasm_max_u_i32x4:
+  ICmp = Builder.CreateICmpUGT(LHS, RHS);
+  break;
+default:
+  llvm_unreachable("unexpected builtin ID");
+}
+return Builder.CreateSelect(ICmp, LHS, RHS);
+  }
   case WebAssembly::BI__builtin_wasm_avgr_u_i8x16:
   case WebAssembly::BI__builtin_wasm_avgr_u_i16x8: {
 Value *LHS = EmitScalarExpr(E->getArg(0));


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

2020-03-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 248827.
nickdesaulniers added a comment.

- add release note about change in behavior of -Wduplicate-decl-specifier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -589,6 +589,16 @@
   llvm_unreachable("Unknown 

[PATCH] D75517: [clang-format] Do not format C# array subscript operators as attributes

2020-03-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

sorry could you please take another look at the comments I left


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75517



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


[PATCH] D75752: [Sema] Move pointer to int cast warnings under -Wmicrosoft-cast

2020-03-06 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

Specifically regarding
../../base/debug/close_handle_hook_win.cc(155,16): error: cast to smaller 
integer type 'unsigned long' from 'void *',
I sent out a change to fix that: 
https://chromium-review.googlesource.com/c/chromium/src/+/2091215, and tried 
compiling with ToT clang with the suppression removed, then there were no more 
errors.

Anyway, we should probably be consistent between this and 
https://reviews.llvm.org/D75643. I'm fine with keeping what we have, but then 
https://reviews.llvm.org/D75643 should probably go in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75752



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


[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance marked 2 inline comments as done.
nathanchance added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3673
+def warn_pointer_to_enum_cast : Warning<
+  "cast to smaller integer type %1 from %0">,
+  InGroup;

xbolva00 wrote:
> You can reuse warning text:
> 
> warn_pointer_to_int_cast.Text
> 
> I think..
Thanks, that is indeed cleaner!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75758



___
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-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 248825.
nickdesaulniers added a comment.

- use better error name
- reorder new errors
- git-clang-format HEAD~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -589,6 +589,16 @@
   llvm_unreachable("Unknown 

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 248824.
nathanchance edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75758

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/cast.c


Index: clang/test/Sema/cast.c
===
--- clang/test/Sema/cast.c
+++ clang/test/Sema/cast.c
@@ -186,3 +186,23 @@
 void *intToPointerCast3() {
   return (void*)(1 + 3);
 }
+
+void voidPointerToEnumCast(VoidPtr v) {
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 
'VoidPtr' (aka 'void *')}}
+  // Test that casts to void* can be controlled separately
+  // from other -Wpointer-to-enum-cast warnings.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvoid-pointer-to-enum-cast"
+  (void)(X) v; // no-warning
+#pragma clang diagnostic pop
+}
+
+void pointerToEnumCast(CharPtr v) {
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 
'CharPtr' (aka 'char *')}}
+  // Test that casts to void* can be controlled separately
+  // from other -Wpointer-to-enum-cast warnings.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvoid-pointer-to-enum-cast"
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 
'CharPtr' (aka 'char *')}}
+#pragma clang diagnostic pop
+}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2777,11 +2777,18 @@
   // If the result cannot be represented in the integer type, the behavior
   // is undefined. The result need not be in the range of values of any
   // integer type.
-  unsigned Diag = Self.getLangOpts().MicrosoftExt
-  ? diag::ext_ms_pointer_to_int_cast
-  : SrcType->isVoidPointerType()
-? diag::warn_void_pointer_to_int_cast
-: diag::warn_pointer_to_int_cast;
+  unsigned Diag;
+  if (Self.getLangOpts().MicrosoftExt)
+Diag = diag::ext_ms_pointer_to_int_cast;
+  else if (SrcType->isVoidPointerType())
+if (DestType->isEnumeralType())
+  Diag = diag::warn_void_pointer_to_enum_cast;
+else
+  Diag = diag::warn_void_pointer_to_int_cast;
+  else if (DestType->isEnumeralType())
+Diag = diag::warn_pointer_to_enum_cast;
+  else
+Diag = diag::warn_pointer_to_int_cast;
   Self.Diag(OpRange.getBegin(), Diag) << SrcType << DestType << OpRange;
 }
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3669,9 +3669,15 @@
 def warn_pointer_to_int_cast : Warning<
   "cast to smaller integer type %1 from %0">,
   InGroup;
+def warn_pointer_to_enum_cast : Warning<
+  warn_pointer_to_int_cast.Text>,
+  InGroup;
 def warn_void_pointer_to_int_cast : Warning<
   "cast to smaller integer type %1 from %0">,
   InGroup;
+def warn_void_pointer_to_enum_cast : Warning<
+  warn_void_pointer_to_int_cast.Text>,
+  InGroup;
 def ext_ms_pointer_to_int_cast : ExtWarn<
   "cast to smaller integer type %1 from %0 is a Microsoft extension">,
 InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -838,9 +838,13 @@
 def IntToVoidPointerCast : DiagGroup<"int-to-void-pointer-cast">;
 def IntToPointerCast : DiagGroup<"int-to-pointer-cast",
  [IntToVoidPointerCast]>;
-def VoidPointerToIntCast : DiagGroup<"void-pointer-to-int-cast">;
+def VoidPointerToEnumCast : DiagGroup<"void-pointer-to-enum-cast">;
+def VoidPointerToIntCast : DiagGroup<"void-pointer-to-int-cast",
+ [VoidPointerToEnumCast]>;
+def PointerToEnumCast : DiagGroup<"pointer-to-enum-cast",
+  [VoidPointerToEnumCast]>;
 def PointerToIntCast : DiagGroup<"pointer-to-int-cast",
- [VoidPointerToIntCast]>;
+ [PointerToEnumCast, VoidPointerToIntCast]>;
 
 def Move : DiagGroup<"move", [
 PessimizingMove,


Index: clang/test/Sema/cast.c
===
--- clang/test/Sema/cast.c
+++ clang/test/Sema/cast.c
@@ -186,3 +186,23 @@
 void *intToPointerCast3() {
   return (void*)(1 + 3);
 }
+
+void voidPointerToEnumCast(VoidPtr v) {
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 'VoidPtr' (aka 'void *')}}
+ 

[PATCH] D75719: [clang][Headers] Use __has_builtin instead of _MSC_VER.

2020-03-06 Thread Michael Spencer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16af23fae8ad: [clang][Headers] Use __has_builtin instead of 
_MSC_VER. (authored by Bigcheese).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75719

Files:
  clang/lib/Headers/arm_acle.h
  clang/test/Headers/arm-acle-header.c


Index: clang/test/Headers/arm-acle-header.c
===
--- clang/test/Headers/arm-acle-header.c
+++ clang/test/Headers/arm-acle-header.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 
-fsyntax-only -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 
-fsyntax-only -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=19.11 %s
 // RUN: %clang_cc1 -x c++ -triple aarch64-windows -target-cpu cortex-a53 
-fsyntax-only -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=19.11 %s
+// RUN: %clang_cc1 -x c++ -triple arm64-apple-ios -target-cpu apple-a7 
-fsyntax-only -ffreestanding -fms-extensions %s
 // expected-no-diagnostics
 
 #include 
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -22,31 +22,43 @@
 
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory barriers */
-#if !defined(_MSC_VER)
+#if !__has_builtin(__dmb)
 #define __dmb(i) __builtin_arm_dmb(i)
+#endif
+#if !__has_builtin(__dsb)
 #define __dsb(i) __builtin_arm_dsb(i)
+#endif
+#if !__has_builtin(__isb)
 #define __isb(i) __builtin_arm_isb(i)
 #endif
 
 /* 8.4 Hints */
 
-#if !defined(_MSC_VER)
+#if !__has_builtin(__wfi)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__wfi(void) {
   __builtin_arm_wfi();
 }
+#endif
 
+#if !__has_builtin(__wfe)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__wfe(void) {
   __builtin_arm_wfe();
 }
+#endif
 
+#if !__has_builtin(__sev)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__sev(void) {
   __builtin_arm_sev();
 }
+#endif
 
+#if !__has_builtin(__sevl)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__sevl(void) {
   __builtin_arm_sevl();
 }
+#endif
 
+#if !__has_builtin(__yield)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__yield(void) {
   __builtin_arm_yield();
 }


Index: clang/test/Headers/arm-acle-header.c
===
--- clang/test/Headers/arm-acle-header.c
+++ clang/test/Headers/arm-acle-header.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 -fsyntax-only -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=19.11 %s
 // RUN: %clang_cc1 -x c++ -triple aarch64-windows -target-cpu cortex-a53 -fsyntax-only -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=19.11 %s
+// RUN: %clang_cc1 -x c++ -triple arm64-apple-ios -target-cpu apple-a7 -fsyntax-only -ffreestanding -fms-extensions %s
 // expected-no-diagnostics
 
 #include 
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -22,31 +22,43 @@
 
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory barriers */
-#if !defined(_MSC_VER)
+#if !__has_builtin(__dmb)
 #define __dmb(i) __builtin_arm_dmb(i)
+#endif
+#if !__has_builtin(__dsb)
 #define __dsb(i) __builtin_arm_dsb(i)
+#endif
+#if !__has_builtin(__isb)
 #define __isb(i) __builtin_arm_isb(i)
 #endif
 
 /* 8.4 Hints */
 
-#if !defined(_MSC_VER)
+#if !__has_builtin(__wfi)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfi(void) {
   __builtin_arm_wfi();
 }
+#endif
 
+#if !__has_builtin(__wfe)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfe(void) {
   __builtin_arm_wfe();
 }
+#endif
 
+#if !__has_builtin(__sev)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sev(void) {
   __builtin_arm_sev();
 }
+#endif
 
+#if !__has_builtin(__sevl)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sevl(void) {
   __builtin_arm_sevl();
 }
+#endif
 
+#if !__has_builtin(__yield)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) __yield(void) {
   __builtin_arm_yield();
 }
___
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-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:15
 
-def warn_asm_qualifier_ignored : Warning<
-  "ignored %0 qualifier on asm">, CatInlineAsm, InGroup;
-def warn_file_asm_volatile : Warning<
-  "meaningless 'volatile' on asm outside function">, CatInlineAsm,
-  InGroup;
+def err_file_asm_volatile : Error<
+  "meaningless '%0' on asm outside function">, CatInlineAsm;

oh, I meant to rename this; and I think flipping the order of this and 
following def is a little clearer for code review.


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


[clang] 16af23f - [clang][Headers] Use __has_builtin instead of _MSC_VER.

2020-03-06 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2020-03-06T13:48:09-08:00
New Revision: 16af23fae8ad2949048e0fc34cf9114dfbe4742a

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

LOG: [clang][Headers] Use __has_builtin instead of _MSC_VER.

arm_acle.h relied on `_MSC_VER` to determine if a given function was
already defined as a builtin. This was incorrect because
`-fms-extensions` enables these builtins, but is not responsible for
defining `_MSC_VER` on any target. The next closest thing is
`_MSC_EXTENSIONS`, which is only defined on Windows targets, but even
this is suboptimal. What this conditional is actually trying to
determine is if the given functions are defined as builtins, so just
check that directly.

I also attempted to do this for `__nop`, but in that case intrin.h,
which is only includable if `_MSC_VER` is defined, has its own
definition. So in that case `_MSC_VER` is correct.

Differential Revision: https://reviews.llvm.org/D75719
rdar://60102353

Added: 


Modified: 
clang/lib/Headers/arm_acle.h
clang/test/Headers/arm-acle-header.c

Removed: 




diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index 596ea03cff2f..de568b4ff9c5 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -22,31 +22,43 @@ extern "C" {
 
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory barriers */
-#if !defined(_MSC_VER)
+#if !__has_builtin(__dmb)
 #define __dmb(i) __builtin_arm_dmb(i)
+#endif
+#if !__has_builtin(__dsb)
 #define __dsb(i) __builtin_arm_dsb(i)
+#endif
+#if !__has_builtin(__isb)
 #define __isb(i) __builtin_arm_isb(i)
 #endif
 
 /* 8.4 Hints */
 
-#if !defined(_MSC_VER)
+#if !__has_builtin(__wfi)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__wfi(void) {
   __builtin_arm_wfi();
 }
+#endif
 
+#if !__has_builtin(__wfe)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__wfe(void) {
   __builtin_arm_wfe();
 }
+#endif
 
+#if !__has_builtin(__sev)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__sev(void) {
   __builtin_arm_sev();
 }
+#endif
 
+#if !__has_builtin(__sevl)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__sevl(void) {
   __builtin_arm_sevl();
 }
+#endif
 
+#if !__has_builtin(__yield)
 static __inline__ void __attribute__((__always_inline__, __nodebug__)) 
__yield(void) {
   __builtin_arm_yield();
 }

diff  --git a/clang/test/Headers/arm-acle-header.c 
b/clang/test/Headers/arm-acle-header.c
index 932c59da3d96..e50a68c64b0f 100644
--- a/clang/test/Headers/arm-acle-header.c
+++ b/clang/test/Headers/arm-acle-header.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 
-fsyntax-only -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 
-fsyntax-only -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=19.11 %s
 // RUN: %clang_cc1 -x c++ -triple aarch64-windows -target-cpu cortex-a53 
-fsyntax-only -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=19.11 %s
+// RUN: %clang_cc1 -x c++ -triple arm64-apple-ios -target-cpu apple-a7 
-fsyntax-only -ffreestanding -fms-extensions %s
 // expected-no-diagnostics
 
 #include 



___
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-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 248816.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.
Herald added subscribers: jfb, aheejin.

- completely drop use of Parse::ParseTypeQualifierListOpt
- move paren parsing into helper
- fix up test cases for global asm statements
- delete duplicate test cases covered by the added test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 

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

2020-03-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked 4 inline comments as done.
nickdesaulniers added inline comments.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:746-755
   ParseTypeQualifierListOpt(DS, AR_VendorAttributesParsed);
 
   // GNU asms accept, but warn, about type-qualifiers other than volatile.
   if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
 Diag(Loc, diag::warn_asm_qualifier_ignored) << "const";
   if (DS.getTypeQualifiers() & DeclSpec::TQ_restrict)
 Diag(Loc, diag::warn_asm_qualifier_ignored) << "restrict";

nickdesaulniers wrote:
> I think in a follow up commit, I'll just delete this (the call to 
> `ParseTypeQualifierListOpt` and subsequent `warn_asm_qualifier_ignored` 
> emission); making it a parse error to put type qualifiers after the keyword 
> `asm`, which would match the behavior of GCC, and not waste time looking for 
> and parsing type qualifiers.  It maybe made sense when 
> `ParseTypeQualifierListOpt` was being abused to parse `volatile`, but this 
> patch fixes that.
Chatting with @aaron.ballman , I think it makes sense to tackle this in this 
CL, which will simplify the requested changes to parsing (above).


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] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-06 Thread Jeremy Stenglein via Phabricator via cfe-commits
jstenglein added a comment.

In D75768#1910339 , @erichkeane wrote:

> In D75768#1910324 , @jstenglein 
> wrote:
>
> > In D75768#1910303 , @erichkeane 
> > wrote:
> >
> > > Any reason to not put this in -Wall like GCC? I'm not terribly 
> > > knowledgeable about the intended guidance for adding to Wmost, so if you 
> > > can clarify this decision I'd be grateful.  Otherwise I think this patch 
> > > looks fine.
> >
> >
> > Thanks for the comments.  It is already part of -Wall since I put it in 
> > -Wmost and -Wall includes -Wmost:
> >  def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
> > MisleadingIndentation]>;
>
>
> Right, I know.  I'm wondering about what made you choose most?  I dont know 
> our rules for warning groups, so hopefully someone else can comment.


I chose Most to get the warning included in -Wall - if there is a better 
placement let me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768



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


[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D75768#1910324 , @jstenglein wrote:

> In D75768#1910303 , @erichkeane 
> wrote:
>
> > Any reason to not put this in -Wall like GCC? I'm not terribly 
> > knowledgeable about the intended guidance for adding to Wmost, so if you 
> > can clarify this decision I'd be grateful.  Otherwise I think this patch 
> > looks fine.
>
>
> Thanks for the comments.  It is already part of -Wall since I put it in 
> -Wmost and -Wall includes -Wmost:
>  def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
> MisleadingIndentation]>;


Right, I know.  I'm wondering about what made you choose most?  I dont know our 
rules for warning groups, so hopefully someone else can comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768



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


[libunwind] eb755df - Split findUnwindSectionsByPhdr into target-specific functions.

2020-03-06 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-03-06T13:28:09-08:00
New Revision: eb755df5c27f5687a4f43a62e7eb0713c3f8f030

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

LOG: Split findUnwindSectionsByPhdr into target-specific functions.

Summary:
This further cleans up the control flow and makes it easier to
optimize and replace portions in a subsequent patch.

This should be NFC, but given the amount of #ifdeffing here,
it may not be. So will watch the buildbots closely.

Also, as this is purely moving existing code around, I plan to
ignore the lint errors.

Reviewers: compnerd, miyuki, mstorsjo

Subscribers: libcxx-commits

Tags: #libc

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

Added: 


Modified: 
libunwind/src/AddressSpace.hpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 2f68d6525a0f..d4d66ad74ff6 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -409,24 +409,6 @@ LocalAddressSpace::getEncodedP(pint_t , pint_t end, 
uint8_t encoding,
 // that don't help at all.
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
-  LocalAddressSpace *addressSpace;
-  UnwindInfoSections *sects;
-  uintptr_t targetAddr;
-};
-
-int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
-  auto cbdata = static_cast(data);
-  bool found_obj = false;
-  bool found_hdr = false;
-
-  assert(cbdata);
-  assert(cbdata->sects);
-
-  if (cbdata->targetAddr < pinfo->dlpi_addr) {
-return false;
-  }
-
 #if !defined(Elf_Half)
   typedef ElfW(Half) Elf_Half;
 #endif
@@ -437,8 +419,8 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t, void *data) {
   typedef ElfW(Addr) Elf_Addr;
 #endif
 
+static Elf_Addr calculateImageBase(struct dl_phdr_info *pinfo) {
   Elf_Addr image_base = pinfo->dlpi_addr;
-
 #if defined(__ANDROID__) && __ANDROID_API__ < 18
   if (image_base == 0) {
 // Normally, an image base of 0 indicates a non-PIE executable. On
@@ -456,11 +438,32 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t, void *data) {
 }
   }
 #endif
+  return image_base;
+}
 
- #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
+  LocalAddressSpace *addressSpace;
+  UnwindInfoSections *sects;
+  uintptr_t targetAddr;
+};
+
+#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   #if !defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
-   #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires 
_LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
+#error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires 
_LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
   #endif
+
+int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
+  auto *cbdata = static_cast(data);
+  bool found_obj = false;
+  bool found_hdr = false;
+
+  assert(cbdata);
+  assert(cbdata->sects);
+
+  if (cbdata->targetAddr < pinfo->dlpi_addr)
+return 0;
+
+  Elf_Addr image_base = calculateImageBase(pinfo);
   size_t object_length;
 
   for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {
@@ -492,7 +495,25 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t, void *data) {
   } else {
 return false;
   }
- #else // defined(_LIBUNWIND_ARM_EHABI)
+}
+
+#else  // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND)
+// Given all the #ifdef's above, the code here is for
+// defined(LIBUNWIND_ARM_EHABI)
+
+int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
+  auto *cbdata = static_cast(data);
+  bool found_obj = false;
+  bool found_hdr = false;
+
+  assert(cbdata);
+  assert(cbdata->sects);
+
+  if (cbdata->targetAddr < pinfo->dlpi_addr)
+return 0;
+
+  Elf_Addr image_base = calculateImageBase(pinfo);
+
   for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {
 const Elf_Phdr *phdr = >dlpi_phdr[i];
 if (phdr->p_type == PT_LOAD) {
@@ -508,8 +529,8 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t, void *data) {
 }
   }
   return found_obj && found_hdr;
- #endif
 }
+#endif  // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND)
 #endif  // defined(_LIBUNWIND_ARM_EHABI) || 
defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
 



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


[clang] 6d894af - PR45124: Don't leave behind pending cleanups when declaring implicit

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

Author: Richard Smith
Date: 2020-03-06T13:22:10-08:00
New Revision: 6d894afdea433879f54e5ba07e827db006645b7b

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

LOG: PR45124: Don't leave behind pending cleanups when declaring implicit
deduction guides.

Previously if an implicit deduction guide had a default argument with a
cleanup, we'd leave the 'pending cleanup' flag set after declaring the
implicit guide. But it turns out that there's no reason to even
substitute into the default argument when declaring an implicit
deduction guide: we only need to record that the default argument
exists, not what it is, since we never actually form a call to a
deduction guide.

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index c1084b875a92..3fb39853d9b4 100755
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2173,9 +2173,15 @@ struct ConvertConstructorToDeductionGuideTransform {
 // constructor.
 ExprResult NewDefArg;
 if (OldParam->hasDefaultArg()) {
-  NewDefArg = SemaRef.SubstExpr(OldParam->getDefaultArg(), Args);
-  if (NewDefArg.isInvalid())
-return nullptr;
+  // We don't care what the value is (we won't use it); just create a
+  // placeholder to indicate there is a default argument.
+  QualType ParamTy = NewDI->getType();
+  NewDefArg = new (SemaRef.Context)
+  OpaqueValueExpr(OldParam->getDefaultArg()->getBeginLoc(),
+  ParamTy.getNonLValueExprType(SemaRef.Context),
+  ParamTy->isLValueReferenceType() ? VK_LValue :
+  ParamTy->isRValueReferenceType() ? VK_XValue :
+  VK_RValue);
 }
 
 ParmVarDecl *NewParam = ParmVarDecl::Create(SemaRef.Context, DC,

diff  --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
index 85312cf1049f..2a3f312ebd8e 100644
--- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -507,6 +507,21 @@ umm m(1);
 
 }
 
+namespace PR45124 {
+  class a { int d; };
+  class b : a {};
+
+  struct x { ~x(); };
+  template class y { y(x = x()); };
+  template y(z)->y;
+
+  // Not a constant initializer, but trivial default initialization. We won't
+  // detect this as trivial default initialization if synthesizing the implicit
+  // deduction guide 'template y(x = x()) -> Y;' leaves behind a
+  // pending cleanup.
+  __thread b g;
+}
+
 #else
 
 // expected-no-diagnostics



___
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-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp:63
+  }
+  return FixItHint::CreateRemoval(MD->getSourceRange());
+}

I'm not an ObjC expert, so I apologize if this is a dumb question, but why is 
the fix-it removing the entire method as opposed to just the attribute?

Also, are you sure that the source range for the method declaration is 
sufficient to remove without breaking code? e.g., what about the definition of 
the method? Or can there be any trailing bits after the method that are not 
accounted for in the source range (such as trailing attributes, if those are 
possible in ObjC)?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst:29
+
+  Comma-separated list of names of macros that can define the unavailable
+  attribute for which fixes should be suggested. The default is an empty list.

This looks wrong to me -- it's a semicolon-delimited list, isn't it?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m:34
+// Verify check when using a macro that expands to the unavailable attribute.
+- (void)methodC NS_UNAVAILABLE;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodC' is marked 
unavailable but does not override a superclass method 
[objc-method-unavailable-not-override]

mwyman wrote:
> njames93 wrote:
> > Generally we are cautious about modifying MACRO usages in clang_tidy as we 
> > don't know if its definition can change based on configuration, perhaps its 
> > safer to just warn instead of providing a fix it
> Sounds reasonable; I made this the default behavior.
> 
> However for Objective-C, it's quite common for developers to use a macro from 
> the Apple SDKs like NS_UNAVAILABLE that are unconditional in any situations I 
> know of. I added a config option to allow whitelisting macros that should 
> have fix-its provided.
If the common practice is to use macros like NS_UNAVAILABLE, should that be on 
the default list of options (along with any other common-use macro names that 
do the same thing)?


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


[PATCH] D75770: [WebAssembly] Add SIMD integer min/max builtins

2020-03-06 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff, kripken.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100.
Herald added a project: clang.

Although SIMD integer min/max operations can be expressed using the ?:
operator in C++, that operator is disallowed for vectors in C. As a
workaround, this change introduces new WebAssembly-specific builtin
functions that lower to the desired vector icmp/select sequences.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75770

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c

Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -338,6 +338,90 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 min_s_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_min_s_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp slt <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i8x16 min_u_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_min_u_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp ult <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i8x16 max_s_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_max_s_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp sgt <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i8x16 max_u_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_max_u_i8x16(x, y);
+  // WEBASSEMBLY: %0 = icmp ugt <16 x i8> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <16 x i1> %0, <16 x i8> %x, <16 x i8> %y
+  // WEBASSEMBLY-NEXT: ret <16 x i8> %1
+}
+
+i16x8 min_s_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_min_s_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp slt <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i16x8 min_u_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_min_u_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp ult <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i16x8 max_s_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_max_s_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp sgt <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i16x8 max_u_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_max_u_i16x8(x, y);
+  // WEBASSEMBLY: %0 = icmp ugt <8 x i16> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <8 x i1> %0, <8 x i16> %x, <8 x i16> %y
+  // WEBASSEMBLY-NEXT: ret <8 x i16> %1
+}
+
+i32x4 min_s_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_min_s_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp slt <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
+i32x4 min_u_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_min_u_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp ult <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
+i32x4 max_s_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_max_s_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp sgt <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
+i32x4 max_u_i32x4(i32x4 x, i32x4 y) {
+  return __builtin_wasm_max_u_i32x4(x, y);
+  // WEBASSEMBLY: %0 = icmp ugt <4 x i32> %x, %y
+  // WEBASSEMBLY-NEXT: %1 = select <4 x i1> %0, <4 x i32> %x, <4 x i32> %y
+  // WEBASSEMBLY-NEXT: ret <4 x i32> %1
+}
+
 i16x8 sub_saturate_s_i16x8(i16x8 x, i16x8 y) {
   return __builtin_wasm_sub_saturate_s_i16x8(x, y);
   // WEBASSEMBLY: call <8 x i16> @llvm.wasm.sub.saturate.signed.v8i16(
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -14900,6 +14900,47 @@
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_min_s_i8x16:
+  case WebAssembly::BI__builtin_wasm_min_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_max_s_i8x16:
+  case WebAssembly::BI__builtin_wasm_max_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_min_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_min_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_max_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_max_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_min_s_i32x4:
+  case WebAssembly::BI__builtin_wasm_min_u_i32x4:
+  

[PATCH] D75752: [Sema] Move pointer to int cast warnings under -Wmicrosoft-cast

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

I agree with the reasoning, but this is likely to fire all over existing C++ 
code. In fact, the one we just added finds issues in Chrome
https://ci.chromium.org/p/chrome/builders/ci/ToTWin/5879
../../base/debug/close_handle_hook_win.cc(155,16): error: cast to smaller 
integer type 'unsigned long' from 'void *'

The idea was that -Wpointer-int-cast was a new warning group, so it was fine to 
add new findings to it, but -Wmicrosoft-cast already exists. In this case, I 
would recommend adding some new -W flag.

As for naming, -Wmicrosoft-pointer-to-int? It can still be a subgroup of 
-Wmicrosoft-cast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75752



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


[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-06 Thread Jeremy Stenglein via Phabricator via cfe-commits
jstenglein added a comment.

In D75768#1910303 , @erichkeane wrote:

> Any reason to not put this in -Wall like GCC? I'm not terribly knowledgeable 
> about the intended guidance for adding to Wmost, so if you can clarify this 
> decision I'd be grateful.  Otherwise I think this patch looks fine.


Thanks for the comments.  It is already part of -Wall since I put it in -Wmost 
and -Wall includes -Wmost:
def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
MisleadingIndentation]>;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768



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


[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Any reason to not put this in -Wall like GCC? I'm not terribly knowledgeable 
about the intended guidance for adding to Wmost, so if you can clarify this 
decision I'd be grateful.  Otherwise I think this patch looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768



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


[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

> I thought err_loader_uninitialized_extern says that the variable cannot have 
> external linkage?

Embarrassing! This was a badly written error message, now fixed to:
`external declaration of variable cannot have the 'loader_uninitialized' 
attribute`

The premise behind this feature is to be semantically identical to:
`type foo = undef;`

The initializer value is orthogonal to the variable linkage and visibility. If 
`= 4` was ok, so should this attribute be.

What is not meaningful is to declare that a variable is defined elsewhere that 
is uninitialized.
That is, `extern int x = 42; // warning: 'extern' variable has an initializer`
Therefore `[[loader_uninitialized]] int x = 42; // also bad`

This patch makes the latter an error, on the basis that it's definitely a 
mistake to provide two initializers for one variable (one 42, one undef).

C++ thinks `const int x;` is an error and C thinks `const int x;` is fine. This 
patch remains consistent with that.




Comment at: clang/lib/Sema/SemaDecl.cpp:12377
+  }
+  if (Var->getStorageClass() == SC_Extern) {
+Diag(Var->getLocation(), diag::err_loader_uninitialized_extern);

aaron.ballman wrote:
> Should this either be calling `VarDecl::hasExternalStorage()` or looking at 
> the linkage of the variable, rather than at the storage class written in the 
> source?
Interesting question, thank you. SC_Extern is right.

hasExternalStorage is true if extern or private_extern. I hadn't seen 
private_extern before, but it appears to be a way to model hidden visibility. 
It accepts a normal initializer, e.g.
`__private_extern__ int private_extern_can_be_initialised = 10;`
therefore should also work with undef.

Added a test for this (which will fail if SC_Extern is replaced with 
hasExternalStorage).

Replying to linkage out of line as it comes up on a few inline comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-03-06 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

If the current listed reviewers on this patch are not the best people for 
reviewing this, would one of them please suggest a more appropriate reviewer so 
we can get some traction on this?


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

https://reviews.llvm.org/D69585



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


[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-06 Thread Jeremy Stenglein via Phabricator via cfe-commits
jstenglein created this revision.
jstenglein added reviewers: efriedma, lebedev.ri, rsmith, erichkeane.
jstenglein added a project: clang.
Herald added a subscriber: cfe-commits.

Clang is missing a warning for __builtin_return_address/__builtin_frame_address 
called with > 0 argument.  Gcc provides a warning for this via -Wframe-address:

https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html

As calling these functions with argument > 0 has caused several crashes for us, 
we would like to have the same warning as gcc here.  This diff adds the warning 
and makes it part of -Wmost.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75768

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/builtin-returnaddress.c


Index: clang/test/Sema/builtin-returnaddress.c
===
--- /dev/null
+++ clang/test/Sema/builtin-returnaddress.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s
+
+void* a(unsigned x) {
+return __builtin_return_address(0);
+}
+
+void* b(unsigned x) {
+return __builtin_return_address(1); // expected-warning{{calling 
'__builtin_return_address' with a nonzero argument is unsafe}}
+}
+
+void* c(unsigned x) {
+return __builtin_frame_address(0);
+}
+
+void* d(unsigned x) {
+return __builtin_frame_address(1); // expected-warning{{calling 
'__builtin_frame_address' with a nonzero argument is unsafe}}
+}
+
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -16,6 +16,7 @@
 CHECK-NEXT:  -Wformat-y2k
 CHECK-NEXT:  -Wformat-invalid-specifier
 CHECK-NEXT:-Wfor-loop-analysis
+CHECK-NEXT:-Wframe-address
 CHECK-NEXT:-Wimplicit
 CHECK-NEXT:  -Wimplicit-function-declaration
 CHECK-NEXT:  -Wimplicit-int
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1851,6 +1851,17 @@
   case Builtin::BI__builtin_return_address:
 if (SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x))
   return ExprError();
+
+// -Wframe-address warning if non-zero passed to builtin
+// return/frame address.
+Expr::EvalResult Result;
+if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
+Result.Val.getInt() != 0)
+  Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
+  << ((BuiltinID == Builtin::BI__builtin_return_address)
+  ? "__builtin_return_address"
+  : "__builtin_frame_address")
+  << TheCall->getSourceRange();
 break;
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1780,6 +1780,11 @@
 def err_illegal_union_or_anon_struct_member : Error<
   "%select{anonymous struct|union}0 member %1 has a non-trivial "
   "%sub{select_special_member_kind}2">;
+
+def warn_frame_address : Warning<
+  "calling '%0' with a nonzero argument is unsafe">,
+  InGroup, DefaultIgnore;
+
 def warn_cxx98_compat_nontrivial_union_or_anon_struct_member : Warning<
   "%select{anonymous struct|union}0 member %1 with a non-trivial "
   "%sub{select_special_member_kind}2 is incompatible with C++98">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@
   DiagGroup<"float-conversion", [FloatOverflowConversion,
  FloatZeroConversion]>;
 
+def FrameAddress : DiagGroup<"frame-address">;
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
@@ -868,6 +869,7 @@
 DeleteNonVirtualDtor,
 Format,
 ForLoopAnalysis,
+FrameAddress,
 Implicit,
 InfiniteRecursion,
 IntInBoolContext,


Index: clang/test/Sema/builtin-returnaddress.c
===
--- /dev/null
+++ clang/test/Sema/builtin-returnaddress.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s
+
+void* a(unsigned x) {
+return __builtin_return_address(0);
+}
+
+void* b(unsigned x) {
+return __builtin_return_address(1); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}}
+}
+
+void* c(unsigned x) {
+return __builtin_frame_address(0);
+}
+
+void* 

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3673
+def warn_pointer_to_enum_cast : Warning<
+  "cast to smaller integer type %1 from %0">,
+  InGroup;

You can reuse warning text:

warn_pointer_to_int_cast.Text

I think..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75758



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


[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 248807.
JonChesterfield marked 2 inline comments as done.
JonChesterfield added a comment.

- Review comments, add tests for private_extern


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclBase.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-loader-uninitialized.c
  clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-loader-uninitialized.c
  clang/test/Sema/attr-loader-uninitialized.cpp

Index: clang/test/Sema/attr-loader-uninitialized.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-loader-uninitialized.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int good __attribute__((loader_uninitialized));
+static int local_ok __attribute__((loader_uninitialized));
+int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
+
+const int still_cant_be_const __attribute__((loader_uninitialized));
+// expected-error@-1 {{default initialization of an object of const type}}
+extern int external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{external declaration of variable cannot have the 'loader_uninitialized' attribute}}
+
+int noargs __attribute__((loader_uninitialized(0)));
+// expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}} 
+
+int init_rejected __attribute__((loader_uninitialized)) = 42;
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+void func() __attribute__((loader_uninitialized))
+// expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+{
+  int local __attribute__((loader_uninitialized));
+  // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+  static int sl __attribute__((loader_uninitialized));
+}
+
+struct s {
+  __attribute__((loader_uninitialized)) int field;
+  // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+  static __attribute__((loader_uninitialized)) int sfield;
+
+} __attribute__((loader_uninitialized));
+// expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+int redef_attr_first __attribute__((loader_uninitialized));
+int redef_attr_first;
+// expected-error@-1 {{redefinition of 'redef_attr_first'}}
+// expected-note@-3 {{previous definition is here}}
+
+int redef_attr_second; 
+int redef_attr_second __attribute__((loader_uninitialized)); 
+// expected-warning@-1 {{attribute declaration must precede definition}}
+// expected-note@-3 {{previous definition is here}}
+// expected-error@-3 {{redefinition of 'redef_attr_second'}}
+// expected-note@-5 {{previous definition is here}}
+
+struct trivial {};
+
+trivial default_ok __attribute__((loader_uninitialized));
+trivial value_rejected  __attribute__((loader_uninitialized)) {};
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+struct nontrivial
+{
+  nontrivial() {}
+};
+
+nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
Index: clang/test/Sema/attr-loader-uninitialized.c
===
--- /dev/null
+++ clang/test/Sema/attr-loader-uninitialized.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// See also attr-loader-uninitialized.cpp
+
+int good __attribute__((loader_uninitialized));
+static int local_ok __attribute__((loader_uninitialized));
+int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
+
+const int can_still_be_const __attribute__((loader_uninitialized));
+
+extern int external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{external declaration of variable cannot have the 'loader_uninitialized' attribute}}
+
+int noargs __attribute__((loader_uninitialized(0)));
+// expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
+
+int init_rejected __attribute__((loader_uninitialized)) = 42;
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+int declaration_then_uninit_ok;
+int declaration_then_uninit_ok __attribute__((loader_uninitialized));
+
+int definition_then_uninit_rejected = 0;
+int definition_then_uninit_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{redeclaration 

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks, Verified that this fixes the kernel warnings in my local builds with 
https://gist.github.com/nathanchance/767cccf4d093c1342e1994083518815e!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75758



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


[clang] 00b2a9d - Reapply "clang: Treat ieee mode as the default for denormal-fp-math"

2020-03-06 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-03-06T11:46:55-08:00
New Revision: 00b2a9df452d25cf4a780d20bab7d557d76604ae

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

LOG: Reapply "clang: Treat ieee mode as the default for denormal-fp-math"

This reverts commit 737394c490444e968a6f640b99a6614567ca7f28.

The fp-model test was failing on platforms that enable denormal flushing
based on -ffast-math. This needs to reset to IEEE, not the default in
these cases.

Change-Id: Ibbad32f66d0d0b89b9c1173a3a96fb1a570ddd89

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGenCUDA/flush-denormals.cu
clang/test/CodeGenCUDA/propagate-metadata.cu
clang/test/CodeGenOpenCL/amdgpu-features.cl
clang/test/Driver/cuda-flush-denormals-to-zero.cu
clang/test/Driver/denormal-fp-math.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 0a28edefa1e6..d435bebcdcf9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -164,10 +164,10 @@ class CodeGenOptions : public CodeGenOptionsBase {
   std::string FloatABI;
 
   /// The floating-point denormal mode to use.
-  llvm::DenormalMode FPDenormalMode;
+  llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE();
 
-  /// The floating-point subnormal mode to use, for float.
-  llvm::DenormalMode FP32DenormalMode;
+  /// The floating-point denormal mode to use, for float.
+  llvm::DenormalMode FP32DenormalMode = llvm::DenormalMode::getIEEE();
 
   /// The float precision limit to use, if non-empty.
   std::string LimitFloatPrecision;

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 400ff9d86664..88ce205228fd 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -623,8 +623,7 @@ class ToolChain {
   const llvm::opt::ArgList ,
   Action::OffloadKind DeviceOffloadKind,
   const llvm::fltSemantics *FPType = nullptr) const {
-// FIXME: This should be IEEE when default handling is fixed.
-return llvm::DenormalMode::getInvalid();
+return llvm::DenormalMode::getIEEE();
   }
 };
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d387a1dc2079..a998561a218b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2548,8 +2548,13 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   ReciprocalMath = false;
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcontract handling
-  DenormalFPMath = DefaultDenormalFPMath;
   FPContract = "";
+  DenormalFPMath = llvm::DenormalMode::getIEEE();
+
+  // FIXME: The target may have picked a non-IEEE default mode here based 
on
+  // -cl-denorms-are-zero. Should the target consider -fp-model 
interaction?
+  DenormalFP32Math = llvm::DenormalMode::getIEEE();
+
   StringRef Val = A->getValue();
   if (OFastEnabled && !Val.equals("fast")) {
   // Only -ffp-model=fast is compatible with OFast, ignore.
@@ -2724,9 +2729,10 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   SignedZeros = true;
   TrappingMath = true;
   FPExceptionBehavior = "strict";
-  // -fno_unsafe_math_optimizations restores default denormal handling
-  DenormalFPMath = DefaultDenormalFPMath;
-  DenormalFP32Math = DefaultDenormalFP32Math;
+
+  // The target may have opted to flush by default, so force IEEE.
+  DenormalFPMath = llvm::DenormalMode::getIEEE();
+  DenormalFP32Math = llvm::DenormalMode::getIEEE();
   break;
 
 case options::OPT_Ofast:
@@ -2760,18 +2766,19 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   RoundingFPMath = false;
   // -fno_fast_math restores default denormal and fpcontract handling
   DenormalFPMath = DefaultDenormalFPMath;
-  DenormalFP32Math = DefaultDenormalFP32Math;
+  DenormalFP32Math = llvm::DenormalMode::getIEEE();
   FPContract = "";
   break;
 }
 if (StrictFPModel) {
   // If -ffp-model=strict has been specified on command line but
   // subsequent options conflict then emit warning diagnostic.
-  // TODO: How should this interact with DenormalFP32Math?
   if (HonorINFs && HonorNaNs &&
 !AssociativeMath && !ReciprocalMath &&
 SignedZeros && TrappingMath && RoundingFPMath &&
-(FPContract.equals("off") || FPContract.empty()))
+(FPContract.equals("off") || 

[PATCH] D75723: [X86] Make intrinsics _BitScan* not limited to Windows

2020-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsX86.def:1904
+// BITSCAN
+TARGET_BUILTIN(_BitScanForward, "UcUNi*UNi", "n", "")
+TARGET_BUILTIN(_BitScanReverse, "UcUNi*UNi", "n", "")

craig.topper wrote:
> skan wrote:
> > craig.topper wrote:
> > > The N specifier here is sort of MSVC mode specific. I need to think about 
> > > this.
> > > 
> > > This also makes this available without including a header file which 
> > > isn't good if it doesn't start with __builtin.
> > I think we can define a new builtin `__builtin_ia32_BitScanForward` in 
> > BuiltinsX86.def. And when macro `_MSC_VER` is not defined, define 
> > `_BitScanForward` in ia32intrin.h by calling the 
> > `__builtin_ia32_BitScanForward`. Then we can avoid the N specifier and the 
> > name issue. Do you think it's appropriate?
> Instead of new builtins, can we use  __builtin_clz, __builtin_clzl, 
> __builin_ctz, __builtin_ctzl?
Right, even though _BitScan* is in the implementers namespace, we want to be 
careful about adding builtins that don't start with `__builtin_`. Unless we set 
some dramatically new direction of making all the implementer's namespace MSVC 
builtins available everywhere, I don't see why we would do this when we already 
have equivalent builtins.

Is there some particular motivation as to why you want to make these available 
everywhere? `-fms-extensions` is kind of already available everywhere. This 
compiles on Linux with `-fms-extensions`:
```
extern unsigned char _BitScanReverse64(unsigned int *, unsigned long long);
unsigned char test_BitScanReverse64(unsigned int *index, unsigned long long 
mask) {
  return _BitScanReverse64(index, mask);
}
```


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] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 248797.
ahatanak added a comment.

Don't try to push a cleanup in C++.


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/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,10 @@
   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 +187,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 +1,10 @@
+typedef struct {
+  id x;
+} S;
+
+id getObj(int c, id a) {
+  // Commenting out the following line because AST importer crashes when trying
+  // to import a BlockExpr.
+  // return c ? ^{ return a; }() : ((S){ .x = a }).x;
+  return ((S){ .x = a }).x;

[PATCH] D53327: [Hexagon] Use -fuse-ld update checks.

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


Repository:
  rC Clang

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

https://reviews.llvm.org/D53327



___
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-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment 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:
> > > > > 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.


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] D31342: Add ParsedAttrInfo::handleDeclAttribute

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



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6701-6707
 if (!AL.isStmtAttr()) {
   // Type attributes are handled elsewhere; silently move on.
   assert(AL.isTypeAttr() && "Non-type attribute not handled");
   break;
 }
 S.Diag(AL.getLoc(), diag::err_stmt_attribute_invalid_on_decl)
 << AL << D->getLocation();

john.brawn wrote:
> aaron.ballman wrote:
> > If we're in the situation where we parse a plugin-based attribute (so 
> > `AL.getKind()` falls into the `default` label) and its 
> > `handleDeclAttributes()` (incorrectly) returns false rather than true, it 
> > seems like we would not want to trigger either of these tests, correct? I'm 
> > thinking about a case where the plugin knows about that attribute but 
> > cannot apply it because of some other issues (maybe the subject is wrong, 
> > or args are incorrect, etc) and returns `false` here. We wouldn't want to 
> > assert or claim that this is an invalid statement attribute applied to a 
> > decl in that case.
> > 
> > Rather than requiring the user to return true from `handleDeclAttribute()`, 
> > it seems that what we really want is something more like:
> > ```
> > if (AL.getInfo().hasHandlerFunc()) {
> >   AL.getInfo().handleDeclAttribute(S, D, AL);
> >   break;
> > }
> > if (!AL.isStmtAttr()) {
> >   ...
> > }
> > S.Diag(...);
> > ```
> > where an unknown attribute does not have a handler, but simple and plugin 
> > attributes do have a handler. This way the user doesn't have the chance to 
> > accidentally get confused about what it means to handle an attribute. WDYT?
> That sounds a little overly complex, as instead of defining one thing you now 
> have to define two things so you have the possibility of defining one but not 
> the other which won't do anything useful.
I was hoping we could do it in such a way that the plugin user defines 
`handleDeclAttribute()` and the `hasHandlerFunc()` logic is automatic. This 
way, the user just has to define their function and "everything just works".

My big concern here is that we have a function with a useless return value 
(from the plugin author's perspective) but they're likely to get the behavior 
wrong through simple misunderstanding. Unless the plugin author is careful with 
their testing, this will lead to failed assertions when we go to check for 
whether it's type attribute or not.


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

https://reviews.llvm.org/D31342



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 248789.
ABataev marked an inline comment as done.
ABataev added a comment.

Rebase + fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/depobj_messages.cpp
  clang/test/OpenMP/parallel_reduction_messages.c
  clang/test/OpenMP/task_ast_print.cpp
  clang/test/OpenMP/task_depend_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -379,6 +379,10 @@
 K = CXCursor_OMPArraySectionExpr;
 break;
 
+  case Stmt::OMPArrayShapingExprClass:
+K = CXCursor_OMPArrayShapingExpr;
+break;
+
   case Stmt::BinaryOperatorClass:
 K = CXCursor_BinaryOperator;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5193,6 +5193,8 @@
   return cxstring::createRef("ArraySubscriptExpr");
   case CXCursor_OMPArraySectionExpr:
   return cxstring::createRef("OMPArraySectionExpr");
+  case CXCursor_OMPArrayShapingExpr:
+  return cxstring::createRef("OMPArrayShapingExpr");
   case CXCursor_BinaryOperator:
   return cxstring::createRef("BinaryOperator");
   case CXCursor_CompoundAssignOperator:
Index: clang/test/OpenMP/task_depend_messages.cpp
===
--- clang/test/OpenMP/task_depend_messages.cpp
+++ clang/test/OpenMP/task_depend_messages.cpp
@@ -35,14 +35,14 @@
   #pragma omp task depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}} omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected 'in', 'out', 'inout', 'mutexinoutset' or 'depobj' in OpenMP clause 'depend'}}
   #pragma omp task depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   #pragma omp task depend (out: ) // expected-error {{expected expression}}
-  #pragma omp task depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected addressable lvalue expression, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  #pragma omp task depend (inout : foobool(argc)), depend (in, argc) // omp50-error {{expected addressable lvalue expression, array element, array section or array shaping expression}} omp45-error {{expected addressable lvalue expression, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
   #pragma omp task depend (out :S1) // expected-error {{'S1' does not refer to a value}}
   #pragma omp task depend(in : argv[1][1] = '2')
-  #pragma omp task depend (in : vec[1]) // expected-error {{expected addressable lvalue expression, array element or array section}}
+  #pragma omp task depend (in : vec[1]) // omp50-error {{expected addressable lvalue expression, array element, array section or array shaping expression}} omp45-error {{expected addressable lvalue expression, array element or array section}}
   #pragma omp task depend (in : argv[0])
   #pragma omp task depend (in : ) // expected-error {{expected expression}}
   #pragma omp task depend (in : main)
-  #pragma omp task depend(in : a[0]) // expected-error{{expected addressable lvalue expression, array element or array section}}
+  #pragma omp task depend(in : a[0]) // omp50-error {{expected addressable lvalue 

[PATCH] D31342: Add ParsedAttrInfo::handleDeclAttribute

2020-03-06 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked 3 inline comments as done.
john.brawn added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6701-6707
 if (!AL.isStmtAttr()) {
   // Type attributes are handled elsewhere; silently move on.
   assert(AL.isTypeAttr() && "Non-type attribute not handled");
   break;
 }
 S.Diag(AL.getLoc(), diag::err_stmt_attribute_invalid_on_decl)
 << AL << D->getLocation();

aaron.ballman wrote:
> If we're in the situation where we parse a plugin-based attribute (so 
> `AL.getKind()` falls into the `default` label) and its 
> `handleDeclAttributes()` (incorrectly) returns false rather than true, it 
> seems like we would not want to trigger either of these tests, correct? I'm 
> thinking about a case where the plugin knows about that attribute but cannot 
> apply it because of some other issues (maybe the subject is wrong, or args 
> are incorrect, etc) and returns `false` here. We wouldn't want to assert or 
> claim that this is an invalid statement attribute applied to a decl in that 
> case.
> 
> Rather than requiring the user to return true from `handleDeclAttribute()`, 
> it seems that what we really want is something more like:
> ```
> if (AL.getInfo().hasHandlerFunc()) {
>   AL.getInfo().handleDeclAttribute(S, D, AL);
>   break;
> }
> if (!AL.isStmtAttr()) {
>   ...
> }
> S.Diag(...);
> ```
> where an unknown attribute does not have a handler, but simple and plugin 
> attributes do have a handler. This way the user doesn't have the chance to 
> accidentally get confused about what it means to handle an attribute. WDYT?
That sounds a little overly complex, as instead of defining one thing you now 
have to define two things so you have the possibility of defining one but not 
the other which won't do anything useful.


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

https://reviews.llvm.org/D31342



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


[PATCH] D75470: [SVE] Auto-generate builtins and header for svld1.

2020-03-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added a comment.
Herald added a subscriber: danielkiss.

In D75470#1907562 , @SjoerdMeijer 
wrote:

> Adding @simon_tatham in case he feels wants to have a look too.


Thanks Sjoerd! @simon_tatham and I had a chat about this offline today.

The SVE implementation now does more or less the same thing the MVE 
implementation; `arm_sve.h` also uses `__attribute__((overloadable))` and 
`__attribute__((arm_sve_alias("__builtin_...")))`, the latter only to declare 
the overloaded intrinsics. That means we get the same benefits as Simon 
described.

There are a few details that are different:

- The MVE implementation *does not* use the type string in the actual 
Builtins.def. For example, the type string below is not `"V16ScV16ScV16Sci"`, 
but rather `""`:


  TARGET_HEADER_BUILTIN(__builtin_arm_mve_vcaddq_rot270_f16, "", "n", 
"arm_mve.h", ALL_LANGUAGES, "")

- This means that the implementation relies solely on the declaration in 
arm_mve.h to define the intrinsic prototype.
- If I understood this correctly, this is currently needed to represent the 
tuple types (which cannot yet be expressed in the bulitin type string format) 
returned from structured loads like ld2/ld3/ld4.

The SVE implementation *does* use the type string in Builtins.def.

- For SVE, the structured loads will just return a wider vector with 2, 3 or 4 
times the number of elements, so the lack of support in the builtin type-string 
format is not an issue.
- An advantage of that is that we can use a `#define svadd_u8(...) 
__builtin_svadd_u8(...)` for the non-overloaded builtins which helps 
compile-time performance.

If all the intrinsics can be described *with* a builtin type string, we can 
actually work to define all builtins internally in Clang (as @efriedma 
suggested in D75298 ) rather than having to 
rely on the header file to define the prototypes, hopefully get rid of the 
expensive header file.
When we do this for SVE, MVE can probably follow the same approach.




Comment at: clang/include/clang/Basic/arm_sve.td:121
+// Load one vector (scalar base)
+def SVLD1   : MInst<"svld1[_{2}]", "dPc", "csilUcUsUiUlhfd", [IsLoad]>;

simon_tatham wrote:
> SjoerdMeijer wrote:
> > sdesmalen wrote:
> > > SjoerdMeijer wrote:
> > > > This encoding, e.g, this is  "csilUcUsUiUlhfd", is such a monstrosity. 
> > > > It's a very efficient encoding, but of course completely unreadable.  I 
> > > > know there is prior art, and know that this is how it's been done, but 
> > > > just curious if you have given it thoughts how to do this in a normal 
> > > > way, a bit more c++y.  I don't want to de-rail this work, but if we are 
> > > > adding a new emitter, perhaps now is the time to give it a thought, so 
> > > > was just curious.  
> > > Haha, its a bit of a monstrosity indeed. The only thing I can think of 
> > > here would be having something like:
> > > ```class TypeSpecs val> {
> > >   list v = val;
> > > }
> > > def All_Int_Float_Ty : TypeSpecs<["c", "s", "i", "l", "Uc", "Us", "Ul", 
> > > "h", "f", "d">;
> > > 
> > > def SVLD1 : Minst<"svld1[_{2}]", "dPc", All_Int_Float_Ty, [IsLoad]>;```
> > > 
> > > But I suspect this gets a bit awkward because of the many permutations, I 
> > > count more than 40. Not sure if that would really improve the readability.
> > I would personally welcome any improvement here, even the smallest. But if 
> > you think it's tricky, then fair enough!
> > 
> > I've managed to completely ignore the MVE intrinsics work so far, but 
> > understood there were some innovations here and there (e.g. in tablegen). 
> > Probably because it is dealing with similar problems: a lot of intrinsics, 
> > some of them overloaded with different types. I'm going to have a little 
> > look now to see if there's anything we can borrow from that, or if that is 
> > unrelated
> In the MVE intrinsics implementation I completely avoided that entire system 
> of string-based type specifications. There's another completely different way 
> you can set up the types of builtins, and I used that instead.
> 
> You can declare the function for `Builtins.def` purposes with no type 
> specification at all, and then you fill in its type signature using a 
> declaration in the //header file//, with the unusual combination of 
> `__inline__` and no function body:
> ```static __inline__ int32x4_t __builtin_arm_foo_bar(int16x8_t, float23x7t); 
> // or whatever```
> 
> In fact I went one step further: the user-facing names for the MVE intrinsics 
> are declared in `arm_mve.h` with a special attribute indicating that they're 
> aliases for clang builtins. And the MVE polymorphic intrinsics are done by 
> adding `__attribute__((overloadable))` to the declaration, which allows 
> C++-style overloading based on parameter types even when compiling in C. So 
> when the user invokes an MVE intrinsic by its 

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

2020-03-06 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 248788.
mwyman added a comment.

Update documentation to include description of the FixMacroNames config option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75569

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s objc-method-unavailable-not-override %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN: {key: objc-method-unavailable-not-override.FixMacroNames, \
+// RUN:  value: "UNAVAILABLE_FIXIT"} \
+// RUN: ]}' --
+
+__attribute__((objc_root_class))
+@interface Object
+- (instancetype)init;
+@end
+
+@interface MyObject : Object
+- (instancetype)init __attribute__((unavailable));
+
+// A new method that is not overriding, and is available, should not trigger.
+- (void)notOverridingMethod;
+
+- (void)methodA __attribute__((unavailable)); // methodA
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'methodA' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+// CHECK-FIXES: {{^\s*}}// methodA{{$}}
+
+// Verify check when unavailable attribute has a message.
+- (void)methodB __attribute__((unavailable("use methodE"))); // methodB
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'methodB' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+// CHECK-FIXES: {{^\s*}}// methodB{{$}}
+
+#define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable))
+#define UNAVAILABLE_FIXIT UNAVAILABLE_ATTRIBUTE
+#define UNAVAILABLE_NO_FIXIT UNAVAILABLE_ATTRIBUTE
+
+// Verify check with fix-it when using an configured macro that expands to the unavailable attribute.
+- (void)methodC UNAVAILABLE_FIXIT; // methodC
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: method 'methodC' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+// CHECK-FIXES: {{^\s*}}// methodC{{$}}
+
+// Verify check without fix-it when using a non-configured macro that expands to the unavailable attribute.
+- (void)methodD UNAVAILABLE_NO_FIXIT; // methodD
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: method 'methodD' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+// CHECK-FIXES-NOT: {{^\s*}}// methodD{{$}}
+@end
+
+
+@implementation MyObject
+
+- (void)notOverridingMethod {}
+
+// Should not flag implementations for methods declared unavailable; sometimes
+// implemementations are provided that assert, to catch such codepaths that
+// lead to those calls during development.
+- (void)methodA {}
+
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - objc-method-unavailable-not-override
+
+objc-method-unavailable-not-override
+
+
+Checks that a method marked with ``__attribute__((unavailable))`` is overriding
+a method declaration from a superclass. That declaration can usually be
+deleted entirely.
+
+.. code-block:: objc
+
+   @interface ClassA : NSObject
+   // Neither ClassA nor any superclasses define method -foo.
+   @end
+
+   @interface ClassB : ClassA
+   - (void)foo __attribute__((unavailable));
+   @end
+
+Suggests a fix to remove the method declaration entirely, except if the
+attribute was expanded from a macro not listed in the option ``FixMacroNames``.
+
+
+Options
+---
+
+.. option:: FixMacroNames
+
+  Comma-separated list of names of macros that can define the unavailable
+  attribute for which fixes should be suggested. The default is an empty list.
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
@@ -236,6 +236,7 @@
`objc-avoid-nserror-init `_,
`objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
+   

[PATCH] D75298: [Clang][SVE] Parse builtin type string for scalable vectors

2020-03-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a subscriber: simon_tatham.
sdesmalen added a comment.
Herald added a subscriber: danielkiss.

In D75298#1904561 , @efriedma wrote:

> > Do you happen to know which method in Sema does this? I had a look before, 
> > but couldn't find where we could do something like this.
>
> See Sema::LazilyCreateBuiltin, and its caller Sema::LookupBuiltin.


Thanks for those pointers! I spoke with @simon_tatham today, who is also very 
interested in this in order to simplify the MVE header file.

I would like to suggest first trying to land the current implementation (using 
the header file with all the declarations), so that we can use the regression 
tests added as part of this effort to test a different implementation that does 
not rely as much on the header file. What do you think?


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

https://reviews.llvm.org/D75298



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-06 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added a comment.

In D73898#1901142 , @balazske wrote:

> Is it sure that the signedness in the ranges is handled correctly? The EOF is 
> a negative value but the `RangeInt` is unsigned type. The 
> `tryExpandAsInteger` returns `int` too that is put into an unsigned 
> `RangeInt` later. Probably it is better to use `APSInt` for the ranges? (The 
> problem exists already before this change.)


That is not a problem, because finally in `apply` we use an `APSInt` that is 
constructed by considering the correct `T` type, e.g.:

  const llvm::APSInt  = BVF.getValue(R[I].first, T);

We could consider `RangeInt` as a buffer that is big enough to hold the 
representation of the range values. The concrete interpretation of the bits (as 
`T`) is done by `APSInt`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D75760: [clang-format] Do not indent C# array initialisers as continuations

2020-03-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jbcoe added a comment.

Needs https://reviews.llvm.org/D75731 and https://reviews.llvm.org/D75747 to be 
merged first.


Flag '= {' as a braced init list when parsing C# code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75760

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -562,6 +562,17 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpArrayInitializers) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  
+  verifyFormat(R"(//
+private MySet[] setPoints = {
+  new Point(),
+  new Point(),
+};)",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpNamedArguments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1436,6 +1436,11 @@
 
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
+// Block kind should probably be set to BK_BracedInit for any language.
+// C# needs this change to ensure that array initialisers and object
+// initialisers are indented the same way.
+if (Style.isCSharp())
+  FormatTok->BlockKind = BK_BracedInit;
 nextToken();
 parseBracedList();
   } else if (Style.Language == FormatStyle::LK_Proto &&
@@ -1628,7 +1633,7 @@
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
-
+  
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssigmentExpression() inside.
   do {


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -562,6 +562,17 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpArrayInitializers) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  
+  verifyFormat(R"(//
+private MySet[] setPoints = {
+  new Point(),
+  new Point(),
+};)",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpNamedArguments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1436,6 +1436,11 @@
 
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
+// Block kind should probably be set to BK_BracedInit for any language.
+// C# needs this change to ensure that array initialisers and object
+// initialisers are indented the same way.
+if (Style.isCSharp())
+  FormatTok->BlockKind = BK_BracedInit;
 nextToken();
 parseBracedList();
   } else if (Style.Language == FormatStyle::LK_Proto &&
@@ -1628,7 +1633,7 @@
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
-
+  
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssigmentExpression() inside.
   do {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75209: [OPENMP][NVPTX]Fix PR45003: add support for complex functions.

2020-03-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D75209#1909976 , @jdoerfert wrote:

> I am unsure we need this with the proper math support. Sema patch for that is 
> going for review today. I'll try this out soon.


It has nothing to do with the math functions support. These functions are 
required for the definition of __muldc3/__divdc3/__mulsc2/__divsc3 functions 
emitted for the complex types. CUDA does absolutely the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75209



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


[PATCH] D75760: [clang-format] Do not indent C# array initialisers as continuations

2020-03-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

Needs https://reviews.llvm.org/D75731 and https://reviews.llvm.org/D75747 to be 
merged first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75760



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-06 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 9 inline comments as done.
martong added a comment.

In D73898#1894923 , @balazske wrote:

> It may be useful to make a "macro value map" kind of object. Some macros can 
> be added to it as a string, and it is possible to lookup for an `Expr` if one 
> of the added macros is used there. This can be done by checking the concrete 
> (numeric) value of the `Expr` and compare to the value of the macro, or by 
> checking if the expression comes from a macro and take this macro name (use 
> string comparison). Such an object can be useful because the functionality is 
> needed at more checkers, for example the ones I am working on (StreamChecker 
> and ErrorReturnChecker too).


Please see my previous answer to @gamesh411




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:296
+def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">,
+  HelpText<"Check constraints of arguments of C standard library functions">,
+  Dependencies<[StdCLibraryFunctionsChecker]>,

Szelethus wrote:
> How about we add an example as well?
You mean like NonNull or other constraints?



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:697-699
+  // The behavior is undefined if the value of the argument is not
+  // representable as unsigned char or is not equal to EOF. See e.g. C99
+  // 7.4.1.2 The isalpha function (p: 181-182).

gamesh411 wrote:
> martong wrote:
> > Szelethus wrote:
> > > This is true for the rest of the summaries as well, but shouldn't we 
> > > retrieve the `unsigned char` size from `ASTContext`?
> > Yes this is a good idea. I will do this.
> > 
> > What bothers me really much, however, is that we should handle EOF in a 
> > platform dependent way as well ... and I have absolutely no idea how to do 
> > that given that is defined by a macro in a platform specific header file. I 
> > am desperately in need for help and ideas about how could we get the value 
> > of EOF for the analysed platform.
> If the EOF is not used in the TU analyzed, then there would be no way to find 
> the specific `#define`.
> Another approach would be to check if the value is defined by an expression 
> that is the EOF define (maybe transitively?).
I believe that the given standard C lib implementation (e.g. glibc) must 
provide a header for the prototypes of these functions where EOF is also 
defined transitively in any of the dependent system headers. Otherwise user 
code could misuse the value of EOF and thus the program would behave in an 
undefined manner.

C99 clearly states that you should #include  to use isalhpa.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:161
+
+ValueRange negate() const {
+  ValueRange tmp(*this);

Szelethus wrote:
> Maybe `complement` would be a better name? That sounds a lot more like a set 
> operation. Also, this function highlights well that inheritance might not be 
> the best solution here.
Well, we check the argument constraint validity by trying to apply it's logical 
negation. In case of a range inclusion this is being out of that range. In case 
of non-null this is being null. And so on. The logic how we try to check an 
argument constraint is the same in all cases of the different constraints. And 
that is the point: in order to support a new kind of constraint we just have to 
figure out how to "apply" and "negate" one constraint. In my opinion this is a 
perfect case for polimorphism.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:191
+  ///   * a list of branches - a list of list of ranges -
+  /// i.e. a list of lists of lists of segments,
+  ///   * a list of argument constraints, that must be true on every branch.

Szelethus wrote:
> I think that is a rather poor example to help understand what `list of list 
> of ranges` means :) -- Could you try to find something better?
Yeah, that part definitely should be reworded.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:10
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //

Szelethus wrote:
> I suspect this comment is no longer relevant.
Uh, yes.



Comment at: clang/test/Analysis/std-c-library-functions-arg-constraints.c:1-7
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -verify

Szelethus wrote:
> Hmm, why do we have 2 different test files that essentially do the same? 
> Shouldn't we only have a single 

[PATCH] D75209: [OPENMP][NVPTX]Fix PR45003: add support for complex functions.

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

I am unsure we need this with the proper math support. Sema patch for that is 
going for review today. I'll try this out soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75209



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 6 inline comments as done.
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:2891
   ArgExprs);
 }
+  } else if (!getLangOpts().ObjC && getLangOpts().OpenMP >= 50 &&

jdoerfert wrote:
> Out of curiosity, why do we prevent Objective C here? I doubt anyone runs it 
> in OpenMP mode but it would be kinda cool.
Just used this to prevent the error messages from Objective C tests when 
enabled OpenMP by default to test that parsing work correctl in the corner 
cases. Will remove this check.



Comment at: clang/lib/Sema/SemaExpr.cpp:4750
+return OMPArrayShapingExpr::Create(Context, Context.DependentTy, Base,
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())

jdoerfert wrote:
> Does this trigger as well if BaseTy is a pointer type but dependent? I mean, 
> why do we need the first check (`!BaseTy->isAnyPointerType() &&`)?
Not sure this is a real issue. If the type is not a pointer type, but the 
dependent, just skip all checks. All the required checks will be performed upon 
the instantiation.



Comment at: clang/test/OpenMP/parallel_reduction_messages.c:8
+#pragma omp parallel reduction(+ : incomplete, ([10])p) // expected-error {{a 
reduction list item with incomplete type 'int []'}} omp45-error {{expected 
expression}} omp50-error {{expected variable name, array element or array 
section}}
   ;
 }

jdoerfert wrote:
> Why is there a 50 error here?
Array shaping is not supported for the reductions



Comment at: clang/test/OpenMP/task_ast_print.cpp:153
+#pragma omp task untied mergeable depend(out:argv[:a][1], 
(arr)[0:],([argc][10])argv) if(task: argc > 0) priority(f)
+  // CHECK-NEXT: #pragma omp task untied mergeable depend(out : 
argv[:a][1],(arr)[0:],([argc][10])argv) if(task: argc > 0) priority(f)
   a = 2;

jdoerfert wrote:
> We do not complain that argc is non-constant. Is that on purpose?
Yes, the standard allows the use of the non-constant values as the dimensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance created this revision.
nathanchance added reviewers: Mordante, rjmccall.
Herald added a project: clang.

GCC does not warn on casts from pointers to enumerators, while clang
currently does: https://godbolt.org/z/3DFDVG

This causes a bunch of extra warnings in the Linux kernel, where
certain structs contain a void pointer to avoid using a gigantic
union for all of the various types of driver data, such as
versions.

Add a diagnostic that allows certain projects like the kernel to
disable the warning just for enums, which allowst those projects to
keep full compatibility with GCC but keeps the intention of treating
casts to integers and enumerators the same by default so that other
projects have the opportunity to catch issues not noticed before (or
follow suite and disable the warning).

Link: https://github.com/ClangBuiltLinux/linux/issues/887


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75758

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/cast.c


Index: clang/test/Sema/cast.c
===
--- clang/test/Sema/cast.c
+++ clang/test/Sema/cast.c
@@ -186,3 +186,23 @@
 void *intToPointerCast3() {
   return (void*)(1 + 3);
 }
+
+void voidPointerToEnumCast(VoidPtr v) {
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 
'VoidPtr' (aka 'void *')}}
+  // Test that casts to void* can be controlled separately
+  // from other -Wpointer-to-enum-cast warnings.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvoid-pointer-to-enum-cast"
+  (void)(X) v; // no-warning
+#pragma clang diagnostic pop
+}
+
+void pointerToEnumCast(CharPtr v) {
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 
'CharPtr' (aka 'char *')}}
+  // Test that casts to void* can be controlled separately
+  // from other -Wpointer-to-enum-cast warnings.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvoid-pointer-to-enum-cast"
+  (void)(X) v; // expected-warning{{cast to smaller integer type 'X' from 
'CharPtr' (aka 'char *')}}
+#pragma clang diagnostic pop
+}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2777,11 +2777,18 @@
   // If the result cannot be represented in the integer type, the behavior
   // is undefined. The result need not be in the range of values of any
   // integer type.
-  unsigned Diag = Self.getLangOpts().MicrosoftExt
-  ? diag::ext_ms_pointer_to_int_cast
-  : SrcType->isVoidPointerType()
-? diag::warn_void_pointer_to_int_cast
-: diag::warn_pointer_to_int_cast;
+  unsigned Diag;
+  if (Self.getLangOpts().MicrosoftExt)
+Diag = diag::ext_ms_pointer_to_int_cast;
+  else if (SrcType->isVoidPointerType())
+if (DestType->isEnumeralType())
+  Diag = diag::warn_void_pointer_to_enum_cast;
+else
+  Diag = diag::warn_void_pointer_to_int_cast;
+  else if (DestType->isEnumeralType())
+Diag = diag::warn_pointer_to_enum_cast;
+  else
+Diag = diag::warn_pointer_to_int_cast;
   Self.Diag(OpRange.getBegin(), Diag) << SrcType << DestType << OpRange;
 }
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3669,9 +3669,15 @@
 def warn_pointer_to_int_cast : Warning<
   "cast to smaller integer type %1 from %0">,
   InGroup;
+def warn_pointer_to_enum_cast : Warning<
+  "cast to smaller integer type %1 from %0">,
+  InGroup;
 def warn_void_pointer_to_int_cast : Warning<
   "cast to smaller integer type %1 from %0">,
   InGroup;
+def warn_void_pointer_to_enum_cast : Warning<
+  "cast to smaller integer type %1 from %0">,
+  InGroup;
 def ext_ms_pointer_to_int_cast : ExtWarn<
   "cast to smaller integer type %1 from %0 is a Microsoft extension">,
 InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -838,9 +838,13 @@
 def IntToVoidPointerCast : DiagGroup<"int-to-void-pointer-cast">;
 def IntToPointerCast : DiagGroup<"int-to-pointer-cast",
  [IntToVoidPointerCast]>;
-def VoidPointerToIntCast : DiagGroup<"void-pointer-to-int-cast">;
+def VoidPointerToEnumCast : DiagGroup<"void-pointer-to-enum-cast">;
+def VoidPointerToIntCast : DiagGroup<"void-pointer-to-int-cast",
+ [VoidPointerToEnumCast]>;
+def PointerToEnumCast : 

[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-03-06 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 4 inline comments as done.
martong added a comment.

In D74973#1900852 , @Szelethus wrote:

> I have some high level questions, you have spent far more time with this code 
> and I'm happy to be proven wrong! :)
>
> In D74973#1889188 , @martong wrote:
>
> > > Is really more kind of constraint needed than range constraint?
> >
> > Yes, there are other constraints I am planning to implement:
> >
> > - Size requirements E.g.: asctime_s(char *buf, rsize_t bufsz, const struct 
> > tm *time_ptr); `buf` size must be at least `bufsz`.
> > - Not-null
> > - Not-uninitalized
> > - Not-tainted
>
>
> Are we really sure that we need to express that with constraints? Can't we 
> just change the name of `ValueRange` (or encapsulate it in another class) and 
> add more fields to it, such as taintedness or initializedness? Is there an 
> incentive to keep `ValueRange` lean?


Yes there is: separation of concerns, i.e. ValueRange should handle Values with 
int ranges. One class should handle only one well established responsibility.

> This doesn't look too bad:
> 
>   auto Getc = [&]() {
> return Summary(ArgTypes{Irrelevant}, RetType{IntTy}, NoEvalCall)
> .Case(
> {ReturnValueDescription(RangeConstraints(WithinRange, {{EOFv, 
> EOFv}, {0, UCharMax}},
> Tainted, Non_Uninitialized});
>   };
> 
> 
> 
> 
>>> A non-null can be represented as range constraint too.
>> 
>> Actually, to implement that we should have a branch in all 
>> `ValueRange::apply*` functions that handles `Loc` SVals. Unfortunately, a 
>> pointer cannot be handled as `NonLoc`, and the current Range based 
>> implementation handles `NonLoc`s only.
> 
> So, why didn't we take that route instead? Marking a pointer non-null seems 
> to be a less invasive change.

The answer is the same here. I think we should not mix too much implementation 
of different cases into one monumental function/class.

> 
> 
>>> The compare constraint is used only for the return value for which a 
>>> special `ReturnConstraint` can be used to handle the return value not like 
>>> a normal argument (and then the `Ret` special value is not needed).
>> 
>> The Compare constraint is already forced into a Range "concept" whereas it 
>> has nothing to do with ranges. By handling compare constraints separately, 
>> we attach a single responsibility to each constraint class, instead of 
>> having a monolithic god constraint class. Take a look at this coerced data 
>> representation that we have today in ValueRange:
>> 
>>   BinaryOperator::Opcode getOpcode() const {
>> assert(Kind == ComparesToArgument);
>> assert(Args.size() == 1);
>> BinaryOperator::Opcode Op =
>> static_cast(Args[0].first);
>> assert(BinaryOperator::isComparisonOp(Op) &&
>>"Only comparison ops are supported for ComparesToArgument");
>> return Op;
>>   }
>>
>> 
>> Subclasses are a good way to get rid of this not-so-intuitive structure and 
>> assertions.
> 
> Having more fields feels like another possible solution.

Yes, having fields is another approach of having an enum and a union (i.e. 
tagged union). A tagged union is a variant basically. So adding more fields 
would finally be very similar to a variant based solution. And that is useful 
only if we know the set of classes beforehand and we want to gradually 
implement new operations on them.
In our case we know that we need 3 operations: apply, negate, warning and no 
more. And we want to gradually add new classes: NonNull, NotUninitialized, ...




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:151
+
+  using ValueConstraintPtr = std::shared_ptr;
+  /// The complete list of constraints that defines a single branch.

Szelethus wrote:
> gamesh411 wrote:
> > martong wrote:
> > > Note here, we need a copyable, polymorphic and default initializable type 
> > > (vector needs that). A raw pointer were good, however, we cannot default 
> > > initialize that. unique_ptr makes the Summary class non-copyable, 
> > > therefore not an option.
> > > Releasing the copyablitly requirement would render the initialization of 
> > > the Summary map infeasible.
> > > Perhaps we could come up with a [[ 
> > > https://www.youtube.com/watch?v=bIhUE5uUFOA | type erasure technique 
> > > without inheritance ]] once we consider the shared_ptr as restriction, 
> > > but for now that seems to be overkill.
> > std::variant (with std::monostate for the default constructibility) would 
> > also be an option  (if c++17 were supported). But this is not really an 
> > issue, i agree with that.
> Ugh, we've historically been very hostile towards virtual functions. We don't 
> mind them that much when they don't have to run a lot, like during bug report 
> construction, but as a core part of the analysis, I'm not sure what the 
> current stance 

[clang] 865456d - [Concepts] Add null check for TemplateTypeParmType::getDecl() in GetContainedInventedTypeParmVisitor

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

Author: Saar Raz
Date: 2020-03-06T19:32:10+02:00
New Revision: 865456d589e093582acaafd17d58ad1c0cce66af

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

LOG: [Concepts] Add null check for TemplateTypeParmType::getDecl() in 
GetContainedInventedTypeParmVisitor

GetContainedInventedTypeParmVisitor would not account for the case where 
TemplateTypeParmType::getDecl() is
nullptr, causing bug #45102.

Add the nullptr check.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaTemplate/instantiate-abbreviated-template.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 3ae2822a9803..b37b4bbba783 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2162,7 +2162,7 @@ namespace {
 // The deduced type itself.
 TemplateTypeParmDecl *VisitTemplateTypeParmType(
 const TemplateTypeParmType *T) {
-  if (!T->getDecl()->isImplicit())
+  if (!T->getDecl() || !T->getDecl()->isImplicit())
 return nullptr;
   return T->getDecl();
 }

diff  --git a/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp 
b/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp
index 99801115626f..1f2171a25ebb 100644
--- a/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp
+++ b/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp
@@ -31,3 +31,15 @@ struct G {
 
 using gf1 = decltype(G::foo1('a', 1, 2, 3, 4)); // 
expected-error{{no matching function}}
 using gf2 = decltype(G::foo2('a', 1, 2)); // expected-error{{no 
matching function}}
+
+
+// Regression (bug #45102): check that instantiation works where there is no
+// TemplateTypeParmDecl
+template  using id = T;
+
+template 
+constexpr void g() {
+  id f;
+}
+
+static_assert((g(), true));
\ No newline at end of file



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


[PATCH] D75723: [X86] Make intrinsics _BitScan* not limited to Windows

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



Comment at: clang/include/clang/Basic/BuiltinsX86.def:1904
+// BITSCAN
+TARGET_BUILTIN(_BitScanForward, "UcUNi*UNi", "n", "")
+TARGET_BUILTIN(_BitScanReverse, "UcUNi*UNi", "n", "")

skan wrote:
> craig.topper wrote:
> > The N specifier here is sort of MSVC mode specific. I need to think about 
> > this.
> > 
> > This also makes this available without including a header file which isn't 
> > good if it doesn't start with __builtin.
> I think we can define a new builtin `__builtin_ia32_BitScanForward` in 
> BuiltinsX86.def. And when macro `_MSC_VER` is not defined, define 
> `_BitScanForward` in ia32intrin.h by calling the 
> `__builtin_ia32_BitScanForward`. Then we can avoid the N specifier and the 
> name issue. Do you think it's appropriate?
Instead of new builtins, can we use  __builtin_clz, __builtin_clzl, 
__builin_ctz, __builtin_ctzl?


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] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

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

In D74935#1909054 , @jeroen.dobbelaere 
wrote:

> In D74935#1908665 , @jdoerfert wrote:
>
> > I think we conflate two things here:
> >
> > 1. The modifications to the LangRef which should be in accordance with the 
> > C standard (at least I haven't seen you contradict the new wording 
> > directly).
>
>
> imho, the proposed wording is still confusing, and does not handle the case 
> with the extra indirections.
>  Unless the 'by any means' was meant to also include the  '.. Every  access  
> that modifies X shall be considered also to modify P,for the purposes of this 
> subclause. .. ' from the restrict specification.
>  If that is the idea, we should mention it explicitly.


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.

>> 2. The extended `noalias` deduction D73428 .
>> 
>>   If you look at the commit message in D73428 
>> , it says that `noalias` is not just 
>> derived for all `readonly` arguments. In your example we access `unknown` 
>> memory, e.g., `**pA=42`, so case (1) cannot be applied. For case (2) we need 
>> to show that the loads of `pA` and `pB` do not alias, which we cannot.
> 
> 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 :)


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] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:2891
   ArgExprs);
 }
+  } else if (!getLangOpts().ObjC && getLangOpts().OpenMP >= 50 &&

Out of curiosity, why do we prevent Objective C here? I doubt anyone runs it in 
OpenMP mode but it would be kinda cool.



Comment at: clang/lib/Sema/SemaExpr.cpp:4744
+  // Delay analysis of the types/expressions if instantiation/specialixzation 
is
+  // required.
+  if (!BaseTy->isAnyPointerType() &&

Typo above.



Comment at: clang/lib/Sema/SemaExpr.cpp:4750
+return OMPArrayShapingExpr::Create(Context, Context.DependentTy, Base,
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())

Does this trigger as well if BaseTy is a pointer type but dependent? I mean, 
why do we need the first check (`!BaseTy->isAnyPointerType() &&`)?



Comment at: clang/test/OpenMP/parallel_reduction_messages.c:8
+#pragma omp parallel reduction(+ : incomplete, ([10])p) // expected-error {{a 
reduction list item with incomplete type 'int []'}} omp45-error {{expected 
expression}} omp50-error {{expected variable name, array element or array 
section}}
   ;
 }

Why is there a 50 error here?



Comment at: clang/test/OpenMP/task_ast_print.cpp:153
+#pragma omp task untied mergeable depend(out:argv[:a][1], 
(arr)[0:],([argc][10])argv) if(task: argc > 0) priority(f)
+  // CHECK-NEXT: #pragma omp task untied mergeable depend(out : 
argv[:a][1],(arr)[0:],([argc][10])argv) if(task: argc > 0) priority(f)
   a = 2;

We do not complain that argc is non-constant. Is that on purpose?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-06 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 248757.
jroelofs added a comment.

- Drop dead include.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621

Files:
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -125,6 +125,11 @@
   check now detects in class initializers and constructor initializers which
   are deemed to be redundant.
 
+- Checks supporting the ``HeaderFileExtensions`` flag now support ``;`` as a
+  delimiter in addition to ``,``, with the latter being deprecated as of this
+  release. This simplifies how one specifies the options on the command line:
+  ``--config="{CheckOptions: [{ key: HeaderFileExtensions, value: h;;hpp;hxx }]}"``
+
 Renamed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.h
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.h
@@ -18,11 +18,12 @@
 
 /// Finds and fixes header guards.
 /// The check supports these options:
-///   - `HeaderFileExtensions`: a comma-separated list of filename extensions of
-/// header files (The filename extension should not contain "." prefix).
-/// ",h,hh,hpp,hxx" by default.
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extension should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+///
 /// For extension-less header files, using an empty string or leaving an
-/// empty string between "," if there are other filename extensions.
+/// empty string between ";" if there are other filename extensions.
 class HeaderGuardCheck : public ClangTidyCheck {
 public:
   HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
@@ -30,7 +31,8 @@
 RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
 "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
 utils::parseFileExtensions(RawStringHeaderFileExtensions,
-   HeaderFileExtensions, ',');
+   HeaderFileExtensions,
+   utils::defaultFileExtensionDelimiters());
   }
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -34,11 +34,16 @@
 
 /// Returns recommended default value for the list of header file
 /// extensions.
-inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
+inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
+
+/// Returns recommended default value for the list of file extension
+/// delimiters.
+inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
 
 /// Parses header file extensions from a semicolon-separated list.
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet , char Delimiter);
+ FileExtensionsSet ,
+ StringRef Delimiters);
 
 /// Decides whether a file has one of the specified file extensions.
 bool isFileExtension(StringRef FileName,
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -33,9 +33,16 @@
 }
 
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet , char Delimiter) {
+ FileExtensionsSet ,
+ StringRef Delimiters) {
   SmallVector Suffixes;
-  

[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-03-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:365
 
+  llvm::SmallString<256> AbsPath = CTUDir;
+  llvm::sys::path::append(AbsPath, Identifier);

Could we check somehow if `CTUDir` is indeed an absolute path? If not then 
probably we should bail out with an error. Though I am not sure if there is an 
easy and portable way in llvm:: to check for beeing an absolute path.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:375
+/// Load the AST from a source-file, which is supposed to be located inside the
+/// compilation database \p OnDemandParsingCommands. The compilation database
+/// can contain the path of the file under the key "file" as an absolute path,

There is no variable named as `OnDemandParsingCommands`, perhaps you made a 
rename but forgot to rename in the comments?



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:384
+/// the invocation inside ClangTool is always made with an absolute path. \p
+/// ASTSourcePath is assumed to be the lookup-name of the file, which comes 
from
+/// the Index. The Index is built by the \p clang-extdef-mapping tool, which is

There is no variable named as `ASTSourcePath`, perhaps you made a rename but 
forgot to rename in the comments?



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:413
+  Files.push_back(std::string(Identifier));
+  ClangTool Tool(*CompileCommands, Files, CI.getPCHContainerOperations());
+

martong wrote:
> martong wrote:
> > Seems like `Tool` has it's lifetime ended when `load()` finishes. But we 
> > have long living `ASTUnits` whose lifetime are longer then the `Tool` which 
> > created them. Is this not a problem?
> `CI.getPCHContainerOperations()` is probably not needed, because we are not 
> going to exercise the ASTReader, so this could be a nullptr (default param 
> value).
If `CI.getPCHContainerOperations()` is not needed then we can remove the `CI` 
member of `ASTOnDemandLoader`.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:443
+/// be the absolute path of the file.
+*SourceFilePath = Identifier.str();
+

Perhaps we should make sure that `Identifier` is indeed an absolute path and if 
not then we should emit an error. If a user do not use CodeChecker to generate 
the ExternalDefMapping it may contain relative paths. See e.g.: 
https://clang.llvm.org/docs/analyzer/user-docs/CrossTranslationUnit.html#manual-ctu-analysis



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:457
+return llvm::make_error(
+index_error_code::ambiguous_compile_commands_database);
+

Could we have a lit test for this case? I.e having a compile_commands.json with 
two ambiguous entries for the same file and then we should expect the compiler 
diag?
(Note, I am asking this because it is not immediate for me from the code that 
this will ever fire.)



Comment at: clang/test/Analysis/ctu-main.c:53
   clang_analyzer_eval(res == 6); // expected-warning{{TRUE}}
+  // Call something with uninitialized from the same function in which the 
implicit was called.
+  // This is necessary to reproduce a special bug in NoStoreFuncVisitor.

Is this hunk related?



Comment at: clang/test/Analysis/ctu-on-demand-parsing.c:3
 // RUN: mkdir -p %t/ctudir2
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
-// RUN:   -emit-pch -o %t/ctudir2/ctu-other.c.ast %S/Inputs/ctu-other.c
-// RUN: cp %S/Inputs/ctu-other.c.externalDefMap.txt 
%t/ctudir2/externalDefMap.txt
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -std=c89 -analyze 
\
+// RUN: echo '[{"directory":"%S/Inputs","command":"clang -x c -std=c89 -c 
ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\//g' > 
%t/ctudir2/compile_commands.json
+// RUN: %clang_extdef_map %S/Inputs/ctu-other.c > %t/ctudir2/externalDefMap.txt

Why do we need `sed` here? I don't see any `\` in the compile commands json. Is 
it because of Windows builds? Could you please explain in a comment maybe in 
the previous line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-06 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 248755.
jroelofs added a comment.

- Don't spam the deprecation message. Move that to release notes.
- Drop unnecessary `const`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621

Files:
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -125,6 +125,11 @@
   check now detects in class initializers and constructor initializers which
   are deemed to be redundant.
 
+- Checks supporting the ``HeaderFileExtensions`` flag now support ``;`` as a
+  delimiter in addition to ``,``, with the latter being deprecated as of this
+  release. This simplifies how one specifies the options on the command line:
+  ``--config="{CheckOptions: [{ key: HeaderFileExtensions, value: h;;hpp;hxx }]}"``
+
 Renamed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.h
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.h
@@ -18,11 +18,12 @@
 
 /// Finds and fixes header guards.
 /// The check supports these options:
-///   - `HeaderFileExtensions`: a comma-separated list of filename extensions of
-/// header files (The filename extension should not contain "." prefix).
-/// ",h,hh,hpp,hxx" by default.
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extension should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+///
 /// For extension-less header files, using an empty string or leaving an
-/// empty string between "," if there are other filename extensions.
+/// empty string between ";" if there are other filename extensions.
 class HeaderGuardCheck : public ClangTidyCheck {
 public:
   HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
@@ -30,7 +31,8 @@
 RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
 "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
 utils::parseFileExtensions(RawStringHeaderFileExtensions,
-   HeaderFileExtensions, ',');
+   HeaderFileExtensions,
+   utils::defaultFileExtensionDelimiters());
   }
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -34,11 +34,16 @@
 
 /// Returns recommended default value for the list of header file
 /// extensions.
-inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
+inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
+
+/// Returns recommended default value for the list of file extension
+/// delimiters.
+inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
 
 /// Parses header file extensions from a semicolon-separated list.
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet , char Delimiter);
+ FileExtensionsSet ,
+ StringRef Delimiters);
 
 /// Decides whether a file has one of the specified file extensions.
 bool isFileExtension(StringRef FileName,
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -9,6 +9,7 @@
 #include "FileExtensionsUtils.h"
 #include "clang/Basic/CharInfo.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace tidy {
@@ -33,9 

[clang] 5dadf57 - [OPENMP50]Add 'depobj' modifier in 'depend' clauses.

2020-03-06 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-06T11:44:57-05:00
New Revision: 5dadf577d59b53110f2a0084dc9ef9f974116955

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

LOG: [OPENMP50]Add 'depobj' modifier in 'depend' clauses.

Added basic support (parsing/sema/serialization) for depobj dependency
kind in depend clauses.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/depobj_codegen.cpp
clang/test/OpenMP/depobj_messages.cpp
clang/test/OpenMP/ordered_messages.cpp
clang/test/OpenMP/target_depend_messages.cpp
clang/test/OpenMP/target_enter_data_depend_messages.cpp
clang/test/OpenMP/target_exit_data_depend_messages.cpp
clang/test/OpenMP/target_parallel_depend_messages.cpp
clang/test/OpenMP/target_parallel_for_depend_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
clang/test/OpenMP/target_simd_depend_messages.cpp
clang/test/OpenMP/target_teams_depend_messages.cpp
clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
clang/test/OpenMP/target_update_depend_messages.cpp
clang/test/OpenMP/task_ast_print.cpp
clang/test/OpenMP/task_depend_messages.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index cb3dd24a44cf..181341fed780 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9633,7 +9633,7 @@ def err_omp_expected_var_name_member_expr : Error<
 def err_omp_expected_var_name_member_expr_or_array_item : Error<
   "expected variable name%select{|, data member of current class}0, array 
element or array section">;
 def err_omp_expected_addressable_lvalue_or_array_item : Error<
-  "expected addressable lvalue expression, array element or array section">;
+  "expected addressable lvalue expression, array element or array 
section%select{| of non 'omp_depend_t' type}0">;
 def err_omp_expected_named_var_member_or_array_expression: Error<
   "expected expression containing only member accesses and/or array sections 
based on named variables">;
 def err_omp_bit_fields_forbidden_in_clause : Error<

diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index dbc0d1cec2c7..70f962427e36 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -384,6 +384,7 @@ OPENMP_DEPEND_KIND(in)
 OPENMP_DEPEND_KIND(out)
 OPENMP_DEPEND_KIND(inout)
 OPENMP_DEPEND_KIND(mutexinoutset)
+OPENMP_DEPEND_KIND(depobj)
 OPENMP_DEPEND_KIND(source)
 OPENMP_DEPEND_KIND(sink)
 

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 620f6ea3e654..e16dfbcddbe2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5214,6 +5214,7 @@ static RTLDependenceKindTy 
translateDependencyKind(OpenMPDependClauseKind K) {
 break;
   case OMPC_DEPEND_source:
   case OMPC_DEPEND_sink:
+  case OMPC_DEPEND_depobj:
   case OMPC_DEPEND_unknown:
 llvm_unreachable("Unknown task dependence type");
   }

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 27b88b331199..1da884f657a0 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3198,9 +3198,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
   Data.RLoc = Tok.getLocation();
   if (!T.consumeClose())
 Data.RLoc = T.getCloseLocation();
-  return (Kind == OMPC_depend && Data.ExtraModifier != OMPC_DEPEND_unknown &&
-  Vars.empty()) ||
- (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) ||
+  return (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) ||
  (MustHaveTail && !Data.TailExpr) || InvalidReductionId ||
  IsInvalidMapperModifier;
 }

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index d42a9f45cf8c..c0fb56c47371 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -12247,8 +12247,9 @@ OMPClause 
*Sema::ActOnOpenMPUpdateClause(OpenMPDependClauseKind Kind,
  SourceLocation LParenLoc,
  SourceLocation EndLoc) {
   if (Kind == OMPC_DEPEND_unknown || Kind == OMPC_DEPEND_source ||
- 

[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping 3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D75209: [OPENMP][NVPTX]Fix PR45003: add support for complex functions.

2020-03-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75209



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


[PATCH] D75022: clang-format: Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-03-06 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2eff1c3ce48e: [clang-format] Extend 
AllowShortLoopsOnASingleLine to do ... while loops. (authored by 
mitchell-stellar).

Changed prior to commit:
  https://reviews.llvm.org/D75022?vs=246512=248748#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75022

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -556,6 +556,30 @@
   verifyFormat("for (;;) /* still don't merge */\n"
"  continue;",
AllowsMergedLoops);
+  verifyFormat("do a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do /* Don't merge */\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do\n"
+   "  // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  // Without braces labels are interpreted differently.
+  verifyFormat("{\n"
+   "  do\n"
+   "  label:\n"
+   "a++;\n"
+   "  while (true);\n"
+   "}",
+   AllowsMergedLoops);
 }
 
 TEST_F(FormatTest, FormatShortBracedStatements) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -411,7 +411,7 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -514,7 +514,10 @@
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine  = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
+  return 0;
+// Only merge do while if do is the only statement on the line.
+if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
   return 0;
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -556,6 +556,30 @@
   verifyFormat("for (;;) /* still don't merge */\n"
"  continue;",
AllowsMergedLoops);
+  verifyFormat("do a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do /* Don't merge */\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do\n"
+   "  // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  // Without braces labels are interpreted differently.
+  verifyFormat("{\n"
+   "  do\n"
+   "  label:\n"
+   "a++;\n"
+   "  while (true);\n"
+   "}",
+   AllowsMergedLoops);
 }
 
 TEST_F(FormatTest, FormatShortBracedStatements) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -411,7 +411,7 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -514,7 +514,10 @@
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine  = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
+  return 0;
+// Only merge do while if do is the only statement on the line.
+if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
   return 0;
 if (1 + I[1]->Last->TotalLength > 

[PATCH] D75752: [Sema] Move pointer to int cast warnings under -Wmicrosoft-cast

2020-03-06 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
aeubanks edited the summary of this revision.
aeubanks added reviewers: thakis, rnk.
aeubanks retitled this revision from "Move warnings added in 
https://reviews.llvm.org/D75708 under -Wmicrosoft-cast" to "[Sema] Move pointer 
to int cast warnings under -Wmicrosoft-cast".
aeubanks edited the summary of this revision.

Microsoft extensions should be under a -Wmicrosoft-foo group.
Added in https://reviews.llvm.org/D75708.

There shouldn't be a reason to separate out void pointers since this is C++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75752

Files:
  clang/lib/Sema/SemaCast.cpp


Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2209,10 +2209,8 @@
   bool MicrosoftException =
   Self.getLangOpts().MicrosoftExt && !DestType->isBooleanType();
   if (MicrosoftException) {
-unsigned Diag = SrcType->isVoidPointerType()
-? diag::warn_void_pointer_to_int_cast
-: diag::warn_pointer_to_int_cast;
-Self.Diag(OpRange.getBegin(), Diag) << SrcType << DestType << OpRange;
+Self.Diag(OpRange.getBegin(), diag::ext_ms_pointer_to_int_cast)
+<< SrcType << DestType << OpRange;
   } else {
 msg = diag::err_bad_reinterpret_cast_small_int;
 return TC_Failed;


Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2209,10 +2209,8 @@
   bool MicrosoftException =
   Self.getLangOpts().MicrosoftExt && !DestType->isBooleanType();
   if (MicrosoftException) {
-unsigned Diag = SrcType->isVoidPointerType()
-? diag::warn_void_pointer_to_int_cast
-: diag::warn_pointer_to_int_cast;
-Self.Diag(OpRange.getBegin(), Diag) << SrcType << DestType << OpRange;
+Self.Diag(OpRange.getBegin(), diag::ext_ms_pointer_to_int_cast)
+<< SrcType << DestType << OpRange;
   } else {
 msg = diag::err_bad_reinterpret_cast_small_int;
 return TC_Failed;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-03-06 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

It's not more approval that is needed, it's just that someone with commit 
access (assuming you do not) needs to find the time to commit this. For what 
it's worth, I'm getting a patch rejection for the 4th block in 
lib/Format/Format.cpp. It seems the contents of `LoadConfigFile` need to be 
updated to reflect the most recent changes, so please rebase against master 
when you can.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[clang] 2eff1c3 - [clang-format] Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-03-06 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2020-03-06T11:13:23-05:00
New Revision: 2eff1c3ce48ef529064e2dc006d57c37da0b4d84

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

LOG: [clang-format] Extend AllowShortLoopsOnASingleLine to do ... while loops.
Summary:
If AllowShortLoopsOnASingleLine is enabled,

  do
a++;
  while (true);

becomes

  do a++;
  while (true);

Reviewers: MyDeveloperDay, mitchell-stellar

Reviewed by: mitchell-stellar

Contributed by: DaanDeMeyer

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index da9ee41da71b..84ccbec2150d 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -411,7 +411,7 @@ class LineJoiner {
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -514,7 +514,10 @@ class LineJoiner {
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine  = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
+  return 0;
+// Only merge do while if do is the only statement on the line.
+if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
   return 0;
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index cb052ecaf111..a6f35ba27069 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -556,6 +556,30 @@ TEST_F(FormatTest, FormatLoopsWithoutCompoundStatement) {
   verifyFormat("for (;;) /* still don't merge */\n"
"  continue;",
AllowsMergedLoops);
+  verifyFormat("do a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do /* Don't merge */\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do\n"
+   "  // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  // Without braces labels are interpreted 
diff erently.
+  verifyFormat("{\n"
+   "  do\n"
+   "  label:\n"
+   "a++;\n"
+   "  while (true);\n"
+   "}",
+   AllowsMergedLoops);
 }
 
 TEST_F(FormatTest, FormatShortBracedStatements) {



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


[PATCH] D75749: [clang-tidy] extend bugprone-signed-char-misuse check.

2020-03-06 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

In the LibreOffice codebase, I found 8 catches:
https://gist.github.com/tzolnai/2b22492c0cf79f5dba577f6a878657e3

All catches seem valid to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75749



___
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-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Actually, this is the diff:

  diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
  index ecd871e36ee..1f2c8c50a01 100644
  --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
  +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
  @@ -341,6 +341,8 @@ def err_analyzer_checker_option_unknown : Error<
 "checker '%0' has no option called '%1'">;
   def err_analyzer_checker_option_invalid_input : Error<
 "invalid input for checker option '%0', that expects %1">;
  +def err_analyzer_checker_incompatible_analyzer_option : Error<
  +  "checker cannot be enabled with analyzer option '%0' == %1">;
   
   def err_drv_invalid_hvx_length : Error<
 "-mhvx-length is not supported without a -mhvx/-mhvx= flag">;
  diff --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  index a3a85bfac13..680cb92e1ff 100644
  --- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  +++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  @@ -169,8 +169,8 @@ public:
 void finishedCheckerRegistration();
   
 const LangOptions () const { return LangOpts; }
  -  AnalyzerOptions () { return AOptions; }
  -  ASTContext () {
  +  AnalyzerOptions () const { return AOptions; }
  +  ASTContext () const {
   assert(Context);
   return *Context;
 }
  diff --git a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  index 16a913e761c..f739417a37b 100644
  --- a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  +++ b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  @@ -12,6 +12,7 @@
   
   #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
   #include "clang/AST/DeclTemplate.h"
  +#include "clang/Driver/DriverDiagnostic.h"
   #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
   #include "clang/StaticAnalyzer/Core/Checker.h"
   #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
  @@ -1036,5 +1037,15 @@ void ento::registerContainerModeling(CheckerManager 
) {
   }
   
   bool ento::shouldRegisterContainerModeling(const CheckerManager ) {
  +  if (!mgr.getLangOpts().CPlusPlus)
  +return false;
  +
  +  if (!mgr.getAnalyzerOptions().ShouldAggressivelySimplifyBinaryOperation) {
  +mgr.getASTContext().getDiagnostics().Report(
  +diag::err_analyzer_checker_incompatible_analyzer_option)
  +  << "aggressive-binary-operation-simplification" << "false";
  +return false;
  +  }
  +
 return true;
   }
  diff --git a/clang/test/Analysis/checker-dependencies.c 
b/clang/test/Analysis/checker-dependencies.c
  index 6c8583adb35..54d585561d1 100644
  --- a/clang/test/Analysis/checker-dependencies.c
  +++ b/clang/test/Analysis/checker-dependencies.c
  @@ -18,3 +18,11 @@
   
   // CHECK-IMPLICITLY-DISABLED-NOT: osx.cocoa.RetainCountBase
   // CHECK-IMPLICITLY-DISABLED-NOT: osx.cocoa.RetainCount
  +
  +// RUN: %clang_analyze_cc1 %s \
  +// RUN:   -analyzer-checker=cplusplus.IteratorModeling \
  +// RUN:   -analyzer-config aggressive-binary-operation-simplification=false \
  +// RUN:   -analyzer-list-enabled-checkers \
  +// RUN:   2>&1 | FileCheck %s -check-prefix=DEPENDENCY-SHOULD-NOT-REGISTER
  +
  +// DEPENDENCY-SHOULD-NOT-REGISTER: 
'aggressive-binary-operation-simplification' == false


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] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-03-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Ping


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

https://reviews.llvm.org/D70172



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


[PATCH] D68165: [analyzer][MallocChecker][NFC] Split checkPostCall up, deploy CallDescriptionMap

2020-03-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added a comment.

In D68165#1902702 , @Charusso wrote:

> I wish for a third map, something like `ReallocationMap`. Other than that it 
> is a great direction, I love it. Thanks!


Hah, that is a neat idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68165



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


[PATCH] D75749: [clang-tidy] extend bugprone-signed-char-misuse check.

2020-03-06 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
ztamas added a reviewer: aaron.ballman.
ztamas added a comment.

I run the check on LLVM code and found only one catch of suspicious comparison:

  clang-tidy -p=/home/zolnai/clang/build 
/home/zolnai/clang/llvm-project/clang/lib/Lex/Lexer.cpp
  /home/zolnai/clang/llvm-project/clang/lib/Lex/Lexer.cpp:1293:39: warning: 
comparison between signed and unsigned char [bugprone-signed-char-misuse]
if ((C == '\n' || C == '\r') && C != PrevC)


ztamas added a comment.

In the LibreOffice codebase, I found 8 catches:
https://gist.github.com/tzolnai/2b22492c0cf79f5dba577f6a878657e3

All catches seem valid to me.


Cover a new use case when using a 'signed char' as an integer
might lead to issue with non-ASCII characters. Comparing
a 'signed char' with an 'unsigned char' using equality / unequality
operator produces an unexpected result for non-ASCII characters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75749

Files:
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
@@ -62,6 +62,34 @@
   return NCharacter;
 }
 
+int SignedUnsignedCharEquality(signed char SCharacter) {
+  unsigned char USCharacter = 'a';
+  if (SCharacter == USCharacter) // CHECK-MESSAGES: [[@LINE]]:7: warning: comparison between signed and unsigned char [bugprone-signed-char-misuse]
+return 1;
+  return 0;
+}
+
+int SignedUnsignedCharUneqiality(signed char SCharacter) {
+  unsigned char USCharacter = 'a';
+  if (SCharacter != USCharacter) // CHECK-MESSAGES: [[@LINE]]:7: warning: comparison between signed and unsigned char [bugprone-signed-char-misuse]
+return 1;
+  return 0;
+}
+
+int CompareWithNonAsciiConstant(unsigned char USCharacter) {
+  const signed char SCharacter = -5;
+  if (USCharacter == SCharacter) // CHECK-MESSAGES: [[@LINE]]:7: warning: comparison between signed and unsigned char [bugprone-signed-char-misuse]
+return 1;
+  return 0;
+}
+
+int CompareWithUnsignedNonAsciiConstant(signed char SCharacter) {
+  const unsigned char USCharacter = 128;
+  if (USCharacter == SCharacter) // CHECK-MESSAGES: [[@LINE]]:7: warning: comparison between signed and unsigned char [bugprone-signed-char-misuse]
+return 1;
+  return 0;
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -121,3 +149,61 @@
 
   return USCharacter;
 }
+
+int FixComparisonWithSignedCharCast(signed char SCharacter) {
+  unsigned char USCharacter = 'a';
+  if (SCharacter == static_cast(USCharacter)) // no warning
+return 1;
+  return 0;
+}
+
+int FixComparisonWithUnSignedCharCast(signed char SCharacter) {
+  unsigned char USCharacter = 'a';
+  if (static_cast(SCharacter) == USCharacter) // no warning
+return 1;
+  return 0;
+}
+
+// Make sure we don't catch other type of char comparison.
+int SameCharTypeComparison(signed char SCharacter) {
+  signed char SCharacter2 = 'a';
+  if (SCharacter == SCharacter2) // no warning
+return 1;
+  return 0;
+}
+
+// Make sure we don't catch other type of char comparison.
+int SameCharTypeComparison2(unsigned char USCharacter) {
+  unsigned char USCharacter2 = 'a';
+  if (USCharacter == USCharacter2) // no warning
+return 1;
+  return 0;
+}
+
+// Make sure we don't catch integer - char comparison.
+int CharIntComparison(signed char SCharacter) {
+  int ICharacter = 10;
+  if (SCharacter == ICharacter) // no warning
+return 1;
+  return 0;
+}
+
+int CompareWithAsciiLiteral(unsigned char USCharacter) {
+  if (USCharacter == 'x') // no warning
+return 1;
+  return 0;
+}
+
+int CompareWithAsciiConstant(unsigned char USCharacter) {
+  const signed char SCharacter = 'a';
+  if (USCharacter == SCharacter) // no warning
+return 1;
+  return 0;
+}
+
+int CompareWithUnsignedAsciiConstant(signed char SCharacter) {
+  const unsigned char USCharacter = 'a';
+  if (USCharacter == SCharacter) // no warning
+return 1;
+  return 0;
+}
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
@@ -3,27 +3,38 @@
 bugprone-signed-char-misuse
 ===
 
-Finds ``signed char`` -> 

[PATCH] D75749: [clang-tidy] extend bugprone-signed-char-misuse check.

2020-03-06 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

I run the check on LLVM code and found only one catch of suspicious comparison:

  clang-tidy -p=/home/zolnai/clang/build 
/home/zolnai/clang/llvm-project/clang/lib/Lex/Lexer.cpp
  /home/zolnai/clang/llvm-project/clang/lib/Lex/Lexer.cpp:1293:39: warning: 
comparison between signed and unsigned char [bugprone-signed-char-misuse]
if ((C == '\n' || C == '\r') && C != PrevC)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75749



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


[PATCH] D75700: [NFC] Let mangler accept GlobalDecl

2020-03-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1028
 else
-  MC.mangleName(ND, Out);
+  MC.mangleName(GD, Out);
   } else {

rjmccall wrote:
> What would be necessary in order for this to turn into just `mangleName(GD, 
> Out)`?   I suspect there are a lot of subtle assumptions between the 
> different mangling methods today that could probably be broken down a bit and 
> we'd end up with something much cleaner.
It seems to be just API changes. I will try changing them.


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

https://reviews.llvm.org/D75700



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


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

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

In D75356#1909610 , @balazske wrote:

> The D75682  is the one that should be used 
> now,


If this patch is supposed to be a followup to D75682 
, could you please mark it as such? I find 
these revisions difficult to navigate.

> I have "mirrored" all 3 changes in this stack to the new series in D75682 
> . Probably it is possible to reuse these 
> revisions instead but I do not know if it will not confuse phabricator 
> somehow (and how  phabricator behaves in such "tricky" cases, there is not a 
> usable documentation for it).

Since this is the patch where we held the discussion about error states, I 
think it would be better for this revision land first, that would also solve 
the problem of inlines being all over the place. It doesn't really matter 
whether we're introducing error states first through `feof` and `ferror`, or 
the admittedly quirky `fseek`. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75356



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


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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75356



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


[PATCH] D75745: [clang-tidy] Added AllowMissingMoveFunctionsWhenCopyIsDeleted flag to cppcoreguidelines-special-member-functions

2020-03-06 Thread Paweł Barań via Phabricator via cfe-commits
pbaran updated this revision to Diff 248729.
pbaran added a comment.
Herald added a subscriber: wuzish.

Removed unintendedly added comment


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

https://reviews.llvm.org/D75745

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp
@@ -0,0 +1,49 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t -- -config="{CheckOptions: [{key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted, value: 1}]}" --
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+  DefinesEverything(DefinesEverything &&);
+  DefinesEverything =(const DefinesEverything &);
+  DefinesEverything =(DefinesEverything &&);
+  ~DefinesEverything();
+};
+
+class DefinesNothing {
+};
+
+class DeletedCopyCtorAndOperator {
+  ~DeletedCopyCtorAndOperator() = default;
+  DeletedCopyCtorAndOperator(const DeletedCopyCtorAndOperator &) = delete;
+  DeletedCopyCtorAndOperator =(const DeletedCopyCtorAndOperator &) = delete;
+};
+
+// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'DefaultedCopyCtorAndOperator' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+class DefaultedCopyCtorAndOperator {
+  ~DefaultedCopyCtorAndOperator() = default;
+  DefaultedCopyCtorAndOperator(const DefaultedCopyCtorAndOperator &) = default;
+  DefaultedCopyCtorAndOperator =(const DefaultedCopyCtorAndOperator &) = default;
+};
+
+// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'DefinedCopyCtorAndOperator' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+class DefinedCopyCtorAndOperator {
+  ~DefinedCopyCtorAndOperator() = default;
+  DefinedCopyCtorAndOperator(const DefinedCopyCtorAndOperator &);
+  DefinedCopyCtorAndOperator =(const DefinedCopyCtorAndOperator &);
+};
+
+// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'MissingCopyCtor' defines a default destructor and a copy assignment operator but does not define a copy constructor, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+class MissingCopyCtor {
+  ~MissingCopyCtor() = default;
+  MissingCopyCtor =(const MissingCopyCtor &) = delete;
+};
+
+// CHECK-MESSAGES: [[@LINE+1]]:7:  warning: class 'MissingCopyOperator' defines a default destructor and a copy constructor but does not define a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+class MissingCopyOperator {
+  ~MissingCopyOperator() = default;
+  MissingCopyOperator(const MissingCopyOperator &) = delete;
+};
+
+// CHECK-MESSAGES: [[@LINE+1]]:7:  warning: class 'MissingAll' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+class MissingAll {
+  ~MissingAll() = default;
+};
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
@@ -46,4 +46,19 @@
A(const A&);
A& operator=(const A&);
~A();
- }
+ };
+
+.. option:: AllowMissingMoveFunctionsWhenCopyIsDeleted
+
+   When set to `1` (default is `0`), this check doesn't flag classes which define deleted copy
+   operations but don't define move operations. This flags is related to Google C++ Style Guide
+   https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types. With this option enabled, the 
+   following class won't be flagged:
+   
+   .. code-block:: c++
+   
+ struct A {
+   A(const A&) = delete;
+   A& operator=(const A&) = delete;
+   ~A();
+ };
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
===

[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-03-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: aaron.ballman, rjmccall, erik.pilkington, 
MadCoder.
aaron.ballman added a comment.
Herald added a subscriber: dexonsmith.

Adding some more knowledgeable reviewers for comments on your RFC. I pointed 
out a few minor nits, but I'll hold off on a technical review until the 
ObjC-specific details are worked out and there is buy-in on the feature.




Comment at: clang/include/clang/AST/DeclObjC.h:2197
 
+  /// True if the protocol is tagged as objc_static_protocol
+  bool isStaticProtocol() const;

Comments should be properly punctuated (missing a full stop at the end of the 
sentence), here and elsewhere.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2609
+ const ParsedAttr ) {
+  if (S.getLangOpts().ObjCRuntime.allowsStaticProtocols()) {
+handleSimpleAttribute(S, D, AL);

This should be implemented via a custom `LangOpt` in `Attr.td`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574



___
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-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

You seem to have uploaded the wrong diff :)

In D75171#1908259 , 
@baloghadamsoftware wrote:

> This is the so called "correct" solution. However, it does not even compile 
> because `getAnalyzerOptions()` and `getASTContext()` are non-const functions 
> of `CheckerManager`, but `shouldRegister`//XXX//`()` functions get it as 
> const reference.


That doesn't sound too drastic, why don't you make those methods const?

> Even if I use `const_cast` (not in this patch, just for testing) it does not 
> work, it does not prevent the crash: when trying to register 
> `IteratorModeling` which depends on `ContainerModeling` both checkers are 
> registered after `shouldRegisterContainerModeling()` function returning false.

Huh, that sounds interesting. I just tried it locally and it works like a 
charm. Would you mind me commandeering this patch to demonstrate?


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


  1   2   >