[clang-tools-extra] 11cd977 - Add missing #include

2020-06-29 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2020-06-29T22:08:20-07:00
New Revision: 11cd9770174603aa62deabbe96c7d0db64d07058

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

LOG: Add missing #include

A forward declaration was insufficient here - since Regex needs to be
complete for the implicit dtor to be compiled correctly. (that, or the
dtor would have to be made explicit and out of line)

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 8ec8d8d1d797..eaa7f1851ce3 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -14,10 +14,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "llvm/ADT/DenseMap.h"
-
-namespace llvm {
-class Regex;
-}
+#include "llvm/Support/Regex.h"
 
 namespace clang {
 



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


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751



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


[PATCH] D82392: [CodeGen] Add public function to emit C++ destructor call.

2020-06-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can we do a design more like what we did with constructors?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82392



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


[PATCH] D79400: [CMAKE] Fix build failure when source directory is read only

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

Seems like this change causes `ninja clean` to fail with the error

> ninja: error: remove(include/llvm/Support): Directory not empty

Full repro steps are

  
  ninja install
  ninja clean

Simpler steps are

  
  ninja include/llvm/Support/all
  ninja clean


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79400



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


[clang] bb162df - [clang] attempt to fix a linux test failure for the darwin-ld-platform-version-macos.c test

2020-06-29 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-06-29T20:13:41-07:00
New Revision: bb162dfe252a1abc15af411d8ba51dda63af306c

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

LOG: [clang] attempt to fix a linux test failure for the 
darwin-ld-platform-version-macos.c test

Clang should use explicit -target to ensure that the Darwin driver is used.
Also drop arm64e test-case for now.

Added: 


Modified: 
clang/test/Driver/darwin-ld-platform-version-macos.c

Removed: 




diff  --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 5c7af058e462..d3f49093ef86 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -13,14 +13,8 @@
 // RUN:   | FileCheck --check-prefix=ARM64_NEW %s
 // RUN: %clang -target arm64-apple-macos11.1 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW_1 %s
-// RUN: %clang -arch arm64 -mmacosx-version-min=10.15 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=ARM64_NEW %s
 // RUN: %clang -target arm64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_OLD %s
-// RUN: %clang -arch arm64 -mmacosx-version-min=10.15 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=ARM64_OLD %s
-// RUN: %clang -target arm64e-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=ARM64_NEW %s
 
 // LINKER-OLD: "-macosx_version_min" "10.13.0"
 // LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"



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


[clang] 6792a60 - [darwin][driver] pass the minimum supported OS version to the linker

2020-06-29 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-06-29T19:03:57-07:00
New Revision: 6792a6077889f1ce77a3aa55b3e4fd3f1eb4333b

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

LOG: [darwin][driver] pass the minimum supported OS version to the linker
if it's newer than the target version

This change ensures that the arm64-apple-macOS slice is linked for
macOS 11 even if the deployment target is earlier than macOS 11.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld-platform-version-macos.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 4b98fd09b4b0..ad3b3a955d42 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2546,6 +2546,9 @@ void Darwin::addMinVersionArgs(const ArgList ,
 CmdArgs.push_back("-macosx_version_min");
   }
 
+  VersionTuple MinTgtVers = 
getEffectiveTriple().getMinimumSupportedOSVersion();
+  if (!MinTgtVers.empty() && MinTgtVers > TargetVersion)
+TargetVersion = MinTgtVers;
   CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
 }
 
@@ -2578,6 +2581,9 @@ void Darwin::addPlatformVersionArgs(const 
llvm::opt::ArgList ,
 PlatformName += "-simulator";
   CmdArgs.push_back(Args.MakeArgString(PlatformName));
   VersionTuple TargetVersion = getTargetVersion().withoutBuild();
+  VersionTuple MinTgtVers = 
getEffectiveTriple().getMinimumSupportedOSVersion();
+  if (!MinTgtVers.empty() && MinTgtVers > TargetVersion)
+TargetVersion = MinTgtVers;
   CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
   if (SDKInfo) {
 VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild();

diff  --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index c1b940a3f35f..5c7af058e462 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -7,9 +7,28 @@
 // RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target 
x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 
+// RUN: %clang -target arm64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_NEW %s
+// RUN: %clang -target arm64-apple-darwin19 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_NEW %s
+// RUN: %clang -target arm64-apple-macos11.1 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_NEW_1 %s
+// RUN: %clang -arch arm64 -mmacosx-version-min=10.15 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_NEW %s
+// RUN: %clang -target arm64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_OLD %s
+// RUN: %clang -arch arm64 -mmacosx-version-min=10.15 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_OLD %s
+// RUN: %clang -target arm64e-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=ARM64_NEW %s
+
 // LINKER-OLD: "-macosx_version_min" "10.13.0"
 // LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
 
+// ARM64_NEW: "-platform_version" "macos" "11.0.0" "10.14"
+// ARM64_NEW_1: "-platform_version" "macos" "11.1.0" "10.14"
+// ARM64_OLD: "-macosx_version_min" "11.0.0"
+
 // RUN: %clang -target x86_64-apple-macos10.13  -mlinker-version=520 -### %t.o 
2>&1 \
 // RUN:   | FileCheck --check-prefix=NOSDK %s
 // NOSDK: "-platform_version" "macos" "10.13.0" "0.0.0"



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


[clang] 5a5f535 - [c++20] Fix handling of operator rewrites naming consteval operator<=>.

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

Author: Richard Smith
Date: 2020-06-29T19:02:47-07:00
New Revision: 5a5f5350e1cbe14eaf852d9003523c7fdb1132af

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

LOG: [c++20] Fix handling of operator rewrites naming consteval operator<=>.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 038b814e3aff..d68be854aeeb 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -13506,6 +13506,10 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation 
OpLoc,
 if (R.isInvalid())
   return ExprError();
 
+R = CheckForImmediateInvocation(R, FnDecl);
+if (R.isInvalid())
+  return ExprError();
+
 // For a rewritten candidate, we've already reversed the arguments
 // if needed. Perform the rest of the rewrite now.
 if ((Best->RewriteKind & CRK_DifferentOperator) ||
@@ -13541,7 +13545,7 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation 
OpLoc,
 if (Best->RewriteKind != CRK_None)
   R = new (Context) CXXRewrittenBinaryOperator(R.get(), IsReversed);
 
-return CheckForImmediateInvocation(R, FnDecl);
+return R;
   } else {
 // We matched a built-in operator. Convert the arguments, then
 // break out so that we will build the appropriate built-in

diff  --git a/clang/test/SemaCXX/cxx2a-consteval.cpp 
b/clang/test/SemaCXX/cxx2a-consteval.cpp
index 0a6d137e9670..3231107add09 100644
--- a/clang/test/SemaCXX/cxx2a-consteval.cpp
+++ b/clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -476,6 +476,25 @@ namespace override {
   }
 }
 
+namespace operator_rewrite {
+  struct A {
+friend consteval int operator<=>(const A&, const A&) { return 0; }
+  };
+  const bool k = A() < A();
+  static_assert(!k);
+
+  A a;
+  bool k2 = A() < a; // OK, does not access 'a'.
+
+  struct B {
+friend consteval int operator<=>(const B , const B ) { return r.n - 
l.n; } // expected-note {{read of }}
+int n;
+  };
+  static_assert(B() >= B());
+  B b; // expected-note {{here}}
+  bool k3 = B() < b; // expected-error-re {{call to consteval function 
'{{.*}}::operator<=>' is not a constant expression}} expected-note {{in call}}
+}
+
 struct A {
   int(*ptr)();
   consteval A(int(*p)() = nullptr) : ptr(p) {}



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


[PATCH] D82431: [PowerPC][Power10] Implement Test LSB by Byte Builtins in LLVM/Clang

2020-06-29 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added inline comments.



Comment at: llvm/test/MC/Disassembler/PowerPC/vsx.txt:2
 # RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-linux-gnu -mcpu=pwr7 
| FileCheck %s
+# RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-linux-gnu \
+# RUN:   -mcpu=pwr10 | FileCheck %s --check-prefix=CHECK-P10

So, this is for bigendian, where is the little endian disassemble tests ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82431



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


[PATCH] D82562: Implement AVX ABI Warning/error

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



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2497
+ bool IsArgument) {
+  if (!CallerMap.lookup(Feature) && !CalleeMap.lookup(Feature))
+return Diag.Report(CallLoc, diag::warn_avx_calling_convention)

Should we save the lookup results in bool so we only do 2 lookups instead of 4 
in the common case where there is no error/warning


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

https://reviews.llvm.org/D82562



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


[PATCH] D82832: Correctly generate invert xor value for Binary Atomics of int size > 64

2020-06-29 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: hfinkel, erichkeane, rjmccall, cfe-commits.
Herald added a subscriber: jfb.

When using __sync_nand_and_fetch with __int128, a problem is found that
the wrong value for the 'invert' value gets emitted to the xor in case
where the int size is greater than 64 bits.

This is because uses of llvm::ConstantInt::get which zero extends the
greater than 64 bits, so instead -1 that we require, it end up
getting 18446744073709551615

This patch replaces the call to llvm::ConstantInt::get with the call
to llvm::Constant::getAllOnesValue which works for all integer types.


Repository:
  rC Clang

https://reviews.llvm.org/D82832

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/Atomics.c


Index: clang/test/CodeGen/Atomics.c
===
--- clang/test/CodeGen/Atomics.c
+++ clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@
 unsigned int ui;
 signed long long sll;
 unsigned long long ull;
+__int128 s128;
+unsigned  __int128 u128;
 
 void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
 {
@@ -48,6 +50,8 @@
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i32
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i64
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i64
+  (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i128
+  (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i128
 
   (void) __sync_fetch_and_nand (, 1); // CHECK: atomicrmw nand i8
   (void) __sync_fetch_and_nand (, 1); // CHECK: atomicrmw nand i8
@@ -168,27 +172,43 @@
   sc = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   uc = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   ss = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   us = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   si = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   ui = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   sll = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
   // CHECK: and
   // CHECK: xor
+  // CHECK: -1
   ull = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
   // CHECK: and
   // CHECK: xor
+  // CHECK: -1
+  u128 = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
+  // CHECK: and
+  // CHECK: xor
+  // CHECK: -1
+  s128 = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
+  // CHECK: and
+  // CHECK: xor
+  // CHECK: -1
 
   sc = __sync_and_and_fetch (, uc); // CHECK: atomicrmw and
   uc = __sync_and_and_fetch (, uc); // CHECK: atomicrmw and
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -219,8 +219,9 @@
   Kind, Args[0], Args[1], llvm::AtomicOrdering::SequentiallyConsistent);
   Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]);
   if (Invert)
-Result = CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
- llvm::ConstantInt::get(IntType, -1));
+Result =
+CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
+llvm::ConstantInt::getAllOnesValue(IntType));
   Result = EmitFromInt(CGF, Result, T, ValueType);
   return RValue::get(Result);
 }


Index: clang/test/CodeGen/Atomics.c
===
--- clang/test/CodeGen/Atomics.c
+++ clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@
 unsigned int 

[PATCH] D82825: [clang-tidy] Added alias llvm-else-after-return.

2020-06-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst:15
+
+Note: In this alias the options ``WarnOnUnfixable`` and 
+``RefactorConditionVariables`` are both set to ``false`` by default.

Please use single back-ticks for option names and values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82825



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


[PATCH] D82824: [clang-tidy] Added option to readability-else-after-return

2020-06-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:200
+  ` check now supports a 
+  ``RefactorConditionVariables`` option to control whether to refactor 
condition
+  variables where possible.

Please use single back-ticks for option name.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst:67
+
+   When ``true``, Emit a warning for cases where the check can't output a 
+   Fix-It. These can occur with declarations inside the ``else`` branch that

Please use single back-ticks for option values. Same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82824



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


[clang] 31c689e - Move Sema::PragmaStack::Act into Sema.h so it can be instantiated as needed

2020-06-29 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2020-06-29T18:02:12-07:00
New Revision: 31c689e69404bb8208de9599626f60c77b6fa81d

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

LOG: Move Sema::PragmaStack::Act into Sema.h so it can be 
instantiated as needed

Found by linker failures in ThinLTO where the definition wasn't
available when it needed to be. (eg: ThinLTO may've eliminated the one
caller in the same TU and dropped the definition - breaking accidental
implicit depenednce on that definition from elsewhere)

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index c5e2b4440390..24ceceeb69d0 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -490,10 +490,41 @@ class Sema final {
 PragmaLocation(PragmaLocation),
 PragmaPushLocation(PragmaPushLocation) {}
 };
-void Act(SourceLocation PragmaLocation,
- PragmaMsStackAction Action,
- llvm::StringRef StackSlotLabel,
- ValueType Value);
+
+void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
+ llvm::StringRef StackSlotLabel, ValueType Value) {
+  if (Action == PSK_Reset) {
+CurrentValue = DefaultValue;
+CurrentPragmaLocation = PragmaLocation;
+return;
+  }
+  if (Action & PSK_Push)
+Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
+   PragmaLocation);
+  else if (Action & PSK_Pop) {
+if (!StackSlotLabel.empty()) {
+  // If we've got a label, try to find it and jump there.
+  auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot ) {
+return x.StackSlotLabel == StackSlotLabel;
+  });
+  // If we found the label so pop from there.
+  if (I != Stack.rend()) {
+CurrentValue = I->Value;
+CurrentPragmaLocation = I->PragmaLocation;
+Stack.erase(std::prev(I.base()), Stack.end());
+  }
+} else if (!Stack.empty()) {
+  // We do not have a label, just pop the last entry.
+  CurrentValue = Stack.back().Value;
+  CurrentPragmaLocation = Stack.back().PragmaLocation;
+  Stack.pop_back();
+}
+  }
+  if (Action & PSK_Set) {
+CurrentValue = Value;
+CurrentPragmaLocation = PragmaLocation;
+  }
+}
 
 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
 // method body to restore the stacks on exit, so it works like this:

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index a51d1c3d7e12..b354e810974c 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -494,44 +494,6 @@ void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction 
Action,
   VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
 }
 
-template
-void Sema::PragmaStack::Act(SourceLocation PragmaLocation,
-   PragmaMsStackAction Action,
-   llvm::StringRef StackSlotLabel,
-   ValueType Value) {
-  if (Action == PSK_Reset) {
-CurrentValue = DefaultValue;
-CurrentPragmaLocation = PragmaLocation;
-return;
-  }
-  if (Action & PSK_Push)
-Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
-   PragmaLocation);
-  else if (Action & PSK_Pop) {
-if (!StackSlotLabel.empty()) {
-  // If we've got a label, try to find it and jump there.
-  auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot ) {
-return x.StackSlotLabel == StackSlotLabel;
-  });
-  // If we found the label so pop from there.
-  if (I != Stack.rend()) {
-CurrentValue = I->Value;
-CurrentPragmaLocation = I->PragmaLocation;
-Stack.erase(std::prev(I.base()), Stack.end());
-  }
-} else if (!Stack.empty()) {
-  // We do not have a label, just pop the last entry.
-  CurrentValue = Stack.back().Value;
-  CurrentPragmaLocation = Stack.back().PragmaLocation;
-  Stack.pop_back();
-}
-  }
-  if (Action & PSK_Set) {
-CurrentValue = Value;
-CurrentPragmaLocation = PragmaLocation;
-  }
-}
-
 bool Sema::UnifySection(StringRef SectionName,
 int SectionFlags,
 DeclaratorDecl *Decl) {



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


[PATCH] D81213: [RISCV] Support experimental v extension v0.9.

2020-06-29 Thread Evandro Menezes via Phabricator via cfe-commits
evandro accepted this revision.
evandro added a comment.
This revision is now accepted and ready to land.

It LGTM after D80802 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81213



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


[PATCH] D82815: [clang-tidy] Sanity checks in ClangTidyTest header.

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Motivated by a suspicously failing build, but also good to have anyway in 
general.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82815

Files:
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -19,7 +19,6 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Path.h"
 #include 
 #include 
@@ -67,7 +66,9 @@
 // that check constructors can access the context (for example, through
 // `getLangOpts()`).
 CheckFactory::createChecks(, Checks);
+assert(!Checks.empty() && "No checks created");
 for (auto  : Checks) {
+  assert(Check.get() && "Checks can't be null");
   if (!Check->isLanguageVersionSupported(Context.getLangOpts()))
 continue;
   Check->registerMatchers();
@@ -89,6 +90,7 @@
const ClangTidyOptions  = ClangTidyOptions(),
std::map PathsToContent =
std::map()) {
+  static_assert(sizeof...(CheckTypes) > 0, "No checks specified");
   ClangTidyOptions Options = ExtraOptions;
   Options.Checks = "*";
   ClangTidyContext Context(std::make_unique(
@@ -120,7 +122,7 @@
   llvm::IntrusiveRefCntPtr Files(
   new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
-  SmallVector, 1> Checks;
+  SmallVector, sizeof...(CheckTypes)> Checks;
   tooling::ToolInvocation Invocation(
   Args,
   std::make_unique>(Checks, Finder,


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -19,7 +19,6 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Path.h"
 #include 
 #include 
@@ -67,7 +66,9 @@
 // that check constructors can access the context (for example, through
 // `getLangOpts()`).
 CheckFactory::createChecks(, Checks);
+assert(!Checks.empty() && "No checks created");
 for (auto  : Checks) {
+  assert(Check.get() && "Checks can't be null");
   if (!Check->isLanguageVersionSupported(Context.getLangOpts()))
 continue;
   Check->registerMatchers();
@@ -89,6 +90,7 @@
const ClangTidyOptions  = ClangTidyOptions(),
std::map PathsToContent =
std::map()) {
+  static_assert(sizeof...(CheckTypes) > 0, "No checks specified");
   ClangTidyOptions Options = ExtraOptions;
   Options.Checks = "*";
   ClangTidyContext Context(std::make_unique(
@@ -120,7 +122,7 @@
   llvm::IntrusiveRefCntPtr Files(
   new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
-  SmallVector, 1> Checks;
+  SmallVector, sizeof...(CheckTypes)> Checks;
   tooling::ToolInvocation Invocation(
   Args,
   std::make_unique>(Checks, Finder,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82431: [PowerPC][Power10] Implement Test LSB by Byte Builtins in LLVM/Clang

2020-06-29 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 274239.
amyk added a comment.

Updated revision to:

- add the MC test cases into `vsx.s` and `vsx.txt`.
- create a test file called `builtins-ppc-p10vsx.ll` to place all Power10 VSX 
builtins tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82431

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/builtins-ppc-p10vsx.ll
  llvm/test/MC/Disassembler/PowerPC/vsx.txt
  llvm/test/MC/PowerPC/vsx.s

Index: llvm/test/MC/PowerPC/vsx.s
===
--- llvm/test/MC/PowerPC/vsx.s
+++ llvm/test/MC/PowerPC/vsx.s
@@ -1001,3 +1001,10 @@
 # CHECK-BE: xvtstdcsp 63, 63, 34   # encoding: [0xf3,0xe2,0xfe,0xaf]
 # CHECK-LE: xvtstdcsp 63, 63, 34   # encoding: [0xaf,0xfe,0xe2,0xf3]
 xvtstdcsp 63, 63, 34
+
+# Power 10 Instructions:
+
+# Test LSB Byte by Byte
+# CHECK-BE: xvtlsbb 1, 7   # encoding: [0xf0,0x82,0x3f,0x6c]
+# CHECK-LE: xvtlsbb 1, 7   # encoding: [0x6c,0x3f,0x82,0xf0]
+xvtlsbb 1, 7
Index: llvm/test/MC/Disassembler/PowerPC/vsx.txt
===
--- llvm/test/MC/Disassembler/PowerPC/vsx.txt
+++ llvm/test/MC/Disassembler/PowerPC/vsx.txt
@@ -1,4 +1,6 @@
 # RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s
+# RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-linux-gnu \
+# RUN:   -mcpu=pwr10 | FileCheck %s --check-prefix=CHECK-P10
 
 # CHECK: lxsdx 7, 5, 31
 0x7c 0xe5 0xfc 0x98
@@ -874,3 +876,6 @@
 
 # CHECK: xvtstdcsp 63, 63, 34
 0xf3 0xe2 0xfe 0xaf
+
+# CHECK-P10: xvtlsbb 1, 7
+0xf0 0x82 0x3f 0x6c
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -0,0 +1,35 @@
+; 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
+
+; These test cases aims to test the builtins for the Power10 VSX vector
+; instructions introduced in ISA 3.1.
+
+declare i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8>, i1)
+
+define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> %vuca) {
+; CHECK-LABEL: test_vec_test_lsbb_all_ones:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtlsbb cr0, v2
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:srwi r3, r3, 31
+; CHECK-NEXT:extsw r3, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 1)
+  ret i32 %0
+}
+
+define signext i32 @test_vec_test_lsbb_all_zeros(<16 x i8> %vuca) {
+; CHECK-LABEL: test_vec_test_lsbb_all_zeros:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtlsbb cr0, v2
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:rlwinm r3, r3, 3, 31, 31
+; CHECK-NEXT:extsw r3, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 0)
+  ret i32 %0
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -177,6 +177,25 @@
   let Inst{31} = XT{5};
 }
 
+// [PO BF / XO2 B XO BX /]
+class XX2_BF3_XO5_XB6_XO9 opcode, bits<5> xo2, bits<9> xo, dag OOL,
+  dag IOL, string asmstr, InstrItinClass itin,
+  list pattern>
+  : I {
+  bits<3> BF;
+  bits<6> XB;
+
+  let Pattern = pattern;
+
+  let Inst{6-8}   = BF;
+  let Inst{9-10}  = 0;
+  let Inst{11-15} = xo2;
+  let Inst{16-20} = XB{4-0};
+  let Inst{21-29} = xo;
+  let Inst{30}= XB{5};
+  let Inst{31}= 0;
+}
+
 multiclass MLS_DForm_R_SI34_RTA5_MEM_p opcode, dag OOL, dag IOL,
dag PCRel_IOL, string asmstr,
InstrItinClass itin> {
@@ -552,6 +571,8 @@
  "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
  [(set v16i8:$vD,
(int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
+   def XVTLSBB : XX2_BF3_XO5_XB6_XO9<60, 2, 475, (outs crrc:$BF), (ins vsrc:$XB),
+ "xvtlsbb $BF, $XB", IIC_VecGeneral, []>;
 }
 
 // Anonymous Patterns //
@@ -564,4 +585,8 @@
 (v4i32 (COPY_TO_REGCLASS (XXGENPCVWM $VRB, imm:$IMM), VRRC))>;
   def : Pat<(v2i64 (int_ppc_vsx_xxgenpcvdm v2i64:$VRB, imm:$IMM)),
 (v2i64 (COPY_TO_REGCLASS (XXGENPCVDM 

[PATCH] D82824: [clang-tidy] Added option to readability-else-after-return

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Added a 'RefactorConditionVariables' option to control how the check handles 
condition variables


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82824

Files:
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-cond-var-refactor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-cond-var-refactor.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-cond-var-refactor.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s readability-else-after-return %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN: {key: readability-else-after-return.RefactorConditionVariables, value: false}, \
+// RUN: ]}'
+
+bool foo(int Y) {
+  // Excess scopes are here so that the check would have to opportunity to
+  // refactor the variable out of the condition.
+
+  // Expect warnings here as we don't need to move declaration of 'X' out of the
+  // if condition as its not used in the else.
+  {
+if (int X = Y)
+  return X < 0;
+else
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+  return false;
+  }
+  {
+if (int X = Y; X)
+  return X < 0;
+else
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+  return false;
+  }
+
+  // Expect no warnings for these cases, as even though its safe to move
+  // declaration of 'X' out of the if condition, that has been disabled
+  // by the options.
+  {
+if (int X = Y)
+  return false;
+else
+  return X < 0;
+  }
+  {
+if (int X = Y; X)
+  return false;
+else
+  return X < 0;
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
@@ -59,6 +59,19 @@
   }
 }
 
+Options
+---
+
+.. option:: WarnOnUnfixable
+
+   When ``true``, Emit a warning for cases where the check can't output a 
+   Fix-It. These can occur with declarations inside the ``else`` branch that
+   would have an extended lifetime if the ``else`` branch was removed.
+   Default value is ``true``.
+
+.. option:: RefactorConditionVariables
+
+   When ``true``, The check will attempt to refactor a variable defined inside
+   the condition of the if statement that is used in the else branch.
+   Default value is ``true``.
 
-This check helps to enforce this `LLVM Coding Standards recommendation
-`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -195,6 +195,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:`readability-else-after-return
+  ` check now supports a 
+  ``RefactorConditionVariables`` option to control whether to refactor condition
+  variables where possible.
+
 - Improved :doc:'readability-identifier-naming
   ` check.
 
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
@@ -28,6 +28,7 @@
 
 private:
   const bool WarnOnUnfixable;
+  const bool RefactorConditionVariables;
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -26,6 +26,8 @@
 static const char ThrowStr[] = "throw";
 static const char WarningMessage[] = "do not use 'else' after '%0'";
 static const char WarnOnUnfixableStr[] = "WarnOnUnfixable";
+static const char RefactorConditionVariablesStr[] =
+"RefactorConditionVariables";
 
 const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) {
   if (!Node)
@@ -138,10 +140,14 @@
 ElseAfterReturnCheck::ElseAfterReturnCheck(StringRef Name,
ClangTidyContext *Context)
 : 

[PATCH] D82825: [clang-tidy] Added alias llvm-else-after-return.

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 added a comment.

This is supposed to have a parent revision D82824 
 but for some reason phab won't let me add it


Added an alias llvm-else-after-return from readability-else-after-return to 
help enforce one of the llvm coding guidelines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82825

Files:
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst


Index: clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - llvm-else-after-return
+.. meta::
+   :http-equiv=refresh: 5;URL=readability-else-after-return.html
+
+llvm-else-after-return
+==
+
+The llvm-else-after-return check is an alias, please see
+`readability-else-after-return `_
+for more information.
+
+This check helps to enforce this `LLVM Coding Standards recommendation
+`_.
+
+Note: In this alias the options ``WarnOnUnfixable`` and 
+``RefactorConditionVariables`` are both set to ``false`` by default.
+
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -423,4 +423,5 @@
`hicpp-use-nullptr `_, `modernize-use-nullptr 
`_, "Yes"
`hicpp-use-override `_, `modernize-use-override 
`_, "Yes"
`hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg 
`_,
+   `llvm-else-after-return `_, 
`readability-else-after-return `_, "Yes"
`llvm-qualified-auto `_, 
`readability-qualified-auto `_, "Yes"
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -192,6 +192,11 @@
   :doc:`bugprone-signed-char-misuse
   ` was added.
 
+- New alias :doc:`llvm-else-after-return
+  ` to
+  :doc:`readability-else-after-return
+  ` was added.
+
 Changes in existing checks
 ^^
 
Index: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "../readability/ElseAfterReturnCheck.h"
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/QualifiedAutoCheck.h"
 #include "HeaderGuardCheck.h"
@@ -24,6 +25,8 @@
 class LLVMModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"llvm-else-after-return");
 CheckFactories.registerCheck("llvm-header-guard");
 CheckFactories.registerCheck("llvm-include-order");
 CheckFactories.registerCheck(
@@ -40,6 +43,9 @@
   ClangTidyOptions getModuleOptions() override {
 ClangTidyOptions Options;
 Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
+Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
+Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] =
+"0";
 return Options;
   }
 };


Index: clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - llvm-else-after-return
+.. meta::
+   :http-equiv=refresh: 5;URL=readability-else-after-return.html
+
+llvm-else-after-return
+==
+
+The llvm-else-after-return check is an alias, please see
+`readability-else-after-return `_
+for more information.
+
+This check helps to enforce this `LLVM Coding Standards recommendation
+`_.
+
+Note: In this alias the options ``WarnOnUnfixable`` and 
+``RefactorConditionVariables`` are both set to ``false`` by default.
+
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -423,4 +423,5 @@
`hicpp-use-nullptr `_, 

[PATCH] D82825: [clang-tidy] Added alias llvm-else-after-return.

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

This is supposed to have a parent revision D82824 
 but for some reason phab won't let me add it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82825



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


[PATCH] D82791: [lit] Improve lit's output with default settings and --verbose.

2020-06-29 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 274240.
varungandhi-apple added a comment.
Herald added subscribers: cfe-commits, martong.
Herald added a project: clang.

Include missing commit separating verbose and showOutput.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82791

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/CodeGen/aarch64-sve.c
  clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp
  clang/test/CodeGenCXX/aarch64-sve-typeinfo.cpp
  clang/test/CodeGenObjC/aarch64-sve-types.m
  clang/test/PCH/aarch64-sve-types.c
  clang/test/Sema/aarch64-sve-types.c
  clang/test/SemaObjC/aarch64-sve-types.m
  clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp

Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -170,6 +170,54 @@
 "test.FalsePositiveGenerator:CAN_BE_TRUE\n");
 }
 
+TEST(FalsePositiveRefutationBRVisitor,
+ UnSatAtErrorNodeDueToRefinedConstraintNoReport) {
+  SKIP_WITHOUT_Z3;
+  constexpr auto Code = R"(
+void reportIfCanBeTrue(bool);
+void reachedWithNoContradiction();
+void test(unsigned x, unsigned n) {
+  if (n >= 1 && n <= 2) {
+if (x >= 3)
+  return;
+// x: [0,2] and n: [1,2]
+int y = x + n; // y: '(x+n)' Which is in approximately between 1 and 4.
+
+// Registers the symbol 'y' with the constraint [1, MAX] in the true
+// branch.
+if (y > 0) {
+  // Since the x: [0,2] and n: [1,2], the 'y' is indeed greater than
+  // zero. If we emit a warning here, the constraints on the BugPath is
+  // SAT. Therefore that report is NOT invalidated.
+  reachedWithNoContradiction(); // 'y' can be greater than zero. OK
+
+  // If we ask the analyzer whether the 'y' can be 5. It won't know,
+  // therefore, the state will be created where the 'y' expression is 5.
+  // Although, this assumption is false!
+  // 'y' can not be 5 if the maximal value of both x and n is 2.
+  // The BugPath which become UnSAT in the ErrorNode with a refined
+  // constraint, should be invalidated.
+  reportIfCanBeTrue(y == 5);
+}
+  }
+})";
+
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCodeWithArgs(
+  Code, LazyAssumeAndCrossCheckArgs, Diags));
+  EXPECT_EQ(Diags,
+"test.FalsePositiveGenerator:REACHED_WITH_NO_CONTRADICTION\n");
+  // Single warning. The second report was invalidated by the visitor.
+
+  // Without enabling the crosscheck-with-z3 both reports are displayed.
+  std::string Diags2;
+  EXPECT_TRUE(runCheckerOnCodeWithArgs(
+  Code, LazyAssumeArgs, Diags2));
+  EXPECT_EQ(Diags2,
+"test.FalsePositiveGenerator:REACHED_WITH_NO_CONTRADICTION\n"
+"test.FalsePositiveGenerator:CAN_BE_TRUE\n");
+}
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/test/SemaObjC/aarch64-sve-types.m
===
--- clang/test/SemaObjC/aarch64-sve-types.m
+++ clang/test/SemaObjC/aarch64-sve-types.m
@@ -18,5 +18,7 @@
 @property(nullable) __SVFloat32_t f32; // expected-error {{cannot be applied to non-pointer type}}
 @property(nullable) __SVFloat64_t f64; // expected-error {{cannot be applied to non-pointer type}}
 
+@property(nullable) __SVBFloat16_t bf16; // expected-error {{cannot be applied to non-pointer type}}
+
 @property(nullable) __SVBool_t b8; // expected-error {{cannot be applied to non-pointer type}}
 @end
Index: clang/test/Sema/aarch64-sve-types.c
===
--- clang/test/Sema/aarch64-sve-types.c
+++ clang/test/Sema/aarch64-sve-types.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve,+bf16 -fsyntax-only -verify
 
 void f() {
   int size_s8[sizeof(__SVInt8_t) == 0 ? 1 : -1];// expected-error {{invalid application of 'sizeof' to sizeless type '__SVInt8_t'}}
@@ -34,6 +34,9 @@
   int size_f64[sizeof(__SVFloat64_t) == 0 ? 1 : -1];// expected-error {{invalid application of 'sizeof' to sizeless type '__SVFloat64_t'}}
   int align_f64[__alignof__(__SVFloat64_t) == 16 ? 1 : -1]; // expected-error {{invalid application of '__alignof' to sizeless type '__SVFloat64_t'}}
 
+  int size_bf16[sizeof(__SVBFloat16_t) == 0 ? 1 : -1];// expected-error {{invalid application of 'sizeof' to sizeless type 

[PATCH] D82431: [PowerPC][Power10] Implement Test LSB by Byte Builtins in LLVM/Clang

2020-06-29 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

@lei Could you please take another look at this to see if this change is OK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82431



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


[PATCH] D82782: Clang Driver: refactor support for writing response files to be specified at Command creation, rather than as part of the Tool.

2020-06-29 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4772b99dffec: Clang Driver: refactor support for writing 
response files to be specified at… (authored by jyknight).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82782

Files:
  clang/include/clang/Driver/Job.h
  clang/include/clang/Driver/Tool.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Job.cpp
  clang/lib/Driver/Tool.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/Ananas.h
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CloudABI.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/DragonFly.h
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/FreeBSD.h
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/Minix.cpp
  clang/lib/Driver/ToolChains/Minix.h
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/lib/Driver/ToolChains/Myriad.h
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/NaCl.h
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/NetBSD.h
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/lib/Driver/ToolChains/XCore.cpp

Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -52,7 +52,8 @@
 CmdArgs.push_back(II.getFilename());
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
-  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs));
 }
 
 void tools::XCore::Linker::ConstructJob(Compilation , const JobAction ,
@@ -80,7 +81,8 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
-  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs));
 }
 
 /// XCore tool chain
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -18,10 +18,9 @@
 namespace tools {
 namespace wasm {
 
-class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
-  explicit Linker(const ToolChain )
-  : GnuTool("wasm::Linker", "linker", TC) {}
+  explicit Linker(const ToolChain ) : Tool("wasm::Linker", "linker", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList ) const;
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -114,7 +114,8 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(
+  JA, *this, 

[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 10 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:41
+  ConfigCompile.cpp
   ConfigYAML.cpp
   Diagnostics.cpp

hokein wrote:
> we have a few config-related files now, I wonder would it make sense to 
> create a config/ subdir?
It seems marginal to me - could go either way. We have a small handful (2 
headers and 3 impl files). There may be 1-2 more, but I'm not sure yet. 
(config-files-on-disk, and json->fragment).
So 6-7 files... smaller than the other subdirs, but not tiny.

There's also the fact that config.h/cpp is not like the others: all features 
(not just infra) depend on this, it's not in the `config::` namespace etc. So 
should it really be in the subdir?

Mind if we hold off on this until at least the scope of D82335 has landed? I 
think it would be awkward to do this move halfway through this patchset, but 
fairly easy to do at any point that things are stable.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:96
+
+  constexpr static auto Error = llvm::SourceMgr::DK_Error;
+  void diag(llvm::SourceMgr::DiagKind Kind, llvm::StringRef Message,

hokein wrote:
> this member seems unused.
it's used on line 52 `diag(Error, ...)`.

I wouldn't bother extracting it except there should be a bunch more places 
where errors are emitted, and keeping them readable is worthwhile IME.



Comment at: clang-tools-extra/clangd/ConfigProvider.h:32
+/// Describes the context used to evaluate configuration fragments.
+struct Params {
+  /// Absolute path to file we're targeting. Unix slashes.

hokein wrote:
> nit: I find the name `Params` is too general, it implies less information. 
> When I read the code using `Params`, I have to go-to-definition to see what 
> it means. 
> 
> if we only have a single member in this struct, maybe just use it directly.
Agree with the vague name.
In most contexts, the name is `config::Params` which is at least a bit more 
specific.

> if we only have a single member in this struct, maybe just use it directly.

I don't like this, though - there are likely to be more things here in the 
future (e.g. platform), and passing around a string is much less clear as to 
intent. So any idea about a name for this struct?

What about `config::Environment` or `config::Env`? still too vague?



Comment at: clang-tools-extra/clangd/ConfigProvider.h:40
+///
+/// Fragments are compiled by Providers when first loaded, and cached for 
reuse.
+/// Like a compiled program, this is good for performance and also encourages

hokein wrote:
> I might miss the context, where is the provider, not added yet? 
Right, D82335 has a rought draft of everything together (it's called 
ConfigProvider in that patch).

I think it's less churn-y to add the documentation as the classes are added, 
even if it means temporarily referring to something that doesn't exist yet.



Comment at: clang-tools-extra/clangd/ConfigProvider.h:47
+  /// This always produces a usable compiled fragment (errors are recovered).
+  explicit CompiledFragment(Fragment, DiagnosticCallback);
+

hokein wrote:
> Would it be more nature to have a function `compile`(or so) to do the actual 
> compile (Fragment -> CompiledFragment) rather than doing it in a constructor?
I'm not sure. The idea that the input/result is Fragment/CompiledFragment, and 
that the compilation cannot fail, suggests to me that a constructor is OK here.
On the other hand, the DiangosticCallback param (which we don't keep a 
reference to) is a bit weird.

So I don't really feel strongly about it one way or the other, happy to change 
it if you do think it would be significantly better.



Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:40
+TEST_F(ConfigCompileTests, Condition) {
+  // No condition.
+  Frag.CompileFlags.Add.emplace_back("X");

hokein wrote:
> my first impression was that each `// XXX` is a separated test, but it turns 
> out not, the tests here seem to be stateful -- `Frag` keeps being modified. I 
> think it is intentional, but it is hard for readers to track given that the 
> code is long.
Agree. Made this test reset fragment state after each group of assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82612



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


[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 274237.
sammccall marked 3 inline comments as done.
sammccall added a comment.

Address some review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82612

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigTesting.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -8,14 +8,13 @@
 
 #include "Annotations.h"
 #include "ConfigFragment.h"
-#include "Matchers.h"
+#include "ConfigTesting.h"
 #include "Protocol.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include "gtest/internal/gtest-internal.h"
 
 namespace clang {
 namespace clangd {
@@ -36,55 +35,6 @@
   return false;
 }
 
-Position toPosition(llvm::SMLoc L, const llvm::SourceMgr ) {
-  auto LineCol = SM.getLineAndColumn(L);
-  Position P;
-  P.line = LineCol.first - 1;
-  P.character = LineCol.second - 1;
-  return P;
-}
-
-Range toRange(llvm::SMRange R, const llvm::SourceMgr ) {
-  return Range{toPosition(R.Start, SM), toPosition(R.End, SM)};
-}
-
-struct CapturedDiags {
-  std::function callback() {
-return [this](const llvm::SMDiagnostic ) {
-  Diagnostics.emplace_back();
-  Diag  = Diagnostics.back();
-  Out.Message = D.getMessage().str();
-  Out.Kind = D.getKind();
-  Out.Pos.line = D.getLineNo() - 1;
-  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
-  if (!D.getRanges().empty()) {
-const auto  = D.getRanges().front();
-Out.Rng.emplace();
-Out.Rng->start.line = Out.Rng->end.line = Out.Pos.line;
-Out.Rng->start.character = R.first;
-Out.Rng->end.character = R.second;
-  }
-};
-  }
-  struct Diag {
-std::string Message;
-llvm::SourceMgr::DiagKind Kind;
-Position Pos;
-llvm::Optional Rng;
-
-friend void PrintTo(const Diag , std::ostream *OS) {
-  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
-  << D.Message << "@" << llvm::to_string(D.Pos);
-}
-  };
-  std::vector Diagnostics;
-};
-
-MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
-MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
-MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
-MATCHER_P(DiagRange, R, "") { return arg.Rng == R; }
-
 TEST(ParseYAML, SyntacticForms) {
   CapturedDiags Diags;
   const char *YAML = R"yaml(
Index: clang-tools-extra/clangd/unittests/ConfigTesting.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigTesting.h
@@ -0,0 +1,77 @@
+//===-- ConfigTesting.h - Helpers for configuration tests ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_CONFIGTESTING_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_CONFIGTESTING_H
+
+#include "Protocol.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gmock/gmock.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace config {
+
+// Provides a DiagnosticsCallback that records diganostics.
+// Unlike just pushing them into a vector, underlying storage need not survive.
+struct CapturedDiags {
+  std::function callback() {
+return [this](const llvm::SMDiagnostic ) {
+  Diagnostics.emplace_back();
+  Diag  = Diagnostics.back();
+  Out.Message = D.getMessage().str();
+  Out.Kind = D.getKind();
+  Out.Pos.line = D.getLineNo() - 1;
+  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
+  if (!D.getRanges().empty()) {
+const auto  = D.getRanges().front();
+Out.Range.emplace();
+Out.Range->start.line = Out.Range->end.line = Out.Pos.line;
+Out.Range->start.character = R.first;
+Out.Range->end.character = R.second;
+  }
+};
+  }
+  struct Diag {
+std::string Message;
+llvm::SourceMgr::DiagKind Kind;
+Position Pos;
+llvm::Optional Range;
+
+friend void PrintTo(const Diag , std::ostream *OS) {
+  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
+

[PATCH] D82731: [X86] Move frontend CPU feature initialization to a look up table based implementation.

2020-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

@RKSimon do you mind taking a look at this too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82731



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


[PATCH] D82777: Clang Driver: Use Apple ld64's new @response-file support.

2020-06-29 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG381df1653c92: Clang Driver: Use Apple ld64s new 
@response-file support. (authored by jyknight).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82777

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h


Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -69,9 +69,10 @@
const InputInfoList ) const;
 
 public:
-  Linker(const ToolChain )
-  : MachOTool("darwin::Linker", "linker", TC, RF_FileList,
-  llvm::sys::WEM_UTF8, "-filelist") {}
+  Linker(const ToolChain , bool UseAtFile)
+  : MachOTool("darwin::Linker", "linker", TC,
+  UseAtFile ? RF_Full : RF_FileList, llvm::sys::WEM_UTF8,
+  UseAtFile ? "@" : "-filelist") {}
 
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -929,7 +929,22 @@
   }
 }
 
-Tool *MachO::buildLinker() const { return new tools::darwin::Linker(*this); }
+Tool *MachO::buildLinker() const {
+  // Determine whether to use an @responsefile or the old -filelist mechanism.
+  bool UseAtFile = false;
+  unsigned Version[5] = {0, 0, 0, 0, 0};
+  if (Arg *A =
+  getArgs_DO_NOT_USE().getLastArg(options::OPT_mlinker_version_EQ)) {
+// We don't need to diagnose a parse error here, it'll be caught in
+// ConstructJob.
+if (Driver::GetReleaseVersion(A->getValue(), Version)) {
+  if (Version[0] >= 607)
+UseAtFile = true;
+}
+  }
+
+  return new tools::darwin::Linker(*this, UseAtFile);
+}
 
 Tool *MachO::buildAssembler() const {
   return new tools::darwin::Assembler(*this);
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -201,6 +201,9 @@
 
   // Accessors
 
+  /// Temporary for Darwin::Linker
+  const llvm::opt::ArgList _DO_NOT_USE() const { return Args; }
+
   const Driver () const { return D; }
   llvm::vfs::FileSystem () const;
   const llvm::Triple () const { return Triple; }


Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -69,9 +69,10 @@
const InputInfoList ) const;
 
 public:
-  Linker(const ToolChain )
-  : MachOTool("darwin::Linker", "linker", TC, RF_FileList,
-  llvm::sys::WEM_UTF8, "-filelist") {}
+  Linker(const ToolChain , bool UseAtFile)
+  : MachOTool("darwin::Linker", "linker", TC,
+  UseAtFile ? RF_Full : RF_FileList, llvm::sys::WEM_UTF8,
+  UseAtFile ? "@" : "-filelist") {}
 
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -929,7 +929,22 @@
   }
 }
 
-Tool *MachO::buildLinker() const { return new tools::darwin::Linker(*this); }
+Tool *MachO::buildLinker() const {
+  // Determine whether to use an @responsefile or the old -filelist mechanism.
+  bool UseAtFile = false;
+  unsigned Version[5] = {0, 0, 0, 0, 0};
+  if (Arg *A =
+  getArgs_DO_NOT_USE().getLastArg(options::OPT_mlinker_version_EQ)) {
+// We don't need to diagnose a parse error here, it'll be caught in
+// ConstructJob.
+if (Driver::GetReleaseVersion(A->getValue(), Version)) {
+  if (Version[0] >= 607)
+UseAtFile = true;
+}
+  }
+
+  return new tools::darwin::Linker(*this, UseAtFile);
+}
 
 Tool *MachO::buildAssembler() const {
   return new tools::darwin::Assembler(*this);
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -201,6 +201,9 @@
 
   // Accessors
 
+  /// Temporary for Darwin::Linker
+  const llvm::opt::ArgList _DO_NOT_USE() const { return Args; }
+
   const Driver () const { return D; }
   llvm::vfs::FileSystem () const;
   const llvm::Triple () const { return Triple; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D82791: [lit] Improve lit's output with default settings and --verbose.

2020-06-29 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 274242.
varungandhi-apple added a comment.

- [docs] [lit] Add a more helpful description for lit.py's -s flag.
- [NFC] [lit] Separate verbose and showOutput.
- [lit] Improve lit's output with default settings and --verbose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82791

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/utils/lit/lit/LitConfig.py
  llvm/utils/lit/lit/OutputSettings.py
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/cl_arguments.py
  llvm/utils/lit/lit/display.py
  llvm/utils/lit/lit/main.py
  llvm/utils/lit/tests/shtest-format.py
  llvm/utils/lit/tests/shtest-run-at-line.py
  llvm/utils/lit/tests/unittest-failing-locator.py

Index: llvm/utils/lit/tests/unittest-failing-locator.py
===
--- /dev/null
+++ llvm/utils/lit/tests/unittest-failing-locator.py
@@ -0,0 +1,122 @@
+# Check that the locate_last_failing_run_line function works as expected.
+
+# RUN: %{python} %s
+# END.
+
+import unittest
+
+from lit.TestRunner import locate_last_run_line
+
+class TestRunLineLocatorHeuristics(unittest.TestCase):
+
+def test_basic(self):
+# from a script like
+# RUN: echo Hello 1>&2
+basic = (
+"+ : 'RUN: at line 1'\n"
+"+ echo Hello 1>&2\n"
+"+ Hello\n"
+)
+line_start, substr = locate_last_run_line(basic)
+self.assertEqual(line_start, 0)
+self.assertEqual(substr, "RUN: at line 1")
+
+def test_multiple(self):
+# from a script like
+# RUN: echo Hello 1>&2
+# RUN: false
+multiple = (
+"+ : 'RUN: at line 1'\n"
+"+ echo Hello 1>&2\n"
+"+ Hello\n"
+"+ : 'RUN: at line 2'\n"
+"+ false\n"
+)
+line_start, substr = locate_last_run_line(multiple)
+self.assertEqual(line_start, multiple.rfind("+ :"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_varying_prefix(self):
+# from a script like
+# RUN: echo Hello 1>&2
+# RUN: false
+#
+# in a hypothetical shell which prints line-numbers on 'set +x'
+# (as an example of something that varies)
+varying_prefix = (
+"+ 1 : 'RUN: at line 1'\n"
+"+ 2 echo Hello 1>&2\n"
+"+ Hello\n"
+"+ 3 : 'RUN: at line 2'\n"
+"+ 4 false\n"
+)
+line_start, substr = locate_last_run_line(varying_prefix)
+self.assertEqual(line_start, varying_prefix.rfind("+ 3"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_confusing_basic(self):
+# from a script like
+# RUN: echo 'RUN: at line 10' 1>&2
+confusing_basic = (
+"+ : 'RUN: at line 1'\n"
+"+ echo 'RUN: at line 10'\n"
+"RUN: at line 10\n"
+)
+line_start, substr = locate_last_run_line(confusing_basic)
+# FIXME: These should both be equal ideally.
+self.assertNotEqual(line_start, 0)
+self.assertNotEqual(substr, "RUN: at line 1")
+
+def test_confusing_multiple(self):
+# from a script like
+# RUN: echo 'RUN: at line 10' 1>&2
+# RUN: false
+confusing_multiple = (
+"+ : 'RUN: at line 1'\n"
+"+ echo 'RUN: at line 10'\n"
+"RUN: at line 10\n"
+"+ : 'RUN: at line 2'\n"
+"+ false\n"
+)
+line_start, substr = locate_last_run_line(confusing_multiple)
+self.assertEqual(line_start, confusing_multiple.rfind("+ :"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_confusing_varying_prefix_1(self):
+# from a script like
+# RUN: echo 'RUN: at line 10' 1>&2
+# RUN: false
+#
+# in a hypothetical shell which prints line-numbers on 'set +x'
+# (as an example of something that varies)
+confusing_varying_prefix = (
+"+ 1 : 'RUN: at line 1'\n"
+"+ 2 echo 'RUN: at line 10'\n"
+"RUN: at line 10\n"
+"+ 3 : 'RUN: at line 2'\n"
+"+ 4 false\n"
+)
+line_start, substr = locate_last_run_line(confusing_varying_prefix)
+self.assertEqual(line_start, confusing_varying_prefix.rfind("+ 3"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_confusing_varying_prefix_2(self):
+# from a script like
+# RUN: true
+# RUN: not echo 'RUN: at line 100'
+#
+# in a hypothetical shell which prints line-numbers on 'set +x'
+# (as an example of something that varies)
+confusing_varying_prefix = (
+"+ 1 : 'RUN: at line 1'\n"
+"+ 2 true\n"
+"+ 3 : 'RUN: at line 2'\n"
+"+ 4 not echo 'RUN: at line 100'\n"
+"+ RUN: 

[PATCH] D82807: [clang-tidy] Allows the prevailing include header guard in Flang ...

2020-06-29 Thread Eric Schweitz via Phabricator via cfe-commits
schweitz updated this revision to Diff 274278.

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

https://reviews.llvm.org/D82807

Files:
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp


Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang") - 1);
+
   return StringRef(Guard).upper();
 }
 


Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang") - 1);
+
   return StringRef(Guard).upper();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4d1b7e9 - Fix a few cases that were incorrectly parsed as unary-expressions

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

Author: Richard Smith
Date: 2020-06-29T14:33:21-07:00
New Revision: 4d1b7e9820ee9c87541619ce4dd41e92dc43cd9c

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

LOG: Fix a few cases that were incorrectly parsed as unary-expressions
instead of postfix-expressions, and improve error recovery for postfix
operators after unary-expressions.

This covers nullptr, __null, and some calls to type traits with special
parsing rules. We would previously not parse a postfix-expression suffix
for these expressions, so would reject expressions such as
__is_trivial(int)["foo"].

For the case where a postfix-expression suffix is *not* permitted after
a unary-expression (for example, after a new-expression or sizeof
expression), produce a diagnostic if one appears there anyway. That's
always ill-formed, but previously produced very bad diagnostics.

Added: 
clang/test/Parser/expressions.cpp

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

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 5d57cfd6e71d..f5b32a6ba5fa 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -194,6 +194,8 @@ def err_function_declared_typedef : Error<
 def err_at_defs_cxx : Error<"@defs is not supported in Objective-C++">;
 def err_at_in_class : Error<"unexpected '@' in member specification">;
 def err_unexpected_semi : Error<"unexpected ';' before %0">;
+def err_postfix_after_unary_requires_parens : Error<
+  "expression cannot be followed by a postfix %0 operator; add parentheses">;
 def err_unparenthesized_non_primary_expr_in_requires_clause : Error<
   "parentheses are required around this expression in a requires clause">;
 def note_unparenthesized_non_primary_expr_in_requires_clause : Note<

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index bd003204a97c..bfc465f89628 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -920,6 +920,11 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   auto SavedType = PreferredType;
   NotCastExpr = false;
 
+  // Are postfix-expression suffix operators permitted after this
+  // cast-expression? If not, and we find some, we'll parse them anyway and
+  // diagnose them.
+  bool AllowSuffix = true;
+
   // This handles all of cast-expression, unary-expression, postfix-expression,
   // and primary-expression.  We handle them together like this for efficiency
   // and to simplify handling of an expression starting with a '(' token: which
@@ -929,8 +934,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   // If the parsed tokens consist of a primary-expression, the cases below
   // break out of the switch;  at the end we call ParsePostfixExpressionSuffix
   // to handle the postfix expression suffixes.  Cases that cannot be followed
-  // by postfix exprs should return without invoking
-  // ParsePostfixExpressionSuffix.
+  // by postfix exprs should set AllowSuffix to false.
   switch (SavedKind) {
   case tok::l_paren: {
 // If this expression is limited to being a unary-expression, the paren can
@@ -953,8 +957,11 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
 Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
isTypeCast == IsTypeCast, CastTy, RParenLoc);
 
+// FIXME: What should we do if a vector literal is followed by a
+// postfix-expression suffix? Usually postfix operators are permitted on
+// literals.
 if (isVectorLiteral)
-return Res;
+  return Res;
 
 switch (ParenExprType) {
 case SimpleExpr:   break;// Nothing else to do.
@@ -992,11 +999,13 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
 
   case tok::kw___objc_yes:
   case tok::kw___objc_no:
-  return ParseObjCBoolLiteral();
+Res = ParseObjCBoolLiteral();
+break;
 
   case tok::kw_nullptr:
 Diag(Tok, diag::warn_cxx98_compat_nullptr);
-return Actions.ActOnCXXNullPtrLiteral(ConsumeToken());
+Res = Actions.ActOnCXXNullPtrLiteral(ConsumeToken());
+break;
 
   case tok::annot_uneval_primary_expr:
   case tok::annot_primary_expr:
@@ -1295,7 +1304,8 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
 Res = ParseGenericSelectionExpression();
 break;
   case tok::kw___builtin_available:
-return ParseAvailabilityCheckExpr(Tok.getLocation());
+Res = ParseAvailabilityCheckExpr(Tok.getLocation());
+break;
   case tok::kw___builtin_va_arg:
   case tok::kw___builtin_offsetof:
   case tok::kw___builtin_choose_expr:
@@ -1307,9 +1317,11 @@ 

[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-06-29 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 274260.
amyk added a comment.

Updated the patch to move the MC/llc tests into the appropriate files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
  llvm/test/MC/Disassembler/PowerPC/vsx.txt
  llvm/test/MC/PowerPC/vsx.s

Index: llvm/test/MC/PowerPC/vsx.s
===
--- llvm/test/MC/PowerPC/vsx.s
+++ llvm/test/MC/PowerPC/vsx.s
@@ -1008,3 +1008,17 @@
 # CHECK-BE: xvtlsbb 1, 7   # encoding: [0xf0,0x82,0x3f,0x6c]
 # CHECK-LE: xvtlsbb 1, 7   # encoding: [0x6c,0x3f,0x82,0xf0]
 xvtlsbb 1, 7
+
+#  Store VSX Vector Rightmost
+# CHECK-BE: stxvrbx 32, 3, 1   # encoding: [0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1   # encoding: [0x1b,0x09,0x03,0x7c]
+stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1   # encoding: [0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1   # encoding: [0x5b,0x09,0x23,0x7c]
+stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1   # encoding: [0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1   # encoding: [0x9b,0x09,0x43,0x7c]
+stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1   # encoding: [0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1   # encoding: [0xdb,0x09,0x63,0x7c]
+stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/vsx.txt
===
--- llvm/test/MC/Disassembler/PowerPC/vsx.txt
+++ llvm/test/MC/Disassembler/PowerPC/vsx.txt
@@ -879,3 +879,15 @@
 
 # CHECK-P10: xvtlsbb 1, 7
 0xf0 0x82 0x3f 0x6c
+
+# CHECK-P10: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK-P10: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK-P10: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK-P10: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -33,3 +33,113 @@
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 0)
   ret i32 %0
 }
+
+define void @vec_xst_trunc_sc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_sc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_uc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_uc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_ss(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_ss:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_us(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_us:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_si(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_si:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 2
+; CHECK-NEXT:stxvrwx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <4 x i32>
+  %conv = extractelement <4 x i32> %0, i32 0
+  %add.ptr = getelementptr inbounds i32, i32* %__ptr, i64 %__offset
+  store i32 %conv, i32* %add.ptr, align 4
+  ret void
+}
+
+define void @vec_xst_trunc_ui(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_ui:
+; 

[PATCH] D82805: [clang] Fix a crash on passing C structure of incompatible type to function with reference parameter

2020-06-29 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked an inline comment as done.
ArcsinX added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4539
+if (CXXRecordDecl *T2RecordDecl =
+dyn_cast(T2RecordType->getDecl())) {
+  const auto  = T2RecordDecl->getVisibleConversionFunctions();

riccibruno wrote:
> I cannot reproduce this with the provided test case. Can you explain why 
> `T2RecordDecl` would not be a `CXXRecordDecl` since we should only get there 
> with c++?
You can reproduce it with
```
bin/clang -xc --target=arm-unknown-gnu -c ../clang/test/Sema/init-ref-c.c
```

We can get there with C in case of using builtins declared as functions with 
reference parameters (e.g. `__builtin_va_end()`)


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

https://reviews.llvm.org/D82805



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


[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-06-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 274255.

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

https://reviews.llvm.org/D79219

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/test/lit.common.configured.in
  lld/CMakeLists.txt
  lld/test/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/cmake/config-ix.cmake
  llvm/include/llvm/Config/config.h.cmake
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 
 void TestZlibCompression(StringRef Input, int Level) {
   SmallString<32> Compressed;
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -33,7 +33,7 @@
 config.host_ldflags = '@HOST_LDFLAGS@'
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_libxar = @HAVE_LIBXAR@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
Index: llvm/test/CMakeLists.txt
===
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -1,12 +1,12 @@
 llvm_canonicalize_cmake_booleans(
   BUILD_SHARED_LIBS
   HAVE_LIBXAR
-  HAVE_LIBZ
   HAVE_OCAMLOPT
   HAVE_OCAML_OUNIT
   LLVM_ENABLE_DIA_SDK
   LLVM_ENABLE_FFI
   LLVM_ENABLE_THREADS
+  LLVM_ENABLE_ZLIB
   LLVM_INCLUDE_GO_TESTS
   LLVM_LIBXML2_ENABLED
   LLVM_LINK_LLVM_DYLIB
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -17,13 +17,13 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
+#if LLVM_ENABLE_ZLIB
 #include 
 #endif
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 static Error createError(StringRef Err) {
   return make_error(Err, inconvertibleErrorCode());
 }
Index: llvm/lib/Support/CRC.cpp
===
--- llvm/lib/Support/CRC.cpp
+++ llvm/lib/Support/CRC.cpp
@@ -25,7 +25,7 @@
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 0 || !HAVE_ZLIB_H
+#if !LLVM_ENABLE_ZLIB
 
 static const uint32_t CRCTable[256] = {
 0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -1,7 +1,7 @@
-set(system_libs)
-if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
-  set(system_libs ${system_libs} ${ZLIB_LIBRARIES})
+if(LLVM_ENABLE_ZLIB)
+  set(imported_libs ZLIB::ZLIB)
 endif()
+
 if( MSVC OR MINGW )
   # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
   # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
@@ -194,10 +194,34 @@
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
   ${Backtrace_INCLUDE_DIRS}
-  LINK_LIBS ${system_libs} ${delayload_flags} ${Z3_LINK_FILES}
+  LINK_LIBS ${system_libs} ${imported_libs} ${delayload_flags} ${Z3_LINK_FILES}
   )
 
-set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
+set(llvm_system_libs ${system_libs})
+
+if(LLVM_ENABLE_ZLIB)
+  string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
+  get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
+  if(NOT zlib_library)
+get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
+  endif()
+  get_filename_component(zlib_library ${zlib_library} NAME)
+  if(CMAKE_STATIC_LIBRARY_PREFIX AND zlib_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*")
+STRING(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+  endif()
+  if(CMAKE_STATIC_LIBRARY_SUFFIX AND zlib_library MATCHES ".*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+STRING(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
+  endif()
+  if(CMAKE_SHARED_LIBRARY_PREFIX AND zlib_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*")
+STRING(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+  endif()
+  

[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-06-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek marked an inline comment as done.
phosek added inline comments.



Comment at: llvm/cmake/config-ix.cmake:514
+  if(ZLIB_FOUND)
+set(LLVM_ENABLE_ZLIB "YES" CACHE STRING
+  "Use zlib for compression/decompression if available. Can be ON, OFF, or 
FORCE_ON"

labath wrote:
> JDevlieghere wrote:
> > phosek wrote:
> > > JDevlieghere wrote:
> > > > If I understand correctly, after running the configuration phase with 
> > > > LLVM_ENABLE_ZLIB to FORCE_ON, the cached value will be overwritten by 
> > > > ON? 
> > > Correct, we used `FORCE_ON` above when invoking `find_package` setting 
> > > `REQUIRED` which makes the check fail if the library is missing. 
> > > Recording this information is important for LLVM consumers because it'll 
> > > be stored in `LLVMConfig.cmake` and AFAIU we don't want to propagate 
> > > `FORCE_ON` there.
> > I get that. My worry is that if for whatever reason the library disappears 
> > (system upgrade, package removal, ...) this will silently disable ZLIB 
> > support because now LLVM_ENABLE_ZLIB just equals on. This might sound far 
> > fetched, but happens all the time with "internal installs". This is why I 
> > prefer the ON/OFF/Auto approach because it doesn't update the cache 
> > variable, but would set the internal variable to either ON or OFF.
> I agree with Jonas, though I don't think the actual values (FORCE_ON/ON vs. 
> ON/Auto) really matter here. The important part is not overwriting the cache 
> variables specified by the user, as that can create various problems with 
> reconfigurations (like the zlib becoming unavailable example).
I've updated the change to shadow the variable as suggested by Jonas.


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

https://reviews.llvm.org/D79219



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


[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-06-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 274256.

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

https://reviews.llvm.org/D79219

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/test/lit.common.configured.in
  lld/CMakeLists.txt
  lld/test/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/cmake/config-ix.cmake
  llvm/include/llvm/Config/config.h.cmake
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 
 void TestZlibCompression(StringRef Input, int Level) {
   SmallString<32> Compressed;
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -33,7 +33,7 @@
 config.host_ldflags = '@HOST_LDFLAGS@'
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_libxar = @HAVE_LIBXAR@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
Index: llvm/test/CMakeLists.txt
===
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -1,12 +1,12 @@
 llvm_canonicalize_cmake_booleans(
   BUILD_SHARED_LIBS
   HAVE_LIBXAR
-  HAVE_LIBZ
   HAVE_OCAMLOPT
   HAVE_OCAML_OUNIT
   LLVM_ENABLE_DIA_SDK
   LLVM_ENABLE_FFI
   LLVM_ENABLE_THREADS
+  LLVM_ENABLE_ZLIB
   LLVM_INCLUDE_GO_TESTS
   LLVM_LIBXML2_ENABLED
   LLVM_LINK_LLVM_DYLIB
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -17,13 +17,13 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
+#if LLVM_ENABLE_ZLIB
 #include 
 #endif
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 static Error createError(StringRef Err) {
   return make_error(Err, inconvertibleErrorCode());
 }
Index: llvm/lib/Support/CRC.cpp
===
--- llvm/lib/Support/CRC.cpp
+++ llvm/lib/Support/CRC.cpp
@@ -25,7 +25,7 @@
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 0 || !HAVE_ZLIB_H
+#if !LLVM_ENABLE_ZLIB
 
 static const uint32_t CRCTable[256] = {
 0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -1,7 +1,7 @@
-set(system_libs)
-if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
-  set(system_libs ${system_libs} ${ZLIB_LIBRARIES})
+if(LLVM_ENABLE_ZLIB)
+  set(imported_libs ZLIB::ZLIB)
 endif()
+
 if( MSVC OR MINGW )
   # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
   # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
@@ -194,10 +194,34 @@
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
   ${Backtrace_INCLUDE_DIRS}
-  LINK_LIBS ${system_libs} ${delayload_flags} ${Z3_LINK_FILES}
+  LINK_LIBS ${system_libs} ${imported_libs} ${delayload_flags} ${Z3_LINK_FILES}
   )
 
-set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
+set(llvm_system_libs ${system_libs})
+
+if(LLVM_ENABLE_ZLIB)
+  string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
+  get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
+  if(NOT zlib_library)
+get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
+  endif()
+  get_filename_component(zlib_library ${zlib_library} NAME)
+  if(CMAKE_STATIC_LIBRARY_PREFIX AND zlib_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*")
+STRING(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+  endif()
+  if(CMAKE_STATIC_LIBRARY_SUFFIX AND zlib_library MATCHES ".*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+STRING(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
+  endif()
+  if(CMAKE_SHARED_LIBRARY_PREFIX AND zlib_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*")
+STRING(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+  endif()
+  

[PATCH] D82823: canonicalize macOS 10.16 availability to macOS 11 while preserving uses of if @available macOS 10.16

2020-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: erik.pilkington, steven_wu.
Herald added subscribers: ributzka, dexonsmith, jkorous.
Herald added a reviewer: aaron.ballman.

This patch canonicalizes the macOS versions in the `availability`, so that 
clang can treat macOS 10.16 availability as macOS 11 availability. The `if 
(@available (macOS 10.16, *)` checks still preserve their original version in 
the generated code to ensure that the software running on macOS Big Sur Beta 1 
can still exhibits the expected runtime behavior for the `10.16` availability 
checks.


https://reviews.llvm.org/D82823

Files:
  clang/include/clang/AST/ExprObjC.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CodeGen/attr-availability-new.c
  clang/test/CodeGenObjC/availability-check.m
  clang/test/Sema/attr-availability-macos-new.c

Index: clang/test/Sema/attr-availability-macos-new.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-macos-new.c
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-macos10.15" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-macos11" -DNEW -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin20" -DNEW -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-macos10.15" -fsyntax-only -verify -fapplication-extension -DAPP_EXT %s
+
+__attribute__((availability(macos,strict,introduced=10.16)))
+void fNew1();
+#ifndef NEW
+// expected-note@-2 {{here}}
+#endif
+
+__attribute__((availability(macosx,strict,introduced=10.16)))
+void fNew();
+
+__attribute__((availability(macos,strict,introduced=11)))
+void fNew() { }
+#ifndef NEW
+// expected-note@-2 {{here}}
+#endif
+
+__attribute__((availability(macosx,strict,deprecated=10.16)))
+void fDep();
+
+__attribute__((availability(macos,strict,deprecated=11)))
+void fDep() { }
+#ifdef NEW
+// expected-note@-2 {{here}}
+#endif
+
+__attribute__((availability(macosx,strict,obsoleted=10.16)))
+void fObs();
+
+__attribute__((availability(macos,strict,obsoleted=11)))
+void fObs() { }
+#ifdef NEW
+// expected-note@-2 {{here}}
+#endif
+
+__attribute__((availability(macosx_app_extension,strict,introduced=10.16)))
+void fAppExt();
+
+__attribute__((availability(macos_app_extension,strict,introduced=11)))
+void fAppExt() { }
+#ifdef APP_EXT
+// expected-note@-2 {{here}}
+#endif
+
+void testVersionRemapping() {
+  fNew1();
+#ifndef NEW
+  // expected-error@-2 {{'fNew1' is unavailable: introduced in macOS 11.0}}
+#endif
+  fNew();
+#ifndef NEW
+  // expected-error@-2 {{'fNew' is unavailable: introduced in macOS 11}}
+#endif
+  fDep();
+#ifdef NEW
+  // expected-warning@-2 {{'fDep' is deprecated: first deprecated in macOS 11}}
+#endif
+  fObs();
+#ifdef NEW
+  // expected-error@-2 {{'fObs' is unavailable: obsoleted in macOS 11}}
+#endif
+
+  fAppExt();
+#ifdef APP_EXT
+  // expected-error@-2 {{'fAppExt' is unavailable: introduced in macOS (App Extension) 11}}
+#endif
+}
+
+__attribute__((availability(macosx,strict,introduced=10.16.1))) // expected-note {{here}}
+void fMatchErr();
+
+__attribute__((availability(macos,strict,introduced=11))) // expected-warning {{availability does not match previous declaration}}
+void fMatchErr() { }
+
+__attribute__((availability(macosx_app_extension,strict,introduced=10.16))) // expected-note {{here}}
+void fAppExtErr();
+
+__attribute__((availability(macos_app_extension,strict,introduced=11.1))) // expected-warning {{availability does not match previous declaration}}
+void fAppExtErr() { }
+
+__attribute__((availability(macos,introduced=11)))
+void fNew2();
+#ifndef NEW
+  // expected-note@-2 {{'fNew2' has been marked as being introduced in macOS 11 here, but the deployment target is macOS 10.15.0}}
+#endif
+__attribute__((availability(macos,introduced=10.16)))
+void fNew3();
+
+__attribute__((availability(macos,introduced=12)))
+void evenNewer();
+#ifdef NEW
+  // expected-note@-2 {{'evenNewer' has been marked as being introduced in macOS 12 here, but the deployment target is macOS 11.0.0}}
+#endif
+
+void testAvailabilityCheck() {
+  if (__builtin_available(macOS 10.16, *)) {
+fNew2();
+fNew3();
+  }
+  if (__builtin_available(macOS 11, *)) {
+fNew2();
+fNew3();
+  }
+  fNew2();
+#ifndef NEW
+  // expected-warning@-2 {{'fNew2' is only available on macOS 11 or newer}} expected-note@-2 {{enclose}}
+#endif
+#ifdef NEW
+  evenNewer(); // expected-warning {{'evenNewer' is only available on macOS 12 or newer}} expected-note {{enclose}}
+#endif
+}
+
+
Index: clang/test/CodeGenObjC/availability-check.m
===
--- clang/test/CodeGenObjC/availability-check.m
+++ clang/test/CodeGenObjC/availability-check.m
@@ -26,6 +26,15 @@
   // CHECK: br i1 true
   if 

[PATCH] D82733: [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you for adding this!

In D82733#2121414 , @phil-blain wrote:

> I tested the sphinx build for the `man` and `html` targets. Any other targets 
> I should check ?


No, that sounds good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82733



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


[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

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



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:282
+  IRBuilder<> AllocaBuilder;
+
   /// Map to remember source location strings

fghanim wrote:
> jdoerfert wrote:
> > fghanim wrote:
> > > jdoerfert wrote:
> > > > fghanim wrote:
> > > > > What's the benefit of this over just maintaining an alloca insertion 
> > > > > point?
> > > > > 
> > > > > With this we will have 3 `IRBuilder`s to maintain and keep track of: 
> > > > > the clang (or flang) `IRBuilder`, the OMP `IRBuilder` and the 
> > > > > `allocaBuilder`
> > > > No functional difference. Basically the same reason why clang has an 
> > > > AllocIRBuilder (I think), we can use it independently of the other one. 
> > > > The alternative is to save the builder IP, set it to the alloca IP, do 
> > > > alloca stuff, reset the builder IP, when you use the AllocaIRBuilder 
> > > > below. Again, no functional difference, just less setting/resetting of 
> > > > IPs.
> > > I understand where you are coming from, and I understand that 
> > > functionally there is mostly no change - for now. But I prefer we do a 
> > > small struct with some RAII, over adding an entire builder. I think it's 
> > > a bit overkill and will be a source to lots of trouble.
> > > 
> > > Clang maintains an instruction `AllocaInsertPt`, not a specific builder. 
> > > Speaking of which, This is completely from memory (i.e. check to make 
> > > sure); I think we already save the previous `AllocaInsertionPt` in clang 
> > > as part of the `bodyGenCB`. In which case, this is not needed; a nested 
> > > `parallel` will always be generated by clang as part of the `bodyGenCB`, 
> > > which in turn is going to save the Alloca insertion point for us. 
> > > To enable the creation of the allocas for `TID` and `ZeroAddr` in the 
> > > outer function, Why not pass current `AllocaInsertionPt` as an arg. to 
> > > `createParallel`
> > > I understand where you are coming from, and I understand that 
> > > functionally there is mostly no change - for now. But I prefer we do a 
> > > small struct with some RAII, over adding an entire builder. I think it's 
> > > a bit overkill and will be a source to lots of trouble.
> > 
> > Could you explain what kind of overkill you see here? And maybe also the 
> > lots of trouble you expect from a builder versus a insertion point? It is 
> > the same information, just packed in a different struct, right?
> > 
> > 
> > > Clang maintains an instruction AllocaInsertPt, not a specific builder. 
> > 
> > Right.
> > 
> > 
> > > Speaking of which, This is completely from memory (i.e. check to make 
> > > sure); I think we already save the previous AllocaInsertionPt in clang as 
> > > part of the bodyGenCB. 
> > 
> > I think so.
> > 
> > 
> > > In which case, this is not needed; 
> > 
> > Not strictly, no. 
> > 
> > > a nested parallel will always be generated by clang as part of the 
> > > bodyGenCB,
> > 
> > Yes.
> > 
> > > which in turn is going to save the Alloca insertion point for us.
> > 
> > Yes.
> > 
> > > To enable the creation of the allocas for TID and ZeroAddr in the outer 
> > > function, Why not pass current AllocaInsertionPt as an arg. to 
> > > createParallel
> > 
> > So far, because this will not be the only one that needs to create allocas. 
> > If you want to add the allocaIP to all runtime calls that create allocas, 
> > I'm fine with that too.
> > Could you explain what kind of overkill you see here?
> Using an IRBuilder when an insertion point suffices
> 
> > And maybe also the lots of trouble you expect from a builder versus a 
> > insertion point?
> Currently, when using the OMPBuilder you need to juggle two IRBuilders, let's 
> not make them 3 :)
> 
> > It is the same information, just packed in a different struct, right?
> no it is not. `InsetrionPoint` vs  struct that contains `Insertionpoint` + 
> other things. But that's beside the point
> 
> I mean, is the `AllocaBuilder` providing a new functionality other than a 
> convenient way to keep track of the Alloca `InsertionPoint`?
> Personally, I prefer some suitable structure to your needs and a stack (i.e. 
> the way clang does it) . This should also resolve the todo below. 
> Alternatively, pass an allocation point as an argument as suggested earlier. 
> I am open to any third way if you have any.
> Personally, I prefer some suitable structure to your needs and a stack (i.e. 
> the way clang does it).

The stack is already here, implicitly, and actually on the stack. With
`IRBuilder<>::InsertPointGuard AIPG(AllocaBuilder);`
we have all the stack we need without leaking the state.
The updates to the insertion point are done for use and the AllocaBuilder is 
always ready to be used. No need to create a builder or update an insertion 
point (other than the places that create the new alloca insertion points). Note 
that the suitable structure is the builder, as it is the 

[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-06-29 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

@milianw could you try to reduce the reproducer you have? Maybe take lldb and 
see where does the `nullptr` come from?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[clang] 4772b99 - Clang Driver: refactor support for writing response files to be

2020-06-29 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2020-06-29T18:27:02-04:00
New Revision: 4772b99dffec4f87bb7bc9273495066058ac0186

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

LOG: Clang Driver: refactor support for writing response files to be
specified at Command creation, rather than as part of the Tool.

This resolves the hack I just added to allow Darwin toolchain to vary
its level of support based on `-mlinker-version=`.

The change preserves the _current_ settings for response-file support.
Some tools look likely to be declaring that they don't support
response files in error, however I kept them as-is in order for this
change to be a simple refactoring.

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

Added: 


Modified: 
clang/include/clang/Driver/Job.h
clang/include/clang/Driver/Tool.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/Job.cpp
clang/lib/Driver/Tool.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/AVR.h
clang/lib/Driver/ToolChains/Ananas.cpp
clang/lib/Driver/ToolChains/Ananas.h
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/lib/Driver/ToolChains/CloudABI.cpp
clang/lib/Driver/ToolChains/CloudABI.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CrossWindows.cpp
clang/lib/Driver/ToolChains/CrossWindows.h
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Cuda.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/DragonFly.cpp
clang/lib/Driver/ToolChains/DragonFly.h
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Driver/ToolChains/Hexagon.h
clang/lib/Driver/ToolChains/InterfaceStubs.cpp
clang/lib/Driver/ToolChains/MSP430.cpp
clang/lib/Driver/ToolChains/MSP430.h
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/MinGW.h
clang/lib/Driver/ToolChains/Minix.cpp
clang/lib/Driver/ToolChains/Minix.h
clang/lib/Driver/ToolChains/Myriad.cpp
clang/lib/Driver/ToolChains/Myriad.h
clang/lib/Driver/ToolChains/NaCl.cpp
clang/lib/Driver/ToolChains/NaCl.h
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/NetBSD.h
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.h
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/lib/Driver/ToolChains/PS4CPU.h
clang/lib/Driver/ToolChains/RISCVToolchain.cpp
clang/lib/Driver/ToolChains/RISCVToolchain.h
clang/lib/Driver/ToolChains/Solaris.cpp
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/lib/Driver/ToolChains/WebAssembly.h
clang/lib/Driver/ToolChains/XCore.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 1c6ea6971919..6173b9d314b4 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/Program.h"
 #include 
 #include 
 #include 
@@ -36,6 +37,69 @@ struct CrashReportInfo {
   : Filename(Filename), VFSPath(VFSPath) {}
 };
 
+// Encodes the kind of response file supported for a command invocation.
+// Response files are necessary if the command line gets too large, requiring
+// the arguments to be transferred to a file.
+struct ResponseFileSupport {
+  enum ResponseFileKind {
+// Provides full support for response files, which means we can transfer
+// all tool input arguments to a file.
+RF_Full,
+// Input file names can live in a file, but flags can't. This is a special
+// case for old versions of Apple's ld64.
+RF_FileList,
+// Does not support response files: all arguments must be passed via
+// command line.
+RF_None
+  };
+  /// The level of support for response files.
+  ResponseFileKind ResponseKind;
+
+  /// The encoding to use when writing response files on Windows. Ignored on
+  /// other host OSes.
+  ///
+  /// Windows use cases: - GCC and Binutils on mingw only accept ANSI response
+  /// files encoded with the system current code 

[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-29 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 274276.
zixuw added a comment.

Abort the design of making 'Wundef' an alias to 'Wundef-prefix' because it
depends on the alias expansion to work, which adds an empty string to 
'UndefPrefixes'
to do the trick. However, any other way to enable 'Wundef', for example, via 
'Werror=undef'
or '#pragma clang diagnostic', will not work and cannot be handled easily.

Instead, just suppress 'Wundef-prefix' when 'Wundef' is enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify=undef
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify=undef-prefix
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A,BC -verify=both
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify=undef-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef-prefix -Wundef-prefix=A,BC -verify=undef-prefix-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -Wundef-prefix=A,BC -verify=both-error
+
+extern int x;
+
+#if AB // #1
+#endif
+// undef-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// both-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// both-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+
+#if B // #2
+#endif
+// undef-warning@#2 {{'B' is not defined, evaluates to 0}}
+// no warning for undef-prefix
+// both-warning@#2 {{'B' is not defined, evaluates to 0}}
+// undef-error-error@#2 {{'B' is not defined, evaluates to 0}}
+// no error for undef-prefix
+// both-error-error@#2 {{'B' is not defined, evaluates to 0}}
+
+#define BC 0
+#if BC // no warning/error
+#endif
+
+#undef BC
+#if BC // #3
+#endif
+// undef-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// both-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// both-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+
+// Test that #pragma-enabled 'Wundef' can override 'Wundef-prefix'
+#pragma clang diagnostic error "-Wundef"
+
+#if C // #4
+#endif
+// undef-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-prefix-error@#4 {{'C' is not defined, evaluates to 0}}
+// both-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-error-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#4 {{'C' is not defined, evaluates to 0}}
+// both-error-error@#4 {{'C' is not defined, evaluates to 0}}
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -15,7 +15,6 @@
 //
 //===--===//
 
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -26,9 +25,12 @@
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -251,8 +253,24 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
+if (ValueLive) {
   PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+
+  const DiagnosticsEngine  = PP.getDiagnostics();
+  // If 'Wundef' is enabled, do not emit 'undef-prefix' diagnostics.
+  if (DiagEngine.isIgnored(diag::warn_pp_undef_identifier,
+   PeekTok.getLocation())) {
+const std::vector UndefPrefixes =
+DiagEngine.getDiagnosticOptions().UndefPrefixes;
+const StringRef IdentifierName = II->getName();
+if (llvm::any_of(UndefPrefixes,
+ [](const std::string ) 

[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-06-29 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 274275.
cchen added a comment.

1. Remove a commit that is not on master branch
2. Add a rule in Sema to avoid non-contiguous array section for map clause
3. Add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/target_data_messages.c
  clang/test/OpenMP/target_depend_messages.cpp
  clang/test/OpenMP/target_enter_data_depend_messages.cpp
  clang/test/OpenMP/target_exit_data_depend_messages.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_depend_messages.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/task_affinity_messages.cpp
  clang/test/OpenMP/task_depend_messages.cpp

Index: clang/test/OpenMP/task_depend_messages.cpp
===
--- clang/test/OpenMP/task_depend_messages.cpp
+++ clang/test/OpenMP/task_depend_messages.cpp
@@ -52,7 +52,7 @@
   #pragma omp task depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
   #pragma omp task depend (in : argv[-1:0]) // expected-error {{zero-length array section is not allowed in 'depend' clause}}
   #pragma omp task depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
-  #pragma omp task depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
+  #pragma omp task depend (in : argv[3:4:1]) // omp45-error {{expected ']'}} omp45-note {{to match this '['}}
   #pragma omp task depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
   #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
   #pragma omp task depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
Index: clang/test/OpenMP/task_affinity_messages.cpp
===
--- clang/test/OpenMP/task_affinity_messages.cpp
+++ clang/test/OpenMP/task_affinity_messages.cpp
@@ -44,7 +44,7 @@
   #pragma omp task affinity (argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
   #pragma omp task affinity (argv[-1:0])
   #pragma omp task affinity (argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
-  #pragma omp task affinity (argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
+  #pragma omp task affinity (argv[3:4:1])
   #pragma omp task affinity(a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
   #pragma omp task affinity(argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
   #pragma omp task affinity(argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: 

[clang] 381df16 - Clang Driver: Use Apple ld64's new @response-file support.

2020-06-29 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2020-06-29T18:26:53-04:00
New Revision: 381df1653c927efa9dac86c24a9db2b98f270de0

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

LOG: Clang Driver: Use Apple ld64's new @response-file support.

In XCode 12, ld64 got support for @files, in addition to the old
-filelist mechanism. Response files allow passing all command-line
arguments to the linker via a file, rather than just filenames, and is
therefore preferred.

Because of the way response-file support is currently implemented as
part of the Tool class in Clang, this change requires an ugly backdoor
function to access Args. A follow-up commit fixes this, but I've
ordered this change first, for easier backportability.

I've added no tests here, because unfortunately, there don't appear to
be _any_ response-file emission automated tests, and I don't see an
obvious way to add them. I've tested that this change works as
expected locally.

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 7495e08fe6e6..0d3727b4ab8d 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -201,6 +201,9 @@ class ToolChain {
 
   // Accessors
 
+  /// Temporary for Darwin::Linker
+  const llvm::opt::ArgList _DO_NOT_USE() const { return Args; }
+
   const Driver () const { return D; }
   llvm::vfs::FileSystem () const;
   const llvm::Triple () const { return Triple; }

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 47bf036d24d8..81b5576096e4 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -929,7 +929,22 @@ Tool *MachO::getTool(Action::ActionClass AC) const {
   }
 }
 
-Tool *MachO::buildLinker() const { return new tools::darwin::Linker(*this); }
+Tool *MachO::buildLinker() const {
+  // Determine whether to use an @responsefile or the old -filelist mechanism.
+  bool UseAtFile = false;
+  unsigned Version[5] = {0, 0, 0, 0, 0};
+  if (Arg *A =
+  getArgs_DO_NOT_USE().getLastArg(options::OPT_mlinker_version_EQ)) {
+// We don't need to diagnose a parse error here, it'll be caught in
+// ConstructJob.
+if (Driver::GetReleaseVersion(A->getValue(), Version)) {
+  if (Version[0] >= 607)
+UseAtFile = true;
+}
+  }
+
+  return new tools::darwin::Linker(*this, UseAtFile);
+}
 
 Tool *MachO::buildAssembler() const {
   return new tools::darwin::Assembler(*this);

diff  --git a/clang/lib/Driver/ToolChains/Darwin.h 
b/clang/lib/Driver/ToolChains/Darwin.h
index 04c5bfa69a5a..5f13aa9a3087 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -69,9 +69,10 @@ class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
const InputInfoList ) const;
 
 public:
-  Linker(const ToolChain )
-  : MachOTool("darwin::Linker", "linker", TC, RF_FileList,
-  llvm::sys::WEM_UTF8, "-filelist") {}
+  Linker(const ToolChain , bool UseAtFile)
+  : MachOTool("darwin::Linker", "linker", TC,
+  UseAtFile ? RF_Full : RF_FileList, llvm::sys::WEM_UTF8,
+  UseAtFile ? "@" : "-filelist") {}
 
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }



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


[PATCH] D82805: [clang] Fix a crash on passing C structure of incompatible type to function with reference parameter

2020-06-29 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 274250.
ArcsinX added a comment.

Fix format


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

https://reviews.llvm.org/D82805

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-ref-c.c


Index: clang/test/Sema/init-ref-c.c
===
--- /dev/null
+++ clang/test/Sema/init-ref-c.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
+
+void f() {
+  struct EmptyStruct {};
+  struct EmptyStruct S;
+  __builtin_va_end(S); // no-crash, expected-error {{non-const lvalue 
reference to type '__builtin_va_list' cannot bind to a value of unrelated type 
'struct EmptyStruct'}}
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4535,39 +4535,41 @@
   S.isCompleteType(Kind.getLocation(), T2)) {
 // The type we're converting from is a class type, enumerate its conversion
 // functions.
-CXXRecordDecl *T2RecordDecl = cast(T2RecordType->getDecl());
-
-const auto  = T2RecordDecl->getVisibleConversionFunctions();
-for (auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
-  NamedDecl *D = *I;
-  CXXRecordDecl *ActingDC = cast(D->getDeclContext());
-  if (isa(D))
-D = cast(D)->getTargetDecl();
-
-  FunctionTemplateDecl *ConvTemplate = dyn_cast(D);
-  CXXConversionDecl *Conv;
-  if (ConvTemplate)
-Conv = cast(ConvTemplate->getTemplatedDecl());
-  else
-Conv = cast(D);
-
-  // If the conversion function doesn't return a reference type,
-  // it can't be considered for this conversion unless we're allowed to
-  // consider rvalues.
-  // FIXME: Do we need to make sure that we only consider conversion
-  // candidates with reference-compatible results? That might be needed to
-  // break recursion.
-  if ((AllowRValues ||
-   Conv->getConversionType()->isLValueReferenceType())) {
+if (CXXRecordDecl *T2RecordDecl =
+dyn_cast(T2RecordType->getDecl())) {
+  const auto  = T2RecordDecl->getVisibleConversionFunctions();
+  for (auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
+NamedDecl *D = *I;
+CXXRecordDecl *ActingDC = cast(D->getDeclContext());
+if (isa(D))
+  D = cast(D)->getTargetDecl();
+
+FunctionTemplateDecl *ConvTemplate = dyn_cast(D);
+CXXConversionDecl *Conv;
 if (ConvTemplate)
-  S.AddTemplateConversionCandidate(
-  ConvTemplate, I.getPair(), ActingDC, Initializer, DestType,
-  CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, AllowExplicitConvs);
+  Conv = cast(ConvTemplate->getTemplatedDecl());
 else
-  S.AddConversionCandidate(
-  Conv, I.getPair(), ActingDC, Initializer, DestType, CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, AllowExplicitConvs);
+  Conv = cast(D);
+
+// If the conversion function doesn't return a reference type,
+// it can't be considered for this conversion unless we're allowed to
+// consider rvalues.
+// FIXME: Do we need to make sure that we only consider conversion
+// candidates with reference-compatible results? That might be needed
+// to break recursion.
+if ((AllowRValues ||
+ Conv->getConversionType()->isLValueReferenceType())) {
+  if (ConvTemplate)
+S.AddTemplateConversionCandidate(
+ConvTemplate, I.getPair(), ActingDC, Initializer, DestType,
+CandidateSet,
+/*AllowObjCConversionOnExplicit=*/false, AllowExplicitConvs);
+  else
+S.AddConversionCandidate(Conv, I.getPair(), ActingDC, Initializer,
+ DestType, CandidateSet,
+ /*AllowObjCConversionOnExplicit=*/false,
+ AllowExplicitConvs);
+}
   }
 }
   }


Index: clang/test/Sema/init-ref-c.c
===
--- /dev/null
+++ clang/test/Sema/init-ref-c.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
+
+void f() {
+  struct EmptyStruct {};
+  struct EmptyStruct S;
+  __builtin_va_end(S); // no-crash, expected-error {{non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'struct EmptyStruct'}}
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4535,39 +4535,41 @@
   S.isCompleteType(Kind.getLocation(), T2)) {
 // The type we're converting 

[PATCH] D82805: [clang] Fix a crash on passing C structure of incompatible type to function with reference parameter

2020-06-29 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4539
+if (CXXRecordDecl *T2RecordDecl =
+dyn_cast(T2RecordType->getDecl())) {
+  const auto  = T2RecordDecl->getVisibleConversionFunctions();

I cannot reproduce this with the provided test case. Can you explain why 
`T2RecordDecl` would not be a `CXXRecordDecl` since we should only get there 
with c++?


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

https://reviews.llvm.org/D82805



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


[PATCH] D82733: [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-29 Thread Philippe Blain via Phabricator via cfe-commits
phil-blain added a comment.

I tested the sphinx build for the `man` and `html` targets. Any other targets I 
should check ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82733



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


[PATCH] D82733: [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-29 Thread Philippe Blain via Phabricator via cfe-commits
phil-blain updated this revision to Diff 274286.
phil-blain added a comment.

Use `note::` Sphinx directive

Also:

- Fix Sphinx formatting for preformatted text
- Correctly pass the linker argument (initial '-' was missing)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82733

Files:
  clang/docs/CommandGuide/clang.rst


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -474,6 +474,16 @@
   optimization. With "thin", :doc:`ThinLTO <../ThinLTO>`
   compilation is invoked instead.
 
+  .. note::
+
+ On Darwin, when using :option:`-flto` along with :option:`-g` and
+ compiling and linking in separate steps, you also need to pass
+ ``-Wl,-object_path_lto,.o`` at the linking step to instruct 
the
+ ld64 linker not to delete the temporary object file generated during Link
+ Time Optimization (this flag is automatically passed to the linker by 
Clang
+ if compilation and linking are done in a single step). This allows 
debugging
+ the executable as well as generating the ``.dSYM`` bundle using 
:manpage:`dsymutil(1)`.
+
 Driver Options
 ~~
 


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -474,6 +474,16 @@
   optimization. With "thin", :doc:`ThinLTO <../ThinLTO>`
   compilation is invoked instead.
 
+  .. note::
+
+ On Darwin, when using :option:`-flto` along with :option:`-g` and
+ compiling and linking in separate steps, you also need to pass
+ ``-Wl,-object_path_lto,.o`` at the linking step to instruct the
+ ld64 linker not to delete the temporary object file generated during Link
+ Time Optimization (this flag is automatically passed to the linker by Clang
+ if compilation and linking are done in a single step). This allows debugging
+ the executable as well as generating the ``.dSYM`` bundle using :manpage:`dsymutil(1)`.
+
 Driver Options
 ~~
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-29 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/test/DebugInfo/debugify-each-original.c:16
+// CHECK: Force set function attributes: {{.*}}
+// CHECK-NEXT: Infer set function attributes: {{.*}}
+// CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation: {{.*}}

I think this is still implicitly hardcoding the pass pipeline just through the 
order of CHECK lines. If there were a way to dump the flags Clang is passing to 
LLVM and check that, or get the pass manager to dump its configuration, that 
would be better. I'm not sure if there is such an affordance.


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

https://reviews.llvm.org/D82547



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


[PATCH] D82822: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: anchu-rajendran, kiranktp, fghanim.
Herald added subscribers: sstefan1, guansong, bollu, yaxunl.
Herald added a project: clang.

When we use the OpenMPIRBuilder for the parallel region we need to also
use it to get the thread ID (among other things) in the body. This is
because CGOpenMPRuntime::getThreadID() and
CGOpenMPRuntime::emitUpdateLocation implicitly assumes that if they are
called from within a parallel region there is a certain structure to the
code and certain members of the OMPRegionInfo are initialized. It might
make sense to initialize them even if we use the OpenMPIRBuilder but we
would preferably get rid of such state instead.

Bug reported by Anchu Rajendran Sudhakumari.

Depends on D82470 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82822

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/irbuilder_nested_parallel_for.c

Index: clang/test/OpenMP/irbuilder_nested_parallel_for.c
===
--- /dev/null
+++ clang/test/OpenMP/irbuilder_nested_parallel_for.c
@@ -0,0 +1,299 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefixes=CHECK %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -verify %s -emit-llvm -o - | FileCheck --check-prefixes=CHECK-DEBUG %s
+
+// expected-no-diagnostics
+
+// TODO: Teach the update script to check new functions too.
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-LABEL: @_Z14parallel_for_0v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1)
+// CHECK-NEXT:br label [[OMP_PARALLEL:%.*]]
+// CHECK:   omp_parallel:
+// CHECK-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @1, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @_Z14parallel_for_0v..omp_par to void (i32*, i32*, ...)*))
+// CHECK-NEXT:br label [[OMP_PAR_OUTLINED_EXIT:%.*]]
+// CHECK:   omp.par.outlined.exit:
+// CHECK-NEXT:br label [[OMP_PAR_EXIT_SPLIT:%.*]]
+// CHECK:   omp.par.exit.split:
+// CHECK-NEXT:ret void
+//
+// CHECK-DEBUG-LABEL: @_Z14parallel_for_0v(
+// CHECK-DEBUG-NEXT:  entry:
+// CHECK-DEBUG-NEXT:[[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1), !dbg !10
+// CHECK-DEBUG-NEXT:br label [[OMP_PARALLEL:%.*]]
+// CHECK-DEBUG:   omp_parallel:
+// CHECK-DEBUG-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @1, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @_Z14parallel_for_0v..omp_par to void (i32*, i32*, ...)*)), !dbg !11
+// CHECK-DEBUG-NEXT:br label [[OMP_PAR_OUTLINED_EXIT:%.*]]
+// CHECK-DEBUG:   omp.par.outlined.exit:
+// CHECK-DEBUG-NEXT:br label [[OMP_PAR_EXIT_SPLIT:%.*]]
+// CHECK-DEBUG:   omp.par.exit.split:
+// CHECK-DEBUG-NEXT:ret void, !dbg !14
+//
+void parallel_for_0(void) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < 100; ++i) {
+}
+  }
+}
+
+// CHECK-LABEL: @_Z14parallel_for_1Pfid(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[R_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store float* [[R:%.*]], float** [[R_ADDR]], align 8
+// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK-NEXT:store double [[B:%.*]], double* [[B_ADDR]], align 8
+// CHECK-NEXT:[[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1)
+// CHECK-NEXT:br label [[OMP_PARALLEL:%.*]]
+// CHECK:   omp_parallel:
+// CHECK-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @1, i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*, double*, float**)* @_Z14parallel_for_1Pfid..omp_par.1 to void (i32*, i32*, ...)*), i32* [[A_ADDR]], double* [[B_ADDR]], float** [[R_ADDR]])
+// CHECK-NEXT:br label [[OMP_PAR_OUTLINED_EXIT19:%.*]]
+// CHECK:   omp.par.outlined.exit19:
+// CHECK-NEXT:br label [[OMP_PAR_EXIT_SPLIT:%.*]]
+// CHECK:   omp.par.exit.split:
+// CHECK-NEXT:ret void
+//
+// CHECK-DEBUG-LABEL: @_Z14parallel_for_1Pfid(
+// CHECK-DEBUG-NEXT:  entry:
+// CHECK-DEBUG-NEXT:[[R_ADDR:%.*]] = alloca float*, align 8
+// CHECK-DEBUG-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK-DEBUG-NEXT:[[B_ADDR:%.*]] = alloca double, align 8
+// CHECK-DEBUG-NEXT:store float* [[R:%.*]], float** [[R_ADDR]], 

[PATCH] D81728: [InstCombine] Add target-specific inst combining

2020-06-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> This combines instructions, so I think it belongs into the InstCombine pass. 
> On the other hand, the f16 form of the intrinsics is not available on all 
> targets, so this combination cannot be applied unconditionally but it needs 
> to be gated depending on the target.

I don't think this is a great justification for doing anything here.  You can 
always reverse the transform in isel on targets where it isn't supported; 
adding more IR patterns increases the potential for missed optimizations.

That said, I think moving the handling for target intrinsics into the target 
makes sense as a cleanup.




Comment at: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:1444
+  *this, *II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
+  simplifyAndSetOp, ))
+return V;

Is there some way we can check that an intrinsic is actually target-specific, 
to discourage people from handling generic intrinsics in target-specific ways?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81728



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


[PATCH] D82807: [clang-tidy] Allows the prevailing include header guard in Flang ...

2020-06-29 Thread Eric Schweitz via Phabricator via cfe-commits
schweitz created this revision.
schweitz added reviewers: bkramer, hokein.
schweitz added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a reviewer: DavidTruby.
Herald added a reviewer: sscalpone.
Herald added a project: clang.

to be recognized rather than flagged as a violation in phabricator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82807

Files:
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp


Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang")-1);
+
   return StringRef(Guard).upper();
 }
 


Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang")-1);
+
   return StringRef(Guard).upper();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82806: [AIX] Static init support for template specialization and inline variable

2020-06-29 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: hubert.reinterpretcast, jasonliu, yusra.syeda, 
ZarkoCA, sfertile.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

This is a follow-up patch of D74166 .

This patch adds static init support for template specialization kinds that were 
left out by D74166  [implicit instantiation, 
explicit instantiation definition] and inline variable.

Also.it adds a test for explicit specialization TSK.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82806

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp

Index: clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
@@ -0,0 +1,238 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -std=c++2a < %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -std=c++2a < %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+  struct Test1 {
+Test1(int) {}
+~Test1() {}
+  };
+
+  Test1 t0 = 2;
+  template  Test1 t1 = 2;
+  inline Test1 t2 = 2;
+
+  void foo() {
+(void) ;
+  }
+} // namespace test1
+
+namespace test2 {
+  template 
+  struct A {
+A() {}
+~A() {}
+static A instance;
+  };
+
+  template  A A::instance;
+  template A<> A<>::instance;
+
+  A () { 
+A *a = new A;
+return *a;
+  }
+  template<> A A::instance = bar();
+} // namespace test2
+
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_32add9385a76444cd9d0fab0fb83307b, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_32add9385a76444cd9d0fab0fb83307b, i8* null }]
+
+// CHECK: define internal void @__cxx_global_var_init() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK32: call void @_ZN5test15Test1C1Ei(%"struct.test1::Test1"* @_ZN5test12t0E, i32 2)
+// CHECK64: call void @_ZN5test15Test1C1Ei(%"struct.test1::Test1"* @_ZN5test12t0E, i32 signext 2)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test12t0E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test12t0E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t0E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define internal void @__finalize__ZN5test12t0E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor__ZN5test12t0E)
+// CHECK:   %needs_destruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor__ZN5test12t0E()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+ //CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*)
+
+// CHECK: define internal void @__cxx_global_var_init.1() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = load atomic i8, i8* bitcast (i64* @_ZGVN5test12t2E to i8*) acquire
+// CHECK:   %guard.uninitialized = icmp eq i8 %0, 0
+// CHECK:   br i1 %guard.uninitialized, label %init.check, label %init.end
+
+// CHECK: init.check:
+ //CHECK:   %1 = call i32 @__cxa_guard_acquire(i64* @_ZGVN5test12t2E)
+// CHECK:   %tobool = icmp ne i32 %1, 0
+// CHECK:   br i1 %tobool, label %init, label %init.end
+
+// CHECK: init:
+// CHECK32: call void @_ZN5test15Test1C1Ei(%"struct.test1::Test1"* @_ZN5test12t2E, i32 2)
+// CHECK64: call void @_ZN5test15Test1C1Ei(%"struct.test1::Test1"* @_ZN5test12t2E, i32 signext 2)
+// CHECK:   %2 = call i32 @atexit(void ()* @__dtor__ZN5test12t2E)
+// CHECK:   call void @__cxa_guard_release(i64* @_ZGVN5test12t2E)
+// CHECK:   br label %init.end
+
+// CHECK: init.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__finalize__ZN5test12t2E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor__ZN5test12t2E)
+// CHECK:   %needs_destruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor__ZN5test12t2E()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void 

[PATCH] D82805: [clang] Fix a crash on passing C structure of incompatible type to function with reference parameter

2020-06-29 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
ArcsinX added a reviewer: rsmith.
ArcsinX added a project: clang.
Herald added a subscriber: cfe-commits.
ArcsinX edited the summary of this revision.

`__builtin_va_*()` and `__builtin_ms_va_*()` declared as functions with 
reference parameters.

This patch fix clang crashes at using these functions in C and passing 
incompatible structures as parameters in case of 
`__builtin_va_list`/`__builtin_ms_va_list` are structures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82805

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-ref-c.c


Index: clang/test/Sema/init-ref-c.c
===
--- /dev/null
+++ clang/test/Sema/init-ref-c.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
+
+void f() {
+  struct EmptyStruct {};
+  struct EmptyStruct S;
+  __builtin_va_end(S); // no-crash, expected-error {{non-const lvalue 
reference to type '__builtin_va_list' cannot bind to a value of unrelated type 
'struct EmptyStruct'}}
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4535,39 +4535,41 @@
   S.isCompleteType(Kind.getLocation(), T2)) {
 // The type we're converting from is a class type, enumerate its conversion
 // functions.
-CXXRecordDecl *T2RecordDecl = cast(T2RecordType->getDecl());
-
-const auto  = T2RecordDecl->getVisibleConversionFunctions();
-for (auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
-  NamedDecl *D = *I;
-  CXXRecordDecl *ActingDC = cast(D->getDeclContext());
-  if (isa(D))
-D = cast(D)->getTargetDecl();
-
-  FunctionTemplateDecl *ConvTemplate = dyn_cast(D);
-  CXXConversionDecl *Conv;
-  if (ConvTemplate)
-Conv = cast(ConvTemplate->getTemplatedDecl());
-  else
-Conv = cast(D);
-
-  // If the conversion function doesn't return a reference type,
-  // it can't be considered for this conversion unless we're allowed to
-  // consider rvalues.
-  // FIXME: Do we need to make sure that we only consider conversion
-  // candidates with reference-compatible results? That might be needed to
-  // break recursion.
-  if ((AllowRValues ||
-   Conv->getConversionType()->isLValueReferenceType())) {
+if (CXXRecordDecl *T2RecordDecl =
+dyn_cast(T2RecordType->getDecl())) {
+  const auto  = T2RecordDecl->getVisibleConversionFunctions();
+  for (auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
+NamedDecl *D = *I;
+CXXRecordDecl *ActingDC = cast(D->getDeclContext());
+if (isa(D))
+  D = cast(D)->getTargetDecl();
+
+FunctionTemplateDecl *ConvTemplate = dyn_cast(D);
+CXXConversionDecl *Conv;
 if (ConvTemplate)
-  S.AddTemplateConversionCandidate(
-  ConvTemplate, I.getPair(), ActingDC, Initializer, DestType,
-  CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, AllowExplicitConvs);
+  Conv = cast(ConvTemplate->getTemplatedDecl());
 else
-  S.AddConversionCandidate(
-  Conv, I.getPair(), ActingDC, Initializer, DestType, CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, AllowExplicitConvs);
+  Conv = cast(D);
+
+// If the conversion function doesn't return a reference type,
+// it can't be considered for this conversion unless we're allowed to
+// consider rvalues.
+// FIXME: Do we need to make sure that we only consider conversion
+// candidates with reference-compatible results? That might be needed
+// to break recursion.
+if ((AllowRValues ||
+ Conv->getConversionType()->isLValueReferenceType())) {
+  if (ConvTemplate)
+S.AddTemplateConversionCandidate(
+ConvTemplate, I.getPair(), ActingDC, Initializer, DestType,
+CandidateSet,
+/*AllowObjCConversionOnExplicit=*/false, AllowExplicitConvs);
+  else
+S.AddConversionCandidate(
+Conv, I.getPair(), ActingDC, Initializer, DestType,
+CandidateSet, /*AllowObjCConversionOnExplicit=*/false,
+AllowExplicitConvs);
+}
   }
 }
   }


Index: clang/test/Sema/init-ref-c.c
===
--- /dev/null
+++ clang/test/Sema/init-ref-c.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
+
+void f() {
+  struct EmptyStruct {};
+  struct EmptyStruct S;
+  __builtin_va_end(S); // no-crash, expected-error {{non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'struct EmptyStruct'}}
+}
\ No newline at end of 

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

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



Comment at: clang/lib/Driver/ToolChains/Arch/X86.cpp:200
+if (!Args.hasArg(options::OPT_mno_lvi_cfi)) {
+  Features.push_back("+lvi-cfi");
+  LVIOpt = options::OPT_mlvi_cfi;

sconstab wrote:
> zbrid wrote:
> > sconstab wrote:
> > > Would it be better to add `FeatureLVIControlFlowIntegrity` as a 
> > > dependency for `FeatureSpeculativeExecutionSideEffectSuppression` in 
> > > `llvm/lib/Target/X86/X86.td`?
> > Thanks for the tip! Yeah, I will update to do that, but it looks like that 
> > only ensures an error will be thrown if they aren't used together rather 
> > than ensuring one is enabled when the other is enabled. Am I 
> > misunderstanding?
> I'm not certain about this either. @craig.topper opinion?
Making them dependent in X86.td will make +sese imply +lvi-cfi and make 
-lvi-cfi imply -sese. So sese can never be enabled without lvi-cfi also enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:4907
+  if (Stride) {
+auto Res =
+PerformOpenMPImplicitIntegerConversion(Stride->getExprLoc(), Stride);

cchen wrote:
> ABataev wrote:
> > `auto`->`ExprResult`
> Should I also change it for LowerBound and Length? Just to make it consistent.
Not in this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[clang-tools-extra] 1f14287 - [clangd] config() -> Config::current to avoid confict with NS

2020-06-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-29T23:05:19+02:00
New Revision: 1f14287eab972e76a521a32a2c326b8ff3b8d21f

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

LOG: [clangd] config() -> Config::current to avoid confict with NS

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/Config.cpp
clang-tools-extra/clangd/Config.h

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f9d5cccf5baf..0b27e0e3e828 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -184,7 +184,7 @@ CommandMangler CommandMangler::forTests() {
 
 void CommandMangler::adjust(std::vector ) const {
   // FIXME: remove const_cast once unique_function is const-compatible.
-  for (auto  : const_cast(config()).CompileFlags.Edits)
+  for (auto  : const_cast(Config::current()).CompileFlags.Edits)
 Edit(Cmd);
 
   // Check whether the flag exists, either as -flag or -flag=*

diff  --git a/clang-tools-extra/clangd/Config.cpp 
b/clang-tools-extra/clangd/Config.cpp
index 699b03e52484..3b9b9bf71e24 100644
--- a/clang-tools-extra/clangd/Config.cpp
+++ b/clang-tools-extra/clangd/Config.cpp
@@ -14,8 +14,8 @@ namespace clangd {
 
 Key Config::Key;
 
-const Config () {
-  if (const Config *C = Context::current().get(Config::Key))
+const Config ::current() {
+  if (const Config *C = Context::current().get(Key))
 return *C;
   static Config Default;
   return Default;

diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index c1c2cbbd3a1e..878c9e8549b5 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -34,10 +34,12 @@ namespace clangd {
 
 /// Settings that express user/project preferences and control clangd behavior.
 ///
-/// Generally, features should consume config() and the caller is responsible
-/// for setting it appropriately. In practice these callers are ClangdServer,
-/// TUScheduler, and BackgroundQueue.
+/// Generally, features should consume Config::current() and the caller is
+/// responsible for setting it appropriately. In practice these callers are
+/// ClangdServer, TUScheduler, and BackgroundQueue.
 struct Config {
+  /// Returns the Config of the current Context, or an empty configuration.
+  static const Config ();
   /// Context key which can be used to set the current Config.
   static clangd::Key Key;
 
@@ -55,9 +57,6 @@ struct Config {
   } CompileFlags;
 };
 
-/// Returns the Config of the current Context, or an empty configuration.
-const Config ();
-
 } // namespace clangd
 } // namespace clang
 



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


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

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



Comment at: llvm/lib/Transforms/Utils/CodeExtractor.cpp:932
   case Attribute::NoCfCheck:
+  case Attribute::NoUndef:
 break;

nikic wrote:
> Not familiar with this code, but based on the placement of other similar 
> attributes like nonnull, this should probably be in the first list.
Technically, it should not matter because this is not a function attribute. 
That said, the first list makes logically more sense. I would even prefer three 
lists, OK to propagate, not OK, and assertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


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

2020-06-29 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.

I've run across an issue when bootstrapping clang, that manifests itself in the 
following code when compiled with optimizations:

  #include 
  
  float my_exp2(float a) {
  return pow(2.0, a);
  }

With this code, the call to `pow` is lifted to a `exp2`, and then the resulting 
call causes `llvm::verifyFunction` to fail. The error is that attributes are 
present past the end of the argument list.
I'm thinking that whatever code does the lifting here fails to remove the 
attribute list corresponding to the `2.0` parameter here.

Could anyone point me to where I might need to make a change for that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


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

2020-06-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D81678#2120709 , @guiand wrote:

> Could anyone point me to where I might need to make a change for that?


LibCallSimplifier::optimizePow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


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

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



Comment at: clang/lib/CodeGen/CGCall.cpp:2082
+  const Type *RetTyPtr = RetTy.getTypePtr();
+  if (!RetTy->isVoidType() && !RetTyPtr->isRecordType() &&
+  RetAI.getKind() != ABIArgInfo::Indirect) {

guiand wrote:
> guiand wrote:
> > guiand wrote:
> > > rsmith wrote:
> > > > Other types that we should think about from a padding perspective:
> > > > 
> > > >  * `nullptr_t` (which has the same size and alignment as `void*` but is 
> > > > all padding)
> > > >  * 80-bit `long double` and `_Complex long double` (I don't know 
> > > > whether we guarantee to initialize the 6 padding bytes)
> > > >  * member pointers might contain padding under some ABI rules -- under 
> > > > the MS ABI, you get a struct containing N pointers followed by M ints, 
> > > > which could have 4 bytes of tail padding on 64-bit targets
> > > >  * vector types with tail padding (eg, a vector of 3 `char`s is 
> > > > sometimes passed as an `i32` with one byte `undef`)
> > > >  * matrix types (presumably the same concerns as for vector types apply 
> > > > here)
> > > >  * maybe Obj-C object types?
> > > >  * `_ExtInt` types (eg, returning an `_ExtInt(65)` initialized to 0 
> > > > produces an `{i64, i64}` containing 7 bytes of `undef`)
> > > > 
> > > > It would be safer to list exactly those types for which we know this 
> > > > assumption is correct rather than assuming that it's correct by default 
> > > > -- I think more than half of the `Type` subclasses for concrete 
> > > > canonical types can have undef bits in their IR representation.
> > > This is a good point, and I think there was some nuance that I had 
> > > previously included in determining this for records (since removed) that 
> > > I didn't think to include in CGCall.cpp.
> > > 
> > > I think one particular check, 
> > > `llvm::DataLayout::typeSizeEqualsStoreSize`, handles a lot of these cases:
> > > - `long double`
> > > - oddly-sized vectors
> > > - `_ExtInt` types
> > > 
> > > I don't know if the `matrix` type has internal padding (like structs) but 
> > > if not it would cover that as well.  
> > > I believe that the struct with padding wouldn't be an issue as we're 
> > > excluding record types here.  
> > > And I'd have to take a closer look at `nullptr_t` to see how it behaves 
> > > here.
> > > 
> > > ~~~
> > > 
> > > But if I'd like to build an exhaustive list of types I think will work 
> > > correctly with a check like this:
> > > - scalars
> > > - floating point numbers
> > > - pointers
> > > 
> > > I think I'd need also need an inner `typeSizeEqualsStoreSize` check on 
> > > the base type of vectors/complex numbers.
> > > nullptr_t (which has the same size and alignment as void* but is all 
> > > padding)
> > 
> > From what I can gather looking at the IR of `test/CodeGenCXX/nullptr.cpp`, 
> > it looks like `nullptr_t` arguments and return values are represented as 
> > normal `i8*` types but given the special value `null`. From this it seems 
> > like we can mark them `noundef` without worry?
> Actually I've been thinking more about these cases, and they should only 
> really be a problem if clang coerces them away from their native types to 
> something larger.
> 
> For example, if clang emits `i33` that's not a problem, as potential padding 
> belonging to `i33` can be always be determined by looking at the data layout.
> But if it emits `{ i32, i32 }` or `i64` or something similar, it's 
> introducing new hidden/erased padding and so we can't mark it `noundef`.
> Same thing goes for `long double`: if it's emitted as `x86_fp80` that's no 
> problem.
> 
> There's been some confusion wrt this in the LangRef patch as well. I think 
> what we really want is an attribute that indicates the presence of undef bits 
> *not inherent to the IR type*. So (for the sake of argument, we're not 
> handling structs right now) `struct { char; short }` emitted as `{ i8, i16 } 
> noundef` is fine, but emitting it as `i64` is a problem.
> struct { char; short } emitted as { i8, i16 } noundef is fine, but emitting 
> it as i64 is a problem.

FWIW, I agree with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D82802: [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

2020-06-29 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde172dd17f03: [clang][RelativeVTablesABI] Update 
CodeGenCXX/RelativeVTablesABI/dynamic-cast. (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82802

Files:
  clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp


Index: clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
@@ -35,13 +35,13 @@
 // CHECK-NEXT:   [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null
 // CHECK-NEXT:   br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], 
label %[[dynamic_cast_notnull:[a-z0-9._]+]]
 // CHECK:  [[dynamic_cast_notnull]]:
-// CHECK-NEXT:   [[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
-// CHECK-NEXT:   [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
-// CHECK-NEXT:   [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
-// CHECK-NEXT:   [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
-// CHECK-NEXT:   [[b:%[0-9]+]] = bitcast %class.B* %b to i8*
-// CHECK-NEXT:   [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
-// CHECK-NEXT:   [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
+// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
+// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
+// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
+// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
+// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8*
+// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
+// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
 // CHECK-NEXT:   br label %[[dynamic_cast_end]]
 // CHECK:  [[dynamic_cast_end]]:
 // CHECK-NEXT:   [[res:%[0-9]+]] = phi i8* [ [[casted]], 
%[[dynamic_cast_notnull]] ], [ null, %entry ]


Index: clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
@@ -35,13 +35,13 @@
 // CHECK-NEXT:   [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null
 // CHECK-NEXT:   br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], label %[[dynamic_cast_notnull:[a-z0-9._]+]]
 // CHECK:  [[dynamic_cast_notnull]]:
-// CHECK-NEXT:   [[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
-// CHECK-NEXT:   [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
-// CHECK-NEXT:   [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* [[vtable]], i64 -2
-// CHECK-NEXT:   [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
-// CHECK-NEXT:   [[b:%[0-9]+]] = bitcast %class.B* %b to i8*
-// CHECK-NEXT:   [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
-// CHECK-NEXT:   [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 [[offset_to_top2]]
+// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
+// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
+// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* [[vtable]], i64 -2
+// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
+// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8*
+// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
+// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 [[offset_to_top2]]
 // CHECK-NEXT:   br label %[[dynamic_cast_end]]
 // CHECK:  [[dynamic_cast_end]]:
 // CHECK-NEXT:   [[res:%[0-9]+]] = phi i8* [ [[casted]], %[[dynamic_cast_notnull]] ], [ null, %entry ]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-06-29 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 274223.
tianshilei1992 added a comment.
Herald added a subscriber: sstefan1.

Will update failed tests later


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

https://reviews.llvm.org/D78075

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9297,7 +9297,8 @@
 
   assert(OutlinedFn && "Invalid outlined function!");
 
-  const bool RequiresOuterTask = D.hasClausesOfKind();
+  const bool RequiresOuterTask = D.hasClausesOfKind() ||
+ D.hasClausesOfKind();
   llvm::SmallVector CapturedVars;
   const CapturedStmt  = *D.getCapturedStmt(OMPD_target);
   auto & = [, ](CodeGenFunction ,


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9297,7 +9297,8 @@
 
   assert(OutlinedFn && "Invalid outlined function!");
 
-  const bool RequiresOuterTask = D.hasClausesOfKind();
+  const bool RequiresOuterTask = D.hasClausesOfKind() ||
+ D.hasClausesOfKind();
   llvm::SmallVector CapturedVars;
   const CapturedStmt  = *D.getCapturedStmt(OMPD_target);
   auto & = [, ](CodeGenFunction ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-29 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 274219.
zixuw added a comment.

- Remove implementation details from the help text of 'Wundef';
- Hide help text for 'Wundef-prefix' and 'Wundef'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify=undef
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify=undef-prefix
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A,BC -verify=both
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify=undef-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef-prefix -Wundef-prefix=A,BC -verify=undef-prefix-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -Wundef-prefix=A,BC -verify=both-error
+
+extern int x;
+
+#if AB // #1
+#endif
+// undef-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// both-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// both-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+
+#if B // #2
+#endif
+// undef-warning@#2 {{'B' is not defined, evaluates to 0}}
+// no warning for undef-prefix
+// both-warning@#2 {{'B' is not defined, evaluates to 0}}
+// undef-error-error@#2 {{'B' is not defined, evaluates to 0}}
+// no error for undef-prefix
+// both-error-error@#2 {{'B' is not defined, evaluates to 0}}
+
+#define BC 0
+#if BC // no warning/error
+#endif
+
+#undef BC
+#if BC // #3
+#endif
+// undef-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// both-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// both-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wundef"
+
+#if A // no warning/error
+#endif
+
+#pragma clang diagnostic pop
+
+#if A // #4
+#endif
+// undef-warning@#4 {{'A' is not defined, evaluates to 0}}
+// undef-prefix-warning@#4 {{'A' is not defined, evaluates to 0}}
+// both-warning@#4 {{'A' is not defined, evaluates to 0}}
+// undef-error-error@#4 {{'A' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#4 {{'A' is not defined, evaluates to 0}}
+// both-error-error@#4 {{'A' is not defined, evaluates to 0}}
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -15,7 +15,6 @@
 //
 //===--===//
 
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -26,8 +25,10 @@
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -251,8 +252,24 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
-  PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+if (ValueLive) {
+  const DiagnosticOptions  =
+  PP.getDiagnostics().getDiagnosticOptions();
+  const StringRef IdentifierName = II->getName();
+  // Check whether "-Werror=undef" is present.
+  // "-Werror=undef" implies "-Wundef" but does not add an empty
+  // string to UndefPrefixes as an explicit "-Wundef" does.
+  // This check ensures that "-Werror=undef" emits errors for all
+  // undefined macros.
+  const bool hasWerrorEQundef =
+  llvm::is_contained(diagOptions.Warnings, "error=undef");
+  if (hasWerrorEQundef ||
+  llvm::any_of(diagOptions.UndefPrefixes,
+   [](const std::string ) {
+ return IdentifierName.startswith(Prefix);
+ 

[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-06-29 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked 3 inline comments as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7893-7897
+llvm::errs() << "DEBUG in CGOpenMPRuntime.cpp\n";
+OASE->getLowerBound()->dump();
+OASE->getLength()->dump();
+OASE->getStride()->dump();
+

ABataev wrote:
> Must be removed
I'll remove the commit. Thanks



Comment at: clang/lib/Sema/SemaExpr.cpp:4907
+  if (Stride) {
+auto Res =
+PerformOpenMPImplicitIntegerConversion(Stride->getExprLoc(), Stride);

ABataev wrote:
> `auto`->`ExprResult`
Should I also change it for LowerBound and Length? Just to make it consistent.



Comment at: clang/test/OpenMP/target_update_ast_print.cpp:66
 
+#pragma omp target update from(marr [1:1:1] [0:2:] [1:0])
+

ABataev wrote:
> It would be good to add some positive tests for other constructs, like 
> `target`, `target data` etc., if allowed.
I'm going to add those, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-29 Thread Scott Constable via Phabricator via cfe-commits
sconstab accepted this revision.
sconstab added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/lib/Driver/ToolChains/Arch/X86.cpp:200
+if (!Args.hasArg(options::OPT_mno_lvi_cfi)) {
+  Features.push_back("+lvi-cfi");
+  LVIOpt = options::OPT_mlvi_cfi;

zbrid wrote:
> sconstab wrote:
> > Would it be better to add `FeatureLVIControlFlowIntegrity` as a dependency 
> > for `FeatureSpeculativeExecutionSideEffectSuppression` in 
> > `llvm/lib/Target/X86/X86.td`?
> Thanks for the tip! Yeah, I will update to do that, but it looks like that 
> only ensures an error will be thrown if they aren't used together rather than 
> ensuring one is enabled when the other is enabled. Am I misunderstanding?
I'm not certain about this either. @craig.topper opinion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


[PATCH] D82802: [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

2020-06-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82802



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


[PATCH] D82802: [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

2020-06-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a reviewer: phosek.
leonardchan added a project: clang.

After c7bcd431d9c4bfeb631a3599f1d628603e6351d6 
, this 
test started failing when running with the new pass manager. One of the CHECKs 
in this file checks how the vtable is loaded for a void cast, which involves 
taking 2 bitcasts from the pointer to the original object. The order of these 
bitcasts changes under the new PM. The order doesn't matter, so this relaxes 
the CHECKs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82802

Files:
  clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp


Index: clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
@@ -35,13 +35,13 @@
 // CHECK-NEXT:   [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null
 // CHECK-NEXT:   br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], 
label %[[dynamic_cast_notnull:[a-z0-9._]+]]
 // CHECK:  [[dynamic_cast_notnull]]:
-// CHECK-NEXT:   [[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
-// CHECK-NEXT:   [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
-// CHECK-NEXT:   [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
-// CHECK-NEXT:   [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
-// CHECK-NEXT:   [[b:%[0-9]+]] = bitcast %class.B* %b to i8*
-// CHECK-NEXT:   [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
-// CHECK-NEXT:   [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
+// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
+// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
+// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
+// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
+// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8*
+// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
+// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
 // CHECK-NEXT:   br label %[[dynamic_cast_end]]
 // CHECK:  [[dynamic_cast_end]]:
 // CHECK-NEXT:   [[res:%[0-9]+]] = phi i8* [ [[casted]], 
%[[dynamic_cast_notnull]] ], [ null, %entry ]


Index: clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
@@ -35,13 +35,13 @@
 // CHECK-NEXT:   [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null
 // CHECK-NEXT:   br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], label %[[dynamic_cast_notnull:[a-z0-9._]+]]
 // CHECK:  [[dynamic_cast_notnull]]:
-// CHECK-NEXT:   [[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
-// CHECK-NEXT:   [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
-// CHECK-NEXT:   [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* [[vtable]], i64 -2
-// CHECK-NEXT:   [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
-// CHECK-NEXT:   [[b:%[0-9]+]] = bitcast %class.B* %b to i8*
-// CHECK-NEXT:   [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
-// CHECK-NEXT:   [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 [[offset_to_top2]]
+// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
+// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
+// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* [[vtable]], i64 -2
+// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
+// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8*
+// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
+// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 [[offset_to_top2]]
 // CHECK-NEXT:   br label %[[dynamic_cast_end]]
 // CHECK:  [[dynamic_cast_end]]:
 // CHECK-NEXT:   [[res:%[0-9]+]] = phi i8* [ [[casted]], %[[dynamic_cast_notnull]] ], [ null, %entry ]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] de172dd - [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

2020-06-29 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-06-29T13:06:42-07:00
New Revision: de172dd17f0334e1fcbbf28a33d0ea24f7cbff1a

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

LOG: [clang][RelativeVTablesABI] Update 
CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

After c7bcd431d9c4bfeb631a3599f1d628603e6351d6, this test started failing when
running with the new pass manager. One of the CHECKs in this file checks how the
vtable is loaded for a void cast, which involves taking 2 bitcasts from the 
pointer
to the original object. The order of these bitcasts changes under the new PM.
The order doesn't matter, so this relaxes the CHECKs.

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

Added: 


Modified: 
clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
index 56b56a1b9398..62d674669661 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
@@ -35,13 +35,13 @@
 // CHECK-NEXT:   [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null
 // CHECK-NEXT:   br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], 
label %[[dynamic_cast_notnull:[a-z0-9._]+]]
 // CHECK:  [[dynamic_cast_notnull]]:
-// CHECK-NEXT:   [[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
-// CHECK-NEXT:   [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
-// CHECK-NEXT:   [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
-// CHECK-NEXT:   [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
-// CHECK-NEXT:   [[b:%[0-9]+]] = bitcast %class.B* %b to i8*
-// CHECK-NEXT:   [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
-// CHECK-NEXT:   [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
+// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
+// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
+// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
+// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
+// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8*
+// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
+// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
 // CHECK-NEXT:   br label %[[dynamic_cast_end]]
 // CHECK:  [[dynamic_cast_end]]:
 // CHECK-NEXT:   [[res:%[0-9]+]] = phi i8* [ [[casted]], 
%[[dynamic_cast_notnull]] ], [ null, %entry ]



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


[PATCH] D76389: [NewPM] Run the Speculative Execution Pass only if the target has divergent branches

2020-06-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

This seems like it covers a different case than D82735 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76389



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


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-29 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 274212.
zixuw added a comment.

- Refine test cases to check combinations of 'Wundef' and 'Wundef-prefix', and 
with/without 'Werror';
- Fix issues with '-Werror=undef' by explicitly looking for the option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify=undef
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify=undef-prefix
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A,BC -verify=both
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify=undef-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef-prefix -Wundef-prefix=A,BC -verify=undef-prefix-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -Wundef-prefix=A,BC -verify=both-error
+
+extern int x;
+
+#if AB // #1
+#endif
+// undef-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// both-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// both-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+
+#if B // #2
+#endif
+// undef-warning@#2 {{'B' is not defined, evaluates to 0}}
+// no warning for undef-prefix
+// both-warning@#2 {{'B' is not defined, evaluates to 0}}
+// undef-error-error@#2 {{'B' is not defined, evaluates to 0}}
+// no error for undef-prefix
+// both-error-error@#2 {{'B' is not defined, evaluates to 0}}
+
+#define BC 0
+#if BC // no warning/error
+#endif
+
+#undef BC
+#if BC // #3
+#endif
+// undef-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// both-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// both-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wundef"
+
+#if A // no warning/error
+#endif
+
+#pragma clang diagnostic pop
+
+#if A // #4
+#endif
+// undef-warning@#4 {{'A' is not defined, evaluates to 0}}
+// undef-prefix-warning@#4 {{'A' is not defined, evaluates to 0}}
+// both-warning@#4 {{'A' is not defined, evaluates to 0}}
+// undef-error-error@#4 {{'A' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#4 {{'A' is not defined, evaluates to 0}}
+// both-error-error@#4 {{'A' is not defined, evaluates to 0}}
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -28,6 +28,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -251,8 +252,24 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
-  PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+if (ValueLive) {
+  const DiagnosticOptions  =
+  PP.getDiagnostics().getDiagnosticOptions();
+  const StringRef IdentifierName = II->getName();
+  // Check whether "-Werror=undef" is present.
+  // "-Werror=undef" implies "-Wundef" but does not add an empty
+  // string to UndefPrefixes as an explicit "-Wundef" does.
+  // This check ensures that "-Werror=undef" emits errors for all
+  // undefined macros.
+  const bool hasWerrorEQundef =
+  llvm::is_contained(diagOptions.Warnings, "error=undef");
+  if (hasWerrorEQundef ||
+  llvm::any_of(diagOptions.UndefPrefixes,
+   [](const std::string ) {
+ return IdentifierName.startswith(Prefix);
+   }))
+PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+}
 Result.Val = 0;
 Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
 Result.setIdentifier(II);
Index: clang/lib/Frontend/CompilerInvocation.cpp

[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-06-29 Thread Shuhong Liu via Phabricator via cfe-commits
ShuhongL added a comment.

Added testcase for the clang toolchain changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677



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


[PATCH] D80681: [clang][SourceManager] cache Macro Expansions

2020-06-29 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Reverted in 7c2cb1448ad2d20e251db5e3ae4a0c84c12aa970 
, relanded 
in 7b8cf98b4a9a2f5ea3667fdbf913a4f8952ed36a 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80681



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-06-29 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 274209.
cchen added a comment.

Revert unnecessary changes made by bot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/target_depend_messages.cpp
  clang/test/OpenMP/target_enter_data_depend_messages.cpp
  clang/test/OpenMP/target_exit_data_depend_messages.cpp
  clang/test/OpenMP/target_parallel_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_depend_messages.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/task_affinity_messages.cpp
  clang/test/OpenMP/task_depend_messages.cpp

Index: clang/test/OpenMP/task_depend_messages.cpp
===
--- clang/test/OpenMP/task_depend_messages.cpp
+++ clang/test/OpenMP/task_depend_messages.cpp
@@ -52,7 +52,7 @@
   #pragma omp task depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
   #pragma omp task depend (in : argv[-1:0]) // expected-error {{zero-length array section is not allowed in 'depend' clause}}
   #pragma omp task depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
-  #pragma omp task depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
+  #pragma omp task depend (in : argv[3:4:1]) // omp45-error {{expected ']'}} omp45-note {{to match this '['}}
   #pragma omp task depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
   #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
   #pragma omp task depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
Index: clang/test/OpenMP/task_affinity_messages.cpp
===
--- clang/test/OpenMP/task_affinity_messages.cpp
+++ clang/test/OpenMP/task_affinity_messages.cpp
@@ -44,7 +44,7 @@
   #pragma omp task affinity (argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
   #pragma omp task affinity (argv[-1:0])
   #pragma omp task affinity (argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
-  #pragma omp task affinity (argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
+  #pragma omp task affinity (argv[3:4:1])
   #pragma omp task affinity(a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
   #pragma omp task affinity(argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
   #pragma omp task affinity(argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -54,5 +54,9 @@
   {}
 #pragma omp target update from(dptr[0:2][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 
+  int iarr[5][5];
+#pragma omp target update to(marr [0:] [1:2:-1]) // le50-error {{section stride is evaluated to a non-positive value -1}} le45-error {{expected ']'}} le45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [1:2:-1]) // 

[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-06-29 Thread Shuhong Liu via Phabricator via cfe-commits
ShuhongL updated this revision to Diff 274210.
Herald added a subscriber: ormris.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Driver/aix-toolchain-include.cpp

Index: clang/test/Driver/aix-toolchain-include.cpp
===
--- /dev/null
+++ clang/test/Driver/aix-toolchain-include.cpp
@@ -0,0 +1,21 @@
+// Tests that aix toolchain adds system includes to the search path
+
+// Check without -nostdinc option
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+// CHECK-INTERNAL-INCLUDE: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "/usr/include"
+
+// Check with -nostdinc option
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+// CHECK-NOSTDINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE-NOT:	"-internal-isystem"
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -381,6 +381,7 @@
   case llvm::Triple::Linux:
   case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
+  case llvm::Triple::AIX:
 llvm_unreachable("Include management is handled in the driver.");
 break;
   case llvm::Triple::Win32:
@@ -424,6 +425,7 @@
   case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::AIX:
 return;
 
   case llvm::Triple::Win32:
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -63,6 +63,10 @@
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return true; }
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -13,12 +13,15 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
 
 using AIX = clang::driver::toolchains::AIX;
 using namespace clang::driver;
 using namespace clang::driver::tools;
+using namespace clang::driver::toolchains;
 
 using namespace llvm::opt;
+using namespace llvm::sys;
 
 void aix::Assembler::ConstructJob(Compilation , const JobAction ,
   const InputInfo ,
@@ -161,6 +164,21 @@
   getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
+void AIX::AddClangSystemIncludeArgs(const ArgList ,
+ArgStringList ) const {
+  // Check if -nostdinc is specified as a driver option
+  if (DriverArgs.hasArg(options::OPT_nostdinc))
+return;
+
+  const Driver  = getDriver();
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> P(D.ResourceDir);
+path::append(P, "/include");
+addSystemInclude(DriverArgs, CC1Args, P.str());
+  }
+  addSystemInclude(DriverArgs, CC1Args, "/usr/include");
+}
+
 auto AIX::buildAssembler() const -> Tool * { return new aix::Assembler(*this); }
 
 auto AIX::buildLinker() const -> Tool * { return new aix::Linker(*this); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82690: [clang][SourceManager] cache Macro Expansions pt.2

2020-06-29 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers abandoned this revision.
nickdesaulniers added a comment.

Reverted in 7c2cb1448ad2d20e251db5e3ae4a0c84c12aa970 
, relanded 
in 7b8cf98b4a9a2f5ea3667fdbf913a4f8952ed36a 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82690



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


[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, reverted and looking into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82606



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


[PATCH] D80791: [AArch64] Generate .note.gnu.property based on module flags.

2020-06-29 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

In D80791#2120755 , @kees wrote:

> In D80791#2120503 , @nickdesaulniers 
> wrote:
>
> > Might someone wish to disable PAC/BTI on an individual function, while 
> > having it on for the rest?  I guess that would mean you can't call that 
> > function indirectly?
>
>
> It would mean you can't call it _at all_, not just indirectly. :) Which is 
> why I still think the warning is useful. Perhaps don't warn for the functions 
> with the attribute?


BTI landing pad is needed only when the previous instructions was an indirect 
branch/jump  `bl x16`. 
With a direct branch `bl foo` no landing pad is needed at all. Rational is that 
direct branches can't be hijacked, they always land at the same location. 
Landing pads emitted only when indirect branch is possible to a function.[1]

[1] 
https://github.com/llvm/llvm-project/blob/f45b41348ba49c4a76baab1e3e302ef8e2bb992b/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp#L94


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80791



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


[clang-tools-extra] c5a6ee1 - Reland [clangd] Config: config struct propagated through Context

2020-06-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-29T21:49:25+02:00
New Revision: c5a6ee16f2f6cd7fd46616ba6808a98da53e71bd

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

LOG: Reland [clangd] Config: config struct propagated through Context

This reverts commit a3684dfc45c3a7bbdf72750d8a527e07e776b608.

Added: 
clang-tools-extra/clangd/Config.cpp
clang-tools-extra/clangd/Config.h

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index de3dd81a81db..20a32d28e119 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -36,6 +36,7 @@ add_clang_library(clangDaemon
   CollectMacros.cpp
   CompileCommands.cpp
   Compiler.cpp
+  Config.cpp
   ConfigYAML.cpp
   Diagnostics.cpp
   DraftStore.cpp

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index a2d704f57bda..f9d5cccf5baf 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "CompileCommands.h"
+#include "Config.h"
 #include "support/Logger.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
@@ -182,6 +183,10 @@ CommandMangler CommandMangler::forTests() {
 }
 
 void CommandMangler::adjust(std::vector ) const {
+  // FIXME: remove const_cast once unique_function is const-compatible.
+  for (auto  : const_cast(config()).CompileFlags.Edits)
+Edit(Cmd);
+
   // Check whether the flag exists, either as -flag or -flag=*
   auto Has = [&](llvm::StringRef Flag) {
 for (llvm::StringRef Arg : Cmd) {

diff  --git a/clang-tools-extra/clangd/Config.cpp 
b/clang-tools-extra/clangd/Config.cpp
new file mode 100644
index ..699b03e52484
--- /dev/null
+++ b/clang-tools-extra/clangd/Config.cpp
@@ -0,0 +1,25 @@
+//===--- Config.cpp - User configuration of clangd behavior 
---===//
+//
+// 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 "Config.h"
+#include "support/Context.h"
+
+namespace clang {
+namespace clangd {
+
+Key Config::Key;
+
+const Config () {
+  if (const Config *C = Context::current().get(Config::Key))
+return *C;
+  static Config Default;
+  return Default;
+}
+
+} // namespace clangd
+} // namespace clang

diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
new file mode 100644
index ..c1c2cbbd3a1e
--- /dev/null
+++ b/clang-tools-extra/clangd/Config.h
@@ -0,0 +1,64 @@
+//===--- Config.h - User configuration of clangd behavior *- 
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
+//
+//===--===//
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// This file defines "resolved" configuration seen by features within clangd.
+// For example, settings may vary per-file, the resolved Config only contains
+// settings that apply to the current file.
+//
+// This is distinct from how the config is specified by the user (Fragment)
+// interpreted (CompiledFragment), and combined (Provider).
+// ConfigFragment.h describes the steps to add a new configuration option.
+//
+// Because this structure is shared throughout clangd, it's a potential source
+// of layering problems. Config should be expressed in terms of simple
+// vocubulary types where possible.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+
+#include "support/Context.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Settings that express user/project preferences and control clangd behavior.
+///
+/// Generally, features should consume config() and the caller is responsible
+/// for setting it appropriately. In practice these callers are ClangdServer,
+/// TUScheduler, and BackgroundQueue.
+struct Config {
+  /// Context key which can be used to set the current 

[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7893-7897
+llvm::errs() << "DEBUG in CGOpenMPRuntime.cpp\n";
+OASE->getLowerBound()->dump();
+OASE->getLength()->dump();
+OASE->getStride()->dump();
+

Must be removed



Comment at: clang/lib/Sema/SemaExpr.cpp:4907
+  if (Stride) {
+auto Res =
+PerformOpenMPImplicitIntegerConversion(Stride->getExprLoc(), Stride);

`auto`->`ExprResult`



Comment at: clang/test/OpenMP/target_update_ast_print.cpp:66
 
+#pragma omp target update from(marr [1:1:1] [0:2:] [1:0])
+

It would be good to add some positive tests for other constructs, like 
`target`, `target data` etc., if allowed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[clang] 7c2cb14 - Revert "[clang][SourceManager] cache Macro Expansions"

2020-06-29 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-06-29T12:54:32-07:00
New Revision: 7c2cb1448ad2d20e251db5e3ae4a0c84c12aa970

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

LOG: Revert "[clang][SourceManager] cache Macro Expansions"

This reverts commit dffc1420451f674731cb36799c8ae084104ff0b5.

Missed a hunk (D82690).

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 5c5a9974d7f9..425bef717574 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -861,8 +861,11 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) 
const {
 --I;
 if (I->getOffset() <= SLocOffset) {
   FileID Res = FileID::get(int(I - LocalSLocEntryTable.begin()));
-  // Remember it.  We have good locality across FileID lookups.
-  LastFileIDLookup = Res;
+
+  // If this isn't an expansion, remember it.  We have good locality across
+  // FileID lookups.
+  if (!I->isExpansion())
+LastFileIDLookup = Res;
   NumLinearScans += NumProbes+1;
   return Res;
 }
@@ -937,7 +940,9 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) 
const {
 const SrcMgr::SLocEntry  = getLoadedSLocEntry(I);
 if (E.getOffset() <= SLocOffset) {
   FileID Res = FileID::get(-int(I) - 2);
-  LastFileIDLookup = Res;
+
+  if (!E.isExpansion())
+LastFileIDLookup = Res;
   NumLinearScans += NumProbes + 1;
   return Res;
 }
@@ -970,7 +975,8 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) 
const {
 
 if (isOffsetInFileID(FileID::get(-int(MiddleIndex) - 2), SLocOffset)) {
   FileID Res = FileID::get(-int(MiddleIndex) - 2);
-  LastFileIDLookup = Res;
+  if (!E.isExpansion())
+LastFileIDLookup = Res;
   NumBinaryProbes += NumProbes;
   return Res;
 }



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


[clang] 7b8cf98 - Reland "[clang][SourceManager] cache Macro Expansions""

2020-06-29 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-06-29T12:54:32-07:00
New Revision: 7b8cf98b4a9a2f5ea3667fdbf913a4f8952ed36a

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

LOG: Reland "[clang][SourceManager] cache Macro Expansions""

This reverts commit 33d63f02ce408d181e13089ee5a667fb2e1cdc78.

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

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 425bef717574..0a76c78cd44f 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -861,11 +861,8 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) 
const {
 --I;
 if (I->getOffset() <= SLocOffset) {
   FileID Res = FileID::get(int(I - LocalSLocEntryTable.begin()));
-
-  // If this isn't an expansion, remember it.  We have good locality across
-  // FileID lookups.
-  if (!I->isExpansion())
-LastFileIDLookup = Res;
+  // Remember it.  We have good locality across FileID lookups.
+  LastFileIDLookup = Res;
   NumLinearScans += NumProbes+1;
   return Res;
 }
@@ -899,10 +896,8 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) 
const {
 SLocOffset < getLocalSLocEntry(MiddleIndex + 1).getOffset()) {
   FileID Res = FileID::get(MiddleIndex);
 
-  // If this isn't a macro expansion, remember it.  We have good locality
-  // across FileID lookups.
-  if (!LocalSLocEntryTable[MiddleIndex].isExpansion())
-LastFileIDLookup = Res;
+  // Remember it.  We have good locality across FileID lookups.
+  LastFileIDLookup = Res;
   NumBinaryProbes += NumProbes;
   return Res;
 }
@@ -940,9 +935,7 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) 
const {
 const SrcMgr::SLocEntry  = getLoadedSLocEntry(I);
 if (E.getOffset() <= SLocOffset) {
   FileID Res = FileID::get(-int(I) - 2);
-
-  if (!E.isExpansion())
-LastFileIDLookup = Res;
+  LastFileIDLookup = Res;
   NumLinearScans += NumProbes + 1;
   return Res;
 }
@@ -975,8 +968,7 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) 
const {
 
 if (isOffsetInFileID(FileID::get(-int(MiddleIndex) - 2), SLocOffset)) {
   FileID Res = FileID::get(-int(MiddleIndex) - 2);
-  if (!E.isExpansion())
-LastFileIDLookup = Res;
+  LastFileIDLookup = Res;
   NumBinaryProbes += NumProbes;
   return Res;
 }



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


[clang-tools-extra] a3684df - Revert "[clangd] Config: config struct propagated through Context"

2020-06-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-29T21:41:57+02:00
New Revision: a3684dfc45c3a7bbdf72750d8a527e07e776b608

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

LOG: Revert "[clangd] Config: config struct propagated through Context"

This reverts commit 9963d93b0731e21dd1c9c1cebf8baaecf2010330.

Fails on mac/win:
http://45.33.8.238/win/18704/step_9.txt
http://45.33.8.238/mac/16341/step_9.txt

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Removed: 
clang-tools-extra/clangd/Config.cpp
clang-tools-extra/clangd/Config.h



diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 20a32d28e119..de3dd81a81db 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -36,7 +36,6 @@ add_clang_library(clangDaemon
   CollectMacros.cpp
   CompileCommands.cpp
   Compiler.cpp
-  Config.cpp
   ConfigYAML.cpp
   Diagnostics.cpp
   DraftStore.cpp

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f9d5cccf5baf..a2d704f57bda 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "CompileCommands.h"
-#include "Config.h"
 #include "support/Logger.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
@@ -183,10 +182,6 @@ CommandMangler CommandMangler::forTests() {
 }
 
 void CommandMangler::adjust(std::vector ) const {
-  // FIXME: remove const_cast once unique_function is const-compatible.
-  for (auto  : const_cast(config()).CompileFlags.Edits)
-Edit(Cmd);
-
   // Check whether the flag exists, either as -flag or -flag=*
   auto Has = [&](llvm::StringRef Flag) {
 for (llvm::StringRef Arg : Cmd) {

diff  --git a/clang-tools-extra/clangd/Config.cpp 
b/clang-tools-extra/clangd/Config.cpp
deleted file mode 100644
index 699b03e52484..
--- a/clang-tools-extra/clangd/Config.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===--- Config.cpp - User configuration of clangd behavior 
---===//
-//
-// 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 "Config.h"
-#include "support/Context.h"
-
-namespace clang {
-namespace clangd {
-
-Key Config::Key;
-
-const Config () {
-  if (const Config *C = Context::current().get(Config::Key))
-return *C;
-  static Config Default;
-  return Default;
-}
-
-} // namespace clangd
-} // namespace clang

diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
deleted file mode 100644
index c1c2cbbd3a1e..
--- a/clang-tools-extra/clangd/Config.h
+++ /dev/null
@@ -1,64 +0,0 @@
-//===--- Config.h - User configuration of clangd behavior *- 
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
-//
-//===--===//
-//
-// Various clangd features have configurable behaviour (or can be disabled).
-// This file defines "resolved" configuration seen by features within clangd.
-// For example, settings may vary per-file, the resolved Config only contains
-// settings that apply to the current file.
-//
-// This is distinct from how the config is specified by the user (Fragment)
-// interpreted (CompiledFragment), and combined (Provider).
-// ConfigFragment.h describes the steps to add a new configuration option.
-//
-// Because this structure is shared throughout clangd, it's a potential source
-// of layering problems. Config should be expressed in terms of simple
-// vocubulary types where possible.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
-
-#include "support/Context.h"
-#include "llvm/ADT/FunctionExtras.h"
-#include 
-#include 
-
-namespace clang {
-namespace clangd {
-
-/// Settings that express user/project preferences and control clangd behavior.
-///
-/// Generally, features should consume config() and the caller is responsible
-/// for setting it appropriately. In practice these callers are ClangdServer,
-/// 

[PATCH] D82696: [darwin][driver] isMacosxVersionLT should check against the minimum supported OS version

2020-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7a14514ee63: [darwin][driver] isMacosxVersionLT should 
check against the minimum supported… (authored by arphaman).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D82696?vs=273868=274202#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82696

Files:
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1624,6 +1624,17 @@
   }
 }
 
+VersionTuple Triple::getMinimumSupportedOSVersion() const {
+  if (getVendor() != Triple::Apple || getArch() != Triple::aarch64)
+return VersionTuple();
+  /// ARM64 slice is supported starting from macOS 11.0+.
+  if (getOS() == Triple::MacOSX)
+return VersionTuple(11, 0, 0);
+  if (getOS() == Triple::IOS && isMacCatalystEnvironment())
+return VersionTuple(14, 0, 0);
+  return VersionTuple();
+}
+
 StringRef Triple::getARMCPUForArch(StringRef MArch) const {
   if (MArch.empty())
 MArch = getArchName();
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -860,6 +860,12 @@
   /// Merge target triples.
   std::string merge(const Triple ) const;
 
+  /// Some platforms have different minimum supported OS versions that
+  /// varies by the architecture specified in the triple. This function
+  /// returns the minimum supported OS version for this triple if one an exists,
+  /// or an invalid version tuple if this triple doesn't have one.
+  VersionTuple getMinimumSupportedOSVersion() const;
+
   /// @}
   /// @name Static helpers for IDs.
   /// @{
Index: clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
===
--- /dev/null
+++ clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang -### -target arm64-apple-macos10.7 %s 2>&1 | FileCheck -check-prefix=ARM64-10_7 %s
+// RUN: %clang -### -target x86_64-apple-macos10.7 %s 2>&1 | FileCheck -check-prefix=x86_64-10_7 %s
+
+// RUN: %clang -### -target arm64-apple-macos10.5 %s 2>&1 | FileCheck -check-prefix=ARM64-10_5 %s
+// RUN: %clang -### -target x86_64-apple-macos10.5 %s 2>&1 | FileCheck -check-prefix=x86_64-10_5 %s
+
+// RUN: %clang -### -target arm64-apple-macos10.4 %s 2>&1 | FileCheck -check-prefix=ARM64-10_4 %s
+// RUN: %clang -### -target x86_64-apple-macos10.4 %s 2>&1 | FileCheck -check-prefix=x86_64-10_4 %s
+
+// RUN: %clang -### -target arm64-apple-macos10.5 -bundle %s 2>&1 | FileCheck -check-prefix=ARM64-BUNDLE %s
+// RUN: %clang -### -target x86_64-apple-macos10.5 -bundle %s 2>&1 | FileCheck -check-prefix=x86_64-BUNDLE %s
+
+// RUN: %clang -### -target arm64-apple-macos10.5 -dynamiclib %s 2>&1 | FileCheck -check-prefix=ARM64-10_5-DYNAMICLIB %s
+// RUN: %clang -### -target x86_64-apple-macos10.5 -dynamiclib %s 2>&1 | FileCheck -check-prefix=x86_64-10_5-DYNAMICLIB %s
+
+// RUN: %clang -### -target arm64-apple-macos10.4 -dynamiclib %s 2>&1 | FileCheck -check-prefix=ARM64-10_4-DYNAMICLIB %s
+// RUN: %clang -### -target arm64-apple-darwin8 -dynamiclib %s 2>&1 | FileCheck -check-prefix=ARM64-10_4-DYNAMICLIB %s
+// RUN: %clang -### -target x86_64-apple-macos10.4 -dynamiclib %s 2>&1 | FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s
+// RUN: %clang -### -target x86_64-apple-darwin8 -dynamiclib %s 2>&1 | FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s
+
+// RUN: %clang -### -target arm64-apple-macos10.7 -static %s 2>&1 | FileCheck -check-prefix=STATIC %s
+// RUN: %clang -### -target x86_64-apple-macos10.7 -static %s 2>&1 | FileCheck -check-prefix=STATIC %s
+
+// ARM64-10_7-NOT: -lcrt1.10.6.o
+// x86_64-10_7:-lcrt1.10.6.o
+
+// ARM64-10_5-NOT: -lcrt1.10.5.o
+// x86_64-10_5:-lcrt1.10.5.o
+
+// ARM64-10_4-NOT: -lcrt1.o
+// x86_64-10_4:-lcrt1.o
+
+// ARM64-BUNDLE-NOT: -lbundle1.o
+// x86_64-BUNDLE:-lbundle1.o
+
+// ARM64-10_5-DYNAMICLIB-NOT: -ldylib1.10.5.o
+// x86_64-10_5-DYNAMICLIB:-ldylib1.10.5.o
+
+// ARM64-10_4-DYNAMICLIB-NOT: -ldylib1.o
+// x86_64-10_4-DYNAMICLIB:-ldylib1.o
+
+// STATIC: -lcrt0.o
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -434,9 +434,17 @@
 return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
+  /// Returns true if the minimum supported macOS version for the slice that's
+  /// being built is less than the specified version. If there's no minimum
+  /// supported macOS version, the deployment target 

[PATCH] D80263: [HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.

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

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80263



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


[PATCH] D82720: [clang-tidy] performance-faster-string-find string-view

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 274200.
njames93 added a comment.

Update docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82720

Files:
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
  clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp
@@ -1,7 +1,8 @@
-// RUN: %check_clang_tidy %s performance-faster-string-find %t -- \
+// RUN: %check_clang_tidy %s performance-faster-string-find %t
+// RUN: %check_clang_tidy -check-suffix=CUSTOM %s performance-faster-string-find %t -- \
 // RUN:   -config="{CheckOptions: \
 // RUN: [{key: performance-faster-string-find.StringLikeClasses, \
-// RUN:   value: 'std::basic_string; ::llvm::StringRef;'}]}" --
+// RUN:   value: '::llvm::StringRef;'}]}"
 
 namespace std {
 template 
@@ -17,6 +18,20 @@
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+template 
+struct basic_string_view {
+  int find(const Char *, int = 0) const;
+  int find(const Char *, int, int) const;
+  int rfind(const Char *) const;
+  int find_first_of(const Char *) const;
+  int find_first_not_of(const Char *) const;
+  int find_last_of(const Char *) const;
+  int find_last_not_of(const Char *) const;
+};
+
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }  // namespace std
 
 namespace llvm {
@@ -75,11 +90,25 @@
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'find' called with a string literal
   // CHECK-FIXES: Str.find(L'\x3A9');
 
+  // std::string_view and std::wstring_view should work.
+  std::string_view StrView;
+  StrView.find("n");
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: 'find' called with a string literal
+  // CHECK-FIXES: StrView.find('n');
+  std::wstring_view WStrView;
+
+  WStrView.find(L"n");
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'find' called with a string literal
+  // CHECK-FIXES: WStrView.find(L'n');
+  WStrView.find(L"\x3A9");
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'find' called with a string literal
+  // CHECK-FIXES: WStrView.find(L'\x3A9');
+
   // Also with other types, but only if it was specified in the options.
   llvm::StringRef sr;
   sr.find("x");
-  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: 'find' called with a string literal
-  // CHECK-FIXES: sr.find('x');
+  // CHECK-MESSAGES-CUSTOM: [[@LINE-1]]:11: warning: 'find' called with a string literal
+  // CHECK-FIXES-CUSTOM: sr.find('x');
   NotStringRef nsr;
   nsr.find("x");
 }
Index: clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
@@ -23,6 +23,8 @@
 .. option:: StringLikeClasses
 
Semicolon-separated list of names of string-like classes. By default only
-   ``std::basic_string`` is considered. The list of methods to consired is
-   fixed.
+   ``::std::basic_string`` and ``::std::basic_string_view`` are considered. 
+   The check will only consider member functions named ``find``, ``rfind``, 
+   ``find_first_of``, ``find_first_not_of``, ``find_last_of``, or 
+   ``find_last_not_of`` within these classes.
 
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -195,6 +195,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'performance-faster-string-find
+  ` check.
+
+  Now checks ``std::basic_string_view`` by default.
+
 - Improved :doc:'readability-identifier-naming
   ` check.
 
Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -51,7 +51,8 @@
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   StringLikeClasses(utils::options::parseStringList(
-  Options.get("StringLikeClasses", "std::basic_string"))) {}
+  Options.get("StringLikeClasses",
+  "::std::basic_string;::std::basic_string_view"))) {}
 
 void FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   

[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

The test fails on mac and win:
http://45.33.8.238/mac/16341/step_9.txt
http://45.33.8.238/win/18704/step_9.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82606



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-06-29 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, sstefan1, arphaman, guansong, yaxunl.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82800

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/target_depend_messages.cpp
  clang/test/OpenMP/target_enter_data_depend_messages.cpp
  clang/test/OpenMP/target_exit_data_depend_messages.cpp
  clang/test/OpenMP/target_parallel_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_depend_messages.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/task_affinity_messages.cpp
  clang/test/OpenMP/task_depend_messages.cpp

Index: clang/test/OpenMP/task_depend_messages.cpp
===
--- clang/test/OpenMP/task_depend_messages.cpp
+++ clang/test/OpenMP/task_depend_messages.cpp
@@ -52,32 +52,60 @@
   #pragma omp task depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
   #pragma omp task depend (in : argv[-1:0]) // expected-error {{zero-length array section is not allowed in 'depend' clause}}
   #pragma omp task depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
-  #pragma omp task depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
-  #pragma omp task depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
-  #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
-  #pragma omp task depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
-  #pragma omp task depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
-  #pragma omp task depend(in : argv[ : argc][1 : argc - 1])
-  #pragma omp task depend(in : arr[0])
-  #pragma omp task depend(depobj:argc) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not 'int'}}
-  #pragma omp task depend(depobj : argv[ : argc][1 : argc - 1]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not ''}}
-  #pragma omp task depend(depobj : arr[0]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}
-  #pragma omp task depend(in : ([ // expected-error {{expected variable name or 'this' in lambda capture list}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp task depend(in : ([] // expected-error {{expected body of lambda expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp task depend(in : ([]) // omp45-error {{expected body of lambda expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error 2 {{expected expression}}
-  #pragma omp task depend(in : ([])a // omp45-error {{expected body of lambda expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected expression}}
-  #pragma omp task depend(in : ([])a) // omp45-error {{expected body of lambda expression}} omp50-error {{expected expression}}
-  #pragma omp task depend(in : ([a])a) // omp45-error {{expected body of lambda expression}} omp50-error {{expected expression with a pointer to a complete type as a base of an array shaping operation}}
-  #pragma omp task depend(in : ([a])argc) // omp45-error {{expected body of lambda expression}} omp50-error {{expected expression with a pointer to a complete type as a base of an array shaping 

[PATCH] D80791: [AArch64] Generate .note.gnu.property based on module flags.

2020-06-29 Thread Kees Cook via Phabricator via cfe-commits
kees added a comment.

In D80791#2120503 , @nickdesaulniers 
wrote:

> Might someone wish to disable PAC/BTI on an individual function, while having 
> it on for the rest?  I guess that would mean you can't call that function 
> indirectly?


It would mean you can't call it _at all_, not just indirectly. :) Which is why 
I still think the warning is useful. Perhaps don't warn for the functions with 
the attribute?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80791



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


[clang] f7a1451 - [darwin][driver] isMacosxVersionLT should check against the minimum supported OS version

2020-06-29 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-06-29T12:21:54-07:00
New Revision: f7a14514ee63dc2ab9558c50254efb8ac2ad7cc6

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

LOG: [darwin][driver] isMacosxVersionLT should check against the minimum 
supported OS version

This change ensures that the Darwin driver doesn't add unsupported libraries to 
the link
invocation when linking the Apple Silicon macOS slice.

rdar://61011136

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

Added: 
clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp

Modified: 
clang/lib/Driver/ToolChains/Darwin.h
llvm/include/llvm/ADT/Triple.h
llvm/lib/Support/Triple.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.h 
b/clang/lib/Driver/ToolChains/Darwin.h
index 438455996ccb..04c5bfa69a5a 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -434,9 +434,17 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
 return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
+  /// Returns true if the minimum supported macOS version for the slice that's
+  /// being built is less than the specified version. If there's no minimum
+  /// supported macOS version, the deployment target version is compared to the
+  /// specifed version instead.
   bool isMacosxVersionLT(unsigned V0, unsigned V1 = 0, unsigned V2 = 0) const {
-assert(isTargetMacOS() && "Unexpected call for non OS X target!");
-return TargetVersion < VersionTuple(V0, V1, V2);
+assert(isTargetMacOS() && getTriple().isMacOSX() &&
+   "Unexpected call for non OS X target!");
+VersionTuple MinVers = getTriple().getMinimumSupportedOSVersion();
+return (!MinVers.empty() && MinVers > TargetVersion
+? MinVers
+: TargetVersion) < VersionTuple(V0, V1, V2);
   }
 
 protected:

diff  --git a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp 
b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
new file mode 100644
index ..522fda34987e
--- /dev/null
+++ b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang -### -target arm64-apple-macos10.7 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_7 %s
+// RUN: %clang -### -target x86_64-apple-macos10.7 %s 2>&1 | FileCheck 
-check-prefix=x86_64-10_7 %s
+
+// RUN: %clang -### -target arm64-apple-macos10.5 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_5 %s
+// RUN: %clang -### -target x86_64-apple-macos10.5 %s 2>&1 | FileCheck 
-check-prefix=x86_64-10_5 %s
+
+// RUN: %clang -### -target arm64-apple-macos10.4 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_4 %s
+// RUN: %clang -### -target x86_64-apple-macos10.4 %s 2>&1 | FileCheck 
-check-prefix=x86_64-10_4 %s
+
+// RUN: %clang -### -target arm64-apple-macos10.5 -bundle %s 2>&1 | FileCheck 
-check-prefix=ARM64-BUNDLE %s
+// RUN: %clang -### -target x86_64-apple-macos10.5 -bundle %s 2>&1 | FileCheck 
-check-prefix=x86_64-BUNDLE %s
+
+// RUN: %clang -### -target arm64-apple-macos10.5 -dynamiclib %s 2>&1 | 
FileCheck -check-prefix=ARM64-10_5-DYNAMICLIB %s
+// RUN: %clang -### -target x86_64-apple-macos10.5 -dynamiclib %s 2>&1 | 
FileCheck -check-prefix=x86_64-10_5-DYNAMICLIB %s
+
+// RUN: %clang -### -target arm64-apple-macos10.4 -dynamiclib %s 2>&1 | 
FileCheck -check-prefix=ARM64-10_4-DYNAMICLIB %s
+// RUN: %clang -### -target arm64-apple-darwin8 -dynamiclib %s 2>&1 | 
FileCheck -check-prefix=ARM64-10_4-DYNAMICLIB %s
+// RUN: %clang -### -target x86_64-apple-macos10.4 -dynamiclib %s 2>&1 | 
FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s
+// RUN: %clang -### -target x86_64-apple-darwin8 -dynamiclib %s 2>&1 | 
FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s
+
+// RUN: %clang -### -target arm64-apple-macos10.7 -static %s 2>&1 | FileCheck 
-check-prefix=STATIC %s
+// RUN: %clang -### -target x86_64-apple-macos10.7 -static %s 2>&1 | FileCheck 
-check-prefix=STATIC %s
+
+// ARM64-10_7-NOT: -lcrt1.10.6.o
+// x86_64-10_7:-lcrt1.10.6.o
+
+// ARM64-10_5-NOT: -lcrt1.10.5.o
+// x86_64-10_5:-lcrt1.10.5.o
+
+// ARM64-10_4-NOT: -lcrt1.o
+// x86_64-10_4:-lcrt1.o
+
+// ARM64-BUNDLE-NOT: -lbundle1.o
+// x86_64-BUNDLE:-lbundle1.o
+
+// ARM64-10_5-DYNAMICLIB-NOT: -ldylib1.10.5.o
+// x86_64-10_5-DYNAMICLIB:-ldylib1.10.5.o
+
+// ARM64-10_4-DYNAMICLIB-NOT: -ldylib1.o
+// x86_64-10_4-DYNAMICLIB:-ldylib1.o
+
+// STATIC: -lcrt0.o

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 89679619dd55..6bad18f19244 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -860,6 +860,12 @@ class Triple {
   /// Merge target triples.
   std::string merge(const Triple ) const;
 
+  /// Some platforms have 
diff erent minimum supported OS versions 

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-29 Thread Zola Bridges via Phabricator via cfe-commits
zbrid added a comment.

@sconstab @craig.topper - Ping for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-29 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 rG9963d93b0731: [clangd] Config: config struct propagated 
through Context (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D82606?vs=273543=274194#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82606

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Config.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -7,7 +7,9 @@
 //===--===//
 
 #include "CompileCommands.h"
+#include "Config.h"
 #include "TestFS.h"
+#include "support/Context.h"
 
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
@@ -185,6 +187,26 @@
 }
 #endif
 
+TEST(CommandMangler, ConfigEdits) {
+  auto Mangler = CommandMangler::forTests();
+  std::vector Cmd = {"clang++", "foo.cc"};
+  {
+Config Cfg;
+Cfg.CompileFlags.Edits.push_back([](std::vector ) {
+  for (auto  : Argv)
+for (char  : Arg)
+  C = llvm::toUpper(C);
+});
+Cfg.CompileFlags.Edits.push_back(
+[](std::vector ) { Argv.push_back("--hello"); });
+WithContextValue WithConfig(Config::Key, std::move(Cfg));
+Mangler.adjust(Cmd);
+  }
+  // Edits are applied in given order and before other mangling.
+  EXPECT_THAT(Cmd,
+  ElementsAre("CLANG++", "FOO.CC", "--hello", "-fsyntax-only"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Config.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Config.h
@@ -0,0 +1,64 @@
+//===--- Config.h - User configuration of clangd behavior *- 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
+//
+//===--===//
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// This file defines "resolved" configuration seen by features within clangd.
+// For example, settings may vary per-file, the resolved Config only contains
+// settings that apply to the current file.
+//
+// This is distinct from how the config is specified by the user (Fragment)
+// interpreted (CompiledFragment), and combined (Provider).
+// ConfigFragment.h describes the steps to add a new configuration option.
+//
+// Because this structure is shared throughout clangd, it's a potential source
+// of layering problems. Config should be expressed in terms of simple
+// vocubulary types where possible.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+
+#include "support/Context.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Settings that express user/project preferences and control clangd behavior.
+///
+/// Generally, features should consume config() and the caller is responsible
+/// for setting it appropriately. In practice these callers are ClangdServer,
+/// TUScheduler, and BackgroundQueue.
+struct Config {
+  /// Context key which can be used to set the current Config.
+  static clangd::Key Key;
+
+  Config() = default;
+  Config(const Config &) = delete;
+  Config =(const Config &) = delete;
+  Config(Config &&) = default;
+  Config =(Config &&) = default;
+
+  /// Controls how the compile command for the current file is determined.
+  struct {
+// Edits to apply to the compile command, in sequence.
+// FIXME: these functions need to be const-callable. For now, const_cast.
+std::vector &)>> Edits;
+  } CompileFlags;
+};
+
+/// Returns the Config of the current Context, or an empty configuration.
+const Config ();
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/clangd/Config.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Config.cpp
@@ -0,0 +1,25 @@
+//===--- Config.cpp - User configuration of clangd behavior ---===//
+//
+// 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 

[PATCH] D82733: [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-29 Thread Philippe Blain via Phabricator via cfe-commits
phil-blain added inline comments.



Comment at: clang/docs/CommandGuide/clang.rst:477
 
+  Note: on Darwin, when using :option:`-flto` along with :option:`-g` and
+  compiling and linking in separate steps, you also need to pass

JDevlieghere wrote:
> Any reason not to use the sphinx note directive (`.. note::` )?
> 
> https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#paragraph-level-markup
None, appart from my limited knowledge of Sphinx directives ;) 

I'll fix that for v2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82733



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


[clang-tools-extra] 9963d93 - [clangd] Config: config struct propagated through Context

2020-06-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-29T20:18:48+02:00
New Revision: 9963d93b0731e21dd1c9c1cebf8baaecf2010330

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

LOG: [clangd] Config: config struct propagated through Context

Summary:
This introduces the "semantic form" of config exposed to features,
contrasted with the "syntactic form" exposed to users in e9fb1506b83d.

The two are not connected, CompiledFragment and Provider will bridge that gap.
Nor is configuration actually set: that needs changes to ClangdServer,
TUScheduler, and BackgroundQueue.

Reviewers: hokein, kadircet

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 
clang-tools-extra/clangd/Config.cpp
clang-tools-extra/clangd/Config.h

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index de3dd81a81db..20a32d28e119 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -36,6 +36,7 @@ add_clang_library(clangDaemon
   CollectMacros.cpp
   CompileCommands.cpp
   Compiler.cpp
+  Config.cpp
   ConfigYAML.cpp
   Diagnostics.cpp
   DraftStore.cpp

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index a2d704f57bda..f9d5cccf5baf 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "CompileCommands.h"
+#include "Config.h"
 #include "support/Logger.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
@@ -182,6 +183,10 @@ CommandMangler CommandMangler::forTests() {
 }
 
 void CommandMangler::adjust(std::vector ) const {
+  // FIXME: remove const_cast once unique_function is const-compatible.
+  for (auto  : const_cast(config()).CompileFlags.Edits)
+Edit(Cmd);
+
   // Check whether the flag exists, either as -flag or -flag=*
   auto Has = [&](llvm::StringRef Flag) {
 for (llvm::StringRef Arg : Cmd) {

diff  --git a/clang-tools-extra/clangd/Config.cpp 
b/clang-tools-extra/clangd/Config.cpp
new file mode 100644
index ..699b03e52484
--- /dev/null
+++ b/clang-tools-extra/clangd/Config.cpp
@@ -0,0 +1,25 @@
+//===--- Config.cpp - User configuration of clangd behavior 
---===//
+//
+// 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 "Config.h"
+#include "support/Context.h"
+
+namespace clang {
+namespace clangd {
+
+Key Config::Key;
+
+const Config () {
+  if (const Config *C = Context::current().get(Config::Key))
+return *C;
+  static Config Default;
+  return Default;
+}
+
+} // namespace clangd
+} // namespace clang

diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
new file mode 100644
index ..c1c2cbbd3a1e
--- /dev/null
+++ b/clang-tools-extra/clangd/Config.h
@@ -0,0 +1,64 @@
+//===--- Config.h - User configuration of clangd behavior *- 
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
+//
+//===--===//
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// This file defines "resolved" configuration seen by features within clangd.
+// For example, settings may vary per-file, the resolved Config only contains
+// settings that apply to the current file.
+//
+// This is distinct from how the config is specified by the user (Fragment)
+// interpreted (CompiledFragment), and combined (Provider).
+// ConfigFragment.h describes the steps to add a new configuration option.
+//
+// Because this structure is shared throughout clangd, it's a potential source
+// of layering problems. Config should be expressed in terms of simple
+// vocubulary types where possible.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+
+#include "support/Context.h"
+#include 

[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:187
+  // FIXME: remove const_cast once unique_function is const-compatible.
+  for (auto  : const_cast(Config::current()).CompileFlags.Edits)
+Edit(Cmd);

kadircet wrote:
> sammccall wrote:
> > kadircet wrote:
> > > what's the rationale behind applying this before any other mangling?
> > > 
> > > I can see that the rest of the mangling happens to make sure clangd works 
> > > out-of-the-box for "more" users, so should be safe to apply as a final 
> > > step.
> > > But on the other hand, applying config after those would give the user 
> > > full control over the final command, which I believe is equally important.
> > I'll be honest, I don't really know which is better here. The differences 
> > are subtle, and there are arguments for each. I think we should probably 
> > just pick one and be open to changing it later.
> > 
> > My reasoning for this behavior: currently the user view of compile commands 
> > is basically "strings in compile_commands.json", and this mangling we do is 
> > best thought of as modifying the behavior of the driver. E.g. in an ideal 
> > world `-fsyntax-only` would not be a flag, we'd just use APIs that imply 
> > that behavior.
> > In this view of the world, the user is expected to understand compile 
> > commands + tweaks but not the mangling, so placing tweaks after mangling 
> > means they can't really reason about the transformations. And it allows 
> > stripping structurally important things we inject like `fsyntax-only` which 
> > seems wrong.
> > 
> > This argument works better for some args/manglings than others, and the way 
> > we log args cuts against it a bit too. 
> SG, as you mentioned in the last paragraph I would be looking at logs to 
> figure out what my compile commands for a file are, but may be it's just me. 
> Hence having this tweaking in the middle was a little bit surprising. 
> (Moreover, if one day we decide to have build system integrations it might 
> imply there won't be any written compile_commands.json, but we'll rather 
> fetch them on the fly and logs might be the only way to look at those 
> commands. Even in such a scenario, I suppose changing the way we log might be 
> a better approach because we indeed do more manipulations even after logging 
> e.g. turning off preamble related options)
Yeah logging earlier would be nice but there's a layering problem - CDB doesn't 
know if this is a file we're actually editing, and we only want to log if it 
is. I think this is annoying, but not urgent to solve.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82606



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


[PATCH] D82729: [clangd] Make sure headers are available in FS inside FindSymbolsTests

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Why? workspaceSymbols depends on the index only.
ISTM the dynamic index + blockUntilIdle should be enough - what does the FS 
have to do with it?
Oh, is this a race condition due to async preamble builds?

---

I think a slightly more principled fix here is that we should just use TestTU + 
clangd::getWorkspaceSymbols directly and stop using ClangdServer.
We can land this as-is if tests are flaking and need a quick fix and TestTU is 
too invasive, but it seems it shouldn't be complicated. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82729



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


[PATCH] D82793: [clangd] Suppress GCC -Woverloaded-virtual by renaming ThreadsafeFS extension point

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov, kristof.beyls.
Herald added a project: clang.

By making all overloads non-virtual and delegating to a differently-named
private method, we avoid any (harmless) name-hiding in the subclasses.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82793

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -33,8 +33,7 @@
 // A VFS provider that returns TestFSes containing a provided set of files.
 class MockFS : public ThreadsafeFS {
 public:
-  IntrusiveRefCntPtr
-  view(llvm::NoneType) const override {
+  IntrusiveRefCntPtr viewImpl() const override {
 return buildTestFS(Files, Timestamps);
   }
 
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -273,8 +273,7 @@
 TEST_F(ClangdVFSTest, PropagatesContexts) {
   static Key Secret;
   struct ContextReadingFS : public ThreadsafeFS {
-IntrusiveRefCntPtr
-view(llvm::NoneType) const override {
+IntrusiveRefCntPtr viewImpl() const override {
   Got = Context::current().getExisting(Secret);
   return buildTestFS({});
 }
@@ -929,8 +928,7 @@
 StatRecordingFS(llvm::StringMap )
 : CountStats(CountStats) {}
 
-IntrusiveRefCntPtr
-view(llvm::NoneType) const override {
+IntrusiveRefCntPtr viewImpl() const override {
   class StatRecordingVFS : public llvm::vfs::ProxyFileSystem {
   public:
 StatRecordingVFS(IntrusiveRefCntPtr FS,
Index: clang-tools-extra/clangd/support/ThreadsafeFS.h
===
--- clang-tools-extra/clangd/support/ThreadsafeFS.h
+++ clang-tools-extra/clangd/support/ThreadsafeFS.h
@@ -30,20 +30,25 @@
   virtual ~ThreadsafeFS() = default;
 
   /// Obtain a vfs::FileSystem with an arbitrary initial working directory.
-  virtual llvm::IntrusiveRefCntPtr
-  view(llvm::NoneType CWD) const = 0;
+  llvm::IntrusiveRefCntPtr
+  view(llvm::NoneType CWD) const {
+return viewImpl();
+  }
 
   /// Obtain a vfs::FileSystem with a specified working directory.
   /// If the working directory can't be set (e.g. doesn't exist), logs and
   /// returns the FS anyway.
-  virtual llvm::IntrusiveRefCntPtr
-  view(PathRef CWD) const;
+  llvm::IntrusiveRefCntPtr view(PathRef CWD) const;
+
+private:
+  /// Overridden by implementations to provide a vfs::FileSystem.
+  /// This is distinct from view(NoneType) to avoid GCC's -Woverloaded-virtual.
+  virtual llvm::IntrusiveRefCntPtr viewImpl() const = 0;
 };
 
 class RealThreadsafeFS : public ThreadsafeFS {
 public:
-  llvm::IntrusiveRefCntPtr
-  view(llvm::NoneType) const override;
+  llvm::IntrusiveRefCntPtr viewImpl() const override;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/support/ThreadsafeFS.cpp
===
--- clang-tools-extra/clangd/support/ThreadsafeFS.cpp
+++ clang-tools-extra/clangd/support/ThreadsafeFS.cpp
@@ -83,7 +83,7 @@
 }
 
 llvm::IntrusiveRefCntPtr
-RealThreadsafeFS::view(llvm::NoneType) const {
+RealThreadsafeFS::viewImpl() const {
   // Avoid using memory-mapped files.
   // FIXME: Try to use a similar approach in Sema instead of relying on
   //propagation of the 'isVolatile' flag through all layers.
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -230,8 +230,7 @@
 scanPreamble(llvm::StringRef Contents, const tooling::CompileCommand ) {
   class EmptyFS : public ThreadsafeFS {
   public:
-llvm::IntrusiveRefCntPtr
-view(llvm::NoneType) const override {
+llvm::IntrusiveRefCntPtr viewImpl() const override {
   return new llvm::vfs::InMemoryFileSystem;
 }
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-29 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 274183.
asoffer added a comment.

Signed-comparison issue in test fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82226

Files:
  clang/include/clang/Tooling/Refactoring/AtomicChange.h
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Refactoring/AtomicChange.cpp
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/RefactoringTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -439,6 +439,29 @@
   Input, Expected);
 }
 
+TEST_F(TransformerTest, WithMetadata) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+
+  Transformer T(
+  makeRule(declStmt().bind("decl"),
+   withMetadata(remove(statement(std::string("decl"))), 17)),
+  consumer());
+  T.registerMatchers();
+  auto Factory = newFrontendActionFactory();
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Input, std::vector(), "input.cc",
+  "clang-tool", std::make_shared(), {}));
+  ASSERT_EQ(Changes.size(), 1u);
+  const llvm::Any  = Changes[0].getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/unittests/Tooling/RefactoringTest.cpp
===
--- clang/unittests/Tooling/RefactoringTest.cpp
+++ clang/unittests/Tooling/RefactoringTest.cpp
@@ -1296,6 +1296,18 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+TEST_F(AtomicChangeTest, Metadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc, 17);
+  const llvm::Any  = Change.getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_EQ(llvm::any_cast(Metadata), 17);
+}
+
+TEST_F(AtomicChangeTest, NoMetadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  EXPECT_FALSE(Change.getMetadata().hasValue());
+}
+
 class ApplyAtomicChangesTest : public ::testing::Test {
 protected:
   ApplyAtomicChangesTest() : FilePath("file.cc") {
Index: clang/lib/Tooling/Transformer/Transformer.cpp
===
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/lib/Tooling/Transformer/Transformer.cpp
@@ -53,7 +53,7 @@
 auto ID = Result.SourceManager->getFileID(T.Range.getBegin());
 auto Iter = ChangesByFileID
 .emplace(ID, AtomicChange(*Result.SourceManager,
-  T.Range.getBegin()))
+  T.Range.getBegin(), T.Metadata))
 .first;
 auto  = Iter->second;
 if (auto Err = AC.replace(*Result.SourceManager, T.Range, T.Replacement)) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -47,6 +47,7 @@
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
+T.Metadata = E.Metadata;
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/lib/Tooling/Refactoring/AtomicChange.cpp
===
--- clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -204,6 +204,12 @@
   Key = FilePath + ":" + std::to_string(FileIDAndOffset.second);
 }
 
+AtomicChange::AtomicChange(const SourceManager , SourceLocation KeyPosition,
+   llvm::Any M)
+: AtomicChange(SM, KeyPosition) {
+  Metadata = std::move(M);
+}
+
 AtomicChange::AtomicChange(std::string Key, std::string FilePath,
std::string Error,
std::vector InsertedHeaders,
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -35,6 +35,7 @@
 struct Edit {
   CharSourceRange Range;
   std::string Replacement;
+  llvm::Any Metadata;
 };
 
 /// Maps a match result to a list of concrete edits (with possible
@@ -85,6 +86,7 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
+  llvm::Any Metadata;
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -258,6 +260,11 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
+inline ASTEdit 

[PATCH] D82736: [clangd] Rename FS.view(None) to FS.viewWithDefaultCWD()

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D82736#2120089 , @Quuxplusone wrote:

> In D82736#2119262 , @sammccall wrote:
>
> > `viewWithDefaultCWD` suggests to me the default has some semantics which 
> > don't exist, if using this API "shape" I'd substitute `Arbitrary` here
>
>
> I'm naturally 100% fine with that. I can continue updating this patch if you 
> like; otherwise my default will be to abandon this patch on the assumption 
> that anything I can do, you can do better. :)D82793 
> 


Thanks! I put together D82793 . Feel free to 
ignore the below as my "for the record" nitpicking,..

>> - I think the argument for changing the *public* API is particularly weak 
>> (or missing?)...
> 
> Well, see, I would call that "the two overloads do **completely different 
> things**," right? One changes the CWD and the other doesn't.

Not really, that's an implementation detail! The contract is request vs no 
request of working directory.
With both overloads virtual (current state), the most reasonable implementation 
for a truly virtual FS is probably for one to return `new FSImpl(Path)` and the 
other to call `new FSImpl("/")`. But both the strategy and the directory chosen 
are impl-dependent.

> Also, splitting a single function `view(Optional)` into a pair of 
> overloads `view(PathRef)` and `view(NoneType)` does not work the way you seem 
> to be expecting it to.

It's a bit rude to assume that if you can't think of a reason, it must be 
everyone else that's ignorant. To recap what's been previously stated:

- an overload set is required to allow passing both `string` and `NoneType`, 
because string doesn't implicitly convert to Optional.
- large overload sets are prone to ambiguity problems
- we have out-of-tree callers that use yet-different string types
- the change that introduced this interface was primarily a renaming patch that 
touched many files (and so each change is trivial, but work to revert)
- making the overload set support actual optionals touches few files, but may 
introduce subtle compile problems and need to be reverted
- therefore we deferred the `Optional` overload until the dust settled 
from that patch (it hasn't) and possibly until it's actually needed.

I'm sure there are different ways to do this, but I can assure you that both 
author and reviewer understand how function calls work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82736



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


[PATCH] D82733: [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: clang/docs/CommandGuide/clang.rst:477
 
+  Note: on Darwin, when using :option:`-flto` along with :option:`-g` and
+  compiling and linking in separate steps, you also need to pass

Any reason not to use the sphinx note directive (`.. note::` )?

https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#paragraph-level-markup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82733



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

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

In D82188#2119980 , @thakis wrote:

> In this case, trunk was broken for > 12h, so I'd expect there's lots of 
> evidence of this being broken on cmake bots too. However, the mac bots aren't 
> on buildbot but on http://green.lab.llvm.org/green/ for whatever reason, and 
> I find that page hard to read. 
> http://green.lab.llvm.org/green/job/clang-stage1-RA/ has a bunch of red on 
> the LHS … ah yeah 
> http://green.lab.llvm.org/green/job/clang-stage1-RA/11966/console has "  
> Extra Tools Unit Tests :: 
> clang-tidy/./ClangTidyTests/ClangTidyDiagnosticConsumer.SortsErrors" at the 
> bottom.
>
> So this showed up on the regular mac bots, yes.
>
>  ---
>
> The tree's been broken for over half a day to this. I'd suggest taking 
> breakage supports a bit more serious going forward, instead of replying with 
> "it can't possibly be this patch" and "it must be bot setup weirdness" going 
> forward :)


Thanks for clarifying about the regular mac bots. Is this isolated to just mac 
bots?

If it is isolated then the logical reason for this failure would be a subtle 
bug in the host toolchain. 
When I landed for a second time, I noticed that the `TestCheck` in 
`ClangTidyDiagnosticsConsumerTest.cpp` gets instantiated, but the 
`registerMatchers` function never gets called, this is the root cause for why 
the test fails.
However you just need to read the the code to see how that situation shouldn't 
happen.
Without a mac to test on, I wont be able to investigate further(no pre merge 
mac test bot also makes this significantly harder for me to test), Tried 
testing on older clang compiler and wasn't able to reproduce any error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82699: [driver][arm64] Set target CPU to A12 for compiler invocations that target Apple Silicon

2020-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I'll fix up Clang.Preprocessor::aarch64-target-features.c test this morning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82699



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


  1   2   3   >