[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Is there a test with indentation within a namespace? If not maybe you should 
add one.




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:613
+  // settings. This allows the format to back up one level in those cases.
+  if (!AddLevel && NamespaceBlock &&
+  Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths)

Maybe give `!AddLevel && Style.BreakBeforeBraces == 
FormatStyle::BS_Whitesmiths` a name? You check it three times.



Comment at: clang/lib/Format/UnwrappedLineParser.h:146
+  // when resetting the line state.
+  enum LineLevel { LL_Remove, LL_Keep };
+

I would prefer an enum class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D94955: [clang-format] Treat ForEachMacros as loops

2021-01-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested changes to this revision.
curdeius added a comment.
This revision now requires changes to proceed.

LGTM per se. But, as it's a somehow a breaking change, I'd rather wait for 
release 12 branch before landing to main, so that folks have time to veto 
before release 13.
Please update release notes.
Also given that @mydeveloperday was involved in the bug discussion, please wait 
for his review too (if he has anything to add).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94955

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


[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-19 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj updated this revision to Diff 317766.
timwoj added a comment.

Fixing diff to look at the right commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13601,7 +13601,7 @@
"  }\n",
WhitesmithsBraceStyle);
 
-  WhitesmithsBraceStyle.IndentCaseBlocks = true;
+  WhitesmithsBraceStyle.IndentCaseLabels = true;
   verifyFormat("void switchTest1(int a)\n"
"  {\n"
"  switch (a)\n"
@@ -13609,7 +13609,7 @@
"case 2:\n"
"  {\n"
"  }\n"
-   "break;\n"
+   "  break;\n"
"}\n"
"  }\n",
WhitesmithsBraceStyle);
@@ -13619,7 +13619,7 @@
"  switch (a)\n"
"{\n"
"case 0:\n"
-   "break;\n"
+   "  break;\n"
"case 1:\n"
"  {\n"
"  break;\n"
@@ -13627,9 +13627,9 @@
"case 2:\n"
"  {\n"
"  }\n"
-   "break;\n"
+   "  break;\n"
"default:\n"
-   "break;\n"
+   "  break;\n"
"}\n"
"  }\n",
WhitesmithsBraceStyle);
@@ -13642,17 +13642,17 @@
"  {\n"
"  foo(x);\n"
"  }\n"
-   "break;\n"
+   "  break;\n"
"default:\n"
"  {\n"
"  foo(1);\n"
"  }\n"
-   "break;\n"
+   "  break;\n"
"}\n"
"  }\n",
WhitesmithsBraceStyle);
 
-  WhitesmithsBraceStyle.IndentCaseBlocks = false;
+  WhitesmithsBraceStyle.IndentCaseLabels = false;
 
   verifyFormat("void switchTest4(int a)\n"
"  {\n"
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -86,7 +86,7 @@
   void parseFile();
   void parseLevel(bool HasOpeningBrace);
   void parseBlock(bool MustBeDeclaration, bool AddLevel = true,
-  bool MunchSemi = true);
+  bool MunchSemi = true, bool NamespaceBlock = false);
   void parseChildBlock();
   void parsePPDirective(unsigned Level);
   void parsePPDefine();
@@ -140,7 +140,12 @@
   bool tryToParsePropertyAccessor();
   void tryToParseJSFunction();
   bool tryToParseSimpleAttribute();
-  void addUnwrappedLine();
+
+  // Used by addUnwrappedLine to denote whether to keep or remove a level
+  // when resetting the line state.
+  enum LineLevel { LL_Remove, LL_Keep };
+
+  void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::LL_Remove);
   bool eof() const;
   // LevelDifference is the difference of levels after and before the current
   // token. For example:
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -580,12 +580,17 @@
 }
 
 void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
- bool MunchSemi) {
+ bool MunchSemi, bool NamespaceBlock) {
   assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
  "'{' or macro block token expected");
   const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
   FormatTok->setBlockKind(BK_Block);
 
+  // For Whitesmiths mode, jump to the next level prior to skipping over the
+  // braces.
+  if (AddLevel && Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths)
+++Line->Level;
+
   size_t PPStartHash = computePPHash();
 
   unsigned InitialLevel = Line->Level;
@@ -602,9 +607,16 @@
   ? (UnwrappedLine::kInvalidIndex)
   : (CurrentLines->size() - 1 - NbPreprocessorDirectives);
 
+  // Whitesmiths is weird here. The brace needs to be indented for the namespace
+  // block, but the block itself may not be indented depending on the style
+  // settings. This allows the format to back up one level in those cases.
+  if (!AddLevel && NamespaceBlock &&
+  Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths)
+--Line->Level;
+
   ScopedDeclarationState DeclarationState(*Line, Declar

[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-19 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj updated this revision to Diff 317765.
timwoj added a comment.

Updates from review:

- Fixed handling of IndentCaseLabels
- Fixed indentation of namespace braces
- Replaced bool argument to addUnwrappedLine with an enum


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

Files:
  clang/lib/Format/TokenAnalyzer.cpp


Index: clang/lib/Format/TokenAnalyzer.cpp
===
--- clang/lib/Format/TokenAnalyzer.cpp
+++ clang/lib/Format/TokenAnalyzer.cpp
@@ -68,7 +68,6 @@
   IdentifierTable IdentTable(getFormattingLangOpts(Style));
   FormatTokenLexer Lex(Env.getSourceManager(), Env.getFileID(),
Env.getFirstStartColumn(), Style, Encoding, Allocator,
-
IdentTable);
   ArrayRef Toks(Lex.lex());
   SmallVector Tokens(Toks.begin(), Toks.end());


Index: clang/lib/Format/TokenAnalyzer.cpp
===
--- clang/lib/Format/TokenAnalyzer.cpp
+++ clang/lib/Format/TokenAnalyzer.cpp
@@ -68,7 +68,6 @@
   IdentifierTable IdentTable(getFormattingLangOpts(Style));
   FormatTokenLexer Lex(Env.getSourceManager(), Env.getFileID(),
Env.getFirstStartColumn(), Style, Encoding, Allocator,
-
IdentTable);
   ArrayRef Toks(Lex.lex());
   SmallVector Tokens(Toks.begin(), Toks.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-19 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer added a comment.

I'll work on fixing the unit tests. Thought they ran with check-cpang-format 
but I was obviously wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-19 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer created this revision.
kentsommer requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Adds an option to [clang-format] which sorts headers in an alphabetical 
manner using case only for tie-breakers. The options is off by default in favor 
of the current ASCIIbetical sorting style.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95017

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Tooling/Inclusions/IncludeStyle.h
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -598,6 +598,22 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseAwareSorting) {
+  Style.IncludeSortCaseAware = true;
+
+  EXPECT_EQ("#include \"A/B.h\"\n"
+"#include \"A/b.h\"\n"
+"#include \"a/b.h\"\n"
+"#include \"B/A.h\"\n"
+"#include \"B/a.h\"\n",
+sort("#include \"B/a.h\"\n"
+ "#include \"B/A.h\"\n"
+ "#include \"A/B.h\"\n"
+ "#include \"a/b.h\"\n"
+ "#include \"A/b.h\"\n",
+ "a.cc"));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14827,6 +14827,8 @@
   "abc$");
   CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
   IncludeStyle.IncludeIsMainSourceRegex, "abc$");
+  CHECK_PARSE("IncludeSortCaseAware: true", IncludeStyle.IncludeSortCaseAware,
+  true);
 
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -556,6 +556,8 @@
 IO.mapOptional("IncludeIsMainRegex", Style.IncludeStyle.IncludeIsMainRegex);
 IO.mapOptional("IncludeIsMainSourceRegex",
Style.IncludeStyle.IncludeIsMainSourceRegex);
+IO.mapOptional("IncludeSortCaseAware",
+   Style.IncludeStyle.IncludeSortCaseAware);
 IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
 IO.mapOptional("IndentCaseBlocks", Style.IndentCaseBlocks);
 IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels);
@@ -2180,6 +2182,14 @@
 Indices.push_back(i);
   }
   llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
+if (Style.IncludeStyle.IncludeSortCaseAware) {
+  const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
+  const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
+  return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
+  Includes[LHSI].Filename) <
+ std::tie(Includes[RHSI].Priority, RHSFilenameLower,
+  Includes[RHSI].Filename);
+}
 return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
std::tie(Includes[RHSI].Priority, Includes[RHSI].Filename);
   });
Index: clang/include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -147,6 +147,33 @@
   /// ``ClassImpl.hpp`` would not have the main include file put on top
   /// before any other include.
   std::string IncludeIsMainSourceRegex;
+
+  /// Specify if sorting should be done in a case aware fashion.
+  ///
+  /// By default, clang-format sorts includes in an ASCIIbetical
+  /// fashion. For instance:
+  ///
+  /// \code
+  ///#include "B/a.h"   into  #include "A/B.h"
+  ///#include "B/A.h" #include "A/b.h"
+  ///#include "A/B.h" #include "B/A.h"
+  ///#include "a/b.h" #include "B/a.h"
+  ///#include "A/b.h" #include "a/b.h"
+  /// \endcode
+  ///
+  /// This option will cause includes to be sorted alphabetically with case
+  /// used as a tie-breaker. For instance:
+  ///
+  /// \code
+  ///#include "B/a.h"   into  #include "A/B.h"
+  ///#include "B/A.h" #include "A/b.h"
+  ///#include "A/B.h" #include "a/b.h"
+  ///#include "a/b.h" #include "B/A.h"
+  ///#include "A/b.h" #include "B/a.h"

[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 abandoned this revision.
tianshilei1992 added a comment.

Let's use LLVM intrinsics for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D91303: [clang-tidy] readability-container-size-empty: simplify implementation

2021-01-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp:480-482
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: the 'empty' method should be used
-// CHECK-MESSAGES: :101:18: note: method 'Lazy'::empty() defined here
-// CHECK-FIXES: {{^  }}void func() noexcept(!L.empty());

Wait, is losing these diagnostics necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91303

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


[PATCH] D91303: [clang-tidy] readability-container-size-empty: simplify implementation

2021-01-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91303

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


[PATCH] D94732: [CUDA] Normalize handling of defauled dtor.

2021-01-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:15162-15170
+  bool SkipDtorChecks = VD->getType()->isArrayType();
+
+  // CUDA: Skip destructor checks for host-only variables during device-side
+  // compilation
+  SkipDtorChecks |=
+  (LangOpts.CUDAIsDevice && VD->hasGlobalStorage() &&
+   !(VD->hasAttr() || VD->hasAttr() ||

Is this safe? What happens if the destructor for the variable is a template, 
and instantiating that template results in a reference to a device function? Eg:

```
template __device__ void f() {}
template struct A {
  ~A() { f<<<>>>(); }
};
A a;
```



Comment at: clang/test/SemaCUDA/default-ctor.cu:28
   InHD inhd;
-  Out out; // expected-error{{no matching constructor for initialization of 
'Out'}}
+  Out out;
   OutD outd;

I don't think we should accept this -- only functions that are defaulted on 
their first declaration should get special treatment. Instead of checking for 
`isDefaulted()` above, you should check for `!isUserProvided()` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94732

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


[PATCH] D95012: [WebAssembly] Prototype new f64x2 conversions

2021-01-19 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: wingo, ecnelises, sunfish, hiraditya, 
jgravelle-google, sbc100, dschuff.
tlively requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

As proposed in https://github.com/WebAssembly/simd/pull/383.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95012

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -742,4 +742,22 @@
 # CHECK: prefetch.nt 16 # encoding: [0xfd,0xc6,0x01,0x00,0x10]
 prefetch.nt 16
 
+# CHECK: f64x2.convert_low_i32x4_s # encoding: [0xfd,0x53]
+f64x2.convert_low_i32x4_s
+
+# CHECK: f64x2.convert_low_i32x4_u # encoding: [0xfd,0x54]
+f64x2.convert_low_i32x4_u
+
+# CHECK: i32x4.trunc_sat_zero_f64x2_s # encoding: [0xfd,0x55]
+i32x4.trunc_sat_zero_f64x2_s
+
+# CHECK: i32x4.trunc_sat_zero_f64x2_u # encoding: [0xfd,0x56]
+i32x4.trunc_sat_zero_f64x2_u
+
+# CHECK: f32x4.demote_zero_f64x2 # encoding: [0xfd,0x57]
+f32x4.demote_zero_f64x2
+
+# CHECK: f64x2.promote_low_f32x4 # encoding: [0xfd,0x69]
+f64x2.promote_low_f32x4
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -566,6 +566,26 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: trunc_sat_zero_signed_v4i32:
+; SIMD128-NEXT: .functype trunc_sat_zero_signed_v4i32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: i32x4.trunc_sat_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.wasm.trunc.saturate.zero.signed(<2 x double>)
+define <4 x i32> @trunc_sat_zero_signed_v4i32(<2 x double> %a) {
+  %v = call <4 x i32> @llvm.wasm.trunc.saturate.zero.signed(<2 x double> %a)
+  ret <4 x i32> %v
+}
+
+; CHECK-LABEL: trunc_sat_zero_unsigned_v4i32:
+; SIMD128-NEXT: .functype trunc_sat_zero_unsigned_v4i32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.wasm.trunc.saturate.zero.unsigned(<2 x double>)
+define <4 x i32> @trunc_sat_zero_unsigned_v4i32(<2 x double> %a) {
+  %v = call <4 x i32> @llvm.wasm.trunc.saturate.zero.unsigned(<2 x double> %a)
+  ret <4 x i32> %v
+}
+
 ; ==
 ; 2 x i64
 ; ==
@@ -820,6 +840,16 @@
   ret <4 x float> %v
 }
 
+; CHECK-LABEL: demote_zero_v4f32:
+; SIMD128-NEXT: .functype demote_zero_v4f32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.demote.zero(<2 x double>)
+define <4 x float> @demote_zero_v4f32(<2 x double> %a) {
+  %v = call <4 x float> @llvm.wasm.demote.zero(<2 x double> %a)
+  ret <4 x float> %v
+}
+
 ; ==
 ; 2 x f64
 ; ==
@@ -918,3 +948,33 @@
   )
   ret <2 x double> %v
 }
+
+; CHECK-LABEL: convert_low_signed_v2f64:
+; SIMD128-NEXT: .functype convert_low_signed_v2f64 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.convert_low_i32x4_s $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.convert.low.signed(<4 x i32>)
+define <2 x double> @convert_low_signed_v2f64(<4 x i32> %a) {
+  %v = call <2 x double> @llvm.wasm.convert.low.signed(<4 x i32> %a)
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: convert_low_unsigned_v2f64:
+; SIMD128-NEXT: .functype convert_low_unsigned_v2f64 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.convert_low_i32x4_u $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.convert.low.unsigned(<4 x i32>)
+define <2 x double> @convert_low_unsigned_v2f64(<4 x i32> %a) {
+  %v = call <2 x double> @llvm.wasm.convert.low.unsigned(<4 x i32> %a)
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: promote_low_v2f64:
+; SIMD128-NEXT: .functype promote_low_v2f64 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.promote_low_f32x4 $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.promote.low(<4 x float>)
+define <2 x double> @promote

[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good!

Might be worth some comments explaining why it's being done this way (probably 
good to have some details wherever we're making these changes to cope with CV's 
need for distinct functions by name/type/etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D95007: [CUDA][HIP] Add -fuse-cuid

2021-01-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2307
+  // Only alphanumeric and underscore is allowed in -cuid option.
+  if (auto *A = Args.getLastArg(OPT_cuid_EQ)) {
+const char *V = A->getValue();

Why this limitation? In particular I can imagine people using an id based on a 
filesystem location, which introduces /\:. and possibly other characters.


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

https://reviews.llvm.org/D95007

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 317728.
akhuang added a comment.

Update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,18 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: 
![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
+  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3734,7 +3734,8 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
+ !CGM.getCodeGenOpts().EmitCodeView))
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,18 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
+  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3734,7 +3734,8 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
+ !CGM.getCodeGenOpts().EmitCodeView))
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp:30-32
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl

dblaikie wrote:
> This test doesn't seem related to the code change. Perhaps it's meant to test 
> the "type:" parameter of the DISubprogram (like the type parameter of the 
> DISubprogram for "m" is tested).
ah, yeah, it's not. I originally had a change for lambdas but took it out. I 
think I'll remove this part of the test for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D95007: [CUDA][HIP] Add -fuse-cuid

2021-01-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added subscribers: jdoerfert, JonChesterfield.
JonChesterfield added a reviewer: jdoerfert.
JonChesterfield added a comment.

@jdoerfert this may be a candidate for deriving names of extracted target 
regions


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

https://reviews.llvm.org/D95007

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp:30-32
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl

This test doesn't seem related to the code change. Perhaps it's meant to test 
the "type:" parameter of the DISubprogram (like the type parameter of the 
DISubprogram for "m" is tested).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D93264: [CSSPGO] Introducing distribution factor for pseudo probe.

2021-01-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 317726.
hoy marked an inline comment as done.
hoy added a comment.

Addressing Wei's feedbacks.

Also prorating indirect callsite target count annotation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93264

Files:
  clang/test/CodeGen/pseudo-probe-emit.c
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/IR/PseudoProbe.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-update.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll

Index: llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
@@ -0,0 +1,77 @@
+; REQUIRES: x86_64-linux
+; RUN: opt < %s -passes='pseudo-probe,loop-unroll-full' -verify-pseudo-probe -S -o %t 2>&1 | FileCheck %s --check-prefix=VERIFY
+; RUN: FileCheck %s < %t
+
+; VERIFY: *** Pseudo Probe Verification After LoopFullUnrollPass ***
+; VERIFY: Function foo:
+; VERIFY: Probe 6	previous factor 1.00	current factor 5.00
+; VERIFY: Probe 4	previous factor 1.00	current factor 5.00
+
+declare void @foo2() nounwind
+
+define void @foo(i32 %x) {
+bb:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1)
+  %tmp = alloca [5 x i32*], align 16
+  br label %bb7.preheader
+
+bb3.loopexit:
+  %spec.select.lcssa = phi i32 [ %spec.select, %bb10 ]
+  %tmp5.not = icmp eq i32 %spec.select.lcssa, 0
+  br i1 %tmp5.not, label %bb24, label %bb7.preheader
+
+bb7.preheader:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0, i64 -1)
+  %tmp1.06 = phi i32 [ 5, %bb ], [ %spec.select.lcssa, %bb3.loopexit ]
+  br label %bb10
+
+bb10:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0, i64 -1)
+  %indvars.iv = phi i64 [ 0, %bb7.preheader ], [ %indvars.iv.next, %bb10 ]
+  %tmp1.14 = phi i32 [ %tmp1.06, %bb7.preheader ], [ %spec.select, %bb10 ]
+  %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %indvars.iv
+  %tmp14 = load i32*, i32** %tmp13, align 8
+  %tmp15.not = icmp ne i32* %tmp14, null
+  %tmp18 = sext i1 %tmp15.not to i32
+  %spec.select = add nsw i32 %tmp1.14, %tmp18
+  call void @foo2(), !dbg !12
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond.not = icmp eq i64 %indvars.iv.next, 5
+  br i1 %exitcond.not, label %bb3.loopexit, label %bb10, !llvm.loop !13
+
+bb24:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 5, i32 0, i64 -1)
+  ret void
+}
+
+;; A discriminator of 186646583 which is 0xb200037 in hexdecimal, stands for a direct call probe
+;; with an index of 6 and a scale of -1%.
+; CHECK: ![[#PROBE6]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE:]])
+; CHECK: ![[#SCOPE]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 186646583)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{!"clang version 3.9.0"}
+!12 = !DILocation(line: 2, column: 20, scope: !4)
+!13 = distinct !{!13, !14}
+!14 = !{!"l

[PATCH] D93095: Introduce -Wreserved-identifier

2021-01-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:2421-2428
+// Perform a lookup at TUScope. If it succeeds, we're at global scope and a
+// single '_' is enough to be reserved.
+LookupResult IdentifierLookup(*this, II, SourceLocation(),
+  Sema::LookupAnyName,
+  Sema::ForExternalRedeclaration);
+IdentifierLookup.suppressDiagnostics();
+if (LookupName(IdentifierLookup, TUScope))

I don't understand why name lookup is involved here. Whether an identifier is 
reserved doesn't depend on whether it's already been declared in the global 
namespace or not. It's valid to declare `_foo` in some user-defined namespace 
regardless of whether there's already a `_foo` in the global namespace, and 
it's invalid to declare `_foo` in the global namespace regardless of whether 
there's already a `_foo` in the global namespace.

If you're trying to detect whether the name is being introduced in the global 
namespace scope, per C++ [lex.name]/3.2, you can't do that like this; you'll 
need to look at the `DeclContext` of the declaration instead of just the 
identifier.



Comment at: clang/lib/Sema/SemaDecl.cpp:5898
 
+  if (D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_extern)
+warnOnReservedIdentifier(New);

Why does the presence / absence of `extern` matter here?



Comment at: clang/lib/Sema/SemaDecl.cpp:13640
 
+  warnOnReservedIdentifier(New);
+

Is there somewhere more central you can do this, rather than repeating it once 
for each kind of declaration? (Eg, `PushOnScopeChains`)



Comment at: clang/lib/Sema/SemaDecl.cpp:16296
   } else {
+if (TUK == TUK_Definition)
+  warnOnReservedIdentifier(New);

Why do we not diagnose the other possible `TagUseKind`s? `struct _foo;` and 
`struct _foo *p;` both use reserved identifiers too.


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

https://reviews.llvm.org/D93095

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1050-1052
+  // Don't include a linkage name in line tables only, except to differentiate
+  // between lambdas.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo() || RD->isLambda())

dblaikie wrote:
> rnk wrote:
> > We discussed giving lambdas display names as an alternative to doing this.
> Should this be only for CodeView (due to CV's need for functions to be 
> distinct in some way)? Adding the linkage name could increase debug info size 
> for DWARF consumers unnecessarily
I think the CodeView change is elsewhere - here it just makes sure we only emit 
linkage names if it's not line tables only. (Now I'm remembering me creating 
the `hasReducedDebugInfo` function and the naming is pretty confusing...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 317718.
akhuang marked an inline comment as done.
akhuang added a comment.

Add check for CodeView


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,23 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: 
![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl
+  auto lambda1 = []() {};
+  lambda1();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3734,7 +3734,8 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
+ !CGM.getCodeGenOpts().EmitCodeView))
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,23 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl
+  auto lambda1 = []() {};
+  lambda1();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3734,7 +3734,8 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
+ !CGM.getCodeGenOpts().EmitCodeView))
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 retur

[PATCH] D93978: [clangd] DefineOutline doesn't require implementation file being saved

2021-01-19 Thread Nathan James via Phabricator via cfe-commits
njames93 planned changes to this revision.
njames93 added a comment.

I've decided I much prefer the implementation in D94554 
, So once thats cleaned up and split up, I'll 
merge changes in here with there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93978

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


[PATCH] D89441: [xray] Honor xray-never function-instrument attribute

2021-01-19 Thread Ian Levesque via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68a1f09107a4: [xray] Honor xray-never function-instrument 
attribute (authored by ianlevesque).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89441

Files:
  llvm/lib/CodeGen/XRayInstrumentation.cpp
  llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll

Index: llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
===
--- llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
+++ llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
@@ -1,6 +1,7 @@
 ; RUN: llc -filetype=asm -o - -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
 
 define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK-LABEL: foo:
 ; CHECK-LABEL: Lxray_sled_0:
 ; CHECK-NEXT:  b  #32
 ; CHECK-NEXT:  nop
@@ -24,8 +25,80 @@
 ; CHECK-LABEL: Ltmp1:
 ; CHECK-NEXT:  ret
 }
+
 ; CHECK-LABEL: xray_instr_map
 ; CHECK-LABEL: Lxray_sleds_start0
 ; CHECK:   .xword .Lxray_sled_0
 ; CHECK:   .xword .Lxray_sled_1
 ; CHECK-LABEL: Lxray_sleds_end0
+
+define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-never" "function-instrument"="xray-always" {
+; CHECK-LABEL: bar:
+; CHECK-LABEL: Lxray_sled_2:
+; CHECK-NEXT:  b  #32
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: Ltmp4:
+  ret i32 0
+; CHECK-LABEL: Lxray_sled_3:
+; CHECK-NEXT:  b  #32
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: Ltmp5:
+; CHECK-NEXT:  ret
+}
+
+; CHECK-LABEL: xray_instr_map
+; CHECK-LABEL: Lxray_sleds_start1
+; CHECK:   .xword .Lxray_sled_2
+; CHECK:   .xword .Lxray_sled_3
+; CHECK-LABEL: Lxray_sleds_end1
+
+define i32 @instrumented() nounwind noinline uwtable "xray-instruction-threshold"="1" {
+; CHECK-LABEL: instrumented:
+; CHECK-LABEL: Lxray_sled_4:
+; CHECK-NEXT:  b  #32
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: Ltmp8:
+  ret i32 0
+; CHECK-LABEL: Lxray_sled_5:
+; CHECK-NEXT:  b  #32
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: Ltmp9:
+; CHECK-NEXT:  ret
+}
+
+; CHECK-LABEL: xray_instr_map
+; CHECK-LABEL: Lxray_sleds_start2
+; CHECK:   .xword .Lxray_sled_4
+; CHECK:   .xword .Lxray_sled_5
+; CHECK-LABEL: Lxray_sleds_end2
+
+define i32 @not_instrumented() nounwind noinline uwtable "xray-instruction-threshold"="1" "function-instrument"="xray-never" {
+; CHECK-LABEL: not_instrumented
+; CHECK-NOT: .Lxray_sled_6
+  ret i32 0
+; CHECK:  ret
+}
Index: llvm/lib/CodeGen/XRayInstrumentation.cpp
===
--- llvm/lib/CodeGen/XRayInstrumentation.cpp
+++ llvm/lib/CodeGen/XRayInstrumentation.cpp
@@ -147,6 +147,10 @@
   auto InstrAttr = F.getFnAttribute("function-instrument");
   bool AlwaysInstrument = InstrAttr.isStringAttribute() &&
   InstrAttr.getValueAsString() == "xray-always";
+  bool NeverInstrument = InstrAttr.isStringAttribute() &&
+ InstrAttr.getValueAsString() == "xray-never";
+  if (NeverInstrument && !AlwaysInstrument)
+return false;
   auto ThresholdAttr = F.getFnAttribute("xray-instruction-threshold");
   auto IgnoreLoopsAttr = F.getFnAttribute("xray-ignore-loops");
   unsigned int XRayThreshold = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2021-01-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

It would be great if you could split the `--` support out into a separate patch 
to commit ahead of time, but I left a couple of comments since I was taking a 
look.




Comment at: clang/lib/Tooling/Tooling.cpp:438-440
   for (StringRef Arg : Args)
 if (Arg.startswith("-resource-dir"))
   return;

Seems like this should break early on `--`. You could also avoid the subsequent 
`llvm::find` by remembering where it is.



Comment at: clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json:4-5
   "directory": "DIR",
-  "command": "clang --analyze DIR/static-analyzer.c",
-  "file": "DIR/static-analyzer.c"
+  "command": "clang --analyze -- DIR/static-analyzer_clang.c",
+  "file": "DIR/static-analyzer_clang.c"
+},

It's not clear why you made these changes. Can you clarify?


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

https://reviews.llvm.org/D92191

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


[PATCH] D85223: [CUDA][HIP] Support accessing static device variable in host code for -fgpu-rdc

2021-01-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 317712.
yaxunl edited the summary of this revision.
yaxunl added a comment.

separate CUID patch.


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

https://reviews.llvm.org/D85223

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCUDA/static-device-var-rdc.cu
  clang/test/SemaCUDA/static-device-var.cu

Index: clang/test/SemaCUDA/static-device-var.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/static-device-var.cu
@@ -0,0 +1,37 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple nvptx -fcuda-is-device \
+// RUN:-emit-llvm -o - %s -fsyntax-only -verify
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux \
+// RUN:-emit-llvm -o - %s -fsyntax-only -verify
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+__device__ void f1() {
+  const static int b = 123;
+  static int a;
+}
+
+__global__ void k1() {
+  const static int b = 123;
+  static int a;
+}
+
+static __device__ int x;
+static __constant__ int y;
+
+__global__ void kernel(int *a) {
+  a[0] = x;
+  a[1] = y;
+}
+
+int* getDeviceSymbol(int *x);
+
+void foo() {
+  getDeviceSymbol(&x);
+  getDeviceSymbol(&y);
+}
Index: clang/test/CodeGenCUDA/static-device-var-rdc.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/static-device-var-rdc.cu
@@ -0,0 +1,89 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -fgpu-rdc -emit-llvm -o - -x hip %s | FileCheck \
+// RUN:   -check-prefixes=DEV,INT-DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux \
+// RUN:   -fgpu-rdc -emit-llvm -o - -x hip %s | FileCheck \
+// RUN:   -check-prefixes=HOST,INT-HOST %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -cuid=123abc \
+// RUN:   -fgpu-rdc -emit-llvm -o - -x hip %s | FileCheck \
+// RUN:   -check-prefixes=DEV,EXT-DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -cuid=123abc \
+// RUN:   -fgpu-rdc -emit-llvm -o - -x hip %s | FileCheck \
+// RUN:   -check-prefixes=HOST,EXT-HOST %s
+
+#include "Inputs/cuda.h"
+
+// Test function scope static device variable, which should not be externalized.
+// DEV-DAG: @_ZZ6kernelPiPPKiE1w = internal addrspace(4) constant i32 1
+
+
+// HOST-DAG: @_ZL1x = internal global i32 undef
+// HOST-DAG: @_ZL1y = internal global i32 undef
+
+// Test normal static device variables
+// INT-DEV-DAG: @_ZL1x = internal addrspace(1) global i32 0
+// INT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x\00"
+
+// Test externalized static device variables
+// EXT-DEV-DAG: @_ZL1x.static.123abc = {{.*}}addrspace(1) externally_initialized global i32 0
+// EXT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.123abc\00"
+
+static __device__ int x;
+
+// Test static device variables not used by host code should not be externalized
+// DEV-DAG: @_ZL2x2 = internal addrspace(1) global i32 0
+
+static __device__ int x2;
+
+// Test normal static device variables
+// INT-DEV-DAG: @_ZL1y = internal addrspace(4) global i32 0
+// INT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y\00"
+
+// Test externalized static device variables
+// EXT-DEV-DAG: @_ZL1y.static.123abc = {{.*}}addrspace(4) externally_initialized global i32 0
+// EXT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y.static.123abc\00"
+
+static __constant__ int y;
+
+// Test static host variable, which should not be externalized nor registered.
+// HOST-DAG: @_ZL1z = internal global i32 0
+// DEV-NOT: @_ZL1z
+static int z;
+
+// Test static device variable in inline function, which should not be
+// externalized nor registered.
+// DEV-DAG: @_ZZ6devfunPPKiE1p = linkonce_odr addrspace(4) constant i32 2, comdat
+
+inline __device__ void devfun(const int ** b) {
+  const static int p = 2;
+  b[0] = &p;
+}
+
+__global__ void kernel(int *a, const int **b) {
+  const static int w = 1;
+  a[0] = x;
+  a[1] = y;
+  b[0] = &w;
+  b[1] = &x2;
+  devfun(b);
+}
+
+int* getDeviceSymbol(int *x);
+
+void foo() {
+  getDeviceSymbol(&x);
+  getDeviceSymbol(&y);
+  z = 123;
+}
+
+// HOST: __hipRegisterVar({{.*}}@_ZL1x {{.*}}@[[DEVNAMEX]]
+// HOST: __hipRegisterVar({{.*}}@_ZL1y {{.*}}@[[DEVNAMEY]]
+// HOST-NOT: __hipRegisterVar({{.*}}@_ZL2x2
+// HOST-NOT: __hipRegisterVar({{.*}}@_ZZ6kernelPiPPKiE1w
+// HOST-NOT: __hipRegisterVar({{.*}}@_ZZ6devfunPPKiE1p
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1416,6 +1416,10 @@
TBAAAccessInfo *TBAAInfo = nullptr);
   bool stopAutoInit();
 
+  /// Print the postfix for externalized static variable for single source
+  /// off

[PATCH] D95007: [CUDA][HIP] Add -fuse-cuid

2021-01-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
Herald added subscribers: dexonsmith, dang.
yaxunl requested review of this revision.

This patch added a distinct CUID for each input file, which is represented by 
InputAction.
clang initially creates an InputAction for each input file for the host 
compilation. In CUDA/HIP action
builder, each InputAction is given a CUID and cloned for each GPU arch, and the 
CUID is also cloned. In this way,
we guarantee the corresponding device and host compilation for the same file 
shared the
same CUID. On the other hand, different compilation units have different CUID.

-fuse-cuid=random|hash|none is added to control the method to generate CUID. 
The default
is hash. -cuid=X is also added to specify CUID explicitly, which overrides 
-fuse-cuid.

This patch is separated from https://reviews.llvm.org/D85223


https://reviews.llvm.org/D95007

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/hip-cuid.hip
  clang/test/Frontend/hip-cuid.hip

Index: clang/test/Frontend/hip-cuid.hip
===
--- /dev/null
+++ clang/test/Frontend/hip-cuid.hip
@@ -0,0 +1,6 @@
+// RUN: not %clang_cc1 -cuid=abc-123 -offload-arch=gfx906 %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=INVALID %s
+
+// INVALID: invalid value 'abc-123' in '-cuid=abc-123' (alphanumeric characters and underscore only)
+
+// RUN: %clang_cc1 -cuid=abc_123 -offload-arch=gfx906 %s
Index: clang/test/Driver/hip-cuid.hip
===
--- /dev/null
+++ clang/test/Driver/hip-cuid.hip
@@ -0,0 +1,130 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Check invalid -fuse-cuid= option.
+
+// RUN: not %clang -### -x hip \
+// RUN:   -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx900 \
+// RUN:   --offload-arch=gfx906 \
+// RUN:   -c -nogpulib -fuse-cuid=invalid \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=INVALID %s
+
+// INVALID: invalid value 'invalid' in '-fuse-cuid=invalid'
+
+// Check random CUID generator.
+
+// RUN: %clang -### -x hip \
+// RUN:   -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx900 \
+// RUN:   --offload-arch=gfx906 \
+// RUN:   -c -nogpulib -fuse-cuid=random \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,HEX %s
+
+// Check fixed CUID.
+
+// RUN: %clang -### -x hip \
+// RUN:   -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx900 \
+// RUN:   --offload-arch=gfx906 \
+// RUN:   -c -nogpulib -cuid=xyz_123 \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,FIXED %s
+
+// Check fixed CUID override -fuse-cuid.
+
+// RUN: %clang -### -x hip \
+// RUN:   -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx900 \
+// RUN:   --offload-arch=gfx906 \
+// RUN:   -c -nogpulib -fuse-cuid=random -cuid=xyz_123 \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,FIXED %s
+
+// Check hash CUID generator.
+
+// RUN: %clang -### -x hip \
+// RUN:   -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx900 \
+// RUN:   --offload-arch=gfx906 \
+// RUN:   -c -nogpulib -fuse-cuid=hash \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,HEX %s
+
+// COMMON: "{{.*}}clang{{.*}}" "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-target-cpu" "gfx900"
+// HEX-SAME: "-cuid=[[CUID:[0-9a-f]+]]"
+// FIXED-SAME: "-cuid=[[CUID:xyz_123]]"
+// COMMON-SAME: "{{.*}}a.cu"
+
+// COMMON: "{{.*}}clang{{.*}}" "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-target-cpu" "gfx906"
+// COMMON-SAME: "-cuid=[[CUID]]"
+// COMMON-SAME: "{{.*}}a.cu"
+
+// COMMON: "{{.*}}clang{{.*}}" "-cc1"{{.*}} "-triple" "x86_64-unknown-linux-gnu"
+// COMMON-SAME: "-cuid=[[CUID]]"
+// COMMON-SAME: "{{.*}}a.cu"
+
+// COMMON: "{{.*}}clang{{.*}}" "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-target-cpu" "gfx900"
+// HEX-NOT: "-cuid=[[CUID]]"
+// HEX-SAME: "-cuid=[[CUID2:[0-9a-f]+]]"
+// FIXED-SAME: "-cuid=[[CUID2:xyz_123]]"
+// COMMON-SAME: "{{.*}}b.hip"
+
+// COMMON: "{{.*}}clang{{.*}}" "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-target-cpu" "gfx906"
+// HEX-NOT: "-cuid=[[CUID]]"
+// COMMON-SAME: 

[PATCH] D94986: Remove requirement for -maltivec to be used when using -mabi=vec-extabi or -mabi=vec-default when not using vector code

2021-01-19 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added inline comments.



Comment at: clang/test/CodeGen/altivec.c:1
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpcle-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE

I think it would be a good idea to explicitly specify the cpu while you're in 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94986

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


[PATCH] D94865: [ASTMatchers] Add callOrConstruct matcher

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 317709.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94865

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -863,6 +863,48 @@
  mapAnyOf(unaryOperator, cxxOperatorCallExpr)
  .with(hasAnyOperatorName("+", "!"),
forFunction(functionDecl(hasName("opFree")));
+
+  Code = R"cpp(
+struct ConstructorTakesInt
+{
+  ConstructorTakesInt(int i) {}
+};
+
+void callTakesInt(int i)
+{
+
+}
+
+void doCall()
+{
+  callTakesInt(42);
+}
+
+void doConstruct()
+{
+  ConstructorTakesInt cti(42);
+}
+)cpp";
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   callOrConstruct(
+   forFunction(functionDecl(hasName("doCall"))),
+   hasArgument(0, integerLiteral(equals(42))),
+   hasAnyArgument(integerLiteral(equals(42))),
+   forEachArgumentWithParam(integerLiteral(equals(42)),
+parmVarDecl(hasName("i")));
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   callOrConstruct(
+   forFunction(functionDecl(hasName("doConstruct"))),
+   hasArgument(0, integerLiteral(equals(42))),
+   hasAnyArgument(integerLiteral(equals(42))),
+   forEachArgumentWithParam(integerLiteral(equals(42)),
+parmVarDecl(hasName("i")));
 }
 
 TEST_P(ASTMatchersTest, IsDerivedFrom) {
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -152,6 +152,7 @@
   REGISTER_MATCHER(builtinType);
   REGISTER_MATCHER(cStyleCastExpr);
   REGISTER_MATCHER(callExpr);
+  REGISTER_MATCHER(callOrConstruct);
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -924,6 +924,9 @@
 const internal::MapAnyOfMatcher
 binaryOperation;
+const internal::MapAnyOfMatcher
+callOrConstruct;
 const internal::VariadicDynCastAllOfMatcher unaryOperator;
 const internal::VariadicDynCastAllOfMatcher
 conditionalOperator;
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2829,6 +2829,44 @@
CXXRewrittenBinaryOperator>
 binaryOperation;
 
+/// Matches function calls and constructor calls
+///
+/// Because CallExpr and CXXConstructExpr do not share a common
+/// base class with API accessing arguments etc, AST Matchers for code
+/// which should match both are typically duplicated. This matcher
+/// removes the need for duplication.
+///
+/// Given code
+/// \code
+/// struct ConstructorTakesInt
+/// {
+///   ConstructorTakesInt(int i) {}
+/// };
+///
+/// void callTakesInt(int i)
+/// {
+/// }
+///
+/// void doCall()
+/// {
+///   callTakesInt(42);
+/// }
+///
+/// void doConstruct()
+/// {
+///   ConstructorTakesInt cti(42);
+/// }
+/// \endcode
+///
+/// The matcher
+/// \code
+/// callOrConstruct(hasArgument(0, integerLiteral(equals(42
+/// \endcode
+/// matches the expression in both doCall and doConstruct
+extern const internal::MapAnyOfMatcher<
+CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr>
+callOrConstruct;
+
 /// Matches unary expressions that have a specific type of argument.
 ///
 /// Given
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -5613,6 +5613,40 @@
 
 
 
+Matcher<*>callOrConstructMatcher<*>...Matcher<*>
+Matches function calls and constructor calls
+
+Because CallExpr and CXXConstructExpr do not share a common
+base class with API accessing arguments etc, AST Matchers for code
+which should match both are typically duplicated. This m

[PATCH] D94879: Implement dynamic mapAnyOf in terms of ASTNodeKinds

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:948
+  return {};
+auto VM = Arg.Value.getMatcher();
+if (VM.hasTypedMatcher(NK)) {

aaron.ballman wrote:
> Note, this is an example of why use of `auto` is discouraged in the project 
> when the type is not spelled out explicitly in the initialization -- this was 
> accidentally creating a non-const copy of the `VariantMatcher`, not getting a 
> const reference as `getMatcher()` returns. Not the worst problem in the 
> world, but it takes a lot of review effort to find these issues when you use 
> `auto`, which is why the guidance is what it is.
> Note, this is an example of why use of auto is discouraged 

Nope, this isn't a good example of that. It's actually the opposite. `auto` 
does no harm here.

If I had written 

```
VariantMatcher VM = Arg.Value.getMatcher();
```

you would either already-know what the return type of `getMatcher()` is and see 
the copy, or you would be satisfied that the variable type is not `auto` 
(dangerously, potentially) and move on, or you would go and check the return 
type of `getMatcher()` if you had a suspicion.

If I had written 

```
SomeTypedefName VM = Arg.Value.getMatcher();
```

you wouldn't see an `auto`, which again might be satisfying, but you would have 
to go and look at the typedef to see if it contains a `const` or a `&` (for 
example see `ValueParamT` in `SmallVector` which is either `const T&` or `T`, 
depending on `T`).

Requiring non-use of `auto` is not a way around knowing or checking the return 
value of methods, and can actually give you a false sense of security! 

I don't think you'll ever convince me that your way doesn't make the code worse 
:).



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:950
+if (VM.hasTypedMatcher(NK)) {
+  auto DM = VM.getTypedMatcher(NK);
+  InnerArgs.push_back(DM);

aaron.ballman wrote:
> Rather than have a has/get pair, would it make sense to have a get method 
> that returns an `Optional` so that we don't have to check the same thing 
> twice?
I think you're talking about the `VariantMatcher` API, so I think that's out of 
scope of this patch.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:988
+  *LeastDerivedKind = CladeNodeKind;
+return true;
   }

aaron.ballman wrote:
> We used to traverse the list of matcher functions to see if one is 
> convertible or not and now we're always assuming that the conversion is fine 
> -- was that previous checking unnecessary or has it been subsumed by checking 
> somewhere else?
Yes, the checking was not necessary. Because this matcher is basically a 
convenient implementation of `stmt(anyOf(ifStmt(innerMatchers), 
forStmt(innerMatchers)))`, it's the outer `stmt` that it is convertible to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94879

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


[PATCH] D94879: Implement dynamic mapAnyOf in terms of ASTNodeKinds

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 317705.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94879

Files:
  clang/lib/ASTMatchers/Dynamic/Marshallers.h


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -925,32 +925,50 @@
   const StringRef MatcherName;
 };
 
-template 
 class MapAnyOfMatcherDescriptor : public MatcherDescriptor {
-  std::vector Funcs;
+  ASTNodeKind CladeNodeKind;
+  std::vector NodeKinds;
 
 public:
-  MapAnyOfMatcherDescriptor(StringRef MatcherName)
-  : Funcs{DynCastAllOfMatcherDescriptor(
-ast_matchers::internal::VariadicDynCastAllOfMatcher{},
-MatcherName)...} {}
+  MapAnyOfMatcherDescriptor(ASTNodeKind CladeNodeKind,
+std::vector NodeKinds)
+  : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
 
   VariantMatcher create(SourceRange NameRange, ArrayRef Args,
 Diagnostics *Error) const override {
-std::vector InnerArgs;
 
-for (auto const &F : Funcs) {
-  InnerArgs.push_back(F.create(NameRange, Args, Error));
-  if (!Error->errors().empty())
-return {};
+std::vector NodeArgs;
+
+for (auto NK : NodeKinds) {
+  std::vector InnerArgs;
+
+  for (const auto &Arg : Args) {
+if (!Arg.Value.isMatcher())
+  return {};
+const VariantMatcher &VM = Arg.Value.getMatcher();
+if (VM.hasTypedMatcher(NK)) {
+  auto DM = VM.getTypedMatcher(NK);
+  InnerArgs.push_back(DM);
+}
+  }
+
+  if (InnerArgs.empty()) {
+NodeArgs.push_back(
+DynTypedMatcher::trueMatcher(NK).dynCastTo(CladeNodeKind));
+  } else {
+NodeArgs.push_back(
+DynTypedMatcher::constructVariadic(
+ast_matchers::internal::DynTypedMatcher::VO_AllOf, NK,
+InnerArgs)
+.dynCastTo(CladeNodeKind));
+  }
 }
-return VariantMatcher::SingleMatcher(
-ast_matchers::internal::BindableMatcher(
-VariantMatcher::VariadicOperatorMatcher(
-ast_matchers::internal::DynTypedMatcher::VO_AnyOf,
-std::move(InnerArgs))
-.getTypedMatcher()));
+
+auto Result = DynTypedMatcher::constructVariadic(
+ast_matchers::internal::DynTypedMatcher::VO_AnyOf, CladeNodeKind,
+NodeArgs);
+Result.setAllowBind(true);
+return VariantMatcher::SingleMatcher(Result);
   }
 
   bool isVariadic() const override { return true; }
@@ -963,9 +981,11 @@
 
   bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
ASTNodeKind *LeastDerivedKind) const override {
-return llvm::all_of(Funcs, [=](const auto &F) {
-  return F.isConvertibleTo(Kind, Specificity, LeastDerivedKind);
-});
+if (Specificity)
+  *Specificity = 1;
+if (LeastDerivedKind)
+  *LeastDerivedKind = CladeNodeKind;
+return true;
   }
 };
 
@@ -1077,8 +1097,9 @@
 std::unique_ptr makeMatcherAutoMarshall(
 ast_matchers::internal::MapAnyOfMatcherImpl,
 StringRef MatcherName) {
-  return std::make_unique>(
-  MatcherName);
+  return std::make_unique(
+  ASTNodeKind::getFromNodeKind(),
+  std::vector{ASTNodeKind::getFromNodeKind()...});
 }
 
 } // namespace internal


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -925,32 +925,50 @@
   const StringRef MatcherName;
 };
 
-template 
 class MapAnyOfMatcherDescriptor : public MatcherDescriptor {
-  std::vector Funcs;
+  ASTNodeKind CladeNodeKind;
+  std::vector NodeKinds;
 
 public:
-  MapAnyOfMatcherDescriptor(StringRef MatcherName)
-  : Funcs{DynCastAllOfMatcherDescriptor(
-ast_matchers::internal::VariadicDynCastAllOfMatcher{},
-MatcherName)...} {}
+  MapAnyOfMatcherDescriptor(ASTNodeKind CladeNodeKind,
+std::vector NodeKinds)
+  : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
 
   VariantMatcher create(SourceRange NameRange, ArrayRef Args,
 Diagnostics *Error) const override {
-std::vector InnerArgs;
 
-for (auto const &F : Funcs) {
-  InnerArgs.push_back(F.create(NameRange, Args, Error));
-  if (!Error->errors().empty())
-return {};
+std::vector NodeArgs;
+
+for (auto NK : NodeKinds) {
+  std::vector InnerArgs;
+
+  for (const auto &Arg : Args) {
+if (!Arg.Value.isMatcher())
+  return {};
+const VariantMatcher &VM = Arg.Value.getMatcher();
+if (VM.hasTypedMatcher(NK)) {
+  auto DM = VM.getTypedMatcher(N

[PATCH] D94878: Make it possible to store a ASTNodeKind in VariantValue

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 317704.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94878

Files:
  clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
  clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
  clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Index: clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
@@ -184,6 +184,25 @@
   .getTypedMatcher()));
 }
 
+TEST(VariantValueTest, NodeKind) {
+  VariantValue Value = ASTNodeKind::getFromNodeKind();
+  EXPECT_TRUE(Value.isNodeKind());
+  EXPECT_TRUE(Value.getNodeKind().isSame(ASTNodeKind::getFromNodeKind()));
+
+  Value = ASTNodeKind::getFromNodeKind();
+  EXPECT_TRUE(Value.isNodeKind());
+  EXPECT_TRUE(Value.getNodeKind().isSame(
+  ASTNodeKind::getFromNodeKind()));
+
+  Value.setNodeKind(ASTNodeKind::getFromNodeKind());
+  EXPECT_TRUE(Value.isNodeKind());
+  EXPECT_TRUE(
+  Value.getNodeKind().isSame(ASTNodeKind::getFromNodeKind()));
+
+  Value = 42;
+  EXPECT_TRUE(!Value.isNodeKind());
+}
+
 } // end anonymous namespace
 } // end namespace dynamic
 } // end namespace ast_matchers
Index: clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -268,6 +268,10 @@
   setString(String);
 }
 
+VariantValue::VariantValue(ASTNodeKind NodeKind) : Type(VT_Nothing) {
+  setNodeKind(NodeKind);
+}
+
 VariantValue::VariantValue(const VariantMatcher &Matcher) : Type(VT_Nothing) {
   setMatcher(Matcher);
 }
@@ -290,6 +294,9 @@
   case VT_String:
 setString(Other.getString());
 break;
+  case VT_NodeKind:
+setNodeKind(Other.getNodeKind());
+break;
   case VT_Matcher:
 setMatcher(Other.getMatcher());
 break;
@@ -308,6 +315,9 @@
   case VT_Matcher:
 delete Value.Matcher;
 break;
+  case VT_NodeKind:
+delete Value.NodeKind;
+break;
   // Cases that do nothing.
   case VT_Boolean:
   case VT_Double:
@@ -378,6 +388,19 @@
   Value.String = new std::string(NewValue);
 }
 
+bool VariantValue::isNodeKind() const { return Type == VT_NodeKind; }
+
+const ASTNodeKind &VariantValue::getNodeKind() const {
+  assert(isNodeKind());
+  return *Value.NodeKind;
+}
+
+void VariantValue::setNodeKind(ASTNodeKind NewValue) {
+  reset();
+  Type = VT_NodeKind;
+  Value.NodeKind = new ASTNodeKind(NewValue);
+}
+
 bool VariantValue::isMatcher() const {
   return Type == VT_Matcher;
 }
@@ -449,6 +472,8 @@
   case VT_Boolean: return "Boolean";
   case VT_Double: return "Double";
   case VT_Unsigned: return "Unsigned";
+  case VT_NodeKind:
+return getNodeKind().asStringRef().str();
   case VT_Nothing: return "Nothing";
   }
   llvm_unreachable("Invalid Type");
Index: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
===
--- clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -251,6 +251,7 @@
   VariantValue(double Double);
   VariantValue(unsigned Unsigned);
   VariantValue(StringRef String);
+  VariantValue(ASTNodeKind NodeKind);
   VariantValue(const VariantMatcher &Matchers);
 
   /// Constructs an \c unsigned value (disambiguation from bool).
@@ -280,6 +281,10 @@
   const std::string &getString() const;
   void setString(StringRef String);
 
+  bool isNodeKind() const;
+  const ASTNodeKind &getNodeKind() const;
+  void setNodeKind(ASTNodeKind NodeKind);
+
   /// Matcher value functions.
   bool isMatcher() const;
   const VariantMatcher &getMatcher() const;
@@ -316,7 +321,8 @@
 VT_Double,
 VT_Unsigned,
 VT_String,
-VT_Matcher
+VT_Matcher,
+VT_NodeKind
   };
 
   /// All supported value types.
@@ -326,6 +332,7 @@
 bool Boolean;
 std::string *String;
 VariantMatcher *Matcher;
+ASTNodeKind *NodeKind;
   };
 
   ValueType Type;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94877: Add API to retrieve a clade kind from ASTNodeKind

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0cd0eb6e0a81: Add API to retrieve a clade kind from 
ASTNodeKind (authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D94877?vs=317226&id=317703#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94877

Files:
  clang/include/clang/AST/ASTTypeTraits.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/unittests/AST/ASTTypeTraitsTest.cpp


Index: clang/unittests/AST/ASTTypeTraitsTest.cpp
===
--- clang/unittests/AST/ASTTypeTraitsTest.cpp
+++ clang/unittests/AST/ASTTypeTraitsTest.cpp
@@ -39,6 +39,18 @@
   EXPECT_TRUE(DNT().isSame(DNT()));
 }
 
+TEST(DynTypedNode, Clades) {
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_FALSE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_TRUE(ASTNodeKind().getCladeKind().isNone());
+}
+
 TEST(ASTNodeKind, BaseDistances) {
   unsigned Distance = 1;
   EXPECT_TRUE(DNT().isBaseOf(DNT(), &Distance));
Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -63,6 +63,17 @@
   return Derived == Base;
 }
 
+ASTNodeKind ASTNodeKind::getCladeKind() const {
+  NodeKindId LastId = KindId;
+  while (LastId) {
+NodeKindId ParentId = AllKindInfo[LastId].ParentId;
+if (ParentId == NKI_None)
+  return LastId;
+LastId = ParentId;
+  }
+  return NKI_None;
+}
+
 StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; }
 
 ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1,
Index: clang/include/clang/AST/ASTTypeTraits.h
===
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -100,6 +100,8 @@
   static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1,
   ASTNodeKind Kind2);
 
+  ASTNodeKind getCladeKind() const;
+
   /// Hooks for using ASTNodeKind as a key in a DenseMap.
   struct DenseMapInfo {
 // ASTNodeKind() is a good empty key because it is represented as a 0.


Index: clang/unittests/AST/ASTTypeTraitsTest.cpp
===
--- clang/unittests/AST/ASTTypeTraitsTest.cpp
+++ clang/unittests/AST/ASTTypeTraitsTest.cpp
@@ -39,6 +39,18 @@
   EXPECT_TRUE(DNT().isSame(DNT()));
 }
 
+TEST(DynTypedNode, Clades) {
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_FALSE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_TRUE(ASTNodeKind().getCladeKind().isNone());
+}
+
 TEST(ASTNodeKind, BaseDistances) {
   unsigned Distance = 1;
   EXPECT_TRUE(DNT().isBaseOf(DNT(), &Distance));
Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -63,6 +63,17 @@
   return Derived == Base;
 }
 
+ASTNodeKind ASTNodeKind::getCladeKind() const {
+  NodeKindId LastId = KindId;
+  while (LastId) {
+NodeKindId ParentId = AllKindInfo[LastId].ParentId;
+if (ParentId == NKI_None)
+  return LastId;
+LastId = ParentId;
+  }
+  return NKI_None;
+}
+
 StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; }
 
 ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1,
Index: clang/include/clang/AST/ASTTypeTraits.h
===
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -100,6 +100,8 @@
   static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1,
   ASTNodeKind Kind2);
 
+  ASTNodeKind getCladeKind() const;
+
   /// Hooks for using ASTNodeKind as a key in a DenseMap.
   struct DenseMapInfo {
 // ASTNodeKind() is a good empty key because it is represented as a 0.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0cd0eb6 - Add API to retrieve a clade kind from ASTNodeKind

2021-01-19 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-01-19T22:51:30Z
New Revision: 0cd0eb6e0a8133ec86d884c1bbc9c3cbd1769c0b

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

LOG: Add API to retrieve a clade kind from ASTNodeKind

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

Added: 


Modified: 
clang/include/clang/AST/ASTTypeTraits.h
clang/lib/AST/ASTTypeTraits.cpp
clang/unittests/AST/ASTTypeTraitsTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index a91f6b0c1a69..57195a9d6066 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -100,6 +100,8 @@ class ASTNodeKind {
   static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1,
   ASTNodeKind Kind2);
 
+  ASTNodeKind getCladeKind() const;
+
   /// Hooks for using ASTNodeKind as a key in a DenseMap.
   struct DenseMapInfo {
 // ASTNodeKind() is a good empty key because it is represented as a 0.

diff  --git a/clang/lib/AST/ASTTypeTraits.cpp b/clang/lib/AST/ASTTypeTraits.cpp
index 49335ff37c41..b040f9e4cc40 100644
--- a/clang/lib/AST/ASTTypeTraits.cpp
+++ b/clang/lib/AST/ASTTypeTraits.cpp
@@ -63,6 +63,17 @@ bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId 
Derived,
   return Derived == Base;
 }
 
+ASTNodeKind ASTNodeKind::getCladeKind() const {
+  NodeKindId LastId = KindId;
+  while (LastId) {
+NodeKindId ParentId = AllKindInfo[LastId].ParentId;
+if (ParentId == NKI_None)
+  return LastId;
+LastId = ParentId;
+  }
+  return NKI_None;
+}
+
 StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; }
 
 ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1,

diff  --git a/clang/unittests/AST/ASTTypeTraitsTest.cpp 
b/clang/unittests/AST/ASTTypeTraitsTest.cpp
index 998488f1f1f9..18e8b8431b4c 100644
--- a/clang/unittests/AST/ASTTypeTraitsTest.cpp
+++ b/clang/unittests/AST/ASTTypeTraitsTest.cpp
@@ -39,6 +39,18 @@ TEST(ASTNodeKind, Bases) {
   EXPECT_TRUE(DNT().isSame(DNT()));
 }
 
+TEST(DynTypedNode, Clades) {
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+  EXPECT_TRUE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_FALSE(DNT().getCladeKind().isSame(DNT()));
+
+  EXPECT_TRUE(ASTNodeKind().getCladeKind().isNone());
+}
+
 TEST(ASTNodeKind, BaseDistances) {
   unsigned Distance = 1;
   EXPECT_TRUE(DNT().isBaseOf(DNT(), &Distance));



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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1050-1052
+  // Don't include a linkage name in line tables only, except to differentiate
+  // between lambdas.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo() || RD->isLambda())

rnk wrote:
> We discussed giving lambdas display names as an alternative to doing this.
Should this be only for CodeView (due to CV's need for functions to be distinct 
in some way)? Adding the linkage name could increase debug info size for DWARF 
consumers unnecessarily



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3738
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D)
 // Create fake but valid subroutine type. Otherwise -verify would fail, and

And here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D94986: Remove requirement for -maltivec to be used when using -mabi=vec-extabi or -mabi=vec-default when not using vector code

2021-01-19 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm accepted this revision.
cebowleratibm added a comment.
This revision is now accepted and ready to land.

Minor suggestion to keep and remap some of the diagnostic cases.




Comment at: clang/test/CodeGen/altivec.c:13
 // RUN: not %clang -S -emit-llvm -maltivec -target powerpc64-unknown-aix %s 
2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER

You should keep the -mabi=vec-default diagnostic lines and remap them to the 
expected error.  Applies to a few below.



Comment at: clang/test/CodeGen/altivec.c:16
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER

d


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94986

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 317701.
akhuang added a comment.

Remove lambda change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,23 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: 
![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl
+  auto lambda1 = []() {};
+  lambda1();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3734,7 +3734,7 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D)
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,23 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl
+  auto lambda1 = []() {};
+  lambda1();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3734,7 +3734,7 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D)
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94876: Remove TypedMatcherOps from VariantValue

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d112a8eda9d: Remove TypedMatcherOps from VariantValue 
(authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94876

Files:
  clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
  clang/lib/ASTMatchers/Dynamic/VariantValue.cpp


Index: clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -59,6 +59,11 @@
   return Matcher.canConvertTo(NodeKind);
 }
 
+DynTypedMatcher VariantMatcher::MatcherOps::convertMatcher(
+const DynTypedMatcher &Matcher) const {
+  return Matcher.dynCastTo(NodeKind);
+}
+
 llvm::Optional
 VariantMatcher::MatcherOps::constructVariadicOperator(
 DynTypedMatcher::VariadicOperator Op,
Index: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
===
--- clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -100,8 +100,7 @@
 
 /// Convert \p Matcher the destination type and return it as a new
 /// DynTypedMatcher.
-virtual DynTypedMatcher
-convertMatcher(const DynTypedMatcher &Matcher) const = 0;
+DynTypedMatcher convertMatcher(const DynTypedMatcher &Matcher) const;
 
 /// Constructs a variadic typed matcher from \p InnerMatchers.
 /// Will try to convert each inner matcher to the destination type and
@@ -110,9 +109,6 @@
 constructVariadicOperator(DynTypedMatcher::VariadicOperator Op,
   ArrayRef InnerMatchers) const;
 
-  protected:
-~MatcherOps() = default;
-
   private:
 ASTNodeKind NodeKind;
   };
@@ -174,8 +170,12 @@
   /// that can, the result would be ambiguous and false is returned.
   template 
   bool hasTypedMatcher() const {
+return hasTypedMatcher(ASTNodeKind::getFromNodeKind());
+  }
+
+  bool hasTypedMatcher(ASTNodeKind NK) const {
 if (!Value) return false;
-return Value->getTypedMatcher(TypedMatcherOps()).hasValue();
+return Value->getTypedMatcher(MatcherOps(NK)).hasValue();
   }
 
   /// Determines if the contained matcher can be converted to \p Kind.
@@ -197,10 +197,15 @@
   template 
   ast_matchers::internal::Matcher getTypedMatcher() const {
 assert(hasTypedMatcher() && "hasTypedMatcher() == false");
-return Value->getTypedMatcher(TypedMatcherOps())
+return 
Value->getTypedMatcher(MatcherOps(ASTNodeKind::getFromNodeKind()))
 ->template convertTo();
   }
 
+  DynTypedMatcher getTypedMatcher(ASTNodeKind NK) const {
+assert(hasTypedMatcher(NK) && "hasTypedMatcher(NK) == false");
+return *Value->getTypedMatcher(MatcherOps(NK));
+  }
+
   /// String representation of the type of the value.
   ///
   /// If the underlying matcher is a polymorphic one, the string will show all
@@ -211,7 +216,6 @@
   explicit VariantMatcher(std::shared_ptr Value)
   : Value(std::move(Value)) {}
 
-  template  struct TypedMatcherOps;
 
   class SinglePayload;
   class PolymorphicPayload;
@@ -220,17 +224,6 @@
   std::shared_ptr Value;
 };
 
-template 
-struct VariantMatcher::TypedMatcherOps final : VariantMatcher::MatcherOps {
-  TypedMatcherOps() : MatcherOps(ASTNodeKind::getFromNodeKind()) {}
-  typedef ast_matchers::internal::Matcher MatcherT;
-
-  DynTypedMatcher
-  convertMatcher(const DynTypedMatcher &Matcher) const override {
-return DynTypedMatcher(Matcher.convertTo());
-  }
-};
-
 /// Variant value class.
 ///
 /// Basically, a tagged union with value type semantics.


Index: clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -59,6 +59,11 @@
   return Matcher.canConvertTo(NodeKind);
 }
 
+DynTypedMatcher VariantMatcher::MatcherOps::convertMatcher(
+const DynTypedMatcher &Matcher) const {
+  return Matcher.dynCastTo(NodeKind);
+}
+
 llvm::Optional
 VariantMatcher::MatcherOps::constructVariadicOperator(
 DynTypedMatcher::VariadicOperator Op,
Index: clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
===
--- clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -100,8 +100,7 @@
 
 /// Convert \p Matcher the destination type and return it as a new
 /// DynTypedMatcher.
-virtual DynTypedMatcher
-convertMatcher(const DynTypedMatcher &Matcher) const = 0;
+DynTypedMatcher convertMatcher(const DynTypedMatcher &Matcher) const;
 
 /// Constructs a variadic typed matcher from \p InnerMatchers.
 /// Will try to convert each inner matcher to the destination ty

[clang] 8d112a8 - Remove TypedMatcherOps from VariantValue

2021-01-19 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-01-19T22:39:58Z
New Revision: 8d112a8eda9d78bc4c97cf7bc9e133afae7b6eed

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

LOG: Remove TypedMatcherOps from VariantValue

It provides no features or advantage over ASTNodeKind-based handling.

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
clang/lib/ASTMatchers/Dynamic/VariantValue.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h 
b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
index e47b42a4f38c..140b41dffc40 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -100,8 +100,7 @@ class VariantMatcher {
 
 /// Convert \p Matcher the destination type and return it as a new
 /// DynTypedMatcher.
-virtual DynTypedMatcher
-convertMatcher(const DynTypedMatcher &Matcher) const = 0;
+DynTypedMatcher convertMatcher(const DynTypedMatcher &Matcher) const;
 
 /// Constructs a variadic typed matcher from \p InnerMatchers.
 /// Will try to convert each inner matcher to the destination type and
@@ -110,9 +109,6 @@ class VariantMatcher {
 constructVariadicOperator(DynTypedMatcher::VariadicOperator Op,
   ArrayRef InnerMatchers) const;
 
-  protected:
-~MatcherOps() = default;
-
   private:
 ASTNodeKind NodeKind;
   };
@@ -174,8 +170,12 @@ class VariantMatcher {
   /// that can, the result would be ambiguous and false is returned.
   template 
   bool hasTypedMatcher() const {
+return hasTypedMatcher(ASTNodeKind::getFromNodeKind());
+  }
+
+  bool hasTypedMatcher(ASTNodeKind NK) const {
 if (!Value) return false;
-return Value->getTypedMatcher(TypedMatcherOps()).hasValue();
+return Value->getTypedMatcher(MatcherOps(NK)).hasValue();
   }
 
   /// Determines if the contained matcher can be converted to \p Kind.
@@ -197,10 +197,15 @@ class VariantMatcher {
   template 
   ast_matchers::internal::Matcher getTypedMatcher() const {
 assert(hasTypedMatcher() && "hasTypedMatcher() == false");
-return Value->getTypedMatcher(TypedMatcherOps())
+return 
Value->getTypedMatcher(MatcherOps(ASTNodeKind::getFromNodeKind()))
 ->template convertTo();
   }
 
+  DynTypedMatcher getTypedMatcher(ASTNodeKind NK) const {
+assert(hasTypedMatcher(NK) && "hasTypedMatcher(NK) == false");
+return *Value->getTypedMatcher(MatcherOps(NK));
+  }
+
   /// String representation of the type of the value.
   ///
   /// If the underlying matcher is a polymorphic one, the string will show all
@@ -211,7 +216,6 @@ class VariantMatcher {
   explicit VariantMatcher(std::shared_ptr Value)
   : Value(std::move(Value)) {}
 
-  template  struct TypedMatcherOps;
 
   class SinglePayload;
   class PolymorphicPayload;
@@ -220,17 +224,6 @@ class VariantMatcher {
   std::shared_ptr Value;
 };
 
-template 
-struct VariantMatcher::TypedMatcherOps final : VariantMatcher::MatcherOps {
-  TypedMatcherOps() : MatcherOps(ASTNodeKind::getFromNodeKind()) {}
-  typedef ast_matchers::internal::Matcher MatcherT;
-
-  DynTypedMatcher
-  convertMatcher(const DynTypedMatcher &Matcher) const override {
-return DynTypedMatcher(Matcher.convertTo());
-  }
-};
-
 /// Variant value class.
 ///
 /// Basically, a tagged union with value type semantics.

diff  --git a/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp 
b/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
index 866e2d0e3491..f31dda82a932 100644
--- a/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -59,6 +59,11 @@ VariantMatcher::MatcherOps::canConstructFrom(const 
DynTypedMatcher &Matcher,
   return Matcher.canConvertTo(NodeKind);
 }
 
+DynTypedMatcher VariantMatcher::MatcherOps::convertMatcher(
+const DynTypedMatcher &Matcher) const {
+  return Matcher.dynCastTo(NodeKind);
+}
+
 llvm::Optional
 VariantMatcher::MatcherOps::constructVariadicOperator(
 DynTypedMatcher::VariadicOperator Op,



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


[clang] 18e093f - [msabi] Mangle a template argument referring to array-to-pointer decay

2021-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-19T14:38:07-08:00
New Revision: 18e093faf726d15f210ab4917142beec51848258

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

LOG: [msabi] Mangle a template argument referring to array-to-pointer decay
applied to an array the same as the array itself.

This follows MS ABI, and corrects a regression from the implementation
of generalized non-type template parameters, where we "forgot" how to
mangle this case.

Added: 


Modified: 
clang/lib/AST/MicrosoftMangle.cpp
clang/test/CodeGenCXX/mangle-ms-templates.cpp

Removed: 




diff  --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 16e0aa2ae466..b9c289b6497a 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -1466,6 +1466,21 @@ void MicrosoftCXXNameMangler::mangleTemplateArgs(
   }
 }
 
+/// If value V (with type T) represents a decayed pointer to the first element
+/// of an array, return that array.
+static ValueDecl *getAsArrayToPointerDecayedDecl(QualType T, const APValue &V) 
{
+  // Must be a pointer...
+  if (!T->isPointerType() || !V.isLValue() || !V.hasLValuePath() ||
+  !V.getLValueBase())
+return nullptr;
+  // ... to element 0 of an array.
+  QualType BaseT = V.getLValueBase().getType();
+  if (!BaseT->isArrayType() || V.getLValuePath().size() != 1 ||
+  V.getLValuePath()[0].getAsArrayIndex() != 0)
+return nullptr;
+  return const_cast(V.getLValueBase().dyn_cast());
+}
+
 void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD,
 const TemplateArgument &TA,
 const NamedDecl *Parm) {
@@ -1576,6 +1591,14 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const 
TemplateDecl *TD,
 break;
   }
   case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {
+  // Mangle the result of array-to-pointer decay as if it were a reference
+  // to the original declaration, to match MSVC's behavior. This can result
+  // in mangling collisions in some cases!
+  return mangleTemplateArg(
+  TD, TemplateArgument(D, TA.getUncommonValueType()), Parm);
+}
 Out << "$";
 if (cast(Parm)
 ->getType()

diff  --git a/clang/test/CodeGenCXX/mangle-ms-templates.cpp 
b/clang/test/CodeGenCXX/mangle-ms-templates.cpp
index c9149a473b6f..a5ddb41461cc 100644
--- a/clang/test/CodeGenCXX/mangle-ms-templates.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -4,6 +4,20 @@
 // RUN: %clang_cc1 -std=c++17 -fms-compatibility-version=19 -emit-llvm %s -o - 
-fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck 
-check-prefix X64 %s
 // RUN: %clang_cc1 -std=c++20 -fms-compatibility-version=19 -emit-llvm %s -o - 
-fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck 
-check-prefix CXX20-X64 %s
 
+// Check that array-to-pointer decay is mangled as the underlying declaration.
+extern const char arr[4] = "foo";
+template struct Decay1 {};
+// CHECK: "?decay1@@3U?$Decay1@$1?arr@@3QBDB@@A"
+Decay1 decay1;
+#if __cplusplus >= 201702L
+// Note that this mangling approach can lead to collisions.
+template struct Decay2 {};
+// CXX20-X64: "?decay2a@@3U?$Decay2@$1?arr@@3QBDB@@A"
+Decay2<(const void*)arr> decay2a;
+// CXX20-X64: "?decay2b@@3U?$Decay2@$1?arr@@3QBDB@@A"
+Decay2<(const void*)&arr> decay2b;
+#endif
+
 template
 class Class {
  public:



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


[PATCH] D94957: [clang][cli] Port more options to new parsing system

2021-01-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94957

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1050-1052
+  // Don't include a linkage name in line tables only, except to differentiate
+  // between lambdas.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo() || RD->isLambda())

We discussed giving lambdas display names as an alternative to doing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


[PATCH] D92797: APINotes: add initial stub of APINotesWriter

2021-01-19 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Welcome back, hope you had a good time off.  Thanks for the review!




Comment at: clang/lib/APINotes/APINotesWriter.cpp:35
+  bool SwiftImportAsMember = false;
+#endif
+

martong wrote:
> compnerd wrote:
> > Please ignore this `#if`-defed portion, it is not intended for upstream, 
> > but I need to keep this working downstream.  I will remove this before 
> > merging.
> Could you please remove from the patch then?
Yeah, this is not meant to be committed with that in place, I just need to keep 
that around for testing locally.  I will absolutely be removing them.



Comment at: clang/lib/APINotes/APINotesWriter.cpp:764
+
+  hash_value_type ComputeHash(key_type_ref Key) {
+return llvm::DenseMapInfo::getHashValue(Key);

martong wrote:
> Some other *TableInfo classes do not have `ComputeHash`. E.g. 
> `GlobalVariableTableInfo`. Why?
> Where do we use `ComputeHash`?
Excellent observation.  The `ComputeHash` is not directly used, it is 
implemented as part of a trait used for the hashing, used in LLVM as part of 
`llvm::OnDiskChainedHashTableGenerator` which is used throughout this file.  
The reason that `GlobalVariableTableInfo` does not use it is because the 
versioned items derive from `VersionedInfo` which provides a shared 
implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92797

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


[PATCH] D95002: [RISCV] Update B extension version to 0.93.

2021-01-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: asb, luismarques, frasercrmck, lewis-revill, 
simoncook, PaoloS, kito-cheng.
Herald added subscribers: NickHung, evandro, apazos, sameer.abuasal, pzheng, 
s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, johnrusso, 
rbar.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95002

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -49,9 +49,9 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
 
-// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions -march=rv32ib0p92 -x c -E -dM %s \
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions -march=rv32ib0p93 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
-// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions -march=rv64ib0p92 -x c -E -dM %s \
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions -march=rv64ib0p93 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
 // CHECK-B-EXT: __riscv_bitmanip 1
 
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -343,7 +343,7 @@
 // RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32ib0p1'
 // RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ib0p92 
-menable-experimental-extensions -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
 // RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-b"
 
@@ -352,20 +352,20 @@
 // RV32-EXPERIMENTAL-ZBB-NOFLAG: error: invalid arch name 'rv32izbb'
 // RV32-EXPERIMENTAL-ZBB-NOFLAG: requires '-menable-experimental-extensions'
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p92 
-menable-experimental-extensions -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB %s
 // RV32-EXPERIMENTAL-ZBB: "-target-feature" "+experimental-zbb"
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p92_zbp0p92 
-menable-experimental-extensions -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p93_zbp0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP 
%s
 // RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+experimental-zbb"
 // RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+experimental-zbp"
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p92zbp0p92 
-menable-experimental-extensions -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p93zbp0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE %s
-// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb0p92zbp0p92', multi-character extensions must be separated by 
underscores
+// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb0p93zbp0p93', multi-character extensions must be separated by 
underscores
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32izba0p92 
-menable-experimental-extensions -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izba0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBA %s
 // RV32-EXPERIMENTAL-ZBA: "-target-feature" "+experimental-zba"
 
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -61,7 +61,7 @@
   if (Ext == "b" || Ext == "zba" || Ext == "zbb" || Ext == "zbc" || Ext == 
"zbe" ||
   Ext == "zbf" || Ext == "zbm" || Ext == "zbp" || Ext == "zbr" ||
   Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
-return RISCVExtensionVersion{"0", "92"};
+return RISCVExtensionVersion{"0", "93"};
   if (Ext == "v")
 return RISCVExtensionVersion{"0", "9

[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D94884#2508000 , @JonChesterfield 
wrote:

> I won't object too strongly, as ultimately I don't care about cuda, but I 
> view intertwining the two implementations as technical debt.

+1 A lot of CUDA-releated headers are not intended to be reusable nor often the 
best way to implement particular functionality.
While it may be tempting to reuse existing CUDA bits, having a clean 
implementation not tied to CUDA SDK is usually better.

That said, the builtin vars header is relatively independent from the CUDA SDK 
(unlike the runtime wrapper and various math-related headers)  and is OK to use 
for other purposes, if needed.

Whether OpenMP should make threadIdx & friends available -- I have no opinion 
on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94864: [ASTMatchers] Re-order the internals to allow another use-case

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecf696641e6c: [ASTMatchers] Allow use of mapAnyOf in more 
contexts (authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D94864?vs=317175&id=317690#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94864

Files:
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -491,6 +491,17 @@
   Code, traverse(TK_IgnoreUnlessSpelledInSource,
  mapAnyOf(ifStmt, 
forStmt).with(hasCondition(falseExpr);
 
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(true),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);
+
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(false),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);
+
+  EXPECT_TRUE(
+  notMatches(Code, floatLiteral(hasAncestor(mapAnyOf(ifStmt, forStmt);
+
   Code = R"cpp(
 void func(bool b) {}
 struct S {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1443,6 +1443,13 @@
   operator()(const Matcher &InnerMatcher) const {
 return create(InnerMatcher);
   }
+
+  template 
+  ArgumentAdaptingMatcherFuncAdaptor::Type, ToTypes>
+  operator()(const MapAnyOfHelper &InnerMatcher) const {
+return create(InnerMatcher.with());
+  }
 };
 
 template  class TraversalMatcher : public MatcherInterface {


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -491,6 +491,17 @@
   Code, traverse(TK_IgnoreUnlessSpelledInSource,
  mapAnyOf(ifStmt, forStmt).with(hasCondition(falseExpr);
 
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(true),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);
+
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(false),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);
+
+  EXPECT_TRUE(
+  notMatches(Code, floatLiteral(hasAncestor(mapAnyOf(ifStmt, forStmt);
+
   Code = R"cpp(
 void func(bool b) {}
 struct S {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1443,6 +1443,13 @@
   operator()(const Matcher &InnerMatcher) const {
 return create(InnerMatcher);
   }
+
+  template 
+  ArgumentAdaptingMatcherFuncAdaptor::Type, ToTypes>
+  operator()(const MapAnyOfHelper &InnerMatcher) const {
+return create(InnerMatcher.with());
+  }
 };
 
 template  class TraversalMatcher : public MatcherInterface {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ecf6966 - [ASTMatchers] Allow use of mapAnyOf in more contexts

2021-01-19 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-01-19T22:10:09Z
New Revision: ecf696641e6ce4b22e8c8ea3c7476b9c1f0f200b

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

LOG: [ASTMatchers] Allow use of mapAnyOf in more contexts

Add an operator overload to ArgumentAdaptingMatcherFunc to allow use of
mapAnyOf within hasAncestor, hasParent etc.

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index aa78a893dcf6b..2af4e6e88109b 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1443,6 +1443,13 @@ struct ArgumentAdaptingMatcherFunc {
   operator()(const Matcher &InnerMatcher) const {
 return create(InnerMatcher);
   }
+
+  template 
+  ArgumentAdaptingMatcherFuncAdaptor::Type, ToTypes>
+  operator()(const MapAnyOfHelper &InnerMatcher) const {
+return create(InnerMatcher.with());
+  }
 };
 
 template  class TraversalMatcher : public MatcherInterface {

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index b3582a02243a2..d681620cf5483 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -491,6 +491,17 @@ void F() {
   Code, traverse(TK_IgnoreUnlessSpelledInSource,
  mapAnyOf(ifStmt, 
forStmt).with(hasCondition(falseExpr);
 
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(true),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);
+
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(false),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);
+
+  EXPECT_TRUE(
+  notMatches(Code, floatLiteral(hasAncestor(mapAnyOf(ifStmt, forStmt);
+
   Code = R"cpp(
 void func(bool b) {}
 struct S {



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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D94884#2508000 , @JonChesterfield 
wrote:

> Note that a cuda-free openmp devicertl compilation doesn't require this 
> patch, or any other pieces of cuda headers.

Yes, we can write all code with CUDA built-in or others in LLVM intrinsics. 
Then the question is, do we want to use existing wrapper headers or all LLVM 
instrinsics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D94472#2507361 , @jansvoboda11 
wrote:

> Thanks for putting your time into the comment, @dexonsmith.
>
> I agree that adding a `-round-trip-args` flag to enable/disable 
> round-tripping is more sensible than hard-coding it via something like 
> `#ifndef NDEBUG`.
> Providing `-round-trip-args-debug-mode` to help with debugging would be a 
> great addition too. Thanks for pointing that out.
>
> I would be interested to hear why exactly are you concerned by the current 
> approach being too low level.
> From my point of view, having to opt-in into round-tripping a part of 
> `CompilerInvocation` is a feature and I think it should work relatively well 
> with the current roll-out plan:
>
> 1. Write documentation on porting existing options to the new marshalling 
> system.
> 2. Send a message to the mailing list pointing out that we'll be enabling 
> round-tripping in assert builds by default and what that means. Downstream 
> projects can prepare to port their custom options or disable the 
> round-tripping in assert builds.
> 3. Some time later, commit this patch. Downstream projects already have 
> enough information how to deal with the change. Because we've enabled 
> round-tripping only for `HeaderSearchOptions`, adopting it isn't that 
> time-consuming if a downstream project decides to do so.
> 4. (Any patches that add a command line option affecting 
> `HeaderSearchOptions` will from now on be forced to include the 
> generating/marshalling code.)
> 5. Slowly commit following patches, each enabling round-tripping for another 
> chunk of `CompilerInvocation`.
> 6. After round-tripping has been enabled for all of `CompilerInvocation`, 
> simplify the code (remove `ParseHS`, `GenerateHS`, `ResetHS`, etc.) and 
> round-trip everything (when told to do so with `-round-trip-args`).
>
> I'd be interested in hearing your thoughts on that ^.

I have three concerns with the approach:

1. Churn. This adds a lot of code that will eventually be removed / refactored 
away. One example is that shifting the `NDEBUG` logic to the driver requires 
threading a Boolean (or tristate/enum) for round-trip mode through a few 
layers; once we're finished, we'll end up stripping that argument back out. A 
second example is that this seems to require splitting up 
`OPTIONS_WITH_MARSHALLING` for each option. Once this work is finished, someone 
will need to clean them up / unify them, or maybe they'll unnecessarily stay 
split / duplicated.
2. Boilerplate. Somewhat related to churn; there's a fair bit of additional 
boilerplate required in this approach. This makes it harder to read / 
understand / modify the code.
3. Correctness. I'm not sure ResetHS is quite right. It'll probably work for a 
normal command-line `-cc1` invocation, but perhaps not for all tooling 
applications, since it's changing the pointer identity of `HeaderSearchOptions`.

On the other hand, one thing I really like about your approach, which I don't 
see a way of getting with a top-level check, is the ability to turn on "strict" 
mode for subsets of the command-line, which helps to hold the line in the face 
of new options being added (I think this is the feature you're (rightly) 
calling out). I'm not sure how important it is in practice, as long as we still 
think getting them all is going to happen in a reasonable time frame. There 
aren't that many new options being added: filtering out `[cli]` (your patches), 
`[flang]`, `[[D]driver]`, reverts, and relandings, there are 39 commits to 
Options.td in the last three months (3 / week). Some of those are deleting 
options or changing values, and not important to catch. Even for new options, I 
imagine most people copy/paste nearby options. I think it's critical to hold 
the line once we have them all, but until then I'm not sure.

Both approaches seem possible for downstreams to adapt / adopt in their own 
time, although reverting a one line patch switching from "relaxed" to "strict" 
would be easier than maintaining all the Parse/Generate/Reset infrastructure 
after upstream deletes it.

(I'm mostly concerned about #1 and #2; I assume #3 can be fixed somehow, 
although I haven't thought about how.)

> To help me understand the reasoning behind your proposal, can you answer 
> these questions?
>
> 2. What does `GeneratedArgs1 != GeneratedArgs2` prove? If we forget to 
> generate some option, it will be in neither `GeneratedArgs1` nor 
> `GeneratedArgs2`. We'll catch that only in "strict" mode anyways. I guess 
> this can help us discover other kinds of lossy generation, but I think the 
> guarantees of "strict" mode are nicer.

Firstly, `GeneratedArgs1 == GeneratedArgs2` proves that generate is an exact 
inversion of parse, for the subset of args that are handled by the generator 
(eventually, this will be all args). IOW, it's adding coverage (in one 
direction) that parse+generate "match" for every option that has generation 
code. 

[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I don't think introducing everything from the cuda namespace into openmp nvptx 
offloading is a feature. Inevitably people will call threadIdx.x instead of the 
openmp or clang equivalent, and this will mask missing functionality in openmp.

I won't object too strongly, as ultimately I don't care about cuda, but I view 
intertwining the two implementations as technical debt.

Note that a cuda-free openmp devicertl compilation doesn't require this patch, 
or any other pieces of cuda headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

2021-01-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 317679.
HazardyKnusperkeks added a comment.

Found and fixed the case when no `BasedOnStyle` apart from 
`InheritParentConfig` is used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16783,6 +16783,110 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9.1: overwriting a file style, when parent no file exists with no
+  // fallback style
+  ASSERT_TRUE(FS.addFile("/e/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: InheritParentConfig\n"
+  "ColumnLimit: 20")));
+  ASSERT_TRUE(FS.addFile("/e/sub/code.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getNoStyle();
+Style.ColumnLimit = 20;
+return Style;
+  }());
+
+  // Test 9.2: with LLVM fallback style
+  Style9 = getStyle("file", "/e/sub/code.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+Style.ColumnLimit = 20;
+return Style;
+  }());
+
+  // Test 9.3: with a parent file
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google\n"
+  "UseTab: Always")));
+  Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getGoogleStyle();
+Style.ColumnLimit = 20;
+Style.UseTab = FormatStyle::UT_Always;
+return Style;
+  }());
+
+  // Test 9.4: propagate more than one level
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/code.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer(
+ "BasedOnStyle: InheritParentConfig\n"
+ "WhitespaceSensitiveMacros: ['FOO', 'BAR']")));
+  std::vector NonDefaultWhiteSpaceMacros{"FOO", "BAR"};
+
+  const auto SubSubStyle = [&NonDefaultWhiteSpaceMacros] {
+auto Style = getGoogleStyle();
+Style.ColumnLimit = 20;
+Style.UseTab = FormatStyle::UT_Always;
+Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;
+return Style;
+  }();
+
+  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);
+  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.5: use InheritParentConfig as style name
+  Style9 =
+  getStyle("inheritparentconfig", "/e/sub/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.6: use command line style with inheritance
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig}", "/e/sub/code.cpp",
+"none", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.7: use command line style with inheritance and own config
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig, "
+"WhitespaceSensitiveMacros: ['FOO', 'BAR']}",
+"/e/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.8: use inheritance from a file without BasedOnStyle
+  ASSERT_TRUE(FS.addFile("/e/withoutbase/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("ColumnLimit: 123")));
+  ASSERT_TRUE(
+  FS.addFile("/e/withoutbase/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer(
+ "BasedOnStyle: InheritParentConfig\nIndentWidth: 7")));
+  // Make sure we do not use the fallback style
+  Style9 = getStyle("file", "/e/withoutbase/code.cpp", "google", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+Style.ColumnLimit = 123;
+return Style;
+  }());
+
+  Style9 = getStyle("file", "/e/withoutbase/sub/code.cpp", "google", "", &FS);
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+S

[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added reviewers: rnk, dblaikie.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change adds function types to further differentiate between
FUNC_IDs in -gline-tables-only.

Size increase of object files in clang are
Before: 917990 kb
After:  999312 kb

Bug: https://bugs.llvm.org/show_bug.cgi?id=48432


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95001

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,24 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: 
![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl
+  // CHECK-SAME:   identifier: {{.*lambda.*}}
+  auto lambda1 = []() {};
+  lambda1();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1047,8 +1047,9 @@
 
   // Create the type.
   SmallString<256> Identifier;
-  // Don't include a linkage name in line tables only.
-  if (CGM.getCodeGenOpts().hasReducedDebugInfo())
+  // Don't include a linkage name in line tables only, except to differentiate
+  // between lambdas.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo() || RD->isLambda())
 Identifier = getTypeIdentifier(Ty, CGM, TheCU);
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, Flags,
@@ -3734,7 +3735,7 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
  QualType FnType,
  llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (!D)
 // Create fake but valid subroutine type. Otherwise -verify would fail, and
 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,24 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:  type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA:[0-9]+]]
+  // CHECK: ![[LAMBDA]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:   flags: DIFlagFwdDecl
+  // CHECK-SAME:   identifier: {{.*lambda.*}}
+  auto lambda1 = []() {}

[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Nice! Thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D93095: Introduce -Wreserved-identifier

2021-01-19 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 317677.
serge-sans-paille added a comment.

As suggested by @aaron.ballman base the detection of top-level-ness on 
`Sema::LookupName` to avoid re-implementing the wheel.


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

https://reviews.llvm.org/D93095

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{'foo__bar' is a reserved identifier}}
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _barbouille() { return 0; } // expected-warning {{'_barbouille' is a reserved identifier}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{'__toucan' is a reserved identifier}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{'_Barbotine' is a reserved identifier}}
+
+template  // expected-warning {{'__' is a reserved identifier}}
+struct BarbeNoire {};
+
+template  // expected-warning {{'__' is a reserved identifier}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{'_Barbidur' is a reserved identifier}}
+
+struct __barbidou {}; // expected-warning {{'__barbidou' is a reserved identifier}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{'__barbouille' is a reserved identifier}}
+int _barbouille;  // expected-warning {{'_barbouille' is a reserved identifier}}
+
+int __babar() { return 0; } // expected-warning {{'__babar' is a reserved identifier}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{'__barbapapa' is a reserved identifier}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{'_Barbalala' is a reserved identifier}}
+};
+
+enum class __menu { // expected-warning {{'__menu' is a reserved identifier}}
+  __some,   // expected-warning {{'__some' is a reserved identifier}}
+  _Other,   // expected-warning {{'_Other' is a reserved identifier}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{'_Menu' is a reserved identifier}}
+  _OtheR_,   // expected-warning {{'_OtheR_' is a reserved identifier}}
+  _other_// expected-warning {{'_other_' is a reserved identifier}}
+};
+
+enum {
+  __some, // expected-warning {{'__some' is a reserved identifier}}
+  _Other, // expected-warning {{'_Other' is a reserved identifier}}
+  _other  // expected-warning {{'_other' is a reserved identifier}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+};
+
+using _Barbamama = __barbapapa; // expected-warning {{'_Barbamama' is a reserved identifier}}
+
+int foobar() {
+  return foo__bar(); // no-warning
+}
+
+namespace {
+// we skip this one because it's not at top-level.
+int _barbatruc; // expected-warning {{'_barbatruc' is a reserved identifier}}
+}
+
+long double operator"" _BarbeBleue(long double) // no-warning
+{
+  return 0.;
+}
Index: clang/test/Sema/reserved-identifier.c
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s
+
+#define __oof foo__ // expected-warning {{macro name is a reserved identifier}}
+
+int foo__bar() { return 0; }// no-warning
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _foo() { return 0; }// expected-warning {{'_foo' is a reserved identifier}}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+  goto __reserved;
+__re

[clang] ce24bb0 - [ASTMatchers] NFC Rearrange declarations to allow more arg adapting

2021-01-19 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-01-19T21:32:42Z
New Revision: ce24bb0eddab12460a01e4d91faa435f2fc84bb6

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

LOG: [ASTMatchers] NFC Rearrange declarations to allow more arg adapting

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index f56cda318f4e..aa78a893dcf6 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1171,6 +1171,232 @@ using HasDeclarationSupportedTypes =
  TemplateSpecializationType, TemplateTypeParmType, TypedefType,
  UnresolvedUsingType, ObjCIvarRefExpr>;
 
+/// A Matcher that allows binding the node it matches to an id.
+///
+/// BindableMatcher provides a \a bind() method that allows binding the
+/// matched node to an id if the match was successful.
+template  class BindableMatcher : public Matcher {
+public:
+  explicit BindableMatcher(const Matcher &M) : Matcher(M) {}
+  explicit BindableMatcher(MatcherInterface *Implementation)
+  : Matcher(Implementation) {}
+
+  /// Returns a matcher that will bind the matched node on a match.
+  ///
+  /// The returned matcher is equivalent to this matcher, but will
+  /// bind the matched node on a match.
+  Matcher bind(StringRef ID) const {
+return DynTypedMatcher(*this)
+.tryBind(ID)
+->template unconditionalConvertTo();
+  }
+
+  /// Same as Matcher's conversion operator, but enables binding on
+  /// the returned matcher.
+  operator DynTypedMatcher() const {
+DynTypedMatcher Result = static_cast &>(*this);
+Result.setAllowBind(true);
+return Result;
+  }
+};
+
+/// Matches any instance of the given NodeType.
+///
+/// This is useful when a matcher syntactically requires a child matcher,
+/// but the context doesn't care. See for example: anything().
+class TrueMatcher {
+public:
+  using ReturnTypes = AllNodeBaseTypes;
+
+  template  operator Matcher() const {
+return DynTypedMatcher::trueMatcher(ASTNodeKind::getFromNodeKind())
+.template unconditionalConvertTo();
+  }
+};
+
+/// Creates a Matcher that matches if all inner matchers match.
+template 
+BindableMatcher
+makeAllOfComposite(ArrayRef *> InnerMatchers) {
+  // For the size() == 0 case, we return a "true" matcher.
+  if (InnerMatchers.empty()) {
+return BindableMatcher(TrueMatcher());
+  }
+  // For the size() == 1 case, we simply return that one matcher.
+  // No need to wrap it in a variadic operation.
+  if (InnerMatchers.size() == 1) {
+return BindableMatcher(*InnerMatchers[0]);
+  }
+
+  using PI = llvm::pointee_iterator *const *>;
+
+  std::vector DynMatchers(PI(InnerMatchers.begin()),
+   PI(InnerMatchers.end()));
+  return BindableMatcher(
+  DynTypedMatcher::constructVariadic(DynTypedMatcher::VO_AllOf,
+ ASTNodeKind::getFromNodeKind(),
+ std::move(DynMatchers))
+  .template unconditionalConvertTo());
+}
+
+/// Creates a Matcher that matches if
+/// T is dyn_cast'able into InnerT and all inner matchers match.
+///
+/// Returns BindableMatcher, as matchers that use dyn_cast have
+/// the same object both to match on and to run submatchers on,
+/// so there is no ambiguity with what gets bound.
+template 
+BindableMatcher
+makeDynCastAllOfComposite(ArrayRef *> InnerMatchers) {
+  return BindableMatcher(
+  makeAllOfComposite(InnerMatchers).template dynCastTo());
+}
+
+/// A VariadicDynCastAllOfMatcher object is a
+/// variadic functor that takes a number of Matcher and returns a
+/// Matcher that matches TargetT nodes that are matched by all of the
+/// given matchers, if SourceT can be dynamically casted into TargetT.
+///
+/// For example:
+///   const VariadicDynCastAllOfMatcher record;
+/// Creates a functor record(...) that creates a Matcher given
+/// a variable number of arguments of type Matcher.
+/// The returned matcher matches if the given Decl can by dynamically
+/// casted to CXXRecordDecl and all given matchers match.
+template 
+class VariadicDynCastAllOfMatcher
+: public VariadicFunction, Matcher,
+  makeDynCastAllOfComposite> {
+public:
+  VariadicDynCastAllOfMatcher() {}
+};
+
+/// A \c VariadicAllOfMatcher object is a variadic functor that takes
+/// a number of \c Matcher and returns a \c Matcher that matches \c T
+/// nodes that are matched by all of the given matchers.
+///
+/// For example:
+///   const VariadicAllOfMatcher nestedNameSpecifier;
+/// Creates a functor nestedNameSpecifier(...) th

[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM for `__clang_cuda_builtin_vars.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-19 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: clang/docs/SourceBasedCodeCoverage.rst:77
+the files and functions specified in ``file.list`` will be instrumented.  The
+option can be specified multiple times to pass multiple files:
+

perhaps documenting how compiler generated functions are handled? 



Comment at: clang/docs/SourceBasedCodeCoverage.rst:86
+.. code-block:: none
+
+  # all functions whose name starts with foo will be instrumented.

what is the default section name?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2569
+  // If the profile list is empty, then instrument everything.
+  if (ProfileList.isEmpty())
+return true;

Should the option to turn on instrumentation also be checked?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2591
+  }
+  return false;
+}

If the profile list contains only one line of exclude list, it seems that all 
functions will be rejected as the function returns 'false' by default for all 
other functions?



Comment at: clang/lib/CodeGen/CodeGenModule.h:1280
 
+  bool isProfileInstrumented(llvm::Function *Fn, SourceLocation Loc,
+ StringRef Section = StringRef()) const;

Document the method and params.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D94814: [HIP] Support `__managed__` attribute

2021-01-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Presumably, `__managed__` variables would have to be memory-mapped into the 
host address space.




Comment at: clang/lib/CodeGen/CGCUDANV.cpp:391
+  SmallVector, 8> WorkList;
+  for (auto &&UU : Var->uses()) {
+WorkList.push_back({UU.getUser()});

`VarUse` ?



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:395
+  while (!WorkList.empty()) {
+auto &&US = WorkList.pop_back_val();
+auto *U = US.back();

`WorkItem`



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:552-553
+llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()),
+llvm::ConstantInt::get(IntTy, CGM.getLangOpts().HIP &&
+  Info.Flags.isManaged())};
+Builder.CreateCall(RegisterVar, Args);

This will always be `false`, because all cases where `Info.Flags.isManaged()` 
is true are handled in the other branch of this `if`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7728
+  case ParsedAttr::AT_HIPManaged:
+handleSimpleAttributeWithExclusions(S, D,
+AL);

The code changes in the patch appear to treat `__managed__` variable as a 
superset of a `__device__` var. If that's indeed the case, adding an implicit 
`__device__` attribute here would help to simplify the code. This way the 
existing code can handle generic  `__device__` var functionality without 
additional changes, and would use `__managed__` checks for the cases specific 
for managed vars only.




Comment at: llvm/lib/IR/ReplaceConstant.cpp:20
+namespace llvm {
+Instruction *createReplacementInstr(ConstantExpr *CE, Instruction *Instr) {
+  IRBuilder Builder(Instr);

The function could use a descriptive comment.

Despite the comment above, it does seem to do any replacing itself. Presumably 
it creates a an instruction that would perform an equivalent calculation at 
runtime.


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

https://reviews.llvm.org/D94814

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


[PATCH] D85223: [CUDA][HIP] Support accessing static device variable in host code for -fgpu-rdc

2021-01-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D85223#2507518 , @tra wrote:

> I'd propose splitting the patch into two. One with the addition of CUID and 
> the other that changes the way we havdle static vars.
> CUID is useful on its own and is relatively uncontroversial.
>
> Externalizing static vars is a more interesting issue and I'm not sure what's 
> the best way to handle it yet. On one hand it is necessary for visibility 
> across host/device, on the other, externalizing all static vars will almost 
> always have negative effect as very few of the static vars actually need 
> this. As already pointed out in the `#if 0` section of the patch, ideally we 
> should externalize only the vars that need it. Generally speaking, I do not 
> think we will be able to do that, because with `-fgpu-rdc` it may be used 
> from the host code in some other TU.
>
> We may need to explicitly annotate such the static variables that need to be 
> visible on both sides and only apply externalization to the variables 
> annotated this way. E.g. require them to be `__host__ __device__`.
>
> WDYT?

Agree that CUID may be useful for other situations. Will separate it to another 
review.


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

https://reviews.llvm.org/D85223

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


[PATCH] D93585: [AArch64] Enable out-of-line atomics by default.

2021-01-19 Thread James Greenhalgh via Phabricator via cfe-commits
jgreenhalgh added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:1087
  FeatureNEON,
+ FeatureOutlineAtomics,
  FeaturePerfMon,

t.p.northover wrote:
> ilinpv wrote:
> > t.p.northover wrote:
> > > I think this still enables it more widely than we want. Clang overrides 
> > > it with `-outline-atomics`, but other front-ends don't.
> > Could I ask you to clarify what front-ends you meant (to check outline 
> > atomics suport for them)?
> Any front-end that generates LLVM IR. Generally important ones are Swift and 
> Rust, but there are many more and I kind of doubt it's feasible to ensure 
> they all will. It's unfortunate, and maybe at some point we can put logic in 
> LLVM to approximate Clang's decision-making and get the benefit without any 
> opt-in, but I kind of think it's a bit early yet. We'd risk breaking too many 
> people's builds.
> 
> Also, putting it in the generic CPU model here means that if a front-end 
> allows something like `-mcpu=cortex-a57` it will suddenly disable outlined 
> atomics. Whether they're good or bad, that's just plain weird behaviour. A 
> CPU-level feature isn't the right place for this.
Not necessarily arguing in either direction for where these should be enabled, 
but is that behaviour really so weird?

I would expect that we want to specialise to inline atomics as soon as we're 
given architecture permission (-march=armv8.1-a+lse or greater) or CPU-directed 
specialisation. These things are only useful for the transition case where your 
platform mandates Armv8.0 only binaries but you're expecting to also run fast 
on cores with LSE support.

What we're nervous about is burying this option, which we believe to be 
generally useful for the Armv8.0 platforms, such that it is opt-in. It really 
isn't the end of the world if this is C/C++ on LInux/Android only for now, but 
it feels like missed opportunity. That said, it is safe, so probably makes 
sense to go for that now Pavel and think again about where else we want it on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

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


[PATCH] D94865: [ASTMatchers] Add callOrConstruct matcher

2021-01-19 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2867
+extern const internal::MapAnyOfMatcher
+callOrConstruct;
+

aaron.ballman wrote:
> I'm not super keen on this name. It's certainly descriptive, but I do wonder 
> if it's a bit too specific and should perhaps be something more like 
> `callableExpr()`, `callLikeExpr()`, or something more generic. For instance, 
> I could imagine wanting this to match on something like:
> ```
> struct S {
>   void setter(int val) {}
>   __declspec(property(put = setter)) int x;
> };
> 
> int main() {
>   S s;
>   s.x = 12; // Match here
>   // Because the above code actually does this:
>   // s.setter(12);
> }
> ```
> because this also has an expression that isn't really a call (as far as our 
> AST is concerned) but is a call as far as program semantics are concerned. 
> I'm not suggesting to make the matcher support that right now (unless you 
> felt like doing it), but thinking about the future and avoiding a name that 
> may paint us into a corner.
> 
> WDYT about using a more generic name?
I haven't seen code like that before (ms extension?) 
https://godbolt.org/z/anvd43 but I think that should be matched by 
`binaryOperator` instead. That already matches based on what the code looks 
like, rather than what it is in the AST.

This `callOrConstruct` is really for using `hasArgument` and related 
submatchers with nodes which support it. As such I think the name is fine. I 
don't like `callableExpr` or `callLikeExpr` because they don't bring to mind 
the possibility that construction is also supported.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94865

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


[PATCH] D94333: [Inliner] Change inline remark format and update ReplayInlineAdvisor to use it

2021-01-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei added inline comments.



Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:412
+
+  Remark << ";";
 }

modimo wrote:
> wenlei wrote:
> > nit: any special reason for adding this? doesn't seem consistent with other 
> > remarks we have.
> If you grab the remark outputs via `-Rpass=inline` you'll get additional 
> suffix information:
> ```
> inline.cpp:8:12: remark: _Z3foov inlined into main with (cost=0, 
> threshold=375) at callsite main:2:12; [-Rpass=inline]
> return foo();
> ```
> 
> The semicolon is to separate the remark from any additional output at the end 
> so when replaying we can match the correct callsite. Something like this 
> would be unneeded for yaml replay but for the current implementation it's 
> necessary for correctness.
> 
By correctness, did you mean the fact that you rely on `split(";")` in parsing, 
or something else?

This is not a big deal, but if no other remarks end with `;`, it would be good 
to be consistent. Using `split(";")` for parsing is just one way of 
implementing it, and IMO could be changed to favor consistency in remarks 
output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94333

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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 317664.
tianshilei1992 added a comment.

Renamed the macro and undef it after use


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

Files:
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  clang/test/Headers/openmp_device_math_isnan.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp

Index: clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
===
--- clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fexceptions -fcxx-exceptions -aux-triple powerpc64le-unknown-unknown -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns

[clang] da98651 - Revert "DR2064: decltype(E) is only a dependent type if E is type-dependent, not

2021-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-19T12:48:40-08:00
New Revision: da986511fb9da1a46a0ca4dba2e49e2426036303

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

LOG: Revert "DR2064: decltype(E) is only a dependent type if E is 
type-dependent, not
if E is merely instantiation-dependent."

This change leaves us unable to distinguish between different function
templates that differ in only instantiation-dependent ways, for example

template decltype(int(T())) f();
template decltype(int(T(0))) f();

We'll need substantially better support for types that are
instantiation-dependent but not dependent before we can go ahead with
this change.

This reverts commit e3065ce238475ec202c707f4c58d90df171626ca.

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Type.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/CodeGenCXX/mangle-subst.cpp
clang/test/Sema/invalid-bitwidth-expr.mm
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/invalid-template-base-specifier.cpp
clang/test/SemaTemplate/dependent-expr.cpp
clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 8c47047a7526..ca96b65574bd 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -255,12 +255,6 @@ inline TypeDependence 
toTypeDependence(TemplateNameDependence D) {
 inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
   return Dependence(D).type();
 }
-/// Compute the dependence of a type that depends on the type of an expression,
-/// given the dependence of that expression and of its type.
-inline TypeDependence typeToTypeDependence(ExprDependence ED, TypeDependence 
TD) {
-  return Dependence(ED & ~ExprDependence::Value).type() |
- (TD & TypeDependence::VariablyModified);
-}
 
 inline NestedNameSpecifierDependence
 toNestedNameSpecifierDependendence(TypeDependence D) {

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d396f81188df..c482235caaed 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5383,10 +5383,10 @@ QualType ASTContext::getDecltypeType(Expr *e, QualType 
UnderlyingType) const {
   DecltypeType *dt;
 
   // C++11 [temp.type]p2:
-  //   If an expression e is type-dependent, decltype(e) denotes a unique
-  //   dependent type. Two such decltype-specifiers refer to the same type only
-  //   if their expressions are equivalent (14.5.6.1).
-  if (e->isTypeDependent()) {
+  //   If an expression e involves a template parameter, decltype(e) denotes a
+  //   unique dependent type. Two such decltype-specifiers refer to the same
+  //   type only if their expressions are equivalent (14.5.6.1).
+  if (e->isInstantiationDependent()) {
 llvm::FoldingSetNodeID ID;
 DependentDecltypeType::Profile(ID, *this, e);
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index e7db8e2baa84..27aa622e00e9 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2578,11 +2578,6 @@ void CXXNameMangler::mangleType(QualType T) {
 if (!TST->isTypeAlias())
   break;
 
-  // Don't desugar instantiation-dependent decltype / typeof types. We need
-  // to mangle the expression as written.
-  if (isa(T))
-break;
-
   // FIXME: We presumably shouldn't strip off ElaboratedTypes with
   // instantation-dependent qualifiers. See
   // https://github.com/itanium-cxx-abi/cxx-abi/issues/114.
@@ -5612,11 +5607,12 @@ static bool hasMangledSubstitutionQualifiers(QualType 
T) {
 
 bool CXXNameMangler::mangleSubstitution(QualType T) {
   if (!hasMangledSubstitutionQualifiers(T)) {
-if (const RecordType *RT = dyn_cast(T))
+if (const RecordType *RT = T->getAs())
   return mangleSubstitution(RT->getDecl());
   }
 
   uintptr_t TypePtr = reinterpret_cast(T.getAsOpaquePtr());
+
   return mangleSubstitution(TypePtr);
 }
 
@@ -5775,7 +5771,7 @@ bool CXXNameMangler::mangleStandardSubstitution(const 
NamedDecl *ND) {
 
 void CXXNameMangler::addSubstitution(QualType T) {
   if (!hasMangledSubstitutionQualifiers(T)) {
-if (const RecordType *RT = dyn_cast(T)) {
+if (const RecordType *RT = T->getAs()) {
   addSubstitution(RT->getDecl());
   return;
 }

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 5dec80be9ccb..034e175f1352 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -125,7 +125,8 @@ ArrayType::ArrayType(TypeClass tc, QualType et, QualType 
can,
 //   template int arr

[clang] 5a684b7 - Ensure we don't strip the ConstantExpr carrying a non-type template

2021-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-19T12:48:39-08:00
New Revision: 5a684b70dc74f9f671f8eb61993a25769ec68117

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

LOG: Ensure we don't strip the ConstantExpr carrying a non-type template
argument's value off it during substitution.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7679063ead71..7d7591ab669c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1597,7 +1597,9 @@ 
TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr(
 ExprResult
 TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr(
   SubstNonTypeTemplateParmExpr *E) {
-  ExprResult SubstReplacement = TransformExpr(E->getReplacement());
+  ExprResult SubstReplacement = E->getReplacement();
+  if (!isa(SubstReplacement.get()))
+SubstReplacement = TransformExpr(E->getReplacement());
   if (SubstReplacement.isInvalid())
 return true;
   QualType SubstType = TransformType(E->getParameterType(getSema().Context));

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
index bc8a22e89041..4d61b9c7d937 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
@@ -511,3 +511,18 @@ namespace dependent_reference {
   // Ensure that we can instantiate the definition of S<...>.
   int n = *v.q + *w.q;
 }
+
+namespace decay {
+  template struct 
X {
+template void f(const X &v) {}
+  };
+  struct A {
+static constexpr const char *arr[] = {"hello", "world"};
+static constexpr int count = 2;
+  };
+  void f() {
+X x1;
+X x2;
+x1.f(x2);
+  }
+}



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


[PATCH] D91261: [OPENMP]Do not use OMP_MAP_TARGET_PARAM for data movement directives.

2021-01-19 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb272698de790: [OPENMP]Do not use OMP_MAP_TARGET_PARAM for 
data movement directives. (authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D91261?vs=307694&id=317660#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91261

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp

Index: clang/test/OpenMP/target_update_depend_codegen.cpp
===
--- clang/test/OpenMP/target_update_depend_codegen.cpp
+++ clang/test/OpenMP/target_update_depend_codegen.cpp
@@ -30,15 +30,15 @@
 double gc[100];
 
 // CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i64] [i64 800]
-// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i64] [i64 4]
-// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
-// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i64] [i64 sdiv exact (i64 sub (i64 ptrtoint (double** getelementptr (double*, double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)), i64 24]
-// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 281474976710673]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 281474976710673]
 
 // CK1-LABEL: _Z3fooi
 void foo(int arg) {
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -36,15 +36,15 @@
 // CK1-64: [[KMP_PRIVATES_T]] = type { [1 x i8*], [1 x i8*], [1 x i64] }
 
 // CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
-// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
-// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
-// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i64] [i64 sdiv exact (i64 sub (i64 ptrtoint (double** getelementptr (double*, double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)), i64 24]
-// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 281474976710673]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 281474976710673]
 
 // CK1-LABEL: _Z3fooi
 void foo(int arg) {
@@ -205,7 +205,7 @@
   }
 };
 
-// CK2: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 281474976710674]
+// CK2: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 281474976710674]
 
 // CK2-LABEL: _Z3bari
 int bar(int arg){
@@ -342,7 +342,7 @@
 #ifdef CK5
 
 // CK5: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
 // CK5-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
@@ -384,7 +384,7 @@
 #ifdef CK6
 
 // CK6: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK6: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK6: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
 // CK6-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
@@ -431,7 +431,7 @@
 #ifdef CK7
 
 // CK7: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK7: [[MTYPE00:@.+]] = {{.

[clang] b272698 - [OPENMP]Do not use OMP_MAP_TARGET_PARAM for data movement directives.

2021-01-19 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2021-01-19T12:41:15-08:00
New Revision: b272698de790d6603db7992c0c0ad6446b7a52b8

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

LOG: [OPENMP]Do not use OMP_MAP_TARGET_PARAM for data movement directives.

OMP_MAP_TARGET_PARAM flag is used to mark the data that shoud be passed
as arguments to the target kernels, nothing else. But the compiler still
marks the data with OMP_MAP_TARGET_PARAM flags even if the data is
passed to the data movement directives, like target data, target update
etc. This flag is just ignored for this directives and the compiler does
not need to emit it.

Reviewed By: cchen

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_data_codegen.cpp
clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
clang/test/OpenMP/target_enter_data_codegen.cpp
clang/test/OpenMP/target_enter_data_depend_codegen.cpp
clang/test/OpenMP/target_exit_data_codegen.cpp
clang/test/OpenMP/target_exit_data_depend_codegen.cpp
clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_depend_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 17fa56fb06c8..22df862db1b5 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8233,7 +8233,7 @@ class MappableExprsHandler {
  MapFlagsArrayTy &CurTypes,
  const StructRangeInfoTy &PartialStruct,
  const ValueDecl *VD = nullptr,
- bool NotTargetParams = false) const {
+ bool NotTargetParams = true) const {
 if (CurTypes.size() == 1 &&
 ((CurTypes.back() & OMP_MAP_MEMBER_OF) != OMP_MAP_MEMBER_OF) &&
 !PartialStruct.IsArraySection)
@@ -8284,7 +8284,7 @@ class MappableExprsHandler {
   /// pair of the relevant declaration and index where it occurs is appended to
   /// the device pointers info array.
   void generateAllInfo(
-  MapCombinedInfoTy &CombinedInfo, bool NotTargetParams = false,
+  MapCombinedInfoTy &CombinedInfo,
   const llvm::DenseSet> &SkipVarSet =
   llvm::DenseSet>()) const {
 // We have to process the component lists that relate with the same
@@ -8420,9 +8420,7 @@ class MappableExprsHandler {
   UseDevicePtrCombinedInfo.Pointers.push_back(Ptr);
   UseDevicePtrCombinedInfo.Sizes.push_back(
   llvm::Constant::getNullValue(CGF.Int64Ty));
-  UseDevicePtrCombinedInfo.Types.push_back(
-  OMP_MAP_RETURN_PARAM |
-  (NotTargetParams ? OMP_MAP_NONE : OMP_MAP_TARGET_PARAM));
+  UseDevicePtrCombinedInfo.Types.push_back(OMP_MAP_RETURN_PARAM);
   UseDevicePtrCombinedInfo.Mappers.push_back(nullptr);
 }
   }
@@ -8490,19 +8488,13 @@ class MappableExprsHandler {
   CombinedInfo.Pointers.push_back(Ptr);
   CombinedInfo.Sizes.push_back(
   llvm::Constant::getNullValue(CGF.Int64Ty));
-  CombinedInfo.Types.push_back(
-  OMP_MAP_RETURN_PARAM |
-  (NotTargetParams ? OMP_MAP_NONE : OMP_MAP_TARGET_PARAM));
+  CombinedInfo.Types.push_back(OMP_MAP_RETURN_PARAM);
   CombinedInfo.Mappers.push_back(nullptr);
 }
   }
 }
 
 for (const auto &M : Info) {
-  // We need to know when we generate information for the first component
-  // associated with a capture, because the mapping flags depend on it.
-  bool IsFirstComponentList = !NotTargetParams;
-
   // Underlying variable declaration used in the map clause.
   const ValueDecl *VD = std::get<0>(M);
 
@@ -8520,8 +8512,8 @@ class MappableExprsHandler {
 L.Components.back().isNonContiguous();
 generateInfoForComponentList(
 L.MapType, L.MapModifiers, L.MotionModifiers, L.Components, 
CurInfo,
-PartialStruct, IsFirstComponentList, L.IsImplicit, L.Mapper,
-L.ForDeviceAddr, VD, L.VarRef);
+PartialStruct, /*IsFirstComponentList=*/false, L.IsImplicit,
+L.Mapper, L.ForDeviceAddr, VD, L.VarRef);
 
 // If this entry relates with a device pointer, set the relevant
 // declaration and add the 'return pointer' flag.
@@ -8538,7 +8530,6 @@ class MappableExprsHandler {
 

[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:31
+#ifdef __OPENMP_NVPTX__
+#define DEVICE
+#else

You should use `__` prefix to avoid unintentional clashes with user-defined 
macros.
`__DEVICE__` ?



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:124
 #undef __CUDA_DISALLOW_BUILTINVAR_ACCESS
 #undef __DELETE
 

You need to `#undef` the DEVICE macro here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94941: Add minor version to libclang.so and libclang-cpp.so SONAME

2021-01-19 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

@sylvestre.ledru removed the minor version from the binary (on purpose, I 
think?) in rGa8b717fda42294d1c8e1f05d71280503e5839f14 
:

  commit a8b717fda42294d1c8e1f05d71280503e5839f14
  Author: Sylvestre Ledru 
  Date:   Thu Mar 29 10:05:46 2018 +
  
  Rename clang link from clang-X.Y to clang-X
  
  Summary:
  As we are only doing X.0.Z releases (not using the minor version), there 
is no need to keep -X.Y in the version.
  So, instead, I propose the following:
  Instead of having clang-7.0 in bin/, we will have clang-7
  
  Since also matches was gcc is doing.
  
  Reviewers: tstellar, dlj, dim, hans
  
  Reviewed By: dim, hans
  
  Subscribers: dim, mgorny, cfe-commits
  
  Differential Revision: https://reviews.llvm.org/D41808
  
  llvm-svn: 328769

But this seems to have been mainly about the clang executable that gets 
installed into `$prefix/bin`, i.e. `clang-11` instead of `clang-11.1`.

I think this doesn't matter for the clang executable here, since nobody uses 
its ABI. But indeed for the shared library it looks like a good solution, if 
you would want to install both versions side-by-side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94941

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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 2 inline comments as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:40
 
+#ifdef __cplusplus
 #define __CUDA_DEVICE_BUILTIN(FIELD, INTRINSIC)
\

tra wrote:
> Perhaps we should move all C++-related code under `#ifdef __cplusplus` intead 
> of cherry-picking them all one by one and let the compilation fail if some C 
> code references builtin vars.
Finally I decided to only include the header in C++ mode. For C mode, 
everything is unchanged, which means compilation error will still be emitted 
because the variables are not defined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 317647.
tianshilei1992 added a comment.

Refined the patch to make it only work in C++ mode. In C mode everything is 
unchanged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

Files:
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  clang/test/Headers/openmp_device_math_isnan.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp

Index: clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
===
--- clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fexceptions -fcxx-exceptions -aux-triple powerpc64le-unknown-unknown -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// 

[PATCH] D94854: [Clang] Fix SwiftCallingConv's aggregate lowering for _Atomic(_Bool).

2021-01-19 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple abandoned this revision.
varungandhi-apple added a comment.

Closing this in favor of a Swift-side fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94854

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


[PATCH] D93668: [clang] Override the Fuchsia platform ABI using the triple environment

2021-01-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D93668#2492081 , @phosek wrote:

> I agree that if we want to allow selecting C++ ABI only, a flag like 
> `-fc++abi=` with some additional checks to disallow invalid combinations is 
> better. The question is whether we want to allow that in the first place? The 
> motivation behind this change is to support generating code that's ABI 
> compatible with the code generated by GCC. That could be expressed using the 
> target triple (one idea is to use `*-*-fuchsia-gnu`), which would cover both 
> C++ ABI as well as other aspects of the ABI (for example it could also 
> disable SafeStack/ShadowCallStack) so developers don't need to concern 
> themselves with all the details of the ABI, which could evolve over time 
> expanding the set of flags you'd need to pass to the compiler to generate 
> code that's ABI compatible with GCC.

In the context of representing the fourth component of the triple to represent 
the *platform* ABI rather than exclusively the C++ ABI, I think this would make 
sense. Using this other component would essentially just mean adding another 
layer of default flag configurations whose default values differ from those set 
by the first three components. I think we'd only want to have this extra layer 
if we have a sizable number of flags that we'd want separate from the default 
triple.

For our case, I think this mainly includes

- the C++ ABI (which encompasses "return this" on ctors/dtors and relative 
vtables),
- SS/SCS
- and maybe the PIC-friendly lookup tables if that ends up getting hidden 
behind a switch

but there could be new ABI changes down the line that could fall under this (or 
others that exist now but don't come to mind right now). Unless I'm missing 
some other features, this list seems fairly small and might not be worth 
tucking this under something that's meant to control a set of flags, but if we 
care more about being preventative from adding new flags, then it seems fine to 
just stick with using the triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93668

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


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

tianshilei1992 wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > tianshilei1992 wrote:
> > > > > ABataev wrote:
> > > > > > jdoerfert wrote:
> > > > > > > tianshilei1992 wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > jdoerfert wrote:
> > > > > > > > > > ABataev wrote:
> > > > > > > > > > > I would add a chack that to auxiliary device was 
> > > > > > > > > > > specified. And if it was specified, it means this is not 
> > > > > > > > > > > device-only mode and still need to emit an error.
> > > > > > > > > > No it doesn't. There is nothing wrong with 
> > > > > > > > > > https://godbolt.org/z/T1h9b5, and as I said before, I can 
> > > > > > > > > > build the situation in various other ways as well, some of 
> > > > > > > > > > which will be outside of the users control. A global can 
> > > > > > > > > > exist in the host/device code only.
> > > > > > > > > I'm not saying that this is wrong. This code was used to 
> > > > > > > > > check that the compiler works correctly and it just allows 
> > > > > > > > > developer to understand that there is a problem with the 
> > > > > > > > > compiler if it misses something and there is a difference 
> > > > > > > > > between host and device codegens. If we don't want to emit an 
> > > > > > > > > error here, still would be good to have something like an 
> > > > > > > > > assert to be sure that the host/device codegens are synced.
> > > > > > > > That check still doesn't work for the test case provided by 
> > > > > > > > @jdoerfert because host IR doesn't contain that global in the 
> > > > > > > > offload info.
> > > > > > > As @tianshilei1992 says, my test case does show how this can 
> > > > > > > never be an assertion/warning even for regular host+device 
> > > > > > > compliation. There is no guarantee a host version exists, or a 
> > > > > > > device one does. We need to gracefully allow either.
> > > > > > So, this is caused by the `nohost` variant selector, right? In this 
> > > > > > case we don't emit it for the host and don't have corresponding 
> > > > > > entry in the metadata?
> > > > > Correct.
> > > > Ok, now I see. Is it possible to distinguish this corner case from the 
> > > > general one, where the variable is available for both, host and device, 
> > > > or it will require some extra work/design? If it is easy to 
> > > > differentiate these 2 cases, it would be good to keep something like an 
> > > > error message/assert for the general case and remove the restriction 
> > > > for this corner case. Otherwise, proceed with the current solution.
> > > FWIW, I can also use ifdef, or various other context selectors to achieve 
> > > the same effect.
> > Ok, then go ahead with this solution.
> I'm thinking we can probably set a new option to invoke device only 
> compilation, like `--cuda-device-only` we already had for CUDA. However, the 
> thing is, unlike CUDA, we cannot tell which parts are kernels implicitly w/o 
> host compilation. So if we provide the option, we might end up with only 
> recognizing code in `declare target` or all its variant.
I think the host part is not really required here. IIRC, it is used currently 
only to check that the host code and the device code are synced and device part 
matches the host codegen. If we need device-only codegen, we can just turn off 
this check. At least, you can try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D90188: Add support for attribute 'using_if_exists'

2021-01-19 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/test/SemaCXX/using-if-exists.cpp:11
+
+using NotNS::x UIE; // expected-error{{use of undeclared identifier 'NotNS'}}
+} // test_basic

Do you also have a test for `using NS::NotNS::x UIE;`?
(Both of these `NotNS` tests produce hard errors; `[[using_if_exists]]` does 
the silent-ignore thing only when the tippymost identifier is nonexistent, not 
if some intermediate name is nonexistent. This seems reasonable enough.)



Comment at: clang/test/SemaCXX/using-if-exists.cpp:60
+  typedef int mt;
+};
+

An inheritance case not yet covered here errors out with `error: no matching 
constructor for initialization of 'Derived'`:
```
struct Base { Base(int); };
template struct Derived : T {
using T::T [[clang::using_if_exists]];
};
Derived d(1);
```
Does this make sense? Should this attribute perhaps give a hard error if you 
try to use it to inherit a constructor overload set like this, instead of 
(apparently) just no-opping the construct?



Comment at: clang/test/SemaCXX/using-if-exists.cpp:79
+  using B::mf UIE; // expected-note {{using declaration annotated with 
'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note 2 {{using declaration annotated 
with 'using_if_exists' here}}
+

I notice there's a hard `error: 'using_if_exists' attribute cannot be applied 
to types` on

using B::operator int UIE;

Any thoughts on how to disambiguate that grammar?



Comment at: clang/test/SemaCXX/using-if-exists.cpp:107
+  using typename Ts::x... UIE; // expected-error 2 {{target of using 
declaration conflicts with declaration already in scope}} 
expected-note{{conflicting declaration}} expected-note{{target of using 
declaration}}
+};
+

This is a very good test, but it feels to me as if
```
struct B { static int f(int); };
struct C { };
template struct D : Ts... {
using Ts::f... [[clang::using_if_exists]];
};
int main() { D::f(1); }
```
ought to be //at least// as well-formed as
```
struct B { static int f(int); };
struct C { static void f(); };
template struct D : Ts... {
using Ts::f... [[clang::using_if_exists]];
};
int main() { D::f(1); }
```
I guess what's going on here is that an "unresolved using decl" is considered a 
separate kind of entity, i.e. `using Ts::f...` will work if //all// `Ts::f...` 
are variables, or if //all// of them are functions, or if //all// of them are 
unresolved, but it doesn't work if you have a mix of variables and functions, 
or variables and unresolveds, or functions and unresolveds. Is that basically 
correct, and intended? 



Comment at: clang/test/SemaCXX/using-if-exists.cpp:199
+using ::fopen UIE; // expected-note {{using declaration annotated with 
'using_if_exists' here}}
+using ::size_t UIE; // expected-note {{using declaration annotated with 
'using_if_exists' here}}
+}

IMHO this test would be clearer if it used obviously fake names, e.g. `using 
::fake_FILE`, `using ::fake_printf`, etc.


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

https://reviews.llvm.org/D90188

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


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 6 inline comments as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > tianshilei1992 wrote:
> > > > ABataev wrote:
> > > > > jdoerfert wrote:
> > > > > > tianshilei1992 wrote:
> > > > > > > ABataev wrote:
> > > > > > > > jdoerfert wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > I would add a chack that to auxiliary device was specified. 
> > > > > > > > > > And if it was specified, it means this is not device-only 
> > > > > > > > > > mode and still need to emit an error.
> > > > > > > > > No it doesn't. There is nothing wrong with 
> > > > > > > > > https://godbolt.org/z/T1h9b5, and as I said before, I can 
> > > > > > > > > build the situation in various other ways as well, some of 
> > > > > > > > > which will be outside of the users control. A global can 
> > > > > > > > > exist in the host/device code only.
> > > > > > > > I'm not saying that this is wrong. This code was used to check 
> > > > > > > > that the compiler works correctly and it just allows developer 
> > > > > > > > to understand that there is a problem with the compiler if it 
> > > > > > > > misses something and there is a difference between host and 
> > > > > > > > device codegens. If we don't want to emit an error here, still 
> > > > > > > > would be good to have something like an assert to be sure that 
> > > > > > > > the host/device codegens are synced.
> > > > > > > That check still doesn't work for the test case provided by 
> > > > > > > @jdoerfert because host IR doesn't contain that global in the 
> > > > > > > offload info.
> > > > > > As @tianshilei1992 says, my test case does show how this can never 
> > > > > > be an assertion/warning even for regular host+device compliation. 
> > > > > > There is no guarantee a host version exists, or a device one does. 
> > > > > > We need to gracefully allow either.
> > > > > So, this is caused by the `nohost` variant selector, right? In this 
> > > > > case we don't emit it for the host and don't have corresponding entry 
> > > > > in the metadata?
> > > > Correct.
> > > Ok, now I see. Is it possible to distinguish this corner case from the 
> > > general one, where the variable is available for both, host and device, 
> > > or it will require some extra work/design? If it is easy to differentiate 
> > > these 2 cases, it would be good to keep something like an error 
> > > message/assert for the general case and remove the restriction for this 
> > > corner case. Otherwise, proceed with the current solution.
> > FWIW, I can also use ifdef, or various other context selectors to achieve 
> > the same effect.
> Ok, then go ahead with this solution.
I'm thinking we can probably set a new option to invoke device only 
compilation, like `--cuda-device-only` we already had for CUDA. However, the 
thing is, unlike CUDA, we cannot tell which parts are kernels implicitly w/o 
host compilation. So if we provide the option, we might end up with only 
recognizing code in `declare target` or all its variant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94987: DR39: Perform ambiguous subobject checks for class member access as part of object argument conversion, not as part of name lookup.

2021-01-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

(I didn't mean to submit the last comment before I finished the review, sorry)

It looks like you've chosen to treat this as a DR that we should apply under 
all standards.  Have you investigated whether it causes compatibility problems? 
 It does look like it'd be painful to try to support both rules.




Comment at: clang/lib/Sema/SemaAccess.cpp:891
+// Note that declaresSameEntity doesn't correctly determine whether
+// two type declarations declare the same type entity.
+if ((!Best || Best->getAccess() > Corresponding->getAccess()) &&

Is it okay to check them in sequence like this, or do we need to check in 
advance which case to use?



Comment at: clang/lib/Sema/SemaAccess.cpp:983
+  }
+  return false;
+};

Is this not doing a *lot* of extra work?  I suppose this is only in the slow 
path where we weren't able to immediately recognize that the found decl is 
public or we're in a scope with obviously adequate access?



Comment at: clang/lib/Sema/SemaLookup.cpp:2296
+  }
+}
+

I wonder under this new model if we can record that we saw something along 
ambiguous paths and avoid a lot of work in access-checking in the common case 
where we don't?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94987

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


[PATCH] D85223: [CUDA][HIP] Support accessing static device variable in host code for -fgpu-rdc

2021-01-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I'd propose splitting the patch into two. One with the addition of CUID and the 
other that changes the way we havdle static vars.
CUID is useful on its own and is relatively uncontroversial.

Externalizing static vars is a more interesting issue and I'm not sure what's 
the best way to handle it yet. On one hand it is necessary for visibility 
across host/device, on the other, externalizing all static vars will almost 
always have negative effect as very few of the static vars actually need this. 
As already pointed out in the `#if 0` section of the patch, ideally we should 
externalize only the vars that need it. Generally speaking, I do not think we 
will be able to do that, because with `-fgpu-rdc` it may be used from the host 
code in some other TU.

We may need to explicitly annotate such the static variables that need to be 
visible on both sides and only apply externalization to the variables annotated 
this way. E.g. require them to be `__host__ __device__`.

WDYT?


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

https://reviews.llvm.org/D85223

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


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-19 Thread Shilei Tian via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82e537a9d28a: [Clang][OpenMP] Fixed an issue that clang 
crashed when compiling OpenMP program… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp


Index: clang/test/OpenMP/declare_target_device_only_compilation.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,16 +2941,12 @@
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum)) {
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "Unable to find target region on line '%0' in the device code.");
-  CGM.getDiags().Report(DiagID) << LineNum;
-  return;
-}
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);
 auto &Entry =
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum];
-assert(Entry.isValid() && "Entry not initialized!");
 Entry.setAddress(Addr);
 Entry.setID(ID);
 Entry.setFlags(Flags);
@@ -3017,9 +3013,10 @@
  OMPTargetGlobalVarEntryKind Flags,
  llvm::GlobalValue::LinkageTypes Linkage) {
   if (CGM.getLangOpts().OpenMPIsDevice) {
+// This could happen if the device compilation is invoked standalone.
+if (!hasDeviceGlobalVarEntryInfo(VarName))
+  initializeDeviceGlobalVarEntryInfo(VarName, Flags, OffloadingEntriesNum);
 auto &Entry = OffloadEntriesDeviceGlobalVar[VarName];
-assert(Entry.isValid() && Entry.getFlags() == Flags &&
-   "Entry not initialized!");
 assert((!Entry.getAddress() || Entry.getAddress() == Addr) &&
"Resetting with the new address.");
 if (Entry.getAddress() && hasDeviceGlobalVarEntryInfo(VarName)) {


Index: clang/test/OpenMP/declare_target_device_only_compilation.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,16 +2941,12 @@
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, Pare

[clang] 82e537a - [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-19 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-01-19T14:18:42-05:00
New Revision: 82e537a9d28a2c18bd1637e2eac0e0af658ed829

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

LOG: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP 
program in device only mode without host IR

D94745 rewrites the `deviceRTLs` using OpenMP and compiles it by directly
calling the device compilation. `clang` crashes because entry in
`OffloadEntriesDeviceGlobalVar` is unintialized. Current design supposes the
device compilation can only be invoked after host compilation with the host IR
such that `clang` can initialize `OffloadEntriesDeviceGlobalVar` from host IR.
This avoids us using device compilation directly, especially when we only have
code wrapped into `declare target` which are all device code. The same issue
also exists for `OffloadEntriesInfoManager`.

In this patch, we simply initialized an entry if it is not in the maps. Not sure
we need an option to tell the device compiler that it is invoked standalone.

Reviewed By: jdoerfert

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

Added: 
clang/test/OpenMP/declare_target_device_only_compilation.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a3b24039365b..17fa56fb06c8 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,16 +2941,12 @@ void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum)) {
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "Unable to find target region on line '%0' in the device code.");
-  CGM.getDiags().Report(DiagID) << LineNum;
-  return;
-}
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);
 auto &Entry =
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum];
-assert(Entry.isValid() && "Entry not initialized!");
 Entry.setAddress(Addr);
 Entry.setID(ID);
 Entry.setFlags(Flags);
@@ -3017,9 +3013,10 @@ void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
  OMPTargetGlobalVarEntryKind Flags,
  llvm::GlobalValue::LinkageTypes Linkage) {
   if (CGM.getLangOpts().OpenMPIsDevice) {
+// This could happen if the device compilation is invoked standalone.
+if (!hasDeviceGlobalVarEntryInfo(VarName))
+  initializeDeviceGlobalVarEntryInfo(VarName, Flags, OffloadingEntriesNum);
 auto &Entry = OffloadEntriesDeviceGlobalVar[VarName];
-assert(Entry.isValid() && Entry.getFlags() == Flags &&
-   "Entry not initialized!");
 assert((!Entry.getAddress() || Entry.getAddress() == Addr) &&
"Resetting with the new address.");
 if (Entry.getAddress() && hasDeviceGlobalVarEntryInfo(VarName)) {

diff  --git a/clang/test/OpenMP/declare_target_device_only_compilation.cpp 
b/clang/test/OpenMP/declare_target_device_only_compilation.cpp
new file mode 100644
index ..280959540306
--- /dev/null
+++ b/clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}



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


[clang] e678656 - Add bounds checking assertions to APValue, NFC

2021-01-19 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2021-01-19T11:15:02-08:00
New Revision: e678656625a3e2b6a5f2849f4a6f7612ceeaed07

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

LOG: Add bounds checking assertions to APValue, NFC

These checks help find llvm.org/pr48582 without ASan

Added: 


Modified: 
clang/include/clang/AST/APValue.h

Removed: 




diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index f9b189926c76..5f4ac02f53c9 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -537,10 +537,12 @@ class APValue {
   }
   APValue &getStructBase(unsigned i) {
 assert(isStruct() && "Invalid accessor");
+assert(i < getStructNumBases() && "base class index OOB");
 return ((StructData *)(char *)&Data)->Elts[i];
   }
   APValue &getStructField(unsigned i) {
 assert(isStruct() && "Invalid accessor");
+assert(i < getStructNumFields() && "field index OOB");
 return ((StructData *)(char *)&Data)->Elts[getStructNumBases() + i];
   }
   const APValue &getStructBase(unsigned i) const {



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


[clang] 6f69f2e - Consider ASan messages interesting for creduce

2021-01-19 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2021-01-19T11:15:02-08:00
New Revision: 6f69f2ed61ae805df496fc86ef22e7685573d556

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

LOG: Consider ASan messages interesting for creduce

Helped me reduce llvm.org/pr48582

Added: 


Modified: 
clang/utils/creduce-clang-crash.py

Removed: 




diff  --git a/clang/utils/creduce-clang-crash.py 
b/clang/utils/creduce-clang-crash.py
index cdc639c6f854..51f4d9d333bc 100755
--- a/clang/utils/creduce-clang-crash.py
+++ b/clang/utils/creduce-clang-crash.py
@@ -134,7 +134,8 @@ def read_expected_output(self):
r"UNREACHABLE executed at .+?!",
r"LLVM IR generation of declaration '.+'",
r"Generating code for declaration '.+'",
-   r"\*\*\* Bad machine code: .+ \*\*\*"]
+   r"\*\*\* Bad machine code: .+ \*\*\*",
+   r"ERROR: .*Sanitizer: [^ ]+ "]
 for msg_re in regexes:
   match = re.search(msg_re, crash_output)
   if match:



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


[PATCH] D94987: DR39: Perform ambiguous subobject checks for class member access as part of object argument conversion, not as part of name lookup.

2021-01-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

How does this new rule work if we find overlapping but non-equal sets of 
declarations in different subobjects?  I'm sure you can get that with `using` 
declarations.




Comment at: clang/include/clang/AST/CXXInheritance.h:77
 
-  CXXBasePath() = default;
+  /// Additional data stashed on the base path by its consumers.
+  union {

Is there a way to know which case we're in, or do different consumers do 
different things?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94987

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-01-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGCleanup.cpp:1341
+  llvm::FunctionCallee SehCppScope =
+  CGM.CreateRuntimeFunction(FTy, "llvm.seh.scope.begin");
+  EmitSehScope(*this, SehCppScope);

We generally prefer to get intrinsic functions with `CGM.getIntrinsic`.



Comment at: clang/lib/CodeGen/CGException.cpp:465
 if (const CapturedDecl* CD = dyn_cast_or_null(D)) {
-  if (CD->isNothrow())
+  if (CD->isNothrow() && !getLangOpts().EHAsynch /* !IsEHa */)
 EHStack.pushTerminate();

Please remove the comment here.  The option name should be sufficiently 
self-descriptive.

Anyway, I don't think this change is right, because we *do* still need to push 
a terminate scope: we need C++ exceptions to trigger a call to 
`std::terminate`.  It's just that such scopes aren't fully terminal when async 
exceptions are enabled, because MSVC defines those exceptions as passing 
through `noexcept` and so on.  (I assume that's true; can you link to 
documentation about it?)



Comment at: clang/lib/CodeGen/CGException.cpp:554
+  if (isNoexceptExceptionSpec(EST) && Proto->canThrow() == CT_Cannot &&
+  !EHStack.empty() /* possible empty when -EHa */) {
 EHStack.popTerminate();

Again, please try to refer to this in a more driver-agnostic way: "under async 
exceptions" rather than "when -EHa".  But actually as mentioned above I think 
this is incorrect.



Comment at: clang/lib/CodeGen/CGException.cpp:1668
+  } else if (isa(J)) {
+auto *MCI = cast(J);
+MCI->setVolatile(llvm::ConstantInt::get(Builder.getInt1Ty(), 1));

Please use `dyn_cast` for all of these.



Comment at: clang/lib/CodeGen/CGException.cpp:1678
+  VolatilizeTryBlocks(TI->getSuccessor(I), V);
+  }
+}

Volatilizing every block that's reachable from the `try` block seems like it 
makes a lot of assumptions about where branches within the `try` can reach.  
For example, a `goto` could certainly go to a block that's already been 
emitted, as could `break` or `continue` if the emitter just makes slightly 
different decisions about emission order.  Please look at how `FragileHazards` 
(in the ObjC emission code) collects blocks in order to do its transforms — I 
think you can probably extract a reasonable common base out.  Alternatively, I 
think you could handle this directly in the insertion callback 
(`CodeGenFunction::InsertHelper`) when we're in an appropriate `try` scope.



Comment at: clang/lib/CodeGen/CGException.cpp:603
+
+  //  For IsEHa catch(...) must handle HW exception
+  //  Adjective = HT_IsStdDotDot (0x40), only catch C++ exceptions

asmith wrote:
> nit - extra space after //
The comment here isn't explaining anything, it's just repeating what the code 
is doing.  If you want a useful comment, you could explain why it's important 
to mark the scope.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6584
+if (EH.Asynch)
+  CmdArgs.push_back("-feh-asynch");
   }

For consistency with the existing options, please spell this option 
`-fasync-exceptions`, and please spell the corresponding LangOption 
`AsyncExceptions`.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2786
   Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
+  Opts.EHAsynch = Args.hasArg(OPT_feh_asynch);
 

You should emit an error if this is enabled on targets that are not in the 
appropriate Windows environment, since we don't (yet) support it there.  I 
assume that's just the MSVC Windows environment and that this can't easily be 
supported on e.g. MinGW?

Does it have other target restrictions, like i386-only?



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:935
+LabelStmt *Label = cast(To);
+Label->setSideEntry(true);
   }

This doesn't seem like a reasonable assertion in the abstract.  Even if we 
really only currently emit warnings with jumps to labels, that doesn't seem 
like something we should write code that relies on.  And I'm sure this problem 
can come up with switch cases, unless that's structurally outlawed in some 
other way.

Also, you're making the correct setting of this flag dependent on whether we're 
emitting a warning vs. an error.  Seems like we should be setting it regardless.

What conditions exactly do you want this flag set on?  I would naturally assume 
it's specifically branches from a block outside the `try`, and you don't care 
about branches within the `try`?  If the label is used in multiple places, do 
you need to be careful to only set the flag on those branches that come from 
outside the `try`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

_

[clang] 987760b - [www] Fix background color in table cell.

2021-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-19T11:04:31-08:00
New Revision: 987760b463c1303121fff8197c4ebc66b61f0616

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

LOG: [www] Fix background color in table cell.

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 923b13db73a6..685f32dbe0d3 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1005,7 +1005,7 @@ C++20 implementation status
 
   Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Clang 12
+  Clang 12
 

 https://wg21.link/p1907r1";>P1907R1



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


[PATCH] D93585: [AArch64] Enable out-of-line atomics by default.

2021-01-19 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:1087
  FeatureNEON,
+ FeatureOutlineAtomics,
  FeaturePerfMon,

ilinpv wrote:
> t.p.northover wrote:
> > I think this still enables it more widely than we want. Clang overrides it 
> > with `-outline-atomics`, but other front-ends don't.
> Could I ask you to clarify what front-ends you meant (to check outline 
> atomics suport for them)?
Any front-end that generates LLVM IR. Generally important ones are Swift and 
Rust, but there are many more and I kind of doubt it's feasible to ensure they 
all will. It's unfortunate, and maybe at some point we can put logic in LLVM to 
approximate Clang's decision-making and get the benefit without any opt-in, but 
I kind of think it's a bit early yet. We'd risk breaking too many people's 
builds.

Also, putting it in the generic CPU model here means that if a front-end allows 
something like `-mcpu=cortex-a57` it will suddenly disable outlined atomics. 
Whether they're good or bad, that's just plain weird behaviour. A CPU-level 
feature isn't the right place for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:40
 
+#ifdef __cplusplus
 #define __CUDA_DEVICE_BUILTIN(FIELD, INTRINSIC)
\

Perhaps we should move all C++-related code under `#ifdef __cplusplus` intead 
of cherry-picking them all one by one and let the compilation fail if some C 
code references builtin vars.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:48
+#else
+#define __CUDA_DEVICE_BUILTIN(FIELD, INTRINSIC) unsigned int FIELD;
+#endif

Can we generate a sensible error instead?
I'd rather fail in an obvious way during compilation than compile successfully 
into somethings that will not do what the user expected.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94599: [clang][Tooling] Get rid of a hack in SymbolOccurrences, NFCI

2021-01-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 317627.
miyuki edited the summary of this revision.
miyuki added a comment.

Added `static_assert`s that check that `SourceRange` and `SourceLocation` are 
trivially destructible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94599

Files:
  clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp


Index: clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
+++ clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
@@ -21,13 +21,12 @@
  "mismatching number of locations and lengths");
   assert(!Locations.empty() && "no locations");
   if (Locations.size() == 1) {
-RangeOrNumRanges = SourceRange(
+new (&SingleRange) SourceRange(
 Locations[0], Locations[0].getLocWithOffset(NamePieces[0].size()));
 return;
   }
   MultipleRanges = std::make_unique(Locations.size());
-  RangeOrNumRanges.setBegin(
-  SourceLocation::getFromRawEncoding(Locations.size()));
+  NumRanges = Locations.size();
   for (const auto &Loc : llvm::enumerate(Locations)) {
 MultipleRanges[Loc.index()] = SourceRange(
 Loc.value(),
Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -42,6 +42,14 @@
 // SourceLocation
 
//===--===//
 
+static_assert(std::is_trivially_destructible::value,
+  "SourceLocation must be trivially destructible because it is "
+  "used in unions");
+
+static_assert(std::is_trivially_destructible::value,
+  "SourceRange must be trivially destructible because it is "
+  "used in unions");
+
 unsigned SourceLocation::getHashValue() const {
   return llvm::DenseMapInfo::getHashValue(ID);
 }
Index: clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
===
--- clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
+++ clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
@@ -69,17 +69,18 @@
   OccurrenceKind getKind() const { return Kind; }
 
   ArrayRef getNameRanges() const {
-if (MultipleRanges) {
-  return llvm::makeArrayRef(MultipleRanges.get(),
-RangeOrNumRanges.getBegin().getRawEncoding());
-}
-return RangeOrNumRanges;
+if (MultipleRanges)
+  return llvm::makeArrayRef(MultipleRanges.get(), NumRanges);
+return SingleRange;
   }
 
 private:
   OccurrenceKind Kind;
   std::unique_ptr MultipleRanges;
-  SourceRange RangeOrNumRanges;
+  union {
+SourceRange SingleRange;
+unsigned NumRanges;
+  };
 };
 
 using SymbolOccurrences = std::vector;


Index: clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
+++ clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
@@ -21,13 +21,12 @@
  "mismatching number of locations and lengths");
   assert(!Locations.empty() && "no locations");
   if (Locations.size() == 1) {
-RangeOrNumRanges = SourceRange(
+new (&SingleRange) SourceRange(
 Locations[0], Locations[0].getLocWithOffset(NamePieces[0].size()));
 return;
   }
   MultipleRanges = std::make_unique(Locations.size());
-  RangeOrNumRanges.setBegin(
-  SourceLocation::getFromRawEncoding(Locations.size()));
+  NumRanges = Locations.size();
   for (const auto &Loc : llvm::enumerate(Locations)) {
 MultipleRanges[Loc.index()] = SourceRange(
 Loc.value(),
Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -42,6 +42,14 @@
 // SourceLocation
 //===--===//
 
+static_assert(std::is_trivially_destructible::value,
+  "SourceLocation must be trivially destructible because it is "
+  "used in unions");
+
+static_assert(std::is_trivially_destructible::value,
+  "SourceRange must be trivially destructible because it is "
+  "used in unions");
+
 unsigned SourceLocation::getHashValue() const {
   return llvm::DenseMapInfo::getHashValue(ID);
 }
Index: clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
===
--- clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
+++ clang/include/clang/Tooling/Refact

[PATCH] D94987: DR39: Perform ambiguous subobject checks for class member access as part of object argument conversion, not as part of name lookup.

2021-01-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: rjmccall.
rsmith requested review of this revision.
Herald added a project: clang.

Under C++ core issue 39, the rules for class-scope name lookup were reworked so
that name lookup no longer concerns itself with whether the names were found in
an ambiguous subobject.  The checks for an ambiguous subobject are now done as
part of conversion of the object argument in a member access (if needed)
instead.

One other important consequence of the new lookup rule is that it's now OK to
find different lookup results in multiple different classes, so long as the
same set of entities is found in each case (in any order, perhaps with
duplicates, and in the type case, perhaps via unrelated typedef declarations).

This patch implements the new lookup rule. This also has some follow-on impact
on access checks: it's now OK for name lookup to find different member
declarations in different base classes so long as they all resolve to the same
set of entities, so we now need to compute what the corresponding found
declaration is, and access-check it, for each path independently.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94987

Files:
  clang/include/clang/AST/CXXInheritance.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/DelayedDiagnostic.h
  clang/include/clang/Sema/Lookup.h
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/CXX/class.derived/class.member.lookup/p6.cpp
  clang/test/CXX/class.derived/class.member.lookup/p8.cpp
  clang/test/CXX/class.derived/class.member.lookup/p9.cpp
  clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp
  clang/test/CXX/drs/dr0xx.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/drs/dr4xx.cpp
  clang/test/CXX/temp/temp.res/temp.local/p3.cpp
  clang/test/SemaCXX/access.cpp
  clang/test/SemaCXX/lookup-member.cpp
  clang/test/SemaCXX/member-name-lookup.cpp
  clang/test/SemaCXX/microsoft-dtor-lookup.cpp
  clang/test/SemaCXX/new-delete.cpp
  clang/test/SemaTemplate/dependent-base-classes.cpp
  clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
  clang/test/SemaTemplate/temp.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -272,7 +272,7 @@
 https://wg21.link/cwg39";>39
 CD1
 Conflicting ambiguity rules
-No
+Clang 12
   
   
 https://wg21.link/cwg40";>40
@@ -1876,7 +1876,7 @@
 https://wg21.link/cwg306";>306
 CD1
 Ambiguity by class name injection
-Duplicate of 39
+Duplicate of 39
   
   
 https://wg21.link/cwg307";>307
Index: clang/test/SemaTemplate/temp.cpp
===
--- clang/test/SemaTemplate/temp.cpp
+++ clang/test/SemaTemplate/temp.cpp
@@ -12,7 +12,7 @@
   namespace B { template struct Base { typedef T t; }; } // expected-note {{member type 'test1::B::Base' found}}
 
   template struct Derived : A::Base, B::Base {
-typename Derived::Base::t x; // expected-error {{found in multiple base classes of different types}}
+typename Derived::Base::t x; // expected-error {{found in multiple base classes}}
   };
 
   class X : A::Base {}; // expected-note 2{{private}}
@@ -41,10 +41,10 @@
   template struct X : T... {};
 
   void f() {
-X::x(); // expected-error {{found in multiple base classes of different types}}
-X::x(); // expected-error {{found in multiple base classes of different types}}
-X::x(); // expected-error {{found in multiple base classes of different types}}
-X::x(); // expected-error {{found in multiple base classes of different types}}
-X::x(); // expected-error {{found in multiple base classes of different types}}
+X::x(); // expected-error {{found in multiple base classes}}
+X::x(); // expected-error {{found in multiple base classes}}
+X::x(); // expected-error {{found in multiple base classes}}
+X::x(); // expected-error {{found in multiple base classes}}
+X::x(); // expected-error {{found in multiple base classes}}
   }
 }
Index: clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
===
--- clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -307,7 +307,7 @@
 template  struct A { typedef T NameFromBase; }; // expected-note {{member type 'int' found by ambiguous name lookup}}
 template  struct B { struct NameFromBase { T m; }; }; // expected-note {{member type 'two_types_in_base::B::NameFromBase' found by ambiguous name lookup}}
 template  struct C : A, B {
-  NameFromBase m; // expected-error {{member 'NameFromBase' found in multiple base classes of different types}} expected-warning {{use of member 'NameFromBase' found via unqualified lookup into dependent bases of

[PATCH] D94927: [clangd] Use ASTSignals in Heuristics CC Ranking.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17846ed5af4a: [clangd] Use ASTSignals in Heuristics CC 
Ranking. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94927

Files:
  clang-tools-extra/clangd/Quality.cpp


Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  // Use a sigmoid style boosting function similar to `References`, which flats
+  // out nicely for large values. This avoids a sharp gradient for heavily
+  // referenced symbols. Use smaller gradient for ScopeRefsInFile since ideally
+  // MainFileRefs <= ScopeRefsInFile.
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 


Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  // Use a sigmoid style boosting function similar to `References`, which flats
+  // out nicely for large values. This avoids a sharp gradient for heavily
+  // referenced symbols. Use smaller gradient for ScopeRefsInFile since ideally
+  // MainFileRefs <= ScopeRefsInFile.
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 17846ed - [clangd] Use ASTSignals in Heuristics CC Ranking.

2021-01-19 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2021-01-19T19:48:42+01:00
New Revision: 17846ed5af4a83334ef7d07f0b4a9d525e6ec0db

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

LOG: [clangd] Use ASTSignals in Heuristics CC Ranking.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 1c41b7c7661f..b49392bc7d04 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@ float SymbolRelevanceSignals::evaluateHeuristics() const {
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  // Use a sigmoid style boosting function similar to `References`, which flats
+  // out nicely for large values. This avoids a sharp gradient for heavily
+  // referenced symbols. Use smaller gradient for ScopeRefsInFile since ideally
+  // MainFileRefs <= ScopeRefsInFile.
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 



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


[PATCH] D94986: Remove requirement for -maltivec to be used when using -mabi=vec-extabi or -mabi=vec-default when not using vector code

2021-01-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: cebowleratibm, hubert.reinterpretcast, sfertile, 
Xiangling_L, etiotto.
ZarkoCA requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If we are not using vector code `-maltivec` should not be required. The 
previous implementation requirement that `-maltivec` is used even in cases 
where the compiler generated vector instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94986

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/altivec.c


Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -8,17 +8,9 @@
 // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple 
powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
  
 // RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: not %clang -S -emit-llvm -maltivec -target powerpc-unknown-aix %s 2>&1 
| FileCheck %s --check-prefix=AIX-ERROR
 // RUN: not %clang -S -emit-llvm -maltivec -target powerpc64-unknown-aix %s 
2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-default -target powerpc-unknown-aix %s 2>&1  | 
FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-extabi -target powerpc-unknown-aix %s 2>&1  | 
FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-default -target powerpc64-unknown-aix %s 2>&1  
| FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-extabi -target powerpc64-unknown-aix %s 2>&1  
| FileCheck  %s --check-prefix=AIX-ATVER
 // Check initialization
 
 vector int test0 = (vector int)(1);   // CHECK: @test0 ={{.*}} global <4 x 
i32> 
@@ -63,4 +55,3 @@
 }
 
 // AIX-ERROR:  error: The default Altivec ABI on AIX is not yet supported, use 
'-mabi=vec-extabi' for the extended Altivec ABI
-// AIX-ATVER:  error: '-mabi=vec-extabi' and '-mabi=vec-default' require 
'-maltivec'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4666,8 +4666,8 @@
 if (!Triple.isOSAIX())
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << RawTriple.str();
-if (!Args.hasArg(options::OPT_maltivec))
-  D.Diag(diag::err_aix_altivec);
+if (Args.hasArg(options::OPT_mabi_EQ_vec_default))
+  D.Diag(diag::err_aix_default_altivec_abi);
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -536,6 +536,4 @@
 
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
-
-def err_aix_altivec : Error<"'-mabi=vec-extabi' and '-mabi=vec-default' 
require '-maltivec'">;
 }


Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -8,17 +8,9 @@
 // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
  
 // RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: not %clang -S -emit-llvm -maltivec -target powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
 // RUN: not %clang -S -emit-llvm -maltivec -target powerpc64-unknown-aix %s 2>&1 |

[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-01-19 Thread C. Bland via Phabricator via cfe-commits
blandcr added a comment.

Hi, this is a pretty desirable feature for me and I see there hasn't been any 
work for a few months. Is this still being worked on and/or is there anything I 
can do to help it along?


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

https://reviews.llvm.org/D33029

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


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Thanks for putting your time into the comment, @dexonsmith.

I agree that adding a `-round-trip-args` flag to enable/disable round-tripping 
is more sensible than hard-coding it via something like `#ifndef NDEBUG`.
Providing `-round-trip-args-debug-mode` to help with debugging would be a great 
addition too. Thanks for pointing that out.

I would be interested to hear why exactly are you concerned by the current 
approach being too low level.
From my point of view, having to opt-in into round-tripping a part of 
`CompilerInvocation` is a feature and I think it should work relatively well 
with the current roll-out plan:

1. Write documentation on porting existing options to the new marshalling 
system.
2. Send a message to the mailing list pointing out that we'll be enabling 
round-tripping in assert builds by default and what that means. Downstream 
projects can prepare to port their custom options or disable the round-tripping 
in assert builds.
3. Some time later, commit this patch. Downstream projects already have enough 
information how to deal with the change. Because we've enabled round-tripping 
only for `HeaderSearchOptions`, adopting it isn't that time-consuming if a 
downstream project decides to do so.
4. (Any patches that add a command line option affecting `HeaderSearchOptions` 
will from now on be forced to include the generating/marshalling code.)
5. Slowly commit following patches, each enabling round-tripping for another 
chunk of `CompilerInvocation`.
6. After round-tripping has been enabled for all of `CompilerInvocation`, 
simplify the code (remove `ParseHS`, `GenerateHS`, `ResetHS`, etc.) and 
round-trip everything (when told to do so with `-round-trip-args`).

I'd be interested in hearing your thoughts on that ^.

To help me understand the reasoning behind your proposal, can you answer these 
questions?

1. What is the benefit or "relaxed" round-tripping compared to the selective 
strict round-tripping in this patch?
2. What does `GeneratedArgs1 != GeneratedArgs2` prove? If we forget to generate 
some option, it will be in neither `GeneratedArgs1` nor `GeneratedArgs2`. We'll 
catch that only in "strict" mode anyways. I guess this can help us discover 
other kinds of lossy generation, but I think the guarantees of "strict" mode 
are nicer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D94927: [clangd] Use ASTSignals in Heuristics CC Ranking.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 317613.
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Added a comment about the calculation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94927

Files:
  clang-tools-extra/clangd/Quality.cpp


Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  // Use a sigmoid style boosting function similar to `References`, which flats
+  // out nicely for large values. This avoids a sharp gradient for heavily
+  // referenced symbols. Use smaller gradient for ScopeRefsInFile since ideally
+  // MainFileRefs <= ScopeRefsInFile.
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 


Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  // Use a sigmoid style boosting function similar to `References`, which flats
+  // out nicely for large values. This avoids a sharp gradient for heavily
+  // referenced symbols. Use smaller gradient for ScopeRefsInFile since ideally
+  // MainFileRefs <= ScopeRefsInFile.
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94979: [CGExpr] Honor getCharWidth() in ConstantAggregateBuilderUtils

2021-01-19 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In D94979#2507242 , @lebedev.ri wrote:

> As far as i recall, all RFC's about LLVM support for non-8-bit char targets 
> didn't end in favor of the proposal
> I'd say that until there's general consensus/buy-in (including testing path), 
> cleaning stuff up will only confuse things.
> CC @jfb

Well, I haven't even added reviewers. But if it hurts so much maybe I should 
abandon it ;-)

But from my point of view this patch isn't really adding non-8-bit char 
support. But there is an abstraction in clang (such as ASTContext) with 
getCharWidth(), toCharUnitsFromBits() etc. And it is confusing when things 
don't add up (such as calculating the number of chars using 
toCharUnitsFromBits(), indirectly using getCharWidth(), and then later ignoring 
it and assuming that the char width is 8. I don't see how being more consistent 
is more confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94979

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


[PATCH] D94979: [CGExpr] Honor getCharWidth() in ConstantAggregateBuilderUtils

2021-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added subscribers: jfb, lebedev.ri.
lebedev.ri added a comment.

As far as i recall, all RFC's about LLVM support for non-8-bit char targets 
didn't end in favor of the proposal
I'd say that until there's general consensus/buy-in (including testing path), 
cleaning stuff up will only confuse things.
CC @jfb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94979

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


[PATCH] D94624: PATCH] [clang-query] Add a --use-color option to clang-query to allow forcing the behavior

2021-01-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D94624#2506906 , @tomrittervg wrote:

> In D94624#2506831 , @aaron.ballman 
> wrote:
>
>> In D94624#2501894 , @tomrittervg 
>> wrote:
>>
>>> I started trying to work on a patch, but I'm still unpacking from a move 
>>> and don't have all my machines set up - trying to enable and build tests 
>>> filled up my hard drive (even after I removed the easy-to-remove stuff), so 
>>> I don't think I'm going to be able to create a test for this in the 
>>> short-term.
>>
>> Okay, I think this LGTM even without the test coverage. Thank you for the 
>> patch, do you need someone to commit it on your behalf?
>
> Yes, please.

I'm not certain why, but the patch is not applying to a fresh pull for me.

  F:\llvm-project>git apply "F:\Aaron Ballman\Desktop\D94624.diff"
  error: patch failed: clang-tools-extra/clang-query/tool/ClangQuery.cpp:109
  error: clang-tools-extra/clang-query/tool/ClangQuery.cpp: patch does not apply

As usual, git's not being particularly helpful in stating what went wrong. 
Perhaps rebasing your patch on ToT and re-uploading it will cause the issue to 
go away?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94624

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


[PATCH] D94979: [CGExpr] Honor getCharWidth() in ConstantAggregateBuilderUtils

2021-01-19 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope created this revision.
bjope requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In CGExprConstant.cpp, when dealing with padding etc, some sizes
are calculated as char units. But then the type used when creating
the aggregate expression was hardcoded to Int8Ty. Since a char
normally is eight bits this usually is fine, but it seems a bit
inconsistent to use the size of a char unit when requesting the
size of the aggregate, but then ending up not taking getCharWidth()
into consideration when selecting the type for the aggregate.

This patch honors the size of a char unit by using getCharWidth()
together with getIntNTy instead of hardcoding the type to Int8Ty.

This can be considered as NFC, as getCharWidth always return 8
and can't be configured (at least not in-tree). But it makes the
code a bit more consistent, and might be helpful for out-of-tree
targets that has different char widths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94979

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1225,6 +1225,9 @@
   /// Return the store size, in character units, of the given LLVM type.
   CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const;
 
+  // Return the LLVM type sized as one character unit.
+  llvm::Type *getCharSizedType();
+
   /// Returns LLVM linkage for a declarator.
   llvm::GlobalValue::LinkageTypes
   getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage,
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3982,6 +3982,11 @@
   getDataLayout().getTypeStoreSizeInBits(Ty));
 }
 
+llvm::Type *CodeGenModule::getCharSizedType() {
+  return llvm::Type::getIntNTy(getLLVMContext(),
+   getContext().getCharWidth());
+}
+
 LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
   LangAS AddrSpace = LangAS::Default;
   if (LangOpts.OpenCL) {
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -58,14 +58,15 @@
   }
 
   llvm::Constant *getPadding(CharUnits PadSize) const {
-llvm::Type *Ty = CGM.Int8Ty;
+llvm::Type *Ty = CGM.getCharSizedType();
 if (PadSize > CharUnits::One())
   Ty = llvm::ArrayType::get(Ty, PadSize.getQuantity());
 return llvm::UndefValue::get(Ty);
   }
 
   llvm::Constant *getZeroes(CharUnits ZeroSize) const {
-llvm::Type *Ty = llvm::ArrayType::get(CGM.Int8Ty, ZeroSize.getQuantity());
+llvm::Type *Ty = llvm::ArrayType::get(CGM.getCharSizedType(),
+  ZeroSize.getQuantity());
 return llvm::ConstantAggregateZero::get(Ty);
   }
 };
@@ -1069,7 +1070,7 @@
 
   assert(CurSize <= TotalSize && "Union size mismatch!");
   if (unsigned NumPadBytes = TotalSize - CurSize) {
-llvm::Type *Ty = CGM.Int8Ty;
+llvm::Type *Ty = CGM.getCharSizedType();
 if (NumPadBytes > 1)
   Ty = llvm::ArrayType::get(Ty, NumPadBytes);
 


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1225,6 +1225,9 @@
   /// Return the store size, in character units, of the given LLVM type.
   CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const;
 
+  // Return the LLVM type sized as one character unit.
+  llvm::Type *getCharSizedType();
+
   /// Returns LLVM linkage for a declarator.
   llvm::GlobalValue::LinkageTypes
   getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage,
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3982,6 +3982,11 @@
   getDataLayout().getTypeStoreSizeInBits(Ty));
 }
 
+llvm::Type *CodeGenModule::getCharSizedType() {
+  return llvm::Type::getIntNTy(getLLVMContext(),
+   getContext().getCharWidth());
+}
+
 LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
   LangAS AddrSpace = LangAS::Default;
   if (LangOpts.OpenCL) {
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -58,14 +58,15 @@
   }
 
   llvm::Constant *getPadding(CharUnits PadSize) const {
-llvm::Type *Ty = CGM.Int8Ty;
+llvm::Type *Ty = CGM.getCharSizedType();
 

[PATCH] D94977: [CodeGen] Honor getCharWidth() in CGRecordLowering

2021-01-19 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope created this revision.
bjope requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When using getByteArrayType the requested size was calculated in
char units, but the type used for the array was hardcoded to the
Int8Ty. Honor the size of char, and use getIntNTy in combination
with getCharWidth to make the code a bit more consistent.

This can be considered as NFC, as getCharWidth always return 8
and can't be configured (at least not in-tree). It just makes the
code a bit more consistent, and it might be helpful for out-of-tree
targets that implement different char widths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94977

Files:
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp


Index: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
===
--- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -127,15 +127,20 @@
 
   /// Wraps llvm::Type::getIntNTy with some implicit arguments.
   llvm::Type *getIntNType(uint64_t NumBits) {
+unsigned AlignedBits = llvm::alignTo(NumBits, Context.getCharWidth());
+return llvm::Type::getIntNTy(Types.getLLVMContext(), AlignedBits);
+  }
+  /// Get the LLVM type sized as one character unit.
+  llvm::Type *getCharType() {
 return llvm::Type::getIntNTy(Types.getLLVMContext(),
- (unsigned)llvm::alignTo(NumBits, 8));
+ Context.getCharWidth());
   }
-  /// Gets an llvm type of size NumBytes and alignment 1.
-  llvm::Type *getByteArrayType(CharUnits NumBytes) {
-assert(!NumBytes.isZero() && "Empty byte arrays aren't allowed.");
-llvm::Type *Type = llvm::Type::getInt8Ty(Types.getLLVMContext());
-return NumBytes == CharUnits::One() ? Type :
-(llvm::Type *)llvm::ArrayType::get(Type, NumBytes.getQuantity());
+  /// Gets an llvm type of size NumChars and alignment 1.
+  llvm::Type *getByteArrayType(CharUnits NumChars) {
+assert(!NumChars.isZero() && "Empty byte arrays aren't allowed.");
+llvm::Type *Type = getCharType();
+return NumChars == CharUnits::One() ? Type :
+(llvm::Type *)llvm::ArrayType::get(Type, NumChars.getQuantity());
   }
   /// Gets the storage type for a field decl and handles storage
   /// for itanium bitfields that are smaller than their declared type.


Index: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
===
--- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -127,15 +127,20 @@
 
   /// Wraps llvm::Type::getIntNTy with some implicit arguments.
   llvm::Type *getIntNType(uint64_t NumBits) {
+unsigned AlignedBits = llvm::alignTo(NumBits, Context.getCharWidth());
+return llvm::Type::getIntNTy(Types.getLLVMContext(), AlignedBits);
+  }
+  /// Get the LLVM type sized as one character unit.
+  llvm::Type *getCharType() {
 return llvm::Type::getIntNTy(Types.getLLVMContext(),
- (unsigned)llvm::alignTo(NumBits, 8));
+ Context.getCharWidth());
   }
-  /// Gets an llvm type of size NumBytes and alignment 1.
-  llvm::Type *getByteArrayType(CharUnits NumBytes) {
-assert(!NumBytes.isZero() && "Empty byte arrays aren't allowed.");
-llvm::Type *Type = llvm::Type::getInt8Ty(Types.getLLVMContext());
-return NumBytes == CharUnits::One() ? Type :
-(llvm::Type *)llvm::ArrayType::get(Type, NumBytes.getQuantity());
+  /// Gets an llvm type of size NumChars and alignment 1.
+  llvm::Type *getByteArrayType(CharUnits NumChars) {
+assert(!NumChars.isZero() && "Empty byte arrays aren't allowed.");
+llvm::Type *Type = getCharType();
+return NumChars == CharUnits::One() ? Type :
+(llvm::Type *)llvm::ArrayType::get(Type, NumChars.getQuantity());
   }
   /// Gets the storage type for a field decl and handles storage
   /// for itanium bitfields that are smaller than their declared type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94906: [clang-format] Apply Allman style to lambdas

2021-01-19 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcbdde495ba28: [clang-format] Apply Allman style to lambdas 
(authored by HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94906

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,58 @@
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine,
+FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  // Reset
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+
   // This shouldn't affect ObjC blocks..
   verifyFormat("[self doSomeThingWithACompletionHandler:^{\n"
"  // ...\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -801,6 +801,7 @@
 Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_Whitesmiths:
 Expanded.BraceWrapping.AfterCaseLabel = true;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,58 @@
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine,
+FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  // Reset
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;

  1   2   >