[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders created this revision.
wanders added reviewers: MyDeveloperDay, klimek.
wanders added a project: clang-format.
Herald added a project: clang.

  

  This new option allows controlling if there should be spaces around
  the ':' in a bitfield declaration.
  
  Decides if it should be the existing (and therefore default with the
  new option) behavior:
  
unsigned bitfield : 5;   // SpaceAroundBitFieldColon = true
  
  or:
  
unsigned bitfield:5; // SpaceAroundBitFieldColon = false





A bit unsure about naming of the option.   Should there be separate 
Before/After?   I guess some might find `uint x :1` and `uint x: 1` useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84090

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2165,6 +2165,13 @@
"  uchar : 8;\n"
"  uchar other;\n"
"};");
+  FormatStyle LLVMWithNoSpaceAroundBitfields = getLLVMStyle();
+  LLVMWithNoSpaceAroundBitfields.SpaceAroundBitFieldColon = false;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass:8;\n"
+   "  unsigned ValueKind:2;\n"
+   "  uchar other;\n"
+   "};", LLVMWithNoSpaceAroundBitfields);
 }
 
 TEST_F(FormatTest, FormatsNamespaces) {
@@ -12156,6 +12163,11 @@
"int   oneTwoThree : 23 = 0;",
Alignment);
 
+  Alignment.SpaceAroundBitFieldColon = false;
+  verifyFormat("int const a  :5;\n"
+   "int   oneTwoThree:23;",
+   Alignment);
+
   // Known limitations: ':' is only recognized as a bitfield colon when
   // followed by a number.
   /*
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3251,6 +3251,8 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Left.is(TT_BitFieldColon))
+return Style.SpaceAroundBitFieldColon;
   if (Right.is(tok::colon)) {
 if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
 !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
@@ -3267,6 +3269,8 @@
   return false;
 if (Right.is(TT_CSharpNamedArgumentColon))
   return false;
+if (Right.is(TT_BitFieldColon))
+  return Style.SpaceAroundBitFieldColon;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -593,6 +593,8 @@
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
 IO.mapOptional("SpaceBeforeSquareBrackets",
Style.SpaceBeforeSquareBrackets);
+IO.mapOptional("SpaceAroundBitFieldColon",
+   Style.SpaceAroundBitFieldColon);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("StatementMacros", Style.StatementMacros);
 IO.mapOptional("TabWidth", Style.TabWidth);
@@ -918,6 +920,7 @@
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeSquareBrackets = false;
+  LLVMStyle.SpaceAroundBitFieldColon = true;
   LLVMStyle.SpacesInAngles = false;
   LLVMStyle.SpacesInConditionalStatement = false;
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2228,6 +2228,13 @@
   /// \endcode
   bool SpaceBeforeSquareBrackets;
 
+  /// If ``false``, space will be removed around ``:`` in bitfield 
declarations.
+  /// \code
+  ///true:  false:
+  ///unsigned bf : 3;  vs.  unsigned bf:3;
+  /// \endcode
+  bool SpaceAroundBitFieldColon;
+
   /// Supported language standards for parsing and formatting C++ constructs.
   /// \code
   ///Latest:vector>
@@ -2404,6 +2411,7 @@
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
+   SpaceAroundBitFieldColon == R.SpaceAroundBitFieldColon &&
Standard == R.Standard && TabWidth == R.TabWidth &&
StatementMacros == R.StatementMacros && UseTab == R.UseTab &&
UseCRLF == R.UseCRLF && TypenameMacros == R.TypenameMacros;


Index: clang/unittests/Format/FormatTest.cpp
==

[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

please clang-format




Comment at: clang/include/clang/Format/Format.h:2236
+  /// \endcode
+  bool SpaceAroundBitFieldColon;
+

We need to regenerate the ClangFormatStyleOptions.rst from this change

run clang/docs/tool/dump_format_style.py

Please add a release note too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090



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


[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In principle, this looks ok.




Comment at: clang/unittests/Format/FormatTest.cpp:12163
"int   oneTwoThree : 23 = 0;",
Alignment);

you are missing a CHECK_PARSE_BOOL test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D81031#2159943 , @jdoerfert wrote:

> In D81031#2159895 , @jhuber6 wrote:
>
> > Fixing errors caused by unused attribute sets. Adding missing attributes to 
> > barrier_codegen.cpp.
> >
> > Should I go ahead and commit this considering the previous was temporarily 
> > reverted? Or should I just wait a bit to see if it fails testing again.
>
>
> If you only did minor modifications and no major problem showed up, the 
> previous LGTM still stands. You should (always) run a full make check-all 
> locally (or better on a server) to verify no other issues are known.
>
> FWIW, it happens that we break bots and patches get reverted. That is not 
> great but also not too bad.


I did run a check-all but apparently the last build I did didn't build clang 
for some reason so it wasn't included in the tests. I ran cmake again with the 
same options and it seemed to build clang this time so I don't know what that 
was about.

After that I ran the tests again and I passed everything except these four. I 
reverted my commit and pulled from master and still failed the same test so I'm 
assuming it's a problem with my CUDA installation rather than the patch.

  libomp :: env/kmp_set_dispatch_buf.c
  libomp :: worksharing/for/kmp_set_dispatch_buf.c
  libomptarget :: mapping/declare_mapper_target_update.cpp
  libomptarget :: offloading/target_depend_nowait.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

you need to make a full contextdiff   git diff -U 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-18 Thread Gui Andrade via Phabricator via cfe-commits
guiand closed this revision.
guiand added a comment.

Merged in https://reviews.llvm.org/rG780528d9da707b15849d6c9711cc3ab19f6c7f00


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert resigned from this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

My concerns have been addressed. I am not the right one to look at the clang 
changes but what we merged into LLVM was really useful, thanks again for 
working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-18 Thread Gui Andrade via Phabricator via cfe-commits
guiand reopened this revision.
guiand added a comment.
This revision is now accepted and ready to land.

Sorry, closed this mistakenly!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

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

I hope you don't mind if I bring up a point you mentioned during a daily 
meeting.

> The error checking shouldn't be present on one of execution, but rather on 
> all of them.

I think your recent comment highlights why that wouldn't be sufficient, 
unfortunately. Also, the else branch will have be accounted for, good forward 
thinking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-07-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 279000.
yaxunl added a comment.
Herald added subscribers: llvm-commits, dang, hiraditya.
Herald added a project: LLVM.

rebase and added more checks.

The documentation work is still under development.


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

https://reviews.llvm.org/D60620

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/TargetID.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/TargetID.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenCUDA/target-id.hip
  clang/test/CodeGenOpenCL/target-id.cl
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_908.bc
  clang/test/Driver/amdgpu-features.c
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Driver/hip-invalid-target-id.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/invalid-target-id.cl
  clang/test/Driver/target-id-macros.cl
  clang/test/Driver/target-id-macros.hip
  clang/test/Driver/target-id.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -83,26 +83,26 @@
   {{"mullins"},   {"gfx703"},  GK_GFX703,  FEATURE_NONE},
   {{"gfx704"},{"gfx704"},  GK_GFX704,  FEATURE_NONE},
   {{"bonaire"},   {"gfx704"},  GK_GFX704,  FEATURE_NONE},
-  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}

[PATCH] D84103: [clang-format] Make sure rst documentation matches comments

2020-07-18 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders created this revision.
wanders added reviewers: MyDeveloperDay, JakeMerdichAMD.
wanders added a project: clang-format.
Herald added a project: clang.

  clang/docs/tools/dump_format_style.py is used to read the comments
  from clang/include/clang/Format/Format.h and update the contents of
  clang/docs/ClangFormatStyleOptions.rst
  
  Recent changes made these out of date. This commit syncs them by
  folding the improved wording back to the comments and then
  regenerating the rst file.

https://github.com/wanders/llvm-project/commit/148dd6d805a3429fef4973a5fb0a217b2ffeda32


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84103

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1425,15 +1425,20 @@
   /// For example: TESTSUITE
   std::vector NamespaceMacros;
 
-  /// A vector of macros which are whitespace-sensitive and shouldn't be
-  /// touched.
+  /// A vector of macros which are whitespace-sensitive and should not
+  /// be touched.
   ///
   /// These are expected to be macros of the form:
   /// \code
   ///   STRINGIZE(...)
   /// \endcode
   ///
-  /// For example: STRINGIZE
+  /// In the .clang-format configuration file, this can be configured like:
+  /// \code{.yaml}
+  ///   WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+  /// \endcode
+  ///
+  /// For example: BOOST_PP_STRINGIZE
   std::vector WhitespaceSensitiveMacros;
 
   tooling::IncludeStyle IncludeStyle;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2694,8 +2694,11 @@
 Use tabs whenever we need to fill whitespace that spans at least from
 one tab stop to the next one.
 
+
+
 **WhitespaceSensitiveMacros** (``std::vector``)
-  A vector of macros which are whitespace-sensitive and should not be touched.
+  A vector of macros which are whitespace-sensitive and should not
+  be touched.
 
   These are expected to be macros of the form:
 
@@ -2709,9 +2712,7 @@
 
 WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
 
-  For example: BOOST_PP_STRINGIZE.
-
-
+  For example: BOOST_PP_STRINGIZE
 
 .. END_FORMAT_STYLE_OPTIONS
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1425,15 +1425,20 @@
   /// For example: TESTSUITE
   std::vector NamespaceMacros;
 
-  /// A vector of macros which are whitespace-sensitive and shouldn't be
-  /// touched.
+  /// A vector of macros which are whitespace-sensitive and should not
+  /// be touched.
   ///
   /// These are expected to be macros of the form:
   /// \code
   ///   STRINGIZE(...)
   /// \endcode
   ///
-  /// For example: STRINGIZE
+  /// In the .clang-format configuration file, this can be configured like:
+  /// \code{.yaml}
+  ///   WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+  /// \endcode
+  ///
+  /// For example: BOOST_PP_STRINGIZE
   std::vector WhitespaceSensitiveMacros;
 
   tooling::IncludeStyle IncludeStyle;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2694,8 +2694,11 @@
 Use tabs whenever we need to fill whitespace that spans at least from
 one tab stop to the next one.
 
+
+
 **WhitespaceSensitiveMacros** (``std::vector``)
-  A vector of macros which are whitespace-sensitive and should not be touched.
+  A vector of macros which are whitespace-sensitive and should not
+  be touched.
 
   These are expected to be macros of the form:
 
@@ -2709,9 +2712,7 @@
 
 WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
 
-  For example: BOOST_PP_STRINGIZE.
-
-
+  For example: BOOST_PP_STRINGIZE
 
 .. END_FORMAT_STYLE_OPTIONS
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84103: [clang-format] Make sure rst documentation matches comments

2020-07-18 Thread Anders Waldenborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d7ec54170f9: [clang-format] Make sure rst documentation 
matches comments (authored by wanders).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84103

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1425,15 +1425,20 @@
   /// For example: TESTSUITE
   std::vector NamespaceMacros;
 
-  /// A vector of macros which are whitespace-sensitive and shouldn't be
-  /// touched.
+  /// A vector of macros which are whitespace-sensitive and should not
+  /// be touched.
   ///
   /// These are expected to be macros of the form:
   /// \code
   ///   STRINGIZE(...)
   /// \endcode
   ///
-  /// For example: STRINGIZE
+  /// In the .clang-format configuration file, this can be configured like:
+  /// \code{.yaml}
+  ///   WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+  /// \endcode
+  ///
+  /// For example: BOOST_PP_STRINGIZE
   std::vector WhitespaceSensitiveMacros;
 
   tooling::IncludeStyle IncludeStyle;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2694,8 +2694,11 @@
 Use tabs whenever we need to fill whitespace that spans at least from
 one tab stop to the next one.
 
+
+
 **WhitespaceSensitiveMacros** (``std::vector``)
-  A vector of macros which are whitespace-sensitive and should not be touched.
+  A vector of macros which are whitespace-sensitive and should not
+  be touched.
 
   These are expected to be macros of the form:
 
@@ -2709,9 +2712,7 @@
 
 WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
 
-  For example: BOOST_PP_STRINGIZE.
-
-
+  For example: BOOST_PP_STRINGIZE
 
 .. END_FORMAT_STYLE_OPTIONS
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1425,15 +1425,20 @@
   /// For example: TESTSUITE
   std::vector NamespaceMacros;
 
-  /// A vector of macros which are whitespace-sensitive and shouldn't be
-  /// touched.
+  /// A vector of macros which are whitespace-sensitive and should not
+  /// be touched.
   ///
   /// These are expected to be macros of the form:
   /// \code
   ///   STRINGIZE(...)
   /// \endcode
   ///
-  /// For example: STRINGIZE
+  /// In the .clang-format configuration file, this can be configured like:
+  /// \code{.yaml}
+  ///   WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+  /// \endcode
+  ///
+  /// For example: BOOST_PP_STRINGIZE
   std::vector WhitespaceSensitiveMacros;
 
   tooling::IncludeStyle IncludeStyle;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2694,8 +2694,11 @@
 Use tabs whenever we need to fill whitespace that spans at least from
 one tab stop to the next one.
 
+
+
 **WhitespaceSensitiveMacros** (``std::vector``)
-  A vector of macros which are whitespace-sensitive and should not be touched.
+  A vector of macros which are whitespace-sensitive and should not
+  be touched.
 
   These are expected to be macros of the form:
 
@@ -2709,9 +2712,7 @@
 
 WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
 
-  For example: BOOST_PP_STRINGIZE.
-
-
+  For example: BOOST_PP_STRINGIZE
 
 .. END_FORMAT_STYLE_OPTIONS
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6d7ec54 - [clang-format] Make sure rst documentation matches comments

2020-07-18 Thread Anders Waldenborg via cfe-commits

Author: Anders Waldenborg
Date: 2020-07-18T18:02:14+02:00
New Revision: 6d7ec54170f9ef68710f484299caa1a6dd42ff48

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

LOG: [clang-format] Make sure rst documentation matches comments

clang/docs/tools/dump_format_style.py is used to read the comments
from clang/include/clang/Format/Format.h and update the contents of
clang/docs/ClangFormatStyleOptions.rst

Recent changes made these out of date. This commit syncs them by
folding the improved wording back to the comments and then
regenerating the rst file.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index e84676760c30..6647b117ac59 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2694,8 +2694,11 @@ the configuration (without a prefix: ``Auto``).
 Use tabs whenever we need to fill whitespace that spans at least from
 one tab stop to the next one.
 
+
+
 **WhitespaceSensitiveMacros** (``std::vector``)
-  A vector of macros which are whitespace-sensitive and should not be touched.
+  A vector of macros which are whitespace-sensitive and should not
+  be touched.
 
   These are expected to be macros of the form:
 
@@ -2709,9 +2712,7 @@ the configuration (without a prefix: ``Auto``).
 
 WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
 
-  For example: BOOST_PP_STRINGIZE.
-
-
+  For example: BOOST_PP_STRINGIZE
 
 .. END_FORMAT_STYLE_OPTIONS
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3549ec9eee0e..7201c11f1158 100755
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1425,15 +1425,20 @@ struct FormatStyle {
   /// For example: TESTSUITE
   std::vector NamespaceMacros;
 
-  /// A vector of macros which are whitespace-sensitive and shouldn't be
-  /// touched.
+  /// A vector of macros which are whitespace-sensitive and should not
+  /// be touched.
   ///
   /// These are expected to be macros of the form:
   /// \code
   ///   STRINGIZE(...)
   /// \endcode
   ///
-  /// For example: STRINGIZE
+  /// In the .clang-format configuration file, this can be configured like:
+  /// \code{.yaml}
+  ///   WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+  /// \endcode
+  ///
+  /// For example: BOOST_PP_STRINGIZE
   std::vector WhitespaceSensitiveMacros;
 
   tooling::IncludeStyle IncludeStyle;



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


[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders updated this revision to Diff 279010.
wanders added a comment.

- Regenerated rst
- Fixed clang format errors
- Added release note
- Added bool parsing test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2165,6 +2165,14 @@
"  uchar : 8;\n"
"  uchar other;\n"
"};");
+  FormatStyle LLVMWithNoSpaceAroundBitfields = getLLVMStyle();
+  LLVMWithNoSpaceAroundBitfields.SpaceAroundBitFieldColon = false;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass:8;\n"
+   "  unsigned ValueKind:2;\n"
+   "  uchar other;\n"
+   "};",
+   LLVMWithNoSpaceAroundBitfields);
 }
 
 TEST_F(FormatTest, FormatsNamespaces) {
@@ -12156,6 +12164,11 @@
"int   oneTwoThree : 23 = 0;",
Alignment);
 
+  Alignment.SpaceAroundBitFieldColon = false;
+  verifyFormat("int const a  :5;\n"
+   "int   oneTwoThree:23;",
+   Alignment);
+
   // Known limitations: ':' is only recognized as a bitfield colon when
   // followed by a number.
   /*
@@ -13685,6 +13698,7 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
+  CHECK_PARSE_BOOL(SpaceAroundBitFieldColon);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3251,6 +3251,8 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Left.is(TT_BitFieldColon))
+return Style.SpaceAroundBitFieldColon;
   if (Right.is(tok::colon)) {
 if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
 !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
@@ -3267,6 +3269,8 @@
   return false;
 if (Right.is(TT_CSharpNamedArgumentColon))
   return false;
+if (Right.is(TT_BitFieldColon))
+  return Style.SpaceAroundBitFieldColon;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -593,6 +593,7 @@
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
 IO.mapOptional("SpaceBeforeSquareBrackets",
Style.SpaceBeforeSquareBrackets);
+IO.mapOptional("SpaceAroundBitFieldColon", Style.SpaceAroundBitFieldColon);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("StatementMacros", Style.StatementMacros);
 IO.mapOptional("TabWidth", Style.TabWidth);
@@ -918,6 +919,7 @@
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeSquareBrackets = false;
+  LLVMStyle.SpaceAroundBitFieldColon = true;
   LLVMStyle.SpacesInAngles = false;
   LLVMStyle.SpacesInConditionalStatement = false;
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2233,6 +2233,13 @@
   /// \endcode
   bool SpaceBeforeSquareBrackets;
 
+  /// If ``true``, space will be inserted around ``:`` in bitfield declarations.
+  /// \code
+  ///true:  false:
+  ///unsigned bf : 3;  vs.  unsigned bf:3;
+  /// \endcode
+  bool SpaceAroundBitFieldColon;
+
   /// Supported language standards for parsing and formatting C++ constructs.
   /// \code
   ///Latest:vector>
@@ -2409,6 +2416,7 @@
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
+   SpaceAroundBitFieldColon == R.SpaceAroundBitFieldColon &&
Standard == R.Standard && TabWidth == R.TabWidth &&
StatementMacros == R.StatementMacros && UseTab == R.UseTab &&
UseCRLF == R.UseCRLF && TypenameMacros == R.TypenameMacros;
Index: clang/docs/ReleaseNotes.rst
===

[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

The changes look good to me in general. I share your doubt though about whether 
a book flag is sufficient here. We've seen in the past a few times that at some 
time a false/true flag is not enough. I'd rather go for a 
Before/After/Both/None flag (or similar, naming probably should be coherent 
with other flags). But I'm not really aware of the projects/coding styles that 
use bit fields. Maybe a small research on this would be good to confirm or 
infirm a necessity of higher complexity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090



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


[clang] 3bbbe4c - [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-18 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2020-07-18T12:55:50-04:00
New Revision: 3bbbe4c4b6c8e20538a388df164da6f8d935e0cc

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

LOG: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

Summary:
This patch adds more function attribute information to the runtime function 
definitions in OMPKinds.def. The goal is to provide sufficient information 
about OpenMP runtime functions to perform more optimizations on OpenMP code.

Reviewers: jdoerfert

Subscribers: aaron.ballman cfe-commits yaxunl guansong sstefan1 llvm-commits

Tags: #OpenMP #clang #LLVM

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

Added: 


Modified: 
clang/test/OpenMP/barrier_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/test/Transforms/OpenMP/add_attributes.ll
llvm/test/Transforms/OpenMP/parallel_deletion.ll

Removed: 




diff  --git a/clang/test/OpenMP/barrier_codegen.cpp 
b/clang/test/OpenMP/barrier_codegen.cpp
index f84a26380df9..35b2ed721276 100644
--- a/clang/test/OpenMP/barrier_codegen.cpp
+++ b/clang/test/OpenMP/barrier_codegen.cpp
@@ -46,7 +46,7 @@ int main(int argc, char **argv) {
 // IRBUILDER:  ; Function Attrs: nounwind
 // IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) 
#
 // IRBUILDER_OPT:  ; Function Attrs: inaccessiblememonly nofree nosync 
nounwind readonly
-// IRBUILDER_OPT-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) 
#
+// IRBUILDER_OPT-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t* 
nocapture nofree readonly) #
 
 // CHECK: define {{.+}} [[TMAIN_INT]](
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T]]* 
[[LOC]])

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 0dc2b34f2e4d..4f2fcb8af5d1 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -383,7 +383,8 @@ __OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, 
Int32, /* Int */ Int32)
 __OMP_RTL(__kmpc_serialized_parallel, false, Void, IdentPtr, Int32)
 __OMP_RTL(__kmpc_end_serialized_parallel, false, Void, IdentPtr, Int32)
 __OMP_RTL(__kmpc_omp_reg_task_with_affinity, false, Int32, IdentPtr, Int32,
-  Int8Ptr, Int32, Int8Ptr)
+  /* kmp_task_t */ VoidPtr, Int32,
+  /* kmp_task_affinity_info_t */ VoidPtr)
 
 __OMP_RTL(omp_get_thread_num, false, Int32, )
 __OMP_RTL(omp_get_num_threads, false, Int32, )
@@ -430,8 +431,7 @@ __OMP_RTL(__kmpc_reduce, false, Int32, IdentPtr, Int32, 
Int32, SizeTy, VoidPtr,
   ReduceFunctionPtr, KmpCriticalNamePtrTy)
 __OMP_RTL(__kmpc_reduce_nowait, false, Int32, IdentPtr, Int32, Int32, SizeTy,
   VoidPtr, ReduceFunctionPtr, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_end_reduce, false, Void, IdentPtr, Int32,
-  KmpCriticalNamePtrTy)
+__OMP_RTL(__kmpc_end_reduce, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)
 __OMP_RTL(__kmpc_end_reduce_nowait, false, Void, IdentPtr, Int32,
   KmpCriticalNamePtrTy)
 
@@ -514,10 +514,10 @@ __OMP_RTL(__kmpc_taskloop, false, Void, IdentPtr, /* Int 
*/ Int32, VoidPtr,
   /* Int */ Int32, Int64, VoidPtr)
 __OMP_RTL(__kmpc_omp_target_task_alloc, false, /* kmp_task_t */ VoidPtr,
   IdentPtr, Int32, Int32, SizeTy, SizeTy, TaskRoutineEntryPtr, Int64)
-__OMP_RTL(__kmpc_taskred_modifier_init, false, VoidPtr, IdentPtr,
-  /* Int */ Int32, /* Int */ Int32, /* Int */ Int32, VoidPtr)
-__OMP_RTL(__kmpc_taskred_init, false, VoidPtr, /* Int */ Int32,
-  /* Int */ Int32, VoidPtr)
+__OMP_RTL(__kmpc_taskred_modifier_init, false, /* kmp_taskgroup */ VoidPtr,
+  IdentPtr, /* Int */ Int32, /* Int */ Int32, /* Int */ Int32, VoidPtr)
+__OMP_RTL(__kmpc_taskred_init, false, /* kmp_taskgroup */ VoidPtr,
+  /* Int */ Int32, /* Int */ Int32, VoidPtr)
 __OMP_RTL(__kmpc_task_reduction_modifier_fini, false, Void, IdentPtr,
   /* Int */ Int32, /* Int */ Int32)
 __OMP_RTL(__kmpc_task_reduction_get_th_data, false, VoidPtr, Int32, VoidPtr,
@@ -594,7 +594,9 @@ __OMP_RTL(__last, false, Void, )
 #undef __OMP_RTL
 #undef OMP_RTL
 
+#define ParamAttrs(...) ArrayRef({__VA_ARGS__})
 #define EnumAttr(Kind) Attribute::get(Ctx, Attribute::AttrKind::Kind)
+#define EnumAttrInt(Kind, N) Attribute::get(Ctx, Attribute::AttrKind::Kind, N)
 #define AttributeSet(...)  
\
   AttributeSet::get(Ctx, ArrayRef({__VA_ARGS__}))
 
@@ -607,19 +609,94 @@ __OMP_RTL(__last, false, Void, )
 __OMP_ATTRS_SET(GetterAttrs,
 OptimisticAttributes
 ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(ReadOnly),
-   EnumAttr(NoS

[clang] 0b2a922 - [analyzer] scan-build: Fix silencing multiple core checkers.

2020-07-18 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-07-18T10:37:00-07:00
New Revision: 0b2a92224630f6e177d091b8391cfa943764aba5

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

LOG: [analyzer] scan-build: Fix silencing multiple core checkers.

It was only silencing one checker because -analyzer-config flags
can only carry one value at a time.

Added: 

clang/test/Analysis/scan-build/Inputs/null_dereference_and_division_by_zero.c
clang/test/Analysis/scan-build/silence-core-checkers.test

Modified: 
clang/tools/scan-build/bin/scan-build

Removed: 




diff  --git 
a/clang/test/Analysis/scan-build/Inputs/null_dereference_and_division_by_zero.c 
b/clang/test/Analysis/scan-build/Inputs/null_dereference_and_division_by_zero.c
new file mode 100644
index ..438af79c90bb
--- /dev/null
+++ 
b/clang/test/Analysis/scan-build/Inputs/null_dereference_and_division_by_zero.c
@@ -0,0 +1,8 @@
+int test(int x) {
+  if (x) {
+int *p = 0;
+return *p; // Null dereference.
+  } else {
+return 1 / x; // Division by zero.
+  }
+}

diff  --git a/clang/test/Analysis/scan-build/silence-core-checkers.test 
b/clang/test/Analysis/scan-build/silence-core-checkers.test
new file mode 100644
index ..6d9a3017fcd6
--- /dev/null
+++ b/clang/test/Analysis/scan-build/silence-core-checkers.test
@@ -0,0 +1,30 @@
+// FIXME: Actually, "perl".
+REQUIRES: shell
+
+RUN: rm -rf %t.output_dir && mkdir %t.output_dir
+RUN: %scan-build -o %t.output_dir \
+RUN:   %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
+RUN:   | FileCheck %s -check-prefix CHECK-TWO-BUGS
+
+RUN: rm -rf %t.output_dir && mkdir %t.output_dir
+RUN: %scan-build -o %t.output_dir \
+RUN:   -disable-checker core.DivideZero \
+RUN:   %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
+RUN:   | FileCheck %s -check-prefix CHECK-ONE-BUG
+
+RUN: rm -rf %t.output_dir && mkdir %t.output_dir
+RUN: %scan-build -o %t.output_dir \
+RUN:   -disable-checker core.NullDereference \
+RUN:   %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
+RUN:   | FileCheck %s -check-prefix CHECK-ONE-BUG
+
+RUN: rm -rf %t.output_dir && mkdir %t.output_dir
+RUN: %scan-build -o %t.output_dir \
+RUN:   -disable-checker core.NullDereference \
+RUN:   -disable-checker core.DivideZero \
+RUN:   %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
+RUN:   | FileCheck %s -check-prefix CHECK-NO-BUGS
+
+CHECK-NO-BUGS: scan-build: No bugs found.
+CHECK-ONE-BUG: scan-build: 1 bug found.
+CHECK-TWO-BUGS: scan-build: 2 bugs found.

diff  --git a/clang/tools/scan-build/bin/scan-build 
b/clang/tools/scan-build/bin/scan-build
index 11334a0b9626..aed8c417b6cc 100755
--- a/clang/tools/scan-build/bin/scan-build
+++ b/clang/tools/scan-build/bin/scan-build
@@ -1973,11 +1973,13 @@ my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun;
 my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } 
@{$Options{PluginsToLoad}};
 my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } 
@{$Options{ConfigOptions}};
 
-foreach (sort { $Options{SilenceCheckers}{$a} <=> 
$Options{SilenceCheckers}{$b} }
- keys %{$Options{SilenceCheckers}}) {
-  # Add checkers in order they were silenced.
+if (%{$Options{SilenceCheckers}}) {
   $CCC_ANALYZER_CONFIG =
-  $CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers=".$_;
+  $CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers="
+  .join(';', sort {
+$Options{SilenceCheckers}{$a} <=>
+$Options{SilenceCheckers}{$b}
+  } keys %{$Options{SilenceCheckers}});
 }
 
 my %EnvVars = (



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


[PATCH] D83551: [PATCH 2/4][Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

2020-07-18 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1541
 
+def ArmSveVectorBits128 : TypeAttr {
+  let Spellings = [];

aaron.ballman wrote:
> c-rhodes wrote:
> > aaron.ballman wrote:
> > > c-rhodes wrote:
> > > > c-rhodes wrote:
> > > > > aaron.ballman wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > c-rhodes wrote:
> > > > > > > > sdesmalen wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > sdesmalen wrote:
> > > > > > > > > > > nit: Can you add a comment saying why these are 
> > > > > > > > > > > undocumented (and have no spellings)
> > > > > > > > > > Also, I think these are all missing `let SemaHandler = 0;` 
> > > > > > > > > > and `let ASTNode = 0;`
> > > > > > > > > > 
> > > > > > > > > > Is there a reason why we need N different type attributes 
> > > > > > > > > > instead of having a single type attribute which encodes the 
> > > > > > > > > > N as an argument? I think this may simplify the patch 
> > > > > > > > > > somewhat as you no longer need to switch over N as much.
> > > > > > > > > > Is there a reason why we need N different type attributes 
> > > > > > > > > > instead of having a single type attribute which encodes the 
> > > > > > > > > > N as an argument?
> > > > > > > > > AIUI this was a workaround for getting the value of N from an 
> > > > > > > > > AttributedType, because this only has `getAttrKind` to return 
> > > > > > > > > the attribute kind, but no way to get the corresponding 
> > > > > > > > > argument/value. This seemed like a simple way to do that 
> > > > > > > > > without having to create a new subclass for Type and having 
> > > > > > > > > to support that in various places. Is the latter the approach 
> > > > > > > > > you were thinking of? (or is there perhaps a simpler way?)
> > > > > > > > > Also, I think these are all missing let SemaHandler = 0; and 
> > > > > > > > > let ASTNode = 0;
> > > > > > > > 
> > > > > > > > Good to know. In SemaType I'm doing `CurType = 
> > > > > > > > State.getAttributedType(A, CurType, CurType);` which gives an 
> > > > > > > > `AttributedType` in the AST, should I still set `let ASTNode = 
> > > > > > > > 0;` in this case?
> > > > > > > > 
> > > > > > > > > Is there a reason why we need N different type attributes 
> > > > > > > > > instead of having a single type attribute which encodes the N 
> > > > > > > > > as an argument?
> > > > > > > > 
> > > > > > > > As Sander mentioned, it seemed like the easiest solution, 
> > > > > > > > interested to know if there's a better approach however
> > > > > > > I was thinking specifically of creating a new `Type` subclass and 
> > > > > > > supporting it rather than adding 5 new attributes that only vary 
> > > > > > > by a bit-width (which means there's likely to be a 6th someday). 
> > > > > > > It's not immediately clear to me whether that's a really big ask 
> > > > > > > for little gain or not, though.
> > > > > > Ah, you're right, we may still need `ASTNode` to be kept around for 
> > > > > > that, good call.
> > > > > > Also, I think these are all missing let SemaHandler = 0; and let 
> > > > > > ASTNode = 0;
> > > > > 
> > > > > I've added `let SemaHandler = 0;` for the internal types and `let 
> > > > > ASTNode = 0;` for the user-facing attr.
> > > > > I was thinking specifically of creating a new Type subclass and 
> > > > > supporting it rather than adding 5 new attributes that only vary by a 
> > > > > bit-width (which means there's likely to be a 6th someday).
> > > > 
> > > > It would be nice if the `Attr` was accessible from the 
> > > > `AttributedType`, similar to how it is for `Decl`s, so something like:
> > > > ```  if (const auto *AT = T->getAs())
> > > > if (ArmSveVectorBitsAttr *Attr = AT->getAttr())
> > > >   unsigned Width = Attr->getNumBits();```
> > > > Although I'm not sure if that makes sense or how easy it is. I do agree 
> > > > adding 5 new attributes isn't ideal but for an initial implementation 
> > > > it's nice and simple. Would you be ok with us addressing this in a 
> > > > later patch?
> > > > It would be nice if the Attr was accessible from the AttributedType, 
> > > > similar to how it is for Decls, so something like:
> > > 
> > > You can do that through an `AttributedTypeLoc` object, which I think 
> > > should be available from the situations you need to check this through a 
> > > `TypeSourceInfo *` for the type. Then you can use 
> > > `AttributedTypeLoc::getAttr()` to get the semantic attribute.
> > > 
> > > > Would you be ok with us addressing this in a later patch?
> > > 
> > > No and yes. It's a novel design to have a user-facing attribute that is 
> > > never hooked up in the AST but is instead used to decide which 
> > > spellingless attribute to use instead, so I'd strongly prefer to find a 
> > > solution that doesn't use this approach. I also think we'll wind up with 
> > > cleaner code from this. That said, if it turns out to be awkward to do 
> > 

[clang] acf3bdc - [clang][NFC] Tests showing the problems with some uses of NamedDecl::getDeclName in diagnostics, SemaOverload.cpp+SemaStmt.cpp part

2020-07-18 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-18T20:44:06+01:00
New Revision: acf3bdc283ecf6e2c3a85a391a24becc4814b8b8

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

LOG: [clang][NFC] Tests showing the problems with some uses of 
NamedDecl::getDeclName in diagnostics, SemaOverload.cpp+SemaStmt.cpp part

Added: 
clang/test/Sema/return-non-void.c
clang/test/SemaCXX/consteval-return-void.cpp
clang/test/SemaCXX/return-void.cpp
clang/test/SemaObjC/method-return-void.m

Modified: 
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/return.cpp
clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
clang/test/SemaCXX/warn-pure-virtual-kext.cpp

Removed: 




diff  --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
index 59cac367dbf2..0d4d34ac0e14 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -7,6 +7,12 @@ void a2 [[noreturn]] () {
   return; // expected-warning {{function 'a2' declared 'noreturn' should not 
return}}
 }
 
+template  void a3 [[noreturn]] () {}
+template <> void a3 () { return; } // expected-warning {{function 'a3' 
declared 'noreturn' should not return}}
+
+template  void a4 [[noreturn]] () { return; } // expected-warning 
2{{function 'a4' declared 'noreturn' should not return}}
+void a4_test() { a4(); } // expected-note {{in instantiation of function 
template specialization 'a4' requested here}}
+
 [[noreturn, noreturn]] void b() { throw 0; } // expected-error {{attribute 
'noreturn' cannot appear multiple times in an attribute specifier}}
 [[noreturn]] [[noreturn]] void b2() { throw 0; } // ok
 

diff  --git a/clang/test/Sema/return-non-void.c 
b/clang/test/Sema/return-non-void.c
new file mode 100644
index ..f1ee3722af48
--- /dev/null
+++ b/clang/test/Sema/return-non-void.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -Wreturn-type -std=c99 -fsyntax-only -verify=c99 %s
+// RUN: %clang_cc1 -Wreturn-type -std=c90 -fsyntax-only -verify=c90 %s
+
+int foo(void) { return; } // c99-error {{non-void function 'foo' should return 
a value}}
+  // c90-error@-1 {{non-void function 'foo' should 
return a value}}

diff  --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp 
b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index b69bcb2fef9d..7ff260c37c69 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2167,6 +2167,11 @@ namespace PR21786 {
 namespace PR21859 {
   constexpr int Fun() { return; } // expected-error {{non-void constexpr 
function 'Fun' should return a value}}
   constexpr int Var = Fun();
+
+  template  constexpr int FunT1() { return; } // expected-error 
{{non-void constexpr function 'FunT1' should return a value}}
+  template  constexpr int FunT2() { return 0; }
+  template <> constexpr int FunT2() { return 0; }
+  template <> constexpr int FunT2() { return; } // expected-error 
{{non-void constexpr function 'FunT2' should return a value}}
 }
 
 struct InvalidRedef {

diff  --git a/clang/test/SemaCXX/consteval-return-void.cpp 
b/clang/test/SemaCXX/consteval-return-void.cpp
new file mode 100644
index ..a5207f41bf2c
--- /dev/null
+++ b/clang/test/SemaCXX/consteval-return-void.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+consteval int Fun() { return; } // expected-error {{non-void constexpr 
function 'Fun' should return a value}}
+
+// FIXME: The diagnostic is wrong; should be "consteval".
+
+template  consteval int FunT1() { return; } // expected-error 
{{non-void constexpr function 'FunT1' should return a value}}
+template  consteval int FunT2() { return 0; }
+template <> consteval int FunT2() { return 0; }
+template <> consteval int FunT2() { return; } // expected-error 
{{non-void constexpr function 'FunT2' should return a value}}

diff  --git a/clang/test/SemaCXX/return-void.cpp 
b/clang/test/SemaCXX/return-void.cpp
new file mode 100644
index ..b3aa203133dc
--- /dev/null
+++ b/clang/test/SemaCXX/return-void.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify
+
+void f1() { return {1,2}; } // expected-error {{void function 'f1' must not 
return a value}}
+
+template  void f2() { return {1,2}; } // expected-error {{void 
function 'f2' must not return a value}}
+
+template <> void f2() { return {1,2}; } // expected-error {{void 
function 'f2' must not return a value}}
+
+void test_f2() {
+  f2();
+  f2();
+}
+
+struct S {
+  void f3() { return {1,2}; } // expected-error {{void function 'f3' must not 
return a value}}
+  S() 

[PATCH] D83681: [clang] Provide a more specific diagnostic for a misplaced lambda capture-default.

2020-07-18 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32db24a7f242: [clang] Provide a more specific diagnostic for 
a misplaced lambda capture… (authored by riccibruno).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83681

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/lambda-misplaced-capture-default.cpp


Index: clang/test/Parser/lambda-misplaced-capture-default.cpp
===
--- /dev/null
+++ clang/test/Parser/lambda-misplaced-capture-default.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -fsyntax-only -verify %s
+
+namespace misplaced_capture_default {
+void Test() {
+  int i = 0;
+  [&, i, &] {};   // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+  [&, i, = ] {};  // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+  [=, &i, &] {};  // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+  [=, &i, = ] {}; // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+
+  [i, &] {};   // expected-error {{capture default must be first}}
+  [i, = ] {};  // expected-error {{capture default must be first}}
+  [i, = x] {}; // expected-error {{expected variable name or 'this' in lambda 
capture list}}
+  [=, &i] {};  // ok
+  [&, &i] {};  // expected-error {{'&' cannot precede a capture when the 
capture default is '&'}}
+  [&x = i] {}; // ok
+  [=, &x = i] {};  // ok
+  [x = &i] {}; // ok
+  [=, &x = &i] {}; // expected-error {{non-const lvalue reference to type 'int 
*' cannot bind to a temporary of type 'int *'}}
+  [&, this] {}; // expected-error {{'this' cannot be captured in this context}}
+
+  [i, &, x = 2] {}; // expected-error {{capture default must be first}}
+  [i, =, x = 2] {}; // expected-error {{capture default must be first}}
+}
+} // namespace misplaced_capture_default
+
+namespace misplaced_capture_default_pack {
+template  void Test(Args... args) {
+  [&, args...] {}; // ok
+  [args..., &] {}; // expected-error {{capture default must be first}}
+  [=, &args...] {};// ok
+  [&, ... xs = &args] {};  // ok
+  [&, ... xs = &] {};  // expected-error {{expected expression}}
+  [... xs = &] {}; // expected-error {{expected expression}}
+  [... xs = &args, = ] {}; // expected-error {{capture default must be first}}
+  [... xs = &args, &] {};  // expected-error {{capture default must be first}}
+}
+} // namespace misplaced_capture_default_pack
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -926,6 +926,15 @@
 } else if (Tok.is(tok::kw_this)) {
   Kind = LCK_This;
   Loc = ConsumeToken();
+} else if (Tok.isOneOf(tok::amp, tok::equal) &&
+   NextToken().isOneOf(tok::comma, tok::r_square) &&
+   Intro.Default == LCD_None) {
+  // We have a lone "&" or "=" which is either a misplaced capture-default
+  // or the start of a capture (in the "&" case) with the rest of the
+  // capture missing. Both are an error but a misplaced capture-default
+  // is more likely if we don't already have a capture default.
+  return Invalid(
+  [&] { Diag(Tok.getLocation(), diag::err_capture_default_first); });
 } else {
   TryConsumeToken(tok::ellipsis, EllipsisLocs[0]);
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -934,6 +934,8 @@
   "the name of the capture">;
 def err_lambda_capture_multiple_ellipses : Error<
   "multiple ellipses in pack capture">;
+def err_capture_default_first : Error<
+  "capture default must be first">;
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;


Index: clang/test/Parser/lambda-misplaced-capture-default.cpp
===
--- /dev/null
+++ clang/test/Parser/lambda-misplaced-capture-default.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -fsyntax-only -verify %s
+
+namespace misplaced_capture_default {
+void Test() {
+  int i = 0;
+  [&, i, &] {};   // expected-error {{expected variable name or 'this' in lambda capture list}}
+  [&, i, = ] {};  // expected-error {{expected variable name or 'this' in lambda capture list}}
+  [=, &i, &] {};  // expected-error {{expected variable name or 'this' in lambda capture list}}
+  [=, &i, = ] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
+
+  [i, &] {};   /

[clang] be8e5fe - [clang][NFC] Tests showing the problems with some uses of NamedDecl::getDeclName in diagnostics, SemaExpr.cpp part

2020-07-18 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-18T20:39:16+01:00
New Revision: be8e5fee91b44522056f1e780cdc861427f8738f

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

LOG: [clang][NFC] Tests showing the problems with some uses of 
NamedDecl::getDeclName in diagnostics, SemaExpr.cpp part

Added: 


Modified: 
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
clang/test/SemaCXX/attr-unused.cpp
clang/test/SemaCXX/default2.cpp
clang/test/SemaCXX/incomplete-call.cpp
clang/test/SemaCXX/lambda-expressions.cpp

Removed: 




diff  --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp 
b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
index af2e7cf09ceb..52986faa4e85 100644
--- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
 
 void h() {
   int i1 = 0;
@@ -16,4 +16,16 @@ void h() {
   const int i4 = 0;
   extern void h4(int x = sizeof(i4)); // ok, not odr-use
   extern void h5(int x = decltype(i4 + 4)()); // ok, not odr-use
+
+  union {
+int i5;
+  };
+
+  extern void h6(int = i5);
+  // expected-error@-1 {{default argument references local variable '' of 
enclosing function}}
+
+  struct S { int i; };
+  auto [x] = S();
+
+  extern void h7(int = x); // FIXME: reject
 }

diff  --git a/clang/test/SemaCXX/attr-unused.cpp 
b/clang/test/SemaCXX/attr-unused.cpp
index b74bc915ce07..e3878152eca9 100644
--- a/clang/test/SemaCXX/attr-unused.cpp
+++ b/clang/test/SemaCXX/attr-unused.cpp
@@ -3,7 +3,17 @@
 namespace ns_unused { typedef int Int_unused __attribute__((unused)); }
 namespace ns_not_unused { typedef int Int_not_unused; }
 
+template  class C;
+template <> class __attribute__((unused)) C {};
+
 void f() {
   ns_not_unused::Int_not_unused i1; // expected-warning {{unused variable}}
   ns_unused::Int_unused i0; // expected-warning {{'Int_unused' was marked 
unused but was used}}
+
+  union __attribute__((unused)) { // expected-warning {{'' was marked unused 
but was used}}
+int i;
+  };
+  (void) i;
+
+  C(); // expected-warning {{'C' was marked unused but was used}}
 }

diff  --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp
index 4c8e8ce6941a..7651233f8636 100644
--- a/clang/test/SemaCXX/default2.cpp
+++ b/clang/test/SemaCXX/default2.cpp
@@ -117,6 +117,12 @@ class C2 {
   static int f(int = 10); // expected-note{{default argument declared here}}
 };
 
+template  class C3;
+template <> class C3 {
+  static void g(int = f()); // expected-error {{use of default argument to 
function 'f' that is declared later in class 'C3'}}
+  static int f(int = 10); // expected-note {{default argument declared here}}
+};
+
 // Make sure we actually parse the default argument for an inline definition
 class XX {
   void A(int length = -1 ) {  } 

diff  --git a/clang/test/SemaCXX/incomplete-call.cpp 
b/clang/test/SemaCXX/incomplete-call.cpp
index 0fb1ef5f07a5..46f470e4a881 100644
--- a/clang/test/SemaCXX/incomplete-call.cpp
+++ b/clang/test/SemaCXX/incomplete-call.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-struct A; // expected-note 14 {{forward declaration of 'A'}}
+struct A; // expected-note 15 {{forward declaration of 'A'}}
 
 A f(); // expected-note {{'f' declared here}}
+template  A ft(T); // expected-note {{'ft' declared here}}
 
 struct B {
   A f(); // expected-note {{'f' declared here}}
@@ -38,7 +39,8 @@ void g() {
   
   A (B::*mfp)() = 0;
   (b.*mfp)(); // expected-error {{calling function with incomplete return type 
'A'}}
-  
+
+  ft(42); // expected-error {{calling 'ft' with incomplete return type 'A'}}
 }
 
 

diff  --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 3240d5351fc5..7f7f9c570487 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -649,3 +649,14 @@ void Run(const int& points) {
 void operator_parens() {
   [&](int x){ operator()(); }(0); // expected-error {{undeclared 'operator()'}}
 }
+
+namespace captured_name {
+void Test() {
+  union {   // expected-note {{'' declared here}}
+int i;
+  };
+  [] { return i; }; // expected-error {{variable '' cannot be implicitly 
captured in a lambda with no capture-default specified}}
+// expected-note@-1 {{lambda expression begins here}}
+
+}
+};



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


[clang] 32db24a - [clang] Provide a more specific diagnostic for a misplaced lambda capture-default.

2020-07-18 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-18T20:35:16+01:00
New Revision: 32db24a7f24236d78beaeb5cfd96b115d67a5c21

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

LOG: [clang] Provide a more specific diagnostic for a misplaced lambda 
capture-default.

Currently a capture-default which is not the first element in the lambda-capture
is diagnosed with a generic expected variable name or 'this' in lambda capture
list, which is true but not very helpful.

If we don't have already parsed a capture-default then a lone "&" or "=" is
likely to be a misplaced capture-default, so diagnose it as such.

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

Reviewed By: aaron.ballman

Added: 
clang/test/Parser/lambda-misplaced-capture-default.cpp

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExprCXX.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 1038a4119d4c..a10191e91be3 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -934,6 +934,8 @@ def err_lambda_capture_misplaced_ellipsis : Error<
   "the name of the capture">;
 def err_lambda_capture_multiple_ellipses : Error<
   "multiple ellipses in pack capture">;
+def err_capture_default_first : Error<
+  "capture default must be first">;
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;

diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index aa35200c33b6..b225bb7c8b36 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -926,6 +926,15 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
 } else if (Tok.is(tok::kw_this)) {
   Kind = LCK_This;
   Loc = ConsumeToken();
+} else if (Tok.isOneOf(tok::amp, tok::equal) &&
+   NextToken().isOneOf(tok::comma, tok::r_square) &&
+   Intro.Default == LCD_None) {
+  // We have a lone "&" or "=" which is either a misplaced capture-default
+  // or the start of a capture (in the "&" case) with the rest of the
+  // capture missing. Both are an error but a misplaced capture-default
+  // is more likely if we don't already have a capture default.
+  return Invalid(
+  [&] { Diag(Tok.getLocation(), diag::err_capture_default_first); });
 } else {
   TryConsumeToken(tok::ellipsis, EllipsisLocs[0]);
 

diff  --git a/clang/test/Parser/lambda-misplaced-capture-default.cpp 
b/clang/test/Parser/lambda-misplaced-capture-default.cpp
new file mode 100644
index ..d65b875102da
--- /dev/null
+++ b/clang/test/Parser/lambda-misplaced-capture-default.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -fsyntax-only -verify %s
+
+namespace misplaced_capture_default {
+void Test() {
+  int i = 0;
+  [&, i, &] {};   // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+  [&, i, = ] {};  // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+  [=, &i, &] {};  // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+  [=, &i, = ] {}; // expected-error {{expected variable name or 'this' in 
lambda capture list}}
+
+  [i, &] {};   // expected-error {{capture default must be first}}
+  [i, = ] {};  // expected-error {{capture default must be first}}
+  [i, = x] {}; // expected-error {{expected variable name or 'this' in lambda 
capture list}}
+  [=, &i] {};  // ok
+  [&, &i] {};  // expected-error {{'&' cannot precede a capture when the 
capture default is '&'}}
+  [&x = i] {}; // ok
+  [=, &x = i] {};  // ok
+  [x = &i] {}; // ok
+  [=, &x = &i] {}; // expected-error {{non-const lvalue reference to type 'int 
*' cannot bind to a temporary of type 'int *'}}
+  [&, this] {}; // expected-error {{'this' cannot be captured in this context}}
+
+  [i, &, x = 2] {}; // expected-error {{capture default must be first}}
+  [i, =, x = 2] {}; // expected-error {{capture default must be first}}
+}
+} // namespace misplaced_capture_default
+
+namespace misplaced_capture_default_pack {
+template  void Test(Args... args) {
+  [&, args...] {}; // ok
+  [args..., &] {}; // expected-error {{capture default must be first}}
+  [=, &args...] {};// ok
+  [&, ... xs = &args] {};  // ok
+  [&, ... xs = &] {};  // expected-error {{expected expression}}
+  [... xs = &] {}; // expected-error {{expected expression}}
+  [... xs = &args, = ] {}; // expected-error {{capture default must be first}}
+  [... xs = &args, &] {};  // expected-error {{capture default must be first}}
+}
+} // namespa

[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

2020-07-18 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In addition to Aaron's suggestion, can you also change the diff's title to 
something a little bit more informative. Suggestion: "[clang] Handle 128-bits 
IntegerLiterals in StmtPrinter", and say in the description that this addresses 
PR35677.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82880



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


[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-18 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders marked an inline comment as done.
wanders added a comment.

In D84090#2160411 , @curdeius wrote:

> The changes look good to me in general. I share your doubt though about 
> whether a bool flag is sufficient here. We've seen in the past a few times 
> that at some time a false/true flag is not enough. I'd rather go for a 
> Before/After/Both/None flag (or similar, naming probably should be coherent 
> with other flags). But I'm not really aware of the projects/coding styles 
> that use bit fields. Maybe a small research on this would be good to confirm 
> or infirm a necessity of higher complexity.


Did some basic research in repos I happened to have.

Here I call the different styles:  "Neither" - no spaces around colon. "Both" 
space on both sides. "Left" space on left side only. "Right" space on right 
side only. ("Right" is of course subject to AlignConsecutiveBitField, so if 
alignment requires there to be spaces there will be space).

In summary - in the projects I looked at - the uses doesn't seem to be very 
consistent, can even use different styles within same struct. Most projects 
mixes "Both" and "Neither".  "Right" doesn't really seem to be used - it seems 
to be typos when it is.  "Left" is used in some cases when there are aligment 
for consecutive lines. (keep in mind that there almost always is consecutive 
lines,  a single bitfield in a struct seldom makes any sense)..

There was one case in musl that really made me smile.  `include/arpa/nameser.h` 
struct HEADER has different bitfield members depending on endianness,  for big 
endian it uses "Right" and little endian it uses "Left".  ( 
https://git.musl-libc.org/cgit/musl/tree/include/arpa/nameser.h#n324 )

My guess is that no project's coding style document really specifies this 
detail (except implicitly for projects where the style is defined as "whatever 
clang-format says").

But I think the conclusion is that it probably should be more that true/false.  
Pondering about doing it in steps, so first just `BitFieldColonSpacing` with 
values `Both` and `Neither` (i.e same functionality as in current patch) and 
then add `Before` as an additional option.

- qemu
  - mixing "Both" and "Neither"

- emacs
  - mixing "Both" and "Neither"

- git
  - mixing "Both" and "Neither"

- linux kernel
  - mixing "Both" and "Neither"
  - (also has a bunch of "unsigned x:1, y:2, z:3", which is interesting and 
seems to be missing tests for clang-format)
  - Has consecutive aligned variants

- gnupg
  - mixing "Both" and "Neither"
  - but mostly "Neither"
  - Also has one "Right": `agent/agent.h:int raw_value: 1;`

- lwip
  - Mostly "Left" combined with aligned consecutive
  - Some "Both"

- intel-pcm
  - "Both"

- syslog-ng
  - "Neither"

- busybox
  - "Left" combined with aligned consecutive

- glibc
  - mixing "Both" and "Neither"

- gcc
  - mixing "Both" and "Neither"  (mostly "Both")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090



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


[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-18 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5809a32e7c2d: [gcov] Add __gcov_dump/__gcov_reset and delete 
__gcov_flush (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83149

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/CodeGen/code-coverage.c
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/GCDAProfiling.c
  compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
  compiler-rt/test/profile/Posix/gcov-dlopen.c
  compiler-rt/test/profile/Posix/gcov-shared-flush.c
  compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
  compiler-rt/test/profile/gcov-dump-and-remove.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -130,7 +130,6 @@
   Function *
   insertCounterWriteout(ArrayRef>);
   Function *insertReset(ArrayRef>);
-  Function *insertFlush(Function *ResetF);
 
   bool AddFlushBeforeForkAndExec();
 
@@ -909,7 +908,6 @@
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
 Function *ResetF = insertReset(CountersBySP);
-Function *FlushF = insertFlush(ResetF);
 
 // Create a small bit of code that registers the "__llvm_gcov_writeout" to
 // be executed at exit and the "__llvm_gcov_flush" function to be executed
@@ -927,14 +925,13 @@
 IRBuilder<> Builder(BB);
 
 FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
-Type *Params[] = {PointerType::get(FTy, 0), PointerType::get(FTy, 0),
-  PointerType::get(FTy, 0)};
-FTy = FunctionType::get(Builder.getVoidTy(), Params, false);
+auto *PFTy = PointerType::get(FTy, 0);
+FTy = FunctionType::get(Builder.getVoidTy(), {PFTy, PFTy}, false);
 
 // Initialize the environment and register the local writeout, flush and
 // reset functions.
 FunctionCallee GCOVInit = M->getOrInsertFunction("llvm_gcov_init", FTy);
-Builder.CreateCall(GCOVInit, {WriteoutF, FlushF, ResetF});
+Builder.CreateCall(GCOVInit, {WriteoutF, ResetF});
 Builder.CreateRetVoid();
 
 appendToGlobalCtors(*M, F, 0);
@@ -1266,36 +1263,3 @@
 
   return ResetF;
 }
-
-Function *GCOVProfiler::insertFlush(Function *ResetF) {
-  FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
-  Function *FlushF = M->getFunction("__llvm_gcov_flush");
-  if (!FlushF)
-FlushF = Function::Create(FTy, GlobalValue::InternalLinkage,
-  "__llvm_gcov_flush", M);
-  FlushF->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
-  FlushF->addFnAttr(Attribute::NoInline);
-  if (Options.NoRedZone)
-FlushF->addFnAttr(Attribute::NoRedZone);
-
-  BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
-
-  // Write out the current counters.
-  Function *WriteoutF = M->getFunction("__llvm_gcov_writeout");
-  assert(WriteoutF && "Need to create the writeout function first!");
-
-  IRBuilder<> Builder(Entry);
-  Builder.CreateCall(WriteoutF, {});
-  Builder.CreateCall(ResetF, {});
-
-  Type *RetTy = FlushF->getReturnType();
-  if (RetTy->isVoidTy())
-Builder.CreateRetVoid();
-  else if (RetTy->isIntegerTy())
-// Used if __llvm_gcov_flush was implicitly declared.
-Builder.CreateRet(ConstantInt::get(RetTy, 0));
-  else
-report_fatal_error("invalid return type for __llvm_gcov_flush");
-
-  return FlushF;
-}
Index: compiler-rt/test/profile/gcov-dump-and-remove.c
===
--- compiler-rt/test/profile/gcov-dump-and-remove.c
+++ compiler-rt/test/profile/gcov-dump-and-remove.c
@@ -8,16 +8,19 @@
 // RUN: rm -f gcov-dump-and-remove.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-dump-and-remove.gcda | FileCheck %s
 
-extern void __gcov_flush(void);
+extern void __gcov_dump(void);
+extern void __gcov_reset(void);
 extern int remove(const char *);   // CHECK:  -: [[#@LINE]]:extern int remove
 int main(void) {   // CHECK-NEXT: #: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_dump();   // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_reset();  // CHECK-NEXT: #: [[#@LINE]]:
   if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: #: [[#@LINE]]:
 return 1;  // CHECK-NEXT: #: [[#@LINE]]: return 1;
// CHECK-NEXT: -: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
-  if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_dump();   // CHECK-NEXT: 1: [[#@LINE]]:
+  

[clang] 5809a32 - [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-18 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-18T15:07:46-07:00
New Revision: 5809a32e7c2d79a9a463eb9c15cde994b42e3002

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

LOG: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

GCC r187297 (2012-05) introduced `__gcov_dump` and `__gcov_reset`.
  `__gcov_flush = __gcov_dump + __gcov_reset`

The resolution to https://gcc.gnu.org/PR93623 ("No need to dump gcdas when 
forking" target GCC 11.0) removed the unuseful and undocumented __gcov_flush.

Close PR38064.

Reviewed By: calixte, serge-sans-paille

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/CodeGen/code-coverage.c
clang/test/Driver/darwin-ld.c
compiler-rt/lib/profile/GCDAProfiling.c
compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
compiler-rt/test/profile/Posix/gcov-dlopen.c
compiler-rt/test/profile/Posix/gcov-shared-flush.c
compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
compiler-rt/test/profile/gcov-dump-and-remove.c
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 7b879f8cb652..f910c88fa967 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1196,7 +1196,8 @@ void Darwin::addProfileRTLibs(const ArgList &Args,
   // runtime's functionality.
   if (hasExportSymbolDirective(Args)) {
 if (ForGCOV) {
-  addExportedSymbol(CmdArgs, "___gcov_flush");
+  addExportedSymbol(CmdArgs, "___gcov_dump");
+  addExportedSymbol(CmdArgs, "___gcov_reset");
   addExportedSymbol(CmdArgs, "_flush_fn_list");
   addExportedSymbol(CmdArgs, "_writeout_fn_list");
   addExportedSymbol(CmdArgs, "_reset_fn_list");

diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index 34ba3554f5b5..5a663135e2f0 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -51,7 +51,6 @@ int test2(int b) {
 // Check that the noredzone flag is set on the generated functions.
 
 // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ:#[0-9]+]]
-// CHECK: void @__llvm_gcov_flush() unnamed_addr [[NRZ]]
 // CHECK: void @__llvm_gcov_init() unnamed_addr [[NRZ]]
 
 // CHECK: attributes [[NRZ]] = { {{.*}}noredzone{{.*}} }

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index 3fc0556a2bde..ea71142e88c1 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -351,7 +351,8 @@
 // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
-// GCOV_EXPORT: "-exported_symbol" "___gcov_flush"
+// GCOV_EXPORT: "-exported_symbol" "___gcov_dump"
+// GCOV_EXPORT: "-exported_symbol" "___gcov_reset"
 //
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \

diff  --git a/compiler-rt/lib/profile/GCDAProfiling.c 
b/compiler-rt/lib/profile/GCDAProfiling.c
index 57d8dec423cc..fa4b95138332 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -639,25 +639,6 @@ static void llvm_writeout_and_clear(void) {
   fn_list_remove(&writeout_fn_list);
 }
 
-COMPILER_RT_VISIBILITY
-void llvm_register_flush_function(fn_ptr fn) {
-  fn_list_insert(&flush_fn_list, fn);
-}
-
-void __gcov_flush() {
-  struct fn_node* curr = flush_fn_list.head;
-
-  while (curr) {
-curr->fn();
-curr = curr->next;
-  }
-}
-
-COMPILER_RT_VISIBILITY
-void llvm_delete_flush_function_list(void) {
-  fn_list_remove(&flush_fn_list);
-}
-
 COMPILER_RT_VISIBILITY
 void llvm_register_reset_function(fn_ptr fn) {
   fn_list_insert(&reset_fn_list, fn);
@@ -698,15 +679,12 @@ pid_t __gcov_fork() {
 #endif
 
 COMPILER_RT_VISIBILITY
-void llvm_gcov_init(fn_ptr wfn, fn_ptr ffn, fn_ptr rfn) {
+void llvm_gcov_init(fn_ptr wfn, fn_ptr rfn) {
   static int atexit_ran = 0;
 
   if (wfn)
 llvm_register_writeout_function(wfn);
 
-  if (ffn)
-llvm_register_flush_function(ffn);
-
   if (rfn)
 llvm_register_reset_function(rfn);
 
@@ -715,11 +693,20 @@ void llvm_gcov_init(fn_ptr wfn, fn_ptr ffn, fn_ptr rfn) {
 
 /* Make sure we write out the data and delete the data structures. */
 atexit(llvm_delete_reset_function_list);
-atexit(llvm_delete_flush_function_list);
 #ifdef _WIN32
 atexit(llvm_writeout_and_clear);
 #endif
   }
 }
 
+void __gcov_dump(void) {
+  for (struct fn_node *f = writeout_fn_list.head; f; f = f->next)
+f->fn();
+}
+
+void __g

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

2020-07-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:1418
+  /// Whether floating point atomic fetch add/sub is supported.
+  virtual bool isFPAtomicFetchAddSubSupported() const { return false; }
+

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > I think it should be predicated on specific type.
> > > E.g. NVPTX supports atomic ops on fp32 ~everywhere, but fp64 atomic 
> > > add/sub is only supported on newer GPUs.
> > > And then there's fp16...
> > will do and add tests for fp16
> The number of bits alone may not be sufficient to differentiate the FP 
> variants.
> E.g. 16-bit floats currently have 2 variants: IEEE FP16 and BFloat16 
> (supported by intel and newer NVIDIA GPUs).
> CUDA-11 has introduced TF32 FP format, so we're likely to have more than one 
> 32-bit FP type, too.
> I think PPC has an odd `long double` variant represented as pair of 64-bit 
> doubles.
> 
will use llvm::fltSemantics for checking, which should cover different fp types.



Comment at: clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu:26
+  // CHECK: atomicrmw fsub double* {{.*}} monotonic
+  return __atomic_fetch_sub(p, 1.0, memory_order_relaxed);
+}

ldionne wrote:
> Nitpick, but this should be `1.0L` to be consistent.
done


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

https://reviews.llvm.org/D71726



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


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

2020-07-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 279032.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

use llvm::fltSemantics for checking


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

https://reviews.llvm.org/D71726

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Sema/atomic-ops.c
  clang/test/SemaCUDA/amdgpu-atomic-ops.cu
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
+// RUN:   -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
+// RUN:   -triple=amdgcn-amd-amdhsa
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 typedef __INTPTR_TYPE__ intptr_t;
 typedef int int8 __attribute__((ext_vector_type(8)));
@@ -36,7 +39,7 @@
 
 atomic_int gn;
 void f(atomic_int *i, const atomic_int *ci,
-   atomic_intptr_t *p, atomic_float *d,
+   atomic_intptr_t *p, atomic_float *d, atomic_double *d2, atomic_half *h, // expected-error {{unknown type name 'atomic_half'}}
int *I, const int *CI,
intptr_t *P, float *D, struct S *s1, struct S *s2,
global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
@@ -70,7 +73,8 @@
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(d, 1.0f, memory_order_seq_cst, memory_scope_work_group); // spir-error {{address argument to atomic operation must be a pointer to atomic integer, pointer or supported floating point type ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(d2, 1.0, memory_order_seq_cst, memory_scope_work_group); // spir-error {{address argument to atomic operation must be a pointer to atomic integer, pointer or supported floating point type ('__generic atomic_double *' (aka '__generic _Atomic(double) *') invalid)}}
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
Index: clang/test/SemaCUDA/amdgpu-atomic-ops.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/amdgpu-atomic-ops.cu
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx906 -fnative-half-type \
+// RUN:   -fnative-half-arguments-and-returns
+
+// REQUIRES: amdgpu-registered-target
+
+#include "Inputs/cuda.h"
+#include 
+
+__device__ _Float16 test_Flot16(_Float16 *p) {
+  return __atomic_fetch_sub(p, 1.0f16, memory_order_relaxed);
+  // expected-error@-1 {{address argument to atomic operation must be a pointer to integer, pointer or supported floating point type ('_Float16 *' invalid)}}
+}
+
+__device__ __fp16 test_fp16(__fp16 *p) {
+  return __atomic_fetch_sub(p, 1.0f16, memory_order_relaxed);
+  // expected-error@-1 {{address argument to atomic operation must be a pointer to integer, pointer or supported floating point type ('__fp16 *' invalid)}}
+}
Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -99,7 +99,8 @@
 #define _AS2 __attribute__((address_space(2)))
 
 void f(_Atomic(int) *i, const _Atomic(int) *ci,
-   _Atomic(int*) *p, _Atomic(float) *d,
+   _Atomic(int*) *p, _Atomic(float) *d, _Atomic(double) *d2,
+   _Atomic(long double) *d3,
int *I, const int *CI,
int **P, float *D, struct S *s1, struct S *s2) {
   __c11_atomic_init(I, 5); // expected-error {{pointer t

[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D81031#2160281 , @jhuber6 wrote:

> In D81031#2159943 , @jdoerfert wrote:
>
> > In D81031#2159895 , @jhuber6 wrote:
> >
> > > Fixing errors caused by unused attribute sets. Adding missing attributes 
> > > to barrier_codegen.cpp.
> > >
> > > Should I go ahead and commit this considering the previous was 
> > > temporarily reverted? Or should I just wait a bit to see if it fails 
> > > testing again.
> >
> >
> > If you only did minor modifications and no major problem showed up, the 
> > previous LGTM still stands. You should (always) run a full make check-all 
> > locally (or better on a server) to verify no other issues are known.
> >
> > FWIW, it happens that we break bots and patches get reverted. That is not 
> > great but also not too bad.
>
>
> I did run a check-all but apparently the last build I did didn't build clang 
> for some reason so it wasn't included in the tests. I ran cmake again with 
> the same options and it seemed to build clang this time so I don't know what 
> that was about.
>
> After that I ran the tests again and I passed everything except these four. I 
> reverted my commit and pulled from master and still failed the same test so 
> I'm assuming it's a problem with my CUDA installation rather than the patch.
>
>   libomp :: env/kmp_set_dispatch_buf.c
>   libomp :: worksharing/for/kmp_set_dispatch_buf.c
>   libomptarget :: mapping/declare_mapper_target_update.cpp
>   libomptarget :: offloading/target_depend_nowait.cpp
>   


They might be flaky, incompatible with your environment, or broken by something 
else. You should not assume master is always working ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[clang] 3452a0d - [Driver] -B: don't search for target triple prefixes

2020-07-18 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-18T20:26:01-07:00
New Revision: 3452a0d8c17f7166f479706b293caf6ac76ffd90

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

LOG: [Driver] -B: don't search for target triple prefixes

To match GCC (either crossing or not), which doesn't prepend target triple 
prefixes to `exec_prefixes`.

As an example, powerpc64le-linux-gnu-gcc does not search 
"powerpc64le-linux-gnu-${name}" in a -B path.

Added: 
clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/ld

Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/B-opt.c
clang/test/Driver/fuse-ld.c
clang/test/Driver/prefixed-tools.c
clang/test/Driver/program-path-priority.c
clang/test/Driver/windows-cross.c

Removed: 
clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/armv7-windows-itanium-ld



diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d2b6268d5fa3..7d52882f8532 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4785,8 +4785,7 @@ void Driver::generatePrefixedToolNames(
 Names.emplace_back((DefaultTargetTriple + "-" + Tool).str());
 }
 
-static bool ScanDirForExecutable(SmallString<128> &Dir,
- const std::string &Name) {
+static bool ScanDirForExecutable(SmallString<128> &Dir, StringRef Name) {
   llvm::sys::path::append(Dir, Name);
   if (llvm::sys::fs::can_execute(Twine(Dir)))
 return true;
@@ -4803,9 +4802,8 @@ std::string Driver::GetProgramPath(StringRef Name, const 
ToolChain &TC) const {
   for (const auto &PrefixDir : PrefixDirs) {
 if (llvm::sys::fs::is_directory(PrefixDir)) {
   SmallString<128> P(PrefixDir);
-  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables)
-if (ScanDirForExecutable(P, TargetSpecificExecutable))
-  return std::string(P.str());
+  if (ScanDirForExecutable(P, Name))
+return std::string(P.str());
 } else {
   SmallString<128> P((PrefixDir + Name).str());
   if (llvm::sys::fs::can_execute(Twine(P)))

diff  --git a/clang/test/Driver/B-opt.c b/clang/test/Driver/B-opt.c
index 5e5ff42fd095..df85dee4b704 100644
--- a/clang/test/Driver/B-opt.c
+++ b/clang/test/Driver/B-opt.c
@@ -1,9 +1,10 @@
 // Check -B driver option.
-//
+
+/// Target triple prefix is not detected for -B.
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN: -B %S/Inputs/B_opt_tree/dir1 -fuse-ld=ld 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-TRIPLE %s
-// CHECK-B-OPT-TRIPLE: 
"{{.*}}/Inputs/B_opt_tree/dir1{{/|}}i386-unknown-linux-ld"
+// CHECK-B-OPT-TRIPLE-NOT: 
"{{.*}}/Inputs/B_opt_tree/dir1{{/|}}i386-unknown-linux-ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN: -B %S/Inputs/B_opt_tree/dir2 -fuse-ld=ld 2>&1 \

diff  --git 
a/clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/armv7-windows-itanium-ld 
b/clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/ld
similarity index 100%
rename from 
clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/armv7-windows-itanium-ld
rename to clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/ld

diff  --git a/clang/test/Driver/fuse-ld.c b/clang/test/Driver/fuse-ld.c
index 13e709ccfdfa..f2ca9fb36194 100644
--- a/clang/test/Driver/fuse-ld.c
+++ b/clang/test/Driver/fuse-ld.c
@@ -31,23 +31,21 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
-
-
 // RUN: %clang %s -### -fuse-ld=ld \
 // RUN: -target arm-linux-androideabi \
-// RUN: -B%S/Inputs/basic_android_tree/bin 2>&1 \
+// RUN: -B%S/Inputs/basic_android_tree/bin/arm-linux-androideabi- 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-ANDROID-ARM-LD
 // CHECK-ANDROID-ARM-LD: 
Inputs/basic_android_tree/bin{{/|\\+}}arm-linux-androideabi-ld
 
 // RUN: %clang %s -### -fuse-ld=bfd \
 // RUN: -target arm-linux-androideabi \
-// RUN: -B%S/Inputs/basic_android_tree/bin 2>&1 \
+// RUN: -B%S/Inputs/basic_android_tree/bin/arm-linux-androideabi- 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-ANDROID-ARM-BFD
 // CHECK-ANDROID-ARM-BFD: 
Inputs/basic_android_tree/bin{{/|\\+}}arm-linux-androideabi-ld.bfd
 
 // RUN: %clang %s -### -fuse-ld=gold \
 // RUN: -target arm-linux-androideabi \
-// RUN: -B%S/Inputs/basic_android_tree/bin 2>&1 \
+// RUN: -B%S/Inputs/basic_android_tree/bin/arm-linux-androideabi- 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-ANDROID-ARM-GOLD
 // CHECK-ANDROID-ARM-GOLD: 
Inputs/basic_android_tree/bin{{/|\\+}}arm-linux-androideabi-ld.gold
 

diff  --git a/clang/test/Driver/prefixed-tools.c 
b/clang/test/Driver/prefixed-tools.c
index 63f7f29ae963..0252a2f70143 100644
--- a/clang/test/Driver/prefixed-tools.c
+++ b/clang/test/Driver/prefixed-tools.c
@@ -1,8

[clang] b2b39c5 - [Driver] --print-search-dirs: print -B options and COMPILER_PATH

2020-07-18 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-18T21:01:41-07:00
New Revision: b2b39c5d455b950c6fffcc902924516fe7f8ec9f

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

LOG: [Driver] --print-search-dirs: print -B options and COMPILER_PATH

Added: 
clang/test/Driver/print-search-dirs.c

Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/immediate-options.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7d52882f8532..317098e24823 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1748,6 +1748,13 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
   if (C.getArgs().hasArg(options::OPT_print_search_dirs)) {
 llvm::outs() << "programs: =";
 bool separator = false;
+// Print -B and COMPILER_PATH.
+for (const std::string &Path : PrefixDirs) {
+  if (separator)
+llvm::outs() << llvm::sys::EnvPathSeparator;
+  llvm::outs() << Path;
+  separator = true;
+}
 for (const std::string &Path : TC.getProgramPaths()) {
   if (separator)
 llvm::outs() << llvm::sys::EnvPathSeparator;

diff  --git a/clang/test/Driver/immediate-options.c 
b/clang/test/Driver/immediate-options.c
index 71494eec616f..d7cd6be40801 100644
--- a/clang/test/Driver/immediate-options.c
+++ b/clang/test/Driver/immediate-options.c
@@ -9,10 +9,6 @@
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
 // DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
-// RUN: %clang -print-search-dirs | FileCheck %s 
-check-prefix=PRINT-SEARCH-DIRS
-// PRINT-SEARCH-DIRS: programs: ={{.*}}
-// PRINT-SEARCH-DIRS: libraries: ={{.*}}
-
 // Test if the -print-resource-dir option is accepted without error.
 // Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.
 // RUN: %clang -print-resource-dir | FileCheck %s 
-check-prefix=PRINT-RESOURCE-DIR

diff  --git a/clang/test/Driver/print-search-dirs.c 
b/clang/test/Driver/print-search-dirs.c
new file mode 100644
index ..0ac13125c9a1
--- /dev/null
+++ b/clang/test/Driver/print-search-dirs.c
@@ -0,0 +1,6 @@
+// UNSUPPORTED: system-windows
+
+// RUN: env COMPILER_PATH=cpath1:cpath2 %clang %s -target x86_64-pc-freebsd 
--sysroot=%S/Inputs/basic_freebsd64_tree \
+// RUN:   -B b1 -B b2 -print-search-dirs | FileCheck %s
+// CHECK:  programs: =b1:b2:cpath1:cpath2:{{.*}}
+// CHECK-NEXT: libraries: ={{.*}}Inputs/basic_freebsd64_tree/usr/lib



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


[PATCH] D83645: Bump the default target CPU for i386-freebsd to i686

2020-07-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@dim

Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` 
`Subscribers:` `Tags:` and the text `Summary:` from the git commit with the 
following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. 
(`--date=now` is my personal preference (author dates are usually not useful. 
Using committer dates can make log almost monotonic in time))

`llvm/utils/git/pre-push.py` can validate the message does not include unneeded 
tags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83645



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


[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 279051.
nridge marked 9 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -548,6 +548,74 @@
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
 }
 
+TEST_F(TargetDeclTest, DependentExprs) {
+  Flags = {"-fno-delayed-template-parsing"};
+
+  // Heuristic resolution of method of dependent field
+  Code = R"cpp(
+struct A { void foo() {} };
+template 
+struct B {
+  A a;
+  void bar() {
+this->a.[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but base expression involves a function call.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  A getA();
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.getA().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but uses a function pointer.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  using FPtr = A(*)();
+  FPtr fptr;
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.fptr().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Base expression involves a member access into this.
+  Code = R"cpp(
+struct Bar {
+  int ;
+};
+template  struct Foo {
+  Bar func(int);
+  void test() {
+func(1).[[]];
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
@@ -705,36 +773,37 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {// Simple expressions.
-   {R"cpp(
+  {
+  // Simple expressions.
+  {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-"0: targets = {global}\n"
-"1: targets = {param}\n"
-"2: targets = {func}\n"},
-   {R"cpp(
+   "0: targets = {global}\n"
+   "1: targets = {param}\n"
+   "2: targets = {func}\n"},
+  {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-"0: targets = {x}\n"
-"1: targets = {X::a}\n"},
-   {R"cpp(
+   "0: targets = {x}\n"
+   "1: targets = {X::a}\n"},
+  {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-"0: targets = {bar}\n"
-"1: targets = {bar}\n"},
-   // Namespaces and aliases.
-   {R"cpp(
+   "0: targets = {bar}\n"
+   "1: targets = {bar}\n"},
+  // Namespaces and aliases.
+  {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -742,19 +811,19 @@
 using namespace $1^alias;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {alias}\n"},
-   // Using declarations.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {alias}\n"},
+  // Using declarations.
+  {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {ns::global}, qualifier = 'ns::'\n"},
-   // Simple types.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+  // Simple types.
+  {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -763,13 +832,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp",
-"0: targets = {Struct}\n"
-"1: targets = {x}, decl\n"
-"2: targets = {Typedef}\n"
-"3: targets = {y}, decl\n"
-"4: targets = {Struct}\n"},
-   // Name qualifiers.
-   {R"cpp(
+   "0: targets = {Struct}\n"
+   "1: targets = {x}

[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:214
   }
+  if (const auto *CE = dyn_cast(E)) {
+const auto *CalleeType = resolveDependentExprToType(CE->getCallee());

hokein wrote:
> btw, could you try the case below? it doesn't seem to work.
> 
> ```
> struct Bar {
>   int ;
> };
> template  struct Foo {
>   Bar func(int);
>   void test() {
> func(1).aa^aa;
>   }
> };
> ```
Thanks for the additional example. To make this work I had to handle one more 
case (`MemberExpr`) in `resolveDependentExprToDecls()`.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:287
 //
 // FIXME: improve common dependent scope using name lookup in primary 
templates.
 // e.g. template int foo() { return std::vector().size(); }

hokein wrote:
> this FIXME looks stale now, could you please update it?
I think the FIXME is still relevant. While we handle 
`DependentScopeDeclRefExpr` and `CXXDependentScopeMemberExpr`, we still do not 
handle the AST node types listed in the comment.

For example, we do not handle:

```
template 
struct A {
  typedef int [[type]];
};

template 
struct B {
  typedef typename A::t^ype type;
};
```

(I believe that one would be `DependentNameType`? You can imagine similar 
scenarios involving using-decls etc.)

However, the example in the FIXME (which depicts a 
`CXXDependentScopeMemberExpr`) is now stale, so I've removed it and clarified 
the comment a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739



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


[PATCH] D84122: [clangd] Handle deduction guides in TargetFinder and ExplicitReferenceCollector

2020-07-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84122

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -389,6 +389,19 @@
   Flags.push_back("-std=c++17");
   EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
{"struct Test", Rel::TemplatePattern});
+
+  Code = R"cpp(
+// Deduction guide
+template 
+struct Test {
+  template 
+  Test(I, I);
+};
+template 
+[[Test]](I, I) -> Test;
+  )cpp";
+  Flags.push_back("-std=c++17");
+  EXPECT_DECLS("CXXDeductionGuideDecl", {"template  struct Test"});
 }
 
 TEST_F(TargetDeclTest, Concept) {
@@ -792,8 +805,8 @@
goto $1^ten;
  }
)cpp",
-   "0: targets = {ten}, decl\n"
-   "1: targets = {ten}\n"},
+"0: targets = {ten}, decl\n"
+"1: targets = {ten}\n"},
// Simple templates.
{R"cpp(
   template  struct vector { using value_type = T; };
@@ -1295,7 +1308,7 @@
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
 "8: targets = {foo()::Baz::Field}\n"},
-  {R"cpp(
+   {R"cpp(
template
void crash(T);
template
@@ -1305,10 +1318,9 @@
 )cpp",
 "0: targets = {crash}\n"
 "1: targets = {}\n"
-"2: targets = {T}\n"
-  },
-  // unknown template name should not crash.
-  {R"cpp(
+"2: targets = {T}\n"},
+   // unknown template name should not crash.
+   {R"cpp(
 template  typename T>
 struct Base {};
 namespace foo {
@@ -1316,12 +1328,34 @@
 struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
 }
   )cpp",
-  "0: targets = {foo::Derive::T}, decl\n"
-  "1: targets = {foo::Derive}, decl\n"
-  "2: targets = {Base}\n"
-  "3: targets = {foo::Derive::T}\n"
-  "4: targets = {}, qualifier = 'T::'\n"},
-};
+"0: targets = {foo::Derive::T}, decl\n"
+"1: targets = {foo::Derive}, decl\n"
+"2: targets = {Base}\n"
+"3: targets = {foo::Derive::T}\n"
+"4: targets = {}, qualifier = 'T::'\n"},
+   // deduction guide
+   {R"cpp(
+  namespace foo {
+template 
+struct $1^Test {
+  template 
+  $3^Test($4^I);
+};
+template 
+$6^Test($7^I) -> $8^Test;
+  }
+)cpp",
+"0: targets = {T}, decl\n"
+"1: targets = {foo::Test}, decl\n"
+"2: targets = {I}, decl\n"
+"3: targets = {foo::Test::Test}, decl\n"
+"4: targets = {I}\n"
+"5: targets = {I}, decl\n"
+"6: targets = {foo::Test}\n"
+"7: targets = {I}\n"
+"8: targets = {foo::Test}\n"
+"9: targets = {I}\n"
+"10: targets = {}, qualifier = 'I::'\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -270,6 +270,8 @@
   // Record the underlying decl instead, if allowed.
   D = USD->getTargetDecl();
   Flags |= Rel::Underlying; // continue with the underlying decl.
+} else if (const auto *DG = dyn_cast(D)) {
+  D = DG->getDeducedTemplate();
 }
 
 if (const Decl *Pat = getTemplatePattern(D)) {
@@ -636,6 +638,15 @@
   /*IsDecl=*/true,
   {ND}});
 }
+
+void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *DG) {
+  // The class template name in a deduction guide targets the class
+  // template.
+  Refs.push_back(ReferenceLoc{DG->getQualifierLoc(),
+  DG->getNameInfo().getLoc(),
+  /*IsDecl=*/false,
+  {DG->getDeducedTemplate()}});
+}
   };
 
   Visitor V;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:57
 
+class OptNoneInstrumentation {
+public:

I may probably name this `SkipPassInstrumentation`. But it is up to you.



Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:65
+
+  bool DebugPM;
+};

How about calling this `DebugLogging`?



Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:27
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"

Why need this?



Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:270
+  }
+  if (F) {
+bool HasOptNone = F->hasOptNone();

```
  if (F && F->hasOptNone()) {
 ...
  }
  return true;
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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