[clang] b86e7ae - [clang][driver][NFC][obvious] Remove obsolete unistd.h include

2021-01-19 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2021-01-19T09:22:40+01:00
New Revision: b86e7ae66cb988dda33445c29fa64f93e7ca9c3c

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

LOG: [clang][driver][NFC][obvious] Remove obsolete unistd.h include

getuid() is not being called in this file anymore.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d6e8c42053f..7ae0de21317d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -45,10 +45,6 @@
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/YAMLParser.h"
 
-#ifdef LLVM_ON_UNIX
-#include  // For getuid().
-#endif
-
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang;



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


[PATCH] D94873: [clang] [driver] Remove obsolete unistd.h include

2021-01-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Pushed as b86e7ae66cb988dda33445c29fa64f93e7ca9c3c 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94873

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


[PATCH] D94950: [clang] Speculative fix for buffer overrun on raw string parse

2021-01-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This attempts to fix a (non-deterministic) buffer overrun when parsing raw 
string literals during modular build.

Similar fix to 4e5b5c36f47c9a406ea7f6b4f89fae477693973a.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94950

Files:
  clang/lib/Lex/LiteralSupport.cpp


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -1628,11 +1628,18 @@
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < 16 && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -1628,11 +1628,18 @@
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < 16 && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94952: [clangd] Take into account what is in the index (symbols, references, etc.) at indexes merge

2021-01-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
ArcsinX requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Current indexes merge logic skip data from the static index if the file is in 
the dynamic index, but sometimes the dynamic index does not contain references 
(e.g. preamble (dynamic) index vs background (static) index).
This problem was masked by an incorrect file list in the preamble index: the 
preamble file list consists of files URI's and all other indexes file lists 
consist of file paths.
This patch introduces the index data kind (kind of data inside the index), 
which makes indexes merge more flexible and solves the problem described above.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94952

Files:
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1238,9 +1238,9 @@
llvm::function_ref
Callback) const override {}
 
-llvm::unique_function
+llvm::unique_function
 indexedFiles() const override {
-  return [](llvm::StringRef) { return false; };
+  return [](llvm::StringRef) { return IndexDataKind::None; };
 }
 
 size_t estimateMemoryUsage() const override { return 0; }
@@ -1292,9 +1292,9 @@
llvm::function_ref)
 const override {}
 
-llvm::unique_function
+llvm::unique_function
 indexedFiles() const override {
-  return [](llvm::StringRef) { return false; };
+  return [](llvm::StringRef) { return IndexDataKind::None; };
 }
 
 size_t estimateMemoryUsage() const override { return 0; }
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -231,11 +231,11 @@
   auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
   llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
   MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
- std::move(Files), std::move(Data), Size);
+ std::move(Files), IndexDataKind::All, std::move(Data), Size);
   auto ContainsFile = I.indexedFiles();
-  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
-  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
-  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+  EXPECT_EQ(ContainsFile("unittest:///foo.cc"), IndexDataKind::All);
+  EXPECT_EQ(ContainsFile("unittest:///bar.cc"), IndexDataKind::All);
+  EXPECT_EQ(ContainsFile("unittest:///foobar.cc"), IndexDataKind::None);
 }
 
 TEST(MemIndexTest, TemplateSpecialization) {
@@ -508,23 +508,24 @@
   auto DynData = std::make_pair(std::move(DynSymbols), std::move(DynRefs));
   llvm::StringSet<> DynFiles = {testPath("foo.cc")};
   MemIndex DynIndex(std::move(DynData.first), std::move(DynData.second),
-RelationSlab(), std::move(DynFiles), std::move(DynData),
-DynSize);
+RelationSlab(), std::move(DynFiles), IndexDataKind::Symbols,
+std::move(DynData), DynSize);
   SymbolSlab StaticSymbols;
   RefSlab StaticRefs;
   auto StaticData =
   std::make_pair(std::move(StaticSymbols), std::move(StaticRefs));
-  llvm::StringSet<> StaticFiles = {testPath("bar.cc")};
-  MemIndex StaticIndex(std::move(StaticData.first),
-   std::move(StaticData.second), RelationSlab(),
-   std::move(StaticFiles), std::move(StaticData),
-   StaticSymbols.bytes() + StaticRefs.bytes());
+  llvm::StringSet<> StaticFiles = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex StaticIndex(
+  std::move(StaticData.first), std::move(StaticData.second), RelationSlab(),
+  std::move(StaticFiles), IndexDataKind::References, std::move(StaticDat

[PATCH] D94952: [clangd] Take into account what is in the index (symbols, references, etc.) at indexes merge

2021-01-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added reviewers: sammccall, kadircet.
ArcsinX added a comment.

Initial discussion https://reviews.llvm.org/D93683?id=313280#inline-875666


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94952

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


[clang] 39a2a23 - [clang][cli] Parse Lang and CodeGen options separately

2021-01-19 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-19T09:52:46+01:00
New Revision: 39a2a233f88443e865758ba73c156787c77ead2c

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

LOG: [clang][cli] Parse Lang and CodeGen options separately

This patch moves the parsing of `{Lang,CodeGen}Options` from `parseSimpleArgs` 
to the original `Parse{Lang,CodeGen}Args` functions.

This ensures all marshalled `LangOptions` are being parsed **after** the call 
`setLangDefaults`, which in turn enables us to marshall `LangOptions` that 
somehow depend on the defaults. (In a future patch.)

Now, `CodeGenOptions` need to be parsed **after** `LangOptions`, because 
`-cl-mad-enable` (a `CodeGenOpt`) depends on the value of 
`-cl-fast-relaxed-math` and `-cl-unsafe-math-optimizations` (`LangOpts`).

Unfortunately, this removes the nice property that marshalled options get 
parsed in the exact order they appear in the `.td` file. Now we cannot be sure 
that a TableGen record referenced in `ImpliedByAnyOf` has already been parsed. 
This might cause an ordering issues (i.e. reading value of uninitialized 
variable). I plan to mitigate this by moving each `XxxOpt` group from 
`parseSimpleArgs` back to their original parsing function. With this setup, if 
an option from group `A` references option from group `B` in TableGen, the 
compiler will require us to make the `CompilerInvocation` member for `B` 
visible in the parsing function for `A`. That's where we notice that `B` didn't 
get parsed yet.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Frontend/diagnostics-order.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3722192c7eee..e50c313450a9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -244,7 +244,7 @@ def clang_ignored_gcc_optimization_f_Group : OptionGroup<
 class DiagnosticOpts
   : KeyPathAndMacro<"DiagnosticOpts->", base, "DIAG_"> {}
 class LangOpts
-  : KeyPathAndMacro<"LangOpts->", base> {}
+  : KeyPathAndMacro<"LangOpts->", base, "LANG_"> {}
 class TargetOpts
   : KeyPathAndMacro<"TargetOpts->", base> {}
 class FrontendOpts
@@ -254,7 +254,7 @@ class PreprocessorOutputOpts
 class DependencyOutputOpts
   : KeyPathAndMacro<"DependencyOutputOpts.", base> {}
 class CodeGenOpts
-  : KeyPathAndMacro<"CodeGenOpts.", base> {}
+  : KeyPathAndMacro<"CodeGenOpts.", base, "CODEGEN_"> {}
 class HeaderSearchOpts
   : KeyPathAndMacro<"HeaderSearchOpts->", base> {}
 class PreprocessorOpts
@@ -510,6 +510,9 @@ multiclass BoolGOption;
 }
 
+// Key paths that are constant during parsing of options with the same key 
path prefix.
+defvar open_cl = LangOpts<"OpenCL">;
+
 /
 // Options
 
@@ -1820,9 +1823,13 @@ defm experimental_relative_cxx_abi_vtables : 
BoolFOption<"experimental-relative-
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, 
Group,
   HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, 
Flags<[CC1Option]>,
-  NormalizedValuesScope<"LangOptions::LaxVectorConversionKind">,
-  NormalizedValues<["None", "Integer", "All"]>,
-  MarshallingInfoString, "All">, 
AutoNormalizeEnum;
+  NormalizedValues<["LangOptions::LaxVectorConversionKind::None",
+"LangOptions::LaxVectorConversionKind::Integer",
+"LangOptions::LaxVectorConversionKind::All"]>,
+  MarshallingInfoString,
+!strconcat(open_cl.KeyPath, " ? 
LangOptions::LaxVectorConversionKind::None"
+" : 
LangOptions::LaxVectorConversionKind::All")>,
+  AutoNormalizeEnum;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group,
   Alias, AliasArgs<["integer"]>;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index b65b087510ce..0d83a228c301 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -258,7 +258,8 @@ class CompilerInvocation : public CompilerInvocationBase {
   static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
InputKind IK, DiagnosticsEngine &Diags,
const llvm::Triple &T,
-   const std::string &OutputFile);
+   const std::string &OutputFile,
+ 

[PATCH] D94682: [clang][cli] Parse Lang and CodeGen options separately

2021-01-19 Thread Jan Svoboda 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 rG39a2a233f884: [clang][cli] Parse Lang and CodeGen options 
separately (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D94682?vs=316643&id=317477#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94682

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/diagnostics-order.c

Index: clang/test/Frontend/diagnostics-order.c
===
--- clang/test/Frontend/diagnostics-order.c
+++ clang/test/Frontend/diagnostics-order.c
@@ -7,6 +7,6 @@
 //
 // CHECK:  error: invalid value '-foo' in '-verify='
 // CHECK-NEXT: note: -verify prefixes must start with a letter and contain only alphanumeric characters, hyphens, and underscores
-// CHECK-NEXT: warning: optimization level '-O999' is not supported
 // CHECK-NEXT: error: invalid value 'bogus' in '-std=bogus'
 // CHECK-NEXT: note: use {{.*}} for {{.*}} standard
+// CHECK: warning: optimization level '-O999' is not supported
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -385,6 +385,21 @@
   return KeyPath & Value;
 }
 
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  \
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,\
+  IMPLIED_CHECK, IMPLIED_VALUE,\
+  NORMALIZER, MERGER, TABLE_INDEX) \
+  if ((FLAGS)&options::CC1Option) {\
+KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  \
+if (IMPLIED_CHECK) \
+  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);\
+if (SHOULD_PARSE)  \
+  if (auto MaybeValue =\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) \
+KEYPATH =  \
+MERGER(KEYPATH, static_cast(*MaybeValue));  \
+  }
+
 static void FixupInvocation(CompilerInvocation &Invocation,
 DiagnosticsEngine &Diags,
 const InputArgList &Args) {
@@ -911,7 +926,8 @@
   InputKind IK,
   DiagnosticsEngine &Diags,
   const llvm::Triple &T,
-  const std::string &OutputFile) {
+  const std::string &OutputFile,
+  const LangOptions &LangOptsRef) {
   bool Success = true;
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
@@ -926,6 +942,25 @@
   }
   Opts.OptimizationLevel = OptimizationLevel;
 
+  // The key paths of codegen options defined in Options.td start with
+  // "CodeGenOpts.". Let's provide the expected variable name and type.
+  CodeGenOptions &CodeGenOpts = Opts;
+  // Some codegen options depend on language options. Let's provide the expected
+  // variable name and type.
+  const LangOptions *LangOpts = &LangOptsRef;
+
+#define CODEGEN_OPTION_WITH_MARSHALLING(   \
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
+MERGER, EXTRACTOR, TABLE_INDEX)\
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM,\
+SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,  \
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  \
+MERGER, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef CODEGEN_OPTION_WITH_MARSHALLING
+
   // At O0 we want to fully disable inlining outside of cases marked with
   // 'alwaysinline' that are required for correctness.
   Opts.setInlining((Opts.OptimizationLevel == 0)
@@ -1367,21 +1402,6 @@
   return Success;
 }
 
-#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  \
-  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,\
-  IMPLIED_CHECK, IMPL

[PATCH] D94682: [clang][cli] Parse Lang and CodeGen options separately

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

Committed with the parsing macro moved to the top of the file as discussed with 
Michael. This will make following patches cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94682

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


[PATCH] D94930: [RISCV] Add support for Zvamo/Zvlsseg to driver

2021-01-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai 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/D94930/new/

https://reviews.llvm.org/D94930

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


[clang] 7e1d222 - [X86][AMX] Fix the typo.

2021-01-19 Thread via cfe-commits

Author: Luo, Yuanke
Date: 2021-01-19T16:57:34+08:00
New Revision: 7e1d2224b42b411acf2d3cb20e3cf5a564ef79bb

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

LOG: [X86][AMX] Fix the typo.

The dpbsud should be dpbssd.

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

Added: 


Modified: 
clang/lib/Headers/amxintrin.h
clang/test/CodeGen/X86/amx_api.c

Removed: 




diff  --git a/clang/lib/Headers/amxintrin.h b/clang/lib/Headers/amxintrin.h
index 901488a17e8c..823c7ca1f076 100644
--- a/clang/lib/Headers/amxintrin.h
+++ b/clang/lib/Headers/amxintrin.h
@@ -258,7 +258,7 @@ static void __tile_loadd(__tile1024i *dst, const void *base,
 }
 
 __DEFAULT_FN_ATTRS_INT8
-static void __tile_dpbsud(__tile1024i *dst, __tile1024i src1,
+static void __tile_dpbssd(__tile1024i *dst, __tile1024i src1,
   __tile1024i src2) {
   dst->tile = _tile_dpbssd_internal(src1.row, src2.col, src1.col, dst->tile,
 src1.tile, src2.tile);

diff  --git a/clang/test/CodeGen/X86/amx_api.c 
b/clang/test/CodeGen/X86/amx_api.c
index 55290f3fa6fb..7d3aa385f6a2 100644
--- a/clang/test/CodeGen/X86/amx_api.c
+++ b/clang/test/CodeGen/X86/amx_api.c
@@ -27,7 +27,7 @@ void test_api(int cond, short row, short col) {
 __tile_loadd(&b, buf2, STRIDE);
 __tile_loadd(&c, buf2, STRIDE);
   }
-  __tile_dpbsud(&c, a, b);
+  __tile_dpbssd(&c, a, b);
   __tile_stored(buf, STRIDE, c);
 }
 
@@ -39,11 +39,11 @@ void test_tile_loadd(short row, short col) {
   __tile_loadd(&a, buf, STRIDE);
 }
 
-void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_dpbsud
+void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbssd
   //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_dpbsud(&c, a, b);
+  __tile_dpbssd(&c, a, b);
 }
 
 void test_tile_stored(__tile1024i c) {



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


[PATCH] D94943: [X86][AMX] Fix the typo.

2021-01-19 Thread LuoYuanke 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 rG7e1d2224b42b: [X86][AMX] Fix the typo. (authored by 
LuoYuanke).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94943

Files:
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c


Index: clang/test/CodeGen/X86/amx_api.c
===
--- clang/test/CodeGen/X86/amx_api.c
+++ clang/test/CodeGen/X86/amx_api.c
@@ -27,7 +27,7 @@
 __tile_loadd(&b, buf2, STRIDE);
 __tile_loadd(&c, buf2, STRIDE);
   }
-  __tile_dpbsud(&c, a, b);
+  __tile_dpbssd(&c, a, b);
   __tile_stored(buf, STRIDE, c);
 }
 
@@ -39,11 +39,11 @@
   __tile_loadd(&a, buf, STRIDE);
 }
 
-void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_dpbsud
+void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbssd
   //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_dpbsud(&c, a, b);
+  __tile_dpbssd(&c, a, b);
 }
 
 void test_tile_stored(__tile1024i c) {
Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -258,7 +258,7 @@
 }
 
 __DEFAULT_FN_ATTRS_INT8
-static void __tile_dpbsud(__tile1024i *dst, __tile1024i src1,
+static void __tile_dpbssd(__tile1024i *dst, __tile1024i src1,
   __tile1024i src2) {
   dst->tile = _tile_dpbssd_internal(src1.row, src2.col, src1.col, dst->tile,
 src1.tile, src2.tile);


Index: clang/test/CodeGen/X86/amx_api.c
===
--- clang/test/CodeGen/X86/amx_api.c
+++ clang/test/CodeGen/X86/amx_api.c
@@ -27,7 +27,7 @@
 __tile_loadd(&b, buf2, STRIDE);
 __tile_loadd(&c, buf2, STRIDE);
   }
-  __tile_dpbsud(&c, a, b);
+  __tile_dpbssd(&c, a, b);
   __tile_stored(buf, STRIDE, c);
 }
 
@@ -39,11 +39,11 @@
   __tile_loadd(&a, buf, STRIDE);
 }
 
-void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_dpbsud
+void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbssd
   //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_dpbsud(&c, a, b);
+  __tile_dpbssd(&c, a, b);
 }
 
 void test_tile_stored(__tile1024i c) {
Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -258,7 +258,7 @@
 }
 
 __DEFAULT_FN_ATTRS_INT8
-static void __tile_dpbsud(__tile1024i *dst, __tile1024i src1,
+static void __tile_dpbssd(__tile1024i *dst, __tile1024i src1,
   __tile1024i src2) {
   dst->tile = _tile_dpbssd_internal(src1.row, src2.col, src1.col, dst->tile,
 src1.tile, src2.tile);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94403: [RISCV] Implement new architecture extension macros

2021-01-19 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Just note how current GCC implemented, GCC implement that like implied 
extension, e.g. `V` implied `Zvamo` and `Zvlsseg`, so `__riscv_zvamo` is 
naturally defined when `V`-ext is enabled.




Comment at: clang/lib/Basic/Targets/RISCV.cpp:148
+  if (HasB) {
+Builder.defineMacro("__riscv_b", "92000");
 Builder.defineMacro("__riscv_bitmanip");

kito-cheng wrote:
> Could you add all subset included in `B`, like zba, zbb, zbc, zbp...
I expect there `HasB` also define `__riscv_zbb`, `__riscv_zbc`... as well here.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:153
+  if (HasV) {
+Builder.defineMacro("__riscv_v", "9000");
 Builder.defineMacro("__riscv_vector");

kito-cheng wrote:
> Could you add all subset included in `V`, `Zvamo` and `Zvlsseg`.
Ditto, I expect there `HasV` also define `__riscv_zvamo`, `__riscv_zvlsseg`... 
as well here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94403

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


[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

mostly good.

I think we'd better bump the index version, even though this is not a breaking 
change, but we will collect more data. Not bumping the index version may lead 
to a half-completed state of the index (e.g. only newly-changed files will get 
completed index data in background index).




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:227
+  // Index all virtual and overridding methods.
+  if (const auto *CXXMD = llvm::dyn_cast(&ND))
+if (CXXMD->isVirtual() || !CXXMD->overridden_methods().empty())

having a special case here is subtle, I think the reason we need this is to 
filter out non-virtual methods etc for function-local classes? not sure we 
should do this, my guess is that we wouldn't save too much, I'd just remove 
this and index all members for function-local classes. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

___
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 Jiashu Zou via Phabricator via cfe-commits
GoBigorGoHome created this revision.
GoBigorGoHome added a reviewer: MyDeveloperDay.
GoBigorGoHome requested review of this revision.
Herald added a project: clang.

TT_ForEachMacro should be considered in rules AllowShortBlocksOnASingleLine
and AllowShortLoopsOnASingleLine.
This fixes bug-46087.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94955

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -993,9 +993,12 @@
 
 TEST_F(FormatTest, ForEachLoops) {
   verifyFormat("void f() {\n"
-   "  foreach (Item *item, itemlist) {}\n"
-   "  Q_FOREACH (Item *item, itemlist) {}\n"
-   "  BOOST_FOREACH (Item *item, itemlist) {}\n"
+   "  foreach (Item *item, itemlist) {\n"
+   "  }\n"
+   "  Q_FOREACH (Item *item, itemlist) {\n"
+   "  }\n"
+   "  BOOST_FOREACH (Item *item, itemlist) {\n"
+   "  }\n"
"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}");
 
@@ -1003,9 +1006,12 @@
   Style.SpaceBeforeParens =
   FormatStyle::SBPO_ControlStatementsExceptForEachMacros;
   verifyFormat("void f() {\n"
-   "  foreach(Item *item, itemlist) {}\n"
-   "  Q_FOREACH(Item *item, itemlist) {}\n"
-   "  BOOST_FOREACH(Item *item, itemlist) {}\n"
+   "  foreach(Item *item, itemlist) {\n"
+   "  }\n"
+   "  Q_FOREACH(Item *item, itemlist) {\n"
+   "  }\n"
+   "  BOOST_FOREACH(Item *item, itemlist) {\n"
+   "  }\n"
"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}",
Style);
@@ -17838,6 +17844,18 @@
 "}",
 format(Source, Style));
 }
+
+TEST_F(FormatTest, TreatForEachMacrosAsLoops) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ForEachMacros.push_back("rng");
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
+  verifyFormat("rng (i, 0, 10) { int j = 1; }", Style);
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+  verifyFormat("rng (i, 0, 10) {\n"
+   "  int j = 1;\n"
+   "}",
+   Style);
+}
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -306,7 +306,8 @@
 }
 // Try to merge a control statement block with left brace unwrapped
 if (TheLine->Last->is(tok::l_brace) && TheLine->First != TheLine->Last &&
-TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
+TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
+TT_ForEachMacro)) {
   return Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never
  ? tryMergeSimpleBlock(I, E, Limit)
  : 0;
@@ -421,7 +422,8 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do,
+TT_ForEachMacro)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -474,7 +476,7 @@
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;
 if (I[1]->First->isOneOf(tok::semi, tok::kw_if, tok::kw_for, tok::kw_while,
- TT_LineComment))
+ TT_ForEachMacro, TT_LineComment))
   return 0;
 // Only inline simple if's (no nested if or else), unless specified
 if (Style.AllowShortIfStatementsOnASingleLine != FormatStyle::SIS_Always) {
@@ -578,12 +580,14 @@
   I + 2 != E && !I[2]->First->is(tok::r_brace))
 return 0;
   if (!Style.AllowShortLoopsOnASingleLine &&
-  Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for) &&
+  Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
+  TT_ForEachMacro) &&
   !Style.BraceWrapping.AfterControlStatement &&
   !I[1]->First->is(tok::r_brace))
 return 0;
   if (!Style.AllowShortLoopsOnASingleLine &&
-  Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for) &&
+  Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
+  TT_ForEachMacro) &&
   Style.BraceWrapping.AfterControlStatement ==
   FormatStyle::BWACS_Always &&
   I + 2 != E && !I[2]->F

[PATCH] D93095: Introduce -Wreserved-identifier

2021-01-19 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/lib/AST/Decl.cpp:1099
+const DeclContext *CurrentContext = getDeclContext();
+while (true) {
+  if (isa(CurrentContext))

aaron.ballman wrote:
> Rather than trying to manually decide whether the name will be exposed at the 
> top level, I wonder if we should use `Sema::LookupName()` to try to find the 
> name in the global scope. That would move this code from `AST` into `Sema` to 
> avoid layering issues, so it'd be something more like `bool 
> Sema::IsDeclReserved(const NamedDecl *ND) const` or `bool 
> Sema::IsIdentifierReserved(const IdentifierInfo *II) const`.
> 
> The idea is to perform the lookup in global scope and if the lookup finds the 
> identifier, then regardless of how it got there (anonymous union field, 
> anonymous namespaces, enumeration constants, etc), we know it may conflict 
> with an external declaration and diagnose.
> 
> WDYT?
That's an interesting proposal.Let me try that!


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] D57054: [MachineOutliner][ARM][RFC] Add Machine Outliner support for ARM

2021-01-19 Thread Yvan Roux via Phabricator via cfe-commits
yroux abandoned this revision.
yroux added a comment.

All patches are now committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57054

___
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 Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added subscribers: dang, jfb.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds marshalling information to more options.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94957

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -634,13 +634,6 @@
 }
   }
 
-  Opts.ShouldEmitErrorsOnInvalidConfigValue =
-  /* negated */!llvm::StringSwitch(
-   Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
-.Case("true", true)
-.Case("false", false)
-.Default(false);
-
   Opts.CheckersAndPackages.clear();
   for (const Arg *A :
Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
@@ -828,10 +821,6 @@
<< "a filename";
 }
 
-static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
-  Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
-}
-
 /// Create a new Regex instance out of the string value in \p RpassArg.
 /// It returns a pointer to the newly generated Regex instance.
 static std::shared_ptr
@@ -1645,7 +1634,6 @@
 Opts.ProgramAction = frontend::PluginAction;
 Opts.ActionName = A->getValue();
   }
-  Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
   for (const auto *AA : Args.filtered(OPT_plugin_arg))
 Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
 
@@ -1686,7 +1674,6 @@
 if (Val.find('=') == StringRef::npos)
   Opts.ModuleFiles.push_back(std::string(Val));
   }
-  Opts.AllowPCMWithCompilerErrors = Args.hasArg(OPT_fallow_pcm_with_errors);
 
   if (Opts.ProgramAction != frontend::GenerateModule && Opts.IsSystemModule)
 Diags.Report(diag::err_drv_argument_only_allowed_with) << "-fsystem-module"
@@ -2845,8 +2832,6 @@
   frontend::ActionKind Action) {
   Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
 Args.hasArg(OPT_pch_through_hdrstop_use);
-  Opts.AllowPCHWithCompilerErrors =
-  Args.hasArg(OPT_fallow_pch_with_errors, OPT_fallow_pcm_with_errors);
 
   for (const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
 Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
@@ -2930,9 +2915,6 @@
 
 static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
 DiagnosticsEngine &Diags) {
-  Opts.AllowAMDGPUUnsafeFPAtomics =
-  Args.hasFlag(options::OPT_munsafe_fp_atomics,
-   options::OPT_mno_unsafe_fp_atomics, false);
   if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {
 llvm::VersionTuple Version;
 if (Version.tryParse(A->getValue()))
@@ -2987,7 +2969,6 @@
   }
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
  /*DefaultDiagColor=*/false);
-  ParseCommentArgs(LangOpts.CommentOpts, Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3071,10 +3071,10 @@
 def mno_wavefrontsize64 : Flag<["-"], "mno-wavefrontsize64">, Group,
   HelpText<"Specify wavefront size 32 mode (AMDGPU only)">;
 
-def munsafe_fp_atomics : Flag<["-"], "munsafe-fp-atomics">, Group,
-  HelpText<"Enable unsafe floating point atomic instructions (AMDGPU only)">,
-  Flags<[CC1Option]>;
-def mno_unsafe_fp_atomics : Flag<["-"], "mno-unsafe-fp-atomics">, Group;
+defm unsafe_fp_atomics : BoolCC1Option<"unsafe-fp-atomics",
+  TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultsToFalse,
+  ChangedBy,
+  ResetBy, BothFlags<[]>, "m">, Group;
 
 def faltivec : Flag<["-"], "faltivec">, Group, Flags<[NoXarchOption]>;
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, Flags<[NoXarchOption]>;
@@ -4378,7 +4378,10 @@
   MarshallingInfoFlag>;
 
 def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">,
-  HelpText<"Don't emit errors on invalid analyzer-config inputs">;
+  HelpText<"Don't emit errors on invalid analyzer-config inputs">,
+  Values<"true,false">, NormalizedValues<[[{false}], [{true}]]>,
+  MarshallingInfoString, [{true}]>,
+  AutoNormalizeEnum;
 
 def analyzer_config_compatibility_mode_EQ : Joined<["-"], "analyzer-config-compatibility-mode=">,
   Alias;
@@ -4842,7 +4845,8 @@
 M

[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);

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?


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] D94599: [clang][Tooling] Get rid of a hack in SymbolOccurrences, NFCI

2021-01-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

I will wait until the end of this week to see if anyone has objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94599

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


[clang] 87dfd5e - [flang][driver] Add support for `-I` in the new driver

2021-01-19 Thread Andrzej Warzynski via cfe-commits

Author: Faris Rehman
Date: 2021-01-19T11:20:56Z
New Revision: 87dfd5e012e147f4bfa3a9a4564e9cbc167278ff

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

LOG: [flang][driver] Add support for `-I` in the new driver

Add support for option -I in the new Flang driver. This will allow for
included headers and module files in other directories, as the default
search path is currently the working folder. The behaviour of this is
consistent with the current f18 driver, where the current folder (i.e.
".") has the highest priority followed by the order of '-I's taking
priority from first to last.

Summary of changes:
- Add SearchDirectoriesFromDashI to PreprocessorOptions, to be forwarded
  into the parser's searchDirectories
- Add header files and non-functional module files to be used in
  regression tests. The module files are just text files and are used to
  demonstrated that paths specified with `-I` are taken into account when
  searching for .mod files.

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

Added: 
flang/test/Flang-Driver/Inputs/basic-header-one.h
flang/test/Flang-Driver/Inputs/basic-header-two.h
flang/test/Flang-Driver/Inputs/basictestmoduleone.mod
flang/test/Flang-Driver/Inputs/header-dir/basic-header-one.h
flang/test/Flang-Driver/Inputs/header-dir/basic-header-two.h
flang/test/Flang-Driver/Inputs/module-dir/basictestmoduletwo.mod
flang/test/Flang-Driver/include-header.f90
flang/test/Flang-Driver/include-module.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/PreprocessorOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Flang-Driver/driver-help-hidden.f90
flang/test/Flang-Driver/driver-help.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e50c313450a9..8150b24e337b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -678,7 +678,7 @@ def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
 def I : JoinedOrSeparate<["-"], "I">, Group,
-Flags<[CC1Option,CC1AsOption]>, MetaVarName<"">,
+Flags<[CC1Option,CC1AsOption,FlangOption,FC1Option]>, MetaVarName<"">,
 HelpText<"Add directory to the end of the list of include search paths">,
 DocBrief<[{Add directory to include search path. For C++ inputs, if
 there are multiple -I options, these directories are searched

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index bf300d737991..669d911de18a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -21,7 +21,7 @@ using namespace llvm::opt;
 
 void Flang::AddPreprocessingOptions(const ArgList &Args,
 ArgStringList &CmdArgs) const {
-  Args.AddAllArgs(CmdArgs, {options::OPT_D, options::OPT_U});
+  Args.AddAllArgs(CmdArgs, {options::OPT_D, options::OPT_U, options::OPT_I});
 }
 
 void Flang::ConstructJob(Compilation &C, const JobAction &JA,

diff  --git a/flang/include/flang/Frontend/PreprocessorOptions.h 
b/flang/include/flang/Frontend/PreprocessorOptions.h
index d182969eb78b..39ea4d3d3c6c 100644
--- a/flang/include/flang/Frontend/PreprocessorOptions.h
+++ b/flang/include/flang/Frontend/PreprocessorOptions.h
@@ -24,6 +24,11 @@ namespace Fortran::frontend {
 class PreprocessorOptions {
 public:
   std::vector> macros;
+  // Search directories specified by the user with -I
+  // TODO: When adding support for more options related to search paths,
+  // consider collecting them in a separate aggregate. For now we keep it here
+  // as there is no point creating a class for just one field.
+  std::vector searchDirectoriesFromDashI;
 
 public:
   PreprocessorOptions() {}

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 57f097f189f9..aeb4ac3e274a 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -176,6 +176,10 @@ static void parsePreprocessorArgs(
   opts.addMacroUndef(currentArg->getValue());
 }
   }
+
+  // Add the ordered list of -I's.
+  for (const auto *currentArg : args.filtered(clang::driver::options::OPT_I))
+opts.searchDirectoriesFromDashI.emplace_back(currentArg->getValue());
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &res,
@@ -261,4 +265,9 @@ void CompilerInvocation::setFortranOpts() {
   const auto &preprocessorOptions = preprocessorOpts();
 
   collectMacroDefinitions(preprocessorOptions, fortranOptions);
+
+  fortranOptions

[PATCH] D93453: [flang][driver] Add support for `-I`

2021-01-19 Thread Andrzej Warzynski 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 rG87dfd5e012e1: [flang][driver] Add support for `-I` in the 
new driver (authored by FarisRehman, committed by awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D93453?vs=316908&id=317506#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93453

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/basic-header-one.h
  flang/test/Flang-Driver/Inputs/basic-header-two.h
  flang/test/Flang-Driver/Inputs/basictestmoduleone.mod
  flang/test/Flang-Driver/Inputs/header-dir/basic-header-one.h
  flang/test/Flang-Driver/Inputs/header-dir/basic-header-two.h
  flang/test/Flang-Driver/Inputs/module-dir/basictestmoduletwo.mod
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/include-header.f90
  flang/test/Flang-Driver/include-module.f90

Index: flang/test/Flang-Driver/include-module.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/include-module.f90
@@ -0,0 +1,32 @@
+! Ensure argument -I works as expected with module files.
+! The module files for this test are not real module files.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+
+!-
+! EXPECTED OUTPUT FOR MISSING MODULE FILE
+!-
+! SINGLEINCLUDE:No such file or directory
+! SINGLEINCLUDE-NOT:Error reading module file for module 'basictestmoduletwo'
+
+!---
+! EXPECTED OUTPUT FOR ALL MODULES FOUND
+!---
+! INCLUDED-NOT:No such file or directory
+
+program test_dash_I_with_mod_files
+USE basictestmoduleone
+USE basictestmoduletwo
+end
Index: flang/test/Flang-Driver/include-header.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/include-header.f90
@@ -0,0 +1,77 @@
+! Ensure argument -I works as expected with an included header.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -E %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+! RUN: %flang-new -E -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: %flang-new -E -I %S/Inputs -I %S/Inputs/header-dir %s  2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY
+! RUN: %flang-new -E -I %S/Inputs/header-dir -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: not %flang-new -fc1 -E %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+! RUN: %flang-new -fc1 -E -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: %flang-new -fc1 -E -I %S/Inputs -I %S/Inputs/header-dir %s  2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY
+! RUN: %flang-new -fc1 -E -I %S/Inputs/header-dir -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY
+
+!
+! EXPECTED OUTPUT FOR MISSING INCLUDED FILE
+!
+! UNINCLUDED:No such file or directory
+! UNINCLUDED-NOT:program b
+! UNINCLUDED-NOT:program c
+
+!-
+! EXPECTED OUTPUT FOR A SINGLE INCLUDED FOLDER
+!
+! SINGLEINCLUDE:program maindirectoryone
+! SINGLEINCLUDE-NOT:program x
+! SINGLEINCLUDE-NOT:program b
+! SINGLEINCLUDE-NEXT:end
+! SINGLEINCLUDE-NEXT:program maindirectorytwo
+! SINGLEINCLUDE-NOT:program y
+! SINGLEINCLUDE-NOT:program c
+
+!---
+! EXPECTED OUTPUT FOR Inputs/ DIRECTORY SPECIFIED FIRST
+!---
+! MAINDIRECTORY:program maindirectoryone
+! MAINDIRECTORY-NOT:program subdirectoryone
+! MAINDIRECTORY-NOT:program b
+! MAINDIRECTORY

[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain skeleton for AMDGPU

2021-01-19 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal created this revision.
pdhaliwal added reviewers: jdoerfert, grokos, JonChesterfield, ronlieb, ABataev.
Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, 
nhaehnle, jvesely, kzhuravl.
pdhaliwal requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

This patch adds AMDGPUOpenMPToolChain for supporting OpenMP
offloading to AMD GPU's.

This is the first patch in the series which provides the basic
skeleton, few of the methods are marked as llvm_unreachable to 
keep it simple as next patch will implement those.

Originally authored by Greg Rodgers


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94961

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.h

Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -0,0 +1,85 @@
+//===- AMDGPUOpenMP.h - AMDGPUOpenMP ToolChain Implementation -*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
+
+#include "AMDGPU.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+
+namespace tools {
+
+namespace AMDGCN {
+// Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
+// device library, then compiles it to ISA in a shared object.
+class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool {
+public:
+  OpenMPLinker(const ToolChain &TC)
+  : Tool("AMDGCN::OpenMPLinker", "amdgcn-link", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
+} // end namespace AMDGCN
+} // end namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY AMDGPUOpenMPToolChain final
+: public ROCMToolChain {
+public:
+  AMDGPUOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
+const ToolChain &HostTC, const llvm::opt::ArgList &Args,
+const Action::OffloadKind OK);
+
+  const llvm::Triple *getAuxTriple() const override {
+return &HostTC.getTriple();
+  }
+
+  llvm::opt::DerivedArgList *
+  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+
+  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const override;
+
+  SanitizerMask getSupportedSanitizers() const override;
+
+  VersionTuple
+  computeMSVCVersion(const Driver *D,
+ const llvm::opt::ArgList &Args) const override;
+
+  const ToolChain &HostTC;
+
+protected:
+  Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -0,0 +1,117 @@
+//===- AMDGPUOpenMP.cpp - AMDGPUOpenMP ToolChain Implementation -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AMDGPUOpenMP.h"
+#include "AMDGPU.h"
+#include "CommonArgs.h"
+#include "InputInfo.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang::driver::tools;
+using names

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

2021-01-19 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: 
clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h:81
+  union {
+SourceRange SingleRange;
+unsigned NumRanges;

This surely relies on `SourceRange` having no destructor (or rather, a trivial 
one). If that ever changes, then destruction of this class will risk either a 
spurious call to the destructor or a missing one.

Is there any way to somehow arrange that a build failure will occur if the 
definition of `SourceRange` changes in that way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94599

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


[PATCH] D92277: [OpenCL] Refactor of targets OpenCL option settings

2021-01-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Basic/TargetInfo.cpp:360
+// Set core features based on OpenCL version
+for (auto CoreExt : clang::getCoreFeatures(Opts))
+  getTargetOpts().OpenCLFeaturesMap[CoreExt] = true;

azabaznov wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > azabaznov wrote:
> > > > Anastasia wrote:
> > > > > I still think the target map should be immutable and especially we 
> > > > > should not change it silently based on the language compiled even if 
> > > > > we have done it before but that caused incorrect behavior i.e. 
> > > > > successfully compiling for the architectures that didn't support the 
> > > > > features.
> > > > > 
> > > > > If I look at existing targets they already set most of the core 
> > > > > features apart from 3d image writes. Perhaps it is reasonable to just 
> > > > > drop this code? I don't think it makes the issue worse, in fact, I 
> > > > > think it will make the behavior slightly better because now a 
> > > > > diagnostic will occur if there is an attempt to use the unsupported 
> > > > > feature although the diagnostic won't be the optimal one.  After all 
> > > > > it will still remain the responsibility of the user to get the right 
> > > > > combination of a language version and a target.
> > > > > 
> > > > > It would be reasonable however to introduce a diagnostic that would 
> > > > > report a mismatch between the language version and the hardware 
> > > > > support available. We report similar diagnostics in 
> > > > > `CompilerInvocation` already. But I don't think we have to do it in 
> > > > > this patch because it doesn't introduce any regression. We already 
> > > > > have a bug although the behavior of this bug will change. And perhaps 
> > > > > if we add `OpenCLOptions` as a part of `LangOpts` at some point this 
> > > > > will become straightforward to diagnose. However, I suggest we add 
> > > > > information about this issue in a FIXME or perhaps this deserves a 
> > > > > clang bug!
> > > > > I still think the target map should be immutable and especially we 
> > > > > should not change it silently based on the language compiled
> > > > 
> > > > I'm confused. I think we have agreed to unconditionally support core 
> > > > features for a specific language version. Did I miss something?
> > > > 
> > > > > successfully compiling for the architectures that didn't support the 
> > > > > features.
> > > > 
> > > > I like idea providing diagnostics in that case. Something like: 
> > > > "Warning: r600 target doesn't support 
> > > > cl_khr_3d_image_writes which is core in OpenCL C 2.0, consider using 
> > > > OpenCL C 3.0". I also think this should be done in a separate commit.
> > > > 
> > > > > If I look at existing targets they already set most of the core 
> > > > > features apart from 3d image writes. Perhaps it is reasonable to just 
> > > > > drop this code?
> > > > 
> > > > Oh, I haven't noticed that target set core features. For example 
> > > > //cl_khr_global_int32_base_atomics// is being set by NVPTX and AMDGPU, 
> > > > so I agree that this should be removed from target settings.
> > > It is correct that the core features should be set unconditionally but 
> > > not in the `TargetInfo`. If core features are used for targets that don't 
> > > support them then it should not succeed silently as it does now i.e. this 
> > > means we need to know what is supported by the targets.
> > > 
> > > Setting target features in `TargetInfo` is correct and should stay.  We 
> > > should not change them here though because the language version doesn't 
> > > change the target capabilities. It can either expose or hide them from 
> > > the user but it should not modify targets. This is why `TargetInfo` is 
> > > immutable after its creation and this is how it should stay. I think it's 
> > > better if we remove the code here completely and introduce a diagnostic 
> > > in the subsequent patches that would just check that the features 
> > > required in the language version are supported by the target.
> > > 
> > > If we do this then during the parsing we will only use feature 
> > > information from `OpenCLOptions` not the targets, but we will know that 
> > > the target have support of all the features because the check has been 
> > > performed earlier.
> > I'm not generally against of removing core features set up, but I do have 
> > some questions and arguments:
> > 
> > > It is correct that the core features should be set unconditionally but 
> > > not in the TargetInfo
> > 
> > Just to make sure: where do you mean core features should be set 
> > unconditionally? 
> > 
> > > Setting target features in TargetInfo is correct and should stay. We 
> > > should not change them here though because the language version doesn't 
> > > change the target capabilities. It can either expose or hide them from 
> > > the user but it should not modify targets. This is why TargetInfo is 
> 

[PATCH] D94606: [clangd] Move DirBasedCDB broadcasting onto its own thread.

2021-01-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:496
+  std::condition_variable CV;
+  std::atomic ShouldStop = {false}; // Must notify CV after writing.
+  std::deque Queue;

sammccall wrote:
> kadircet wrote:
> > nit: we already hold the lock within the loop while reading. it is nice 
> > that we no longer need to acquire the lock during destructor, but is it 
> > worth the extra mental load that comes with memory orderings? (also IIRC, 
> > default load/store behaviors are already acquire-release)
> Whoops, I split this patch in half and now this makes no sense.
> 
> The point is rather that we should interrupt the "evaluate the config for 
> every file" loop (which will be part of process()) if ShouldStop is set. So 
> we check this atomic inside that loop, without acquiring the lock.
> 
> (In practice maybe this is always "fast enough" that we should just run the 
> whole loop, enqueue all the background indexing stuff, and then shut down 
> afterwards?)
> 
> > (also IIRC, default load/store behaviors are already acquire-release)
> 
> Default is sequentially consistent, which is almost always more than we need.
> 
> ---
> 
> I've added a check to the existing loop (which probes directory caches), less 
> necessary but shows the idea. If you prefer to drop this entirely that's OK 
> too.
> The point is rather that we should interrupt the "evaluate the config for 
> every file" loop (which will be part of process()) if ShouldStop is set. So 
> we check this atomic inside that loop, without acquiring the lock.

ah okay now it makes sense.

> I've added a check to the existing loop (which probes directory caches), less 
> necessary but shows the idea. If you prefer to drop this entirely that's OK 
> too.

i suppose we could end up blocking the shutdown for quite some time in 
pathological cases due to disk io. so this looks like a good tradeoff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94606

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain skeleton for AMDGPU

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

This patch was written, roughly, by:

- copying the known-working openmp driver from rocm into the trunk source tree
- deleting lots of stuff that didn't look necessary
- deleting some stuff that is broadly necessary, but the specifics are up for 
debate

The idea is to move language-independent but amdgcn-specific code into 
ROCMToolChain. Some has already gone in, others (like computeMSVCVersion) will 
likely move too.

Regarding the rest of the end to end stack:

- host plugin works, same code in trunk / rocm / aomp
- device plugin will work once it's building as openmp, modulo printf and malloc
- compiler backend will work for spmd kernels today, will work for generic 
kernels after D94648  or equivalent lands

Regarding tests (which need the unimplemented bit filled in with the next 
patch):

- Runtime tests (for spmd kernels) are working locally with a jury rigged 
devicertl
- Codegen tests are proving awkward to update. Dropping line number would help, 
but there's still a difference in addrspace cast distribution. I'm hoping the 
scripts involved in generating the nvptx cases can be adapted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D94952: [clangd] Take into account what is in the index (symbols, references, etc.) at indexes merge

2021-01-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 317521.
ArcsinX added a comment.

Prevent crash in debug mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94952

Files:
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1238,9 +1238,9 @@
llvm::function_ref
Callback) const override {}
 
-llvm::unique_function
+llvm::unique_function
 indexedFiles() const override {
-  return [](llvm::StringRef) { return false; };
+  return [](llvm::StringRef) { return IndexDataKind::None; };
 }
 
 size_t estimateMemoryUsage() const override { return 0; }
@@ -1292,9 +1292,9 @@
llvm::function_ref)
 const override {}
 
-llvm::unique_function
+llvm::unique_function
 indexedFiles() const override {
-  return [](llvm::StringRef) { return false; };
+  return [](llvm::StringRef) { return IndexDataKind::None; };
 }
 
 size_t estimateMemoryUsage() const override { return 0; }
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -231,11 +231,11 @@
   auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
   llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
   MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
- std::move(Files), std::move(Data), Size);
+ std::move(Files), IndexDataKind::All, std::move(Data), Size);
   auto ContainsFile = I.indexedFiles();
-  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
-  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
-  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+  EXPECT_EQ(ContainsFile("unittest:///foo.cc"), IndexDataKind::All);
+  EXPECT_EQ(ContainsFile("unittest:///bar.cc"), IndexDataKind::All);
+  EXPECT_EQ(ContainsFile("unittest:///foobar.cc"), IndexDataKind::None);
 }
 
 TEST(MemIndexTest, TemplateSpecialization) {
@@ -508,23 +508,24 @@
   auto DynData = std::make_pair(std::move(DynSymbols), std::move(DynRefs));
   llvm::StringSet<> DynFiles = {testPath("foo.cc")};
   MemIndex DynIndex(std::move(DynData.first), std::move(DynData.second),
-RelationSlab(), std::move(DynFiles), std::move(DynData),
-DynSize);
+RelationSlab(), std::move(DynFiles), IndexDataKind::Symbols,
+std::move(DynData), DynSize);
   SymbolSlab StaticSymbols;
   RefSlab StaticRefs;
   auto StaticData =
   std::make_pair(std::move(StaticSymbols), std::move(StaticRefs));
-  llvm::StringSet<> StaticFiles = {testPath("bar.cc")};
-  MemIndex StaticIndex(std::move(StaticData.first),
-   std::move(StaticData.second), RelationSlab(),
-   std::move(StaticFiles), std::move(StaticData),
-   StaticSymbols.bytes() + StaticRefs.bytes());
+  llvm::StringSet<> StaticFiles = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex StaticIndex(
+  std::move(StaticData.first), std::move(StaticData.second), RelationSlab(),
+  std::move(StaticFiles), IndexDataKind::References, std::move(StaticData),
+  StaticSymbols.bytes() + StaticRefs.bytes());
   MergedIndex Merge(&DynIndex, &StaticIndex);
 
   auto ContainsFile = Merge.indexedFiles();
-  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
-  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
-  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+  EXPECT_EQ(ContainsFile("unittest:///foo.cc"),
+IndexDataKind::Symbols | IndexDataKind::References);
+  EXPECT_EQ(ContainsFile("unittest:///bar.cc"), IndexDataKind::References);
+  EXPECT_EQ(ContainsFile("unittest:///foobar.cc"), IndexDataKind::None);
 }
 
 TEST(MergeIndexTest, NonDocument

[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

In D94785#2506186 , @hokein wrote:

> I think we'd better bump the index version, even though this is not a 
> breaking change, but we will collect more data. Not bumping the index version 
> may lead to a half-completed state of the index (e.g. only newly-changed 
> files will get completed index data in background index).

Yes. Good point. Incremented the version of the index.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

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


[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 317522.
usaxena95 added a comment.

Index all member functions instead of only polymorphic functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1637,14 +1637,28 @@
 template
 struct $5^TemplateBase {};
 struct $5[[Child3]] : public TemplateBase {};
+
+// Local classes.
+void LocationFunction() {
+  struct $0[[LocalClass1]] : Base {
+void $1[[Foo]]() override;
+  };
+  struct $6^LocalBase {
+virtual void $7^Bar();
+  };
+  struct $6[[LocalClass2]]: LocalBase {
+void $7[[Bar]]() override;
+  };
+}
   )cpp";
 
   Annotations Code(Test);
   auto TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  for (StringRef Label : {"0", "1", "2", "3", "4", "5"}) {
+  auto Index = TU.index();
+  for (StringRef Label : {"0", "1", "2", "3", "4", "5", "6", "7"}) {
 for (const auto &Point : Code.points(Label)) {
-  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  EXPECT_THAT(findImplementations(AST, Point, Index.get()),
   UnorderedPointwise(DeclRange(), Code.ranges(Label)))
   << Code.code() << " at " << Point << " for Label " << Label;
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -55,6 +55,7 @@
   return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
+MATCHER_P(HasName, Name, "") { return arg.Name == Name; }
 MATCHER_P(TemplateArgs, TemplArgs, "") {
   return arg.TemplateSpecializationArgs == TemplArgs;
 }
@@ -157,6 +158,37 @@
   EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
 }
 
+TEST_F(ShouldCollectSymbolTest, CollectLocalClassesAndVirtualMethods) {
+  build(R"(
+namespace nx {
+auto f() {
+  int Local;
+  auto LocalLambda = [&](){
+Local++;
+class ClassInLambda{};
+return Local;
+  };
+} // auto ensures function body is parsed.
+auto foo() {
+  class LocalBase {
+virtual void LocalVirtual();
+void LocalConcrete();
+int BaseMember;
+  };
+}
+} // namespace nx
+  )",
+"");
+  auto AST = File.build();
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("ClassInLambda", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalBase", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalVirtual", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalConcrete", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("BaseMember", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+}
+
 TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
   HeaderName = "f.proto.h";
   build(
@@ -228,7 +260,7 @@
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
-IndexOpts.IndexFunctionLocals = false;
+IndexOpts.IndexFunctionLocals = true;
 Collector = std::make_shared(COpts);
 return std::make_unique(Collector, std::move(IndexOpts),
  PragmaHandler);
@@ -320,7 +352,11 @@
 void ff() {} // ignore
 }
 
-void f1() {}
+void f1() {
+  auto LocalLambda = [&](){
+class ClassInLambda{};
+  };
+}
 
 namespace foo {
 // Type alias
@@ -351,7 +387,7 @@
AllOf(QName("Foo::operator="), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested"), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested::f"), ForCodeCompletion(false)),
-
+   AllOf(QName("ClassInLambda"), ForCodeCompletion(false)),
AllOf(QName("Friend"), ForCodeCompletion(true)),
AllOf(QName("f1"), ForCodeCompletion(true)),
AllOf(QName("f2"), ForCodeCompletion(true)),
@@ -774,7 +810,8 @@
   };
   EXPECT_EQ(Container("ref1a"),
 findSymbol(Symbols, "f2").I

[PATCH] D94942: [clangd] Add tweak for implementing abstract class

2021-01-19 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 317523.
njames93 added a comment.

Update printing policy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94942

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ImplementAbstract.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
@@ -0,0 +1,217 @@
+//===-- ImplementAbstractTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(ImplementAbstract);
+
+TEST_F(ImplementAbstractTest, TestUnavailable) {
+
+  StringRef Cases[]{
+  // Not a pure virtual method.
+  R"cpp(
+  class A {
+virtual void Foo();
+  };
+  class ^B : public A {};
+)cpp",
+  // Pure virtual method overridden in class.
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+void Foo() override;
+  };
+)cpp",
+  // Pure virtual method overridden in class with virtual keyword
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+virtual void Foo() override;
+  };
+)cpp",
+  // Pure virtual method overridden in class without override keyword
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+void Foo();
+  };
+)cpp",
+  // Pure virtual method overriden in base class.
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class B : public A {
+void Foo() override;
+  };
+  class ^C : public B {
+  };
+)cpp"};
+  for (const auto &Case : Cases) {
+EXPECT_THAT(Case, Not(isAvailable()));
+  }
+}
+
+TEST_F(ImplementAbstractTest, TestApply) {
+  struct Case {
+llvm::StringRef TestHeader;
+llvm::StringRef TestSource;
+llvm::StringRef ExpectedSource;
+  };
+
+  Case Cases[]{
+  {
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };)cpp",
+  R"cpp(
+  class B : public A {^};
+)cpp",
+  R"cpp(
+  class B : public A {
+void Foo() override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+public:
+virtual void Foo() = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {};
+)cpp",
+  R"cpp(
+  class B : public A {
+public:
+
+void Foo() override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo(int Param) = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {};
+)cpp",
+  R"cpp(
+  class B : public A {
+void Foo(int Param) override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo(int Param) = 0;
+  };)cpp",
+  R"cpp(
+  struct ^B : public A {};
+)cpp",
+  R"cpp(
+  struct B : public A {
+private:
+
+void Foo(int Param) override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo(int Param) const volatile = 0;
+public:
+virtual void Bar(int Param) = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {
+void Foo(int Param) const volatile override;
+  };
+)cpp",
+  R"cpp(
+  class B : public A {
+void Foo(int Param) const volatile override;
+  
+public:
+
+void Bar(int Param) override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+   class A {
+virtual void Foo() = 0;
+virtual void Bar() = 0;
+  };
+  class B : public A {
+void Foo() override;
+  };
+)cpp",
+  R"cpp(
+  class ^C : public B {
+virtual void Baz();
+  };
+)cpp",
+  R"cpp(
+  class C : public B {
+virtual void Baz();
+void Bar() override;
+
+  };
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {
+~B();
+  };
+)cpp",
+  R"cpp(
+  

[clang] 2c4f6be - [SystemZ][z/OS] Fix No such file or directory expression error

2021-01-19 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-01-19T07:25:24-05:00
New Revision: 2c4f6be86c14c28243915ab9eb3a2ff1902fee99

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

LOG: [SystemZ][z/OS] Fix No such file or directory expression error

On z/OS, the following error message is not matched correctly in lit tests. 
This patch updates the CHECK expression to match the end period successfully.
```
EDC5129I No such file or directory.
```

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

Added: 


Modified: 
clang/test/Frontend/stats-file.c

Removed: 




diff  --git a/clang/test/Frontend/stats-file.c 
b/clang/test/Frontend/stats-file.c
index 007bb7f00b6c..0d0a97b0d1d6 100644
--- a/clang/test/Frontend/stats-file.c
+++ b/clang/test/Frontend/stats-file.c
@@ -5,4 +5,4 @@
 // CHECK: }
 
 // RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
-// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{.*}}{{[Nn]}}o such file or directory'
+// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{.*}}{{[Nn]}}o such file or directory{{.*}}'



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


[PATCH] D92715: [Clang][RISCV] Define RISC-V V builtin types

2021-01-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 316854.
HsiangKai added a comment.

According to "9. Vector Memory Alignment Constraints" in V specification, 
change the alignment of RVV types to the element size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92715

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/RISCVVTypes.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
  clang/test/Sema/riscv-types.c
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1548,6 +1548,8 @@
 #include "clang/Basic/AArch64SVEACLETypes.def"
 #define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
+#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/RISCVVTypes.def"
 #define BUILTIN_TYPE(Id, SingletonId)
 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
Index: clang/test/Sema/riscv-types.c
===
--- /dev/null
+++ clang/test/Sema/riscv-types.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -ast-print %s \
+// RUN:| FileCheck %s
+
+void bar(void) {
+  // CHECK: __rvv_int64m1_t x0;
+  __rvv_int64m1_t x0;
+
+  // CHECK: __rvv_float64m1_t x1;
+  __rvv_float64m1_t x1;
+
+  // CHECK: __rvv_int64m2_t x2;
+  __rvv_int64m2_t x2;
+
+  // CHECK: __rvv_float64m2_t x3;
+  __rvv_float64m2_t x3;
+
+  // CHECK: __rvv_int64m4_t x4;
+  __rvv_int64m4_t x4;
+
+  // CHECK: __rvv_float64m4_t x5;
+  __rvv_float64m4_t x5;
+
+  // CHECK: __rvv_int64m8_t x6;
+  __rvv_int64m8_t x6;
+
+  // CHECK: __rvv_float64m8_t x7;
+  __rvv_float64m8_t x7;
+
+  // CHECK: __rvv_int32m1_t x8;
+  __rvv_int32m1_t x8;
+
+  // CHECK: __rvv_float32m1_t x9;
+  __rvv_float32m1_t x9;
+
+  // CHECK: __rvv_int32m2_t x10;
+  __rvv_int32m2_t x10;
+
+  // CHECK: __rvv_float32m2_t x11;
+  __rvv_float32m2_t x11;
+
+  // CHECK: __rvv_int32m4_t x12;
+  __rvv_int32m4_t x12;
+
+  // CHECK: __rvv_float32m4_t x13;
+  __rvv_float32m4_t x13;
+
+  // CHECK: __rvv_int32m8_t x14;
+  __rvv_int32m8_t x14;
+
+  // CHECK: __rvv_float32m8_t x15;
+  __rvv_float32m8_t x15;
+
+  // CHECK: __rvv_int16m1_t x16;
+  __rvv_int16m1_t x16;
+
+  // CHECK: __rvv_float16m1_t x17;
+  __rvv_float16m1_t x17;
+
+  // CHECK: __rvv_int16m2_t x18;
+  __rvv_int16m2_t x18;
+
+  // CHECK: __rvv_float16m2_t x19;
+  __rvv_float16m2_t x19;
+
+  // CHECK: __rvv_int16m4_t x20;
+  __rvv_int16m4_t x20;
+
+  // CHECK: __rvv_float16m4_t x21;
+  __rvv_float16m4_t x21;
+
+  // CHECK: __rvv_int16m8_t x22;
+  __rvv_int16m8_t x22;
+
+  // CHECK: __rvv_float16m8_t x23;
+  __rvv_float16m8_t x23;
+
+  // CHECK: __rvv_int8m1_t x24;
+  __rvv_int8m1_t x24;
+
+  // CHECK: __rvv_int8m2_t x25;
+  __rvv_int8m2_t x25;
+
+  // CHECK: __rvv_int8m4_t x26;
+  __rvv_int8m4_t x26;
+
+  // CHECK: __rvv_int8m8_t x27;
+  __rvv_int8m8_t x27;
+
+  // CHECK: __rvv_bool64_t x28;
+  __rvv_bool64_t x28;
+
+  // CHECK: __rvv_bool32_t x29;
+  __rvv_bool32_t x29;
+
+  // CHECK: __rvv_bool16_t x30;
+  __rvv_bool16_t x30;
+
+  // CHECK: __rvv_bool8_t x31;
+  __rvv_bool8_t x31;
+
+  // CHECK: __rvv_bool8_t x32;
+  __rvv_bool8_t x32;
+
+  // CHECK: __rvv_bool8_t x33;
+  __rvv_bool8_t x33;
+
+  // CHECK: __rvv_bool8_t x34;
+  __rvv_bool8_t x34;
+
+  // CHECK: __rvv_int32mf2_t x35;
+  __rvv_int32mf2_t x35;
+
+  // CHECK: __rvv_float32mf2_t x36;
+  __rvv_float32mf2_t x36;
+
+  // CHECK: __rvv_int16mf4_t x37;
+  __rvv_int16mf4_t x37;
+
+  // CHECK: __rvv_float16mf4_t x38;
+  __rvv_float16mf4_t x38;
+
+  // CHECK: __rvv_int16mf2_t x39;
+  __rvv_int16mf2_t x39;
+
+  // CHECK: __rvv_float16mf2_t x40;
+  __rvv_float16mf2_t x40;
+
+  // CHECK: __rvv_int8mf8_t x41;
+  __rvv_int8mf8_t x41;
+
+  // CHECK: __rvv_int8mf4_t x42;
+  __rvv_int8mf4_t x42;
+
+  // CHECK: __rvv_int8mf2_t x43;
+  __rvv_int8mf2_t x43;
+}
Index: clang/test/CodeGen/RISC

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

2021-01-19 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

As the discussion is spread out across multiple threads, do I understand 
correctly that the current consensus is to introduce the 
`-disable-noundef-analysis` flag, and explicitly add it to all the relevant 
tests (rather than adding it to the substitutions)?

In any case, I'd recommend changing this patch to default 
`-disable-noundef-analysis` to true (so you need to compile with 
`-disable-noundef-analysis=0` to get undef attributes). The flag can then be 
flipped together with the test changes. That should help get the main technical 
change landed directly, and avoid the need of landing patches at the same time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

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


[PATCH] D92715: [Clang][RISCV] Define RISC-V V builtin types

2021-01-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping. If we all agree to use builtin types to model RVV types, is there any 
other issues we need to address in this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92715

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


[PATCH] D94374: [CMake] Remove dead code setting policies to NEW

2021-01-19 Thread Raul Tambre via Phabricator via cfe-commits
tambre marked an inline comment as done.
tambre added a comment.

ldionne: ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94374

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


[PATCH] D94374: [CMake] Remove dead code setting policies to NEW

2021-01-19 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94374

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


[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 317525.
usaxena95 added a comment.
Herald added a subscriber: wenlei.

Updated index tests's input files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1637,14 +1637,28 @@
 template
 struct $5^TemplateBase {};
 struct $5[[Child3]] : public TemplateBase {};
+
+// Local classes.
+void LocationFunction() {
+  struct $0[[LocalClass1]] : Base {
+void $1[[Foo]]() override;
+  };
+  struct $6^LocalBase {
+virtual void $7^Bar();
+  };
+  struct $6[[LocalClass2]]: LocalBase {
+void $7[[Bar]]() override;
+  };
+}
   )cpp";
 
   Annotations Code(Test);
   auto TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  for (StringRef Label : {"0", "1", "2", "3", "4", "5"}) {
+  auto Index = TU.index();
+  for (StringRef Label : {"0", "1", "2", "3", "4", "5", "6", "7"}) {
 for (const auto &Point : Code.points(Label)) {
-  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  EXPECT_THAT(findImplementations(AST, Point, Index.get()),
   UnorderedPointwise(DeclRange(), Code.ranges(Label)))
   << Code.code() << " at " << Point << " for Label " << Label;
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -55,6 +55,7 @@
   return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
+MATCHER_P(HasName, Name, "") { return arg.Name == Name; }
 MATCHER_P(TemplateArgs, TemplArgs, "") {
   return arg.TemplateSpecializationArgs == TemplArgs;
 }
@@ -157,6 +158,37 @@
   EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
 }
 
+TEST_F(ShouldCollectSymbolTest, CollectLocalClassesAndVirtualMethods) {
+  build(R"(
+namespace nx {
+auto f() {
+  int Local;
+  auto LocalLambda = [&](){
+Local++;
+class ClassInLambda{};
+return Local;
+  };
+} // auto ensures function body is parsed.
+auto foo() {
+  class LocalBase {
+virtual void LocalVirtual();
+void LocalConcrete();
+int BaseMember;
+  };
+}
+} // namespace nx
+  )",
+"");
+  auto AST = File.build();
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("ClassInLambda", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalBase", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalVirtual", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalConcrete", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("BaseMember", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+}
+
 TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
   HeaderName = "f.proto.h";
   build(
@@ -228,7 +260,7 @@
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
-IndexOpts.IndexFunctionLocals = false;
+IndexOpts.IndexFunctionLocals = true;
 Collector = std::make_shared(COpts);
 return std::make_unique(Collector, std::move(IndexOpts),
  PragmaHandler);
@@ -320,7 +352,11 @@
 void ff() {} // ignore
 }
 
-void f1() {}
+void f1() {
+  auto LocalLambda = [&](){
+class ClassInLambda{};
+  };
+}
 
 namespace foo {
 // Type alias
@@ -351,7 +387,7 @@
AllOf(QName("Foo::operator="), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested"), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested::f"), ForCodeCompletion(false)),
-
+   AllOf(QName("ClassInLambda"), ForCodeCompletion(false)),
AllOf(QName("Friend"), ForCodeCompletion(true)),
AllOf(QName("f1"), ForCodeCompletion(true)),
AllOf(QName("f2"), ForCodeCompletion(true)),
@@ -774,7 +810,8 @@
   };

[PATCH] D94933: [clang] Check for nullptr when instantiating late attrs

2021-01-19 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6f9077b16da: [clang] Check for nullptr when instantiating 
late attrs (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94933

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp


Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2796,7 +2796,8 @@
 
 Attr *NewAttr =
   instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
-I->NewDecl->addAttr(NewAttr);
+if (NewAttr)
+  I->NewDecl->addAttr(NewAttr);
 LocalInstantiationScope::deleteScopes(I->Scope,
   Instantiator.getStartingScope());
   }


Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2796,7 +2796,8 @@
 
 Attr *NewAttr =
   instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
-I->NewDecl->addAttr(NewAttr);
+if (NewAttr)
+  I->NewDecl->addAttr(NewAttr);
 LocalInstantiationScope::deleteScopes(I->Scope,
   Instantiator.getStartingScope());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a6f9077 - [clang] Check for nullptr when instantiating late attrs

2021-01-19 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-01-19T13:43:15+01:00
New Revision: a6f9077b16da90204b296acd4f840769e83460ac

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

LOG: [clang] Check for nullptr when instantiating late attrs

This was already done in SemaTemplateInstantiateDecl.cpp, but not in
SemaTemplateInstantiate.cpp.

Anecdotally I've seen some clangd crashes where coredumps point to this
being a problem, but I cannot reproduce this so far.

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiate.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index cb74f08830c8..7679063ead71 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2796,7 +2796,8 @@ Sema::InstantiateClass(SourceLocation 
PointOfInstantiation,
 
 Attr *NewAttr =
   instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
-I->NewDecl->addAttr(NewAttr);
+if (NewAttr)
+  I->NewDecl->addAttr(NewAttr);
 LocalInstantiationScope::deleteScopes(I->Scope,
   Instantiator.getStartingScope());
   }



___
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 Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: 
clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h:81
+  union {
+SourceRange SingleRange;
+unsigned NumRanges;

simon_tatham wrote:
> This surely relies on `SourceRange` having no destructor (or rather, a 
> trivial one). If that ever changes, then destruction of this class will risk 
> either a spurious call to the destructor or a missing one.
> 
> Is there any way to somehow arrange that a build failure will occur if the 
> definition of `SourceRange` changes in that way?
... aha, found one. Such as a static assertion that 
`std::is_trivially_destructible::value` is 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94599

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


[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements

2021-01-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Parser/stmt-attributes.c:5
+
+  __attribute__((unknown_attribute));// expected-warning {{unknown 
attribute 'unknown_attribute' ignored}}
+  __attribute__((unknown_attribute)) {}  // expected-warning {{unknown 
attribute 'unknown_attribute' ignored}}

vsavchenko wrote:
> aaron.ballman wrote:
> > Given that these are parser tests, I think you can drop the attribute name 
> > itself except in the cases where you explicitly want to test that an 
> > unknown attribute introduces the start of a declaration (or things where 
> > the attribute identifier matters for some reason). This will reduce the 
> > amount of `expected-warning` comments we need to add.
> > 
> > Also, because this change impacts C++ and ObjC/C++ as well, I think we 
> > should have some tests for language-specific constructs like lambdas, 
> > range-based for loops, blocks, etc.
> This test is mostly a copy-paste of a similar test for C++11 statement 
> attributes.
> I think that these cases show that GNU spelling for attributes doesn't break 
> anything if we put it in front of these various statements.  And you are 
> absolutely right that we need to add more cases for C++ and Obj-C constructs. 
>  But I don't understand about 'unknown_attribute'.  What should I replace it 
> with?
> But I don't understand about 'unknown_attribute'. What should I replace it 
> with?

You can use `__attribute__(())` to test that we parse a GNU style attribute in 
a position without bothering to name any attributes. This will eliminate the 
"unknown attribute" sema warnings from the test without impacting the parser 
test functionality, and it'll make it more clear in what cases the specific 
attribute named impacts the parsing behavior.

e.g., `__attribute__((unknown_attribute)) if (0) {}` converted into 
`__attribute__(()) if (0) {}` should still test what we need tested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93630

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


[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements

2021-01-19 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/test/Parser/stmt-attributes.c:5
+
+  __attribute__((unknown_attribute));// expected-warning {{unknown 
attribute 'unknown_attribute' ignored}}
+  __attribute__((unknown_attribute)) {}  // expected-warning {{unknown 
attribute 'unknown_attribute' ignored}}

aaron.ballman wrote:
> vsavchenko wrote:
> > aaron.ballman wrote:
> > > Given that these are parser tests, I think you can drop the attribute 
> > > name itself except in the cases where you explicitly want to test that an 
> > > unknown attribute introduces the start of a declaration (or things where 
> > > the attribute identifier matters for some reason). This will reduce the 
> > > amount of `expected-warning` comments we need to add.
> > > 
> > > Also, because this change impacts C++ and ObjC/C++ as well, I think we 
> > > should have some tests for language-specific constructs like lambdas, 
> > > range-based for loops, blocks, etc.
> > This test is mostly a copy-paste of a similar test for C++11 statement 
> > attributes.
> > I think that these cases show that GNU spelling for attributes doesn't 
> > break anything if we put it in front of these various statements.  And you 
> > are absolutely right that we need to add more cases for C++ and Obj-C 
> > constructs.  But I don't understand about 'unknown_attribute'.  What should 
> > I replace it with?
> > But I don't understand about 'unknown_attribute'. What should I replace it 
> > with?
> 
> You can use `__attribute__(())` to test that we parse a GNU style attribute 
> in a position without bothering to name any attributes. This will eliminate 
> the "unknown attribute" sema warnings from the test without impacting the 
> parser test functionality, and it'll make it more clear in what cases the 
> specific attribute named impacts the parsing behavior.
> 
> e.g., `__attribute__((unknown_attribute)) if (0) {}` converted into 
> `__attribute__(()) if (0) {}` should still test what we need tested.
Gotcha, will do!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93630

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


[PATCH] D94067: [clang][ASTImporter] Fix a possible assertion failure `NeedsInjectedClassNameType(Decl)'.

2021-01-19 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@balazske 
Thanks Balázs! Great work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94067

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


[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements

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

In D93630#2504758 , @vsavchenko wrote:

> I'll clean up the tests!  But, unfortunately, I couldn't proceed with GCC 
> folks.  I asked around and I'm not allowed to do that (company rules).

Ah, that's unfortunate. When I get the chance, I'll try to send an email to the 
GCC lists. Do you mind if I pass the email by you first (privately) to ensure 
I'm not misstating your goals or anything from your patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93630

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


[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements

2021-01-19 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D93630#2506604 , @aaron.ballman 
wrote:

> In D93630#2504758 , @vsavchenko 
> wrote:
>
>> I'll clean up the tests!  But, unfortunately, I couldn't proceed with GCC 
>> folks.  I asked around and I'm not allowed to do that (company rules).
>
> Ah, that's unfortunate. When I get the chance, I'll try to send an email to 
> the GCC lists. Do you mind if I pass the email by you first (privately) to 
> ensure I'm not misstating your goals or anything from your patch?

That would be amazing, thank you!
Sure, sounds like a solid plan.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93630

___
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 Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though it would have been a bit easier to review had the rearranging been 
done in a separate NFC patch.




Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:498-500
+  EXPECT_TRUE(
+  matches(Code, cxxBoolLiteral(equals(false),
+   hasAncestor(mapAnyOf(ifStmt, forStmt);

Can you also add a test like:
```
EXPECT_TRUE(notMatches(Code, floatLiteral(hasAncestor(mapAnyOf(ifStmt, 
forStmt);
```
to show that we can still search all of the nodes and fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94864

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



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

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?


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] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, looks good!

if you don't mind, could you rerun the benchmark (we have a behavior changes 
from original version, I guess it won't not change significantly)? and update 
the data in the description before landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

___
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 Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

I did some digging to see why this was added in the first place and it came 
with the original commit of AST matchers. Thank you for the cleanup, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94876

___
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 Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

In D92797#2505254 , @compnerd wrote:

> Ping x 3

Sorry, just came back from holidays.
Generally, I have no major concerns.

My minor concern is that it is not easy to add a new Note. There are many 
different places to extend the code (i.e. adding a new DenseMap instance, 
adding two new write function prototypes and their definitions). I am not sure 
if this could be simpler though.




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

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?



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

Some other *TableInfo classes do not have `ComputeHash`. E.g. 
`GlobalVariableTableInfo`. Why?
Where do we use `ComputeHash`?


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] D94877: Add API to retrieve a clade kind from ASTNodeKind

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

LGTM aside from the use of `auto`.




Comment at: clang/lib/AST/ASTTypeTraits.cpp:67
+ASTNodeKind ASTNodeKind::getCladeKind() const {
+  auto LastId = KindId;
+  while (LastId) {





Comment at: clang/lib/AST/ASTTypeTraits.cpp:69
+  while (LastId) {
+auto ParentId = AllKindInfo[LastId].ParentId;
+if (ParentId == NKI_None)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94877

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


[PATCH] D94614: [FPEnv][X86] Platform builtins edition: clang should get from the AST the metadata for constrained FP builtins

2021-01-19 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:12268
+  case X86::BI__builtin_ia32_cvtqq2pd512_mask: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 return EmitX86ConvertIntToFp(*this, Ops, /*IsSigned*/true);

pengfei wrote:
> Maybe better to move it into these Emit* functions?
Certainly. Will do.



Comment at: clang/test/CodeGen/X86/avx512dq-builtins-constrained.c:3
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512dq -emit-llvm -o - -Wall 
-Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON 
--check-prefix=COMMONIR
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512dq 
-ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | tee 
/tmp/X | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON 
--check-prefix=COMMONIR
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512dq -S -o - -Wall -Werror | 
FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON

pengfei wrote:
> Where is the file used? It results in failure on Windows.
Because I forgot to remove the "tee" command perhaps?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94614

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


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

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

I assume the test coverage for this change is from existing tests that are 
being updated as part of another patch? Or is there test coverage missing for 
this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94878

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


[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added a comment.

In D94785#2506685 , @hokein wrote:

> if you don't mind, could you rerun the benchmark (we have a behavior changes 
> from original version, I guess it won't not change significantly)? and update 
> the data in the description before landing.

Updated the stats. The stats are still very similar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

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


[PATCH] D94786: [clang][ASTImporter] Add support for importing CXXFoldExpr.

2021-01-19 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Looks good to me! Thanks!




Comment at: clang/lib/AST/ASTImporter.cpp:8019
+  auto ToType = importChecked(Err, E->getType());
+  auto ToCallee = importChecked(Err, E->getCallee());
+  auto ToLParenLoc = importChecked(Err, E->getLParenLoc());

Could you please address the Lint messages? Making it `auto *` has sense.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:642-649
+const internal::VariadicDynCastAllOfMatcher cxxFoldExpr;
+
+AST_MATCHER_P(CXXFoldExpr, hasOperator, BinaryOperatorKind, Op) {
+  return Node.getOperator() == Op;
+}
+AST_MATCHER(CXXFoldExpr, hasInit) { return Node.getInit(); }
+AST_MATCHER(CXXFoldExpr, isRightFold) { return Node.isRightFold(); }

Perhaps we could add this directly to ASTMatchers.h ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94786

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain skeleton for AMDGPU

2021-01-19 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 317553.
pdhaliwal added a comment.

Fix clang-tidy error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.h

Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -0,0 +1,85 @@
+//===- AMDGPUOpenMP.h - AMDGPUOpenMP ToolChain Implementation -*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
+
+#include "AMDGPU.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+
+namespace tools {
+
+namespace AMDGCN {
+// Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
+// device library, then compiles it to ISA in a shared object.
+class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool {
+public:
+  OpenMPLinker(const ToolChain &TC)
+  : Tool("AMDGCN::OpenMPLinker", "amdgcn-link", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
+} // end namespace AMDGCN
+} // end namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY AMDGPUOpenMPToolChain final
+: public ROCMToolChain {
+public:
+  AMDGPUOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
+const ToolChain &HostTC,
+const llvm::opt::ArgList &Args);
+
+  const llvm::Triple *getAuxTriple() const override {
+return &HostTC.getTriple();
+  }
+
+  llvm::opt::DerivedArgList *
+  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+
+  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const override;
+
+  SanitizerMask getSupportedSanitizers() const override;
+
+  VersionTuple
+  computeMSVCVersion(const Driver *D,
+ const llvm::opt::ArgList &Args) const override;
+
+  const ToolChain &HostTC;
+
+protected:
+  Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -0,0 +1,116 @@
+//===- AMDGPUOpenMP.cpp - AMDGPUOpenMP ToolChain Implementation -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AMDGPUOpenMP.h"
+#include "AMDGPU.h"
+#include "CommonArgs.h"
+#include "InputInfo.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang::driver::tools;
+using namespace clang;
+using namespace llvm::opt;
+
+// For amdgcn the inputs of the linker job are device bitcode and output is
+// object file. It calls llvm-link, opt, llc, then lld steps.
+void AMDGCN::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output,
+const InputInfoList &Inputs,
+const ArgList &Args,
+const char *LinkingOu

[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain skeleton for AMDGPU

2021-01-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Won't this just prevent us from building clang due to the missing cmake 
changes? We need somewhat testable chunks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain skeleton for AMDGPU

2021-01-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D94961#2506460 , @JonChesterfield 
wrote:

> This patch was written, roughly, by:
>
> - copying the known-working openmp driver from rocm into the trunk source tree
> - deleting lots of stuff that didn't look necessary
> - deleting some stuff that is broadly necessary, but the specifics are up for 
> debate
>
> The idea is to move language-independent but amdgcn-specific code into 
> ROCMToolChain. Some has already gone in, others (like computeMSVCVersion) 
> will likely move too.
>
> Regarding the rest of the end to end stack:
>
> - host plugin works, same code in trunk / rocm / aomp
> - device plugin will work once it's building as openmp, modulo printf and 
> malloc
> - compiler backend will work for spmd kernels today, will work for generic 
> kernels after D94648  or equivalent lands
>
> Regarding tests (which need the unimplemented bit filled in with the next 
> patch):
>
> - Runtime tests (for spmd kernels) are working locally with a jury rigged 
> devicertl
> - Codegen tests are proving awkward to update. Dropping line number would 
> help, but there's still a difference in addrspace cast distribution. I'm 
> hoping the scripts involved in generating the nvptx cases can be adapted.

Could you add the tests for the tools invocation to check that the newly added 
classes/functions correctly translate options/flags?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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



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

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.



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

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?



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

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?


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] D94880: Add clang-query support for mapAnyOf

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

LGTM aside from some minor nits.




Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:1081
+if (NodeKinds.empty()) {
+  // Set error
+  return {};

Is this a TODO comment?



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:1095-1098
+  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
+   std::vector &ArgKinds) const override {
+return;
+  }





Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:1099-1100
+  }
+  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity = nullptr,
+   ASTNodeKind *LeastDerivedKind = nullptr) const override 
{
+return false;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94880

___
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 Adam Czachorowski via Phabricator via cfe-commits
adamcz accepted this revision.
adamcz added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Quality.cpp:477
 
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).

Can you add a comment explaining how you chose those magic numbers? So that in 
the future, when someone needs to change it somehow, they have an idea of where 
this came from.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94927

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


[clang-tools-extra] 8bf7116 - [clangd] Index local classes, virtual and overriding methods.

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

Author: Utkarsh Saxena
Date: 2021-01-19T16:18:48+01:00
New Revision: 8bf7116d50bfe8cb881273798ff384ed965c05e9

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

LOG: [clangd] Index local classes, virtual and overriding methods.

Previously we did not record local class declarations. Now with features like
findImplementation and typeHierarchy, we have a need to index such local
classes to accurately report subclasses and implementations of methods.

Performance testing results:
- No changes in indexing timing.
- No significant change in memory usage.
- **1%** increase in #relations.
- **0.17%** increase in #refs.
- **0.22%** increase #symbols.

**New index stats**
Time to index: **4:13 min**
memory usage **543MB**
number of symbols: **521.5K**
number of refs: **8679K**
number of relations: **49K**

**Base Index stats**
Time to index: **4:15 min**
memory usage **542MB**
number of symbols: **520K**
number of refs: **8664K**
number of relations: **48.5K**

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

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

Added: 


Modified: 
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/IndexAction.cpp
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index 143e76863777..26084c288674 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -61,7 +61,8 @@ SlabTuple indexSymbols(ASTContext &AST, 
std::shared_ptr PP,
   // We only need declarations, because we don't count references.
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
-  IndexOpts.IndexFunctionLocals = false;
+  // We index function-local classes and its member functions only.
+  IndexOpts.IndexFunctionLocals = true;
   if (IsIndexMainAST) {
 // We only collect refs when indexing main AST.
 CollectorOpts.RefFilter = RefKind::All;

diff  --git a/clang-tools-extra/clangd/index/IndexAction.cpp 
b/clang-tools-extra/clangd/index/IndexAction.cpp
index aa65008b51c0..e5a48df90b4d 100644
--- a/clang-tools-extra/clangd/index/IndexAction.cpp
+++ b/clang-tools-extra/clangd/index/IndexAction.cpp
@@ -212,6 +212,8 @@ std::unique_ptr createStaticIndexingAction(
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::All;
+  // We index function-local classes and its member functions only.
+  IndexOpts.IndexFunctionLocals = true;
   Opts.CollectIncludePath = true;
   if (Opts.Origin == SymbolOrigin::Unknown)
 Opts.Origin = SymbolOrigin::Static;

diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index bba5eaa36754..ad1299aa1445 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -452,7 +452,7 @@ readCompileCommand(Reader CmdReader, 
llvm::ArrayRef Strings) {
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 15;
+constexpr static uint32_t Version = 16;
 
 llvm::Expected readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);

diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 20f2eacafb27..b1363c1f9cef 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -223,6 +223,11 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl 
&ND,
   if (!IsMainFileOnly && ND.isInAnonymousNamespace())
 return false;
 
+  // For function local symbols, index only classes and its member functions.
+  if (index::isFunctionLocalSymbol(&ND))
+return isa(ND) ||
+   (ND.isCXXInstanceMember() && ND.isFunctionOrFunctionTemplate());
+
   // We want most things but not "local" symbols such as symbols inside
   // FunctionDecl, BlockDecl, ObjCMethodDecl and OMPDeclareReductionDecl.
   // FIXME: Need a matcher for ExportDecl in order to include symbols declared

diff  --git a/clang-tools-extra/clangd/index/Symbo

[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-19 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bf7116d50bf: [clangd] Index local classes, virtual and 
overriding methods. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1637,14 +1637,28 @@
 template
 struct $5^TemplateBase {};
 struct $5[[Child3]] : public TemplateBase {};
+
+// Local classes.
+void LocationFunction() {
+  struct $0[[LocalClass1]] : Base {
+void $1[[Foo]]() override;
+  };
+  struct $6^LocalBase {
+virtual void $7^Bar();
+  };
+  struct $6[[LocalClass2]]: LocalBase {
+void $7[[Bar]]() override;
+  };
+}
   )cpp";
 
   Annotations Code(Test);
   auto TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  for (StringRef Label : {"0", "1", "2", "3", "4", "5"}) {
+  auto Index = TU.index();
+  for (StringRef Label : {"0", "1", "2", "3", "4", "5", "6", "7"}) {
 for (const auto &Point : Code.points(Label)) {
-  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  EXPECT_THAT(findImplementations(AST, Point, Index.get()),
   UnorderedPointwise(DeclRange(), Code.ranges(Label)))
   << Code.code() << " at " << Point << " for Label " << Label;
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -55,6 +55,7 @@
   return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
+MATCHER_P(HasName, Name, "") { return arg.Name == Name; }
 MATCHER_P(TemplateArgs, TemplArgs, "") {
   return arg.TemplateSpecializationArgs == TemplArgs;
 }
@@ -157,6 +158,37 @@
   EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
 }
 
+TEST_F(ShouldCollectSymbolTest, CollectLocalClassesAndVirtualMethods) {
+  build(R"(
+namespace nx {
+auto f() {
+  int Local;
+  auto LocalLambda = [&](){
+Local++;
+class ClassInLambda{};
+return Local;
+  };
+} // auto ensures function body is parsed.
+auto foo() {
+  class LocalBase {
+virtual void LocalVirtual();
+void LocalConcrete();
+int BaseMember;
+  };
+}
+} // namespace nx
+  )",
+"");
+  auto AST = File.build();
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("ClassInLambda", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalBase", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalVirtual", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalConcrete", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("BaseMember", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+}
+
 TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
   HeaderName = "f.proto.h";
   build(
@@ -228,7 +260,7 @@
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
-IndexOpts.IndexFunctionLocals = false;
+IndexOpts.IndexFunctionLocals = true;
 Collector = std::make_shared(COpts);
 return std::make_unique(Collector, std::move(IndexOpts),
  PragmaHandler);
@@ -320,7 +352,11 @@
 void ff() {} // ignore
 }
 
-void f1() {}
+void f1() {
+  auto LocalLambda = [&](){
+class ClassInLambda{};
+  };
+}
 
 namespace foo {
 // Type alias
@@ -351,7 +387,7 @@
AllOf(QName("Foo::operator="), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested"), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested::f"), ForCodeCompletion(false)),
-
+   AllOf(QName("ClassInLambda"), ForCodeCompletion(false)),
AllOf(QName("Friend"), ForCodeCompletion(true)),
AllOf(QName("f1"), ForCodeCompletion(true)),
AllOf(QName("f2"), For

[libunwind] 480643a - [CMake] Remove dead code setting policies to NEW

2021-01-19 Thread Raul Tambre via cfe-commits

Author: Raul Tambre
Date: 2021-01-19T17:19:36+02:00
New Revision: 480643a95cd157e654f4f97e8231b18850e7d79a

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

LOG: [CMake] Remove dead code setting policies to NEW

cmake_minimum_required(VERSION) calls cmake_policy(VERSION),
which sets all policies up to VERSION to NEW.
LLVM started requiring CMake 3.13 last year, so we can remove
a bunch of code setting policies prior to 3.13 to NEW as it
no longer has any effect.

Reviewed By: phosek, #libunwind, #libc, #libc_abi, ldionne

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

Added: 


Modified: 
clang/CMakeLists.txt
compiler-rt/CMakeLists.txt
flang/CMakeLists.txt
libcxx/CMakeLists.txt
libcxx/utils/ci/runtimes/CMakeLists.txt
libcxxabi/CMakeLists.txt
libunwind/CMakeLists.txt
lldb/CMakeLists.txt
llvm/CMakeLists.txt
mlir/examples/standalone/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f1e5a39cfe05..9e74014134a0 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -1,9 +1,5 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
 # If we are not building as a part of LLVM, build Clang as an
 # standalone project, using LLVM as an external library:
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )

diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 30302c2c1427..b44ad2c2118e 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -5,10 +5,6 @@
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
 # Check if compiler-rt is built as a standalone project.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
COMPILER_RT_STANDALONE_BUILD)
   project(CompilerRT C CXX ASM)

diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 07d34354bd81..79aa53830d5e 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -1,20 +1,6 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-# RPATH settings on macOS do not affect INSTALL_NAME.
-if (POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-# Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-# option() honors normal variables.
-if (POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
 
 option(LINK_WITH_FIR "Link driver with FIR and LLVM" ON)
 option(FLANG_BUILD_NEW_DRIVER "Build the flang compiler driver" OFF)

diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f4c7e9992f71..46a669500548 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -10,16 +10,7 @@ endif()
 
#===
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-if(POLICY CMP0022)
-  cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
-endif()
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
 
 # Add path for custom modules
 set(CMAKE_MODULE_PATH

diff  --git a/libcxx/utils/ci/runtimes/CMakeLists.txt 
b/libcxx/utils/ci/runtimes/CMakeLists.txt
index 20980b530d4d..ab4182ae949e 100644
--- a/libcxx/utils/ci/runtimes/CMakeLists.txt
+++ b/libcxx/utils/ci/runtimes/CMakeLists.txt
@@ -1,20 +1,8 @@
 cmake_minimum_required(VERSION 3.13.4)
-
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-if(POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
-
 project(LLVM_RUNTIMES)
 
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+
 find_package(Python3 COMPONENTS Interpreter)
 if(NOT Python3_Interpreter_FOUND)
   message(WARNING "Python3 not found, using python2 as a fallback")

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 146749f57b0a..c8ab9d7acb1d 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -10,10 +10,6 @@ endif()
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index e344263173b0..8ae32fbccf4e 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -8,10 +8,6 @@ endif()
 
 cmake_minimum_required(VERSION 3.13.4)
 
-

[clang] 480643a - [CMake] Remove dead code setting policies to NEW

2021-01-19 Thread Raul Tambre via cfe-commits

Author: Raul Tambre
Date: 2021-01-19T17:19:36+02:00
New Revision: 480643a95cd157e654f4f97e8231b18850e7d79a

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

LOG: [CMake] Remove dead code setting policies to NEW

cmake_minimum_required(VERSION) calls cmake_policy(VERSION),
which sets all policies up to VERSION to NEW.
LLVM started requiring CMake 3.13 last year, so we can remove
a bunch of code setting policies prior to 3.13 to NEW as it
no longer has any effect.

Reviewed By: phosek, #libunwind, #libc, #libc_abi, ldionne

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

Added: 


Modified: 
clang/CMakeLists.txt
compiler-rt/CMakeLists.txt
flang/CMakeLists.txt
libcxx/CMakeLists.txt
libcxx/utils/ci/runtimes/CMakeLists.txt
libcxxabi/CMakeLists.txt
libunwind/CMakeLists.txt
lldb/CMakeLists.txt
llvm/CMakeLists.txt
mlir/examples/standalone/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f1e5a39cfe05..9e74014134a0 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -1,9 +1,5 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
 # If we are not building as a part of LLVM, build Clang as an
 # standalone project, using LLVM as an external library:
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )

diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 30302c2c1427..b44ad2c2118e 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -5,10 +5,6 @@
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
 # Check if compiler-rt is built as a standalone project.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
COMPILER_RT_STANDALONE_BUILD)
   project(CompilerRT C CXX ASM)

diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 07d34354bd81..79aa53830d5e 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -1,20 +1,6 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-# RPATH settings on macOS do not affect INSTALL_NAME.
-if (POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-# Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-# option() honors normal variables.
-if (POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
 
 option(LINK_WITH_FIR "Link driver with FIR and LLVM" ON)
 option(FLANG_BUILD_NEW_DRIVER "Build the flang compiler driver" OFF)

diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f4c7e9992f71..46a669500548 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -10,16 +10,7 @@ endif()
 
#===
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-if(POLICY CMP0022)
-  cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
-endif()
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
 
 # Add path for custom modules
 set(CMAKE_MODULE_PATH

diff  --git a/libcxx/utils/ci/runtimes/CMakeLists.txt 
b/libcxx/utils/ci/runtimes/CMakeLists.txt
index 20980b530d4d..ab4182ae949e 100644
--- a/libcxx/utils/ci/runtimes/CMakeLists.txt
+++ b/libcxx/utils/ci/runtimes/CMakeLists.txt
@@ -1,20 +1,8 @@
 cmake_minimum_required(VERSION 3.13.4)
-
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-if(POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
-
 project(LLVM_RUNTIMES)
 
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+
 find_package(Python3 COMPONENTS Interpreter)
 if(NOT Python3_Interpreter_FOUND)
   message(WARNING "Python3 not found, using python2 as a fallback")

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 146749f57b0a..c8ab9d7acb1d 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -10,10 +10,6 @@ endif()
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index e344263173b0..8ae32fbccf4e 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -8,10 +8,6 @@ endif()
 
 cmake_minimum_required(VERSION 3.13.4)
 
-

[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 accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

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?


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] D94624: PATCH] [clang-query] Add a --use-color option to clang-query to allow forcing the behavior

2021-01-19 Thread Tom Ritter via Phabricator via cfe-commits
tomrittervg added a comment.

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.


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] D94374: [CMake] Remove dead code setting policies to NEW

2021-01-19 Thread Raul Tambre via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG480643a95cd1: [CMake] Remove dead code setting policies to 
NEW (authored by tambre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94374

Files:
  clang/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  flang/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/utils/ci/runtimes/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  mlir/examples/standalone/CMakeLists.txt

Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -1,20 +1,8 @@
 cmake_minimum_required(VERSION 3.13.4)
-
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-if(POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
-
 project(standalone-dialect LANGUAGES CXX C)
 
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+
 set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
 
 find_package(MLIR REQUIRED CONFIG)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -2,18 +2,7 @@
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-if(POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
 
 if(NOT DEFINED LLVM_VERSION_MAJOR)
   set(LLVM_VERSION_MAJOR 12)
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -1,13 +1,5 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-if(POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
-
 # Add path for custom modules.
 set(CMAKE_MODULE_PATH
   ${CMAKE_MODULE_PATH}
Index: libunwind/CMakeLists.txt
===
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -8,10 +8,6 @@
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if (POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -10,10 +10,6 @@
 
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
Index: libcxx/utils/ci/runtimes/CMakeLists.txt
===
--- libcxx/utils/ci/runtimes/CMakeLists.txt
+++ libcxx/utils/ci/runtimes/CMakeLists.txt
@@ -1,20 +1,8 @@
 cmake_minimum_required(VERSION 3.13.4)
-
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-endif()
-
-if(POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif()
-
 project(LLVM_RUNTIMES)
 
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+
 find_package(Python3 COMPONENTS Interpreter)
 if(NOT Python3_Interpreter_FOUND)
   message(WARNING "Python3 not found, using python2 as a fallback")
Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -10,16 +10,7 @@
 #===
 cmake_minimum_required(VERSION 3.13.4)
 
-if(POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
-endif()
-if(POLICY CMP0022)
-  cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
-endif()
-if(POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
 
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
Index: flang/CMakeLists.txt
===
--- flang/CMakeLists.txt
+++ flang/CMakeLists.txt
@@ -1,20 +1,6 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-# RPATH settings on macOS do not affect INSTALL_NAME.
-if (POLICY CMP0068)
-  cmake_policy(SET CMP0068 NEW)
-  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
-endif()
-
-# Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
-if(POLICY CMP0075)
-  cmake_policy(SET CMP0075 NEW)
-en

[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 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:
> > 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.


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] D94973: [clang][OpenMP] Use OpenMPIRBuilder for workshare loops.

2021-01-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: jdoerfert, AMDChirag, anchu-rajendran, 
kiranchandramohan, SouraVX, ftynse, kiranktp, fghanim, ABataev.
Meinersbur added projects: OpenMP, clang.
Herald added subscribers: dexonsmith, rriddle, arphaman, guansong, hiraditya, 
yaxunl.
Meinersbur requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1, stephenneuendorffer.
Herald added a project: LLVM.

Initial support for using the OpenMPIRBuilder by clang to generate loops using 
the OpenMPIRBuilder. This initial support is intentionally limited to:

- Only the worksharing-loop directive.
- Recognizes only the nowait clause.
- No loop nests with more than one loop.
- Untested with templates, exceptions.
- Semantic checking left to the existing infrastructure.

This patch introduces a new AST node, OMPCanonicalLoop, which becomes parent of 
any loop that has to adheres to the restrictions as specified by the OpenMP 
standard. These restrictions allow OMPCanonicalLoop to provide the following 
additional information that depends on base language semantics:

- The distance function: How many loop iterations there will be before entering 
the loop nest.
- The loop variable function: Conversion from a logical iteration number to the 
loop variable.

These allow the OpenMPIRBuilder to act solely using logical iteration numbers 
without needing to be concerned with iterator semantics between calling the 
distance function and determining what the value of the loop variable ought to 
be. Any OpenMP logical should be done by the OpenMPIRBuilder such that it can 
be reused MLIR OpenMP dialect and thus by flang.

The distance and loop variable function are implemented using lambdas (or more 
exactly: CapturedStmt because lambda implementation is more interviewed with 
the parser). It is up to the OpenMPIRBuilder how they are called which depends 
on what is done with the loop. By default, these are emitted as outlined 
functions but we might think about emitting them inline as the OpenMPRuntime 
does.

For compatibility with the current OpenMP implementation, even though not 
necessary for the OpenMPIRBuilder, OMPCanonicalLoop can still be nested within 
OMPLoopDirectives' CapturedStmt. Although OMPCanonicalLoop's are not currently 
generated when the OpenMPIRBuilder is not enabled, these can just be skipped 
when not using the OpenMPIRBuilder in case we don't want to make the AST 
dependent on the EnableOMPBuilder setting.

Loop nests with more than one loop require support by the OpenMPIRBuilder 
(D93268 ). A simple implementation of 
non-rectangular loop nests would add another lambda function that returns 
whether a loop iteration of the rectangular overapproximation is also within 
its non-rectangular subset.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94973

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/OpenMP/irbuilder_for_unsigned.c
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -972,7 +972,8 @@
 
   // Emit the body content. We do it after connecting the loop to the CFG to
   // avoid that the callback encounters degenerate BBs.
-  BodyGenCB(CL->getBodyIP(), CL->getIndVar());
+  if (BodyGenCB)
+BodyGenCB(CL->getBodyIP(), CL->getIndVar());
 
 #ifndef NDEBUG
   CL->assertOK();
@@ -1165,6 +1166,14 @@
   return CLI;
 }
 
+CanonicalLoopInfo *OpenMPIRBuilder::createWorkshareLoop(const LocationDescription &Loc,
+CanonicalLoopInfo *CLI,
+InsertPointTy AllocaIP,
+bool NeedsBarrier) {
+  // Currently only supports static schedules.
+  return createStaticWorkshareLoop(Loc, CLI, AllocaIP, NeedsBarrier);
+}
+
 OpenMPIRBuilder::InsertPointTy
 OpenMPIRBuilder::createCopyPrivate(const LocationDescription &Loc,
   

[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 Johannes Doerfert via Phabricator via cfe-commits
jdoerfert 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:
> > > 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.
FWIW, I can also use ifdef, or various other context selectors to achieve the 
same effect.


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] 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:
> > > 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.



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);

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

[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-01-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

I didn't check correctness of each Factory function but if it passes all tests 
and improves performance, I think it's enough.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:77-78
+  //
+  //   * Range sets are usually very simple, 1 or 2 ranges.
+  // That's why llvm::ImmutableSet is not perfect.
+  //

That's very usefull description for reviewers, but I think is redundant for 
newcomers, when you're reading this you can't understand why it compares to 
`ImmutableSet` at all. I think this preamble only relates to the Summary of 
this patch as the core reason of this change.
You can just mention the fact that formerly it was an `ImmutableSet`. See 
//http// for details.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:133
+/// where N = size(Original)
+RangeSet add(RangeSet Original, Range Element);
+

We can add one more instance of `add` (and maybe others): `RangeSet 
add(RangeSet original, llvm::APSInt &point);`.
Since we have `RangeSet(Factory &F, const llvm::APSInt &Point)` ctor, why 
wouldn't we have similar functionality in the `Factory`?

It could simplify function `RangeSetTest::from` in tests and be useful across 
the code on the whole.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:178
+/// where N = size(From)
+RangeSet deletePoint(const llvm::APSInt &Point, RangeSet From);
+/// Negate the given range set.

IMHO you should change params with each other:
`deletePoint(const llvm::APSInt &Point, RangeSet From)` -> 
`deletePoint(RangeSet Original, const llvm::APSInt &Point)`
This will look more consistent with other interfaces like in `add` or 
`intersect` functions.



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:105
+  void checkNegate(RawRangeSet RawOriginal, RawRangeSet RawExpected) {
+wrap(&Self::checkNegateImpl, RawOriginal, RawExpected);
+  }

Explain, please, what's the matter to use `wrap` everywhere, not just call 
`checkNegateImpl` explicitly?
Won't the call works and looks the same? Like:
```
this->checkNegateImpl({{MIN, A}}, {{MIN, MIN}, {D, MAX}});
```



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:185
+
+using IntTypes = ::testing::Types;

Thank you for making it in a proper way, instead of a list with different type 
instantiations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D94403: [RISCV] Implement new architecture extension macros

2021-01-19 Thread Simon Cook via Phabricator via cfe-commits
simoncook updated this revision to Diff 317591.
simoncook added a comment.

Have 'b'/'v' features imply subfeatures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94403

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  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
@@ -12,12 +12,26 @@
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
 // CHECK-NOT: __riscv_atomic
+// CHECK-NOT: __riscv_zbb
+// CHECK-NOT: __riscv_zbc
+// CHECK-NOT: __riscv_zbe
+// CHECK-NOT: __riscv_zbf
+// CHECK-NOT: __riscv_zbm
+// CHECK-NOT: __riscv_zbp
+// CHECK-NOT: __riscv_zbproposedc
+// CHECK-NOT: __riscv_zbr
+// CHECK-NOT: __riscv_zbs
+// CHECK-NOT: __riscv_zbt
+// CHECK-NOT: __riscv_zfh
+// CHECK-NOT: __riscv_zvamo
+// CHECK-NOT: __riscv_zvlsseg
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
 // CHECK-M-EXT: __riscv_div 1
+// CHECK-M-EXT: __riscv_m 200
 // CHECK-M-EXT: __riscv_mul 1
 // CHECK-M-EXT: __riscv_muldiv 1
 
@@ -25,12 +39,14 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ia -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
+// CHECK-A-EXT: __riscv_a 200
 // CHECK-A-EXT: __riscv_atomic 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32if -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64if -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
+// CHECK-F-EXT: __riscv_f 200
 // CHECK-F-EXT: __riscv_fdiv 1
 // CHECK-F-EXT: __riscv_flen 32
 // CHECK-F-EXT: __riscv_fsqrt 1
@@ -39,6 +55,8 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
+// CHECK-D-EXT: __riscv_d 200
+// CHECK-D-EXT: __riscv_f 200
 // CHECK-D-EXT: __riscv_fdiv 1
 // CHECK-D-EXT: __riscv_flen 64
 // CHECK-D-EXT: __riscv_fsqrt 1
@@ -47,13 +65,24 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
+// CHECK-C-EXT: __riscv_c 200
 // CHECK-C-EXT: __riscv_compressed 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32ib0p92 -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: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_b 92000
 // CHECK-B-EXT: __riscv_bitmanip 1
+// CHECK-B-EXT: __riscv_zbb 92000
+// CHECK-B-EXT: __riscv_zbc 92000
+// CHECK-B-EXT: __riscv_zbe 92000
+// CHECK-B-EXT: __riscv_zbf 92000
+// CHECK-B-EXT: __riscv_zbm 92000
+// CHECK-B-EXT: __riscv_zbp 92000
+// CHECK-B-EXT: __riscv_zbr 92000
+// CHECK-B-EXT: __riscv_zbs 92000
+// CHECK-B-EXT: __riscv_zbt 92000
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
@@ -85,10 +114,85 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
 // RUN:   -march=rv64iv0p9 -x c -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// CHECK-V-EXT: __riscv_v 9000
 // CHECK-V-EXT: __riscv_vector 1
-//
+// CHECK-V-EXT: __riscv_zvamo 9000
+// CHECK-V-EXT: __riscv_zvlsseg 9000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izbb0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izbb0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
+// CHECK-ZBB-EXT: __riscv_zbb 92000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izbc0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izbc0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
+// CHECK-ZBC-EXT: __riscv_zbc 92000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-ext

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

2021-01-19 Thread Sylvain Audi via Phabricator via cfe-commits
saudi added a comment.

Ping!
Would anybody have a chance to take a look at this? I'd like to submit this 
before the LLVM 12 branch, if possible? Thanks in advance!


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] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-01-19 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Gentle ping! Can we merge this? I'd love to move forward with 
https://reviews.llvm.org/D90257.


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

https://reviews.llvm.org/D91630

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


[PATCH] D94391: CGDebugInfo: Drop Loc.isInvalid() special case from getLineNumber

2021-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D94391#2495056 , @dblaikie wrote:

> I'll leave this one to @aprantl

@aprantl :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94391

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


[clang] cbdde49 - [clang-format] Apply Allman style to lambdas

2021-01-19 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2021-01-19T18:17:01+01:00
New Revision: cbdde495ba28915d52b561e44aaba12db4cf724f

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

LOG: [clang-format] Apply Allman style to lambdas

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9f007819326c..110e1a726f55 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -801,6 +801,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) {
 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;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index ae8bfc60f6d9..1565016802f9 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,58 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
"#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"



___
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;

[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] 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] 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 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] 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] 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] 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] 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] 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 |

[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] 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


[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] 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] 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] 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


[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] 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

_

[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


[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


[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


  1   2   >