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

2020-09-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:746
+  Expanded.BraceWrapping.SplitEmptyRecord = true;
+  Expanded.BraceWrapping.SplitEmptyNamespace = true;
+  Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;

I didn't notice this change before... I'm not a massive fan of the code on the 
LHS, actually it was me that added the /*XXX=*/ to make it clearer.. however

If a new style is added to the BraceWrapping style then the code on the left I 
think will complain, but the code on the right will not and so its easy to miss 
a new default case.

Do we need to consider that?

Infact you didn't seem to change that until the very last diff! was that 
intentional?


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

https://reviews.llvm.org/D75791

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


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

2020-09-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:586
 IO.mapOptional("SortIncludes", Style.SortIncludes);
 IO.mapOptional("SortJavaStaticImport", Style.SortJavaStaticImport);
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);

I'm confused by this diff... the Review is closed, if you are proposing changes 
please make a new review


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

https://reviews.llvm.org/D75791

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


[PATCH] D88034: [SyntaxTree][Synthesis] Implement `deepCopyExpandingMacros`

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 293361.
eduucaldas added a comment.

Remove buggy `deepCopy`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88034

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp

Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -217,7 +217,53 @@
  GetParam());
 
   auto *Copy = deepCopy(*Arena, OriginalTree);
-  EXPECT_TRUE(Copy == nullptr);
+  EXPECT_EQ(Copy, nullptr);
+}
+
+TEST_P(SynthesisTest, DeepCopy_MacroExpanding) {
+  auto *OriginalTree = buildTree(R"cpp(
+#define HALF_IF if (1+
+#define HALF_IF_2 1) {}
+void test() {
+  HALF_IF HALF_IF_2 else {}
+})cpp",
+ GetParam());
+
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree);
+
+  // The syntax tree stores expanded Tokens already, as a result we can only see
+  // the macro expansion when computing replacements. The dump does show that
+  // nodes are `modifiable` now.
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+TranslationUnit Detached synthesized
+`-SimpleDeclaration synthesized
+  |-'void' synthesized
+  |-SimpleDeclarator Declarator synthesized
+  | |-'test' synthesized
+  | `-ParametersAndQualifiers synthesized
+  |   |-'(' OpenParen synthesized
+  |   `-')' CloseParen synthesized
+  `-CompoundStatement synthesized
+|-'{' OpenParen synthesized
+|-IfStatement Statement synthesized
+| |-'if' IntroducerKeyword synthesized
+| |-'(' synthesized
+| |-BinaryOperatorExpression synthesized
+| | |-IntegerLiteralExpression LeftHandSide synthesized
+| | | `-'1' LiteralToken synthesized
+| | |-'+' OperatorToken synthesized
+| | `-IntegerLiteralExpression RightHandSide synthesized
+| |   `-'1' LiteralToken synthesized
+| |-')' synthesized
+| |-CompoundStatement ThenStatement synthesized
+| | |-'{' OpenParen synthesized
+| | `-'}' CloseParen synthesized
+| |-'else' ElseKeyword synthesized
+| `-CompoundStatement ElseStatement synthesized
+|   |-'{' OpenParen synthesized
+|   `-'}' CloseParen synthesized
+`-'}' CloseParen synthesized
+  )txt"));
 }
 
 TEST_P(SynthesisTest, Statement_EmptyStatement) {
Index: clang/lib/Tooling/Syntax/Synthesis.cpp
===
--- clang/lib/Tooling/Syntax/Synthesis.cpp
+++ clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -201,25 +201,11 @@
   return T;
 }
 
-namespace {
-bool canModifyAllDescendants(const syntax::Node *N) {
-  if (const auto *L = dyn_cast(N))
-return L->canModify();
-
-  const auto *T = cast(N);
-
-  if (!T->canModify())
-return false;
-  for (const auto *Child = T->getFirstChild(); Child;
-   Child = Child->getNextSibling())
-if (!canModifyAllDescendants(Child))
-  return false;
-
-  return true;
-}
-
-syntax::Node *deepCopyImpl(syntax::Arena &A, const syntax::Node *N) {
+syntax::Node *clang::syntax::deepCopyExpandingMacros(syntax::Arena &A,
+ const syntax::Node *N) {
   if (const auto *L = dyn_cast(N))
+// `L->getToken()` gives us the expanded token, thus we implicitly expand
+// any macros here.
 return createLeaf(A, L->getToken()->kind(),
   L->getToken()->text(A.getSourceManager()));
 
@@ -227,18 +213,10 @@
   std::vector> Children;
   for (const auto *Child = T->getFirstChild(); Child;
Child = Child->getNextSibling())
-Children.push_back({deepCopyImpl(A, Child), Child->getRole()});
+Children.push_back({deepCopyExpandingMacros(A, Child), Child->getRole()});
 
   return createTree(A, Children, N->getKind());
 }
-} // namespace
-
-syntax::Node *clang::syntax::deepCopy(syntax::Arena &A, const Node *N) {
-  if (!canModifyAllDescendants(N))
-return nullptr;
-
-  return deepCopyImpl(A, N);
-}
 
 syntax::EmptyStatement *clang::syntax::createEmptyStatement(syntax::Arena &A) {
   return cast(
Index: clang/include/clang/Tooling/Syntax/BuildTree.h
===
--- clang/include/clang/Tooling/Syntax/BuildTree.h
+++ clang/include/clang/Tooling/Syntax/BuildTree.h
@@ -45,17 +45,13 @@
 // Synthesis of Syntax Nodes
 syntax::EmptyStatement *createEmptyStatement(syntax::Arena &A);
 
-/// Creates a completely independent copy of `N` (a deep copy).
+/// Creates a completely independent copy of `N` with its macros expanded.
 ///
 /// The copy is:
 /// * Detached, i.e. `Parent == NextSibling == nullptr` and
 /// `Role == Detached`.
 /// * Synthesized, i.e. `Original == false`.
-///
-/// `N` might be backed by source code but if any descendants of `N` are
-/// unmodifiable r

[PATCH] D87981: [X86] AMX programming model prototype.

2020-09-22 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 293362.
LuoYuanke added a comment.

Updating D87981 : [X86] AMX programming model 
prototype.
 Fix clang format and add test case for RA that across function call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/AMX/amx_api.c
  llvm/include/llvm/CodeGen/LiveIntervalUnion.h
  llvm/include/llvm/CodeGen/LiveRegMatrix.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/CodeGen/TileShapeInfo.h
  llvm/include/llvm/CodeGen/VirtRegMap.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/LiveIntervalUnion.cpp
  llvm/lib/CodeGen/LiveRegMatrix.cpp
  llvm/lib/CodeGen/VirtRegMap.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Target/X86/X86TileConfig.cpp
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -197,25 +197,25 @@
 enum IIT_Info {
   // Common values should be encoded with 0-15.
   IIT_Done = 0,
-  IIT_I1   = 1,
-  IIT_I8   = 2,
-  IIT_I16  = 3,
-  IIT_I32  = 4,
-  IIT_I64  = 5,
-  IIT_F16  = 6,
-  IIT_F32  = 7,
-  IIT_F64  = 8,
-  IIT_V2   = 9,
-  IIT_V4   = 10,
-  IIT_V8   = 11,
-  IIT_V16  = 12,
-  IIT_V32  = 13,
-  IIT_PTR  = 14,
-  IIT_ARG  = 15,
+  IIT_I1 = 1,
+  IIT_I8 = 2,
+  IIT_I16 = 3,
+  IIT_I32 = 4,
+  IIT_I64 = 5,
+  IIT_F16 = 6,
+  IIT_F32 = 7,
+  IIT_F64 = 8,
+  IIT_V2 = 9,
+  IIT_V4 = 10,
+  IIT_V8 = 11,
+  IIT_V16 = 12,
+  IIT_V32 = 13,
+  IIT_PTR = 14,
+  IIT_ARG = 15,
 
   // Values from 16+ are only encodable with the inefficient encoding.
-  IIT_V64  = 16,
-  IIT_MMX  = 17,
+  IIT_V64 = 16,
+  IIT_MMX = 17,
   IIT_TOKEN = 18,
   IIT_METADATA = 19,
   IIT_EMPTYSTRUCT = 20,
@@ -226,7 +226,7 @@
   IIT_EXTEND_ARG = 25,
   IIT_TRUNC_ARG = 26,
   IIT_ANYPTR = 27,
-  IIT_V1   = 28,
+  IIT_V1 = 28,
   IIT_VARARG = 29,
   IIT_HALF_VEC_ARG = 30,
   IIT_SAME_VEC_WIDTH_ARG = 31,
@@ -246,7 +246,8 @@
   IIT_SUBDIVIDE4_ARG = 45,
   IIT_VEC_OF_BITCASTS_TO_INT = 46,
   IIT_V128 = 47,
-  IIT_BF16 = 48
+  IIT_BF16 = 48,
+  IIT_V256 = 49
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -384,6 +385,9 @@
 case 32: Sig.push_back(IIT_V32); break;
 case 64: Sig.push_back(IIT_V64); break;
 case 128: Sig.push_back(IIT_V128); break;
+case 256:
+  Sig.push_back(IIT_V256);
+  break;
 case 512: Sig.push_back(IIT_V512); break;
 case 1024: Sig.push_back(IIT_V1024); break;
 }
Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -24,6 +24,7 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Basic Alias Analysis (stateless AA impl)
@@ -141,6 +142,7 @@
 ; CHECK-NEXT:   Lazy Machine Block Frequency Analysis
 ; CHECK-NEXT:   Machine Optimization Remark Emitter
 ; CHECK-NEXT:   Greedy Register Allocator
+; CHECK-NEXT:   Tile Register Configure
 ; CHECK-NEXT:   Virtual Register Rewriter
 ; CHECK-NEXT:   Stack Slot Coloring
 ; CHECK-NEXT:   Machine Copy Propagation Pass
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -18,6 +18,7 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
 ; CHECK-NEXT:   

[PATCH] D88034: [SyntaxTree][Synthesis] Implement `deepCopyExpandingMacros`

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 293363.
eduucaldas added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88034

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -22,8 +22,8 @@
 std::vector> ChildrenWithRoles;
 ChildrenWithRoles.reserve(Children.size());
 for (const auto *Child : Children) {
-  ChildrenWithRoles.push_back(
-  std::make_pair(deepCopy(*Arena, Child), NodeRole::Unknown));
+  ChildrenWithRoles.push_back(std::make_pair(
+  deepCopyExpandingMacros(*Arena, Child), NodeRole::Unknown));
 }
 return clang::syntax::createTree(*Arena, ChildrenWithRoles,
  NodeKind::UnknownExpression);
Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -173,7 +173,7 @@
 {LeafSemiColon, NodeRole::Unknown}},
NodeKind::ContinueStatement);
 
-  auto *Copy = deepCopy(*Arena, StatementContinue);
+  auto *Copy = deepCopyExpandingMacros(*Arena, StatementContinue);
   EXPECT_TRUE(
   treeDumpEqual(Copy, StatementContinue->dump(Arena->getSourceManager(;
   // FIXME: Test that copy is independent of original, once the Mutations API is
@@ -183,7 +183,7 @@
 TEST_P(SynthesisTest, DeepCopy_Original) {
   auto *OriginalTree = buildTree("int a;", GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree);
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree);
   EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
 TranslationUnit Detached synthesized
 `-SimpleDeclaration synthesized
@@ -197,7 +197,7 @@
 TEST_P(SynthesisTest, DeepCopy_Child) {
   auto *OriginalTree = buildTree("int a;", GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree->getFirstChild());
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree->getFirstChild());
   EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
 SimpleDeclaration Detached synthesized
 |-'int' synthesized
@@ -216,8 +216,41 @@
 })cpp",
  GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree);
-  EXPECT_TRUE(Copy == nullptr);
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree);
+
+  // The syntax tree stores already expanded Tokens, we can only see whether the
+  // macro was expanded when computing replacements. The dump does show that
+  // nodes in the copy are `modifiable`.
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+TranslationUnit Detached synthesized
+`-SimpleDeclaration synthesized
+  |-'void' synthesized
+  |-SimpleDeclarator Declarator synthesized
+  | |-'test' synthesized
+  | `-ParametersAndQualifiers synthesized
+  |   |-'(' OpenParen synthesized
+  |   `-')' CloseParen synthesized
+  `-CompoundStatement synthesized
+|-'{' OpenParen synthesized
+|-IfStatement Statement synthesized
+| |-'if' IntroducerKeyword synthesized
+| |-'(' synthesized
+| |-BinaryOperatorExpression synthesized
+| | |-IntegerLiteralExpression LeftHandSide synthesized
+| | | `-'1' LiteralToken synthesized
+| | |-'+' OperatorToken synthesized
+| | `-IntegerLiteralExpression RightHandSide synthesized
+| |   `-'1' LiteralToken synthesized
+| |-')' synthesized
+| |-CompoundStatement ThenStatement synthesized
+| | |-'{' OpenParen synthesized
+| | `-'}' CloseParen synthesized
+| |-'else' ElseKeyword synthesized
+| `-CompoundStatement ElseStatement synthesized
+|   |-'{' OpenParen synthesized
+|   `-'}' CloseParen synthesized
+`-'}' CloseParen synthesized
+  )txt"));
 }
 
 TEST_P(SynthesisTest, Statement_EmptyStatement) {
Index: clang/lib/Tooling/Syntax/Synthesis.cpp
===
--- clang/lib/Tooling/Syntax/Synthesis.cpp
+++ clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -201,25 +201,11 @@
   return T;
 }
 
-namespace {
-bool canModifyAllDescendants(const syntax::Node *N) {
-  if (const auto *L = dyn_cast(N))
-return L->canModify();
-
-  const auto *T = cast(N);
-
-  if (!T->canModify())
-return false;
-  for (const auto *Child = T->getFirstChild(); Child;
-   Child = Child->getNextSibling())
-if (!canModifyAllDescendants(Child))
-  return false;
-
-  return true;
-}
-
-syntax::Node *deepCopyImpl(syntax::Arena &A, const syntax::Node *N) {
+syntax::Node *clang::syntax::deepCopyExpandingMacros(syntax::Arena &A,
+

[clang] 3fec6dd - Reapply: [clang-cl] Always interpret the LIB env var as separated with semicolons

2020-09-22 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2020-09-22T10:51:25+03:00
New Revision: 3fec6ddc276a595e4409f04dabdd50c84f5f2a2d

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

LOG: Reapply: [clang-cl] Always interpret the LIB env var as separated with 
semicolons

When cross compiling with clang-cl, clang splits the INCLUDE env
variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp,
MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the
LIB variable similarly (lld/COFF/Driver.cpp,
LinkerDriver::addLibSearchPaths). Therefore, the consensus for
cross compilation with clang-cl and lld-link seems to be to use
semicolons, despite path lists normally being separated by colons
on unix and EnvPathSeparator being set to that.

Therefore, handle the LIB variable similarly in Clang, when
handling lib file arguments when driving linking via Clang.

This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in
a cross compilation setting. Normally, most users call (lld-)link
directly, but meson happens to use this command syntax for
has_function() tests.

Reapply: Change Program.h to define procid_t as ::pid_t. When included
in lldb/unittests/Host/NativeProcessProtocolTest.cpp, it is included
after an lldb namespace containing an lldb::pid_t typedef, followed
later by a "using namespace lldb;". Previously, Program.h wasn't
included in this translation unit, but now it ends up included
transitively from Process.h.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/cl-inputs.c
llvm/include/llvm/Support/Process.h
llvm/include/llvm/Support/Program.h
llvm/lib/Support/Process.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 65b44597bc16..69336f6f94b6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2085,7 +2085,7 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList 
&Args, StringRef Value,
 
   if (IsCLMode()) {
 if (!llvm::sys::path::is_absolute(Twine(Value)) &&
-llvm::sys::Process::FindInEnvPath("LIB", Value))
+llvm::sys::Process::FindInEnvPath("LIB", Value, ';'))
   return true;
 
 if (Args.hasArg(options::OPT__SLASH_link) && Ty == types::TY_Object) {

diff  --git a/clang/test/Driver/cl-inputs.c b/clang/test/Driver/cl-inputs.c
index c67fc24484ee..59455a0aa5e5 100644
--- a/clang/test/Driver/cl-inputs.c
+++ b/clang/test/Driver/cl-inputs.c
@@ -32,7 +32,9 @@
 // WARN-NOT: note
 
 // MSYS2_ARG_CONV_EXCL tells MSYS2 to skip conversion of the specified 
argument.
-// RUN: env LIB=%S/Inputs/cl-libs MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c 
/TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s
+// Add a dummy "other" entry to the path as well, to check that it's split
+// around semicolons even on unix.
+// RUN: env LIB="other;%S/Inputs/cl-libs" MSYS2_ARG_CONV_EXCL="/TP;/c" 
%clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s
 // TPlib: warning: cl-test.lib: 'linker' input unused
 // TPlib: warning: argument unused during compilation: '/TP'
 // TPlib-NOT: cl-test.lib

diff  --git a/llvm/include/llvm/Support/Process.h 
b/llvm/include/llvm/Support/Process.h
index 0ba6d58ba287..af5091ab8ff4 100644
--- a/llvm/include/llvm/Support/Process.h
+++ b/llvm/include/llvm/Support/Process.h
@@ -29,6 +29,7 @@
 #include "llvm/Support/Chrono.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Program.h"
 #include 
 
 namespace llvm {
@@ -107,10 +108,12 @@ class Process {
   /// considered.
   static Optional FindInEnvPath(StringRef EnvName,
  StringRef FileName,
- ArrayRef IgnoreList);
+ ArrayRef IgnoreList,
+ char Separator = 
EnvPathSeparator);
 
   static Optional FindInEnvPath(StringRef EnvName,
- StringRef FileName);
+ StringRef FileName,
+ char Separator = 
EnvPathSeparator);
 
   // This functions ensures that the standard file descriptors (input, output,
   // and error) are properly mapped to a file descriptor before we use any of

diff  --git a/llvm/include/llvm/Support/Program.h 
b/llvm/include/llvm/Support/Program.h
index d729d3883650..b32de47adb57 100644
--- a/llvm/include/llvm/Support/Program.h
+++ b/llvm/include/llvm/Support/Program.h
@@ -36,7 +36,7 @@ namespace sys {
   typedef unsigned long procid_t; // Must match the type of DWORD on Windows.
   typedef void *process_t;// Must match the type of HANDLE on Window

[PATCH] D88009: [AArch64] Fix return type of Neon scalar comparison intrinsics

2020-09-22 Thread David Spickett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf93514545cd9: [AArch64] Fix return type of Neon scalar 
comparison intrinsics (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88009

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/test/CodeGen/aarch64-neon-intrinsics.c

Index: clang/test/CodeGen/aarch64-neon-intrinsics.c
===
--- clang/test/CodeGen/aarch64-neon-intrinsics.c
+++ clang/test/CodeGen/aarch64-neon-intrinsics.c
@@ -13746,8 +13746,8 @@
 // CHECK:   [[TMP0:%.*]] = icmp eq i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vceqd_s64(int64_t a, int64_t b) {
-  return (int64_t)vceqd_s64(a, b);
+uint64_t test_vceqd_s64(int64_t a, int64_t b) {
+  return (uint64_t)vceqd_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vceqd_u64(
@@ -13762,8 +13762,8 @@
 // CHECK:   [[TMP0:%.*]] = icmp eq i64 %a, 0
 // CHECK:   [[VCEQZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQZ_I]]
-int64_t test_vceqzd_s64(int64_t a) {
-  return (int64_t)vceqzd_s64(a);
+uint64_t test_vceqzd_s64(int64_t a) {
+  return (uint64_t)vceqzd_s64(a);
 }
 
 // CHECK-LABEL: @test_vceqzd_u64(
@@ -13778,8 +13778,8 @@
 // CHECK:   [[TMP0:%.*]] = icmp sge i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vcged_s64(int64_t a, int64_t b) {
-  return (int64_t)vcged_s64(a, b);
+uint64_t test_vcged_s64(int64_t a, int64_t b) {
+  return (uint64_t)vcged_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vcged_u64(
@@ -13794,16 +13794,16 @@
 // CHECK:   [[TMP0:%.*]] = icmp sge i64 %a, 0
 // CHECK:   [[VCGEZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCGEZ_I]]
-int64_t test_vcgezd_s64(int64_t a) {
-  return (int64_t)vcgezd_s64(a);
+uint64_t test_vcgezd_s64(int64_t a) {
+  return (uint64_t)vcgezd_s64(a);
 }
 
 // CHECK-LABEL: @test_vcgtd_s64(
 // CHECK:   [[TMP0:%.*]] = icmp sgt i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vcgtd_s64(int64_t a, int64_t b) {
-  return (int64_t)vcgtd_s64(a, b);
+uint64_t test_vcgtd_s64(int64_t a, int64_t b) {
+  return (uint64_t)vcgtd_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vcgtd_u64(
@@ -13818,16 +13818,16 @@
 // CHECK:   [[TMP0:%.*]] = icmp sgt i64 %a, 0
 // CHECK:   [[VCGTZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCGTZ_I]]
-int64_t test_vcgtzd_s64(int64_t a) {
-  return (int64_t)vcgtzd_s64(a);
+uint64_t test_vcgtzd_s64(int64_t a) {
+  return (uint64_t)vcgtzd_s64(a);
 }
 
 // CHECK-LABEL: @test_vcled_s64(
 // CHECK:   [[TMP0:%.*]] = icmp sle i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vcled_s64(int64_t a, int64_t b) {
-  return (int64_t)vcled_s64(a, b);
+uint64_t test_vcled_s64(int64_t a, int64_t b) {
+  return (uint64_t)vcled_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vcled_u64(
@@ -13842,16 +13842,16 @@
 // CHECK:   [[TMP0:%.*]] = icmp sle i64 %a, 0
 // CHECK:   [[VCLEZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCLEZ_I]]
-int64_t test_vclezd_s64(int64_t a) {
-  return (int64_t)vclezd_s64(a);
+uint64_t test_vclezd_s64(int64_t a) {
+  return (uint64_t)vclezd_s64(a);
 }
 
 // CHECK-LABEL: @test_vcltd_s64(
 // CHECK:   [[TMP0:%.*]] = icmp slt i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vcltd_s64(int64_t a, int64_t b) {
-  return (int64_t)vcltd_s64(a, b);
+uint64_t test_vcltd_s64(int64_t a, int64_t b) {
+  return (uint64_t)vcltd_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vcltd_u64(
@@ -13866,8 +13866,8 @@
 // CHECK:   [[TMP0:%.*]] = icmp slt i64 %a, 0
 // CHECK:   [[VCLTZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCLTZ_I]]
-int64_t test_vcltzd_s64(int64_t a) {
-  return (int64_t)vcltzd_s64(a);
+uint64_t test_vcltzd_s64(int64_t a) {
+  return (uint64_t)vcltzd_s64(a);
 }
 
 // CHECK-LABEL: @test_vtstd_s64(
@@ -13875,8 +13875,8 @@
 // CHECK:   [[TMP1:%.*]] = icmp ne i64 [[TMP0]], 0
 // CHECK:   [[VTSTD_I:%.*]] = sext i1 [[TMP1]] to i64
 // CHECK:   ret i64 [[VTSTD_I]]
-int64_t test_vtstd_s64(int64_t a, int64_t b) {
-  return (int64_t)vtstd_s64(a, b);
+uint64_t test_vtstd_s64(int64_t a, int64_t b) {
+  return (uint64_t)vtstd_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vtstd_u64(
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -1419,19 +1419,19 @@
 
 
 // Scalar Integer Comparison
-def SCALAR_CMEQ : SInst<"vceq", "111", "SlSUl">;
-def SCALAR_CMEQZ : SInst<"vceqz", "11", "SlSUl">;
-def SCALAR_CMGE : SInst<"vcge", "111", 

[clang] f935145 - [AArch64] Fix return type of Neon scalar comparison intrinsics

2020-09-22 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2020-09-22T08:53:24+01:00
New Revision: f93514545cd91b132fe987618488b8c1e5388fb0

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

LOG: [AArch64] Fix return type of Neon scalar comparison intrinsics

The following should have unsigned return types
but were signed:
vceqd_s64 vceqzd_s64 vcged_s64 vcgezd_s64
vcgtd_s64 vcgtzd_s64 vcled_s64 vclezd_s64
vcltd_s64 vcltzd_s64 vtstd_s64

See https://developer.arm.com/documentation/ihi0073/latest

Reviewed By: efriedma

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/test/CodeGen/aarch64-neon-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 6369e5a8e342..66b805addd83 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1419,19 +1419,19 @@ def SCALAR_FRSQRTE : IInst<"vrsqrte", "11", "SfSd">;
 
 

 // Scalar Integer Comparison
-def SCALAR_CMEQ : SInst<"vceq", "111", "SlSUl">;
-def SCALAR_CMEQZ : SInst<"vceqz", "11", "SlSUl">;
-def SCALAR_CMGE : SInst<"vcge", "111", "Sl">;
-def SCALAR_CMGEZ : SInst<"vcgez", "11", "Sl">;
-def SCALAR_CMHS : SInst<"vcge", "111", "SUl">;
-def SCALAR_CMLE : SInst<"vcle", "111", "SlSUl">;
-def SCALAR_CMLEZ : SInst<"vclez", "11", "Sl">;
-def SCALAR_CMLT : SInst<"vclt", "111", "SlSUl">;
-def SCALAR_CMLTZ : SInst<"vcltz", "11", "Sl">;
-def SCALAR_CMGT : SInst<"vcgt", "111", "Sl">;
-def SCALAR_CMGTZ : SInst<"vcgtz", "11", "Sl">;
-def SCALAR_CMHI : SInst<"vcgt", "111", "SUl">;
-def SCALAR_CMTST : SInst<"vtst", "111", "SlSUl">;
+def SCALAR_CMEQ : SInst<"vceq", "(U1)11", "SlSUl">;
+def SCALAR_CMEQZ : SInst<"vceqz", "(U1)1", "SlSUl">;
+def SCALAR_CMGE : SInst<"vcge", "(U1)11", "Sl">;
+def SCALAR_CMGEZ : SInst<"vcgez", "(U1)1", "Sl">;
+def SCALAR_CMHS : SInst<"vcge", "(U1)11", "SUl">;
+def SCALAR_CMLE : SInst<"vcle", "(U1)11", "SlSUl">;
+def SCALAR_CMLEZ : SInst<"vclez", "(U1)1", "Sl">;
+def SCALAR_CMLT : SInst<"vclt", "(U1)11", "SlSUl">;
+def SCALAR_CMLTZ : SInst<"vcltz", "(U1)1", "Sl">;
+def SCALAR_CMGT : SInst<"vcgt", "(U1)11", "Sl">;
+def SCALAR_CMGTZ : SInst<"vcgtz", "(U1)1", "Sl">;
+def SCALAR_CMHI : SInst<"vcgt", "(U1)11", "SUl">;
+def SCALAR_CMTST : SInst<"vtst", "(U1)11", "SlSUl">;
 
 

 // Scalar Floating-point Comparison

diff  --git a/clang/test/CodeGen/aarch64-neon-intrinsics.c 
b/clang/test/CodeGen/aarch64-neon-intrinsics.c
index 89632fcd0a98..a24e3c7e5db7 100644
--- a/clang/test/CodeGen/aarch64-neon-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-neon-intrinsics.c
@@ -13746,8 +13746,8 @@ void test_vst1_p64_x4(poly64_t *a, poly64x1x4_t b) {
 // CHECK:   [[TMP0:%.*]] = icmp eq i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vceqd_s64(int64_t a, int64_t b) {
-  return (int64_t)vceqd_s64(a, b);
+uint64_t test_vceqd_s64(int64_t a, int64_t b) {
+  return (uint64_t)vceqd_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vceqd_u64(
@@ -13762,8 +13762,8 @@ uint64_t test_vceqd_u64(uint64_t a, uint64_t b) {
 // CHECK:   [[TMP0:%.*]] = icmp eq i64 %a, 0
 // CHECK:   [[VCEQZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQZ_I]]
-int64_t test_vceqzd_s64(int64_t a) {
-  return (int64_t)vceqzd_s64(a);
+uint64_t test_vceqzd_s64(int64_t a) {
+  return (uint64_t)vceqzd_s64(a);
 }
 
 // CHECK-LABEL: @test_vceqzd_u64(
@@ -13778,8 +13778,8 @@ int64_t test_vceqzd_u64(int64_t a) {
 // CHECK:   [[TMP0:%.*]] = icmp sge i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vcged_s64(int64_t a, int64_t b) {
-  return (int64_t)vcged_s64(a, b);
+uint64_t test_vcged_s64(int64_t a, int64_t b) {
+  return (uint64_t)vcged_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vcged_u64(
@@ -13794,16 +13794,16 @@ uint64_t test_vcged_u64(uint64_t a, uint64_t b) {
 // CHECK:   [[TMP0:%.*]] = icmp sge i64 %a, 0
 // CHECK:   [[VCGEZ_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCGEZ_I]]
-int64_t test_vcgezd_s64(int64_t a) {
-  return (int64_t)vcgezd_s64(a);
+uint64_t test_vcgezd_s64(int64_t a) {
+  return (uint64_t)vcgezd_s64(a);
 }
 
 // CHECK-LABEL: @test_vcgtd_s64(
 // CHECK:   [[TMP0:%.*]] = icmp sgt i64 %a, %b
 // CHECK:   [[VCEQD_I:%.*]] = sext i1 [[TMP0]] to i64
 // CHECK:   ret i64 [[VCEQD_I]]
-int64_t test_vcgtd_s64(int64_t a, int64_t b) {
-  return (int64_t)vcgtd_s64(a, b);
+uint64_t test_vcgtd_s64(int64_t a, int64_t b) {
+  return (uint64_t)vcgtd_s64(a, b);
 }
 
 // CHECK-LABEL: @test_vcgtd_u64(
@@ -13818,16 +13818,16 @@ uint64_t test_

[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-09-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ requested changes to this revision.
NoQ added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp:330-336
+SVal getReturnIterator(const CallEvent &Call) {
+  Optional RetValUnderConstr = Call.getReturnValueUnderConstruction();
+  if (RetValUnderConstr.hasValue())
+return *RetValUnderConstr;
+
+  return Call.getReturnValue();
+}

NoQ wrote:
> I still believe you have not addressed the problem while moving the functions 
> from D81718 to this patch. The caller of this function has no way of knowing 
> whether the return value is the prvalue of the iterator or the glvalue of the 
> iterator.
> 
> Looks like most callers are safe because they expect the object of interest 
> to also be already tracked. But it's quite possible that both are tracked, 
> say:
> 
> ```lang=c++
>   Container1 container1 = ...;
>   Container2 container2 = { container1.begin() };
>   container2.begin(); // ???
> ```
> 
> Suppose `Container1::iterator` is implemented as an object and 
> `Container2::iterator` is implemented as a pointer. In this case 
> `getIteratorPosition(getReturnIterator())` would yield the position of 
> `container1.begin()` whereas the correct answer is the position of 
> `container2.begin()`.
> 
> This problem may seem artificial but it is trivial to avoid if you simply 
> stop defending your convoluted solution of looking at value classes instead 
> of AST types.
Ugh, the problem is much worse. D82185 is entirely broken for the exact reason 
i described above and you only didn't notice it because you wrote almost no 
tests.

Consider the test you've added in D82185:

```lang=c++
void begin_ptr_iterator(const cont_with_ptr_iterator &c) {
  auto i = c.begin();

  clang_analyzer_eval(clang_analyzer_iterator_container(i) == &c); // 
expected-warning{{TRUE}}
}
```

It breaks very easily if you modify it slightly:
```lang=c++
void begin_ptr_iterator(const cont_with_ptr_iterator &c) {
  auto i = c.begin();
  ++i; // <==

  clang_analyzer_eval(clang_analyzer_iterator_container(i) == &c); // Says 
FALSE!
}
```
The iterator obviously still points to the same container, so why does the test 
fail? Because you're tracking the wrong iterator: you treated your 
`&SymRegion{conj_$3}` as a glvalue whereas you should have treated it as a 
prvalue. In other words, your checker thinks that `&SymRegion{conj_$3}` is the 
location of an iterator object rather than the iterator itself, and after you 
increment the pointer it thinks that it's a completely unrelated iterator.

There's a separate concern about why does it say `FALSE` (should be `UNKNOWN`) 
but you get the point.


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

https://reviews.llvm.org/D77229

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


[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-09-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp:330-336
+SVal getReturnIterator(const CallEvent &Call) {
+  Optional RetValUnderConstr = Call.getReturnValueUnderConstruction();
+  if (RetValUnderConstr.hasValue())
+return *RetValUnderConstr;
+
+  return Call.getReturnValue();
+}

NoQ wrote:
> NoQ wrote:
> > I still believe you have not addressed the problem while moving the 
> > functions from D81718 to this patch. The caller of this function has no way 
> > of knowing whether the return value is the prvalue of the iterator or the 
> > glvalue of the iterator.
> > 
> > Looks like most callers are safe because they expect the object of interest 
> > to also be already tracked. But it's quite possible that both are tracked, 
> > say:
> > 
> > ```lang=c++
> >   Container1 container1 = ...;
> >   Container2 container2 = { container1.begin() };
> >   container2.begin(); // ???
> > ```
> > 
> > Suppose `Container1::iterator` is implemented as an object and 
> > `Container2::iterator` is implemented as a pointer. In this case 
> > `getIteratorPosition(getReturnIterator())` would yield the position of 
> > `container1.begin()` whereas the correct answer is the position of 
> > `container2.begin()`.
> > 
> > This problem may seem artificial but it is trivial to avoid if you simply 
> > stop defending your convoluted solution of looking at value classes instead 
> > of AST types.
> Ugh, the problem is much worse. D82185 is entirely broken for the exact 
> reason i described above and you only didn't notice it because you wrote 
> almost no tests.
> 
> Consider the test you've added in D82185:
> 
> ```lang=c++
> void begin_ptr_iterator(const cont_with_ptr_iterator &c) {
>   auto i = c.begin();
> 
>   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &c); // 
> expected-warning{{TRUE}}
> }
> ```
> 
> It breaks very easily if you modify it slightly:
> ```lang=c++
> void begin_ptr_iterator(const cont_with_ptr_iterator &c) {
>   auto i = c.begin();
>   ++i; // <==
> 
>   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &c); // Says 
> FALSE!
> }
> ```
> The iterator obviously still points to the same container, so why does the 
> test fail? Because you're tracking the wrong iterator: you treated your 
> `&SymRegion{conj_$3}` as a glvalue whereas you should have treated it as a 
> prvalue. In other words, your checker thinks that `&SymRegion{conj_$3}` is 
> the location of an iterator object rather than the iterator itself, and after 
> you increment the pointer it thinks that it's a completely unrelated iterator.
> 
> There's a separate concern about why does it say `FALSE` (should be 
> `UNKNOWN`) but you get the point.
The better way to test D82185 would be to make all existing tests with iterator 
objects pass with iterator pointers as well. Like, make existing container 
mocks use either iterator objects or iterator pointers depending on a macro and 
make two run-lines in each test file, one with `-D` and one without it. Most of 
the old tests should have worked out of the box if you did it right; the few 
that don't pass would be hidden under #ifdef for future investigation.


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

https://reviews.llvm.org/D77229

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


[PATCH] D88077: [SyntaxTree] Add tests for the assignment of the `canModify` tag.

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88077

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3855,8 +3855,76 @@
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, NonModifiableNodes) {
-  // Some nodes are non-modifiable, they are marked with 'I:'.
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_Leaf) {
+  // All nodes can be mutated.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define OPEN {
+#define CLOSE }
+
+void test() {
+  OPEN
+1;
+  CLOSE
+
+  OPEN
+2;
+  }
+}
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'1' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'2' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+`-'}' CloseParen
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MatchTree) {
+  // Some nodes are unmodifiable, they are marked with 'unmodifiable'.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define BRACES {}
+
+void test() BRACES
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen unmodifiable
+`-'}' CloseParen unmodifiable
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MismatchTree) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 #define HALF_IF if (1+
@@ -3896,21 +3964,14 @@
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, ModifiableNodes) {
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_ModifiableArguments) {
   // All nodes can be mutated.
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-#define OPEN {
-#define CLOSE }
+#define MIN(X,Y) X < Y ? X : Y
 
 void test() {
-  OPEN
-1;
-  CLOSE
-
-  OPEN
-2;
-  }
+  MIN(1,2);
 }
 )cpp",
   R"txt(
@@ -3924,24 +3985,109 @@
   |   `-')' CloseParen
   `-CompoundStatement
 |-'{' OpenParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
+|-ExpressionStatement Statement
+| |-UnknownExpression Expression
+| | |-BinaryOperatorExpression unmodifiable
+| | | |-IntegerLiteralExpression LeftHandSide
+| | | | `-'1' LiteralToken
+| | | |-'<' OperatorToken unmodifiable
+| | | `-IntegerLiteralExpression RightHandSide
+| | |   `-'2' LiteralToken
+| | |-'?' unmodifiable
+| | |-IntegerLiteralExpression
 | | | `-'1' LiteralToken
-| | `-';'
-| `-'}' CloseParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
-| | | `-'2' LiteralToken
-| | `-';'
-| `-'}' CloseParen
+| | |-':' unmodifiable
+| | `-IntegerLiteralExpression
+| |   `-'2' LiteralToken
+| `-';'
+`-'}' CloseParen
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_MismatchTree) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define HALF_IF(X) if (X &&
+#define HALF_IF_2(Y) Y) {}
+void test() {
+  HALF_IF(1) HALF_IF_2(0) else {}
+})cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-IfStatement Statement
+| |-'if' IntroducerKeyword unmodifiable
+| |-'(' unmodifiable
+| |-BinaryOperatorExpression unmodifiable
+| | |-IntegerLiteralExpression LeftHandSide
+| | | `-'1' LiteralToken
+| | |-'&&' OperatorToken unmodifiable
+| | `-IntegerLiteralExpression RightHandSide
+| |   `-'0' LiteralToken
+| |-')' unmodifiable
+| |-CompoundStatement ThenStatement unmodifiable
+| | |-'{' OpenParen unmodifiable
+| | `-'}' CloseParen unmodifiable
+| |-'else' ElseKeyword
+| `-CompoundStatement ElseStatement
+|   |-'{' OpenParen
+|   `-'}' CloseParen
 `-'}' CloseParen
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_Variadic) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+#define CALL(F_NAME

[clang] 66bcb14 - [SyntaxTree][Synthesis] Fix: `deepCopy` -> `deepCopyExpandingMacros`.

2020-09-22 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-09-22T09:15:21Z
New Revision: 66bcb14312a08b5d7e1197d23d748b2e23c4d852

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

LOG: [SyntaxTree][Synthesis] Fix: `deepCopy` -> `deepCopyExpandingMacros`.

There can be Macros that are tagged with `modifiable`. Thus verifying
`canModifyAllDescendants` is not sufficient to avoid macros when deep
copying.

We think the `TokenBuffer` could inform us whether a `Token` comes from
a macro. We'll look into that when we can surface this information
easily, for instance in unit tests for `ComputeReplacements`.

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/BuildTree.h
clang/lib/Tooling/Syntax/Synthesis.cpp
clang/unittests/Tooling/Syntax/SynthesisTest.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/BuildTree.h 
b/clang/include/clang/Tooling/Syntax/BuildTree.h
index ab4868747e69..537ade4b7151 100644
--- a/clang/include/clang/Tooling/Syntax/BuildTree.h
+++ b/clang/include/clang/Tooling/Syntax/BuildTree.h
@@ -45,17 +45,13 @@ createTree(syntax::Arena &A,
 // Synthesis of Syntax Nodes
 syntax::EmptyStatement *createEmptyStatement(syntax::Arena &A);
 
-/// Creates a completely independent copy of `N` (a deep copy).
+/// Creates a completely independent copy of `N` with its macros expanded.
 ///
 /// The copy is:
 /// * Detached, i.e. `Parent == NextSibling == nullptr` and
 /// `Role == Detached`.
 /// * Synthesized, i.e. `Original == false`.
-///
-/// `N` might be backed by source code but if any descendants of `N` are
-/// unmodifiable returns `nullptr`.
-syntax::Node *deepCopy(syntax::Arena &A, const syntax::Node *N);
-
+syntax::Node *deepCopyExpandingMacros(syntax::Arena &A, const syntax::Node *N);
 } // namespace syntax
 } // namespace clang
 #endif

diff  --git a/clang/lib/Tooling/Syntax/Synthesis.cpp 
b/clang/lib/Tooling/Syntax/Synthesis.cpp
index 9dc83f966d8c..e197c8d35bde 100644
--- a/clang/lib/Tooling/Syntax/Synthesis.cpp
+++ b/clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -201,25 +201,11 @@ syntax::Tree *clang::syntax::createTree(
   return T;
 }
 
-namespace {
-bool canModifyAllDescendants(const syntax::Node *N) {
-  if (const auto *L = dyn_cast(N))
-return L->canModify();
-
-  const auto *T = cast(N);
-
-  if (!T->canModify())
-return false;
-  for (const auto *Child = T->getFirstChild(); Child;
-   Child = Child->getNextSibling())
-if (!canModifyAllDescendants(Child))
-  return false;
-
-  return true;
-}
-
-syntax::Node *deepCopyImpl(syntax::Arena &A, const syntax::Node *N) {
+syntax::Node *clang::syntax::deepCopyExpandingMacros(syntax::Arena &A,
+ const syntax::Node *N) {
   if (const auto *L = dyn_cast(N))
+// `L->getToken()` gives us the expanded token, thus we implicitly expand
+// any macros here.
 return createLeaf(A, L->getToken()->kind(),
   L->getToken()->text(A.getSourceManager()));
 
@@ -227,18 +213,10 @@ syntax::Node *deepCopyImpl(syntax::Arena &A, const 
syntax::Node *N) {
   std::vector> Children;
   for (const auto *Child = T->getFirstChild(); Child;
Child = Child->getNextSibling())
-Children.push_back({deepCopyImpl(A, Child), Child->getRole()});
+Children.push_back({deepCopyExpandingMacros(A, Child), Child->getRole()});
 
   return createTree(A, Children, N->getKind());
 }
-} // namespace
-
-syntax::Node *clang::syntax::deepCopy(syntax::Arena &A, const Node *N) {
-  if (!canModifyAllDescendants(N))
-return nullptr;
-
-  return deepCopyImpl(A, N);
-}
 
 syntax::EmptyStatement *clang::syntax::createEmptyStatement(syntax::Arena &A) {
   return cast(

diff  --git a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp 
b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
index 2af1fcf8f317..7f67b4e2e203 100644
--- a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -173,7 +173,7 @@ TEST_P(SynthesisTest, DeepCopy_Synthesized) {
 {LeafSemiColon, NodeRole::Unknown}},
NodeKind::ContinueStatement);
 
-  auto *Copy = deepCopy(*Arena, StatementContinue);
+  auto *Copy = deepCopyExpandingMacros(*Arena, StatementContinue);
   EXPECT_TRUE(
   treeDumpEqual(Copy, StatementContinue->dump(Arena->getSourceManager(;
   // FIXME: Test that copy is independent of original, once the Mutations API 
is
@@ -183,7 +183,7 @@ TEST_P(SynthesisTest, DeepCopy_Synthesized) {
 TEST_P(SynthesisTest, DeepCopy_Original) {
   auto *OriginalTree = buildTree("int a;", GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree);
+  aut

[PATCH] D88034: [SyntaxTree][Synthesis] Fix: `deepCopy` -> `deepCopyExpandingMacros`.

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66bcb14312a0: [SyntaxTree][Synthesis] Fix: `deepCopy` -> 
`deepCopyExpandingMacros`. (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88034

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -22,8 +22,8 @@
 std::vector> ChildrenWithRoles;
 ChildrenWithRoles.reserve(Children.size());
 for (const auto *Child : Children) {
-  ChildrenWithRoles.push_back(
-  std::make_pair(deepCopy(*Arena, Child), NodeRole::Unknown));
+  ChildrenWithRoles.push_back(std::make_pair(
+  deepCopyExpandingMacros(*Arena, Child), NodeRole::Unknown));
 }
 return clang::syntax::createTree(*Arena, ChildrenWithRoles,
  NodeKind::UnknownExpression);
Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -173,7 +173,7 @@
 {LeafSemiColon, NodeRole::Unknown}},
NodeKind::ContinueStatement);
 
-  auto *Copy = deepCopy(*Arena, StatementContinue);
+  auto *Copy = deepCopyExpandingMacros(*Arena, StatementContinue);
   EXPECT_TRUE(
   treeDumpEqual(Copy, StatementContinue->dump(Arena->getSourceManager(;
   // FIXME: Test that copy is independent of original, once the Mutations API is
@@ -183,7 +183,7 @@
 TEST_P(SynthesisTest, DeepCopy_Original) {
   auto *OriginalTree = buildTree("int a;", GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree);
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree);
   EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
 TranslationUnit Detached synthesized
 `-SimpleDeclaration synthesized
@@ -197,7 +197,7 @@
 TEST_P(SynthesisTest, DeepCopy_Child) {
   auto *OriginalTree = buildTree("int a;", GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree->getFirstChild());
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree->getFirstChild());
   EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
 SimpleDeclaration Detached synthesized
 |-'int' synthesized
@@ -216,8 +216,41 @@
 })cpp",
  GetParam());
 
-  auto *Copy = deepCopy(*Arena, OriginalTree);
-  EXPECT_TRUE(Copy == nullptr);
+  auto *Copy = deepCopyExpandingMacros(*Arena, OriginalTree);
+
+  // The syntax tree stores already expanded Tokens, we can only see whether the
+  // macro was expanded when computing replacements. The dump does show that
+  // nodes in the copy are `modifiable`.
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+TranslationUnit Detached synthesized
+`-SimpleDeclaration synthesized
+  |-'void' synthesized
+  |-SimpleDeclarator Declarator synthesized
+  | |-'test' synthesized
+  | `-ParametersAndQualifiers synthesized
+  |   |-'(' OpenParen synthesized
+  |   `-')' CloseParen synthesized
+  `-CompoundStatement synthesized
+|-'{' OpenParen synthesized
+|-IfStatement Statement synthesized
+| |-'if' IntroducerKeyword synthesized
+| |-'(' synthesized
+| |-BinaryOperatorExpression synthesized
+| | |-IntegerLiteralExpression LeftHandSide synthesized
+| | | `-'1' LiteralToken synthesized
+| | |-'+' OperatorToken synthesized
+| | `-IntegerLiteralExpression RightHandSide synthesized
+| |   `-'1' LiteralToken synthesized
+| |-')' synthesized
+| |-CompoundStatement ThenStatement synthesized
+| | |-'{' OpenParen synthesized
+| | `-'}' CloseParen synthesized
+| |-'else' ElseKeyword synthesized
+| `-CompoundStatement ElseStatement synthesized
+|   |-'{' OpenParen synthesized
+|   `-'}' CloseParen synthesized
+`-'}' CloseParen synthesized
+  )txt"));
 }
 
 TEST_P(SynthesisTest, Statement_EmptyStatement) {
Index: clang/lib/Tooling/Syntax/Synthesis.cpp
===
--- clang/lib/Tooling/Syntax/Synthesis.cpp
+++ clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -201,25 +201,11 @@
   return T;
 }
 
-namespace {
-bool canModifyAllDescendants(const syntax::Node *N) {
-  if (const auto *L = dyn_cast(N))
-return L->canModify();
-
-  const auto *T = cast(N);
-
-  if (!T->canModify())
-return false;
-  for (const auto *Child = T->getFirstChild(); Child;
-   Child = Child->getNextSibling())
-if (!canModifyAllDescendants(Child))
-  return false;
-
-  return true;
-}
-
-syntax::Node *deepCopyImpl(syntax::Arena

[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-09-22 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto added a comment.

Thank you @awarzynski  for this patch.
Very good that you added color feature for Fortran.
It is just a shame that we do not test. Is there a way to add a regression test 
for it?
I don't see any inconsistency with what we have on clang side, so it is good.
My comments are in the code, but two things that need an overall look:
1- style is not yet according to Flang, mainly functions and variables in the 
classes
2 -I believe that the name space is Fortran::frontend to be consistent with the 
other files at Frontend.




Comment at: clang/include/clang/Driver/Options.td:874
+defm color_diagnostics : OptInFFlag<"color-diagnostics", "Enable", "Disable", 
" colors in diagnostics",
+  [CoreOption, FlangOption]>;
 def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, Group,

Is it possible to also add when using FC1Option?



Comment at: clang/tools/driver/driver.cpp:281
   argv.slice(1), MissingArgIndex, MissingArgCount);
+
   // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.

undo



Comment at: flang/include/flang/Frontend/TextDiagnostic.h:18
+
+#include "clang/Frontend/DiagnosticRenderer.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"

Do we need clang/Frontend here?



Comment at: flang/include/flang/Frontend/TextDiagnostic.h:60
+  /// \param showColors Enable colorizing of the message.
+  static void printDiagnosticMessage(llvm::raw_ostream &os, bool 
isSupplemental,
+  llvm::StringRef message, bool showColors);

According to Flang style It should be PrintDiagnosticMessage, no?



Comment at: flang/include/flang/Frontend/TextDiagnosticBuffer.h:23
+
+namespace Fortran {
+

It is inside Frontend, why you are not using Fortran::frontend?



Comment at: flang/include/flang/Frontend/TextDiagnosticBuffer.h:42
+
+  /// FlushDiagnostics - Flush the buffered diagnostics to an given
+  /// diagnostic engine.

a given



Comment at: flang/include/flang/Frontend/TextDiagnosticPrinter.h:48
+  /// start of any diagnostics. If empty, no prefix string is used.
+  void set_prefix(std::string value) { prefix_ = std::move(value); }
+

style



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:75
+bool Fortran::frontend::ParseDiagnosticArgs(clang::DiagnosticOptions &opts,
+llvm::opt::ArgList &args, clang::DiagnosticsEngine *diags,
+bool defaultDiagColor) {

kiranchandramohan wrote:
> Is diags not needed now?
Why do you have clang::DiagnosticsEngine *diags



Comment at: flang/lib/Frontend/TextDiagnostic.cpp:32
+
+/*static*/ void TextDiagnostic::printDiagnosticLevel(llvm::raw_ostream &os,
+clang::DiagnosticsEngine::Level level, bool showColors) {

Why do static is commented?



Comment at: flang/lib/Frontend/TextDiagnosticPrinter.cpp:52
+  Fortran::TextDiagnostic::printDiagnosticMessage(os_,
+  /*IsSupplemental=*/level == clang::DiagnosticsEngine::Note,
+  DiagMessageStream.str(), diagOpts_->ShowColors);

Why when it is clang::DiagnosticsEngine::Note it is Supplemental?



Comment at: flang/tools/flang-driver/driver.cpp:48
+  // when the DiagnosticsEngine actually exists.
+  unsigned missingArgIndex, missingArgCount;
+  llvm::opt::InputArgList args = clang::driver::getDriverOptTable().ParseArgs(

This is an odd part of the code, because  missingArgIndex, missingArgCount are 
not set or even used in this part of the code.



Comment at: flang/tools/flang-driver/driver.cpp:52
+  /*FlagsToInclude=*/clang::driver::options::FlangOption);
+  (void)Fortran::frontend::ParseDiagnosticArgs(*diagOpts, args);
+

can you do only diagOpts.showcolor= parseShowColorsArgs(args, defaultDiagColor)?
this function is not doing much now and it only adds another layer to 
understand the code.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87774

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-22 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> I'm going to concentrate on the standalone port as I think that's the way 
> forward. If I get that working then can work through the other issues.

I'm considering a slight change of plan. @cryptoad, in the name of incremental 
development, would you be happy for me to put the scudo sanitizer version up 
(with working tests), or is this deprecated now? It may not be the best for 
performance long term but it's a smaller step than the standalone port and 
seems to work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 293386.
eduucaldas added a comment.

- [SyntaxTree] Split `TreeTest` and `ListTest` testing fixtures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,6 +9,7 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "TreeTestBase.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -122,4 +123,210 @@
   }
 }
 
+class ListTest : public SyntaxTreeTest {
+private:
+  std::string dump(const List::ElementAndDelimiter &ED) {
+auto Format = [](StringRef s) { return "'" + s.trim().str() + "'"; };
+
+std::string Delimiter =
+ED.delimiter
+? Format(ED.delimiter->dumpTokens(Arena->getSourceManager()))
+: "nul";
+
+std::string Element =
+ED.element ? Format(ED.element->dumpTokens(Arena->getSourceManager()))
+   : "nul";
+
+return "(" + Element + ", " + Delimiter + ")";
+  }
+
+protected:
+  std::string dump(ArrayRef> EDs) {
+if (EDs.empty())
+  return "[]";
+
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[" << dump(EDs.front());
+for (auto ED = std::next(EDs.begin()), End = EDs.end(); ED != End; ++ED)
+  OS << ", " << dump(*ED);
+OS << "]";
+return OS.str();
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(TreeTests, ListTest,
+::testing::ValuesIn(allTestClangConfigs()), );
+
+/// "a, b, c"  <=> [("a", ","), ("b", ","), ("c", nul)]
+TEST_P(ListTest, List_Separated_WellFormed) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dump(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', ','), ('c', nul)]");
+}
+
+/// "a,  , c"  <=> [("a", ","), (nul, ","), ("c", nul)]
+TEST_P(ListTest, List_Separated_MissingElement) {
+  buildTree("", GetParam());
+
+  // "a,  , c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dump(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), (nul, ','), ('c', nul)]");
+}
+
+/// "a, b  c"  <=> [("a", ","), ("b", nul), ("c", nul)]
+TEST_P(ListTest, List_Separated_MissingDelimiter) {
+  buildTree("", GetParam());
+
+  // "a, b  c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dump(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', nul), ('c', nul)]");
+}
+
+/// "a, b,"<=> [("a", ","), ("b", ","), (nul, nul)]
+TEST_P(ListTest, List_Separated_MissingLastElement) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dump(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', ','), (nul, nul)]");
+}
+
+/// "a:: b:: c::" <=> [("a", "::"), ("b", "::"), ("c", "::")]
+TEST_P(ListTest, List_Terminated_WellFormed) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  buildTree("", GetParam());
+
+  // "a:: b:: c::"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(

[PATCH] D88077: [SyntaxTree] Add tests for the assignment of the `canModify` tag.

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 293389.
eduucaldas added a comment.

Add FIXME for `MIN(X, Y)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88077

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3855,8 +3855,76 @@
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, NonModifiableNodes) {
-  // Some nodes are non-modifiable, they are marked with 'I:'.
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_Leaf) {
+  // All nodes can be mutated.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define OPEN {
+#define CLOSE }
+
+void test() {
+  OPEN
+1;
+  CLOSE
+
+  OPEN
+2;
+  }
+}
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'1' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'2' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+`-'}' CloseParen
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MatchTree) {
+  // Some nodes are unmodifiable, they are marked with 'unmodifiable'.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define BRACES {}
+
+void test() BRACES
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen unmodifiable
+`-'}' CloseParen unmodifiable
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MismatchTree) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 #define HALF_IF if (1+
@@ -3896,21 +3964,16 @@
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, ModifiableNodes) {
-  // All nodes can be mutated.
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_ModifiableArguments) {
+  // FIXME: Note that the substitutions for `X` and `Y` are marked modifiable.
+  // However we cannot change `X` freely. Indeed if we change its substitution
+  // in the condition we should also change it the then-branch.
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-#define OPEN {
-#define CLOSE }
+#define MIN(X,Y) X < Y ? X : Y
 
 void test() {
-  OPEN
-1;
-  CLOSE
-
-  OPEN
-2;
-  }
+  MIN(1,2);
 }
 )cpp",
   R"txt(
@@ -3924,24 +3987,109 @@
   |   `-')' CloseParen
   `-CompoundStatement
 |-'{' OpenParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
+|-ExpressionStatement Statement
+| |-UnknownExpression Expression
+| | |-BinaryOperatorExpression unmodifiable
+| | | |-IntegerLiteralExpression LeftHandSide
+| | | | `-'1' LiteralToken
+| | | |-'<' OperatorToken unmodifiable
+| | | `-IntegerLiteralExpression RightHandSide
+| | |   `-'2' LiteralToken
+| | |-'?' unmodifiable
+| | |-IntegerLiteralExpression
 | | | `-'1' LiteralToken
-| | `-';'
-| `-'}' CloseParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
-| | | `-'2' LiteralToken
-| | `-';'
-| `-'}' CloseParen
+| | |-':' unmodifiable
+| | `-IntegerLiteralExpression
+| |   `-'2' LiteralToken
+| `-';'
 `-'}' CloseParen
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_MismatchTree) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define HALF_IF(X) if (X &&
+#define HALF_IF_2(Y) Y) {}
+void test() {
+  HALF_IF(1) HALF_IF_2(0) else {}
+})cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-IfStatement Statement
+| |-'if' IntroducerKeyword unmodifiable
+| |-'(' unmodifiable
+| |-BinaryOperatorExpression unmodifiable
+| | |-IntegerLiteralExpression LeftHandSide
+| | | `-'1' LiteralToken
+| | |-'&&' OperatorToken unmodifiable
+| | `-IntegerLiteralExpression RightHandSide
+| |   `-'0' LiteralToken
+| |-')' unmodifiable
+| |-CompoundStatement ThenStatement unmodifiable
+| | |-'{' OpenParen unmodifiable
+| | `-'}' CloseParen unmodifiable
+| |-'else' ElseKeyword
+| `-CompoundStat

[PATCH] D88077: [SyntaxTree] Add tests for the assignment of the `canModify` tag.

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:3858
 
-TEST_P(BuildSyntaxTreeTest, NonModifiableNodes) {
-  // Some nodes are non-modifiable, they are marked with 'I:'.
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_Leaf) {
+  // All nodes can be mutated.

This is the same as `ModifiableNodes` I just changed the order, to follow a 
sequence of complexity


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88077

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


[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added a comment.

I made a separate class for the tests on Lists, as it didn't share any methods 
with the tests for Trees. What do you think about that?

Should I also put the tests for lists in a different file, even though 
`TreeTest.cpp` could mean test `Tree.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

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


[PATCH] D88077: [SyntaxTree] Add tests for the assignment of the `canModify` tag.

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

Looking for feedback, specially on the names I used. 
Also if you have ideas of interesting tests they will be gladly accepted :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88077

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 293392.
JonasToth added a comment.

- rebase to master after AST Matchers are extracted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
  clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -63,13 +63,18 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
+  std::string buffer;
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
+if (!By)
+  break;
+
 llvm::raw_string_ostream stream(buffer);
 By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+Chain.emplace_back(StringRef(stream.str()).trim().str());
 E = dyn_cast(By);
+buffer.clear();
   }
   return Chain;
 }
@@ -394,22 +399,26 @@
   "void g(const int&&); void f() { int x; g(static_cast(x)); }");
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("struct A {}; A operator+(const A&&, int);"
  "void f() { A x; static_cast(x) + 1; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(const int&&); }; "
  "int x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(); A(const A&&); }; "
  "A x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
@@ -579,7 +588,7 @@
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("return static_cast(x);"));
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, ReturnAsConstRRef) {
@@ -587,7 +596,8 @@
   "const int&& f() { int x; return static_cast(x); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, TakeAddress) {
@@ -863,13 +873,13 @@
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("typedef int& IntRef;"
  "void f() { int x; static_cast(x) = 10; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  Element

[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D54943#2255358 , @AlexanderLanin 
wrote:

> Observed behavior:
>
> Change: `for(string_view token : split_into_views(file_content, " \t\r\n"))` 
> --> `for(string_view const token : split_into_views(file_content, " 
> \t\r\n"))`.
> Note: `std::vector split_into_views(string_view input, const 
> char* separators);`
> Problem: Now it triggers `error: loop variable 'token' of type 'const 
> nonstd::sv_lite::string_view' (aka 'const basic_string_view') creates a 
> copy from type 'const nonstd::sv_lite::string_view' 
> [-Werror,-Wrange-loop-analysis]`
> Fixed manually by making it `for(std::string_view& const token : 
> split_into_views(file_content, " \t\r\n"))`.

Hey alex,
thanks for testing the check out and reporting the issue.
Could you please provide me a full reproducer (optimally without dependencies 
on includes/libraries)?
I am currently trying to go through everything again, as there are simply some 
cases not handled correctly :/

Best Regards, Jonas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D86547: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z

2020-09-22 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

In D86547#2284095 , @MaskRay wrote:

> The `(aWidth - 1) - clzsi(a)` change is correct, but why is the ctz change?

`d.s.low` and `d.s.high` are `su_int`. While some helpers from `libgcc` are 
documented with `int`, `long`, etc. types //for simplicity// and use machine 
modes under the hood, the `__builtin_ctz()` function (as well as clz), on the 
other hand, seems to **really** accept an `int`-sized argument:

  $ clang --version
  clang version 10.0.0-4ubuntu1 
  Target: x86_64-pc-linux-gnu
  Thread model: posix
  InstalledDir: /usr/bin
  $ clang -S -O3 -o- -x c - <<< "int f() { return __builtin_ctz(0x10); }"
  .text
  .file   "-"
  .globl  f   # -- Begin function f
  .p2align4, 0x90
  .type   f,@function
  f:  # @f
  .cfi_startproc
  # %bb.0:
  movl$20, %eax
  retq
  .Lfunc_end0:
  .size   f, .Lfunc_end0-f
  .cfi_endproc
  # -- End function
  .ident  "clang version 10.0.0-4ubuntu1 "
  .section".note.GNU-stack","",@progbits
  .addrsig
  $ clang -S -O3 -target msp430 -o- -x c - <<< "int f() { return 
__builtin_ctz(0x10); }"
  :1:32: warning: implicit conversion from 'long' to 'unsigned int' 
changes value from 1048576 to 0 [-Wconstant-conversion]
  int f() { return __builtin_ctz(0x10); }
   ~ ^~~~
  .text
  .file   "-"
  .globl  f   ; -- Begin function f
  .p2align1
  .type   f,@function
  f:  ; @f
  ; %bb.0:
  ret
  .Lfunc_end0:
  .size   f, .Lfunc_end0-f
  ; -- End function
  .ident  "clang version 10.0.0-4ubuntu1 "
  .section".note.GNU-stack","",@progbits
  .addrsig
  1 warning generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86547

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


[PATCH] D87279: [clang] Fix handling of physical registers in inline assembly operands.

2020-09-22 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa added a comment.

ping!


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

https://reviews.llvm.org/D87279

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


[PATCH] D88084: [clang-format] Changed default styles BraceWrappping bool table to directly use variables

2020-09-22 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 created this revision.
MarcusJohnson91 added reviewers: MyDeveloperDay, sylvestre.ledru.
MarcusJohnson91 added a project: clang-format.
Herald added a project: clang.
MarcusJohnson91 requested review of this revision.

Which should make these defaults more immune to changes in the BraceWrapping 
enum.

using a table of values is just asking for trouble, and by doing it this way 
there's more confidence about the correctness of the default styles.

as @Silvestre.Ledru inadvertently pointed out.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88084

Files:
  clang/lib/Format/Format.cpp

Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -726,24 +726,25 @@
   if (Style.BreakBeforeBraces == FormatStyle::BS_Custom)
 return Style;
   FormatStyle Expanded = Style;
-  Expanded.BraceWrapping = {/*AfterCaseLabel=*/false,
-/*AfterClass=*/false,
-/*AfterControlStatement=*/FormatStyle::BWACS_Never,
-/*AfterEnum=*/false,
-/*AfterFunction=*/false,
-/*AfterNamespace=*/false,
-/*AfterObjCDeclaration=*/false,
-/*AfterStruct=*/false,
-/*AfterUnion=*/false,
-/*AfterExternBlock=*/false,
-/*BeforeCatch=*/false,
-/*BeforeElse=*/false,
-/*BeforeLambdaBody=*/false,
-/*BeforeWhile=*/false,
-/*IndentBraces=*/false,
-/*SplitEmptyFunction=*/true,
-/*SplitEmptyRecord=*/true,
-/*SplitEmptyNamespace=*/true};
+  Expanded.BraceWrapping.AfterCaseLabel = false;
+  Expanded.BraceWrapping.AfterClass = false;
+  Expanded.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
+  Expanded.BraceWrapping.AfterEnum = false;
+  Expanded.BraceWrapping.AfterFunction = false;
+  Expanded.BraceWrapping.AfterNamespace = false;
+  Expanded.BraceWrapping.AfterObjCDeclaration = false;
+  Expanded.BraceWrapping.AfterStruct = false;
+  Expanded.BraceWrapping.AfterUnion = false;
+  Expanded.BraceWrapping.AfterExternBlock = false;
+  Expanded.BraceWrapping.BeforeCatch = false;
+  Expanded.BraceWrapping.BeforeElse = false;
+  Expanded.BraceWrapping.BeforeLambdaBody = false;
+  Expanded.BraceWrapping.BeforeWhile = false;
+  Expanded.BraceWrapping.IndentBraces = false;
+  Expanded.BraceWrapping.SplitEmptyFunction = true;
+  Expanded.BraceWrapping.SplitEmptyRecord = true;
+  Expanded.BraceWrapping.SplitEmptyNamespace = true;
+  Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   switch (Style.BreakBeforeBraces) {
   case FormatStyle::BS_Linux:
 Expanded.BraceWrapping.AfterClass = true;
@@ -797,25 +798,24 @@
 Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_GNU:
-Expanded.BraceWrapping = {
-/*AfterCaseLabel=*/true,
-/*AfterClass=*/true,
-/*AfterControlStatement=*/FormatStyle::BWACS_Always,
-/*AfterEnum=*/true,
-/*AfterFunction=*/true,
-/*AfterNamespace=*/true,
-/*AfterObjCDeclaration=*/true,
-/*AfterStruct=*/true,
-/*AfterUnion=*/true,
-/*AfterExternBlock=*/true,
-/*BeforeCatch=*/true,
-/*BeforeElse=*/true,
-/*BeforeLambdaBody=*/false,
-/*BeforeWhile=*/true,
-/*IndentBraces=*/true,
-/*SplitEmptyFunction=*/true,
-/*SplitEmptyRecord=*/true,
-/*SplitEmptyNamespace=*/true};
+Expanded.BraceWrapping.AfterCaseLabel = true;
+Expanded.BraceWrapping.AfterClass = true;
+Expanded.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+Expanded.BraceWrapping.AfterEnum = true;
+Expanded.BraceWrapping.AfterFunction = true;
+Expanded.BraceWrapping.AfterNamespace = true;
+Expanded.BraceWrapping.AfterObjCDeclaration = true;
+Expanded.BraceWrapping.AfterStruct = true;
+Expanded.BraceWrapping.AfterUnion = true;
+Expanded.BraceWrapping.AfterExternBlock = true;
+Expanded.BraceWrapping.BeforeCatch = true;
+Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeLambdaBody = false;
+Expanded.BraceWrapping.BeforeWhile = true;
+Expanded.BraceWrapping.IndentBraces = true;
+Expanded.BraceWrapping.SplitEmptyFunction = true;
+Expanded.BraceWrapping.SplitEmptyRecord = true;
+Expanded.BraceWrapping.SplitEmptyNamespace = true;
 Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 break;
   case FormatStyle::BS_WebKit:
@@ -859,24 +859,24 @@
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeTernaryOperators = tru

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

2020-09-22 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 marked an inline comment as not done.
MarcusJohnson91 added inline comments.



Comment at: clang/lib/Format/Format.cpp:586
 IO.mapOptional("SortIncludes", Style.SortIncludes);
 IO.mapOptional("SortJavaStaticImport", Style.SortJavaStaticImport);
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);

MyDeveloperDay wrote:
> I'm confused by this diff... the Review is closed, if you are proposing 
> changes please make a new review
I went ahead and made a new revision, thanks for the tip.

I've added you and Silvestre as reviewers.

AS for your question about the very last diff, I originally wanted to change as 
little as possible, but Silvestre getting confused and thinking my patch broke 
something motivated me to fix the confusion with the BraceWrapping table once 
and for all, so here we are.


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

https://reviews.llvm.org/D75791

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


[PATCH] D86964: [ASTMatchers] Avoid recursion in ancestor matching to save stack space.

2020-09-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

bump this in case you have missed this patch :)  our another internal pipeline 
seems to need this fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86964

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


[PATCH] D88084: [clang-format] Changed default styles BraceWrappping bool table to directly use variables

2020-09-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In the examples you give here.. (and I have a feeling there are others in the 
tests) some of these fields are the same in all 3 cases

i.e. `SplitEmptyRecord, SplitEmptyFunction and SplitEmptyNamespace`

In which case why doesn't BraceWrapping have a constructor that sets the global 
default? (LLVMStyle wins) and the other styles only specify what is different.

I have real concerns about what happens when new options are introduced and we 
forget to add them everywhere (same concerns I had before). but I agree the {} 
without comments and even the {} with comments is far from ideal.

I have no confidence that some of the options might not be uninitialized, at a 
minimum some are initialized twice, both before and after it feels a little 
like smelly code to me. (no fault of yours)

That said I think the 1-1 replacement is an improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88084

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


[PATCH] D88084: [clang-format] Changed default styles BraceWrappping bool table to directly use variables

2020-09-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I noticed the pre-merge tests failed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88084

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


[clang] 0fb97fd - [SystemZ][z/OS] Set default wchar_t type for zOS

2020-09-22 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2020-09-22T08:03:03-04:00
New Revision: 0fb97fd6a4f2ec9267a1f4d039ec8895c2460ab7

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

LOG: [SystemZ][z/OS] Set default wchar_t type for zOS

Set the default wchar_t type on z/OS, and unsigned as the default.

Reviewed By: hubert.reinterpretcast, fanbo-meng

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

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/wchar-size.c
clang/test/Lexer/wchar-signedness.c
clang/test/Preprocessor/wchar_t.c
clang/test/Sema/wchar.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 0c06ac3cd035..e07067693054 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -776,7 +776,9 @@ class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public 
OSTargetInfo {
 
 public:
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : OSTargetInfo(Triple, Opts) {}
+  : OSTargetInfo(Triple, Opts) {
+this->WCharType = TargetInfo::UnsignedInt;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8ce59f5ba580..0518dc21db73 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3409,8 +3409,8 @@ static void RenderCharacterOptions(const ArgList &Args, 
const llvm::Triple &T,
 } else {
   bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
   CmdArgs.push_back("-fwchar-type=int");
-  if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
- T.isOSOpenBSD()))
+  if (T.isOSzOS() ||
+  (IsARM && !(T.isOSWindows() || T.isOSNetBSD() || T.isOSOpenBSD(
 CmdArgs.push_back("-fno-signed-wchar");
   else
 CmdArgs.push_back("-fsigned-wchar");

diff  --git a/clang/test/CodeGen/wchar-size.c b/clang/test/CodeGen/wchar-size.c
index 28cd5d14d77a..75d8c47ac22a 100644
--- a/clang/test/CodeGen/wchar-size.c
+++ b/clang/test/CodeGen/wchar-size.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple s390x-none-zos -emit-llvm -o - %s | FileCheck %s 
-check-prefix=LONG-WCHAR
 // Note: -fno-short-wchar implies the target default is used; so there is no
 // need to test this separately here.
 

diff  --git a/clang/test/Lexer/wchar-signedness.c 
b/clang/test/Lexer/wchar-signedness.c
index 1d8bc4d5dd03..ea46da015490 100644
--- a/clang/test/Lexer/wchar-signedness.c
+++ b/clang/test/Lexer/wchar-signedness.c
@@ -1,9 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | 
FileCheck %s --check-prefix=CHECK-X86
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck 
%s --check-prefix=CHECK-ARM
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | 
FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple s390x-none-zos | FileCheck 
%s --check-prefix=CHECK-ZOS
 
 // CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
 // CHECK-X86: #define __WINT_UNSIGNED__ 1
 
 // CHECK-ARM: #define __WCHAR_UNSIGNED__ 1
 // CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1
+
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+// CHECK-ZOS-NOT: #define __WINT_UNSIGNED__ 1

diff  --git a/clang/test/Preprocessor/wchar_t.c 
b/clang/test/Preprocessor/wchar_t.c
index 9a7cade3963a..647bbc94389e 100644
--- a/clang/test/Preprocessor/wchar_t.c
+++ b/clang/test/Preprocessor/wchar_t.c
@@ -48,6 +48,11 @@
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
 
+// RUN: %clang_cc1 -triple s390x-none-zos -fwchar-type=int -fno-signed-wchar 
-dM -E %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// CHECK-ZOS: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ZOS: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+
 // RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
 // CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
 // CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char

diff  --git a/clang/test/Sema/wchar.c b/clang/test/Sema/wchar.c
index 6a4b75b39fd1..3170e363ff77 100644
--- a/cl

[PATCH] D87624: [SystemZ][z/OS] Set default wchar_t type for zOS

2020-09-22 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fb97fd6a4f2: [SystemZ][z/OS] Set default wchar_t type for 
zOS (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87624

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/wchar-size.c
  clang/test/Lexer/wchar-signedness.c
  clang/test/Preprocessor/wchar_t.c
  clang/test/Sema/wchar.c


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -6,7 +6,7 @@
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
  || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
   #define WCHAR_T_TYPE unsigned short
-#elif defined(__arm) || defined(__aarch64__)
+#elif defined(__arm) || defined(__aarch64__) || defined(__MVS__)
   #define WCHAR_T_TYPE unsigned int
 #elif defined(__sun)
   #if defined(__LP64__)
Index: clang/test/Preprocessor/wchar_t.c
===
--- clang/test/Preprocessor/wchar_t.c
+++ clang/test/Preprocessor/wchar_t.c
@@ -48,6 +48,11 @@
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
 
+// RUN: %clang_cc1 -triple s390x-none-zos -fwchar-type=int -fno-signed-wchar 
-dM -E %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// CHECK-ZOS: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ZOS: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+
 // RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
 // CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
 // CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
Index: clang/test/Lexer/wchar-signedness.c
===
--- clang/test/Lexer/wchar-signedness.c
+++ clang/test/Lexer/wchar-signedness.c
@@ -1,9 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | 
FileCheck %s --check-prefix=CHECK-X86
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck 
%s --check-prefix=CHECK-ARM
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | 
FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple s390x-none-zos | FileCheck 
%s --check-prefix=CHECK-ZOS
 
 // CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
 // CHECK-X86: #define __WINT_UNSIGNED__ 1
 
 // CHECK-ARM: #define __WCHAR_UNSIGNED__ 1
 // CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1
+
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+// CHECK-ZOS-NOT: #define __WINT_UNSIGNED__ 1
Index: clang/test/CodeGen/wchar-size.c
===
--- clang/test/CodeGen/wchar-size.c
+++ clang/test/CodeGen/wchar-size.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple s390x-none-zos -emit-llvm -o - %s | FileCheck %s 
-check-prefix=LONG-WCHAR
 // Note: -fno-short-wchar implies the target default is used; so there is no
 // need to test this separately here.
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3409,8 +3409,8 @@
 } else {
   bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
   CmdArgs.push_back("-fwchar-type=int");
-  if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
- T.isOSOpenBSD()))
+  if (T.isOSzOS() ||
+  (IsARM && !(T.isOSWindows() || T.isOSNetBSD() || T.isOSOpenBSD(
 CmdArgs.push_back("-fno-signed-wchar");
   else
 CmdArgs.push_back("-fsigned-wchar");
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -776,7 +776,9 @@
 
 public:
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : OSTargetInfo(Triple, Opts) {}
+  : OSTargetInfo(Triple, Opts) {
+this->WCharType = TargetInfo::UnsignedInt;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -6

[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-09-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D76342#2262414 , @Meinersbur wrote:

> Rebase after D83261 

I will try to adapt it to the new interface (it won't work for `simd`, still 
need to capture the variables) and will send the patch back to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 293418.
JonasToth added a comment.

- include ExprMutAnalyzer implementation changes, that got lost somehow with 
prior rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -19,9 +19,7 @@
 
 using namespace clang::ast_matchers;
 using ::testing::ElementsAre;
-using ::testing::IsEmpty;
 using ::testing::ResultOf;
-using ::testing::StartsWith;
 using ::testing::Values;
 
 namespace {
@@ -63,13 +61,18 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
+  std::string buffer;
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
+if (!By)
+  break;
+
 llvm::raw_string_ostream stream(buffer);
 By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+Chain.emplace_back(StringRef(stream.str()).trim().str());
 E = dyn_cast(By);
+buffer.clear();
   }
   return Chain;
 }
@@ -394,22 +397,26 @@
   "void g(const int&&); void f() { int x; g(static_cast(x)); }");
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("struct A {}; A operator+(const A&&, int);"
  "void f() { A x; static_cast(x) + 1; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(const int&&); }; "
  "int x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(); A(const A&&); }; "
  "A x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
@@ -579,7 +586,7 @@
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("return static_cast(x);"));
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, ReturnAsConstRRef) {
@@ -587,7 +594,8 @@
   "const int&& f() { int x; return static_cast(x); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, TakeAddress) {
@@ -863,13 +871,13 @@
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("typedef int& IntRef;"
  "void f()

[PATCH] D88088: [clang] improve accuracy of ExprMutAnalyzer

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, jfb, a.sidorin, baloghadamsoftware.
Herald added a project: clang.
JonasToth requested review of this revision.

This patch extracts the ExprMutAnalyzer changes from 
https://reviews.llvm.org/D54943
into its own revision for simpler review and more atomic changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88088

Files:
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -19,9 +19,7 @@
 
 using namespace clang::ast_matchers;
 using ::testing::ElementsAre;
-using ::testing::IsEmpty;
 using ::testing::ResultOf;
-using ::testing::StartsWith;
 using ::testing::Values;
 
 namespace {
@@ -63,13 +61,18 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
+  std::string buffer;
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
+if (!By)
+  break;
+
 llvm::raw_string_ostream stream(buffer);
 By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+Chain.emplace_back(StringRef(stream.str()).trim().str());
 E = dyn_cast(By);
+buffer.clear();
   }
   return Chain;
 }
@@ -394,22 +397,26 @@
   "void g(const int&&); void f() { int x; g(static_cast(x)); }");
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("struct A {}; A operator+(const A&&, int);"
  "void f() { A x; static_cast(x) + 1; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(const int&&); }; "
  "int x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(); A(const A&&); }; "
  "A x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
@@ -579,7 +586,7 @@
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("return static_cast(x);"));
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, ReturnAsConstRRef) {
@@ -587,7 +594,8 @@
   "const int&& f() { int x; return static_cast(x); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, TakeAddress) {
@@ -863,13 +871,13 @@
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("typedef int& IntRef;"
  "void f() { int x; static_cast(x) = 10; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, CastToRefNotModified) {
@@ -877,7 +885,8 @@
   buildASTFromCode("void f() { int x; static_cast(x); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, CastToConstRef) {
@@ -1054,20 +1063,22 @@
   buildASTFromCode("void f() { int 

[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 293420.
JonasToth added a comment.

- rebase to revision for https://reviews.llvm.org/D88088


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -19,9 +19,7 @@
 
 using namespace clang::ast_matchers;
 using ::testing::ElementsAre;
-using ::testing::IsEmpty;
 using ::testing::ResultOf;
-using ::testing::StartsWith;
 using ::testing::Values;
 
 namespace {
@@ -63,13 +61,18 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
+  std::string buffer;
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
+if (!By)
+  break;
+
 llvm::raw_string_ostream stream(buffer);
 By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+Chain.emplace_back(StringRef(stream.str()).trim().str());
 E = dyn_cast(By);
+buffer.clear();
   }
   return Chain;
 }
@@ -394,22 +397,26 @@
   "void g(const int&&); void f() { int x; g(static_cast(x)); }");
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("struct A {}; A operator+(const A&&, int);"
  "void f() { A x; static_cast(x) + 1; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(const int&&); }; "
  "int x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(); A(const A&&); }; "
  "A x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
@@ -579,7 +586,7 @@
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("return static_cast(x);"));
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, ReturnAsConstRRef) {
@@ -587,7 +594,8 @@
   "const int&& f() { int x; return static_cast(x); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, TakeAddress) {
@@ -863,13 +871,13 @@
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("typedef int& IntRef;"
  "void f() { int x; static_cast(x) = 10; }")

[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 293422.
JonasToth added a comment.

- remove spurious formatting change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -19,9 +19,7 @@
 
 using namespace clang::ast_matchers;
 using ::testing::ElementsAre;
-using ::testing::IsEmpty;
 using ::testing::ResultOf;
-using ::testing::StartsWith;
 using ::testing::Values;
 
 namespace {
@@ -63,13 +61,18 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
+  std::string buffer;
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
+if (!By)
+  break;
+
 llvm::raw_string_ostream stream(buffer);
 By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+Chain.emplace_back(StringRef(stream.str()).trim().str());
 E = dyn_cast(By);
+buffer.clear();
   }
   return Chain;
 }
@@ -394,22 +397,26 @@
   "void g(const int&&); void f() { int x; g(static_cast(x)); }");
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("struct A {}; A operator+(const A&&, int);"
  "void f() { A x; static_cast(x) + 1; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(const int&&); }; "
  "int x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("void f() { struct A { A(); A(const A&&); }; "
  "A x; A y(static_cast(x)); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
@@ -579,7 +586,7 @@
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("return static_cast(x);"));
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, ReturnAsConstRRef) {
@@ -587,7 +594,8 @@
   "const int&& f() { int x; return static_cast(x); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, TakeAddress) {
@@ -863,13 +871,13 @@
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
-  ElementsAre("static_cast(x) = 10"));
+  ElementsAre("static_cast(x)"));
 
   AST = buildASTFromCode("typedef int& IntRef;"
  "void f() { int x; static_cast(x) = 10; }");
   Results = match(withEnclosingCompound(declRefTo("x"

[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 293429.
ldionne added a comment.

Add some tests from D69134 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

Files:
  libcxx/docs/FeatureTestMacroTable.rst
  libcxx/include/memory
  libcxx/include/new
  libcxx/include/version
  
libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.verify.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
  libcxx/test/std/utilities/memory/default.allocator/allocator.dtor.pass.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.constexpr.size.verify.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
  libcxx/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.construct/construct_at.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_at.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
  libcxx/utils/generate_feature_test_macro_components.py
  libcxx/www/cxx2a_status.html

Index: libcxx/www/cxx2a_status.html
===
--- libcxx/www/cxx2a_status.html
+++ libcxx/www/cxx2a_status.html
@@ -164,7 +164,7 @@
 	https://wg21.link/P0631";>P0631LWGMath ConstantsCologneComplete11.0
 	https://wg21.link/P0645";>P0645LWGText FormattingCologne
 	https://wg21.link/P0660";>P0660LWGStop Token and Joining Thread, Rev 10Cologne
-	https://wg21.link/P0784";>P0784CWGMore constexpr containersCologne
+	https://wg21.link/P0784";>P0784CWGMore constexpr containersCologneComplete12.0
 	https://wg21.link/P0980";>P0980LWGMaking std::string constexprCologne
 	https://wg21.link/P1004";>P1004LWGMaking std::vector constexprCologne
 	https://wg21.link/P1035";>P1035LWGInput Range AdaptorsCologne
Index: libcxx/utils/generate_feature_test_macro_components.py
===
--- libcxx/utils/generate_feature_test_macro_components.py
+++ libcxx/utils/generate_feature_test_macro_components.py
@@ -664,6 +664,12 @@
"depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
"internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
},
+   {"name": "__cpp_lib_constexpr_dynamic_alloc",
+"values": {
+  "c++2a": int(201907)
+},
+"headers": ["memory"]
+   },
 ]], key=lambda tc: tc["name"])
 
 def get_std_dialects():
Index: libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
===
--- libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
+++ libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
@@ -11,40 +11,52 @@
 // 
 
 // template 
-// ForwardIt destroy_n(ForwardIt, Size s);
+// constexpr ForwardIt destroy_n(ForwardIt, Size s);
 
 #include 
-#include 
 #include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
 struct Counted {
-  static int count;
-  static void reset() { count = 0; }
-  Counted() { ++count; }
-  Counted(Counted const&) { ++count; }
-  ~Counted() { --count; }
-  friend void operator&(Counted) = delete;
+int* counter_;
+TEST_CONSTEXPR Counted(int* counter) : counter_(counter) { ++*counter_; }
+TEST_CONSTEXPR Counted(Counted const& other) : counter_(other.counter_) { ++*counter_; }
+TEST_CONSTEXPR_CXX20 ~Counted() { --*counter_; }
+friend void operator&(Counted) = delete;
 };
-int Counted::count = 0;
+
+TEST_CONSTEXPR_CXX20 bo

[PATCH] D88003: Fix typos in ASTMatchers.h

2020-09-22 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!


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

https://reviews.llvm.org/D88003

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


[PATCH] D88092: [analyzer][StdLibraryFunctionsChecker] Fix getline/getdelim signatures

2020-09-22 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: balazske, Szelethus, steakhal, NoQ, vsavchenko.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.
martong requested review of this revision.

It is no longer needed to add summaries of 'getline' for different
possible underlying types of ssize_t. We can just simply lookup the
type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88092

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -57,7 +57,9 @@
 // CHECK-NEXT: Loaded summary for: unsigned int fwrite(const void *restrict, size_t, size_t, FILE *restrict)
 // CHECK-NEXT: Loaded summary for: ssize_t read(int, void *, size_t)
 // CHECK-NEXT: Loaded summary for: ssize_t write(int, const void *, size_t)
-// CHECK-NEXT: Loaded summary for: ssize_t getline(char **, size_t *, FILE *)
+// CHECK-NEXT: Loaded summary for: ssize_t getline(char **restrict, size_t *restrict, FILE *restrict)
+// CHECK-NEXT: Loaded summary for: ssize_t getdelim(char **restrict, size_t *restrict, int, FILE *restrict)
+
 
 void clang_analyzer_eval(int);
 
@@ -126,7 +128,8 @@
   (void)fread(ptr, sz, nmem, fp); // expected-warning {{1st function call argument is an uninitialized value}}
 }
 
-ssize_t getline(char **, size_t *, FILE *);
+ssize_t getline(char **restrict, size_t *restrict, FILE *restrict);
+ssize_t getdelim(char **restrict, size_t *restrict, int, FILE *restrict);
 void test_getline(FILE *fp) {
   char *line = 0;
   size_t n = 0;
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -947,7 +947,6 @@
   const QualType IntTy = ACtx.IntTy;
   const QualType UnsignedIntTy = ACtx.UnsignedIntTy;
   const QualType LongTy = ACtx.LongTy;
-  const QualType LongLongTy = ACtx.LongLongTy;
   const QualType SizeTy = ACtx.getSizeType();
 
   const QualType VoidPtrTy = getPointerTy(VoidTy); // void *
@@ -973,7 +972,6 @@
   const RangeInt UnsignedIntMax =
   BVF.getMaxValue(UnsignedIntTy).getLimitedValue();
   const RangeInt LongMax = BVF.getMaxValue(LongTy).getLimitedValue();
-  const RangeInt LongLongMax = BVF.getMaxValue(LongLongTy).getLimitedValue();
   const RangeInt SizeMax = BVF.getMaxValue(SizeTy).getLimitedValue();
 
   // Set UCharRangeMax to min of int or uchar maximum value.
@@ -1076,6 +1074,12 @@
 return IntRangeVector{std::pair{b, *e}};
   return IntRangeVector{};
 }
+auto operator()(std::pair i0,
+std::pair> i1) {
+  if (i1.second)
+return IntRangeVector{i0, {i1.first, *(i1.second)}};
+  return IntRangeVector{i0};
+}
   } Range;
   auto SingleValue = [](RangeInt v) {
 return IntRangeVector{std::pair{v, v}};
@@ -1089,19 +1093,6 @@
   Optional FilePtrTy = getPointerTy(FileTy);
   Optional FilePtrRestrictTy = getRestrictTy(FilePtrTy);
 
-  // Templates for summaries that are reused by many functions.
-  auto Read = [&](RetType R, RangeInt Max) {
-return Summary(ArgTypes{Irrelevant, Irrelevant, SizeTy}, RetType{R},
-   NoEvalCall)
-.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-   ReturnValueCondition(WithinRange, Range(-1, Max))});
-  };
-  auto Getline = [&](RetType R, RangeInt Max) {
-return Summary(ArgTypes{Irrelevant, Irrelevant, Irrelevant}, RetType{R},
-   NoEvalCall)
-.Case({ReturnValueCondition(WithinRange, {{-1, -1}, {1, Max}})});
-  };
-
   // We are finally ready to define specifications for all supported functions.
   //
   // Argument ranges should always cover all variants. If return value
@@ -1296,27 +1287,52 @@
 RetType{SizeTy}),
   FreadSummary);
 
-  // We are not sure how ssize_t is defined on every platform, so we
-  // provide three variants that should cover common cases.
-  // FIXME Use lookupTy("ssize_t") instead of the `Read` lambda.
+  Optional Ssize_tTy = lookupTy("ssize_t");
+  Optional Ssize_tMax = getMaxValue(Ssize_tTy);
+
+  auto ReadSummary =
+  Summary(NoEvalCall)
+  .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+ ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))});
+
   // FIXME these are actually defined by POSIX and not by the C standard, we
   // should handle them together with the rest of the POSIX functions.
-  addToFunctionSummaryMap("read", {Read(In

[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:224
+  /// "a, b  c"  <=> [("a", ","), ("b", nul), ("c", nul)]
+  /// "a, b,"<=> [("a", ","), ("b", ","), (nul, nul)]
   ///

I'd slightly prefer "null" b/c "nul" refers to the ASCII character. Feel free 
to add more spaces to make columns line up :)



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:129
+  std::string dump(const List::ElementAndDelimiter &ED) {
+auto Format = [](StringRef s) { return "'" + s.trim().str() + "'"; };
+





Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:154
+  OS << ", " << dump(*ED);
+OS << "]";
+return OS.str();

Would llvm::interleaveComma help?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:330
+"[('a', '::'), ('b', '::'), ('c', nul)]");
+}
+

All of the tests above are testing getElementsAsNodesAndDelimiters -- could you 
put that into the test names? Or do you plan adding more assertions in the end? 
Or is that the only meaningful assertion? (I think not, we could also test the 
low-level non-typed function at least.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

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


[PATCH] D77598: Integral template argument suffix and cast printing

2020-09-22 Thread Pratyush Das via Phabricator via cfe-commits
reikdas updated this revision to Diff 293432.
reikdas added a comment.

Attempt an alternate approach, following @rsmith 's inline suggestions. 
Unfortunately, one of the tests added in this revision unexpectedly fail in 
this approach :(


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

https://reviews.llvm.org/D77598

Files:
  clang/include/clang/AST/StmtDataCollectors.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  
clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
@@ -20,7 +20,11 @@
 llvm::raw_string_ostream Stream(ArgStr);
 const TemplateArgument &Arg = ArgLoc.getArgument();
 
-Arg.print(Context->getPrintingPolicy(), Stream);
+bool knownType = true;
+if (auto *DRE = dyn_cast(Arg.getAsExpr()))
+  if (DRE->hadMultipleCandidates())
+knownType = false;
+Arg.print(Context->getPrintingPolicy(), Stream, knownType);
 Match(Stream.str(), ArgLoc.getLocation());
 return ExpectedLocationVisitor::
   TraverseTemplateArgumentLoc(ArgLoc);
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -459,3 +459,13 @@
   X y;
   int n = y.call(); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
 }
+
+namespace PR9227 {
+  template  struct S {};
+  template <> struct S<1> { using type = int; }; // expected-note {{'S<1>::type' declared here}}
+  S<1L>::type t; // expected-error {{no type named 'type' in 'PR9227::S<1L>'; did you mean 'S<1>::type'?}}
+
+  template  struct A {};
+  template <> struct A<1> { using type = int; }; // expected-note {{'A<1>::type' declared here}}
+  A<2>::type x; // expected-error {{no type named 'type' in 'PR9227::A<2>'; did you mean 'A<1>::type'?}}
+}
Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,23 @@
   void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>'; did you mean 'enable_if_char<'a'>::type'?}}
+
+  template  struct enable_if_int {};
+  template <> struct enable_if_int<1> { typedef int type; }; // expected-note{{'enable_if_int<1>::type' declared here}}
+  void test_int() { enable_if_int<2>::type i; } // expected-error{{enable_if_int<2>'; did you mean 'enable_if_int<1>::type'?}}
+
+  template  struct enable_if_unsigned_int {};
+  template <> struct enable_if_unsigned_int<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_int<1>::type' declared here}}
+  void test_unsigned_int() { enable_if_unsigned_int<2>::type i; } // expected-error{{enable_if_unsigned_int<2>'; did you mean 'enable_if_unsigned_int<1>::type'?}}
+
+  template  struct enable_if_unsigned_long_long {};
+  template <> struct enable_if_unsigned_long_long<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_long_long<1>::type' declared here}}
+  void test_unsigned_long_long() { enable_if_unsigned_long_long<2>::type i; } // expected-error{{enable_if_unsigned_long_long<2>'; did you mean 'enable_if_unsigned_long_long<1>::type'?}}
+
+  template  struct enable_if_long_long {};
+  template <> struct enable_if_long_long<1> { typedef int type; }; // expected-note{{'enable_if_long_long<1>::type' declared here}}
+  void test_long_long() { enable_if_long_long<2>::type i; } // expected-error{{enable_if_long_long<2>'; did you mean 'enable_if_long_long<1>::type'?}}
+
 }
 
 namespace PR10579 {
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4694,8 +

[PATCH] D77598: Integral template argument suffix and cast printing

2020-09-22 Thread Pratyush Das via Phabricator via cfe-commits
reikdas added inline comments.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp:466
+  template <> struct S<1> { using type = int; }; // expected-note 
{{'S<1>::type' declared here}}
+  S<1L>::type t; // expected-error {{no type named 'type' in 'PR9227::S<1L>'; 
did you mean 'S<1>::type'?}}
+

@rsmith This test fails with this new diff :( Could you please suggest a 
possible way to fix this?


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

https://reviews.llvm.org/D77598

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


[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-22 Thread Jonathan Wakely via Phabricator via cfe-commits
jwakely added inline comments.



Comment at: libcxx/include/new:243
 # ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
 return ::operator new(__size, __align_val);
 # else

ldionne wrote:
> This breaks GCC (as of GCC 9). I don't know what mechanism GCC uses to tie 
> into constexpr allocation, so I don't know what the fix is.
> 
> @jwakely Can you throw some hints at me?
GCC 9 doesn't support constexpr allocation at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision as: libc++.
ldionne added a comment.

I'll go ahead and ship this even though I know it will cause problems on GCC.




Comment at: libcxx/include/new:243
 # ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
 return ::operator new(__size, __align_val);
 # else

jwakely wrote:
> ldionne wrote:
> > This breaks GCC (as of GCC 9). I don't know what mechanism GCC uses to tie 
> > into constexpr allocation, so I don't know what the fix is.
> > 
> > @jwakely Can you throw some hints at me?
> GCC 9 doesn't support constexpr allocation at all.
Does GCC 10 support it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[clang] 6dc06fa - [SyntaxTree] Add tests for the assignment of the `canModify` tag.

2020-09-22 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-09-22T13:17:33Z
New Revision: 6dc06fa09d1a259df1f897dc821ba1544e2bcd24

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

LOG: [SyntaxTree] Add tests for the assignment of the `canModify` tag.

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 52bd5988b44ec..ecb4a7ce73a50 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3855,8 +3855,76 @@ TranslationUnit Detached
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, NonModifiableNodes) {
-  // Some nodes are non-modifiable, they are marked with 'I:'.
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_Leaf) {
+  // All nodes can be mutated.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define OPEN {
+#define CLOSE }
+
+void test() {
+  OPEN
+1;
+  CLOSE
+
+  OPEN
+2;
+  }
+}
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'1' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'2' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+`-'}' CloseParen
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MatchTree) {
+  // Some nodes are unmodifiable, they are marked with 'unmodifiable'.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define BRACES {}
+
+void test() BRACES
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen unmodifiable
+`-'}' CloseParen unmodifiable
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MismatchTree) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 #define HALF_IF if (1+
@@ -3896,21 +3964,16 @@ TranslationUnit Detached
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, ModifiableNodes) {
-  // All nodes can be mutated.
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_ModifiableArguments) {
+  // FIXME: Note that the substitutions for `X` and `Y` are marked modifiable.
+  // However we cannot change `X` freely. Indeed if we change its substitution
+  // in the condition we should also change it the then-branch.
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-#define OPEN {
-#define CLOSE }
+#define MIN(X,Y) X < Y ? X : Y
 
 void test() {
-  OPEN
-1;
-  CLOSE
-
-  OPEN
-2;
-  }
+  MIN(1,2);
 }
 )cpp",
   R"txt(
@@ -3924,24 +3987,109 @@ TranslationUnit Detached
   |   `-')' CloseParen
   `-CompoundStatement
 |-'{' OpenParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
+|-ExpressionStatement Statement
+| |-UnknownExpression Expression
+| | |-BinaryOperatorExpression unmodifiable
+| | | |-IntegerLiteralExpression LeftHandSide
+| | | | `-'1' LiteralToken
+| | | |-'<' OperatorToken unmodifiable
+| | | `-IntegerLiteralExpression RightHandSide
+| | |   `-'2' LiteralToken
+| | |-'?' unmodifiable
+| | |-IntegerLiteralExpression
 | | | `-'1' LiteralToken
-| | `-';'
-| `-'}' CloseParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
-| | | `-'2' LiteralToken
-| | `-';'
-| `-'}' CloseParen
+| | |-':' unmodifiable
+| | `-IntegerLiteralExpression
+| |   `-'2' LiteralToken
+| `-';'
 `-'}' CloseParen
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_MismatchTree) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define HALF_IF(X) if (X &&
+#define HALF_IF_2(Y) Y) {}
+void test() {
+  HALF_IF(1) HALF_IF_2(0) else {}
+})cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-IfStatement Statement
+| |-'if' IntroducerKeyword unmodifiable
+| |-'(' unmodifiable
+| |-BinaryOperatorExpression unmodifiabl

[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-22 Thread Jonathan Wakely via Phabricator via cfe-commits
jwakely added inline comments.



Comment at: libcxx/include/new:243
 # ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
 return ::operator new(__size, __align_val);
 # else

jwakely wrote:
> ldionne wrote:
> > This breaks GCC (as of GCC 9). I don't know what mechanism GCC uses to tie 
> > into constexpr allocation, so I don't know what the fix is.
> > 
> > @jwakely Can you throw some hints at me?
> GCC 9 doesn't support constexpr allocation at all.
GCC 9 doesn't support constexpr allocation at all. You can use 
`__cpp_constexpr_dynamic_alloc` to test for the feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[PATCH] D88077: [SyntaxTree] Add tests for the assignment of the `canModify` tag.

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6dc06fa09d1a: [SyntaxTree] Add tests for the assignment of 
the `canModify` tag. (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88077

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3855,8 +3855,76 @@
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, NonModifiableNodes) {
-  // Some nodes are non-modifiable, they are marked with 'I:'.
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_Leaf) {
+  // All nodes can be mutated.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define OPEN {
+#define CLOSE }
+
+void test() {
+  OPEN
+1;
+  CLOSE
+
+  OPEN
+2;
+  }
+}
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'1' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+|-CompoundStatement Statement
+| |-'{' OpenParen
+| |-ExpressionStatement Statement
+| | |-IntegerLiteralExpression Expression
+| | | `-'2' LiteralToken
+| | `-';'
+| `-'}' CloseParen
+`-'}' CloseParen
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MatchTree) {
+  // Some nodes are unmodifiable, they are marked with 'unmodifiable'.
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define BRACES {}
+
+void test() BRACES
+)cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen unmodifiable
+`-'}' CloseParen unmodifiable
+)txt"));
+}
+
+TEST_P(BuildSyntaxTreeTest, Macro_ObjectLike_MismatchTree) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 #define HALF_IF if (1+
@@ -3896,21 +3964,16 @@
 )txt"));
 }
 
-TEST_P(BuildSyntaxTreeTest, ModifiableNodes) {
-  // All nodes can be mutated.
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_ModifiableArguments) {
+  // FIXME: Note that the substitutions for `X` and `Y` are marked modifiable.
+  // However we cannot change `X` freely. Indeed if we change its substitution
+  // in the condition we should also change it the then-branch.
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-#define OPEN {
-#define CLOSE }
+#define MIN(X,Y) X < Y ? X : Y
 
 void test() {
-  OPEN
-1;
-  CLOSE
-
-  OPEN
-2;
-  }
+  MIN(1,2);
 }
 )cpp",
   R"txt(
@@ -3924,24 +3987,109 @@
   |   `-')' CloseParen
   `-CompoundStatement
 |-'{' OpenParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
+|-ExpressionStatement Statement
+| |-UnknownExpression Expression
+| | |-BinaryOperatorExpression unmodifiable
+| | | |-IntegerLiteralExpression LeftHandSide
+| | | | `-'1' LiteralToken
+| | | |-'<' OperatorToken unmodifiable
+| | | `-IntegerLiteralExpression RightHandSide
+| | |   `-'2' LiteralToken
+| | |-'?' unmodifiable
+| | |-IntegerLiteralExpression
 | | | `-'1' LiteralToken
-| | `-';'
-| `-'}' CloseParen
-|-CompoundStatement Statement
-| |-'{' OpenParen
-| |-ExpressionStatement Statement
-| | |-IntegerLiteralExpression Expression
-| | | `-'2' LiteralToken
-| | `-';'
-| `-'}' CloseParen
+| | |-':' unmodifiable
+| | `-IntegerLiteralExpression
+| |   `-'2' LiteralToken
+| `-';'
 `-'}' CloseParen
 )txt"));
 }
 
+TEST_P(BuildSyntaxTreeTest, Macro_FunctionLike_MismatchTree) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+#define HALF_IF(X) if (X &&
+#define HALF_IF_2(Y) Y) {}
+void test() {
+  HALF_IF(1) HALF_IF_2(0) else {}
+})cpp",
+  R"txt(
+TranslationUnit Detached
+`-SimpleDeclaration
+  |-'void'
+  |-SimpleDeclarator Declarator
+  | |-'test'
+  | `-ParametersAndQualifiers
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
+  `-CompoundStatement
+|-'{' OpenParen
+|-IfStatement Statement
+| |-'if' IntroducerKeyword unmodifiable
+| |-'(' unmodifiable
+| |-BinaryOperatorExpression unmodifiable
+| | |-IntegerLiteralExpression LeftHandSide
+| | | `-'1' LiteralToken
+| | |-'&&' OperatorToken unmodifiable
+| | `-IntegerLiteralExpression RightHandSide
+| |   `-'0' LiteralToken
+| |-')' unmodifiable
+| |-CompoundStatement ThenStatement unmodifiable
+| | |-'{' OpenParen unmodi

[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-22 Thread Jonathan Wakely via Phabricator via cfe-commits
jwakely added inline comments.



Comment at: libcxx/include/new:243
 # ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
 return ::operator new(__size, __align_val);
 # else

ldionne wrote:
> jwakely wrote:
> > jwakely wrote:
> > > ldionne wrote:
> > > > This breaks GCC (as of GCC 9). I don't know what mechanism GCC uses to 
> > > > tie into constexpr allocation, so I don't know what the fix is.
> > > > 
> > > > @jwakely Can you throw some hints at me?
> > > GCC 9 doesn't support constexpr allocation at all.
> > GCC 9 doesn't support constexpr allocation at all. You can use 
> > `__cpp_constexpr_dynamic_alloc` to test for the feature.
> Does GCC 10 support it?
Yes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[PATCH] D86790: [FE] Use preferred alignment instead of ABI alignment for complete object when applicable

2020-09-22 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4539
 CharUnits CCAlign = getParamTypeAlignment(Ty);
 CharUnits TyAlign = getContext().getTypeAlignInChars(Ty);
 

jasonliu wrote:
> Question: 
> It looks like getNaturalAlignIndirect and getTypeAlignInChars here are all 
> returning ABI alignment.
> But according to the comments, we should use a preferred alignment when it's 
> a complete object. Isn't this complete object? Or I'm missing something?
@jyknight Could you shine a light on this? Personally, I would agree that we 
have complete objects here, so preferred alignment should be used. And if that 
is true, changes should be applied on all other target within this file?


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

https://reviews.llvm.org/D86790

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


[PATCH] D87972: [OldPM] Pass manager: run SROA after (simple) loop unrolling

2020-09-22 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 added a comment.

SPEC 2017 on AArch64 is neutral on the geomean. The only slight worry is 
omnetpp with a 1% regression, but this is balanced by a .8% improvement on mcf. 
Other changes are in the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87972

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


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-09-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342

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


[clang] e8fb4eb - [AIX][clang][driver] Make sure crti[_64].o is linked in C++ mode

2020-09-22 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2020-09-22T09:55:06-04:00
New Revision: e8fb4eba4fb6cbda661080d76059f2b130df5020

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

LOG: [AIX][clang][driver] Make sure crti[_64].o is linked in C++ mode

since crti is required for functional static initialization.

Reviewed By: hubert.reinterpretcast

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index f4bab833fa9d..0d4d7e3dbf9f 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -133,6 +133,10 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
options::OPT_shared)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
+
+if (D.CCCIsCXX())
+  CmdArgs.push_back(Args.MakeArgString(
+  ToolChain.GetFilePath(IsArch32Bit ? "crti.o" : "crti_64.o")));
   }
 
   // Collect all static constructor and destructor functions in CXX mode. This

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 22b0378aa3dd..6dd14dc164df 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -14,6 +14,7 @@
 // CHECK-LD32: "-b32"
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "-lc"
@@ -31,6 +32,7 @@
 // CHECK-LD64: "-b64"
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "-lc"
@@ -49,6 +51,7 @@
 // CHECK-LD32-PTHREAD: "-b32"
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "-lpthreads"
@@ -68,6 +71,7 @@
 // CHECK-LD64-PTHREAD: "-b64"
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "-lpthreads"
@@ -87,6 +91,7 @@
 // CHECK-LD32-PROF: "-b32"
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "-lc"
@@ -105,6 +110,7 @@
 // CHECK-LD64-GPROF: "-b64"
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
+// CHECK-LD64-GPROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "-lc"
@@ -123,6 +129,7 @@
 // CHECK-LD32-STATIC: "-b32"
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-STATIC-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "-lc"
@@ -141,6 +148,7 @@
 // CHECK-LD32-LIBP: "-b32"
 // CHECK-LD32-LIBP: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-LIBP-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
@@ -161,6 +169,7 @@
 // CHECK-LD32-NO-STD-LIB: "-b32"
 // CHECK-LD32-NO-STD-LIB: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-NO-STD-LIB: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
@@ -181,6 +190,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-b64"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-NO-D

[PATCH] D87927: [AIX][clang][driver] Make sure crti[_64].o is linked in C++ mode

2020-09-22 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8fb4eba4fb6: [AIX][clang][driver] Make sure crti[_64].o is 
linked in C++ mode (authored by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87927

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -14,6 +14,7 @@
 // CHECK-LD32: "-b32"
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "-lc"
@@ -31,6 +32,7 @@
 // CHECK-LD64: "-b64"
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "-lc"
@@ -49,6 +51,7 @@
 // CHECK-LD32-PTHREAD: "-b32"
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "-lpthreads"
@@ -68,6 +71,7 @@
 // CHECK-LD64-PTHREAD: "-b64"
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "-lpthreads"
@@ -87,6 +91,7 @@
 // CHECK-LD32-PROF: "-b32"
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "-lc"
@@ -105,6 +110,7 @@
 // CHECK-LD64-GPROF: "-b64"
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
+// CHECK-LD64-GPROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "-lc"
@@ -123,6 +129,7 @@
 // CHECK-LD32-STATIC: "-b32"
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-STATIC-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "-lc"
@@ -141,6 +148,7 @@
 // CHECK-LD32-LIBP: "-b32"
 // CHECK-LD32-LIBP: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-LIBP-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
@@ -161,6 +169,7 @@
 // CHECK-LD32-NO-STD-LIB: "-b32"
 // CHECK-LD32-NO-STD-LIB: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-NO-STD-LIB: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
@@ -181,6 +190,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-b64"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
@@ -199,6 +209,7 @@
 // CHECK-LD32-CXX-ARG-ORDER: "-b32"
 // CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s"
 // CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors"
 // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
@@ -216,6 +227,7 @@
 // CHECK-LD32-CXX-ARG-LCXX: "-b32"
 // CHECK-LD32-CXX-ARG-LCXX: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHEC

[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-09-22 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D87946#2286434 , @grokos wrote:

> Correct, all `__tgt_target_*` functions not ending in `_mapper` are part of 
> the old interface and we are keeping them for compatibility with older 
> versions of clang. These older clang versions do not emit the location 
> pointer anyway, so this extra argument should be removed and each such 
> function should call into its new API equivalent passing a `nullptr`.
>
> We need the location pointer only for `__tgt_target_*_mapper` functions as 
> well as `__kmpc_push_target_tripcount` - this is the current interface.

Since the functions are `extern "C"` I'll need to rename them to something else 
to keep them backwards compatible and then change what current Clang generates. 
something like `__tgt_target_mapper_loc`? Seems like a hacky solution to just 
keep adding suffixed whenever we want a new interface though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87946

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


[PATCH] D85920: [FPEnv][AST] WIP!!! For casts, keep FP options in trailing storage of CastExpr

2020-09-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn abandoned this revision.
kpn added a comment.

Unneeded since D85960  landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85920

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


[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-09-22 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

@nemanjai Would you please take another look to see if I have addressed your 
comments when you get a chance? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83500

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-22 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

In D86694#2287242 , @russell.gallop 
wrote:

> I'm considering a slight change of plan. @cryptoad, in the name of 
> incremental development, would you be happy for me to put the scudo sanitizer 
> version up (with working tests), or is this deprecated now? It may not be the 
> best for performance long term but it's a smaller step than the standalone 
> port and seems to work.

Sounds good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-22 Thread Louis Dionne via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0724f8bf47f8: [libc++] Implement C++20's P0784 (More 
constexpr containers) (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

Files:
  libcxx/docs/FeatureTestMacroTable.rst
  libcxx/include/memory
  libcxx/include/new
  libcxx/include/version
  
libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.verify.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
  libcxx/test/std/utilities/memory/default.allocator/allocator.dtor.pass.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.constexpr.size.verify.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
  
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
  libcxx/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.construct/construct_at.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_at.pass.cpp
  
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
  libcxx/utils/generate_feature_test_macro_components.py
  libcxx/www/cxx2a_status.html

Index: libcxx/www/cxx2a_status.html
===
--- libcxx/www/cxx2a_status.html
+++ libcxx/www/cxx2a_status.html
@@ -164,7 +164,7 @@
 	https://wg21.link/P0631";>P0631LWGMath ConstantsCologneComplete11.0
 	https://wg21.link/P0645";>P0645LWGText FormattingCologne
 	https://wg21.link/P0660";>P0660LWGStop Token and Joining Thread, Rev 10Cologne
-	https://wg21.link/P0784";>P0784CWGMore constexpr containersCologne
+	https://wg21.link/P0784";>P0784CWGMore constexpr containersCologneComplete12.0
 	https://wg21.link/P0980";>P0980LWGMaking std::string constexprCologne
 	https://wg21.link/P1004";>P1004LWGMaking std::vector constexprCologne
 	https://wg21.link/P1035";>P1035LWGInput Range AdaptorsCologne
Index: libcxx/utils/generate_feature_test_macro_components.py
===
--- libcxx/utils/generate_feature_test_macro_components.py
+++ libcxx/utils/generate_feature_test_macro_components.py
@@ -664,6 +664,12 @@
"depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
"internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
},
+   {"name": "__cpp_lib_constexpr_dynamic_alloc",
+"values": {
+  "c++2a": int(201907)
+},
+"headers": ["memory"]
+   },
 ]], key=lambda tc: tc["name"])
 
 def get_std_dialects():
Index: libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
===
--- libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
+++ libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
@@ -11,40 +11,52 @@
 // 
 
 // template 
-// ForwardIt destroy_n(ForwardIt, Size s);
+// constexpr ForwardIt destroy_n(ForwardIt, Size s);
 
 #include 
-#include 
 #include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
 struct Counted {
-  static int count;
-  static void reset() { count = 0; }
-  Counted() { ++count; }
-  Counted(Counted const&) { ++count; }
-  ~Counted() { --count; }
-  friend void operator&(Counted) = delete;
+int* counter_;
+TEST_CONSTEXPR Counted(int* counter) : counter_(counter) { ++*counter_; }
+TEST_CONSTEXPR Counted(Counted const& other) : c

[PATCH] D88100: [analyzer][StdLibraryFunctionsChecker] Separate the signature from the summaries

2020-09-22 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: balazske, Szelethus, steakhal, NoQ, vsavchenko.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.
martong requested review of this revision.

The signature should not be part of the summaries as many FIXME comments
suggests. By separating the signature, we open up the way to a generic
matching implementation which could be used later under the hoods of
CallDescriptionMap.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88100

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -442,10 +442,6 @@
   ///   rules for the given parameter's type, those rules are checked once the
   ///   signature is matched.
   class Summary {
-// FIXME Probably the Signature should not be part of the Summary,
-// We can remove once all overload of addToFunctionSummaryMap requires the
-// Signature explicitly given.
-Optional Sign;
 const InvalidationKind InvalidationKd;
 Cases CaseConstraints;
 ConstraintSet ArgConstraints;
@@ -455,18 +451,8 @@
 const FunctionDecl *FD = nullptr;
 
   public:
-Summary(ArgTypes ArgTys, RetType RetTy, InvalidationKind InvalidationKd)
-: Sign(Signature(ArgTys, RetTy)), InvalidationKd(InvalidationKd) {}
-
 Summary(InvalidationKind InvalidationKd) : InvalidationKd(InvalidationKd) {}
 
-// FIXME Remove, once all overload of addToFunctionSummaryMap requires the
-// Signature explicitly given.
-Summary &setSignature(const Signature &S) {
-  Sign = S;
-  return *this;
-}
-
 Summary &Case(ConstraintSet &&CS) {
   CaseConstraints.push_back(std::move(CS));
   return *this;
@@ -488,10 +474,8 @@
 
 // Returns true if the summary should be applied to the given function.
 // And if yes then store the function declaration.
-bool matchesAndSet(const FunctionDecl *FD) {
-  assert(Sign &&
- "Signature must be set before comparing to a FunctionDecl");
-  bool Result = Sign->matches(FD) && validateByConstraints(FD);
+bool matchesAndSet(const Signature &Sign, const FunctionDecl *FD) {
+  bool Result = Sign.matches(FD) && validateByConstraints(FD);
   if (Result) {
 assert(!this->FD && "FD must not be set more than once");
 this->FD = FD;
@@ -499,13 +483,6 @@
   return Result;
 }
 
-// FIXME Remove, once all overload of addToFunctionSummaryMap requires the
-// Signature explicitly given.
-bool hasInvalidSignature() {
-  assert(Sign && "Signature must be set before this query");
-  return Sign->isInvalid();
-}
-
   private:
 // Once we know the exact type of the function then do sanity check on all
 // the given constraints.
@@ -1007,9 +984,8 @@
 // to the found FunctionDecl only if the signatures match.
 //
 // Returns true if the summary has been added, false otherwise.
-// FIXME remove all overloads without the explicit Signature parameter.
-bool operator()(StringRef Name, Summary S) {
-  if (S.hasInvalidSignature())
+bool operator()(StringRef Name, Signature Sign, Summary Sum) {
+  if (Sign.isInvalid())
 return false;
   IdentifierInfo &II = ACtx.Idents.get(Name);
   auto LookupRes = ACtx.getTranslationUnitDecl()->lookup(&II);
@@ -1017,8 +993,8 @@
 return false;
   for (Decl *D : LookupRes) {
 if (auto *FD = dyn_cast(D)) {
-  if (S.matchesAndSet(FD)) {
-auto Res = Map.insert({FD->getCanonicalDecl(), S});
+  if (Sum.matchesAndSet(Sign, FD)) {
+auto Res = Map.insert({FD->getCanonicalDecl(), Sum});
 assert(Res.second && "Function already has a summary set!");
 (void)Res;
 if (DisplayLoadedSummaries) {
@@ -1032,15 +1008,6 @@
   }
   return false;
 }
-// Add the summary with the Signature explicitly given.
-bool operator()(StringRef Name, Signature Sign, Summary Sum) {
-  return operator()(Name, Sum.setSignature(Sign));
-}
-// Add several summaries for the given name.
-void operator()(StringRef Name, const std::vector &Summaries) {
-  for (const Summary &S : Summaries)
-operator()(Name, S);
-}
 // Add the same summary for different names with the Signature explicitly
 // given.
 void operator()(std::vector Names, Signature Sign, Summary Sum) {
@@ -1109,8 +1076,8 @@
   // representable as unsigned char or is not equal to EOF. See e.g. C99
   // 7.4.1.2 The isalpha function (p: 181-182).
   addToFuncti

Re: [PATCH] D87921: Fix -funique-internal-linkage-names to work with -O2 and new pass manager

2020-09-22 Thread Fāng-ruì Sòng via cfe-commits
FWIW I tested check-msan in a -DCMAKE_BUILD_TYPE=Release build on a
powerpc64le machine. All tests passed. I cannot connect the failure to
the clang patch.

On Mon, Sep 21, 2020 at 10:02 PM Sriraman Tallam  wrote:
>
> On Mon, Sep 21, 2020 at 5:58 PM Matt Morehouse via Phabricator
>  wrote:
> >
> > morehouse added a comment.
> >
> > This change appears to trigger an assertion failure in sysmsg.c on the PPC 
> > bot:  
> > http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/26845/steps/ninja%20check%
> >
> >    TEST 'SanitizerCommon-msan-powerpc64le-Linux :: 
> > Linux/sysmsg.c' FAILED 
> >   Script:
> >   --
> >   : 'RUN: at line 1';  
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/./bin/clang 
> >  -gline-tables-only -fsanitize=memory  -m64 -fno-function-sections  -ldl 
> > -O1 
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/sanitizer_common/TestCases/Linux/sysmsg.c
> >  -o 
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.tmp
> >  &&  
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.tmp
> >   --
> >   Exit Code: 134
> >
> >   Command Output (stderr):
> >   --
> >   sysmsg.c.tmp: 
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/sanitizer_common/TestCases/Linux/sysmsg.c:14:
> >  int main(): Assertion `msgq != -1' failed.
> >   
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.script:
> >  line 1: 2982426 Aborted (core dumped) 
> > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.tmp
> >
> >   --
> >
> > It's not immediately obvious to me what is going wrong.  If you could take 
> > a look, I'd appreciate it.  Otherwise I will look closer tomorrow.
>
> I am having trouble getting access to a PPC machine,  this is going to
> take me longer. Should I revert the patch?
>
> Thanks
> Sri
>
> >
> >
> > Repository:
> >   rG LLVM Github Monorepo
> >
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D87921/new/
> >
> > https://reviews.llvm.org/D87921
> >



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


[PATCH] D78075: [WIP][Clang][OpenMP] Added support for nowait target in CodeGen

2020-09-22 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 293466.
tianshilei1992 added a comment.

Fixed the case `target_teams_distribute_simd_codegen.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78075

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Index: clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
@@ -66,7 +66,11 @@
 #ifndef HEADER
 #define HEADER
 
-// CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[IDENT_T:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[KMP_TASK_T_WITH_PRIVATES:%.+]] = type { [[KMP_TASK_T:%.+]], [[KMP_PRIVATES_T:%.+]] }
+// CHECK-DAG: [[KMP_TASK_T]] = type { i8*, i32 (i32, i8*)*, i32, %{{[^,]+}}, %{{[^,]+}} }
+// CHECK-32-DAG: [[KMP_PRIVATES_T]] = type { [3 x i64], [3 x i8*], [3 x i8*], [3 x i8*], i16 }
+// CHECK-64-DAG: [[KMP_PRIVATES_T]] = type { [3 x i8*], [3 x i8*], [3 x i64], [3 x i8*], i16 }
 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
 // CHECK-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
 
@@ -132,33 +136,26 @@
   double cn[5][n];
   TT d;
 
-  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target_teams_nowait_mapper(i64 -1, i8* @{{[^,]+}}, i32 3, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[SIZET]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[MAPT]], i32 0, i32 0), i8** null, i32 {{[^,]+}}, i32 {{[^)]+}})
-  // CHECK-DAG:   [[BP]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
-  // CHECK-DAG:   [[P]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
-  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
-  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
-  // CHECK-DAG:   [[CBPADDR0:%.+]] = bitcast i8** [[BPADDR0]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR0:%.+]] = bitcast i8** [[PADDR0]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR0]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR0]]
-  // CHECK-DAG:   [[BPADDR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX1:[0-9]+]]
-  // CHECK-DAG:   [[PADDR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX1]]
-  // CHECK-DAG:   [[CBPADDR1:%.+]] = bitcast i8** [[BPADDR1]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR1:%.+]] = bitcast i8** [[PADDR1]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR1]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR1]]
-  // CHECK-DAG:   [[BPADDR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX1:[0-9]+]]
-  // CHECK-DAG:   [[PADDR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX1]]
-  // CHECK-DAG:   [[CBPADDR2:%.+]] = bitcast i8** [[BPADDR2]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR2:%.+]] = bitcast i8** [[PADDR2]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR2]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR2]]
-  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
-  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
-  // CHECK:   [[FAIL]]
-  // CHECK:   call void [[HVT0:@.+]](i[[SZ]] {{[^,]+}}, i[[SZ]] {{[^,]+}}, i[[SZ]] {{[^)]+}})
-  // CHECK-NEXT:  br label %[[END]]
-  // CHECK:   [[END]]
+  // CHECK-DAG: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i8* [[TASK:%.+]])
+  // CHECK-32-DAG:  [[TASK]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i32 84, i32 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-64-DAG:  [[TASK]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 144, i64 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-DAG: [[TASK_CAST:%.+]] = bitcast i8* [[TASK

[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-09-22 Thread sameeran joshi via Phabricator via cfe-commits
sameeranjoshi added a comment.

Thanks for working on it.
Few comments inline:

1. For an out-of-tree build, I see `check-flang` target failing with

  /unittests/Frontend/CompilerInstanceTest.cpp:17:10: fatal error: filesystem: 
No such file or directory
   #include 
^~~~

I used gcc/g++ 7.5 version.
I haven't checked in-tree still, and others/bots might have checked it.

2. Either the documentation comments are wrong or code.

`README` mentions `DBUILD_FLANG_NEW_DRIVER` where as cmake ignores the flag for 
me.
Whereas, `CMakeLists.txt` mentions `FLANG_BUILD_NEW_DRIVER`.




Comment at: flang/include/flang/Frontend/TextDiagnosticBuffer.h:36
+  /// level and an index into the corresponding DiagList above.
+  std::vector> all_;
+

How about simplifying this with `using` keyword?



Comment at: flang/include/flang/Frontend/TextDiagnosticPrinter.h:37
+  /// Handle to the currently active text diagnostic emitter.
+  std::unique_ptr textDiag_;
+

Where is this used? I don't see any reference.



Comment at: flang/lib/Frontend/TextDiagnostic.cpp:12
+#include "llvm/Support/raw_ostream.h"
+#include 
+

Is this header used ?



Comment at: flang/lib/Frontend/TextDiagnostic.cpp:26
+static const enum llvm::raw_ostream::Colors savedColor =
+llvm::raw_ostream::SAVEDCOLOR;
+

Unless Flang is not changing the color scheme w.r.t clang, can't the code be 
shared between both projects?




Comment at: flang/lib/Frontend/TextDiagnosticPrinter.cpp:24
+
+TextDiagnosticPrinter::TextDiagnosticPrinter(
+raw_ostream &os, clang::DiagnosticOptions *diags)

A silly question from what I see usually in Flang coding style.
Why isn't it defined in header file?



Comment at: flang/lib/Frontend/TextDiagnosticPrinter.cpp:37
+  // this later as we print out the diagnostic to the terminal.
+  SmallString<100> outStr;
+  info.FormatDiagnostic(outStr);

kiranchandramohan wrote:
> 100? Will this contain path names by any chance?
Can we use at places where LLVM data structures are used explicit `llvm::` so 
an unknown user can easily identify where they come from?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87774

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


[PATCH] D87534: Sema: introduce `__attribute__((__swift_name__))`

2020-09-22 Thread Saleem Abdulrasool via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
compnerd marked 4 inline comments as done.
Closed by commit rG9bb5ecf1f760: Sema: introduce 
`__attribute__((__swift_name__))` (authored by compnerd).

Changed prior to commit:
  https://reviews.llvm.org/D87534?vs=292548&id=293470#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87534

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaObjC/attr-swift_name.m

Index: clang/test/SemaObjC/attr-swift_name.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_name.m
@@ -0,0 +1,174 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc %s
+
+#define SWIFT_NAME(name) __attribute__((__swift_name__(name)))
+
+typedef struct {
+  float x, y, z;
+} Point3D;
+
+__attribute__((__swift_name__("PType")))
+@protocol P
+@end
+
+__attribute__((__swift_name__("IClass")))
+@interface I
+- (instancetype)init SWIFT_NAME("init()");
+- (instancetype)initWithValue:(int)value SWIFT_NAME("iWithValue(_:)");
+
++ (void)refresh SWIFT_NAME("refresh()");
+
+- (instancetype)i SWIFT_NAME("i()");
+
+- (I *)iWithValue:(int)value SWIFT_NAME("i(value:)");
+- (I *)iWithValue:(int)value value:(int)value2 SWIFT_NAME("i(value:extra:)");
+- (I *)iWithValueConvertingValue:(int)value value:(int)value2 SWIFT_NAME("i(_:extra:)");
+
++ (I *)iWithOtheValue:(int)value SWIFT_NAME("init");
+// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}}
+
++ (I *)iWithAnotherValue:(int)value SWIFT_NAME("i()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
++ (I *)iWithYetAnotherValue:(int)value SWIFT_NAME("i(value:extra:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 1; got 2}}
+
++ (I *)iAndReturnErrorCode:(int *)errorCode SWIFT_NAME("i()"); // no-warning
++ (I *)iWithValue:(int)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(value:)"); // no-warning
+
++ (I *)iFromErrorCode:(const int *)errorCode SWIFT_NAME("i()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
++ (I *)iWithPointerA:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i()"); // no-warning
++ (I *)iWithPointerB:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(pointer:)"); // no-warning
++ (I *)iWithPointerC:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(pointer:errorCode:)"); // no-warning
+
++ (I *)iWithOtherI:(I *)other SWIFT_NAME("i()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
++ (instancetype)specialI SWIFT_NAME("init(options:)");
++ (instancetype)specialJ SWIFT_NAME("init(options:extra:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 0; got 2)}}
++ (instancetype)specialK SWIFT_NAME("init(_:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 0; got 1)}}
++ (instancetype)specialL SWIFT_NAME("i(options:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 0; got 1)}}
+
++ (instancetype)trailingParen SWIFT_NAME("foo(");
+// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}}
++ (instancetype)trailingColon SWIFT_NAME("foo:");
+// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}}
++ (instancetype)initialIgnore:(int)value SWIFT_NAME("_(value:)");
+// expected-warning@-1 {{'__swift_name__' attribute has invalid identifier for the base name}}
++ (instancetype)middleOmitted:(int)value SWIFT_NAME("i(:)");
+// expected-warning@-1 {{'__swift_name__' attribute has invalid identifier for the parameter name}}
+
+@property(strong) id someProp SWIFT_NAME("prop");
+@end
+
+enum SWIFT_NAME("E") E {
+  value1,
+  value2,
+  value3 SWIFT_NAME("three"),
+  value4 SWIFT_NAME("four()"), // expected-warning {{'__swift_name__' attribute has invalid identifier for the base name}}
+};
+
+struct SWIFT_NAME("TStruct") SStruct {
+  int i, j, k SWIFT_NAME("kay");
+};
+
+int i SWIFT_NAME("g_i");
+
+void f0(int i) SWIFT_NAME("f_0");
+// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}}
+
+void f1(int i) SWIFT_NAME("f_1()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
+void f2(int i) SWIFT_NAME("f_2(a:b:)");
+// expected-warning@

[clang] 9bb5ecf - Sema: introduce `__attribute__((__swift_name__))`

2020-09-22 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-09-22T15:32:23Z
New Revision: 9bb5ecf1f760e1b1fe4697189e4db99100baffad

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

LOG: Sema: introduce `__attribute__((__swift_name__))`

This introduces the new `swift_name` attribute that allows annotating
APIs with an alternate spelling for Swift.  This is used as part of the
importing mechanism to allow interfaces to be imported with a new name
into Swift.  It takes a parameter which is the Swift function name.
This parameter is validated to check if it matches the possible
transformed signature in Swift.

This is based on the work of the original changes in
https://github.com/llvm/llvm-project-staging/commit/8afaf3aad2af43cfedca7a24cd817848c4e95c0c

Differential Revision: https://reviews.llvm.org/D87534
Reviewed By: Aaron Ballman, Dmitri Gribenko

Added: 
clang/test/SemaObjC/attr-swift_name.m

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index c2073e68be2c..e8ac819c8b55 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2162,6 +2162,12 @@ def SwiftError : InheritableAttr {
   let Documentation = [SwiftErrorDocs];
 }
 
+def SwiftName : InheritableAttr {
+  let Spellings = [GNU<"swift_name">];
+  let Args = [StringArgument<"Name">];
+  let Documentation = [SwiftNameDocs];
+}
+
 def NoDeref : TypeAttr {
   let Spellings = [Clang<"noderef">];
   let Documentation = [NoDerefDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index aab337a4e24a..9c119218656d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3572,6 +3572,30 @@ The return type is left unmodified.
   }];
 }
 
+def SwiftNameDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_name";
+  let Content = [{
+The ``swift_name`` attribute provides the name of the declaration in Swift. If
+this attribute is absent, the name is transformed according to the algorithm
+built into the Swift compiler.
+
+The argument is a string literal that contains the Swift name of the function,
+variable, or type. When renaming a function, the name may be a compound Swift
+name.  For a type, enum constant, property, or variable declaration, the name
+must be a simple or qualified identifier.
+
+  .. code-block:: c
+
+@interface URL
+- (void) initWithString:(NSString *)s 
__attribute__((__swift_name__("URL.init(_:)")))
+@end
+
+void __attribute__((__swift_name__("squareRoot()"))) sqrt(double v) {
+}
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d826e26bea53..a2f5aeafd457 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -557,6 +557,7 @@ def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
 def StrncatSize : DiagGroup<"strncat-size">;
+def SwiftNameAttribute : DiagGroup<"swift-name-attribute">;
 def IntInBoolContext : DiagGroup<"int-in-bool-context">;
 def TautologicalTypeLimitCompare : 
DiagGroup<"tautological-type-limit-compare">;
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 053aae7a6afa..0cb817df9db3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3974,6 +3974,46 @@ def err_objc_bridged_related_known_method : Error<
 def err_objc_attr_protocol_requires_definition : Error<
   "attribute %0 can only be applied to @protocol definitions, not forward 
declarations">;
 
+// Swift attributes.
+def warn_attr_swift_name_function
+  : Warning<"%0 attribute argument must be a string literal specifying a Swift 
function name">,
+InGroup;
+def warn_attr_swift_name_invalid_identifier
+  : Warning<"%0 attribute has invalid identifier for the 
%select{base|context|parameter}1 name">,
+InGroup;
+def warn_attr_swift_name_decl_kind
+  : Warning<"%0 attribute cannot be applied to this declaration">,
+InGroup;
+def warn_attr_swift_name_subscript_invalid_parame

[PATCH] D86819: [PowerPC][Power10] Implementation of 128-bit Binary Vector Rotate builtins

2020-09-22 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 293474.
Conanap marked 2 inline comments as done.
Conanap added a comment.

Changed implementation for vrlqnm as per Nemanja


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

https://reviews.llvm.org/D86819

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-rotate.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-rotate.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-rotate.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; This test case aims to test the builtins for vector rotate instructions
+; on Power10.
+
+
+define <1 x i128> @test_vrlq(<1 x i128> %x, <1 x i128> %y) {
+; CHECK-LABEL: test_vrlq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vrlq v2, v3, v2
+; CHECK-NEXT:blr
+  %shl.i = shl <1 x i128> %y, %x
+  %sub.i = sub <1 x i128> , %x
+  %lshr.i = lshr <1 x i128> %y, %sub.i
+  %tmp = or <1 x i128> %shl.i, %lshr.i
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vrlq_cost_mult8(<1 x i128> %x) {
+; CHECK-LABEL: test_vrlq_cost_mult8:
+; CHECK: # %bb.0:
+; CHECK: vrlq v2, v3, v2
+; CHECK-NEXT: blr
+  %shl.i = shl <1 x i128> , %x
+  %sub.i = sub <1 x i128> , %x
+  %lshr.i = lshr <1 x i128> , %sub.i
+  %tmp = or <1 x i128> %shl.i, %lshr.i
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vrlq_cost_non_mult8(<1 x i128> %x) {
+; CHECK-LABEL: test_vrlq_cost_non_mult8:
+; CHECK: # %bb.0:
+; CHECK: vrlq v2, v3, v2
+; CHECK-NEXT: blr
+  %shl.i = shl <1 x i128> , %x
+  %sub.i = sub <1 x i128> , %x
+  %lshr.i = lshr <1 x i128> , %sub.i
+  %tmp = or <1 x i128> %shl.i, %lshr.i
+  ret <1 x i128> %tmp
+}
+
+; Function Attrs: nounwind readnone
+define <1 x i128> @test_vrlqmi(<1 x i128> %a, <1 x i128> %b, <1 x i128> %c) {
+; CHECK-LABEL: test_vrlqmi:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vrlqmi v3, v2, v4
+; CHECK-NEXT:vmr v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vrlqmi(<1 x i128> %a, <1 x i128> %c, <1 x i128> %b)
+  ret <1 x i128> %tmp
+}
+
+; Function Attrs: nounwind readnone
+define <1 x i128> @test_vrlqnm(<1 x i128> %a, <1 x i128> %b, <1 x i128> %c) {
+; CHECK-LABEL: test_vrlqnm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vrlqnm v2, v2, v3
+; CHECK-NEXT:xxland v2, v2, v4
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <1 x i128> @llvm.ppc.altivec.vrlqnm(<1 x i128> %a, <1 x i128> %b)
+  %tmp = and <1 x i128> %0, %c
+  ret <1 x i128> %tmp
+}
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vrlqmi(<1 x i128>, <1 x i128>, <1 x i128>)
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vrlqnm(<1 x i128>, <1 x i128>)
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1446,19 +1446,25 @@
"vcmpuq $BF, $vA, $vB", IIC_VecGeneral, []>;
   def VCMPSQ : VXForm_BF3_VAB5<321, (outs crrc:$BF), (ins vrrc:$vA, vrrc:$vB),
"vcmpsq $BF, $vA, $vB", IIC_VecGeneral, []>;
-  def VRLQNM : VX1_VT5_VA5_VB5<325, "vrlqnm", []>;
-  def VRLQMI : VXForm_1<69, (outs vrrc:$vD),
-(ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
-"vrlqmi $vD, $vA, $vB", IIC_VecFP, []>,
-RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
   def VSLQ : VX1_VT5_VA5_VB5<261, "vslq", []>;
   def VSRAQ : VX1_VT5_VA5_VB5<773, "vsraq", []>;
   def VSRQ : VX1_VT5_VA5_VB5<517, "vsrq", []>;
-  def VRLQ : VX1_VT5_VA5_VB5<5, "vrlq", []>;
   def XSCVQPUQZ : X_VT5_XO5_VB5<63, 0, 836, "xscvqpuqz", []>;
   def XSCVQPSQZ : X_VT5_XO5_VB5<63, 8, 836, "xscvqpsqz", []>;
   def XSCVUQQP : X_VT5_XO5_VB5<63, 3, 836, "xscvuqqp", []>;
   def XSCVSQQP : X_VT5_XO5_VB5<63, 11, 836, "xscvsqqp", []>;
+  def VRLQ : VX1_VT5_VA5_VB5<5, "vrlq", []>;
+  def VRLQNM : VX1_VT5_VA5_VB5<325, "vrlqnm",
+   [(set v1i128:$vD,
+   (int_ppc_altivec_vrlqnm v1i128:$vA,
+   v1i128:$vB))]>;
+  def VRLQMI : VXForm_1<69, (outs vrrc:$vD),
+(ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
+"vrlqmi $vD, $vA, $vB", IIC_VecFP,
+[(set v1i128:$vD,
+   (int_ppc_altivec_vrlqmi v1i128:$vA, v1i128:$vB,
+  

[PATCH] D88103: [JSON] Add error reporting facility, used in fromJSON and ObjectMapper.

2020-09-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: clayborg, kadircet, wallace.
Herald added subscribers: llvm-commits, cfe-commits, usaxena95, arphaman, 
mgrang, hiraditya.
Herald added projects: clang, LLVM.
sammccall requested review of this revision.
Herald added a subscriber: ilya-biryukov.

Translating between JSON objects and C++ strutctures is common.
>From experience in clangd, fromJSON/ObjectMapper work well and save a lot of
code, but aren't adopted elsewhere at least partly due to total lack of error
reporting beyond "ok"/"bad".

This new error model should be rich enough for most applications. It comprises:

- a name for the root object, so the user knows what we're parsing
- a path from the root object to the JSON node most associated with the error
- a local error message

These can be presented in two ways:

- An llvm::Error like "expected string at ConfigFile.credentials[0].username"
- A truncated dump of the original object with the error marked, like: { 
"credentials": [ { "username": /* error: expected string */ 42, "password": 
"secret" }, { ... } ] "backups": { ... } }

To track the locations, we exploit the fact that the call graph of recursive
parse functions mirror the structure of the JSON itself.
The current path is represented as a linked list of segments, each of which is
on the stack as a parameter. Concretely, fromJSON now looks like:

  bool fromJSON(const Value&, T&, Path);

The heavy parts mostly stay out of the way:

- building path segments is mostly handled in library code for common cases 
(arrays mapped as std::vector, objects mapped using ObjectMapper)
- no heap allocation at all unless an error is encountered, then one small one
- llvm::Error and error-in-context are created only if needed

The general top-level interface (Path::Root) is independent of fromJSON etc, and
ends up being a bit clunky.
I've added high-level parse(StringRef) -> Expected, but it's not general
enough to be the primary interface I think (at least, not usable in clangd).

---

This can be split into several separate patches if desired:

- the comment support in json::OStream (used to show errors in context)
- the Path type, including llvm::Error representation
- the fromJSON/ObjectMapper changes (and clangd usages - hard to separate)
- support for printing errors in context

I wanted to show it all together first, though.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88103

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  llvm/include/llvm/Support/JSON.h
  llvm/lib/Support/JSON.cpp
  llvm/unittests/Support/JSONTest.cpp

Index: llvm/unittests/Support/JSONTest.cpp
===
--- llvm/unittests/Support/JSONTest.cpp
+++ llvm/unittests/Support/JSONTest.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Error.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -372,8 +373,8 @@
   return OS << "(" << S.S << ", " << (S.I ? std::to_string(*S.I) : "None")
 << ", " << S.B << ")";
 }
-bool fromJSON(const Value &E, CustomStruct &R) {
-  ObjectMapper O(E);
+bool fromJSON(const Value &E, CustomStruct &R, Path P) {
+  ObjectMapper O(E, P);
   if (!O || !O.map("str", R.S) || !O.map("int", R.I))
 return false;
   O.map("bool", R.B);
@@ -403,16 +404,80 @@
   CustomStruct("bar", llvm::None, false),
   CustomStruct("baz", llvm::None, false),
   };
-  ASSERT_TRUE(fromJSON(J, R));
+  Path::Root Root("CustomStruct");
+  ASSERT_TRUE(fromJSON(J, R, Root));
   EXPECT_EQ(R, Expected);
 
   CustomStruct V;
-  EXPECT_FALSE(fromJSON(nullptr, V)) << "Not an object " << V;
-  EXPECT_FALSE(fromJSON(Object{}, V)) << "Missing required field " << V;
-  EXPECT_FALSE(fromJSON(Object{{"str", 1}}, V)) << "Wrong type " << V;
+  EXPECT_FALSE(fromJSON(nullptr, V, Root));
+  EXPECT_EQ("expected object when parsing CustomStruct",
+toString(Root.getError()));
+
+  EXPECT_FALSE(fromJSON(Object{}, V, Root));
+  EXPECT_EQ("missing value at CustomStruct.str", toString(Root.getError()));
+
+  EXPECT_FALSE(fromJSON(Object{{"str", 1}}, V, Root));
+  EXPECT_EQ("expected string at CustomStruct.str", toString(Root.getError()));
+
   // Optional must parse as the correct type if present.
-  EXPECT_FALSE(fromJSON(Object{{"str", 1}, {"int", "string"}}, V))
-  << "Wrong type for Optional " << V;
+  EXPECT_FALSE(fromJSON(Object{{"str", "1"}, {"int", "string"}}, V, Root));
+  EXPECT_EQ("expected integer at CustomStruct.int", toString(Root.getError()));
+}
+
+static std::string errorContext(const Value &V, const Path::Root &R) {
+  std::string Context;
+  llvm::raw_string_ostream OS(Context);
+  R.printErrorContext(V, OS);
+  return OS.str(

[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 293489.
eduucaldas marked 3 inline comments as done.
eduucaldas added a comment.

Answer code review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "TreeTestBase.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "llvm/ADT/STLExtras.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -122,4 +124,239 @@
   }
 }
 
+class ListTest : public SyntaxTreeTest {
+private:
+  std::string dumpQuotedTokensOrNull(const Node *N) {
+return N ? "'" +
+   StringRef(N->dumpTokens(Arena->getSourceManager()))
+   .trim()
+   .str() +
+   "'"
+ : "null";
+  }
+
+protected:
+  std::string
+  dumpElementsAndDelimiters(ArrayRef> EDs) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(
+EDs, OS, [&OS, this](const List::ElementAndDelimiter &ED) {
+  OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
+ << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+});
+
+OS << "]";
+
+return OS.str();
+  }
+
+  std::string dumpNodes(ArrayRef Nodes) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(Nodes, OS, [&OS, this](const Node *N) {
+  OS << dumpQuotedTokensOrNull(N);
+});
+
+OS << "]";
+
+return OS.str();
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(TreeTests, ListTest,
+::testing::ValuesIn(allTestClangConfigs()), );
+
+/// "a, b, c"  <=> [("a", ","), ("b", ","), ("c", null)]
+TEST_P(ListTest, List_Separated_WellFormed) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()),
+"['a', 'b', 'c']");
+}
+
+/// "a,  , c"  <=> [("a", ","), (null, ","), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingElement) {
+  buildTree("", GetParam());
+
+  // "a,  , c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), (null, ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()),
+"['a', null, 'c']");
+}
+
+/// "a, b  c"  <=> [("a", ","), ("b", null), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingDelimiter) {
+  buildTree("", GetParam());
+
+  // "a, b  c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', null), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()),
+"['a', 'b', 'c']");
+}
+
+/// "a, b,"<=> [("a", ","), ("b", ","), (null, null)]
+TEST_P(ListTest, List_Separated_MissingLastElement) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement

[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 293490.
eduucaldas added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "TreeTestBase.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "llvm/ADT/STLExtras.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -122,4 +124,231 @@
   }
 }
 
+class ListTest : public SyntaxTreeTest {
+private:
+  std::string dumpQuotedTokensOrNull(const Node *N) {
+return N ? "'" +
+   StringRef(N->dumpTokens(Arena->getSourceManager()))
+   .trim()
+   .str() +
+   "'"
+ : "null";
+  }
+
+protected:
+  std::string
+  dumpElementsAndDelimiters(ArrayRef> EDs) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(
+EDs, OS, [&OS, this](const List::ElementAndDelimiter &ED) {
+  OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
+ << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+});
+
+OS << "]";
+
+return OS.str();
+  }
+
+  std::string dumpNodes(ArrayRef Nodes) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(Nodes, OS, [&OS, this](const Node *N) {
+  OS << dumpQuotedTokensOrNull(N);
+});
+
+OS << "]";
+
+return OS.str();
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(TreeTests, ListTest,
+::testing::ValuesIn(allTestClangConfigs()), );
+
+/// "a, b, c"  <=> [("a", ","), ("b", ","), ("c", null)]
+TEST_P(ListTest, List_Separated_WellFormed) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
+}
+
+/// "a,  , c"  <=> [("a", ","), (null, ","), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingElement) {
+  buildTree("", GetParam());
+
+  // "a,  , c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), (null, ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', null, 'c']");
+}
+
+/// "a, b  c"  <=> [("a", ","), ("b", null), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingDelimiter) {
+  buildTree("", GetParam());
+
+  // "a, b  c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', null), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
+}
+
+/// "a, b,"<=> [("a", ","), ("b", ","), (null, null)]
+TEST_P(ListTest, List_Separated_MissingLastElement) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  },
+  NodeKind::Ca

[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas marked an inline comment as done.
eduucaldas added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:224
+  /// "a, b  c"  <=> [("a", ","), ("b", nul), ("c", nul)]
+  /// "a, b,"<=> [("a", ","), ("b", ","), (nul, nul)]
   ///

gribozavr2 wrote:
> I'd slightly prefer "null" b/c "nul" refers to the ASCII character. Feel free 
> to add more spaces to make columns line up :)
Thanks for providing my solution to my crazyness ^^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

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


Re: [PATCH] D87921: Fix -funique-internal-linkage-names to work with -O2 and new pass manager

2020-09-22 Thread Sriraman Tallam via cfe-commits
On Tue, Sep 22, 2020 at 8:34 AM Fāng-ruì Sòng  wrote:
>
> FWIW I tested check-msan in a -DCMAKE_BUILD_TYPE=Release build on a
> powerpc64le machine. All tests passed. I cannot connect the failure to
> the clang patch.

Thanks for doing this! Much appreciated!

>
> On Mon, Sep 21, 2020 at 10:02 PM Sriraman Tallam  wrote:
> >
> > On Mon, Sep 21, 2020 at 5:58 PM Matt Morehouse via Phabricator
> >  wrote:
> > >
> > > morehouse added a comment.
> > >
> > > This change appears to trigger an assertion failure in sysmsg.c on the 
> > > PPC bot:  
> > > http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/26845/steps/ninja%20check%
> > >
> > >    TEST 'SanitizerCommon-msan-powerpc64le-Linux :: 
> > > Linux/sysmsg.c' FAILED 
> > >   Script:
> > >   --
> > >   : 'RUN: at line 1';  
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/./bin/clang
> > >   -gline-tables-only -fsanitize=memory  -m64 -fno-function-sections  -ldl 
> > > -O1 
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/sanitizer_common/TestCases/Linux/sysmsg.c
> > >  -o 
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.tmp
> > >  &&  
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.tmp
> > >   --
> > >   Exit Code: 134
> > >
> > >   Command Output (stderr):
> > >   --
> > >   sysmsg.c.tmp: 
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/sanitizer_common/TestCases/Linux/sysmsg.c:14:
> > >  int main(): Assertion `msgq != -1' failed.
> > >   
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.script:
> > >  line 1: 2982426 Aborted (core dumped) 
> > > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/projects/compiler-rt/test/sanitizer_common/msan-powerpc64le-Linux/Linux/Output/sysmsg.c.tmp
> > >
> > >   --
> > >
> > > It's not immediately obvious to me what is going wrong.  If you could 
> > > take a look, I'd appreciate it.  Otherwise I will look closer tomorrow.
> >
> > I am having trouble getting access to a PPC machine,  this is going to
> > take me longer. Should I revert the patch?
> >
> > Thanks
> > Sri
> >
> > >
> > >
> > > Repository:
> > >   rG LLVM Github Monorepo
> > >
> > > CHANGES SINCE LAST ACTION
> > >   https://reviews.llvm.org/D87921/new/
> > >
> > > https://reviews.llvm.org/D87921
> > >
>
>
>
> --
> 宋方睿
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87921: Fix -funique-internal-linkage-names to work with -O2 and new pass manager

2020-09-22 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Thanks for looking.  Indeed, it looks like an issue with the disk being full on 
the bot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87921

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


[clang] 079757b - [PowerPC] Implement Vector String Isolate Builtins in Clang/LLVM

2020-09-22 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-09-22T11:31:44-05:00
New Revision: 079757b551f3ab5218af7344a7ab3c79976ec478

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

LOG: [PowerPC] Implement Vector String Isolate Builtins in Clang/LLVM

This patch implements the vector string isolate (predicate and non-predicate
versions) builtins. The predicate builtins are custom selected within 
PPCISelDAGToDAG.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/p10-string-ops.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index dea547a6e121..b571454cfc7a 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -348,6 +348,16 @@ BUILTIN(__builtin_altivec_mtvsrqm, "V1ULLLiULLi", "")
 BUILTIN(__builtin_altivec_vpdepd, "V2ULLiV2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_vpextd, "V2ULLiV2ULLiV2ULLi", "")
 
+// P10 Vector String Isolate Built-ins.
+BUILTIN(__builtin_altivec_vstribr, "V16cV16c", "")
+BUILTIN(__builtin_altivec_vstribl, "V16cV16c", "")
+BUILTIN(__builtin_altivec_vstrihr, "V8sV8s", "")
+BUILTIN(__builtin_altivec_vstrihl, "V8sV8s", "")
+BUILTIN(__builtin_altivec_vstribr_p, "iiV16c", "")
+BUILTIN(__builtin_altivec_vstribl_p, "iiV16c", "")
+BUILTIN(__builtin_altivec_vstrihr_p, "iiV8s", "")
+BUILTIN(__builtin_altivec_vstrihl_p, "iiV8s", "")
+
 // P10 Vector Centrifuge built-in.
 BUILTIN(__builtin_altivec_vcfuged, "V2ULLiV2ULLiV2ULLi", "")
 

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 010a00e15b74..2c09e477bd3c 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17636,6 +17636,150 @@ vec_test_lsbb_all_zeros(vector unsigned char __a) {
 }
 #endif /* __VSX__ */
 
+/* vec_stril */
+
+static __inline__ vector unsigned char __ATTRS_o_ai
+vec_stril(vector unsigned char __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstribr((vector signed char)__a);
+#else
+  return __builtin_altivec_vstribl((vector signed char)__a);
+#endif
+}
+
+static __inline__ vector signed char __ATTRS_o_ai
+vec_stril(vector signed char __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstribr(__a);
+#else
+  return __builtin_altivec_vstribl(__a);
+#endif
+}
+
+static __inline__ vector unsigned short __ATTRS_o_ai
+vec_stril(vector unsigned short __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstrihr((vector signed short)__a);
+#else
+  return __builtin_altivec_vstrihl((vector signed short)__a);
+#endif
+}
+
+static __inline__ vector signed short __ATTRS_o_ai
+vec_stril(vector signed short __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstrihr(__a);
+#else
+  return __builtin_altivec_vstrihl(__a);
+#endif
+}
+
+/* vec_stril_p */
+
+static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned char __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstribr_p(__CR6_EQ, (vector signed char)__a);
+#else
+  return __builtin_altivec_vstribl_p(__CR6_EQ, (vector signed char)__a);
+#endif
+}
+
+static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed char __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstribr_p(__CR6_EQ, __a);
+#else
+  return __builtin_altivec_vstribl_p(__CR6_EQ, __a);
+#endif
+}
+
+static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned short __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a);
+#else
+  return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a);
+#endif
+}
+
+static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed short __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstrihr_p(__CR6_EQ, __a);
+#else
+  return __builtin_altivec_vstrihl_p(__CR6_EQ, __a);
+#endif
+}
+
+/* vec_strir */
+
+static __inline__ vector unsigned char __ATTRS_o_ai
+vec_strir(vector unsigned char __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstribl((vector signed char)__a);
+#else
+  return __builtin_altivec_vstribr((vector signed char)__a);
+#endif
+}
+
+static __inline__ vector signed char __ATTRS_o_ai
+vec_strir(vector signed char __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstribl(__a);
+#else
+  return __builtin_altivec_vstribr(__a);
+#endif
+}
+
+static __inline__ vector unsigned short __ATTRS_o_ai
+vec_strir(vector unsigned short __a) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vstrihl((vector signed short)__a);
+#else
+  

[clang] b314705 - [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM

2020-09-22 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-09-22T11:31:44-05:00
New Revision: b3147058dec7d42ae0284d6e6edf25eb762c8b89

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

LOG: [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in 
Clang/LLVM

This patch implements the 128-bit vector divide extended builtins in Clang/LLVM.
These builtins map to the vdivesq and vdiveuq instructions respectively.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/p10-vector-divide.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 777932a2e910..dea547a6e121 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -315,6 +315,8 @@ BUILTIN(__builtin_altivec_vdivesw, "V4SiV4SiV4Si", "")
 BUILTIN(__builtin_altivec_vdiveuw, "V4UiV4UiV4Ui", "")
 BUILTIN(__builtin_altivec_vdivesd, "V2LLiV2LLiV2LLi", "")
 BUILTIN(__builtin_altivec_vdiveud, "V2ULLiV2ULLiV2ULLi", "")
+BUILTIN(__builtin_altivec_vdivesq, "V1SLLLiV1SLLLiV1SLLLi", "")
+BUILTIN(__builtin_altivec_vdiveuq, "V1ULLLiV1ULLLiV1ULLLi", "")
 
 // P10 Vector Multiply High built-ins.
 BUILTIN(__builtin_altivec_vmulhsw, "V4SiV4SiV4Si", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 905d06bdae68..010a00e15b74 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -3366,6 +3366,16 @@ static __inline__ vector unsigned long long __ATTRS_o_ai
 vec_dive(vector unsigned long long __a, vector unsigned long long __b) {
   return __builtin_altivec_vdiveud(__a, __b);
 }
+
+static __inline__ vector unsigned __int128 __ATTRS_o_ai
+vec_dive(vector unsigned __int128 __a, vector unsigned __int128 __b) {
+  return __builtin_altivec_vdiveuq(__a, __b);
+}
+
+static __inline__ vector signed __int128 __ATTRS_o_ai
+vec_dive(vector signed __int128 __a, vector signed __int128 __b) {
+  return __builtin_altivec_vdivesq(__a, __b);
+}
 #endif
 
 #ifdef __POWER10_VECTOR__

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index 8557446de800..2f96cdfd9d68 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -106,6 +106,18 @@ vector unsigned long long test_vec_dive_ull(void) {
   return vec_dive(vulla, vullb);
 }
 
+vector unsigned __int128 test_vec_dive_u128(void) {
+  // CHECK: @llvm.ppc.altivec.vdiveuq(<1 x i128> %{{.+}}, <1 x i128> %{{.+}})
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_dive(vui128a, vui128b);
+}
+
+vector signed __int128 test_vec_dive_s128(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesq(<1 x i128> %{{.+}}, <1 x i128> %{{.+}})
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_dive(vsi128a, vsi128b);
+}
+
 vector signed int test_vec_mulh_si(void) {
   // CHECK: @llvm.ppc.altivec.vmulhsw(<4 x i32> %{{.+}}, <4 x i32> %{{.+}})
   // CHECK-NEXT: ret <4 x i32>

diff  --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index dc7fa581fd45..79cf3efbfac4 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1007,6 +1007,8 @@ def int_ppc_altivec_vdivesw : 
PowerPC_Vec_WWW_Intrinsic<"vdivesw">;
 def int_ppc_altivec_vdiveuw : PowerPC_Vec_WWW_Intrinsic<"vdiveuw">;
 def int_ppc_altivec_vdivesd : PowerPC_Vec_DDD_Intrinsic<"vdivesd">;
 def int_ppc_altivec_vdiveud : PowerPC_Vec_DDD_Intrinsic<"vdiveud">;
+def int_ppc_altivec_vdivesq : PowerPC_Vec_QQQ_Intrinsic<"vdivesq">;
+def int_ppc_altivec_vdiveuq : PowerPC_Vec_QQQ_Intrinsic<"vdiveuq">;
 
 // Vector Multiply High Intrinsics.
 def int_ppc_altivec_vmulhsw : PowerPC_Vec_WWW_Intrinsic<"vmulhsw">;

diff  --git a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td 
b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
index 351f08dadadb..114213321f35 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1427,9 +1427,13 @@ let Predicates = [IsISA3_1] in {
 "vdivuq $vD, $vA, $vB", IIC_VecGeneral,
 [(set v1i128:$vD, (udiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVESQ : VXForm_1<779, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- "vdivesq $vD, $vA, $vB", IIC_VecGeneral, []>;
+ "vdivesq $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v1i128:$vD, (int_ppc_altivec_vdivesq v1i128:$vA,
+  v1i128:$vB))]>;
   def VDIVEUQ : VXForm_1<523, (outs

[PATCH] D87729: [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM

2020-09-22 Thread Amy Kwan 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 rGb3147058dec7: [PowerPC] Implement the 128-bit Vector Divide 
Extended Builtins in Clang/LLVM (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87729

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-divide.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
@@ -9,6 +9,7 @@
 ; This test case aims to test the vector divide instructions on Power10.
 ; This includes the low order and extended versions of vector divide,
 ; that operate on signed and unsigned words and doublewords.
+; This also includes 128 bit vector divide instructions.
 
 define <2 x i64> @test_vdivud(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vdivud:
@@ -113,3 +114,25 @@
   %div = tail call <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64> %a, <2 x i64> %b)
   ret <2 x i64> %div
 }
+
+declare <1 x i128> @llvm.ppc.altivec.vdivesq(<1 x i128>, <1 x i128>) nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vdiveuq(<1 x i128>, <1 x i128>) nounwind readnone
+
+define <1 x i128> @test_vdivesq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vdivesq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vdivesq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vdivesq(<1 x i128> %x, <1 x i128> %y)
+  ret <1 x i128> %tmp
+}
+
+
+define <1 x i128> @test_vdiveuq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vdiveuq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vdiveuq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = call <1 x i128> @llvm.ppc.altivec.vdiveuq(<1 x i128> %x, <1 x i128> %y)
+  ret <1 x i128> %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1427,9 +1427,13 @@
 "vdivuq $vD, $vA, $vB", IIC_VecGeneral,
 [(set v1i128:$vD, (udiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVESQ : VXForm_1<779, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- "vdivesq $vD, $vA, $vB", IIC_VecGeneral, []>;
+ "vdivesq $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v1i128:$vD, (int_ppc_altivec_vdivesq v1i128:$vA,
+			   v1i128:$vB))]>;
   def VDIVEUQ : VXForm_1<523, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- "vdiveuq $vD, $vA, $vB", IIC_VecGeneral, []>;
+ "vdiveuq $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v1i128:$vD, (int_ppc_altivec_vdiveuq v1i128:$vA,
+			   v1i128:$vB))]>;
   def VCMPEQUQ : VCMP <455, "vcmpequq $vD, $vA, $vB" , v1i128>;
   def VCMPGTSQ : VCMP <903, "vcmpgtsq $vD, $vA, $vB" , v1i128>;
   def VCMPGTUQ : VCMP <647, "vcmpgtuq $vD, $vA, $vB" , v1i128>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1007,6 +1007,8 @@
 def int_ppc_altivec_vdiveuw : PowerPC_Vec_WWW_Intrinsic<"vdiveuw">;
 def int_ppc_altivec_vdivesd : PowerPC_Vec_DDD_Intrinsic<"vdivesd">;
 def int_ppc_altivec_vdiveud : PowerPC_Vec_DDD_Intrinsic<"vdiveud">;
+def int_ppc_altivec_vdivesq : PowerPC_Vec_QQQ_Intrinsic<"vdivesq">;
+def int_ppc_altivec_vdiveuq : PowerPC_Vec_QQQ_Intrinsic<"vdiveuq">;
 
 // Vector Multiply High Intrinsics.
 def int_ppc_altivec_vmulhsw : PowerPC_Vec_WWW_Intrinsic<"vmulhsw">;
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -106,6 +106,18 @@
   return vec_dive(vulla, vullb);
 }
 
+vector unsigned __int128 test_vec_dive_u128(void) {
+  // CHECK: @llvm.ppc.altivec.vdiveuq(<1 x i128> %{{.+}}, <1 x i128> %{{.+}})
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_dive(vui128a, vui128b);
+}
+
+vector signed __int128 test_vec_dive_s128(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesq(<1 x i128> %{{.+}}, <1 x i128> %{{.+}})
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_dive(vsi128a, vsi128b);
+}
+
 vector signed int test_vec_mulh_si(void) {
   // CHECK: @llvm.ppc.altivec.vmulhsw(<4 x i32> %{{.+}}, <4 x i32> %{{.+}})
   // CHECK-NEXT: ret <4 x i32>
Index: clang/lib/Headers/altivec.h
===

[PATCH] D87671: [PowerPC] Implement Vector String Isolate Builtins in Clang/LLVM

2020-09-22 Thread Amy Kwan 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 rG079757b551f3: [PowerPC] Implement Vector String Isolate 
Builtins in Clang/LLVM (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87671

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-string-ops.ll

Index: llvm/test/CodeGen/PowerPC/p10-string-ops.ll
===
--- llvm/test/CodeGen/PowerPC/p10-string-ops.ll
+++ llvm/test/CodeGen/PowerPC/p10-string-ops.ll
@@ -2,6 +2,9 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
 ; RUN:   FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
 
 ; These test cases aim to test the vector string isolate builtins on Power10.
 
@@ -27,3 +30,97 @@
   %tmp = tail call <16 x i8> @llvm.ppc.altivec.vclrrb(<16 x i8> %a, i32 %n)
   ret <16 x i8> %tmp
 }
+
+declare <16 x i8> @llvm.ppc.altivec.vstribr(<16 x i8>)
+declare <16 x i8> @llvm.ppc.altivec.vstribl(<16 x i8>)
+declare <8 x i16> @llvm.ppc.altivec.vstrihr(<8 x i16>)
+declare <8 x i16> @llvm.ppc.altivec.vstrihl(<8 x i16>)
+
+declare i32 @llvm.ppc.altivec.vstribr.p(i32, <16 x i8>)
+declare i32 @llvm.ppc.altivec.vstribl.p(i32, <16 x i8>)
+declare i32 @llvm.ppc.altivec.vstrihr.p(i32, <8 x i16>)
+declare i32 @llvm.ppc.altivec.vstrihl.p(i32, <8 x i16>)
+
+define <16 x i8> @test_vstribr(<16 x i8> %a) {
+; CHECK-LABEL: test_vstribr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstribr v2, v2
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <16 x i8> @llvm.ppc.altivec.vstribr(<16 x i8> %a)
+  ret <16 x i8> %tmp
+}
+
+define <16 x i8> @test_vstribl(<16 x i8> %a) {
+; CHECK-LABEL: test_vstribl:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstribl v2, v2
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <16 x i8> @llvm.ppc.altivec.vstribl(<16 x i8>%a)
+  ret <16 x i8> %tmp
+}
+
+define <8 x i16> @test_vstrihr(<8 x i16> %a) {
+; CHECK-LABEL: test_vstrihr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstrihr v2, v2
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <8 x i16> @llvm.ppc.altivec.vstrihr(<8 x i16> %a)
+  ret <8 x i16> %tmp
+}
+
+define <8 x i16> @test_vstrihl(<8 x i16> %a) {
+; CHECK-LABEL: test_vstrihl:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstrihl v2, v2
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <8 x i16> @llvm.ppc.altivec.vstrihl(<8 x i16> %a)
+  ret <8 x i16> %tmp
+}
+
+define i32 @test_vstribr_p(<16 x i8> %a) {
+; CHECK-LABEL: test_vstribr_p:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstribr. v2, v2
+; CHECK-NEXT:setbc r3, 4*cr6+eq
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i32 @llvm.ppc.altivec.vstribr.p(i32 1, <16 x i8> %a)
+  ret i32 %tmp
+}
+
+define i32 @test_vstribl_p(<16 x i8> %a) {
+; CHECK-LABEL: test_vstribl_p:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstribl. v2, v2
+; CHECK-NEXT:setbc r3, 4*cr6+eq
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i32 @llvm.ppc.altivec.vstribl.p(i32 1, <16 x i8> %a)
+  ret i32 %tmp
+}
+
+define i32 @test_vstrihr_p(<8 x i16> %a) {
+; CHECK-LABEL: test_vstrihr_p:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstrihr. v2, v2
+; CHECK-NEXT:setbc r3, 4*cr6+eq
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i32 @llvm.ppc.altivec.vstrihr.p(i32 1, <8 x i16> %a)
+  ret i32 %tmp
+}
+
+define i32 @test_vstrihl_p(<8 x i16> %a) {
+; CHECK-LABEL: test_vstrihl_p:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vstrihl. v2, v2
+; CHECK-NEXT:setbc r3, 4*cr6+eq
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i32 @llvm.ppc.altivec.vstrihl.p(i32 1, <8 x i16> %a)
+  ret i32 %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1020,13 +1020,21 @@
   v16i8:$VRB, 
   i32:$SH))]>;
   defm VSTRIBR : VXForm_VTB5_RCr<13, 1, (outs vrrc:$vT), (ins vrrc:$vB),
- "vstribr", "$vT, $vB", IIC_VecGeneral, []>;
+ "vstribr", "$vT, $vB", IIC_VecGeneral,
+ [(set v16i8:$vT,
+   (int_ppc_altivec_vstribr v16i8:$vB))]>;
   defm VSTRIBL : VXForm_VTB5_RCr<13, 0, (outs v

[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include 
@@ -294,46 +295,107 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
+syntax::List::ElementAndDelimiter
+syntax::List::getWithDelimiter(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  if (!Next)
+return {Element, nullptr};
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return {Element, nullptr};
+  case syntax::NodeRole::ListDelimiter:
+return {Element, cast(Next)};
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
+  }
+}
 
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterDelimiter(syntax::Leaf *Delimiter) {
+  assert(Delimiter && Delimiter->getRole() == syntax::NodeRole::ListDelimiter);
+  auto *Next = Delimiter->getNextSibling();
+  if (!Next) {
+switch (getTerminationKind()) {
+// List is separated and ends with delimiter
+// => missing last ElementAndDelimiter.
+case syntax::List::TerminationKind::Separated:
+  return llvm::Optional>(
+  {nullptr, nullptr});
+case syntax::List::TerminationKind::Terminated:
+case syntax::List::TerminationKind::MaybeTerminated:
+  return None;
 }
   }
-
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // Consecutive Delimiters => missing Element
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(Next)});
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
-}
-break;
+}
+
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterElement(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  // a  b, x => End of list, this was the last ElementAndDelimiter.
+  if (!Next)
+return None;
+
+  switch (Next->getRole()) {
+  // x  b, c => next ElementAndDelimiter starts with 'b'.
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // a  x, c => next ElementAndDelimiter starts after ','.
+  case syntax::NodeRole::ListDelimiter:
+return getElementAndDelimiterAfterDelimiter(cast(Next));
+
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
+}
+
+llvm::Optional>
+syntax::List::getNext(syntax::List::ElementAndDelimiter &ED) {
+  if (auto *Delimiter = ED.delimiter)
+return getElementAndDelimiterAfterDelimiter(Delimiter);
+  if (auto *Element = ED.element)
+return getElementAndDelimiterAfterElement(Element);
+  return None;
+}
+
+llvm::Optional>
+syntax::List::getFirst() {
+  auto *First = this->getFirstChild();
+  if (!First)
+return None;
+  switch (First->getRole()) {
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(First);
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(First)});
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as childr

[PATCH] D88105: [NFC] [PPC] Add PowerPC expected IR tests for C99 complex

2020-09-22 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm created this revision.
cebowleratibm added reviewers: daltenty, ZarkoCA, sfertile.
Herald added subscribers: cfe-commits, shchenz, nemanjai.
Herald added a project: clang.
cebowleratibm requested review of this revision.

Adding this test so that I can extend it in a follow on patch with expected IR 
for AIX when I implement complex handling in AIXABIInfo.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88105

Files:
  clang/test/CodeGen/powerpc-c99complex.c


Index: clang/test/CodeGen/powerpc-c99complex.c
===
--- /dev/null
+++ clang/test/CodeGen/powerpc-c99complex.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefix=PPC32LNX
+
+_Complex float foo1(_Complex float x) {
+  return x;
+// PPC64LNX-LABEL:   define { float, float } @foo1(float %x.{{.*}}, float 
%x.{{.*}}) #0 {
+// PPC64LNX: ret { float, float }
+
+// PPC32LNX-LABEL:  define void @foo1({ float, float }* noalias sret align 4 
%agg.result, { float, float }* byval({ float, float }) align 4 %x) #0 {
+// PPC32LNX:[[RETREAL:%.*]] = getelementptr inbounds { float, float }, 
{ float, float }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:   [[RETIMAG:%.*]] = getelementptr inbounds { float, float }, 
{ float, float }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:   store float %{{.*}}, float* [[RETREAL]], align 4
+// PPC32LNX-NEXT:   store float %{{.*}}, float* [[RETIMAG]], align 4
+}
+
+_Complex double foo2(_Complex double x) {
+  return x;
+// PPC64LNX-LABEL:   define { double, double } @foo2(double %x.{{.*}}, 
double %x.{{.*}}) #0 {
+// PPC64LNX: ret { double, double }
+
+// PPC32LNX-LABEL:  define void @foo2({ double, double }* noalias sret align 8 
%agg.result, { double, double }* byval({ double, double }) align 8 %x) #0 {
+// PPC32LNX:[[RETREAL:%.*]] = getelementptr inbounds { double, double 
}, { double, double }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:   [[RETIMAG:%.*]] = getelementptr inbounds { double, double 
}, { double, double }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:   store double %{{.*}}, double* [[RETREAL]], align 8
+// PPC32LNX-NEXT:   store double %{{.*}}, double* [[RETIMAG]], align 8
+}
+
+_Complex long double foo3(_Complex long double x) {
+  return x;
+// PPC64LNX-LDBL128-LABEL:define { ppc_fp128, ppc_fp128 } @foo3(ppc_fp128 
%x.{{.*}}, ppc_fp128 %x.{{.*}}) #0 {
+// PPC64LNX-LDBL128:  ret { ppc_fp128, ppc_fp128 }
+
+// PPC32LNX-LABEL: define void @foo3({ ppc_fp128, ppc_fp128 }* noalias sret 
align 16 %agg.result, { ppc_fp128, ppc_fp128 }* byval({ ppc_fp128, ppc_fp128 }) 
align 16 %x) #0 {
+// PPC32LNX:   [[RETREAL:%.*]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:  [[RETIMAG:%.*]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:  store ppc_fp128 %{{.*}}, ppc_fp128* [[RETREAL]], align 16
+// PPC32LNX-NEXT:  store ppc_fp128 %{{.*}}, ppc_fp128* [[RETIMAG]], align 16
+}


Index: clang/test/CodeGen/powerpc-c99complex.c
===
--- /dev/null
+++ clang/test/CodeGen/powerpc-c99complex.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=PPC32LNX
+
+_Complex float foo1(_Complex float x) {
+  return x;
+// PPC64LNX-LABEL:   define { float, float } @foo1(float %x.{{.*}}, float %x.{{.*}}) #0 {
+// PPC64LNX: ret { float, float }
+
+// PPC32LNX-LABEL:  define void @foo1({ float, float }* noalias sret align 4 %agg.result, { float, float }* byval({ float, float }) align 4 %x) #0 {
+// PPC32LNX:[[RETREAL:%.*]] = getelementptr inbounds { float, float }, { float, float }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:   [[RETIMAG:%.*]] = getelementptr inbounds { float, float }, { float, float }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:   store float %{{.*}}, float* [[RETREAL]], align 4
+// PPC32LNX-NEXT:   store float %{{.*}}, float* [[RETIMAG]], align 4
+}
+
+_Complex double foo2(_Complex double x) {
+  return x;
+// PPC64LNX-LABEL:   define { double, double } @foo2(double %x.{{.*}}, double %x.{{.*}}) #0 {
+// PPC64LNX: ret { double, double }
+
+// PPC32LNX-LABEL:  define void @foo2({ double, double }* noalias sret align 8 %agg.result, { double, double }* byval({ double, double }) align 8 %x) #0 {
+// PPC32LNX:[[RETREAL:%.*]] = getelementptr inbounds { double, double }, { double, double }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:   [[RETIMAG:%.*]] = getelementptr inbounds { d

[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D54222#2281642 , 
@jranieri-grammatech wrote:

> @JonasToth It looks like there are some outstanding review comments that need 
> to be addressed. I've gotten some time allocated to work on this next week.

Great!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54222

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


[PATCH] D87588: [ASTMatchers] extract public matchers from const-analysis into own patch

2020-09-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D87588#2278948 , @ro wrote:

> As described in D87825 , this patch broke 
> `Debug` builds on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

Thank you for reporting this issue. I it is fixed now: 
https://reviews.llvm.org/rGf0546173fa4bdde03ecb21a174fcaa8a6490adbd (thanks for 
that!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87588

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


[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-09-22 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp:330-336
+SVal getReturnIterator(const CallEvent &Call) {
+  Optional RetValUnderConstr = Call.getReturnValueUnderConstruction();
+  if (RetValUnderConstr.hasValue())
+return *RetValUnderConstr;
+
+  return Call.getReturnValue();
+}

NoQ wrote:
> NoQ wrote:
> > NoQ wrote:
> > > I still believe you have not addressed the problem while moving the 
> > > functions from D81718 to this patch. The caller of this function has no 
> > > way of knowing whether the return value is the prvalue of the iterator or 
> > > the glvalue of the iterator.
> > > 
> > > Looks like most callers are safe because they expect the object of 
> > > interest to also be already tracked. But it's quite possible that both 
> > > are tracked, say:
> > > 
> > > ```lang=c++
> > >   Container1 container1 = ...;
> > >   Container2 container2 = { container1.begin() };
> > >   container2.begin(); // ???
> > > ```
> > > 
> > > Suppose `Container1::iterator` is implemented as an object and 
> > > `Container2::iterator` is implemented as a pointer. In this case 
> > > `getIteratorPosition(getReturnIterator())` would yield the position of 
> > > `container1.begin()` whereas the correct answer is the position of 
> > > `container2.begin()`.
> > > 
> > > This problem may seem artificial but it is trivial to avoid if you simply 
> > > stop defending your convoluted solution of looking at value classes 
> > > instead of AST types.
> > Ugh, the problem is much worse. D82185 is entirely broken for the exact 
> > reason i described above and you only didn't notice it because you wrote 
> > almost no tests.
> > 
> > Consider the test you've added in D82185:
> > 
> > ```lang=c++
> > void begin_ptr_iterator(const cont_with_ptr_iterator &c) {
> >   auto i = c.begin();
> > 
> >   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &c); // 
> > expected-warning{{TRUE}}
> > }
> > ```
> > 
> > It breaks very easily if you modify it slightly:
> > ```lang=c++
> > void begin_ptr_iterator(const cont_with_ptr_iterator &c) {
> >   auto i = c.begin();
> >   ++i; // <==
> > 
> >   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &c); // Says 
> > FALSE!
> > }
> > ```
> > The iterator obviously still points to the same container, so why does the 
> > test fail? Because you're tracking the wrong iterator: you treated your 
> > `&SymRegion{conj_$3}` as a glvalue whereas you should have treated it as a 
> > prvalue. In other words, your checker thinks that `&SymRegion{conj_$3}` is 
> > the location of an iterator object rather than the iterator itself, and 
> > after you increment the pointer it thinks that it's a completely unrelated 
> > iterator.
> > 
> > There's a separate concern about why does it say `FALSE` (should be 
> > `UNKNOWN`) but you get the point.
> The better way to test D82185 would be to make all existing tests with 
> iterator objects pass with iterator pointers as well. Like, make existing 
> container mocks use either iterator objects or iterator pointers depending on 
> a macro and make two run-lines in each test file, one with `-D` and one 
> without it. Most of the old tests should have worked out of the box if you 
> did it right; the few that don't pass would be hidden under #ifdef for future 
> investigation.
Thank you for your review and especially for this tip! It is really a good 
idea. I changed it now and it indeed shows the problem you reported. It seems 
that my checker mixes up the region of the pointer-typed variable (`&i` and 
`&j`) with the region they point to (`&SymRegion{reg_$1 & v>}._start>}` for `i` before the 
increment and `&Element{SymRegion{reg_$1 & v>}._start>},1 S64b,int}` for both `i` and `j` after the 
increment).

What I fail to see and I am asking you help in it is that the relation between 
this problem and the `getReturnIterator()` function. This function retrieves 
the object from the construction context if there is one, but for plain 
pointers there is never one. Thus this function is always 
`Call.getReturnValue()` like before this patch.


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

https://reviews.llvm.org/D77229

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


[PATCH] D87839: [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3c08bfdfd62: [SyntaxTree] Test the List API (authored by 
eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87839

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "TreeTestBase.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "llvm/ADT/STLExtras.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -122,4 +124,231 @@
   }
 }
 
+class ListTest : public SyntaxTreeTest {
+private:
+  std::string dumpQuotedTokensOrNull(const Node *N) {
+return N ? "'" +
+   StringRef(N->dumpTokens(Arena->getSourceManager()))
+   .trim()
+   .str() +
+   "'"
+ : "null";
+  }
+
+protected:
+  std::string
+  dumpElementsAndDelimiters(ArrayRef> EDs) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(
+EDs, OS, [&OS, this](const List::ElementAndDelimiter &ED) {
+  OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
+ << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+});
+
+OS << "]";
+
+return OS.str();
+  }
+
+  std::string dumpNodes(ArrayRef Nodes) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(Nodes, OS, [&OS, this](const Node *N) {
+  OS << dumpQuotedTokensOrNull(N);
+});
+
+OS << "]";
+
+return OS.str();
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(TreeTests, ListTest,
+::testing::ValuesIn(allTestClangConfigs()), );
+
+/// "a, b, c"  <=> [("a", ","), ("b", ","), ("c", null)]
+TEST_P(ListTest, List_Separated_WellFormed) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
+}
+
+/// "a,  , c"  <=> [("a", ","), (null, ","), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingElement) {
+  buildTree("", GetParam());
+
+  // "a,  , c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), (null, ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', null, 'c']");
+}
+
+/// "a, b  c"  <=> [("a", ","), ("b", null), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingDelimiter) {
+  buildTree("", GetParam());
+
+  // "a, b  c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', null), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
+}
+
+/// "a, b,"<=> [("a", ","), ("b", ","), (null, null)]
+TEST_P(ListTest, List_Separated_MissingLastElement) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {cre

[clang] c3c08bf - [SyntaxTree] Test the List API

2020-09-22 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-09-22T17:07:41Z
New Revision: c3c08bfdfd6244e0429753ee56df39c90187d772

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

LOG: [SyntaxTree] Test the List API

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Tree.h
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Tree.h 
b/clang/include/clang/Tooling/Syntax/Tree.h
index a544fc1827b7..5840a86199eb 100644
--- a/clang/include/clang/Tooling/Syntax/Tree.h
+++ b/clang/include/clang/Tooling/Syntax/Tree.h
@@ -218,12 +218,16 @@ class List : public Tree {
   /// and delimiters are represented as null pointers.
   ///
   /// For example, in a separated list:
-  /// "a, b, c" <=> [("a", ","), ("b", ","), ("c", null)]
-  /// "a, , c" <=> [("a", ","), (null, ","), ("c", ",)]
-  /// "a, b," <=> [("a", ","), ("b", ","), (null, null)]
+  /// "a, b, c"  <=> [("a" , ","), ("b" , "," ), ("c" , null)]
+  /// "a,  , c"  <=> [("a" , ","), (null, "," ), ("c" , null)]
+  /// "a, b  c"  <=> [("a" , ","), ("b" , null), ("c" , null)]
+  /// "a, b,"<=> [("a" , ","), ("b" , "," ), (null, null)]
   ///
   /// In a terminated or maybe-terminated list:
-  /// "a, b," <=> [("a", ","), ("b", ",")]
+  /// "a; b; c;" <=> [("a" , ";"), ("b" , ";" ), ("c" , ";" )]
+  /// "a;  ; c;" <=> [("a" , ";"), (null, ";" ), ("c" , ";" )]
+  /// "a; b  c;" <=> [("a" , ";"), ("b" , null), ("c" , ";" )]
+  /// "a; b; c"  <=> [("a" , ";"), ("b" , ";" ), ("c" , null)]
   std::vector> getElementsAsNodesAndDelimiters();
 
   /// Returns the elements of the list. Missing elements are represented

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 6e777b353b04..fba3164e5966 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "TreeTestBase.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "llvm/ADT/STLExtras.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -122,4 +124,231 @@ TEST_P(TreeTest, LastLeaf) {
   }
 }
 
+class ListTest : public SyntaxTreeTest {
+private:
+  std::string dumpQuotedTokensOrNull(const Node *N) {
+return N ? "'" +
+   StringRef(N->dumpTokens(Arena->getSourceManager()))
+   .trim()
+   .str() +
+   "'"
+ : "null";
+  }
+
+protected:
+  std::string
+  dumpElementsAndDelimiters(ArrayRef> EDs) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(
+EDs, OS, [&OS, this](const List::ElementAndDelimiter &ED) {
+  OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
+ << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+});
+
+OS << "]";
+
+return OS.str();
+  }
+
+  std::string dumpNodes(ArrayRef Nodes) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+
+OS << "[";
+
+llvm::interleaveComma(Nodes, OS, [&OS, this](const Node *N) {
+  OS << dumpQuotedTokensOrNull(N);
+});
+
+OS << "]";
+
+return OS.str();
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(TreeTests, ListTest,
+::testing::ValuesIn(allTestClangConfigs()), );
+
+/// "a, b, c"  <=> [("a", ","), ("b", ","), ("c", null)]
+TEST_P(ListTest, List_Separated_WellFormed) {
+  buildTree("", GetParam());
+
+  // "a, b, c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::CallArguments));
+
+  EXPECT_EQ(dumpElementsAndDelimiters(List->getElementsAsNodesAndDelimiters()),
+"[('a', ','), ('b', ','), ('c', null)]");
+  EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
+}
+
+/// "a,  , c"  <=> [("a", ","), (null, ","), ("c", null)]
+TEST_P(ListTest, List_Separated_MissingElement) {
+  buildTree("", GetParam());
+
+  // "a,  , c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::comma), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::

[PATCH] D87808: [DebugInfo] Fix bug in constructor homing where it would use ctor homing when a class only has copy/move constructors

2020-09-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D87808#2286664 , @rsmith wrote:

> In D87808#2280197 , @dblaikie wrote:
>
>> @rsmith What's the deal with these anonymous structs/unions? Why do they 
>> have copy/move constructors (are those technically called from the enclosing 
>> class's copy/move constructors?) but no default constructor to be called 
>> from the other ctors of the enclosing class?
>
> Let's use the class `G` in the example. `G::G` directly initializes the field 
> `g_`, so it can't call any kind of constructor for the anonymous struct 
> member. Instead, anonymous structs and unions are "expanded" when building 
> the constructor initializer lists for all cases other than a copy or move 
> constructor (no initialization action is taken for union members by default, 
> though -- not unless they have a default member initializer or an explicit 
> mem-initializer). So the default constructor of an anonymous struct or union 
> is never really used for anything[*].
>
> But now consider the copy or move constructor for a type like this:
>
>   struct X {
> Y y;
> union { ... };
>   };
>
> That copy or move constructor needs to build a member initializer list that 
> (a) calls the `Y` copy/move constructor for `y`, and (b) performs a bytewise 
> copy for the anonymous union. We can't express this in the "expanded" form, 
> because we wouldn't know which union member to initialize.
>
> So for the non-copy/move case, we build `CXXCtorInitializers` for expanded 
> members, and in the copy/move case, we build `CXXCtorInitializers` calling 
> the copy/move constructors for the anonymous structs/unions themselves.

OK - I /mostly/ follow all that.

> [*]: It's not entirely true that the default constructor is never used for 
> anything. When we look up special members for the anonymous struct / union 
> (looking for the copy or move constructor) we can trigger the implicit 
> declaration of the default constructor. And it's actually even possible to 
> *call* that default constructor, if you're tricksy enough: 
> https://godbolt.org/z/Tq56bz

Good to know! Makes things more interesting. (any case where something could 
get constructed without calling the constructor is something this feature needs 
to be aware of/careful about)

> In D87808#2282223 , @rnk wrote:
>
>> Maybe the issue is that this code is running into the lazy implicit special 
>> member declaration optimization. Maybe the class in question has an 
>> implicit, trivial, default constructor, but we there is no 
>> CXXConstructorDecl present in the ctors list for the loop to find.
>
> That seems very likely. The existing check:
>
>   if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
> return false;
>
> is skating on thin ice in this regard: a class with an implicit default 
> constructor might or might not have had that default constructor implicitly 
> declared.

Yeah, that's subtle & probably best not to rely on being able to gloss over 
that case.

> But I think this code should give the same outcome either way, because a 
> class with any constructor other than a default/copy/move constructor must 
> have a user-declared constructor of some kind, and so will never have an 
> implicit default constructor.

Hmm, trying to parse this. So if we're in the subtle case of having an implicit 
default constructor (and no other (necessarily user-declared, as you say) 
constructors) - if it's not been declared, then this function will return 
false. If it has been declared, it'll return false... hmm, nope, then it'll 
return true.

It sounds like there's an assumption related to "a class with any constructor 
other than a default/copy/move" - a default constructor would be nice to use as 
a constructor home. (certainly a user-defined one, but even an implicit one - 
so long as it gets IRGen'd when called, and not skipped (as in the anonymous 
struct/class case) or otherwise frontend-optimized away)

> (Inherited constructors introduce some complications here, but we don't do 
> lazy constructor declaration for classes with inherited constructors, so I 
> think that's OK too.)

Ah, handy!




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:2292-2300
+  bool hasCtor = false;
+  for (const auto *Ctor : RD->ctors()) {
 if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
   return false;
+if (!Ctor->isCopyOrMoveConstructor())
+  hasCtor = true;
+  }

rsmith wrote:
> This looks pretty similar to:
> 
> ```
> return RD->hasUserDeclaredConstructor() && 
> !RD->hasTrivialDefaultConstructor();
> ```
> 
> (other than its treatment of user-declared copy or move constructors), but I 
> have to admit I don't really understand what the "at least one constructor 
> and no trivial or constexpr constructors" rule aims to achieve, so it's hard 
> to know if this is the right interpretati

[PATCH] D87989: [Flang][Driver] Add InputOutputTest frontend action with new -test-IO flag

2020-09-22 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@CarolineConcatto , thank you for this patch! It implements some really 
important functionality and IMO the overall structure is solid.

I've left quite a few comments, but mostly nits and suggestions for more 
detailed comments. There's a few, but it's a relatively big patch :)

One suggestion - IMO this patch first and foremost creates the scaffolding for 
writing frontend actions. The `test-IO` flag is only really there to facilitate 
testing. Perhaps it's worth updating the commit message to reflect that? I 
would definitely like to see a bit more emphasis on the fact that this patch 
introduces the necessary APIs for reading and writing files. For me that's the 
key functionality here.

Also, I tested this patch and currently `-test-IO` is listed together with 
other `clang` options (check `clang --help-hidden`). Please, could you fix that?




Comment at: clang/include/clang/Driver/Options.td:3514
+//===--===//
+def TEST_IO : Flag<["-"], "test-IO">, Flags<[HelpHidden, FlangOption, 
FC1Option]>,Group,
+HelpText<"Only run the InputOutputTest action">;

I think that `test-io` would be more consistent with other options in the file.



Comment at: clang/include/clang/Driver/Options.td:3515
+def TEST_IO : Flag<["-"], "test-IO">, Flags<[HelpHidden, FlangOption, 
FC1Option]>,Group,
+HelpText<"Only run the InputOutputTest action">;
+

I would help to make this a bit more specific. What about: `Run the 
InputOuputTest action. Use for development and testing only`?



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:39-40
   } else if (isa(JA) || isa(JA)) {
+CmdArgs.push_back("-triple");
+CmdArgs.push_back(Args.MakeArgString(TripleStr));
 if (JA.getType() == types::TY_Nothing) {

It would be helpful to have a note that explains this change. Perhaps something 
like this:

```
// TODO: Note that eventually all actions will require a triple (e.g. `-triple 
aarch64-unknown-linux-gnu`). However, `-triple` is currently not supported by 
`flang-new -fc1`, so we only add it to actions that we don't support/execute 
just yet. 
```

Probably above line 33. What do you think?



Comment at: clang/lib/Driver/Types.cpp:329
   if (Driver.CCCIsCPP() || DAL.getLastArg(options::OPT_E) ||
+  DAL.getLastArg(options::OPT_TEST_IO) ||
   DAL.getLastArg(options::OPT__SLASH_EP) ||

This should probably be the last option here (as it's the latest to be added). 
Also, worth adding a comment about, e.g.:
```
-test-io is used by Flang to run InputOutputTest action
```



Comment at: flang/include/flang/Frontend/CompilerInstance.h:26
 
+  /// The Fortran  file  manager.
+  std::shared_ptr allSources_;

[nit] Forrtran or Flang?



Comment at: flang/include/flang/Frontend/CompilerInstance.h:33
+  /// Holds the name of the output file.
+  /// Helps to go through the list when working with the outputFiles_
+  struct OutputFile {

[nit] 'the outputFiles_' -> 'outputFiles_'



Comment at: flang/include/flang/Frontend/CompilerInstance.h:40-42
+  /// If the output doesn't support seeking (terminal, pipe), we switch
+  /// the stream to a buffer_ostream. These are the buffer and the original
+  /// stream.

[nit] 
```
/// If the output doesn't support seeking (terminal, pipe), we switch
/// the stream to a buffer_ostream. These are the buffer and the original
/// stream.
```
vvv
```
/// Output stream that doesn't support seeking (e.g. terminal, pipe). This 
stream is normally wrapped
/// in buffer_ostream before being passed to users (e.g. via CreateOutputFile).
```



Comment at: flang/include/flang/Frontend/CompilerInstance.h:48
+
+  /// Force an output buffer.
+  std::unique_ptr outputStream_;

I think that:
```
This field holds the output stream provided by the user. Normally, users of 
CompilerInstance will call CreateOutputFile to obtain/create an output stream. 
If they want to provide their own output stream, this field will facilitate 
this. It is optional and will normally be just a nullptr.
```
would be a bit more informative :)



Comment at: flang/include/flang/Frontend/CompilerInstance.h:65
 
+  /// setInvocation - Replace the current invocation.
+  void SetInvocation(std::shared_ptr value);

[nit] Delete



Comment at: flang/include/flang/Frontend/CompilerInstance.h:68
+
+  /// Return the current source manager.
+  Fortran::parser::AllSources &GetAllSources() const { return *allSources_; }

[nit] There is no source manager here.

It's probably worth decorating everything related to `AllSources` with:
```
/// }
/// @name File manager
/// {
```



Comment at: flang/include/flang/Frontend/

[PATCH] D86964: [ASTMatchers] Avoid recursion in ancestor matching to save stack space.

2020-09-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:705
+  // Unlike matchesAnyAncestorOf there's no memoization: it doesn't save much.
+  bool matchesParentOf(const DynTypedNode &Node, const DynTypedMatcher 
&Matcher,
+   BoundNodesTreeBuilder *Builder) {

hokein wrote:
> this API makes sense, I'm wondering whether we should do it further (more 
> aligned with `matchesChildOf` pattern):
> 
> - make `matchesParentOf` public;
> - introduce a new `matchesParentOf` interface in ASTMatcherFinder, which 
> calls this function here;
> - then we can remove the special parent case in 
> `MatchASTVisitor::matchesAncestorOf`, and the `AncestorMatchMode` enum is 
> also not needed anymore;
> 
> I'm also ok with the current way.
I'm happy with that change, but I'd rather not bundle it into this one.
The goal here is to fix weird production characteristics (rather than APIs or 
algorithm output) and those are slippery, so let's change one thing at a time.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:740
+// When returning, update the memoization cache.
+auto Finish = [&](bool Result) {
+  for (const auto &Key : Keys) {

hokein wrote:
> maybe
> 
> Finish => Memorize
> Result => IsMatched
> Finish => Memorize

Memoize and Memorize are different words, and memoize doesn't act on results 
but rather on functions. So I think this rename is confusing.

> Result => IsMatched
Done



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86964

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


[PATCH] D88105: [NFC] [PPC] Add PowerPC expected IR tests for C99 complex

2020-09-22 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/test/CodeGen/powerpc-c99complex.c:1
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefix=PPC32LNX

Can you add ppc64le as well? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88105

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


[clang] 6257618 - [ASTMatchers] Avoid recursion in ancestor matching to save stack space.

2020-09-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-09-22T19:43:41+02:00
New Revision: 625761825620f19a44c7a1482ce05d678a1b0deb

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

LOG: [ASTMatchers] Avoid recursion in ancestor matching to save stack space.

A recent change increased the stack size of memoizedMatchesAncestorOfRecursively
leading to stack overflows on real code involving large fold expressions.
It's not totally unreasonable to choke on very deep ASTs, but as common
infrastructure it's be nice if ASTMatchFinder is more robust.
(It already uses data recursion for the regular "downward" traversal.)

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

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index dc937dde88e3..b9b38923495a 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -544,8 +544,9 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
 // don't invalidate any iterators.
 if (ResultCache.size() > MaxMemoizationEntries)
   ResultCache.clear();
-return memoizedMatchesAncestorOfRecursively(Node, Ctx, Matcher, Builder,
-MatchMode);
+if (MatchMode == AncestorMatchMode::AMM_ParentOnly)
+  return matchesParentOf(Node, Matcher, Builder);
+return matchesAnyAncestorOf(Node, Ctx, Matcher, Builder);
   }
 
   // Matches all registered matchers on the given node and calls the
@@ -699,9 +700,23 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
   void matchDispatch(const void *) { /* Do nothing. */ }
   /// @}
 
+  // Returns whether a direct parent of \p Node matches \p Matcher.
+  // Unlike matchesAnyAncestorOf there's no memoization: it doesn't save much.
+  bool matchesParentOf(const DynTypedNode &Node, const DynTypedMatcher 
&Matcher,
+   BoundNodesTreeBuilder *Builder) {
+for (const auto &Parent : ActiveASTContext->getParents(Node)) {
+  BoundNodesTreeBuilder BuilderCopy = *Builder;
+  if (Matcher.matches(Parent, this, &BuilderCopy)) {
+*Builder = std::move(BuilderCopy);
+return true;
+  }
+}
+return false;
+  }
+
   // Returns whether an ancestor of \p Node matches \p Matcher.
   //
-  // The order of matching ((which can lead to 
diff erent nodes being bound in
+  // The order of matching (which can lead to 
diff erent nodes being bound in
   // case there are multiple matches) is breadth first search.
   //
   // To allow memoization in the very common case of having deeply nested
@@ -712,51 +727,64 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
   // Once there are multiple parents, the breadth first search order does not
   // allow simple memoization on the ancestors. Thus, we only memoize as long
   // as there is a single parent.
-  bool memoizedMatchesAncestorOfRecursively(const DynTypedNode &Node,
-ASTContext &Ctx,
-const DynTypedMatcher &Matcher,
-BoundNodesTreeBuilder *Builder,
-AncestorMatchMode MatchMode) {
-// For AST-nodes that don't have an identity, we can't memoize.
-// When doing a single-level match, we don't need to memoize because
-// ParentMap (in ASTContext) already memoizes the result.
-if (!Builder->isComparable() ||
-MatchMode == AncestorMatchMode::AMM_ParentOnly)
-  return matchesAncestorOfRecursively(Node, Ctx, Matcher, Builder,
-  MatchMode);
-
-MatchKey Key;
-Key.MatcherID = Matcher.getID();
-Key.Node = Node;
-Key.BoundNodes = *Builder;
-Key.Traversal = Ctx.getParentMapContext().getTraversalKind();
-Key.Type = MatchType::Ancestors;
-
-// Note that we cannot use insert and reuse the iterator, as recursive
-// calls to match might invalidate the result cache iterators.
-MemoizationMap::iterator I = ResultCache.find(Key);
-if (I != ResultCache.end()) {
-  *Builder = I->second.Nodes;
-  return I->second.ResultOfMatch;
-}
+  //
+  // We avoid a recursive implementation to prevent excessive stack use on
+  // very deep ASTs (similarly to RecursiveASTVisitor's data recursion).
+  bool matchesAnyAncestorOf(DynTypedNode Node, ASTContext &Ctx,
+const DynTypedMatcher &Matcher,
+BoundNodesTreeBuilder *Builder) {
 
-MemoizedMatchResult Result;
-Result.Nodes = *Builder;
-Result.ResultOfMatch = matchesAncestorOfRecursively(
-Node, Ctx, Matcher, &Result.Nodes, MatchMode);
+ 

[PATCH] D86964: [ASTMatchers] Avoid recursion in ancestor matching to save stack space.

2020-09-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG625761825620: [ASTMatchers] Avoid recursion in ancestor 
matching to save stack space. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D86964?vs=289232&id=293504#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86964

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -544,8 +544,9 @@
 // don't invalidate any iterators.
 if (ResultCache.size() > MaxMemoizationEntries)
   ResultCache.clear();
-return memoizedMatchesAncestorOfRecursively(Node, Ctx, Matcher, Builder,
-MatchMode);
+if (MatchMode == AncestorMatchMode::AMM_ParentOnly)
+  return matchesParentOf(Node, Matcher, Builder);
+return matchesAnyAncestorOf(Node, Ctx, Matcher, Builder);
   }
 
   // Matches all registered matchers on the given node and calls the
@@ -699,9 +700,23 @@
   void matchDispatch(const void *) { /* Do nothing. */ }
   /// @}
 
+  // Returns whether a direct parent of \p Node matches \p Matcher.
+  // Unlike matchesAnyAncestorOf there's no memoization: it doesn't save much.
+  bool matchesParentOf(const DynTypedNode &Node, const DynTypedMatcher &Matcher,
+   BoundNodesTreeBuilder *Builder) {
+for (const auto &Parent : ActiveASTContext->getParents(Node)) {
+  BoundNodesTreeBuilder BuilderCopy = *Builder;
+  if (Matcher.matches(Parent, this, &BuilderCopy)) {
+*Builder = std::move(BuilderCopy);
+return true;
+  }
+}
+return false;
+  }
+
   // Returns whether an ancestor of \p Node matches \p Matcher.
   //
-  // The order of matching ((which can lead to different nodes being bound in
+  // The order of matching (which can lead to different nodes being bound in
   // case there are multiple matches) is breadth first search.
   //
   // To allow memoization in the very common case of having deeply nested
@@ -712,51 +727,64 @@
   // Once there are multiple parents, the breadth first search order does not
   // allow simple memoization on the ancestors. Thus, we only memoize as long
   // as there is a single parent.
-  bool memoizedMatchesAncestorOfRecursively(const DynTypedNode &Node,
-ASTContext &Ctx,
-const DynTypedMatcher &Matcher,
-BoundNodesTreeBuilder *Builder,
-AncestorMatchMode MatchMode) {
-// For AST-nodes that don't have an identity, we can't memoize.
-// When doing a single-level match, we don't need to memoize because
-// ParentMap (in ASTContext) already memoizes the result.
-if (!Builder->isComparable() ||
-MatchMode == AncestorMatchMode::AMM_ParentOnly)
-  return matchesAncestorOfRecursively(Node, Ctx, Matcher, Builder,
-  MatchMode);
-
-MatchKey Key;
-Key.MatcherID = Matcher.getID();
-Key.Node = Node;
-Key.BoundNodes = *Builder;
-Key.Traversal = Ctx.getParentMapContext().getTraversalKind();
-Key.Type = MatchType::Ancestors;
-
-// Note that we cannot use insert and reuse the iterator, as recursive
-// calls to match might invalidate the result cache iterators.
-MemoizationMap::iterator I = ResultCache.find(Key);
-if (I != ResultCache.end()) {
-  *Builder = I->second.Nodes;
-  return I->second.ResultOfMatch;
-}
+  //
+  // We avoid a recursive implementation to prevent excessive stack use on
+  // very deep ASTs (similarly to RecursiveASTVisitor's data recursion).
+  bool matchesAnyAncestorOf(DynTypedNode Node, ASTContext &Ctx,
+const DynTypedMatcher &Matcher,
+BoundNodesTreeBuilder *Builder) {
 
-MemoizedMatchResult Result;
-Result.Nodes = *Builder;
-Result.ResultOfMatch = matchesAncestorOfRecursively(
-Node, Ctx, Matcher, &Result.Nodes, MatchMode);
+// Memoization keys that can be updated with the result.
+// These are the memoizable nodes in the chain of unique parents, which
+// terminates when a node has multiple parents, or matches, or is the root.
+std::vector Keys;
+// When returning, update the memoization cache.
+auto Finish = [&](bool Matched) {
+  for (const auto &Key : Keys) {
+MemoizedMatchResult &CachedResult = ResultCache[Key];
+CachedResult.ResultOfMatch = Matched;
+CachedResult.Nodes = *Builder;
+  }
+  return Matched;
+};
+
+// Loop while there's a single parent and we want to attempt

[PATCH] D78075: [WIP][Clang][OpenMP] Added support for nowait target in CodeGen

2020-09-22 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 293505.
tianshilei1992 added a comment.

Fixed the case `target_parallel_for_codegen.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78075

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Index: clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
@@ -66,7 +66,11 @@
 #ifndef HEADER
 #define HEADER
 
-// CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[IDENT_T:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[KMP_TASK_T_WITH_PRIVATES:%.+]] = type { [[KMP_TASK_T:%.+]], [[KMP_PRIVATES_T:%.+]] }
+// CHECK-DAG: [[KMP_TASK_T]] = type { i8*, i32 (i32, i8*)*, i32, %{{[^,]+}}, %{{[^,]+}} }
+// CHECK-32-DAG: [[KMP_PRIVATES_T]] = type { [3 x i64], [3 x i8*], [3 x i8*], [3 x i8*], i16 }
+// CHECK-64-DAG: [[KMP_PRIVATES_T]] = type { [3 x i8*], [3 x i8*], [3 x i64], [3 x i8*], i16 }
 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
 // CHECK-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
 
@@ -132,33 +136,26 @@
   double cn[5][n];
   TT d;
 
-  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target_teams_nowait_mapper(i64 -1, i8* @{{[^,]+}}, i32 3, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[SIZET]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[MAPT]], i32 0, i32 0), i8** null, i32 {{[^,]+}}, i32 {{[^)]+}})
-  // CHECK-DAG:   [[BP]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
-  // CHECK-DAG:   [[P]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
-  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
-  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
-  // CHECK-DAG:   [[CBPADDR0:%.+]] = bitcast i8** [[BPADDR0]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR0:%.+]] = bitcast i8** [[PADDR0]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR0]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR0]]
-  // CHECK-DAG:   [[BPADDR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX1:[0-9]+]]
-  // CHECK-DAG:   [[PADDR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX1]]
-  // CHECK-DAG:   [[CBPADDR1:%.+]] = bitcast i8** [[BPADDR1]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR1:%.+]] = bitcast i8** [[PADDR1]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR1]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR1]]
-  // CHECK-DAG:   [[BPADDR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX1:[0-9]+]]
-  // CHECK-DAG:   [[PADDR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX1]]
-  // CHECK-DAG:   [[CBPADDR2:%.+]] = bitcast i8** [[BPADDR2]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR2:%.+]] = bitcast i8** [[PADDR2]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR2]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR2]]
-  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
-  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
-  // CHECK:   [[FAIL]]
-  // CHECK:   call void [[HVT0:@.+]](i[[SZ]] {{[^,]+}}, i[[SZ]] {{[^,]+}}, i[[SZ]] {{[^)]+}})
-  // CHECK-NEXT:  br label %[[END]]
-  // CHECK:   [[END]]
+  // CHECK-DAG: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i8* [[TASK:%.+]])
+  // CHECK-32-DAG:  [[TASK]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i32 84, i32 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-64-DAG:  [[TASK]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 144, i64 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-DAG: [[TASK_CAST:%.+]] = bitcast i8* [[TASK]] to [[K

[PATCH] D86895: [Modules] Add stats to measure performance of building and loading modules.

2020-09-22 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.

This looks pretty useful, thanks for adding this Volodymyr. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86895

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


[PATCH] D86895: [Modules] Add stats to measure performance of building and loading modules.

2020-09-22 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Where is the test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86895

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-22 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Should we wait for that one to land and then pick this one up? Otherwise any 
thoughts on the outstanding discussion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D87949: [ThinLTO] Option to bypass function importing.

2020-09-22 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 293506.
mtrofin added a comment.

clang tidy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87949

Files:
  clang/include/clang/CodeGen/BackendUtil.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/thinlto_embed_bitcode.ll
  llvm/include/llvm/LTO/LTOBackend.h
  llvm/lib/LTO/LTOBackend.cpp

Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -69,6 +69,11 @@
   "Embed post merge, but before optimizations")),
 cl::desc("Embed LLVM bitcode in object files produced by LTO"));
 
+static cl::opt ThinLTOAssumeMerged(
+"thinlto-assume-merged", cl::init(false),
+cl::desc("Assume the input has already undergone ThinLTO function "
+ "importing and the other pre-optimization pipeline changes."));
+
 LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) {
   errs() << "failed to open " << Path << ": " << Msg << '\n';
   errs().flush();
@@ -583,6 +588,21 @@
   if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(Task, Mod))
 return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
 
+  auto OptimizeAndCodegen =
+  [&](Module &Mod, TargetMachine *TM,
+  std::unique_ptr DiagnosticOutputFile) {
+if (!opt(Conf, TM, Task, Mod, /*IsThinLTO=*/true,
+ /*ExportSummary=*/nullptr, /*ImportSummary=*/&CombinedIndex,
+ CmdArgs))
+  return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
+
+codegen(Conf, TM, AddStream, Task, Mod, CombinedIndex);
+return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
+  };
+
+  if (ThinLTOAssumeMerged)
+return OptimizeAndCodegen(Mod, TM.get(), std::move(DiagnosticOutputFile));
+
   // When linking an ELF shared object, dso_local should be dropped. We
   // conservatively do this for -fpic.
   bool ClearDSOLocalOnDeclarations =
@@ -623,11 +643,81 @@
   if (Conf.PostImportModuleHook && !Conf.PostImportModuleHook(Task, Mod))
 return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
 
-  if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLTO=*/true,
-   /*ExportSummary=*/nullptr, /*ImportSummary=*/&CombinedIndex,
-   CmdArgs))
-return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
+  return OptimizeAndCodegen(Mod, TM.get(), std::move(DiagnosticOutputFile));
+}
+
+BitcodeModule *lto::findThinLTOModule(MutableArrayRef BMs) {
+  if (ThinLTOAssumeMerged && BMs.size() == 1)
+return BMs.begin();
 
-  codegen(Conf, TM.get(), AddStream, Task, Mod, CombinedIndex);
-  return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
+  for (BitcodeModule &BM : BMs) {
+Expected LTOInfo = BM.getLTOInfo();
+if (LTOInfo && LTOInfo->IsThinLTO)
+  return &BM;
+  }
+  return nullptr;
 }
+
+Expected lto::findThinLTOModule(MemoryBufferRef MBRef) {
+  Expected> BMsOrErr = getBitcodeModuleList(MBRef);
+  if (!BMsOrErr)
+return BMsOrErr.takeError();
+
+  // The bitcode file may contain multiple modules, we want the one that is
+  // marked as being the ThinLTO module.
+  if (const BitcodeModule *Bm = lto::findThinLTOModule(*BMsOrErr))
+return *Bm;
+
+  return make_error("Could not find module summary",
+ inconvertibleErrorCode());
+}
+
+bool lto::loadReferencedModules(
+const Module &M, const ModuleSummaryIndex &CombinedIndex,
+FunctionImporter::ImportMapTy &ImportList,
+MapVector &ModuleMap,
+std::vector>
+&OwnedImportsLifetimeManager) {
+  if (ThinLTOAssumeMerged)
+return true;
+  // We can simply import the values mentioned in the combined index, since
+  // we should only invoke this using the individual indexes written out
+  // via a WriteIndexesThinBackend.
+  for (const auto &GlobalList : CombinedIndex) {
+// Ignore entries for undefined references.
+if (GlobalList.second.SummaryList.empty())
+  continue;
+
+auto GUID = GlobalList.first;
+for (const auto &Summary : GlobalList.second.SummaryList) {
+  // Skip the summaries for the importing module. These are included to
+  // e.g. record required linkage changes.
+  if (Summary->modulePath() == M.getModuleIdentifier())
+continue;
+  // Add an entry to provoke importing by thinBackend.
+  ImportList[Summary->modulePath()].insert(GUID);
+}
+  }
+
+  for (auto &I : ImportList) {
+ErrorOr> MBOrErr =
+llvm::MemoryBuffer::getFile(I.first());
+if (!MBOrErr) {
+  errs() << "Error loading imported file '" << I.first()
+ << "': " << MBOrErr.getError().message() << "\n";
+  return false;
+}
+
+Expected BMOrErr = findThinLTOModule(**MBOrErr);
+if (!BMOrErr) {
+  handleAllEr

[clang] 8a64689 - [Analyzer][WebKit] UncountedLocalVarsChecker

2020-09-22 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-09-22T11:05:04-07:00
New Revision: 8a64689e264ce039e4fb0a09c3e136a1c8451838

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

LOG: [Analyzer][WebKit] UncountedLocalVarsChecker

Differential Review: https://reviews.llvm.org/D83259

Added: 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 9fb6782cf5a5..dbbd49085dac 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2538,6 +2538,53 @@ We also define a set of safe transformations which if 
passed a safe value as an
 - casts
 - unary operators like ``&`` or ``*``
 
+alpha.webkit.UncountedLocalVarsChecker
+""
+The goal of this rule is to make sure that any uncounted local variable is 
backed by a ref-counted object with lifetime that is strictly larger than the 
scope of the uncounted local variable. To be on the safe side we require the 
scope of an uncounted variable to be embedded in the scope of ref-counted 
object that backs it.
+
+These are examples of cases that we consider safe:
+
+  .. code-block:: cpp
+void foo1() {
+  RefPtr counted;
+  // The scope of uncounted is EMBEDDED in the scope of counted.
+  {
+RefCountable* uncounted = counted.get(); // ok
+  }
+}
+
+void foo2(RefPtr counted_param) {
+  RefCountable* uncounted = counted_param.get(); // ok
+}
+
+void FooClass::foo_method() {
+  RefCountable* uncounted = this; // ok
+}
+
+Here are some examples of situations that we warn about as they *might* be 
potentially unsafe. The logic is that either we're able to guarantee that an 
argument is safe or it's considered if not a bug then bug-prone.
+
+  .. code-block:: cpp
+
+void foo1() {
+  RefCountable* uncounted = new RefCountable; // warn
+}
+
+RefCountable* global_uncounted;
+void foo2() {
+  RefCountable* uncounted = global_uncounted; // warn
+}
+
+void foo3() {
+  RefPtr counted;
+  // The scope of uncounted is not EMBEDDED in the scope of counted.
+  RefCountable* uncounted = counted.get(); // warn
+}
+
+We don't warn about these cases - we don't consider them necessarily safe but 
since they are very common and usually safe we'd introduce a lot of false 
positives otherwise:
+- variable defined in condition part of an ```if``` statement
+- variable defined in init statement condition of a ```for``` statement
+
+For the time being we also don't warn about uninitialized uncounted local 
variables.
 
 Debug Checkers
 ---

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 3540fe5fe55c..444b00d73f0b 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1668,4 +1668,8 @@ def UncountedCallArgsChecker : 
Checker<"UncountedCallArgsChecker">,
   HelpText<"Check uncounted call arguments.">,
   Documentation;
 
+def UncountedLocalVarsChecker : Checker<"UncountedLocalVarsChecker">,
+  HelpText<"Check uncounted local variables.">,
+  Documentation;
+
 } // end alpha.webkit

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 31f971e33cb2..eb4f30137732 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -128,6 +128,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
   WebKit/UncountedCallArgsChecker.cpp
   WebKit/UncountedLambdaCapturesChecker.cpp
+  WebKit/UncountedLocalVarsChecker.cpp
 
   LINK_LIBS
   clangAST

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
new file mode 100644
index ..101aba732aea
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
@@ -0,0 +1,250 @@
+//===- UncountedLocalVarsChecker.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 "ASTUtils.h"
+#inc

[PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked

2020-09-22 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

The expensive-checks bots have been red for several days. Could you please take 
a look or revert?

riscv_generated_funcs.test:

  *** Bad machine code: MBB exits via unconditional fall-through but ends with 
a barrier instruction! ***
  - function:check_boundaries
  - basic block: %bb.4  (0x5653e22035b8)
  LLVM ERROR: Found 1 machine code errors.

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-ubuntu/builds/9171/steps/test-check-all/logs/FAIL%3A%20LLVM%3A%3Ariscv_generated_funcs.test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83004

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


[PATCH] D87921: Fix -funique-internal-linkage-names to work with -O2 and new pass manager

2020-09-22 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir added a comment.

In D87921#2288096 , @morehouse wrote:

> Thanks for looking.  Indeed, it looks like an issue with the disk being full 
> on the bot.

Hi, I checked the disk is not full on the bot. I am not sure what is going on 
here but its definitely not a disk space issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87921

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


[PATCH] D87815: [clang] Fix a typo-correction crash

2020-09-22 Thread Haojian Wu 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 rG16ca71180330: [clang] Fix a typo-correction crash (authored 
by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87815

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/typo-correction-crash.cpp


Index: clang/test/SemaCXX/typo-correction-crash.cpp
===
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -32,3 +32,12 @@
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared 
identifier 'n'}}
 
 void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error 
{{undeclared identifier '_test_'}}
+
+namespace NoCrash {
+class S {
+  void Function(int a) {
+unknown1(unknown2, Function, unknown3); // expected-error 2{{use of 
undeclared identifier}} \
+   expected-error {{reference to 
non-static member function must be called}}
+  }
+};
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6068,8 +6068,6 @@
   ExprResult result = S.CheckPlaceholderExpr(args[i]);
   if (result.isInvalid()) hasInvalid = true;
   else args[i] = result.get();
-} else if (hasInvalid) {
-  (void)S.CorrectDelayedTyposInExpr(args[i]);
 }
   }
   return hasInvalid;


Index: clang/test/SemaCXX/typo-correction-crash.cpp
===
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -32,3 +32,12 @@
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
 
 void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error {{undeclared identifier '_test_'}}
+
+namespace NoCrash {
+class S {
+  void Function(int a) {
+unknown1(unknown2, Function, unknown3); // expected-error 2{{use of undeclared identifier}} \
+   expected-error {{reference to non-static member function must be called}}
+  }
+};
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6068,8 +6068,6 @@
   ExprResult result = S.CheckPlaceholderExpr(args[i]);
   if (result.isInvalid()) hasInvalid = true;
   else args[i] = result.get();
-} else if (hasInvalid) {
-  (void)S.CorrectDelayedTyposInExpr(args[i]);
 }
   }
   return hasInvalid;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 16ca711 - [clang] Fix a typo-correction crash

2020-09-22 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-09-22T20:21:21+02:00
New Revision: 16ca711803300bd966acf8759876a1ccd478c616

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

LOG: [clang] Fix a typo-correction crash

We leave a dangling TypoExpr when typo-correction is performed
successfully in `checkArgsForPlaceholders`, which leads a crash in the
later TypoCorrection.

This code was added in 
https://github.com/llvm/llvm-project/commit/1586782767938df3a20f7abc4d8335c48b100bc4,
and it didn't seem to have enough test coverage.
The fix is to remove this part, and no failuer tests.

Reviewed By: rsmith

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

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/typo-correction-crash.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 736a6c166eb3..9cd5a35660d9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6068,8 +6068,6 @@ static bool checkArgsForPlaceholders(Sema &S, 
MultiExprArg args) {
   ExprResult result = S.CheckPlaceholderExpr(args[i]);
   if (result.isInvalid()) hasInvalid = true;
   else args[i] = result.get();
-} else if (hasInvalid) {
-  (void)S.CorrectDelayedTyposInExpr(args[i]);
 }
   }
   return hasInvalid;

diff  --git a/clang/test/SemaCXX/typo-correction-crash.cpp 
b/clang/test/SemaCXX/typo-correction-crash.cpp
index fce10800f2b6..10c0c11aaa6b 100644
--- a/clang/test/SemaCXX/typo-correction-crash.cpp
+++ b/clang/test/SemaCXX/typo-correction-crash.cpp
@@ -32,3 +32,12 @@ FooRecord::NestedNamespace::type x; // expected-error {{no 
member named 'NestedN
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared 
identifier 'n'}}
 
 void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error 
{{undeclared identifier '_test_'}}
+
+namespace NoCrash {
+class S {
+  void Function(int a) {
+unknown1(unknown2, Function, unknown3); // expected-error 2{{use of 
undeclared identifier}} \
+   expected-error {{reference to 
non-static member function must be called}}
+  }
+};
+}



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


[PATCH] D78075: [WIP][Clang][OpenMP] Added support for nowait target in CodeGen

2020-09-22 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 293537.
tianshilei1992 added a comment.

Refined the case `declare_mapper_codegen.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78075

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Index: clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
@@ -66,7 +66,11 @@
 #ifndef HEADER
 #define HEADER
 
-// CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[IDENT_T:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[KMP_TASK_T_WITH_PRIVATES:%.+]] = type { [[KMP_TASK_T:%.+]], [[KMP_PRIVATES_T:%.+]] }
+// CHECK-DAG: [[KMP_TASK_T]] = type { i8*, i32 (i32, i8*)*, i32, %{{[^,]+}}, %{{[^,]+}} }
+// CHECK-32-DAG: [[KMP_PRIVATES_T]] = type { [3 x i64], [3 x i8*], [3 x i8*], [3 x i8*], i16 }
+// CHECK-64-DAG: [[KMP_PRIVATES_T]] = type { [3 x i8*], [3 x i8*], [3 x i64], [3 x i8*], i16 }
 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
 // CHECK-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
 
@@ -132,33 +136,26 @@
   double cn[5][n];
   TT d;
 
-  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target_teams_nowait_mapper(i64 -1, i8* @{{[^,]+}}, i32 3, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[SIZET]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[MAPT]], i32 0, i32 0), i8** null, i32 {{[^,]+}}, i32 {{[^)]+}})
-  // CHECK-DAG:   [[BP]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
-  // CHECK-DAG:   [[P]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
-  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
-  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
-  // CHECK-DAG:   [[CBPADDR0:%.+]] = bitcast i8** [[BPADDR0]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR0:%.+]] = bitcast i8** [[PADDR0]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR0]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR0]]
-  // CHECK-DAG:   [[BPADDR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX1:[0-9]+]]
-  // CHECK-DAG:   [[PADDR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX1]]
-  // CHECK-DAG:   [[CBPADDR1:%.+]] = bitcast i8** [[BPADDR1]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR1:%.+]] = bitcast i8** [[PADDR1]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR1]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR1]]
-  // CHECK-DAG:   [[BPADDR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BPR]], i32 0, i32 [[IDX1:[0-9]+]]
-  // CHECK-DAG:   [[PADDR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PR]], i32 0, i32 [[IDX1]]
-  // CHECK-DAG:   [[CBPADDR2:%.+]] = bitcast i8** [[BPADDR2]] to i[[SZ]]*
-  // CHECK-DAG:   [[CPADDR2:%.+]] = bitcast i8** [[PADDR2]] to i[[SZ]]*
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CBPADDR2]]
-  // CHECK-DAG:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[CPADDR2]]
-  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
-  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
-  // CHECK:   [[FAIL]]
-  // CHECK:   call void [[HVT0:@.+]](i[[SZ]] {{[^,]+}}, i[[SZ]] {{[^,]+}}, i[[SZ]] {{[^)]+}})
-  // CHECK-NEXT:  br label %[[END]]
-  // CHECK:   [[END]]
+  // CHECK-DAG: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i8* [[TASK:%.+]])
+  // CHECK-32-DAG:  [[TASK]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i32 84, i32 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-64-DAG:  [[TASK]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 144, i64 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-DAG: [[TASK_CAST:%.+]] = bitcast i8* [[TASK]] to [[KMP_

[PATCH] D87921: Fix -funique-internal-linkage-names to work with -O2 and new pass manager

2020-09-22 Thread Albion Fung via Phabricator via cfe-commits
Conanap added a comment.

It looks like this commit is causing a few failures on nearly all PPC bots and 
a sanitizer bot; would it be possible to revert this commit for now until the 
issue is resolved?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87921

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


  1   2   >