[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-04-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 255602.
balazske marked an inline comment as done.
balazske added a comment.

Moved test checker to debug package, changed macro to function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -1,8 +1,10 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-checker=debug.ExprInspection -analyzer-store region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.StreamTester -analyzer-checker=debug.ExprInspection -analyzer-store region -verify %s
 
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void StreamTesterChecker_make_feof_stream(FILE *);
+void StreamTesterChecker_make_ferror_stream(FILE *);
 
 void error_fopen() {
   FILE *F = fopen("file", "r");
@@ -25,16 +27,28 @@
   fclose(F);
 }
 
-void error_clearerr() {
+void stream_error_feof() {
   FILE *F = fopen("file", "r");
   if (!F)
 return;
-  int ch = fputc('a', F);
-  if (ch == EOF) {
-// FIXME: fputc not handled by checker yet, should expect TRUE
-clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
-clearerr(F);
-clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
-  }
+  StreamTesterChecker_make_feof_stream(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{TRUE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  clearerr(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  fclose(F);
+}
+
+void stream_error_ferror() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  StreamTesterChecker_make_ferror_stream(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+  clearerr(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
   fclose(F);
 }
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -19,17 +19,16 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
-#include 
 
 using namespace clang;
 using namespace ento;
-using namespace std::placeholders;
 
 namespace {
 
 /// Full state information about a stream pointer.
 struct StreamState {
   /// State of a stream symbol.
+  /// FIXME: We need maybe an "escaped" state later.
   enum KindTy {
 Opened, /// Stream is opened.
 Closed, /// Closed stream (an invalid stream pointer after it was closed).
@@ -37,37 +36,45 @@
   } State;
 
   /// The error state of a stream.
+  /// Valid only if the stream is opened.
+  /// It is assumed that feof and ferror flags are never true at the same time.
   enum ErrorKindTy {
-NoError,/// No error flag is set or stream is not open.
-EofError,   /// EOF condition (`feof` is true).
-OtherError, /// Other (non-EOF) error (`ferror` is true).
-AnyError/// EofError or OtherError, used if exact error is unknown.
+/// No error flag is set (or stream is not open).
+NoError,
+/// EOF condition (`feof` is true).
+FEof,
+/// Other generic (non-EOF) error (`ferror` is true).
+FError,
   } ErrorState = NoError;
 
   bool isOpened() const { return State == Opened; }
   bool isClosed() const { return State == Closed; }
   bool isOpenFailed() const { return State == OpenFailed; }
 
-  bool isNoError() const { return ErrorState == NoError; }
-  bool isEofError() const { return ErrorState == EofError; }
-  bool isOtherError() const { return ErrorState == OtherError; }
-  bool isAnyError() const { return ErrorState == AnyError; }
+  bool isNoError() const {
+assert(State == Opened && "Error undefined for closed stream.");
+return ErrorState == NoError;
+  }
+  bool isFEof() const {
+assert(State == Opened && "Error undefined for closed stream.");
+return ErrorState == FEof;
+  }
+  bool isFError() const {
+assert(State == Opened && "Error undefined for closed stream.");
+return ErrorState == FError;
+  }
 
   bool operator==(const StreamState &X) const {
+// In not opened state error should always NoError.
 return State == X.State && ErrorState == X.ErrorState;
   }
 
   static Str

[clang-tools-extra] 39e9149 - Fix unused variable warning in Protocol.cpp, NFCI

2020-04-06 Thread Karl-Johan Karlsson via cfe-commits

Author: Karl-Johan Karlsson
Date: 2020-04-07T08:39:17+02:00
New Revision: 39e9149d8e12d77cd389f55860ac2cb9a30b4552

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

LOG: Fix unused variable warning in Protocol.cpp, NFCI

Fixed gcc warning:
clang-tools-extra/clangd/Protocol.cpp:300:16: warning: unused variable 
'SemanticHighlighting' [-Wunused-variable]

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index cd8e6bc10dce..aa7b901da3f0 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -297,7 +297,7 @@ bool fromJSON(const llvm::json::Value &Params, 
ClientCapabilities &R) {
   SemanticHighlighting->getBoolean("semanticHighlighting"))
 R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
 }
-if (auto *SemanticHighlighting = TextDocument->getObject("semanticTokens"))
+if (TextDocument->getObject("semanticTokens"))
   R.SemanticTokens = true;
 if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
   if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))



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


Re: [clang] a8c8b62 - [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2020-04-06 Thread Mikael Holmén via cfe-commits
We see flakiness in the test in our bots too. Fails one time and then
passes again.

/Mikael

On Mon, 2020-04-06 at 21:03 -0400, Nico Weber via cfe-commits wrote:
> This isn't bot-dependent, it's been flaking on many different bots
> over the last few days. Here's one from just now: 
> http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/34705
> 
> On Mon, Apr 6, 2020 at 4:40 PM Volodymyr Sapsai 
> wrote:
> > Is there anything special in the builedbot configuration? Are you
> > still observing intermittent failures?
> > 
> > I’m double checking if we see similar failures internally but so
> > far looks like everything is working fine. I’ve only seen a single
> > failure 
> > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/18616
> > 
> > At the moment I don’t know what might be causing the non-
> > determinism. The type checking depends on the parsing order. We
> > rely that
> > 
> > @interface ParameterizedContainer (Cat)
> > 
> > is parsed before
> > 
> > - (ParameterizedContainer *)inCategory;
> > 
> > So we check type parameter T is consistent with original @interface
> > before using it. What is also confusing is that there is only a
> > single error. I  expect both a category and an extension to have
> > same errors.
> > 
> > > On Apr 5, 2020, at 10:10, Nico Weber  wrote:
> > > 
> > > The test here flakily fails, maybe 1 in 10 times: 
> > > http://45.33.8.238/mac/11180/step_7.txt
> > > 
> > > error: 'error' diagnostics seen but not expected: 
> > >   File /Users/thakis/src/llvm-
> > > project/clang/test/SemaObjC/parameterized_classes_subst.m Line
> > > 479: type argument 'T' (aka 'id') does not satisfy the bound
> > > ('id') of type parameter 'T'
> > > error: 'note' diagnostics seen but not expected: 
> > >   File /Users/thakis/src/llvm-
> > > project/clang/test/SemaObjC/parameterized_classes_subst.m Line
> > > 475: type parameter 'T' declared here
> > > 2 errors generated.
> > > 
> > > Maybe if this is emitted depends on the order of something in a
> > > data structure that has no deterministic order, or similar?
> > > 
> > > On Fri, Apr 3, 2020 at 7:29 PM Volodymyr Sapsai via cfe-commits <
> > > cfe-commits@lists.llvm.org> wrote:
> > > > Author: Volodymyr Sapsai
> > > > Date: 2020-04-03T16:29:02-07:00
> > > > New Revision: a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7
> > > > 
> > > > URL: 
> > > > https://github.com/llvm/llvm-project/commit/a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7
> > > > DIFF: 
> > > > https://github.com/llvm/llvm-project/commit/a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7.diff
> > > > 
> > > > LOG: [ObjC generics] Fix not inheriting type bounds in
> > > > categories/extensions.
> > > > 
> > > > When a category/extension doesn't repeat a type bound,
> > > > corresponding
> > > > type parameter is substituted with `id` when used as a type
> > > > argument. As
> > > > a result, in the added test case it was causing errors like
> > > > 
> > > > > type argument 'T' (aka 'id') does not satisfy the bound
> > > > ('id') of type parameter 'T'
> > > > 
> > > > We are already checking that type parameters should be
> > > > consistent
> > > > everywhere (see `checkTypeParamListConsistency`) and update
> > > > `ObjCTypeParamDecl` to have correct underlying type. And when
> > > > we use the
> > > > type parameter as a method return type or a method parameter
> > > > type, it is
> > > > substituted to the bounded type. But when we use the type
> > > > parameter as a
> > > > type argument, we check `ObjCTypeParamType` that wasn't updated
> > > > and
> > > > remains `id`.
> > > > 
> > > > Fix by updating not only `ObjCTypeParamDecl` UnderlyingType but
> > > > also
> > > > TypeForDecl as we use the underlying type to create a canonical
> > > > type for
> > > > `ObjCTypeParamType` (see `ASTContext::getObjCTypeParamType`).
> > > > 
> > > > This is a different approach to fixing the issue. The previous
> > > > one was
> > > > 02c2ab3d8872416589bd1a6ca3dfb96ba373a3b9 which was reverted in
> > > > 4c539e8da1b3de38a53ef3f7497f5c45a3243b61. The problem with the
> > > > previous
> > > > approach was that `ObjCTypeParamType::desugar` was returning
> > > > underlying
> > > > type for `ObjCTypeParamDecl` without applying any protocols
> > > > stored in
> > > > `ObjCTypeParamType`. It caused inconsistencies in comparing
> > > > types before
> > > > and after desugaring.
> > > > 
> > > > rdar://problem/54329242
> > > > 
> > > > Reviewed By: erik.pilkington
> > > > 
> > > > Differential Revision: https://reviews.llvm.org/D72872
> > > > 
> > > > Added: 
> > > > 
> > > > 
> > > > Modified: 
> > > > clang/include/clang/AST/ASTContext.h
> > > > clang/lib/AST/ASTContext.cpp
> > > > clang/lib/AST/Type.cpp
> > > > clang/lib/Sema/SemaDeclObjC.cpp
> > > >
> > > > clang/test/SemaObjC/parameterized_classes_collection_literal.m
> > > > clang/test/SemaObjC/parameterized_classes_subst.m
> > > > 
> > > > Removed: 
> > > > 
> > > > 
> > > > 
> > > > 

[PATCH] D77628: [Driver][X86] Add -mpad-max-prefix-size

2020-04-06 Thread Kan Shengchen via Phabricator via cfe-commits
skan added a comment.

The remote build failed due to a bug of Pre-merge checks, which tried to apply 
a landed patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77628



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


[PATCH] D77628: [Driver][X86] Add -mpad-max-prefix-size

2020-04-06 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 255583.
skan added a comment.

format the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77628

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/x86-malign-branch.c
  clang/test/Driver/x86-malign-branch.s


Index: clang/test/Driver/x86-malign-branch.s
===
--- clang/test/Driver/x86-malign-branch.s
+++ clang/test/Driver/x86-malign-branch.s
@@ -6,8 +6,8 @@
 // RUN: %clang -target x86_64 -malign-branch=fused,jcc,jmp %s -c -### %s 2>&1 
| FileCheck %s --check-prefix=TYPE
 // TYPE: "-mllvm" "-x86-align-branch=fused+jcc+jmp"
 
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX
-// PREFIX: "-mllvm" "-x86-align-branch-prefix-size=5"
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX
+// PREFIX: "-mllvm" "-x86-pad-max-prefix-size=5"
 
 // RUN: %clang -target x86_64 -mbranches-within-32B-boundaries %s -c -### 2>&1 
| FileCheck %s --check-prefix=32B
 // 32B: "-mllvm" "-x86-branches-within-32B-boundaries"
Index: clang/test/Driver/x86-malign-branch.c
===
--- clang/test/Driver/x86-malign-branch.c
+++ clang/test/Driver/x86-malign-branch.c
@@ -18,13 +18,13 @@
 // TYPE-ERR: invalid argument 'foo' to -malign-branch=; each element must be 
one of: fused, jcc, jmp, call, ret, indirect
 // TYPE-ERR: invalid argument 'bar' to -malign-branch=; each element must be 
one of: fused, jcc, jmp, call, ret, indirect
 
-/// Test -malign-branch-prefix-size=
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=0 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-0
-// PREFIX-0: "-mllvm" "-x86-align-branch-prefix-size=0"
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-5
-// PREFIX-5: "-mllvm" "-x86-align-branch-prefix-size=5"
+/// Test -mpad-max-prefix-size=
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=0 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-0
+// PREFIX-0: "-mllvm" "-x86-pad-max-prefix-size=0"
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-5
+// PREFIX-5: "-mllvm" "-x86-pad-max-prefix-size=5"
 
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=6 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-6
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=6 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-6
 // PREFIX-6: invalid argument
 
 /// Test -mbranches-within-32B-boundaries
@@ -34,6 +34,6 @@
 /// Unsupported on other targets.
 // RUN: %clang -target aarch64 -malign-branch=jmp %s -c -### 2>&1 | FileCheck 
--check-prefix=UNUSED %s
 // RUN: %clang -target aarch64 -malign-branch-boundary=7 %s -c -### 2>&1 | 
FileCheck --check-prefix=UNUSED %s
-// RUN: %clang -target aarch64 -malign-branch-prefix-size=15 %s -c -### 2>&1 | 
FileCheck --check-prefix=UNUSED %s
+// RUN: %clang -target aarch64 -mpad-max-prefix-size=15 %s -c -### 2>&1 | 
FileCheck --check-prefix=UNUSED %s
 // RUN: %clang -target aarch64 -mbranches-within-32B-boundaries %s -c -### 
2>&1 | FileCheck --check-prefix=UNUSED %s
 // UNUSED: warning: argument unused
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2078,8 +2078,7 @@
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back(Args.MakeArgString("-x86-align-branch=" + AlignBranch));
   }
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_malign_branch_prefix_size_EQ)) {
+  if (const Arg *A = Args.getLastArg(options::OPT_mpad_max_prefix_size_EQ)) {
 StringRef Value = A->getValue();
 unsigned PrefixSize;
 if (Value.getAsInteger(10, PrefixSize) || PrefixSize > 5) {
@@ -2087,8 +2086,8 @@
   << Value << A->getOption().getName();
 } else {
   CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back(Args.MakeArgString("-x86-align-branch-prefix-size=" +
-   Twine(PrefixSize)));
+  CmdArgs.push_back(
+  Args.MakeArgString("-x86-pad-max-prefix-size=" + Twine(PrefixSize)));
 }
   }
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2187,7 +2187,8 @@
   HelpText<"Specify types of branches to align">;
 def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group, Flags<[DriverOption]>,
   HelpText<"Specify the boundary's size to align branches">;
-def malign_branch_prefix_size_EQ : Joined<["-"], 
"malign-branch-prefix-size=">, Group;

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-06 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added inline comments.



Comment at: clang/test/CodeGenHIP/builtin_memory_fence.cpp:9
+  // CHECK: fence syncscope("workgroup") seq_cst
+  __builtin_memory_fence(__ATOMIC_SEQ_CST,  "workgroup");
+  

JonChesterfield wrote:
> JonChesterfield wrote:
> > sameerds wrote:
> > > JonChesterfield wrote:
> > > > sameerds wrote:
> > > > > JonChesterfield wrote:
> > > > > > saiislam wrote:
> > > > > > > sameerds wrote:
> > > > > > > > Orderings like `__ATOMIC_SEQ_CST` are defined for C/C++ memory 
> > > > > > > > models. They should not be used with the new builtin because 
> > > > > > > > this new builtin does not follow any specific language model. 
> > > > > > > > For user convenience, the right thing to do is to introduce new 
> > > > > > > > tokens in the Clang preprocessor, similar to the `__ATOMIC_*` 
> > > > > > > > tokens. The convenient shortcut is to just tell the user to 
> > > > > > > > supply numerical values by looking at the LLVM source code.
> > > > > > > > 
> > > > > > > > From llvm/Support/AtomicOrdering.h, note how the numerical 
> > > > > > > > value for `__ATOMIC_SEQ_CST` is 5, but the numerical value for 
> > > > > > > > the LLVM SequentiallyConsistent ordering is 7. The numerical 
> > > > > > > > value 5 refers to the LLVM ordering "release". So, if the 
> > > > > > > > implementation were correct, this line should result in the 
> > > > > > > > following unexpected LLVM IR:
> > > > > > > >   fence syncscope("workgroup") release
> > > > > > > As you pointed out, the range of acquire to sequentiallly 
> > > > > > > consistent memory orders for llvm::AtomicOrdering is [4, 7], 
> > > > > > > while for llvm::AtomicOrderingCABI is [2, 5]. Enums of C ABI was 
> > > > > > > taken to ensure easy of use for the users who are familiar with 
> > > > > > > C/C++ standard memory model. It allows them to use macros like 
> > > > > > > __ATOMIC_ACQUIRE etc.
> > > > > > > Clang CodeGen of the builtin internally maps C ABI ordering to 
> > > > > > > llvm atomic ordering.
> > > > > > What language, implemented in clang, do you have in mind that 
> > > > > > reusing the existing __ATOMIC_* macros would be incorrect for?
> > > > > I think we agreed that this builtin exposes the LLVM fence exactly. 
> > > > > That would mean it takes arguments defined by LLVM. If you are 
> > > > > implementing something different from that, then it first needs to be 
> > > > > specified properly. Perhaps you could say that this is a C ABI 
> > > > > compatible builtin, that happens to take target specific scopes? That 
> > > > > should cover OpenCL whose scope enum is designed to be compatible 
> > > > > with C.
> > > > > 
> > > > > Whatever it is that you are trying to implement here, it definitely 
> > > > > does not expose a raw LLVM fence.
> > > > The llvm fence, in text form, uses a symbol for the memory scope. Not 
> > > > an enum.
> > > > 
> > > > This symbol is set using these macros for the existing atomic builtins. 
> > > > Using an implementation detail of clang instead is strictly worse, by 
> > > > layering and by precedent.
> > > > 
> > > > ABI is not involved here. Nor is OpenCl.
> > > The `__ATOMIC_*` symbols in Clang quite literally represent the C/C++ 
> > > ABI. See the details in AtomicOrdering.h and InitPreprocessor.cpp. I am 
> > > not opposed to specifying that the builtin expects these symbols, but 
> > > then it is incorrect to say that the builtin exposes the raw LLVM 
> > > builtin. It is a C-ABI-compatible builtin that happens to take 
> > > target-specific scope as a string argument. And that would also make it 
> > > an overload of the already existing builting __atomic_fence().
> > I don't know what you mean by "raw",  but am guessing you're asking for 
> > documentation for the intrinsic. Said documentation should indeed be added 
> > for this builtin - it'll probably be in a tablegen file.
> I will try to stop using builtin and intrinsic as synonyms.
Right. It's actually an LLVM instruction, not even an intrinsic. I am guilty of 
using the wrong term quite often, but usually the context helps. I think the 
following is still needed:

  # A testcase that exercises the builtin with an invalid string argument for 
scope.
  # An update to the change description describing what is being introduced 
here. It is more than a direct mapping from builtin to instruction. The C ABI 
is involved.
  # An update to the Clang documentation describing this new builtin: 
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D77628: [Driver][X86] Add -mpad-max-prefix-size

2020-04-06 Thread Kan Shengchen via Phabricator via cfe-commits
skan created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
skan edited the summary of this revision.

The option `-mpad-max-prefix-size` performs some checking and delegate to MC 
option `-x86-pad-max-prefix-size`. This option is designed for eliminate NOPs 
when we need to align something by adding redundant prefixes to instructions, 
e.g. it can be used along with `-malign-branch`, `-malign-branch-boundary` to 
prefix padding branch.

It has similar (but slightly different) effect as GAS's option 
`-malign-branch-prefix-size`, e.g. `-mpad-max-prefix-size` can also elminate 
NOPs emitted by align directive, so we use a different name here. I remove the 
option `-malign-branch-prefix-size` since is unimplemented and not needed. If 
we need to be compatible with GAS, we can make `-malign-branch-prefix-size` an 
alias for this option later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77628

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/x86-malign-branch.c
  clang/test/Driver/x86-malign-branch.s


Index: clang/test/Driver/x86-malign-branch.s
===
--- clang/test/Driver/x86-malign-branch.s
+++ clang/test/Driver/x86-malign-branch.s
@@ -6,8 +6,8 @@
 // RUN: %clang -target x86_64 -malign-branch=fused,jcc,jmp %s -c -### %s 2>&1 
| FileCheck %s --check-prefix=TYPE
 // TYPE: "-mllvm" "-x86-align-branch=fused+jcc+jmp"
 
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX
-// PREFIX: "-mllvm" "-x86-align-branch-prefix-size=5"
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX
+// PREFIX: "-mllvm" "-x86-pad-max-prefix-size=5"
 
 // RUN: %clang -target x86_64 -mbranches-within-32B-boundaries %s -c -### 2>&1 
| FileCheck %s --check-prefix=32B
 // 32B: "-mllvm" "-x86-branches-within-32B-boundaries"
Index: clang/test/Driver/x86-malign-branch.c
===
--- clang/test/Driver/x86-malign-branch.c
+++ clang/test/Driver/x86-malign-branch.c
@@ -18,13 +18,13 @@
 // TYPE-ERR: invalid argument 'foo' to -malign-branch=; each element must be 
one of: fused, jcc, jmp, call, ret, indirect
 // TYPE-ERR: invalid argument 'bar' to -malign-branch=; each element must be 
one of: fused, jcc, jmp, call, ret, indirect
 
-/// Test -malign-branch-prefix-size=
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=0 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-0
-// PREFIX-0: "-mllvm" "-x86-align-branch-prefix-size=0"
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-5
-// PREFIX-5: "-mllvm" "-x86-align-branch-prefix-size=5"
+/// Test -mpad-max-prefix-size=
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=0 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-0
+// PREFIX-0: "-mllvm" "-x86-pad-max-prefix-size=0"
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=5 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-5
+// PREFIX-5: "-mllvm" "-x86-pad-max-prefix-size=5"
 
-// RUN: %clang -target x86_64 -malign-branch-prefix-size=6 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-6
+// RUN: %clang -target x86_64 -mpad-max-prefix-size=6 %s -c -### 2>&1 | 
FileCheck %s --check-prefix=PREFIX-6
 // PREFIX-6: invalid argument
 
 /// Test -mbranches-within-32B-boundaries
@@ -34,6 +34,6 @@
 /// Unsupported on other targets.
 // RUN: %clang -target aarch64 -malign-branch=jmp %s -c -### 2>&1 | FileCheck 
--check-prefix=UNUSED %s
 // RUN: %clang -target aarch64 -malign-branch-boundary=7 %s -c -### 2>&1 | 
FileCheck --check-prefix=UNUSED %s
-// RUN: %clang -target aarch64 -malign-branch-prefix-size=15 %s -c -### 2>&1 | 
FileCheck --check-prefix=UNUSED %s
+// RUN: %clang -target aarch64 -mpad-max-prefix-size=15 %s -c -### 2>&1 | 
FileCheck --check-prefix=UNUSED %s
 // RUN: %clang -target aarch64 -mbranches-within-32B-boundaries %s -c -### 
2>&1 | FileCheck --check-prefix=UNUSED %s
 // UNUSED: warning: argument unused
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2079,7 +2079,7 @@
 CmdArgs.push_back(Args.MakeArgString("-x86-align-branch=" + AlignBranch));
   }
   if (const Arg *A =
-  Args.getLastArg(options::OPT_malign_branch_prefix_size_EQ)) {
+  Args.getLastArg(options::OPT_mpad_max_prefix_size_EQ)) {
 StringRef Value = A->getValue();
 unsigned PrefixSize;
 if (Value.getAsInteger(10, PrefixSize) || PrefixSize > 5) {
@@ -2087,7 +2087,7 @@
   << Value << A->getOption().getName();
 } else {
   CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back(Args.MakeArgString("-x86-align-branch-prefix-size=" +
+  CmdArgs.pu

[PATCH] D76211: OpenMP Metadirective with user defined condition

2020-04-06 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu updated this revision to Diff 255575.
alokmishra.besu added a comment.

Updated the test cases.
Fixed an issue where correct code was not generated if directive variant was 
not provided in when/default clause


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76211

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.cpp
  clang/test/OpenMP/metadirective_codegen.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -92,6 +92,7 @@
 __OMP_DIRECTIVE_EXT(parallel_master_taskloop_simd,
 "parallel master taskloop simd")
 __OMP_DIRECTIVE(depobj)
+__OMP_DIRECTIVE(metadirective)
 
 // Has to be the last because Clang implicitly expects it to be.
 __OMP_DIRECTIVE(unknown)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -578,6 +578,9 @@
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2207,6 +2207,10 @@
   Visitor->AddStmt(C->getNumForLoops());
 }
 
+void OMPClauseEnqueue::VisitOMPWhenClause(const OMPWhenClause *C) {
+  Visitor->AddStmt(C->getExpr());
+}
+
 void OMPClauseEnqueue::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
 
 void OMPClauseEnqueue::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
@@ -5479,6 +5483,8 @@
 return cxstring::createRef("CXXAccessSpecifier");
   case CXCursor_ModuleImportDecl:
 return cxstring::createRef("ModuleImport");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_codegen.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -verify -fopenmp -emit-llvm %s -o - | FileCheck %s 
+// expected-no-diagnostics
+
+int main(int argc, char** argv)
+{
+  int N = 15;
+#pragma omp metadirective when(user={condition(N<=1)}: parallel ) when(user={condition(N>10)}: parallel for ) default()
+  for(int i=0; i10)}: parallel for ) default()
+// CHECK: #pragma omp metadirective when(N > 10: parallel for) default()
+  for(int i=0; igetState());
   Engine.addAbortedBlock(node, currBldrCtx->getBlock());
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2134,6 +2134,13 @@
 Record.AddStmt(S);
 }
 
+void ASTStmtWriter::VisitOMPMetaDirective(OMPMetaDirective *D) {
+  VisitStmt(D);
+  Record.push_back(D->getNumClauses());
+  VisitOMPExecutableDirective(D);
+  Code = serialization::STMT_OMP_META_DIRECTIVE;
+}
+
 void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) {
   VisitStmt(D);
   Record.push_back(D->getNumClauses());
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Seri

[PATCH] D77583: [hip] Remove `hip_pinned_shadow`.

2020-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77583



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


[PATCH] D62445: [test] Fix plugin tests

2020-04-06 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: cfe/trunk/test/CMakeLists.txt:140
-  set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
-
-  if (LLVM_WITH_Z3)

thakis wrote:
> Did you intentionally delete the 2 targets here? 
Not intentionally, although I don't remember the details right now.  Probably 
just a mistake on my part.

Do you want me to re-add them?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62445



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


[clang] c56975e - Fix template instantiation of a non-dependent call to an inherited

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

Author: Richard Smith
Date: 2020-04-06T19:20:30-07:00
New Revision: c56975e299e17a503066c98a3afaf02c5b231f9e

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

LOG: Fix template instantiation of a non-dependent call to an inherited
constructor with default arguments.

We used to try to rebuild the call as a call to the faked-up inherited
constructor, which is only a placeholder and lacks (for example) default
arguments. Instead, build the call by reference to the original
constructor.

In passing, add a note to say where a call that recursively uses a
default argument from within itself occurs. This is usually pretty
obvious, but still at least somewhat useful, and would have saved
significant debugging time for this particular bug.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/default2.cpp
clang/test/SemaTemplate/instantiate-init.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6ccb1c4af951..148f23f362dc 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3952,6 +3952,8 @@ def 
err_use_of_default_argument_to_function_declared_later : Error<
 def note_default_argument_declared_here : Note<
   "default argument declared here">;
 def err_recursive_default_argument : Error<"recursive evaluation of default 
argument">;
+def note_recursive_default_argument_used_here : Note<
+  "default argument used here">;
 
 def ext_param_promoted_not_compatible_with_prototype : ExtWarn<
   "%
diff {promoted type $ of K&R function parameter is not compatible with the "

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b311aad84816..a4f9c22138ee 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5284,6 +5284,7 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation CallLoc, 
FunctionDecl *FD,
   // If the default argument expression is not set yet, we are building it now.
   if (!Param->hasInit()) {
 Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD;
+Diag(CallLoc, diag::note_recursive_default_argument_used_here);
 Param->setInvalidDecl();
 return true;
   }

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1f88f9c57465..e9f4b11ca7bb 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3028,9 +3028,14 @@ class TreeTransform {
  bool RequiresZeroInit,
  CXXConstructExpr::ConstructionKind ConstructKind,
  SourceRange ParenRange) {
+// Reconstruct the constructor we originally found, which might be
+// 
diff erent if this is a call to an inherited constructor.
+CXXConstructorDecl *FoundCtor = Constructor;
+if (Constructor->isInheritingConstructor())
+  FoundCtor = Constructor->getInheritedConstructor().getConstructor();
+
 SmallVector ConvertedArgs;
-if (getSema().CompleteConstructorCall(Constructor, Args, Loc,
-  ConvertedArgs))
+if (getSema().CompleteConstructorCall(FoundCtor, Args, Loc, ConvertedArgs))
   return ExprError();
 
 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,

diff  --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp
index 8f77f300572b..4c8e8ce6941a 100644
--- a/clang/test/SemaCXX/default2.cpp
+++ b/clang/test/SemaCXX/default2.cpp
@@ -130,5 +130,8 @@ template  struct T {};  // 
expected-error-re {{use of u
 T<0, 1> t;
 
 struct PR28105 {
-  PR28105 (int = 0, int = 0, PR28105 = 0);  // expected-error{{recursive 
evaluation of default argument}}
+  PR28105 (int = 0, int = 0,
+  PR28105  // expected-error{{recursive evaluation of default argument}}
+  =
+  0); // expected-note {{default argument used here}}
 };

diff  --git a/clang/test/SemaTemplate/instantiate-init.cpp 
b/clang/test/SemaTemplate/instantiate-init.cpp
index 99b29c77d55a..6a4f65095dd5 100644
--- a/clang/test/SemaTemplate/instantiate-init.cpp
+++ b/clang/test/SemaTemplate/instantiate-init.cpp
@@ -1,5 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
+namespace std {
+  template struct initializer_list {
+T *p;
+__SIZE_TYPE__ n;
+initializer_list(T*, __SIZE_TYPE__);
+  };
+}
+
 struct X0 { // expected-note 8{{candidate}}
   X0(int*, float*); // expected-note 4{{candidate}}
 };
@@ -158,3 +166,15 @@ namespace InitListUpdate {
   void g(AA, AA);
   void h() { f<1, 2>(); } // expected-note {{instantiation of}}
 }
+
+namespace RebuildStdInitList {
+  

[PATCH] D77484: [Vector] Pass VectLib to LTO backend so TLI build correct vector function list

2020-04-06 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D77484#1965629 , @wenlei wrote:

> > Ok then it does sound like these could be handled on a per-function basis, 
> > similar to how -fno-builtin* are handled. I.e. a function attribute to 
> > indicate the veclib, which would then be naturally preserved during LTO 
> > even after merging/importing across modules. Similar to how -fno-builtin* 
> > are handled, these would need to be examined when inlining (see the new 
> > TargetLibraryInfo::areInlineCompatible). Presumably we would want to block 
> > inlining between functions with different veclib attributes in the LTO 
> > backends.
>
> @tejohnson, we could do that. But then on the other hand, technically almost 
> everything for module or whole program can be passed as a function attribute, 
> and yet we have switches passed to backend for many of those things. 
> Wondering what's the convention or rule (if there's one) we want to follow? 
> Specifically, if we only use function attributes for stuff that's indeed 
> going to be different between functions, then vectlib isn't in that category; 
> or if we use function attributes for the greatest flexibility whenever we 
> can, then many other things should be function attributes too (though it's 
> essentially duplication in IR, and probably not the most efficient).


Passing the option through the driver to the linker is the legacy approach. But 
it isn't really scalable and has other issues, so we've been moving towards 
having all the necessary info in the IR itself. For one, this helps deal with 
cases where different options were specified for different source files. For 
another, it keeps the same build behavior with LTO and non-LTO. I.e. for this 
option, if the build system specified it for the cc compiles but not the links, 
it would work for O2  but not for 
LTO if it had to be propagated via the linker. It would work for LTO if it was 
propagated via the IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77484



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


[PATCH] D77583: [hip] Remove `hip_pinned_shadow`.

2020-04-06 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D77583#1965823 , @yaxunl wrote:

> Is the runtime and HIP directed test change in place?


yeah, I verified several tests using texture references.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77583



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


[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

2020-04-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 255560.
jdoerfert added a comment.

Override `RebuildCallExpr` in the template instantiation and specialize calls 
only there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp

Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s   | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
+// expected-no-diagnostics
+
+int also_before() {
+  return 1;
+}
+
+#pragma omp begin declare variant match(implementation={vendor(score(100):llvm)})
+int also_after(void) {
+  return 2;
+}
+int also_after(int) {
+  return 3;
+}
+int also_after(double) {
+  return 0;
+}
+#pragma omp end declare variant
+#pragma omp begin declare variant match(implementation={vendor(score(0):llvm)})
+int also_before() {
+  return 0;
+}
+#pragma omp end declare variant
+
+int also_after(void) {
+  return 4;
+}
+int also_after(int) {
+  return 5;
+}
+int also_after(double) {
+  return 6;
+}
+
+template
+int test1() {
+  // Should return 0.
+  return also_after(T(0));
+}
+
+typedef int(*Ty)();
+
+template
+int test2() {
+  // Should return 0.
+  return fn();
+}
+
+int test() {
+  // Should return 0.
+  return test1() + test2();
+}
+
+// CHECK:  |-FunctionDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:5 used also_before 'int ({{.*}})'
+// CHECK-NEXT: | |-CompoundStmt [[ADDR_1:0x[a-z0-9]*]] 
+// CHECK-NEXT: | | `-ReturnStmt [[ADDR_2:0x[a-z0-9]*]] 
+// CHECK-NEXT: | |   `-IntegerLiteral [[ADDR_3:0x[a-z0-9]*]]  'int' 1
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_4:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(0): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_5:0x[a-z0-9]*]]  'int ({{.*}})' Function [[ADDR_6:0x[a-z0-9]*]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_7:0x[a-z0-9]*]]  col:5 implicit also_after 'int ({{.*}})'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_8:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_9:0x[a-z0-9]*]]  'int ({{.*}})' Function [[ADDR_10:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_10]]  line:10:1 also_after[implementation={vendor(llvm)}] 'int ({{.*}})'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_11:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_12:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_13:0x[a-z0-9]*]]  'int' 2
+// CHECK-NEXT: |-FunctionDecl [[ADDR_14:0x[a-z0-9]*]]  col:5 implicit also_after 'int (int)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]]  col:19 'int'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_16:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_17:0x[a-z0-9]*]]  'int (int)' Function [[ADDR_18:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (int)'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_18]]  line:13:1 also_after[implementation={vendor(llvm)}] 'int (int)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_15]]  col:19 'int'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_19:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_20:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_21:0x[a-z0-9]*]]  'int' 3
+// CHECK-NEXT: |-FunctionDecl [[ADDR_22:0x[a-z0-9]*]]  col:5 implicit used also_after 'int (double)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_23:0x[a-z0-9]*]]  col:22 'double'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_24:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_25:0x[a-z0-9]*]]  'int (double)' Function [[ADDR_26:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (double)'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_26]]  line:16:1 also_after[implementation={vendor(llvm)}] 'int (double)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_23]]  col:22 'double'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_27:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_28:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_29:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: |-FunctionDecl [[ADDR_6]]  line:21:1 also_before[implementation={vendor(llvm)}] 'int ({{.*}})'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_30:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_31:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_32:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: |-FunctionDecl [[ADDR_33:0x[a-z0-9]*]] prev [[ADDR_7]]  line:26:5 also_after 'int ({{.*}})'
+// CH

[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

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



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8260
 }
-return Result;
+
+if (!SemaRef.getLangOpts().OpenMP || !Result.isUsable() ||

mikerice wrote:
> I was expecting the code would be added to RebuildCallExpr in 
> TreeTransform.h.  This seems to just override one of the classes derived from 
> TreeTransform.  
> 
> I think I'd try adding it to TreeTransform then check all the cases where a 
> subclass overrides RebuildCallExpr and try to determine if something needs to 
> be done there.
I'm not paying attention -.-

This is the one class that overrides `RebuildCallExpr` in clang and obviously 
not the right place for this. I will put it in `TreeTransform::RebuildCallExpr` 
which is in `clang/lib/Sema/TreeTransform.h` now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290



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


[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

2020-04-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I figured in TreeTransform everyone would get this behavior but actually only 
template instantiation wants it so I put it there instead.  Do you think it is 
better placed in the generic TreeTransform code after all?
At least this time I verified the test passes. Sorry for that btw.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290



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


[PATCH] D77507: [clangd] Fix HitMapping assertion in Tokens.cpp

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

In D77507#1964309 , @vabridgers wrote:

> Thank you for the comments. I'll keep looking at this to find a proper fix, 
> but any hints you may have would be greatly appreciated (debugging tips, 
> strategies, areas of code to focus on). This code is new to me, so I may not 
> be as efficient at tracking this down as yourself or Ilya. Best!


Hope you don't mind, I ended up writing up a fix myself. (Well, I got 
frustrated with TokenBuffer's internals being complicated, and rewrote some of 
it in a way that makes this bug easy to fix.) D77615 
 is the proposed fix for this bug, and D77614 
 is the required refactoring.

FWIW I don't have much great advice about debugging this stuff beyond 
minimizing the example as far as possible and instrumenting with lots of 
printfs...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77507



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-04-06 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

jyknight@ Hi, pinging again 🔔🔔🔔 (sorry!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951



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


Re: [clang] a8c8b62 - [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2020-04-06 Thread Nico Weber via cfe-commits
This isn't bot-dependent, it's been flaking on many different bots over the
last few days. Here's one from just now:
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/34705

On Mon, Apr 6, 2020 at 4:40 PM Volodymyr Sapsai  wrote:

> Is there anything special in the builedbot configuration? Are you still
> observing intermittent failures?
>
> I’m double checking if we see similar failures internally but so far looks
> like everything is working fine. I’ve only seen a single failure
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/18616
>
> At the moment I don’t know what might be causing the non-determinism. The
> type checking depends on the parsing order. We rely that
>
> @interface ParameterizedContainer (Cat)
>
> is parsed before
>
> - (ParameterizedContainer *)inCategory;
>
> So we check type parameter T is consistent with original @interface before
> using it. What is also confusing is that there is only a single error. I
>  expect both a category and an extension to have same errors.
>
> On Apr 5, 2020, at 10:10, Nico Weber  wrote:
>
> The test here flakily fails, maybe 1 in 10 times:
> http://45.33.8.238/mac/11180/step_7.txt
>
> error: 'error' diagnostics seen but not expected:
>   File
> /Users/thakis/src/llvm-project/clang/test/SemaObjC/parameterized_classes_subst.m
> Line 479: type argument 'T' (aka 'id') does not satisfy the bound
> ('id') of type parameter 'T'
> error: 'note' diagnostics seen but not expected:
>   File
> /Users/thakis/src/llvm-project/clang/test/SemaObjC/parameterized_classes_subst.m
> Line 475: type parameter 'T' declared here
> 2 errors generated.
>
> Maybe if this is emitted depends on the order of something in a data
> structure that has no deterministic order, or similar?
>
> On Fri, Apr 3, 2020 at 7:29 PM Volodymyr Sapsai via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Volodymyr Sapsai
>> Date: 2020-04-03T16:29:02-07:00
>> New Revision: a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7.diff
>>
>> LOG: [ObjC generics] Fix not inheriting type bounds in
>> categories/extensions.
>>
>> When a category/extension doesn't repeat a type bound, corresponding
>> type parameter is substituted with `id` when used as a type argument. As
>> a result, in the added test case it was causing errors like
>>
>> > type argument 'T' (aka 'id') does not satisfy the bound
>> ('id') of type parameter 'T'
>>
>> We are already checking that type parameters should be consistent
>> everywhere (see `checkTypeParamListConsistency`) and update
>> `ObjCTypeParamDecl` to have correct underlying type. And when we use the
>> type parameter as a method return type or a method parameter type, it is
>> substituted to the bounded type. But when we use the type parameter as a
>> type argument, we check `ObjCTypeParamType` that wasn't updated and
>> remains `id`.
>>
>> Fix by updating not only `ObjCTypeParamDecl` UnderlyingType but also
>> TypeForDecl as we use the underlying type to create a canonical type for
>> `ObjCTypeParamType` (see `ASTContext::getObjCTypeParamType`).
>>
>> This is a different approach to fixing the issue. The previous one was
>> 02c2ab3d8872416589bd1a6ca3dfb96ba373a3b9 which was reverted in
>> 4c539e8da1b3de38a53ef3f7497f5c45a3243b61. The problem with the previous
>> approach was that `ObjCTypeParamType::desugar` was returning underlying
>> type for `ObjCTypeParamDecl` without applying any protocols stored in
>> `ObjCTypeParamType`. It caused inconsistencies in comparing types before
>> and after desugaring.
>>
>> rdar://problem/54329242
>>
>> Reviewed By: erik.pilkington
>>
>> Differential Revision: https://reviews.llvm.org/D72872
>>
>> Added:
>>
>>
>> Modified:
>> clang/include/clang/AST/ASTContext.h
>> clang/lib/AST/ASTContext.cpp
>> clang/lib/AST/Type.cpp
>> clang/lib/Sema/SemaDeclObjC.cpp
>> clang/test/SemaObjC/parameterized_classes_collection_literal.m
>> clang/test/SemaObjC/parameterized_classes_subst.m
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/include/clang/AST/ASTContext.h
>> b/clang/include/clang/AST/ASTContext.h
>> index 6813ab58874e..6360f18217c7 100644
>> --- a/clang/include/clang/AST/ASTContext.h
>> +++ b/clang/include/clang/AST/ASTContext.h
>> @@ -1442,6 +1442,8 @@ class ASTContext : public
>> RefCountedBase {
>>
>>QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
>>  ArrayRef protocols)
>> const;
>> +  void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig,
>> +ObjCTypeParamDecl *New) const;
>>
>>bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl
>> *Decl);
>>
>>
>> diff  --git a/clang/lib/AST

[PATCH] D77615: [Syntax] Merge overlapping top-level macros in TokenBuffer

2020-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: kadircet, vabridgers.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
sammccall added a parent revision: D77614: [Syntax] Simplify 
TokenCollector::Builder, use captured expansion bounds. NFC.

Our previous definition of "top-level" was too informal, and didn't
allow for overlapping macros that each directly produce expanded tokens.
See D77507  for previous discussion.

Fixes http://bugs.llvm.org/show_bug.cgi?id=45428


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77615

Files:
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -497,11 +497,28 @@
   mappings:
 ['#'_0, 'int'_7) => ['int'_0, 'int'_0)
 ['FOO'_10, ''_11) => ['10'_3, ''_7)
-)"}};
+)"},
+  {R"cpp(
+ #define NUM 42
+ #define ID(a) a
+ #define M 1 + ID
+ M(NUM)
+   )cpp",
+   R"(expanded tokens:
+  1 + 42
+file './input.cpp'
+  spelled tokens:
+# define NUM 42 # define ID ( a ) a # define M 1 + ID M ( NUM )
+  mappings:
+['#'_0, 'M'_17) => ['1'_0, '1'_0)
+['M'_17, ''_21) => ['1'_0, ''_3)
+)"},
+  };
 
-  for (auto &Test : TestCases)
-EXPECT_EQ(Test.second, collectAndDump(Test.first))
-<< collectAndDump(Test.first);
+  for (auto &Test : TestCases) {
+std::string Dump = collectAndDump(Test.first);
+EXPECT_EQ(Test.second, Dump) << Dump;
+  }
 }
 
 TEST_F(TokenCollectorTest, SpecialTokens) {
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -436,14 +436,37 @@
 SourceRange Range, const MacroArgs *Args) override {
 if (!Collector)
   return;
-// Only record top-level expansions, not those where:
+const auto &SM = Collector->PP.getSourceManager();
+// Only record top-level expansions that directly produce expanded tokens.
+// This excludes those where:
 //   - the macro use is inside a macro body,
 //   - the macro appears in an argument to another macro.
-if (!MacroNameTok.getLocation().isFileID() ||
-(LastExpansionEnd.isValid() &&
- Collector->PP.getSourceManager().isBeforeInTranslationUnit(
- Range.getBegin(), LastExpansionEnd)))
+// However macro expansion isn't really a tree, it's token rewrite rules,
+// so there are other cases, e.g.
+//   #define B(X) X
+//   #define A 1 + B
+//   A(2)
+// Both A and B produce expanded tokens, though the macro name 'B' comes
+// from an expansion. The best we can do is merge the mappings for both.
+
+// The *last* token of the macro reference is in the main file for A and B.
+if (Range.getEnd().isMacroID())
   return;
+// If there's a current expansion that encloses this one, this one can't be
+// top-level.
+if (LastExpansionEnd.isValid() &&
+!SM.isBeforeInTranslationUnit(LastExpansionEnd, Range.getEnd()))
+  return;
+
+// If the macro invocation B starts in a macro A but ends in a file, we'll
+// create a merged mapping for A & B by overwriting the endpoint for A's
+// startpoint.
+if (!Range.getBegin().isFileID()) {
+  Range.setBegin(SM.getExpansionLoc(Range.getBegin()));
+  assert(Collector->Expansions.count(Range.getBegin().getRawEncoding()) &&
+ "Overlapping macros should have same expansion location");
+}
+
 Collector->Expansions[Range.getBegin().getRawEncoding()] = Range.getEnd();
 LastExpansionEnd = Range.getEnd();
   }


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -497,11 +497,28 @@
   mappings:
 ['#'_0, 'int'_7) => ['int'_0, 'int'_0)
 ['FOO'_10, ''_11) => ['10'_3, ''_7)
-)"}};
+)"},
+  {R"cpp(
+ #define NUM 42
+ #define ID(a) a
+ #define M 1 + ID
+ M(NUM)
+   )cpp",
+   R"(expanded tokens:
+  1 + 42
+file './input.cpp'
+  spelled tokens:
+# define NUM 42 # define ID ( a ) a # define M 1 + ID M ( NUM )
+  mappings:
+['#'_0, 'M'_17) => ['1'_0, '1'_0)
+['M'_17, ''_21) => ['1'_0, ''_3)
+)"},
+  };
 
-  for (auto &Test : TestCases)
-EXPECT_EQ(Test.second, collectAndDump(Test.first))
-<< collectAndDump(Test.first);
+  for (auto &Test : TestCases) {
+std::string Dump = collectAndDump(Test.first);
+EXPECT_EQ(Test.second, Dump) << Dump;
+  }
 }
 
 TEST_F(TokenCollectorTest, SpecialTokens) {
Index: clang/lib/Tooling/Syntax/Tokens.cpp
==

[PATCH] D77614: [Syntax] Simplify TokenCollector::Builder, use captured expansion bounds. NFC

2020-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
sammccall updated this revision to Diff 21.
sammccall added a comment.
sammccall added a child revision: D77615: [Syntax] Merge overlapping top-level 
macros in TokenBuffer.

drop accidental change


The motivation here is fixing https://bugs.llvm.org/show_bug.cgi?id=45428, see
D77507 . The fundamental problem is that a 
"top-level" expansion wasn't precisely
defined. Repairing this concept means that TokenBuffer's "top-level expansion"
may not correspond to a single macro expansion. Example:

  #define ID(X) X
  #define M 1+ID
  M(2); // expands to 1+2

The expansions overlap, but neither expansion alone yields all the tokens.
We need a TokenBuffer::Mapping that corresponds to their union.

This is fairly easy to fix in CollectPPExpansions, but the current design of
TokenCollector::Builder needs a fix too as it relies on the macro's expansion
range rather than the captured expansion bounds. This fix is hard to make due
to the way code is reused within Builder. And honestly, I found that code pretty
hard to reason about too.

The new approach doesn't use the expansion range, but only the expansion
location: it assumes an expansion is the contiguous set of expanded tokens with
the same expansion location, which seems like a reasonable formalization of
the "top-level" notion.

And hopefully the control flow is easier to follow too, it's considerably
shorter even with more documentation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77614

Files:
  clang/lib/Tooling/Syntax/Tokens.cpp

Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -500,196 +500,150 @@
   }
 
   TokenBuffer build() && {
-buildSpelledTokens();
-
-// Walk over expanded tokens and spelled tokens in parallel, building the
-// mappings between those using source locations.
-// To correctly recover empty macro expansions, we also take locations
-// reported to PPCallbacks::MacroExpands into account as we do not have any
-// expanded tokens with source locations to guide us.
-
-// The 'eof' token is special, it is not part of spelled token stream. We
-// handle it separately at the end.
 assert(!Result.ExpandedTokens.empty());
 assert(Result.ExpandedTokens.back().kind() == tok::eof);
-for (unsigned I = 0; I < Result.ExpandedTokens.size() - 1; ++I) {
-  // (!) I might be updated by the following call.
-  processExpandedToken(I);
-}
 
-// 'eof' not handled in the loop, do it here.
-assert(SM.getMainFileID() ==
-   SM.getFileID(Result.ExpandedTokens.back().location()));
-fillGapUntil(Result.Files[SM.getMainFileID()],
- Result.ExpandedTokens.back().location(),
- Result.ExpandedTokens.size() - 1);
-Result.Files[SM.getMainFileID()].EndExpanded = Result.ExpandedTokens.size();
+// Tokenize every file that contributed tokens to the expanded stream.
+buildSpelledTokens();
 
-// Some files might have unaccounted spelled tokens at the end, add an empty
-// mapping for those as they did not have expanded counterparts.
-fillGapsAtEndOfFiles();
+// The expanded token stream consists of runs of tokens that came from
+// the same source (a macro expansion, part of a file etc).
+// Between these runs are the logical positions of spelled tokens that
+// didn't expand to anything.
+while (NextExpanded < Result.ExpandedTokens.size() - 1 /* eof */) {
+  // Create empty mappings for spelled tokens that expanded to nothing here.
+  // Advances NextSpelled, but NextExpanded is unchanged.
+  discard();
+  // Create mapping for a contiguous run of expanded tokens.
+  // Advances NextExpanded past the run, and NextSpelled accordingly.
+  advance();
+}
+// If any tokens remain in any of the files, they didn't expand to anything.
+// Create empty mappings up until the end of the file.
+for (const auto& File : Result.Files)
+  discard(File.first);
 
 return std::move(Result);
   }
 
 private:
-  /// Process the next token in an expanded stream and move corresponding
-  /// spelled tokens, record any mapping if needed.
-  /// (!) \p I will be updated if this had to skip tokens, e.g. for macros.
-  void processExpandedToken(unsigned &I) {
-auto L = Result.ExpandedTokens[I].location();
-if (L.isMacroID()) {
-  processMacroExpansion(SM.getExpansionRange(L), I);
-  return;
-}
-if (L.isFileID()) {
-  auto FID = SM.getFileID(L);
-  TokenBuffer::MarkedFile &File = Result.Files[FID];
-
-  fillGapUntil(File, L, I);
-
-  // Skip the token.
-  assert(File.SpelledTokens[NextSpelled[FID]].location() == L &&
-  

[PATCH] D77614: [Syntax] Simplify TokenCollector::Builder, use captured expansion bounds. NFC

2020-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 21.
sammccall added a comment.

drop accidental change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77614

Files:
  clang/lib/Tooling/Syntax/Tokens.cpp

Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -500,196 +500,150 @@
   }
 
   TokenBuffer build() && {
-buildSpelledTokens();
-
-// Walk over expanded tokens and spelled tokens in parallel, building the
-// mappings between those using source locations.
-// To correctly recover empty macro expansions, we also take locations
-// reported to PPCallbacks::MacroExpands into account as we do not have any
-// expanded tokens with source locations to guide us.
-
-// The 'eof' token is special, it is not part of spelled token stream. We
-// handle it separately at the end.
 assert(!Result.ExpandedTokens.empty());
 assert(Result.ExpandedTokens.back().kind() == tok::eof);
-for (unsigned I = 0; I < Result.ExpandedTokens.size() - 1; ++I) {
-  // (!) I might be updated by the following call.
-  processExpandedToken(I);
-}
 
-// 'eof' not handled in the loop, do it here.
-assert(SM.getMainFileID() ==
-   SM.getFileID(Result.ExpandedTokens.back().location()));
-fillGapUntil(Result.Files[SM.getMainFileID()],
- Result.ExpandedTokens.back().location(),
- Result.ExpandedTokens.size() - 1);
-Result.Files[SM.getMainFileID()].EndExpanded = Result.ExpandedTokens.size();
+// Tokenize every file that contributed tokens to the expanded stream.
+buildSpelledTokens();
 
-// Some files might have unaccounted spelled tokens at the end, add an empty
-// mapping for those as they did not have expanded counterparts.
-fillGapsAtEndOfFiles();
+// The expanded token stream consists of runs of tokens that came from
+// the same source (a macro expansion, part of a file etc).
+// Between these runs are the logical positions of spelled tokens that
+// didn't expand to anything.
+while (NextExpanded < Result.ExpandedTokens.size() - 1 /* eof */) {
+  // Create empty mappings for spelled tokens that expanded to nothing here.
+  // Advances NextSpelled, but NextExpanded is unchanged.
+  discard();
+  // Create mapping for a contiguous run of expanded tokens.
+  // Advances NextExpanded past the run, and NextSpelled accordingly.
+  advance();
+}
+// If any tokens remain in any of the files, they didn't expand to anything.
+// Create empty mappings up until the end of the file.
+for (const auto& File : Result.Files)
+  discard(File.first);
 
 return std::move(Result);
   }
 
 private:
-  /// Process the next token in an expanded stream and move corresponding
-  /// spelled tokens, record any mapping if needed.
-  /// (!) \p I will be updated if this had to skip tokens, e.g. for macros.
-  void processExpandedToken(unsigned &I) {
-auto L = Result.ExpandedTokens[I].location();
-if (L.isMacroID()) {
-  processMacroExpansion(SM.getExpansionRange(L), I);
-  return;
-}
-if (L.isFileID()) {
-  auto FID = SM.getFileID(L);
-  TokenBuffer::MarkedFile &File = Result.Files[FID];
-
-  fillGapUntil(File, L, I);
-
-  // Skip the token.
-  assert(File.SpelledTokens[NextSpelled[FID]].location() == L &&
- "no corresponding token in the spelled stream");
-  ++NextSpelled[FID];
-  return;
+  // Consume a sequence of spelled tokens that didn't expand to anything.
+  // In the simplest case, skips spelled tokens until finding one that produced
+  // the NextExpanded token, and creates an empty mapping for them.
+  // If Drain is provided, skips remaining tokens from that file instead.
+  void discard(llvm::Optional Drain = llvm::None) {
+SourceLocation Target =
+Drain ? SM.getLocForEndOfFile(*Drain)
+  : SM.getExpansionLoc(
+Result.ExpandedTokens[NextExpanded].location());
+FileID File = SM.getFileID(Target);
+const auto &SpelledTokens = Result.Files[File].SpelledTokens;
+auto &NextSpelled = this->NextSpelled[File];
+
+TokenBuffer::Mapping Mapping;
+Mapping.BeginSpelled = NextSpelled;
+// When dropping trailing tokens from a file, the empty mapping should
+// be positioned within the file's expanded-token range (at the end).
+Mapping.BeginExpanded = Mapping.EndExpanded =
+Drain ? Result.Files[*Drain].EndExpanded : NextExpanded;
+// We may want to split into several adjacent empty mappings.
+// FlushMapping() emits the current mapping and starts a new one.
+auto FlushMapping = [&, this] {
+  Mapping.EndSpelled = NextSpelled;
+  if (Mapping.BeginSpelled != Mapping.EndSpelled)
+Resu

[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

2020-04-06 Thread Mike Rice via Phabricator via cfe-commits
mikerice added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8260
 }
-return Result;
+
+if (!SemaRef.getLangOpts().OpenMP || !Result.isUsable() ||

I was expecting the code would be added to RebuildCallExpr in TreeTransform.h.  
This seems to just override one of the classes derived from TreeTransform.  

I think I'd try adding it to TreeTransform then check all the cases where a 
subclass overrides RebuildCallExpr and try to determine if something needs to 
be done there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290



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


[PATCH] D75661: Remove SequentialType from the type heirarchy.

2020-04-06 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68b03aee1a15: Remove SequentialType from the type heirarchy. 
(authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D75661?vs=252659&id=255546#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75661

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/GetElementPtrTypeIterator.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -51,12 +51,16 @@
 return result;
   }
 
-  if (!isa(type)) {
+  llvm::Type *elementType;
+  if (auto *arrayTy = dyn_cast(type)) {
+elementType = arrayTy->getElementType();
+  } else if (auto *vectorTy = dyn_cast(type)) {
+elementType = vectorTy->getElementType();
+  } else {
 emitError(loc) << "expected sequential LLVM types wrapping a scalar";
 return nullptr;
   }
 
-  llvm::Type *elementType = type->getSequentialElementType();
   SmallVector nested;
   nested.reserve(shape.front());
   for (int64_t i = 0; i < shape.front(); ++i) {
@@ -74,9 +78,15 @@
 
 /// Returns the first non-sequential type nested in sequential types.
 static llvm::Type *getInnermostElementType(llvm::Type *type) {
-  while (isa(type))
-type = type->getSequentialElementType();
-  return type;
+  do {
+if (auto *arrayTy = dyn_cast(type)) {
+  type = arrayTy->getElementType();
+} else if (auto *vectorTy = dyn_cast(type)) {
+  type = vectorTy->getElementType();
+} else {
+  return type;
+}
+  } while (1);
 }
 
 /// Create an LLVM IR constant of `llvmType` from the MLIR attribute `attr`.
@@ -106,17 +116,24 @@
 return llvm::ConstantExpr::getBitCast(
 functionMapping.lookup(funcAttr.getValue()), llvmType);
   if (auto splatAttr = attr.dyn_cast()) {
-auto *sequentialType = cast(llvmType);
-auto *elementType = sequentialType->getElementType();
-uint64_t numElements = sequentialType->getNumElements();
+llvm::Type *elementType;
+uint64_t numElements;
+if (auto *arrayTy = dyn_cast(llvmType)) {
+  elementType = arrayTy->getElementType();
+  numElements = arrayTy->getNumElements();
+} else {
+  auto *vectorTy = cast(llvmType);
+  elementType = vectorTy->getElementType();
+  numElements = vectorTy->getNumElements();
+}
 // Splat value is a scalar. Extract it only if the element type is not
 // another sequence type. The recursion terminates because each step removes
 // one outer sequential type.
+bool elementTypeSequential =
+isa(elementType) || isa(elementType);
 llvm::Constant *child = getLLVMConstant(
 elementType,
-isa(elementType) ? splatAttr
-   : splatAttr.getSplatValue(),
-loc);
+elementTypeSequential ? splatAttr : splatAttr.getSplatValue(), loc);
 if (!child)
   return nullptr;
 if (llvmType->isVectorTy())
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3131,7 +3131,8 @@
   unsigned N = 1;
   Type *EltTy = T;
 
-  while (isa(EltTy) || isa(EltTy)) {
+  while (isa(EltTy) || isa(EltTy) ||
+ isa(EltTy)) {
 if (auto *ST = dyn_cast(EltTy)) {
   // Check that struct is homogeneous.
   for (const auto *Ty : ST->elements())
@@ -3139,10 +3140,13 @@
   return 0;
   N *= ST->getNumElements();
   EltTy = *ST->element_begin();
+} else if (auto *AT = dyn_cast(EltTy)) {
+  N *= AT->getNumElements();
+  EltTy = AT->getElementType();
 } else {
-  auto *SeqT = cast(EltTy);
-  N *= SeqT->getNumElements();
-  EltTy = SeqT->getElementType();
+  auto *VT = cast(EltTy);
+  

[PATCH] D77583: [hip] Remove `hip_pinned_shadow`.

2020-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Is the runtime and HIP directed test change in place?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77583



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


[PATCH] D77611: [Sema] fix -Wunused-result in StmtExpr

2020-04-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added a comment.

ah, using this to build a Linux kernel triggers tons of warnings. So the 
behavior of GCC is even more subtle than captured in the test cases here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77611



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


[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-04-06 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4205
+
+class PPCAIX32TargetCodeGenInfo : public TargetCodeGenInfo {
+public:

I have a question here. AIX32 falls into PPC32 target, so why we don't inherit 
from `PPC32TargetCodeGenInfo` instead?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4210
+
+  int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
+return 1; // r1 is the dedicated stack pointer

Is `getDwarfEHStackPointer` necessary to be correct for vararg of AIX to work[I 
guess possibly not]? If not, should it fall into Dwarf related patch rather 
than in this one? BTW, if your `PPCAIX32TargetCodeGenInfo` inherits from 
`PPC32TargetCodeGenInfo` instead as I mentioned above, then it would be 
naturally correct.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4447
+CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const {
+  return true;
+}

As simple as this function is, does it make sense to move the body of `return 
true` into the class definition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76360



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


[PATCH] D77611: [Sema] fix -Wunused-result in StmtExpr

2020-04-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: dblaikie.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nickdesaulniers planned changes to this revision.
nickdesaulniers added a comment.

ah, using this to build a Linux kernel triggers tons of warnings. So the 
behavior of GCC is even more subtle than captured in the test cases here.


This is a partial revert of r163034; turns out it doesn't regress the
test case added with that commit.

Add a test case that demonstrates the previous issue; when a GNU C
statement expression is used in a macro Expr::isUnusedResultAWarning was
returning true, but the block removed in this commit from
Sema::DiagnoseUnusedExprResult was returning without emitting a Diag.

Fixes pr/45394.
Link: https://github.com/ClangBuiltLinux/linux/issues/968


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77611

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Frontend/macros.c


Index: clang/test/Frontend/macros.c
===
--- clang/test/Frontend/macros.c
+++ clang/test/Frontend/macros.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -DA= -DB=1 -verify -fsyntax-only %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -Wunused-result -DA= -DB=1 -verify -fsyntax-only %s
 
 int a[(B A) == 1 ? 1 : -1];
 
@@ -11,3 +10,16 @@
 void foo(int a, int b, int c) {
   memset(a,b,c);  // No warning!
 }
+
+__attribute__((warn_unused_result))
+static inline int bar(void) {
+return 42;
+}
+
+#define baz() ({\
+  bar(); \
+})
+
+void quux(void) {
+baz(); // expected-warning {{ignoring return value of function declared 
with 'warn_unused_result' attribute}}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -244,13 +244,6 @@
   if (!E->isUnusedResultAWarning(WarnExpr, Loc, R1, R2, Context))
 return;
 
-  // If this is a GNU statement expression expanded from a macro, it is 
probably
-  // unused because it is a function-like macro that can be used as either an
-  // expression or statement.  Don't warn, because it is almost certainly a
-  // false positive.
-  if (isa(E) && Loc.isMacroID())
-return;
-
   // Check if this is the UNREFERENCED_PARAMETER from the Microsoft headers.
   // That macro is frequently used to suppress "unused parameter" warnings,
   // but its implementation makes clang's -Wunused-value fire.  Prevent this.


Index: clang/test/Frontend/macros.c
===
--- clang/test/Frontend/macros.c
+++ clang/test/Frontend/macros.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -DA= -DB=1 -verify -fsyntax-only %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -Wunused-result -DA= -DB=1 -verify -fsyntax-only %s
 
 int a[(B A) == 1 ? 1 : -1];
 
@@ -11,3 +10,16 @@
 void foo(int a, int b, int c) {
   memset(a,b,c);  // No warning!
 }
+
+__attribute__((warn_unused_result))
+static inline int bar(void) {
+return 42;
+}
+
+#define baz() ({\
+  bar(); \
+})
+
+void quux(void) {
+baz(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -244,13 +244,6 @@
   if (!E->isUnusedResultAWarning(WarnExpr, Loc, R1, R2, Context))
 return;
 
-  // If this is a GNU statement expression expanded from a macro, it is probably
-  // unused because it is a function-like macro that can be used as either an
-  // expression or statement.  Don't warn, because it is almost certainly a
-  // false positive.
-  if (isa(E) && Loc.isMacroID())
-return;
-
   // Check if this is the UNREFERENCED_PARAMETER from the Microsoft headers.
   // That macro is frequently used to suppress "unused parameter" warnings,
   // but its implementation makes clang's -Wunused-value fire.  Prevent this.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 68b03ae - Remove SequentialType from the type heirarchy.

2020-04-06 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-04-06T17:03:49-07:00
New Revision: 68b03aee1a15678ab5b518148d5e75c9dc0436fd

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

LOG: Remove SequentialType from the type heirarchy.

Now that we have scalable vectors, there's a distinction that isn't
getting captured in the original SequentialType: some vectors don't have
a known element count, so counting the number of elements doesn't make
sense.

In some cases, there's a better way to express the commonality using
other methods. If we're dealing with GEPs, there's GEP methods; if we're
dealing with a ConstantDataSequential, we can query its element type
directly.

In the relatively few remaining cases, I just decided to write out
the type checks. We're talking about relatively few places, and I think
the abstraction doesn't really carry its weight. (See thread "[RFC]
Refactor class hierarchy of VectorType in the IR" on llvmdev.)

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp
llvm/include/llvm/IR/Constants.h
llvm/include/llvm/IR/DerivedTypes.h
llvm/include/llvm/IR/GetElementPtrTypeIterator.h
llvm/include/llvm/IR/Type.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/Type.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/FunctionComparator.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index da5d778a4922..fad7d754f551 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -318,12 +318,17 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   CharUnits Offset = Offsets[Index];
 
   if (auto *CA = dyn_cast(C)) {
+// Expand the sequence into its contained elements.
+// FIXME: This assumes vector elements are byte-sized.
 replace(Elems, Index, Index + 1,
 llvm::map_range(llvm::seq(0u, CA->getNumOperands()),
 [&](unsigned Op) { return CA->getOperand(Op); }));
-if (auto *Seq = dyn_cast(CA->getType())) {
+if (isa(CA->getType()) ||
+isa(CA->getType())) {
   // Array or vector.
-  CharUnits ElemSize = getSize(Seq->getElementType());
+  llvm::Type *ElemTy =
+  llvm::GetElementPtrInst::getTypeAtIndex(CA->getType(), (uint64_t)0);
+  CharUnits ElemSize = getSize(ElemTy);
   replace(
   Offsets, Index, Index + 1,
   llvm::map_range(llvm::seq(0u, CA->getNumOperands()),
@@ -344,6 +349,8 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   }
 
   if (auto *CDS = dyn_cast(C)) {
+// Expand the sequence into its contained elements.
+// FIXME: This assumes vector elements are byte-sized.
 // FIXME: If possible, split into two ConstantDataSequentials at Hint.
 CharUnits ElemSize = getSize(CDS->getElementType());
 replace(Elems, Index, Index + 1,
@@ -359,6 +366,7 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   }
 
   if (isa(C)) {
+// Split into two zeros at the hinted offset.
 CharUnits ElemSize = getSize(C);
 assert(Hint > Offset && Hint < Offset + ElemSize && "nothing to split");
 replace(Elems, Index, Index + 1,
@@ -368,6 +376,7 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   }
 
   if (isa(C)) {
+// Drop undef; it doesn't contribute to the final layout.
 replace(Elems, Index, Index + 1, {});
 replace(Offsets, Index, Index + 1, {});
 return true;

diff  --git a/llvm/include/llvm/IR/Constants.h 
b/llvm/include/llvm/IR/Constants.h
index 868b038b055d..c41d1582a834 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -44,7 +44,6 @@ namespace llvm {
 class ArrayType;
 class IntegerType;
 class PointerType;
-class SequentialType;
 class StructType;
 class VectorType;
 template  struct ConstantAggrKeyType;
@@ -631,12 +630,6 @@ class ConstantDataSequential : public ConstantData {
   /// efficient as getElementAsInteger/Float/Doub

[PATCH] D76680: [SveEmitter] Add immediate checks for lanes and complex imms

2020-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D76680



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


[PATCH] D77591: [SveEmitter] Explicitly merge with zero/undef

2020-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D77591/new/

https://reviews.llvm.org/D77591



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


[PATCH] D77596: [SveEmitter] Add NoOverload flag and builtin for svpfalse

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

Would it make sense to generalize getSVEType() to getSVETypeList()?  It seems 
like the current approach won't generalize well once you're dealing with more 
than one overloaded type (for example, llvm.aarch64.sve.scvtf.nxv8f16.nxv8i16).




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7665
+if (auto PredTy = dyn_cast(Call->getType()))
+  if (PredTy->getScalarType()->isIntegerTy(1))
+Call = EmitSVEPredicateCast(Call, cast(Ty));

getElementType().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77596



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


[clang] 8f2d2a7 - For PR45333: Move AnalyzeImplicitConversions to using data recursion

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

Author: Richard Smith
Date: 2020-04-06T16:49:27-07:00
New Revision: 8f2d2a7cb46572d51a7dddcf151fb202e4abeb4d

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

LOG: For PR45333: Move AnalyzeImplicitConversions to using data recursion
instead of recursing on the stack.

This doesn't actually resolve PR45333, because we now hit stack overflow
somewhere else, but it does get us further. I've not found any way of
testing this that doesn't still crash elsewhere.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index c3e168c1e736..736a88782e1d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11649,19 +11649,30 @@ static void CheckBoolLikeConversion(Sema &S, Expr *E, 
SourceLocation CC) {
   CheckImplicitConversion(S, E->IgnoreParenImpCasts(), S.Context.BoolTy, CC);
 }
 
-/// AnalyzeImplicitConversions - Find and report any interesting
-/// implicit conversions in the given expression.  There are a couple
-/// of competing diagnostics here, -Wconversion and -Wsign-compare.
-static void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC,
-   bool IsListInit/*= false*/) {
+namespace {
+struct AnalyzeImplicitConversionsWorkItem {
+  Expr *E;
+  SourceLocation CC;
+  bool IsListInit;
+};
+}
+
+/// Data recursive variant of AnalyzeImplicitConversions. Subexpressions
+/// that should be visited are added to WorkList.
+static void AnalyzeImplicitConversions(
+Sema &S, AnalyzeImplicitConversionsWorkItem Item,
+llvm::SmallVectorImpl &WorkList) {
+  Expr *OrigE = Item.E;
+  SourceLocation CC = Item.CC;
+
   QualType T = OrigE->getType();
   Expr *E = OrigE->IgnoreParenImpCasts();
 
   // Propagate whether we are in a C++ list initialization expression.
   // If so, we do not issue warnings for implicit int-float conversion
   // precision loss, because C++11 narrowing already handles it.
-  IsListInit =
-  IsListInit || (isa(OrigE) && S.getLangOpts().CPlusPlus);
+  bool IsListInit = Item.IsListInit ||
+(isa(OrigE) && S.getLangOpts().CPlusPlus);
 
   if (E->isTypeDependent() || E->isValueDependent())
 return;
@@ -11707,7 +11718,7 @@ static void AnalyzeImplicitConversions(Sema &S, Expr 
*OrigE, SourceLocation CC,
 // FIXME: Use a more uniform representation for this.
 for (auto *SE : POE->semantics())
   if (auto *OVE = dyn_cast(SE))
-AnalyzeImplicitConversions(S, OVE->getSourceExpr(), CC, IsListInit);
+WorkList.push_back({OVE->getSourceExpr(), CC, IsListInit});
   }
 
   // Skip past explicit casts.
@@ -11715,7 +11726,8 @@ static void AnalyzeImplicitConversions(Sema &S, Expr 
*OrigE, SourceLocation CC,
 E = CE->getSubExpr()->IgnoreParenImpCasts();
 if (!CE->getType()->isVoidType() && E->getType()->isAtomicType())
   S.Diag(E->getBeginLoc(), diag::warn_atomic_implicit_seq_cst);
-return AnalyzeImplicitConversions(S, E, CC, IsListInit);
+WorkList.push_back({E, CC, IsListInit});
+return;
   }
 
   if (BinaryOperator *BO = dyn_cast(E)) {
@@ -11754,7 +11766,7 @@ static void AnalyzeImplicitConversions(Sema &S, Expr 
*OrigE, SourceLocation CC,
   // Ignore checking string literals that are in logical and operators.
   // This is a common pattern for asserts.
   continue;
-AnalyzeImplicitConversions(S, ChildExpr, CC, IsListInit);
+WorkList.push_back({ChildExpr, CC, IsListInit});
   }
 
   if (BO && BO->isLogicalOp()) {
@@ -11778,6 +11790,17 @@ static void AnalyzeImplicitConversions(Sema &S, Expr 
*OrigE, SourceLocation CC,
   }
 }
 
+/// AnalyzeImplicitConversions - Find and report any interesting
+/// implicit conversions in the given expression.  There are a couple
+/// of competing diagnostics here, -Wconversion and -Wsign-compare.
+static void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC,
+   bool IsListInit/*= false*/) {
+  llvm::SmallVector WorkList;
+  WorkList.push_back({OrigE, CC, IsListInit});
+  while (!WorkList.empty())
+AnalyzeImplicitConversions(S, WorkList.pop_back_val(), WorkList);
+}
+
 /// Diagnose integer type and any valid implicit conversion to it.
 static bool checkOpenCLEnqueueIntType(Sema &S, Expr *E, const QualType &IntT) {
   // Taking into account implicit conversions,



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


[PATCH] D74387: [SYCL] Defer __float128 type usage diagnostics

2020-04-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D74387#1964483 , @Fznamznon wrote:

> In D74387#1950593 , @jdoerfert wrote:
>
> > This is needed for OpenMP as well. Does it make sense to include it in this 
> > patch or in another one?
>
>
> I thought OpenMP already has diagnostics for unsupported types (at least 
> looking into this commit 
> https://github.com/llvm/llvm-project/commit/123ad1969171d0b22d0c5d0ec23468586c4d8fa7).
>  Am I wrong?
>  The diagnostic which I'm implementing here is stricter than existing OpenMP 
> diagnostic, the main goal is do not emit unsupported type at all. Does OpenMP 
> need such restriction as well?


OpenMP handling needs to be reverted/redone:

1. If no aux triple is available it just crashes.
2. If the unavailable type is not used in one of the pattern matched 
expressions it crashes (usually during instruction selection but not always). 
Try a call with long double arguments for example.

I'm not sure this patch fits the bill but what I was thinking we need is 
roughly:
If you have a expression with operands or function definition with 
return/argument types which are not supported on the target, mark the 
definition as unavailable with the type note you have.
We should especially allow members to have unavailable types if the member is 
not accessed. Memcpy like operations (=mapping) are OK though. I think this 
should be the same for OpenMP and Sycl (and HIP, and ...).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[PATCH] D77484: [Vector] Pass VectLib to LTO backend so TLI build correct vector function list

2020-04-06 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

> Ok then it does sound like these could be handled on a per-function basis, 
> similar to how -fno-builtin* are handled. I.e. a function attribute to 
> indicate the veclib, which would then be naturally preserved during LTO even 
> after merging/importing across modules. Similar to how -fno-builtin* are 
> handled, these would need to be examined when inlining (see the new 
> TargetLibraryInfo::areInlineCompatible). Presumably we would want to block 
> inlining between functions with different veclib attributes in the LTO 
> backends.

@tejohnson, we could do that. But then on the other hand, technically almost 
everything for module or whole program can be passed as a function attribute, 
and yet we have switches passed to backend for many of those things. Wondering 
what's the convention or rule (if there's one) we want to follow? Specifically, 
if we only use function attributes for stuff that's indeed going to be 
different between functions, then vectlib isn't in that category; or if we use 
function attributes for the greatest flexibility whenever we can, then many 
other things should be function attributes too (though it's essentially 
duplication in IR, and probably not the most efficient).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77484



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


[PATCH] D77593: [SveEmitter] Implement zeroing of false lanes

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

Maybe better to emit llvm.aarch64.sve.sel for now, if you're trying to avoid IR 
operations.

Otherwise looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77593



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


[clang] 7545be0 - fix comment typo to cycle bots

2020-04-06 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-04-06T18:58:27-04:00
New Revision: 7545be074d478297ac60efaee3cf919d436d6f32

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

LOG: fix comment typo to cycle bots

Added: 


Modified: 
clang/docs/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 221ac302579b..2d3ac5dbdd19 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -109,7 +109,7 @@ if (LLVM_ENABLE_SPHINX)
   # Copy rst files to build directory before generating the html
   # documentation.  Some of the rst files are generated, so they
   # only exist in the build directory.  Sphinx needs all files in
-  # the same directory in order to genrate the html, so we need to
+  # the same directory in order to generate the html, so we need to
   # copy all the non-gnerated rst files from the source to the build
   # directory before we run sphinx.
   add_custom_target(copy-clang-rst-docs



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


[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

2020-04-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 255524.
jdoerfert added a comment.

Move code as suggested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp

Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s   | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
+// expected-no-diagnostics
+
+int also_before() {
+  return 1;
+}
+
+#pragma omp begin declare variant match(implementation={vendor(score(100):llvm)})
+int also_after(void) {
+  return 2;
+}
+int also_after(int) {
+  return 3;
+}
+int also_after(double) {
+  return 0;
+}
+#pragma omp end declare variant
+#pragma omp begin declare variant match(implementation={vendor(score(0):llvm)})
+int also_before() {
+  return 0;
+}
+#pragma omp end declare variant
+
+int also_after(void) {
+  return 4;
+}
+int also_after(int) {
+  return 5;
+}
+int also_after(double) {
+  return 6;
+}
+
+template
+int test1() {
+  // Should return 0.
+  return also_after(T(0));
+}
+
+typedef int(*Ty)();
+
+template
+int test2() {
+  // Should return 0.
+  return fn();
+}
+
+int test() {
+  // Should return 0.
+  return test1() + test2();
+}
+
+// CHECK:  |-FunctionDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:5 used also_before 'int ({{.*}})'
+// CHECK-NEXT: | |-CompoundStmt [[ADDR_1:0x[a-z0-9]*]] 
+// CHECK-NEXT: | | `-ReturnStmt [[ADDR_2:0x[a-z0-9]*]] 
+// CHECK-NEXT: | |   `-IntegerLiteral [[ADDR_3:0x[a-z0-9]*]]  'int' 1
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_4:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(0): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_5:0x[a-z0-9]*]]  'int ({{.*}})' Function [[ADDR_6:0x[a-z0-9]*]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_7:0x[a-z0-9]*]]  col:5 implicit also_after 'int ({{.*}})'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_8:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_9:0x[a-z0-9]*]]  'int ({{.*}})' Function [[ADDR_10:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_10]]  line:10:1 also_after[implementation={vendor(llvm)}] 'int ({{.*}})'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_11:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_12:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_13:0x[a-z0-9]*]]  'int' 2
+// CHECK-NEXT: |-FunctionDecl [[ADDR_14:0x[a-z0-9]*]]  col:5 implicit also_after 'int (int)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]]  col:19 'int'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_16:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_17:0x[a-z0-9]*]]  'int (int)' Function [[ADDR_18:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (int)'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_18]]  line:13:1 also_after[implementation={vendor(llvm)}] 'int (int)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_15]]  col:19 'int'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_19:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_20:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_21:0x[a-z0-9]*]]  'int' 3
+// CHECK-NEXT: |-FunctionDecl [[ADDR_22:0x[a-z0-9]*]]  col:5 implicit used also_after 'int (double)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_23:0x[a-z0-9]*]]  col:22 'double'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_24:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_25:0x[a-z0-9]*]]  'int (double)' Function [[ADDR_26:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (double)'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_26]]  line:16:1 also_after[implementation={vendor(llvm)}] 'int (double)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_23]]  col:22 'double'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_27:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_28:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_29:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: |-FunctionDecl [[ADDR_6]]  line:21:1 also_before[implementation={vendor(llvm)}] 'int ({{.*}})'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_30:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_31:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_32:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: |-FunctionDecl [[ADDR_33:0x[a-z0-9]*]] prev [[ADDR_7]]  line:26:5 also_after 'int ({{.*}})'
+// CHECK-NEXT: | |-CompoundStmt [[ADDR_34:0x[a-z0-9]*]] 
+// CHECK-NEXT: | | `-Return

[PATCH] D77571: [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.

2020-04-06 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 255513.
mwyman added a comment.

Trying to fix Harbormaster build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77571

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp
  clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s objc-nsinvocation-argument-lifetime %t
+
+__attribute__((objc_root_class))
+@interface NSObject
+@end
+
+@interface NSInvocation : NSObject
+- (void)getArgument:(void *)Arg atIndex:(int)Index;
+- (void)getReturnValue:(void *)ReturnValue;
+@end
+
+@interface OtherClass : NSObject
+- (void)getArgument:(void *)Arg atIndex:(int)Index;
+@end
+
+void foo(NSInvocation *Invocation) {
+  __unsafe_unretained id Arg2;
+  id Arg3;
+  // CHECK-FIXES: __unsafe_unretained id Arg3;
+  NSObject __strong *Arg4;
+  // CHECK-FIXES: NSObject __unsafe_unretained *Arg4;
+  __weak id Arg5;
+  // CHECK-FIXES: __unsafe_unretained id Arg5;
+  id ReturnValue;
+  // CHECK-FIXES: __unsafe_unretained id ReturnValue;
+  void (^BlockArg1)();
+  __unsafe_unretained void (^BlockArg2)();
+
+  [Invocation getArgument:&Arg2 atIndex:2];
+
+  [Invocation getArgument:&Arg3 atIndex:3];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&Arg4 atIndex:4];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&Arg5 atIndex:5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&BlockArg1 atIndex:6];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&BlockArg2 atIndex:6];
+
+  [Invocation getReturnValue:&ReturnValue];
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: NSInvocation '-getReturnValue:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:(void*)0 atIndex:6];
+}
+
+void bar(OtherClass *OC) {
+  id Arg;
+  [OC getArgument:&Arg atIndex:2];
+}
+
+@interface TestClass : NSObject {
+  id Argument;
+}
+@end
+
+@implementation TestClass
+
+- (void)processInvocation:(NSInvocation *)Invocation {
+  [Invocation getArgument:&Argument atIndex:2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+  [Invocation getArgument:&self->Argument atIndex:2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+}
+
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - objc-nsinvocation-argument-lifetime
+
+objc-nsinvocation-argument-lifetime
+===
+
+Finds calls to ``NSInvocation`` methods under ARC that don't have proper
+argument object lifetimes. When passing Objective-C objects as parameters
+to the ``NSInvocation`` methods ``getArgument:atIndex:`` and
+``getReturnValue:``, the values are copied by value into the argument pointer,
+which leads to to incorrect releasing behavior if the object pointers are
+not declared ``__unsafe_unretained``.
+
+For code:
+
+.. code-block:: objc
+
+id arg;
+[invocation getArgument:&arg atIndex:2];
+
+__strong id returnValue;
+[invocation getReturnValue:&returnValue];
+
+The fix will be:
+
+.. code-block:: objc
+
+__unsafe_unretained id arg;

[PATCH] D77598: Integral template argument suffix printing

2020-04-06 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Is this actually appropriate for an argument to `template ` or should the 
type be reflected in more than the suffix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77598



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


[PATCH] D77581: Add map-type check for target and target data directive

2020-04-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Sure, will do it later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581



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


[PATCH] D77571: [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.

2020-04-06 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 255519.
mwyman added a comment.

Missed CHECK-FIXES for block argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77571

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp
  clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m
@@ -0,0 +1,71 @@
+// RUN: %check_clang_tidy %s objc-nsinvocation-argument-lifetime %t
+
+__attribute__((objc_root_class))
+@interface NSObject
+@end
+
+@interface NSInvocation : NSObject
+- (void)getArgument:(void *)Arg atIndex:(int)Index;
+- (void)getReturnValue:(void *)ReturnValue;
+@end
+
+@interface OtherClass : NSObject
+- (void)getArgument:(void *)Arg atIndex:(int)Index;
+@end
+
+void foo(NSInvocation *Invocation) {
+  __unsafe_unretained id Arg2;
+  id Arg3;
+  // CHECK-FIXES: __unsafe_unretained id Arg3;
+  NSObject __strong *Arg4;
+  // CHECK-FIXES: NSObject __unsafe_unretained *Arg4;
+  __weak id Arg5;
+  // CHECK-FIXES: __unsafe_unretained id Arg5;
+  id ReturnValue;
+  // CHECK-FIXES: __unsafe_unretained id ReturnValue;
+  void (^BlockArg1)();
+  // CHECK-FIXES: __unsafe_unretained void (^BlockArg1)();
+  __unsafe_unretained void (^BlockArg2)();
+
+  [Invocation getArgument:&Arg2 atIndex:2];
+
+  [Invocation getArgument:&Arg3 atIndex:3];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&Arg4 atIndex:4];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&Arg5 atIndex:5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&BlockArg1 atIndex:6];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&BlockArg2 atIndex:6];
+
+  [Invocation getReturnValue:&ReturnValue];
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: NSInvocation '-getReturnValue:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:(void *)0 atIndex:6];
+}
+
+void bar(OtherClass *OC) {
+  id Arg;
+  [OC getArgument:&Arg atIndex:2];
+}
+
+@interface TestClass : NSObject {
+  id Argument;
+}
+@end
+
+@implementation TestClass
+
+- (void)processInvocation:(NSInvocation *)Invocation {
+  [Invocation getArgument:&Argument atIndex:2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+  [Invocation getArgument:&self->Argument atIndex:2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+}
+
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - objc-nsinvocation-argument-lifetime
+
+objc-nsinvocation-argument-lifetime
+===
+
+Finds calls to ``NSInvocation`` methods under ARC that don't have proper
+argument object lifetimes. When passing Objective-C objects as parameters
+to the ``NSInvocation`` methods ``getArgument:atIndex:`` and
+``getReturnValue:``, the values are copied by value into the argument pointer,
+which leads to to incorrect releasing behavior if the object pointers are
+not declared ``__unsafe_unretained``.
+
+For code:
+
+.. code-block:: objc
+
+id arg;
+[invocation getArgument:&arg atIndex:2];
+
+__strong id returnValue;
+[invocation getReturnValue:&returnValue];
+
+The fix wi

[PATCH] D77595: [SveEmitter] Add NoAuto flag and builtins for svwhile.

2020-04-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma, rovka.
Herald added a subscriber: tschuett.
Herald added a project: clang.
sdesmalen added a parent revision: D77594: [SveEmitter] Add support for _n form 
builtins.
sdesmalen added a child revision: D77596: [SveEmitter] Add NoOverload flag and 
builtin for svpfalse.

Add the NoAuto flag for intrinsics that can't easily be code-generated
using the default overloaded type and are better handled special-cased
in a switch statement.

This patch also adds all svwhile builtins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77595

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilege.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -520,6 +520,13 @@
 Immediate = true;
 PredicatePattern = true;
 break;
+  case 'k':
+Predicate = false;
+Signed = true;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+break;
   case 'l':
 Predicate = false;
 Signed = true;
@@ -527,6 +534,20 @@
 ElementBitwidth = Bitwidth = 64;
 NumVectors = 0;
 break;
+  case 'm':
+Predicate = false;
+Signed = false;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+break;
+  case 'n':
+Predicate = false;
+Signed = false;
+Float = false;
+ElementBitwidth = Bitwidth = 64;
+NumVectors = 0;
+break;
   case 'S':
 Constant = true;
 Pointer = true;
Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbool_t test_svwhilegt_b8_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b8_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv16i1.i32(i32 %op1, i32 %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b8'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b8_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b8,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b16_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b16_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv8i1.i32(i32 %op1, i32 %op2)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b16'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b16_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b16,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b32_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b32_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv4i1.i32(i32 %op1, i32 %op2)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b32'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b32_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b32,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b64_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b64_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64

[PATCH] D77592: [NFC}[CodeGen] Make VTable initialization a method of CGCXXABI

2020-04-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: pcc, rjmccall, rsmith.
leonardchan added a project: clang.

This patch moves the following instances of this snippet:

  ConstantInitBuilder builder(CGM);
  auto components = builder.beginStruct();
  CGVT.createVTableInitializer(components, VTLayout, RTTI);
  components.finishAndSetAsInitializer(VTable);

into CGCXXABI under a virtual method called `SetVTableInitializer`, which will 
be in charge of selecting the correct vtable initialization from 
`CodegenVTables`.

This is a prerequisite for landing the relative vtables ABI in Fuchsia (see 
D72959 ). The plan is to add a 
`createRelativeVTableInitializer()` method to `CodegenVTables` which will be a 
helper for making PIC-friendly vtables.

This does not affect any tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77592

Files:
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1690,10 +1690,7 @@
[](const VTableComponent &VTC) { return VTC.isRTTIKind(); }))
   RTTI = getMSCompleteObjectLocator(RD, *Info);
 
-ConstantInitBuilder Builder(CGM);
-auto Components = Builder.beginStruct();
-CGVT.createVTableInitializer(Components, VTLayout, RTTI);
-Components.finishAndSetAsInitializer(VTable);
+SetVTableInitializer(CGVT, VTable, VTLayout, RTTI);
 
 emitVTableTypeMetadata(*Info, RD, VTable);
   }
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -493,6 +493,20 @@
   explicit FuchsiaCXXABI(CodeGen::CodeGenModule &CGM)
   : ItaniumCXXABI(CGM) {}
 
+  void SetVTableInitializer(CodeGenVTables &CGVT, llvm::GlobalVariable *VTable,
+const VTableLayout &VTLayout,
+llvm::Constant *RTTI) override {
+ConstantInitBuilder builder(CGM);
+auto components = builder.beginStruct();
+
+// TODO: Replace this with CodeGenVTables::createRelativeVTableInitializer()
+// once it is implemented. This will be the helper for the relative-vtables
+// ABI.
+CGVT.createVTableInitializer(components, VTLayout, RTTI);
+
+components.finishAndSetAsInitializer(VTable);
+  }
+
 private:
   bool HasThisReturn(GlobalDecl GD) const override {
 return isa(GD.getDecl()) ||
@@ -1679,10 +1693,7 @@
   CGM.GetAddrOfRTTIDescriptor(CGM.getContext().getTagDeclType(RD));
 
   // Create and set the initializer.
-  ConstantInitBuilder Builder(CGM);
-  auto Components = Builder.beginStruct();
-  CGVT.createVTableInitializer(Components, VTLayout, RTTI);
-  Components.finishAndSetAsInitializer(VTable);
+  SetVTableInitializer(CGVT, VTable, VTLayout, RTTI);
 
   // Set the correct linkage.
   VTable->setLinkage(Linkage);
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -806,10 +806,7 @@
   CGM.getContext().getTagDeclType(Base.getBase()));
 
   // Create and set the initializer.
-  ConstantInitBuilder builder(CGM);
-  auto components = builder.beginStruct();
-  createVTableInitializer(components, *VTLayout, RTTI);
-  components.finishAndSetAsInitializer(VTable);
+  CGM.getCXXABI().SetVTableInitializer(*this, VTable, *VTLayout, RTTI);
 
   // Set properties only after the initializer has been set to ensure that the
   // GV is treated as definition and not declaration.
Index: clang/lib/CodeGen/CGCXXABI.h
===
--- clang/lib/CodeGen/CGCXXABI.h
+++ clang/lib/CodeGen/CGCXXABI.h
@@ -209,6 +209,12 @@
  llvm::Value *MemPtr,
  const MemberPointerType *MPT);
 
+  /// Create and set the initializer for the vtable.
+  virtual void SetVTableInitializer(CodeGenVTables &CGVT,
+llvm::GlobalVariable *VTable,
+const VTableLayout &VTLayout,
+llvm::Constant *RTTI);
+
 protected:
   /// A utility method for computing the offset required for the given
   /// base-to-derived or derived-to-base member-pointer conversion.
Index: clang/lib/CodeGen/CGCXXABI.cpp
===
--- clang/lib/CodeGen/CGCXXABI.cpp
+++ clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "clang/AST/Attr.h"
+#include "clang/CodeGen/ConstantInitBuilder.h"
 
 using namespace clang;
 using na

[PATCH] D77597: [SveEmitter] Add ExpandOp1SVALL and builtin for svptrue

2020-04-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma, rovka.
Herald added a subscriber: tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
sdesmalen added a parent revision: D77596: [SveEmitter] Add NoOverload flag and 
builtin for svpfalse.

Some ACLE builtins leave out the argument to specify the predicate
pattern, which is expected to be expanded to SV_ALL pattern.

This patch adds the flag ExpandOp1SVALL to expand the second operand
to an SVE_ALL value, or append a SV_ALL if the builtin only takes
a single operand.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77597

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c

Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c
@@ -0,0 +1,201 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+svbool_t test_svptrue_b8()
+{
+  // CHECK-LABEL: test_svptrue_b8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_b8();
+}
+
+svbool_t test_svptrue_b16()
+{
+  // CHECK-LABEL: test_svptrue_b16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  return svptrue_b16();
+}
+
+svbool_t test_svptrue_b32()
+{
+  // CHECK-LABEL: test_svptrue_b32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  return svptrue_b32();
+}
+
+svbool_t test_svptrue_b64()
+{
+  // CHECK-LABEL: test_svptrue_b64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  return svptrue_b64();
+}
+
+svbool_t test_svptrue_pat_b8()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_POW2);
+}
+
+svbool_t test_svptrue_pat_b8_1()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_1
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 1)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL1);
+}
+
+svbool_t test_svptrue_pat_b8_2()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_2
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 2)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL2);
+}
+
+svbool_t test_svptrue_pat_b8_3()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_3
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 3)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL3);
+}
+
+svbool_t test_svptrue_pat_b8_4()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_4
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 4)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL4);
+}
+
+svbool_t test_svptrue_pat_b8_5()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_5
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 5)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL5);
+}
+
+svbool_t test_svptrue_pat_b8_6()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_6
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 6)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL6);
+}
+
+svbool_t test_svptrue_pat_b8_7()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_7
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 7)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL7);
+}
+
+svbool_t test_svptrue_pat_b8_8()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 8)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL8);
+}
+
+svbool_t test_svptrue_pat_b8_9()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_9
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 9)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL16);
+}
+
+svbool_t test_svptrue_pat_b8_10()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_10
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 10)
+  // CHECK: ret  %[[INTRINSIC]]
+  return svptrue_pat_b8(SV_VL32);
+}
+
+svbool_t test_svptrue_pat_b8_11()
+{
+  // CHECK-LABEL: test_svptrue_pat_b8_11
+  // CHECK: %[[INTRINSIC:.*]] = call  @l

[PATCH] D77596: [SveEmitter] Add NoOverload flag and builtin for svpfalse

2020-04-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma, rovka.
Herald added a subscriber: tschuett.
Herald added a project: clang.
sdesmalen added a parent revision: D77595: [SveEmitter] Add NoAuto flag and 
builtins for svwhile..
sdesmalen added a child revision: D77597: [SveEmitter] Add ExpandOp1SVALL and 
builtin for svptrue.

Add the NoOverload flag to tell CGBuiltin that it does not have
an overloaded type. This is used for e.g. svpfalse which does
not take any arguments and always returns a svbool_t.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77596

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -261,6 +261,14 @@
 llvm_unreachable("Unsupported imm check");
   }
 
+  /// Returns the enum value for the flag type
+  uint64_t getEnumValueForFlag(StringRef C) const {
+auto Res = FlagTypes.find(C);
+if (Res != FlagTypes.end())
+  return Res->getValue();
+llvm_unreachable("Unsupported flag");
+  }
+
   // Returns the SVETypeFlags for a given value and mask.
   uint64_t encodeFlag(uint64_t V, StringRef MaskName) const {
 auto It = FlagTypes.find(MaskName);
@@ -844,6 +852,13 @@
   for (auto FlagRec : FlagsList)
 Flags |= FlagRec->getValueAsInt("Value");
 
+  // Create a dummy TypeSpec for non-overloaded builtins.
+  if (Types.empty()) {
+assert((Flags & getEnumValueForFlag("NoOverloadTy")) &&
+   "Expect TypeSpec for overloaded builtin!");
+Types = "i";
+  }
+
   // Extract type specs from string
   SmallVector TypeSpecs;
   TypeSpec Acc;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbool_t test_svpfalse_b()
+{
+  // CHECK-LABEL: test_svpfalse_b
+  // CHECK: ret  zeroinitializer
+  return SVE_ACLE_FUNC(svpfalse,_b,,)();
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -7655,14 +7655,25 @@
   Ops[1] = Builder.CreateSelect(Ops[0], Ops[1], SplatZero);
 }
 
-Function *F = CGM.getIntrinsic(Builtin->LLVMIntrinsic, OverloadedTy);
+Function *F = TypeFlags.isNotOverloaded()
+  ? CGM.getIntrinsic(Builtin->LLVMIntrinsic)
+  : CGM.getIntrinsic(Builtin->LLVMIntrinsic, OverloadedTy);
 Value *Call = Builder.CreateCall(F, Ops);
-		return Call;
+
+// Predicate results must be converted to svbool_t.
+if (auto PredTy = dyn_cast(Call->getType()))
+  if (PredTy->getScalarType()->isIntegerTy(1))
+Call = EmitSVEPredicateCast(Call, cast(Ty));
+
+return Call;
   }
 
   switch (BuiltinID) {
   default:
 return nullptr;
+  case SVE::BI__builtin_sve_svpfalse_b:
+return ConstantInt::getFalse(Ty);
+
   case SVE::BI__builtin_sve_svwhilele_b8_s32:
   case SVE::BI__builtin_sve_svwhilele_b8_s64:
   case SVE::BI__builtin_sve_svwhilele_b8_u32:
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -167,6 +167,7 @@
 def IsStructStore : FlagType<0x0004>;
 def IsZExtReturn  : FlagType<0x0008>; // Return value is sign-extend by default
 def NoAuto: FlagType<0x0010>;
+def NoOverloadTy  : FlagType<0x0020>;
 
 // These must be kept in sync with the flags in include/clang/Basic/TargetBuiltins.h
 class ImmCheckType {
@@ -392,6 +393,7 @@
 def SVCMLA_LANE : SInst<"svcmla_lane[_{d}]", "ii", "hf",  MergeNone, "aarch64_sve_fcmla_lane", [], [ImmCheck<3, ImmCheckLaneIndexCompRotate, 2>,
 ImmCheck<4, ImmCheckComplexRotAll90>]>;
 
+
 def SVCADD_M : SInst<"svc

[PATCH] D77598: Integral template argument suffix printing

2020-04-06 Thread Aristotelis Koutsouridis via Phabricator via cfe-commits
arisKoutsou created this revision.
arisKoutsou added a reviewer: v.g.vassilev.
arisKoutsou added a project: clang.
Herald added a subscriber: cfe-commits.

Added 'U' suffix for unsigned integral types and 'LL' for 64-bit types. Some 
tests fail to pass due to this change, because they expect a diagnostic with 
integral literal without suffix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77598

Files:
  clang/lib/AST/TemplateBase.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp


Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,24 @@
   void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // 
expected-error{{enable_if_char<'\x02'>'; did you mean 
'enable_if_char<'a'>::type'?}}
   void test_char_single_quote() { enable_if_char<'\''>::type i; } // 
expected-error{{enable_if_char<'\''>'; did you mean 
'enable_if_char<'a'>::type'?}}
   void test_char_backslash() { enable_if_char<'\\'>::type i; } // 
expected-error{{enable_if_char<'\\'>'; did you mean 
'enable_if_char<'a'>::type'?}}
+  
+  template  struct enable_if_int {};
+  template <> struct enable_if_int<1> { typedef int type; }; // 
expected-note{{'enable_if_int<1>::type' declared here}}
+  void test_int() { enable_if_int<2>::type i; } // 
expected-error{{enable_if_int<2>'; did you mean 'enable_if_int<1>::type'?}}
+
+  template  struct enable_if_unsigned_int {};
+  template <> struct enable_if_unsigned_int<1> { typedef int type; }; // 
expected-note{{'enable_if_unsigned_int<1>::type' declared here}}
+  void test_unsigned_int() { enable_if_unsigned_int<2>::type i; } // 
expected-error{{enable_if_unsigned_int<2U>'; did you mean 
'enable_if_unsigned_int<1>::type'?}}
+
+
+  template  struct enable_if_unsigned_long_long {};
+  template <> struct enable_if_unsigned_long_long<1> { typedef int type; }; // 
expected-note{{'enable_if_unsigned_long_long<1>::type' declared here}}
+  void test_unsigned_long_long() { enable_if_unsigned_long_long<2>::type i; } 
// expected-error{{enable_if_unsigned_long_long<2ULL>'; did you mean 
'enable_if_unsigned_long_long<1>::type'?}}
+
+  template  struct enable_if_long_long {};
+  template <> struct enable_if_long_long<1> { typedef int type; }; // 
expected-note{{'enable_if_long_long<1>::type' declared here}}
+  void test_long_long() { enable_if_long_long<2>::type i; } // 
expected-error{{enable_if_long_long<2LL>'; did you mean 
'enable_if_long_long<1>::type'?}}
+
 }
 
 namespace PR10579 {
Index: clang/lib/AST/TemplateBase.cpp
===
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -77,6 +77,12 @@
 Out << "'";
   } else {
 Out << Val;
+if (T->isBuiltinType()) {
+  if (Val.isUnsigned())
+Out << "U";
+  if (Val.getBitWidth() == 64)
+Out << "LL";
+}
   }
 }
 


Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,24 @@
   void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>'; did you mean 'enable_if_char<'a'>::type'?}}
+  
+  template  struct enable_if_int {};
+  template <> struct enable_if_int<1> { typedef int type; }; // expected-note{{'enable_if_int<1>::type' declared here}}
+  void test_int() { enable_if_int<2>::type i; } // expected-error{{enable_if_int<2>'; did you mean 'enable_if_int<1>::type'?}}
+
+  template  struct enable_if_unsigned_int {};
+  template <> struct enable_if_unsigned_int<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_int<1>::type' declared here}}
+  void test_unsigned_int() { enable_if_unsigned_int<2>::type i; } // expected-error{{enable_if_unsigned_int<2U>'; did you mean 'enable_if_unsigned_int<1>::type'?}}
+
+
+  template  struct enable_if_unsigned_long_long {};
+  template <> struct enable_if_unsigned_long_long<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_long_long<1>::type' declared here}}
+  void test_unsigned_long_long() { enable_if_unsigned_long_long<2>::type i; } // expected-error{{enable_if_unsigned_long_long<2ULL>'; did you mean 'enable_if_unsigned_long_long<1>::type'?}}
+
+  template  struct enable_if_long_long {};
+  template <> struct enable_if_long_long<1> { typedef int type; }; // expected-note{{'enable_if_long_long<1>::type' declared here}}
+  void test_long_long() { enable_if_long

[PATCH] D77581: Add map-type check for target and target data directive

2020-04-06 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

@ABataev , can you land it for me when you have time? thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581



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


[PATCH] D76680: [SveEmitter] Add immediate checks for lanes and complex imms

2020-04-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 255500.
sdesmalen added a comment.

- Addressed comments - added spaces to `0, 90, 180 or 270`


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

https://reviews.llvm.org/D76680

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/arm_sve.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_cadd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_cmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_dot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_mla.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -455,9 +455,19 @@
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
 break;
+  case 'e':
+Signed = false;
+ElementBitwidth /= 2;
+break;
   case 'h':
 ElementBitwidth /= 2;
 break;
+  case 'q':
+ElementBitwidth /= 4;
+break;
+  case 'o':
+ElementBitwidth *= 4;
+break;
   case 'P':
 Signed = true;
 Float = false;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_mla.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_mla.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+svfloat16_t test_svmla_lane_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 7]}}
+  return SVE_ACLE_FUNC(svmla_lane,_f16,,)(op1, op2, op3, 8);
+}
+
+svfloat32_t test_svmla_lane_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+  return SVE_ACLE_FUNC(svmla_lane,_f32,,)(op1, op2, op3, -1);
+}
+
+svfloat64_t test_svmla_lane_f64(svfloat64_t op1, svfloat64_t op2, svfloat64_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 1]}}
+  return SVE_ACLE_FUNC(svmla_lane,_f64,,)(op1, op2, op3, 2);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_dot.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_dot.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+svint32_t test_svdot_lane_s32(svint32_t op1, svint8_t op2, svint8_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+  return SVE_ACLE_FUNC(svdot_lane,_s32,,)(op1, op2, op3, -1);
+}
+
+svint32_t test_svdot_lane_s32_1(svint32_t op1, svint8_t op2, svint8_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+  return SVE_ACLE_FUNC(svdot_lane,_s32,,)(op1, op2, op3, 4);
+}
+
+svint64_t test_svdot_lane_s64(svint64_t op1, svint16_t op2, svint16_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 1]}}
+  return SVE_ACLE_FUNC(svdot_lane,_s64,,)(op1, op2, op3, -1);
+}
+
+svint64_t test_svdot_lane_s64_1(svint64_t op1, svint16_t op2, svint16_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 1]}}
+  return SVE_ACLE_FUNC(svdot_lane,_s64,,)(op1, op2, op3, 2);
+}
+
+svuint32_t test_svdot_lane_u32(svuint32_t op1, svuint8_t op2, svuint8_t op3)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+  return SVE_ACLE_FUNC(svdot_lane,_u32,,)(op1, op2, op3, 4);
+}
+
+svuint64_t test_svdot_lane_

[PATCH] D77591: [SveEmitter] Explicitly merge with zero/undef

2020-04-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma, rovka.
Herald added a subscriber: tschuett.
Herald added a project: clang.
sdesmalen added a child revision: D77593: [SveEmitter] Implement zeroing of 
false lanes.

Builtins that have the merge type MergeAnyExp or MergeZeroExp,
merge into a 'undef' or 'zero' vector respectively, which enables the
_x and _z behaviour for unary operations.

  

This patch also adds builtins for svabs and svneg.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77591

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_abs.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_neg.c

Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_neg.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_neg.c
@@ -0,0 +1,197 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svneg_s8_z(svbool_t pg, svint8_t op)
+{
+  // CHECK-LABEL: test_svneg_s8_z
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv16i8( zeroinitializer,  %pg,  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s8,_z,)(pg, op);
+}
+
+svint16_t test_svneg_s16_z(svbool_t pg, svint16_t op)
+{
+  // CHECK-LABEL: test_svneg_s16_z
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv8i16( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s16,_z,)(pg, op);
+}
+
+svint32_t test_svneg_s32_z(svbool_t pg, svint32_t op)
+{
+  // CHECK-LABEL: test_svneg_s32_z
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv4i32( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s32,_z,)(pg, op);
+}
+
+svint64_t test_svneg_s64_z(svbool_t pg, svint64_t op)
+{
+  // CHECK-LABEL: test_svneg_s64_z
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv2i64( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s64,_z,)(pg, op);
+}
+
+svint8_t test_svneg_s8_m(svint8_t inactive, svbool_t pg, svint8_t op)
+{
+  // CHECK-LABEL: test_svneg_s8_m
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv16i8( %inactive,  %pg,  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s8,_m,)(inactive, pg, op);
+}
+
+svint16_t test_svneg_s16_m(svint16_t inactive, svbool_t pg, svint16_t op)
+{
+  // CHECK-LABEL: test_svneg_s16_m
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv8i16( %inactive,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s16,_m,)(inactive, pg, op);
+}
+
+svint32_t test_svneg_s32_m(svint32_t inactive, svbool_t pg, svint32_t op)
+{
+  // CHECK-LABEL: test_svneg_s32_m
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv4i32( %inactive,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s32,_m,)(inactive, pg, op);
+}
+
+svint64_t test_svneg_s64_m(svint64_t inactive, svbool_t pg, svint64_t op)
+{
+  // CHECK-LABEL: test_svneg_s64_m
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv2i64( %inactive,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s64,_m,)(inactive, pg, op);
+}
+
+svint8_t test_svneg_s8_x(svbool_t pg, svint8_t op)
+{
+  // CHECK-LABEL: test_svneg_s8_x
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv16i8( undef,  %pg,  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svneg,_s8,_x,)(pg, op);
+}
+
+svint16_t test_svneg_s16_x(svbool_t pg, svint16_t op)
+{
+  // CHECK-LABEL: test_svneg_s16_x
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.neg.nxv8i16( undef,  %[[PG]],  %op)
+

[PATCH] D76680: [SveEmitter] Add immediate checks for lanes and complex imms

2020-04-06 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked 3 inline comments as done.
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9208
+def err_rotation_argument_to_cmla
+: Error<"argument should be the value 0,90,180 or 270">;
 def warn_neon_vector_initializer_non_portable : Warning<

efriedma wrote:
> SjoerdMeijer wrote:
> > A proper nit, perhaps some spaces here: "0,90,180".
> Still not done?
Sorry, I forgot about that earlier. Should be fixed now.


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

https://reviews.llvm.org/D76680



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


[PATCH] D77581: Add map-type check for target and target data directive

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

Reuse existing function for target/target data check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_messages.c
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp

Index: clang/test/OpenMP/target_teams_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_map_messages.cpp
+++ clang/test/OpenMP/target_teams_map_messages.cpp
@@ -580,6 +580,11 @@
 #pragma omp target teams map(*(1+*a+*a)) // expected-error {{indirection requires pointer operand ('int' invalid)}}
   {}
 
+#pragma omp target teams map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams'}}
+  {}
+#pragma omp target teams map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams'}}
+  {}
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
@@ -288,6 +288,12 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for simd map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for simd'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target teams distribute parallel for simd map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for simd'}}
+  for (i = 0; i < argc; ++i)
+foo();
 
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
@@ -288,6 +288,12 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target teams distribute parallel for map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for'}}
+  for (i = 0; i < argc; ++i)
+foo();
 
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/test/OpenMP/target_teams_distribute_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_map_messages.cpp
@@ -288,6 +288,12 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target teams distribute map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute'}}
+  for (i = 0; i < argc; ++i)
+   

[PATCH] D77039: [clang-format] Don't break multi block parameters on ObjCBreakBeforeNestedBlockParam

2020-04-06 Thread Jin Lin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28ecd7f0b086: [clang-format] Don't break multi block 
parameters on… (authored by ghvg1313, committed by jinlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77039

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -1420,6 +1420,10 @@
"*b, NSNumber *c) {\n"
"  b = c;\n"
"}]");
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, "
+   "NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "} z:self]");
 
   Style.ColumnLimit = 80;
   verifyFormat(
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -342,6 +342,7 @@
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
+  Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
   Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
 return true;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -1420,6 +1420,10 @@
"*b, NSNumber *c) {\n"
"  b = c;\n"
"}]");
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, "
+   "NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "} z:self]");
 
   Style.ColumnLimit = 80;
   verifyFormat(
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -342,6 +342,7 @@
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
+  Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
   Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
 return true;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77581: Add map-type check for target and target data directive

2020-04-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581



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


[PATCH] D77581: Add map-type check for target and target data directive

2020-04-06 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:17001-17038
+  // target, target data
+  // OpenMP 5.0 [2.12.2, Restrictions, p. 163]
+  // OpenMP 5.0 [2.12.5, Restrictions, p. 174]
+  // A map-type in a map clause must be to, from, tofrom or alloc
+  if ((DKind == OMPD_target || DKind == OMPD_target_data ||
+   DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for 
||
+   DKind == OMPD_target_parallel_for_simd ||

ABataev wrote:
> 1. Why 2 similar checks?
> 2. Some of the logical conditions can be replaced with 
> `isOpenMPTagetExecutableDirective()` or similar.
I messed up the code with arc, I'll fix it. thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581



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


[clang] 28ecd7f - [clang-format] Don't break multi block parameters on ObjCBreakBeforeNestedBlockParam

2020-04-06 Thread Jin Lin via cfe-commits

Author: Kanglei Fang
Date: 2020-04-06T14:20:09-07:00
New Revision: 28ecd7f0b0865878a12d814a6d0de92cb7529d22

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

LOG: [clang-format] Don't break multi block parameters on 
ObjCBreakBeforeNestedBlockParam

Summary:
While [the original diff](https://reviews.llvm.org/D42493) makes a lot of 
sense, and multiple inline block parameter/trailing paramemter after inline 
block paramemter should be discouraged, the formatting result is different than 
what xcode does by default
For the exact same example provided in the original diff:
```
[object
  blockArgument:^{
a = 42;
  }
 anotherArg:42];
```
The code is hard to read and not very visually pleasing

This diff uses `ObjCBreakBeforeNestedBlockParam` to shield from the formatting
When it's set to false, don't allign the inline block paramemters.

Reviewers: jolesiak, benhamilton, jinlin

Reviewed By: jolesiak

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTestObjC.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 50b4ff5d9010..1c1d0142930f 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@ the configuration (without a prefix: ``Auto``).
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ba42ba0ca050..03e79a22954e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -342,6 +342,7 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
+  Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
   Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
 return true;

diff  --git a/clang/unittests/Format/FormatTestObjC.cpp 
b/clang/unittests/Format/FormatTestObjC.cpp
index edbf092d0421..42e2a80783be 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -1420,6 +1420,10 @@ TEST_F(FormatTestObjC, BreakLineBeforeNestedBlockParam) {
"*b, NSNumber *c) {\n"
"  b = c;\n"
"}]");
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, "
+   "NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "} z:self]");
 
   Style.ColumnLimit = 80;
   verifyFormat(



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


[PATCH] D77581: Add map-type check for target and target data directive

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



Comment at: clang/lib/Sema/SemaOpenMP.cpp:17001-17038
+  // target, target data
+  // OpenMP 5.0 [2.12.2, Restrictions, p. 163]
+  // OpenMP 5.0 [2.12.5, Restrictions, p. 174]
+  // A map-type in a map clause must be to, from, tofrom or alloc
+  if ((DKind == OMPD_target || DKind == OMPD_target_data ||
+   DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for 
||
+   DKind == OMPD_target_parallel_for_simd ||

1. Why 2 similar checks?
2. Some of the logical conditions can be replaced with 
`isOpenMPTagetExecutableDirective()` or similar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581



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


[PATCH] D77502: [clang][CodeGen] Handle throw expression in conditional operator constant folding

2020-04-06 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good (with the comment suitably tweaked). Thanks!




Comment at: clang/lib/CodeGen/CGExpr.cpp:4334
 incrementProfileCounter(expr);
+  // If a throw expression we need to return dead as lvalue.
+  if (auto *ThrowExpr = dyn_cast(live->IgnoreParens())) {

Comment doesn't match the code any more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77502



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-04-06 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/docs/UsersManual.rst:1684
+   linkage symbols. The unique name is obtained by appending the hash of the
+   full module name to the original symbol. This option is particularly useful
+   in attributing profile information to the correct function when multiple

MaskRay wrote:
> rnk wrote:
> > I think it's important to be specific here. I'd go so far as to say:
> > "When this option is set, compiler hashes the main source file path from 
> > the command line and appends it to all internal symbols. If a program 
> > contains multiple objects compiled from the same source file path, the 
> > symbols are not guaranteed to be unique."
> Should option like -ffile-prefix-map= affect the hashed source file path? I 
> suspect it already does this but I haven't verified.
> 
> This may need tests for Windows and non-Windows, similar to D77223.
With respect to @rnk's suggestion, "from the same source file path" implies the 
same file. I would suggest saying "with the same command-line source file 
specification".


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

https://reviews.llvm.org/D73307



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


[PATCH] D76680: [SveEmitter] Add immediate checks for lanes and complex imms

2020-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9208
+def err_rotation_argument_to_cmla
+: Error<"argument should be the value 0,90,180 or 270">;
 def warn_neon_vector_initializer_non_portable : Warning<

SjoerdMeijer wrote:
> A proper nit, perhaps some spaces here: "0,90,180".
Still not done?


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

https://reviews.llvm.org/D76680



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


[PATCH] D76678: [SveEmitter] Add range checks for immediates and predicate patterns.

2020-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


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

https://reviews.llvm.org/D76678



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


[PATCH] D77581: Add map-type check for target and target data directive

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

Do not use lint on test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77581

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_messages.c
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp

Index: clang/test/OpenMP/target_teams_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_map_messages.cpp
+++ clang/test/OpenMP/target_teams_map_messages.cpp
@@ -580,6 +580,11 @@
 #pragma omp target teams map(*(1+*a+*a)) // expected-error {{indirection requires pointer operand ('int' invalid)}}
   {}
 
+#pragma omp target teams map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams'}}
+  {}
+#pragma omp target teams map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams'}}
+  {}
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
@@ -288,6 +288,10 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for simd map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for simd'}}
+  for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for simd map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for simd'}}
+  for (i = 0; i < argc; ++i) foo();
 
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
@@ -288,6 +288,10 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for'}}
+  for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for'}}
+  for (i = 0; i < argc; ++i) foo();
 
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/test/OpenMP/target_teams_distribute_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_map_messages.cpp
@@ -288,6 +288,10 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute'}}
+  for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute'}}
+  for (i = 0; i < argc; ++i) foo();
 
   return tmain(argc)+tmain(argc); // expected-no

[PATCH] D77519: Fix __is_pointer builtin type trait to work with Objective-C pointer types.

2020-04-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added inline comments.
This revision is now accepted and ready to land.



Comment at: libcxx/include/type_traits:901
+// In clang 10.0.0 and earlier __is_pointer didn't work with Objective-C types.
+#if __has_keyword(__is_pointer) && _LIBCPP_CLANG_VER > 1000
+

zoecarver wrote:
> ldionne wrote:
> > Doesn't `__has_keyword` return a number that can be compared against? `#if 
> > __has_keyword(__is_pointer) > some-number` would be better if feasible, 
> > because it would handle Clang, AppleClang and any other potential 
> > derivative.
> I don't think `__has_keyword` returns a comparable number. Libc++ defines 
> `__has_keyword ` using `__is_identifier` [1] and, it seems like all the 
> feature checking macros from clang (including `__is_identifier`) have bool 
> return types [2]. I can add an AppleClang check too if you want. 
> 
> [1]:
> ```
> #define __has_keyword(__x) !(__is_identifier(__x))
> ```
> 
> [2]: 
> https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
Ah, you're right. There's no version of AppleClang to put here right now, so 
I'd say status quo is OK. I can add one later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77519



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


[PATCH] D77572: [clang-tidy] add new check readability-use-anyofallof

2020-04-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

See also suggestion  for more generic 
loop-to-algorithm transformations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77572



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-04-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/UsersManual.rst:1684
+   linkage symbols. The unique name is obtained by appending the hash of the
+   full module name to the original symbol. This option is particularly useful
+   in attributing profile information to the correct function when multiple

rnk wrote:
> I think it's important to be specific here. I'd go so far as to say:
> "When this option is set, compiler hashes the main source file path from the 
> command line and appends it to all internal symbols. If a program contains 
> multiple objects compiled from the same source file path, the symbols are not 
> guaranteed to be unique."
Should option like -ffile-prefix-map= affect the hashed source file path? I 
suspect it already does this but I haven't verified.

This may need tests for Windows and non-Windows, similar to D77223.


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

https://reviews.llvm.org/D73307



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


[PATCH] D77519: Fix __is_pointer builtin type trait to work with Objective-C pointer types.

2020-04-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/test/SemaObjCXX/type-traits-is-pointer.mm:1
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics

Why do you run this through `-verify`? Can't you just drop that and the `// 
expected-no-diagnostics` bit too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77519



___
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-04-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as done.
leonardchan added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:435
   if (Level.getSpeedupLevel() > 1) {
-FPM.addPass(SpeculativeExecutionPass());
+FPM.addPass(SpeculativeExecutionIfHasBranchDivergencePass());
 

arsenm wrote:
> I don't expect this to be a separate pass, just added based on a divergent 
> target
Updated such that the current pass is used, although it's a bit more difficult 
to test since the same pass name will appear when dumping the passes.


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] D76182: [AVR] Support aliases in non-zero address space

2020-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

I agree this needs a test case.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4550
   // Create the new alias itself, but don't set a name yet.
+  unsigned AS = cast(Aliasee->getType())->getAddressSpace();
   auto *GA =

`Aliasee->getType()->getPointerAddressSpace()`

LGTM.  If we ever allow functions to declare an explicit address space, we'll 
need semantic checks that aliases match up, but that's okay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76182



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


[PATCH] D77534: [clangd] DefineOutline: removes static token from static CXXMethodDecl

2020-04-06 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 255472.
njames93 marked an inline comment as done.
njames93 added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77534

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h

Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -170,7 +170,7 @@
 private:
   static Optional getCastKind(llvm::StringRef AttrKind) {
 return llvm::StringSwitch>(AttrKind)
-#define CAST_OPERATION(Name) .Case( #Name, CK_##Name)
+#define CAST_OPERATION(Name) .Case("CK_" #Name, CK_##Name)
 #include "clang/AST/OperationKinds.def"
 .Default(llvm::None);
   }
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2142,6 +2142,28 @@
 };)cpp",
   "void B::foo()   {}\n",
   },
+  {
+  R"cpp(
+struct A {
+  static void fo^o() {}
+};)cpp",
+  R"cpp(
+struct A {
+  static void foo() ;
+};)cpp",
+  " void A::foo() {}\n",
+  },
+  {
+  R"cpp(
+struct A {
+  static static void fo^o() {}
+};)cpp",
+  R"cpp(
+struct A {
+  static static void foo() ;
+};)cpp",
+  "  void A::foo() {}\n",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
@@ -2236,6 +2258,24 @@
 STUPID_MACRO(sizeof sizeof int) void foo() ;
   };)cpp",
" void A::foo() {}\n"},
+  {R"cpp(#define STAT static
+  struct A {
+STAT void f^oo() {}
+  };)cpp",
+   R"cpp(#define STAT static
+  struct A {
+STAT void foo() ;
+  };)cpp",
+   " void A::foo() {}\n"},
+  {R"cpp(#define STUPID_MACRO(X) static
+  struct A {
+STUPID_MACRO(sizeof sizeof int) void f^oo() {}
+  };)cpp",
+   R"cpp(#define STUPID_MACRO(X) static
+  struct A {
+STUPID_MACRO(sizeof sizeof int) void foo() ;
+  };)cpp",
+   " void A::foo() {}\n"},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
@@ -2360,8 +2400,7 @@
   struct A {
 VIRT fo^o() {}
   };)cpp",
-  "fail: define outline: Can't move out of line as function has a "
-  "macro `virtual` specifier."},
+  "fail: define outline: couldn't remove `virtual` keyword."},
   {
   R"cpp(
   #define OVERFINAL final override
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -239,21 +239,22 @@
   DelAttr(FD->getAttr());
   DelAttr(FD->getAttr());
 
-  if (FD->isVirtualAsWritten()) {
-SourceRange SpecRange{FD->getBeginLoc(), FD->getLocation()};
-bool HasErrors = true;
-
-// Clang allows duplicating virtual specifiers so check for multiple
-// occurrences.
-for (const auto &Tok : TokBuf.expandedTokens(SpecRange)) {
-  if (Tok.kind() != tok::kw_virtual)
+  auto DelKeyword = [&](tok::TokenKind Kind, SourceRange FromRange) {
+bool FoundAny = false;
+for (const auto &Tok : TokBuf.expandedTokens(FromRange)) {
+  if (Tok.kind() != Kind)
 continue;
+  FoundAny = true;
   auto Spelling = TokBuf.spelledForExpanded(llvm::makeArrayRef(Tok));
   if (!Spelling) {
-HasErrors = true;
+Errors = llvm::joinErrors(
+std::move(Errors),
+llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+llvm::formatv("define outline: couldn't remove `{0}` keyword.",
+  tok::getKeywordSpelling(Kind;
 break;
   }
-  HasErrors = false;
   CharSourceRange DelRange =
   syntax::Token::range(SM, Spelling->front(), Spelling->back())
   .toCharRange(SM);
@@ -261,13 +262,22 @@
   DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
 Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
 }
-if (HasErrors) {
+if (!FoundAny) {
   Errors = llvm::joinErrors(
   std::move(Errors),
-  llvm::createStringError(llvm::inconvertibleErrorCode(),
-  "define outline: Can't move out of line as "
-  

[PATCH] D77534: [clangd] DefineOutline: removes static token from static CXXMethodDecl

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

- Fix issue with last revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77534

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2142,6 +2142,28 @@
 };)cpp",
   "void B::foo()   {}\n",
   },
+  {
+  R"cpp(
+struct A {
+  static void fo^o() {}
+};)cpp",
+  R"cpp(
+struct A {
+  static void foo() ;
+};)cpp",
+  " void A::foo() {}\n",
+  },
+  {
+  R"cpp(
+struct A {
+  static static void fo^o() {}
+};)cpp",
+  R"cpp(
+struct A {
+  static static void foo() ;
+};)cpp",
+  "  void A::foo() {}\n",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
@@ -2236,6 +2258,24 @@
 STUPID_MACRO(sizeof sizeof int) void foo() ;
   };)cpp",
" void A::foo() {}\n"},
+  {R"cpp(#define STAT static
+  struct A {
+STAT void f^oo() {}
+  };)cpp",
+   R"cpp(#define STAT static
+  struct A {
+STAT void foo() ;
+  };)cpp",
+   " void A::foo() {}\n"},
+  {R"cpp(#define STUPID_MACRO(X) static
+  struct A {
+STUPID_MACRO(sizeof sizeof int) void f^oo() {}
+  };)cpp",
+   R"cpp(#define STUPID_MACRO(X) static
+  struct A {
+STUPID_MACRO(sizeof sizeof int) void foo() ;
+  };)cpp",
+   " void A::foo() {}\n"},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
@@ -2360,8 +2400,7 @@
   struct A {
 VIRT fo^o() {}
   };)cpp",
-  "fail: define outline: Can't move out of line as function has a "
-  "macro `virtual` specifier."},
+  "fail: define outline: couldn't remove `virtual` keyword."},
   {
   R"cpp(
   #define OVERFINAL final override
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -239,21 +239,22 @@
   DelAttr(FD->getAttr());
   DelAttr(FD->getAttr());
 
-  if (FD->isVirtualAsWritten()) {
-SourceRange SpecRange{FD->getBeginLoc(), FD->getLocation()};
-bool HasErrors = true;
-
-// Clang allows duplicating virtual specifiers so check for multiple
-// occurrences.
-for (const auto &Tok : TokBuf.expandedTokens(SpecRange)) {
-  if (Tok.kind() != tok::kw_virtual)
+  auto DelKeyword = [&](tok::TokenKind Kind, SourceRange FromRange) {
+bool FoundAny = false;
+for (const auto &Tok : TokBuf.expandedTokens(FromRange)) {
+  if (Tok.kind() != Kind)
 continue;
+  FoundAny = true;
   auto Spelling = TokBuf.spelledForExpanded(llvm::makeArrayRef(Tok));
   if (!Spelling) {
-HasErrors = true;
+Errors = llvm::joinErrors(
+std::move(Errors),
+llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+llvm::formatv("define outline: couldn't remove `{0}` keyword.",
+  tok::getKeywordSpelling(Kind;
 break;
   }
-  HasErrors = false;
   CharSourceRange DelRange =
   syntax::Token::range(SM, Spelling->front(), Spelling->back())
   .toCharRange(SM);
@@ -261,13 +262,22 @@
   DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
 Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
 }
-if (HasErrors) {
+if (!FoundAny) {
   Errors = llvm::joinErrors(
   std::move(Errors),
-  llvm::createStringError(llvm::inconvertibleErrorCode(),
-  "define outline: Can't move out of line as "
-  "function has a macro `virtual` specifier."));
+  llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  llvm::formatv(
+  "define outline: couldn't find `{0}` keyword to remove.",
+  tok::getKeywordSpelling(Kind;
 }
+  };
+
+  if (const auto *MD = dyn_cast(FD)) {
+if (MD->isVirtualAsWritten())
+  DelKeyword(tok::kw_virtual, {FD->getBeginLoc(), FD->getLocation()});
+if (MD->isStatic())
+  DelKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()});
   }
 
   if (Errors)
_

Re: [clang] a8c8b62 - [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2020-04-06 Thread Volodymyr Sapsai via cfe-commits
Is there anything special in the builedbot configuration? Are you still 
observing intermittent failures?

I’m double checking if we see similar failures internally but so far looks like 
everything is working fine. I’ve only seen a single failure 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/18616
 


At the moment I don’t know what might be causing the non-determinism. The type 
checking depends on the parsing order. We rely that

@interface ParameterizedContainer (Cat)

is parsed before

- (ParameterizedContainer *)inCategory;

So we check type parameter T is consistent with original @interface before 
using it. What is also confusing is that there is only a single error. I  
expect both a category and an extension to have same errors.

> On Apr 5, 2020, at 10:10, Nico Weber  wrote:
> 
> The test here flakily fails, maybe 1 in 10 times: 
> http://45.33.8.238/mac/11180/step_7.txt 
> 
> 
> error: 'error' diagnostics seen but not expected: 
>   File 
> /Users/thakis/src/llvm-project/clang/test/SemaObjC/parameterized_classes_subst.m
>  Line 479: type argument 'T' (aka 'id') does not satisfy the bound 
> ('id') of type parameter 'T'
> error: 'note' diagnostics seen but not expected: 
>   File 
> /Users/thakis/src/llvm-project/clang/test/SemaObjC/parameterized_classes_subst.m
>  Line 475: type parameter 'T' declared here
> 2 errors generated.
> 
> Maybe if this is emitted depends on the order of something in a data 
> structure that has no deterministic order, or similar?
> 
> On Fri, Apr 3, 2020 at 7:29 PM Volodymyr Sapsai via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
> Author: Volodymyr Sapsai
> Date: 2020-04-03T16:29:02-07:00
> New Revision: a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7
>  
> 
> DIFF: 
> https://github.com/llvm/llvm-project/commit/a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7.diff
>  
> 
> 
> LOG: [ObjC generics] Fix not inheriting type bounds in categories/extensions.
> 
> When a category/extension doesn't repeat a type bound, corresponding
> type parameter is substituted with `id` when used as a type argument. As
> a result, in the added test case it was causing errors like
> 
> > type argument 'T' (aka 'id') does not satisfy the bound ('id') 
> > of type parameter 'T'
> 
> We are already checking that type parameters should be consistent
> everywhere (see `checkTypeParamListConsistency`) and update
> `ObjCTypeParamDecl` to have correct underlying type. And when we use the
> type parameter as a method return type or a method parameter type, it is
> substituted to the bounded type. But when we use the type parameter as a
> type argument, we check `ObjCTypeParamType` that wasn't updated and
> remains `id`.
> 
> Fix by updating not only `ObjCTypeParamDecl` UnderlyingType but also
> TypeForDecl as we use the underlying type to create a canonical type for
> `ObjCTypeParamType` (see `ASTContext::getObjCTypeParamType`).
> 
> This is a different approach to fixing the issue. The previous one was
> 02c2ab3d8872416589bd1a6ca3dfb96ba373a3b9 which was reverted in
> 4c539e8da1b3de38a53ef3f7497f5c45a3243b61. The problem with the previous
> approach was that `ObjCTypeParamType::desugar` was returning underlying
> type for `ObjCTypeParamDecl` without applying any protocols stored in
> `ObjCTypeParamType`. It caused inconsistencies in comparing types before
> and after desugaring.
> 
> rdar://problem/54329242
> 
> Reviewed By: erik.pilkington
> 
> Differential Revision: https://reviews.llvm.org/D72872 
> 
> 
> Added: 
> 
> 
> Modified: 
> clang/include/clang/AST/ASTContext.h
> clang/lib/AST/ASTContext.cpp
> clang/lib/AST/Type.cpp
> clang/lib/Sema/SemaDeclObjC.cpp
> clang/test/SemaObjC/parameterized_classes_collection_literal.m
> clang/test/SemaObjC/parameterized_classes_subst.m
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/clang/include/clang/AST/ASTContext.h 
> b/clang/include/clang/AST/ASTContext.h
> index 6813ab58874e..6360f18217c7 100644
> --- a/clang/include/clang/AST/ASTContext.h
> +++ b/clang/include/clang/AST/ASTContext.h
> @@ -1442,6 +1442,8 @@ class ASTContext : public RefCountedBase {
> 
>QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
>  ArrayRef protocols) 
> const;
> +  void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig,
> +ObjCTypeParamDecl *New) const;
> 
>bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceD

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

2020-04-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 255474.
leonardchan edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76389

Files:
  llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp

Index: llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
===
--- llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -123,7 +123,7 @@
   // Variable preserved purely for correct name printing.
   const bool OnlyIfDivergentTarget;
 
-  SpeculativeExecutionPass Impl;
+  SpeculativeExecutionPassImpl Impl;
 };
 } // namespace
 
@@ -150,7 +150,8 @@
 
 namespace llvm {
 
-bool SpeculativeExecutionPass::runImpl(Function &F, TargetTransformInfo *TTI) {
+bool SpeculativeExecutionPassImpl::runImpl(Function &F,
+   TargetTransformInfo *TTI) {
   if (OnlyIfDivergentTarget && !TTI->hasBranchDivergence()) {
 LLVM_DEBUG(dbgs() << "Not running SpeculativeExecution because "
  "TTI->hasBranchDivergence() is false.\n");
@@ -165,7 +166,7 @@
   return Changed;
 }
 
-bool SpeculativeExecutionPass::runOnBasicBlock(BasicBlock &B) {
+bool SpeculativeExecutionPassImpl::runOnBasicBlock(BasicBlock &B) {
   BranchInst *BI = dyn_cast(B.getTerminator());
   if (BI == nullptr)
 return false;
@@ -251,8 +252,8 @@
   }
 }
 
-bool SpeculativeExecutionPass::considerHoistingFromTo(
-BasicBlock &FromBlock, BasicBlock &ToBlock) {
+bool SpeculativeExecutionPassImpl::considerHoistingFromTo(BasicBlock &FromBlock,
+  BasicBlock &ToBlock) {
   SmallPtrSet NotHoisted;
   const auto AllPrecedingUsesFromBlockHoisted = [&NotHoisted](User *U) {
 for (Value* V : U->operand_values()) {
@@ -299,12 +300,13 @@
   return new SpeculativeExecutionLegacyPass(/* OnlyIfDivergentTarget = */ true);
 }
 
-SpeculativeExecutionPass::SpeculativeExecutionPass(bool OnlyIfDivergentTarget)
+SpeculativeExecutionPassImpl::SpeculativeExecutionPassImpl(
+bool OnlyIfDivergentTarget)
 : OnlyIfDivergentTarget(OnlyIfDivergentTarget ||
 SpecExecOnlyIfDivergentTarget) {}
 
-PreservedAnalyses SpeculativeExecutionPass::run(Function &F,
-FunctionAnalysisManager &AM) {
+PreservedAnalyses
+SpeculativeExecutionPassImpl::run(Function &F, FunctionAnalysisManager &AM) {
   auto *TTI = &AM.getResult(F);
 
   bool Changed = runImpl(F, TTI);
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -440,7 +440,7 @@
 
   // Speculative execution if the target has divergent branches; otherwise nop.
   if (Level.getSpeedupLevel() > 1) {
-FPM.addPass(SpeculativeExecutionPass());
+FPM.addPass(SpeculativeExecutionPass(/*OnlyIfDivergentTarget=*/true));
 
 // Optimize based on known information about branches, and cleanup afterward.
 FPM.addPass(JumpThreadingPass());
Index: llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
===
--- llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
+++ llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
@@ -66,10 +66,9 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-class SpeculativeExecutionPass
-: public PassInfoMixin {
+class SpeculativeExecutionPassImpl {
 public:
-  SpeculativeExecutionPass(bool OnlyIfDivergentTarget = false);
+  SpeculativeExecutionPassImpl(bool OnlyIfDivergentTarget = false);
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
@@ -86,6 +85,22 @@
 
   TargetTransformInfo *TTI = nullptr;
 };
+
+class SpeculativeExecutionPass
+: public SpeculativeExecutionPassImpl,
+  public PassInfoMixin {
+public:
+  SpeculativeExecutionPass(bool OnlyIfDivergentTarget = false)
+  : SpeculativeExecutionPassImpl(OnlyIfDivergentTarget) {}
+};
+
+class SpeculativeExecutionIfHasBranchDivergencePass
+: public SpeculativeExecutionPassImpl,
+  public PassInfoMixin {
+public:
+  SpeculativeExecutionIfHasBranchDivergencePass()
+  : SpeculativeExecutionPassImpl(/*OnlyIfDivergentTarget=*/true) {}
+};
 }
 
 #endif //LLVM_TRANSFORMS_SCALAR_SPECULATIVEEXECUTION_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77534: [clangd] DefineOutline: removes static token from static CXXMethodDecl

2020-04-06 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 9 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:294
+  if (isa(FD) && cast(FD)->isStatic())
+DeleteKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()});
 

kadircet wrote:
> sorry if I miscommunicated, I was trying to say that multiple `static` 
> keywords are also allowed by clang. So we should be dropping all of them, as 
> we do for `virtual`
Yeah sorry, I checked and it was rejected. I just realised I was checking 
against gcc...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77534



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


[PATCH] D77572: [clang-tidy] add new check readability-use-anyofallof

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

As no FixIts are made the `IncludeInserter` can be removed.

I'm struggling to see the value of this check though. If it was reworked to 
check for loop in the middle of a function it would have a lot more value.

  bool all_of = true;
  for (auto X : V) {
if (!X) {
  all_of = false;
  break;
}
  }

Being able to identify those and possibly even transform them would have much 
more value

  bool all_of = std::all_of(std::begin(V), std::end(V), [](const auto &X) { 
return static_cast(X) });

I'm guessing you'd want to check for compound statements that have a `bool` 
`VarDecl` with an init just before the range for loop and a condition in the 
loop that flips the value and then breaks after.




Comment at: 
clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp:21-41
+namespace ast_matchers {
+/// Matches a Stmt whose parent is a CompoundStmt,
+/// and which is directly followed by
+/// a Stmt matching the inner matcher.
+AST_MATCHER_P(Stmt, nextStmt, internal::Matcher, InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);
+  if (Parents.size() != 1)

This should be in an anonymous namespace as it doesn't need external linkage. 
Probably shouldn't be in the `ast_matchers` namespace either



Comment at: clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp:34
+
+  const auto *I = std::find(C->body_begin(), C->body_end(), &Node);
+  assert(I != C->body_end()); // C is parent of Node.

nit: `const auto *I = llvm::find(C->body(), &Node);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77572



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


[PATCH] D77451: Accept -x cu to indicate language is CUDA, transfer CUDA language flag to header-file arguments

2020-04-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D77451#1964971 , @sammccall wrote:

> > NVCC uses different options that should be properly translated
>
> Interested to see how this will work. Is clang itself going to support these 
> args (act compatibly with nvcc, or is the idea that just tools will be?


I don't think it makes a lot of sense to create nvcc-compatible driver. Even if 
we did, we'd still have to handle things in the tooling library, too, in a way 
similar to what we currently do for cl or clang-cl.  Argument translation could 
use some refactoring, too, to make it more generic and easier to adapt.




Comment at: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp:119
+  case types::TY_CUDA_DEVICE:
+  case types::TY_CUDA_FATBIN:
+return types::TY_CUDA:

sammccall wrote:
> tra wrote:
> > I don't think you need CUDA_FATBIN for clangd.  If your input is .fatbin, 
> > the source code has been long gone.
> This establishes equivalence classes within which it makes sense to transfer 
> command-line flags. So if you might have compile_commands.json entries 
> building .fatbin inputs, and those flags are a sensible template for building 
> *.cu.cc files, then you want fatbin here, otherwise not.
Both nvcc and clang can build .ptx (nvcc's `-ptx`, clang's `--cuda-device-only 
-S`) or .cubin (`-cubin` and `--cuda-device-only -c`).  I believe neither nvcc 
not clang expose fatbin as a compilation result. It's purely for internal 
driver use in both cases. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77451



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


[PATCH] D77586: Allow parameter names to be elided in a function definition in C

2020-04-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall, erik.pilkington.
Herald added a subscriber: dexonsmith.

WG14 has adopted N2480 
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2480.pdf) into C2x at the 
meetings last week, allowing parameter names of a function definition to be 
elided. This patch relaxes the error so that C++ and C2x do not diagnose this 
situation, and modes before C2x will allow it as an extension.

This also adds the same feature to ObjC blocks under the assumption that ObjC 
wishes to follow the C standard in this regard.


https://reviews.llvm.org/D77586

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/block-args.c
  clang/test/Sema/c89.c
  clang/test/Sema/function.c

Index: clang/test/Sema/function.c
===
--- clang/test/Sema/function.c
+++ clang/test/Sema/function.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// RUN: %clang_cc1 %s -fsyntax-only -verify -verify=c2x -pedantic
+// RUN: %clang_cc1 %s -fsyntax-only -std=c2x -verify -pedantic
 
 // PR1892, PR11354
 void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
@@ -30,7 +31,7 @@
 void t11(){t10(1);} // expected-warning{{too many arguments}}
 
 // PR3208
-void t12(int) {}  // expected-error{{parameter name omitted}}
+void t12(int) {}  // c2x-warning{{omitting the parameter name in a function definition is a C2x extension}}
 
 // PR2790
 void t13() {
@@ -80,7 +81,8 @@
 fn_t t17;
 
 // PR4049
-unknown_type t18(void*) {   // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}}
+unknown_type t18(void*) {   // expected-error {{unknown type name 'unknown_type'}} \
+// c2x-warning {{omitting the parameter name in a function definition is a C2x extension}}
 }
 
 unknown_type t19(int* P) {   // expected-error {{unknown type name 'unknown_type'}}
Index: clang/test/Sema/c89.c
===
--- clang/test/Sema/c89.c
+++ clang/test/Sema/c89.c
@@ -45,7 +45,7 @@
 
 typedef int sometype;
 int a(sometype, y) {return 0;}  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
-   expected-error {{parameter name omitted}}*/
+   expected-warning {{omitting the parameter name in a function definition is a C2x extension}}*/
 
 
 
Index: clang/test/Sema/block-args.c
===
--- clang/test/Sema/block-args.c
+++ clang/test/Sema/block-args.c
@@ -31,8 +31,8 @@
 
 // radar 7528255
 void f0() {
-  ^(int, double d, char) {}(1, 1.34, 'a'); // expected-error {{parameter name omitted}} \
- 	   // expected-error {{parameter name omitted}}
+  ^(int, double d, char) {}(1, 1.34, 'a'); // expected-warning {{omitting the parameter name in a function definition is a C2x extension}} \
+   // expected-warning {{omitting the parameter name in a function definition is a C2x extension}}
 }
 
 // rdar://problem/8962770
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14645,11 +14645,12 @@
   if (ExplicitSignature) {
 for (unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
   ParmVarDecl *Param = ExplicitSignature.getParam(I);
-  if (Param->getIdentifier() == nullptr &&
-  !Param->isImplicit() &&
-  !Param->isInvalidDecl() &&
-  !getLangOpts().CPlusPlus)
-Diag(Param->getLocation(), diag::err_parameter_name_omitted);
+  if (Param->getIdentifier() == nullptr && !Param->isImplicit() &&
+  !Param->isInvalidDecl() && !getLangOpts().CPlusPlus) {
+// Diagnose this as an extension in C17 and earlier.
+if (!getLangOpts().C2x)
+  Diag(Param->getLocation(), diag::ext_parameter_name_ommitted_c2x);
+  }
   Params.push_back(Param);
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -12860,11 +12860,12 @@
 
 // C99 6.9.1p5: If the declarator includes a parameter type list, the
 // declaration of each parameter shall include an identifier.
-if (CheckParameterNames &&
-Param->getIdentifier() == nullptr &&
-!Param->isImplicit() &&
-!getLangOpts().CPlusPlus)
-  Diag(Param->getLocation(), diag::err_parameter_name_omitted);
+if (CheckParameterNames && Param->getIdentifier() == nullptr &&
+!Param->isImplicit() && !getLangOpts().CPlusPlus) {
+  // Diagnose thi

[PATCH] D77585: Stop passing site cfg files via --param to llvm-lit.

2020-04-06 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, mgorny.

This has been unnecessary since https://reviews.llvm.org/D37756.

https://reviews.llvm.org/D37838 removed it for llvm.

This removes it for clang, lld, clang-tools-extra (and for the GN build).

No intended behavior change.


https://reviews.llvm.org/D77585

Files:
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang/test/CMakeLists.txt
  lld/test/CMakeLists.txt
  llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
  llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
  llvm/utils/gn/secondary/clang/test/BUILD.gn
  llvm/utils/gn/secondary/lld/test/BUILD.gn
  llvm/utils/gn/secondary/llvm/test/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/test/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -289,11 +289,6 @@
   }
   args = [
 "-sv",
-"--param",
-"llvm_site_config=" + rebase_path(llvm_lit_site_cfg_file, root_out_dir),
-"--param",
-"llvm_unit_site_config=" +
-rebase_path(llvm_lit_unit_site_cfg_file, root_out_dir),
 rebase_path(".", root_out_dir),
   ]
   outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
Index: llvm/utils/gn/secondary/lld/test/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/test/BUILD.gn
+++ llvm/utils/gn/secondary/lld/test/BUILD.gn
@@ -110,11 +110,6 @@
   }
   args = [
 "-sv",
-"--param",
-"lld_site_config=" + rebase_path(lld_lit_site_cfg_file, root_out_dir),
-"--param",
-"lld_unit_site_config=" +
-rebase_path(lld_lit_unit_site_cfg_file, root_out_dir),
 rebase_path(".", root_out_dir),
   ]
   outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -189,11 +189,6 @@
   }
   args = [
 "-sv",
-"--param",
-"clang_site_config=" + rebase_path(clang_lit_site_cfg_file, root_out_dir),
-"--param",
-"clang_unit_site_config=" +
-rebase_path(clang_lit_unit_site_cfg_file, root_out_dir),
 rebase_path(".", root_out_dir),
   ]
   outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
Index: llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
@@ -90,12 +90,6 @@
   }
   args = [
 "-sv",
-"--param",
-"clang_site_config=" +
-rebase_path(clang_tools_extra_lit_site_cfg_file, root_out_dir),
-"--param",
-"clang_unit_site_config=" +
-rebase_path(clang_tools_extra_lit_unit_site_cfg_file, root_out_dir),
 rebase_path(".", root_out_dir),
   ]
   outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
Index: llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
@@ -21,8 +21,9 @@
   output = clangd_lit_site_cfg_file
 
   extra_values = [
-"CMAKE_CURRENT_BINARY_DIR=" + rebase_path(
-get_label_info("//clang-tools-extra/clangd/test", "target_out_dir")),
+"CMAKE_CURRENT_BINARY_DIR=" +
+rebase_path(get_label_info("//clang-tools-extra/clangd/test",
+   "target_out_dir")),
 "CMAKE_CURRENT_SOURCE_DIR=" +
 rebase_path("//clang-tools-extra/clangd/test"),
 
@@ -91,6 +92,10 @@
   }
   args = [
 "-sv",
+
+# clangd doesn't put unittest configs in test/unit like every other project.
+# Because of that, this needs to pass two folders here, while every other
+# project only needs to pass CMAKE_CURRENT_BINARY_DIR.
 rebase_path(get_path_info(clangd_lit_site_cfg_file, "dir"), root_out_dir),
 rebase_path(get_path_info(clangd_lit_unit_site_cfg_file, "dir"),
 root_out_dir),
Index: lld/test/CMakeLists.txt
===
--- lld/test/CMakeLists.txt
+++ lld/test/CMakeLists.txt
@@ -44,14 +44,8 @@
   list(APPEND LLD_TEST_DEPS LLDUnitTests)
 endif()
 
-set(LLD_TEST_PARAMS
-  lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  )
-
 add_lit_testsuite(check-lld "Running lld test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  PARAMS lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-   lld_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
   DEPENDS ${LLD_TEST_DEPS}
   )
 
@@ -59,8 +53,6 @@
 set_ta

[PATCH] D62445: [test] Fix plugin tests

2020-04-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: cfe/trunk/test/CMakeLists.txt:140
-  set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
-
-  if (LLVM_WITH_Z3)

Did you intentionally delete the 2 targets here? 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62445



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


[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX

2020-04-06 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

Not sure if you want to wait for the feedback from @sfertile and @cebowleratibm 
, but I'm good with the current revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76130



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


[PATCH] D77571: [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.

2020-04-06 Thread Michael Wyman via Phabricator via cfe-commits
mwyman marked an inline comment as done.
mwyman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:71-73
+  // Currently there is no way to directly get the source range for the
+  // __weak/__strong ObjC lifetime qualifiers, so it's necessary to string
+  // search in the source code.

benhamilton wrote:
> Is there a bug filed for this? Seems like an oversight.
> 
Maybe I'm incorrectly reading this, but per the comment on QualifiedTypeLoc it 
seems like this is intentional at this time: 
https://github.com/llvm/llvm-project/blob/549e87f3d04bbae91bc7bc38609ce7073e2c8a6d/clang/include/clang/AST/TypeLoc.h#L275



Comment at: 
clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:116
+  auto Diag = diag(MatchedExpr->getArg(0)->getBeginLoc(),
+   "NSInvocation's %0 should only pass pointers to "
+   "objects with ownership __unsafe_unretained")

benhamilton wrote:
> -[NSInvocation %0] should
> 
Tweaked the format string so it now outputs "NSInvocation '-…'", since the 
diagnostic formatter inserts single-quotes, which would otherwise make it read 
"-[NSInvocation 'getArgument:atIndex:']", which seems weirder.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77571



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


[PATCH] D77571: [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.

2020-04-06 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 255461.
mwyman marked 6 inline comments as done.
mwyman added a comment.

Responding to review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77571

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp
  clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s objc-nsinvocation-argument-lifetime %t -- -fobjc-arc
+
+__attribute__((objc_root_class))
+@interface NSObject
+@end
+
+@interface NSInvocation : NSObject
+- (void)getArgument:(void *)Arg atIndex:(int)Index;
+- (void)getReturnValue:(void *)ReturnValue;
+@end
+
+@interface OtherClass : NSObject
+- (void)getArgument:(void *)Arg atIndex:(int)Index;
+@end
+
+void foo(NSInvocation *Invocation) {
+  __unsafe_unretained id Arg2;
+  id Arg3;
+  // CHECK-FIXES: __unsafe_unretained id Arg3;
+  NSObject __strong *Arg4;
+  // CHECK-FIXES: NSObject __unsafe_unretained *Arg4;
+  __weak id Arg5;
+  // CHECK-FIXES: __unsafe_unretained id Arg5;
+  id ReturnValue;
+  // CHECK-FIXES: __unsafe_unretained id ReturnValue;
+  void (^BlockArg1)();
+  __unsafe_unretained void (^BlockArg2)();
+
+  [Invocation getArgument:&Arg2 atIndex:2];
+
+  [Invocation getArgument:&Arg3 atIndex:3];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&Arg4 atIndex:4];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&Arg5 atIndex:5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&BlockArg1 atIndex:6];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:&BlockArg2 atIndex:6];
+
+  [Invocation getReturnValue:&ReturnValue];
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: NSInvocation '-getReturnValue:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+
+  [Invocation getArgument:(void*)0 atIndex:6];
+}
+
+void bar(OtherClass *OC) {
+  id Arg;
+  [OC getArgument:&Arg atIndex:2];
+}
+
+@interface TestClass : NSObject {
+  id Argument;
+}
+@end
+
+@implementation TestClass
+
+- (void)processInvocation:(NSInvocation *)Invocation {
+  [Invocation getArgument:&Argument atIndex:2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+  [Invocation getArgument:&self->Argument atIndex:2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: NSInvocation '-getArgument:atIndex:' should only pass pointers to objects with ownership __unsafe_unretained [objc-nsinvocation-argument-lifetime]
+}
+
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - objc-nsinvocation-argument-lifetime
+
+objc-nsinvocation-argument-lifetime
+===
+
+Finds calls to ``NSInvocation`` methods under ARC that don't have proper
+argument object lifetimes. When passing Objective-C objects as parameters
+to the ``NSInvocation`` methods ``getArgument:atIndex:`` and
+``getReturnValue:``, the values are copied by value into the argument pointer,
+which leads to to incorrect releasing behavior if the object pointers are
+not declared ``__unsafe_unretained``.
+
+For code:
+
+.. code-block:: objc
+
+id arg;
+[invocation getArgument:&arg atIndex:2];
+
+__strong id returnValue;
+[invocation getReturnValue:&returnValue];
+
+The fix will be:
+
+.. c

[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-04-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:26-28
+#define ASSERT_STREAMSTATE_OPENED  
\
+  assert(SS->isOpened() && 
\
+ "Create of error node failed (only way to get this state)?");

NoQ wrote:
> Szelethus wrote:
> > NoQ wrote:
> > > `assertStreamStateOpened(SS);` isn't much harder to type. Can we make it 
> > > a function please?
> > Mind that this is completely stripped from release builds, unlike a 
> > function call. I think.
> I'd be shocked if that's the case. In LLVM we have a lot of tiny functions 
> all over the place and we'd better have them inlined most of the time.
Ah, okay. Lets turn this into a regular function then!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-04-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Sorry for the delay, thanks for the update. Code looks good, but I want the 
documentation to be specific.




Comment at: clang/docs/UsersManual.rst:1684
+   linkage symbols. The unique name is obtained by appending the hash of the
+   full module name to the original symbol. This option is particularly useful
+   in attributing profile information to the correct function when multiple

I think it's important to be specific here. I'd go so far as to say:
"When this option is set, compiler hashes the main source file path from the 
command line and appends it to all internal symbols. If a program contains 
multiple objects compiled from the same source file path, the symbols are not 
guaranteed to be unique."


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

https://reviews.llvm.org/D73307



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


[PATCH] D77583: [hip] Remove `hip_pinned_shadow`.

2020-04-06 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added a reviewer: yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Use `device_builtin_surface` and `device_builtin_texture` for surface/texture 
reference support. So far, both the host and device use the same reference 
type, which could be revised later when interface/implementation is stablized.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77583

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-hip-pinned-shadow.cu
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-rdc.hip
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \
-// RUN: -emit-llvm -o - -x hip %s -fsyntax-only -verify
-// RUN: %clang_cc1 -triple x86_64 -std=c++11 \
-// RUN: -emit-llvm -o - -x hip %s -fsyntax-only -verify
-
-#define __device__ __attribute__((device))
-#define __constant__ __attribute__((constant))
-#define __hip_pinned_shadow__ __attribute((hip_pinned_shadow))
-
-struct textureReference {
-  int a;
-};
-
-template 
-struct texture : public textureReference {
-texture() { a = 1; }
-};
-
-__hip_pinned_shadow__ texture tex;
-__device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
-__constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -61,7 +61,6 @@
 // CHECK-NEXT: FlagEnum (SubjectMatchRule_enum)
 // CHECK-NEXT: Flatten (SubjectMatchRule_function)
 // CHECK-NEXT: GNUInline (SubjectMatchRule_function)
-// CHECK-NEXT: HIPPinnedShadow (SubjectMatchRule_variable)
 // CHECK-NEXT: Hot (SubjectMatchRule_function)
 // CHECK-NEXT: IBAction (SubjectMatchRule_objc_method_is_instance)
 // CHECK-NEXT: IFunc (SubjectMatchRule_function)
Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -44,7 +44,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV1:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -77,7 +77,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV2:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[OBJ_DEV2]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -38,7 +38,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
 
 //
@@ -67,7 +67,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD]] "-flavor" "gnu" "-shared"
+// CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
 
 //
@@ -112,7 +112,7 @@
 // 

[libunwind] 649f042 - [libunwind] Support the new libc++ test format

2020-04-06 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-04-06T23:26:59+03:00
New Revision: 649f042802d3ed9648da4b1939ac387bc4fe9976

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

LOG: [libunwind] Support the new libc++ test format

Reviewers: ldionne, #libunwind, mstorsjo

Reviewed By: ldionne, #libunwind, mstorsjo

Subscribers: mstorsjo, dexonsmith, llvm-commits, libcxx-commits

Tags: #llvm, #libunwind

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

Added: 


Modified: 
libunwind/test/lit.cfg

Removed: 




diff  --git a/libunwind/test/lit.cfg b/libunwind/test/lit.cfg
index 1d284bdfd771..4ac749392737 100644
--- a/libunwind/test/lit.cfg
+++ b/libunwind/test/lit.cfg
@@ -67,4 +67,9 @@ config_module = __import__(config_module_name, 
fromlist=['Configuration'])
 configuration = config_module.Configuration(lit_config, config)
 configuration.configure()
 configuration.print_config_info()
-config.test_format = configuration.get_test_format()
+if lit_config.params.get('use_new_format', False):
+lit_config.note("Using the experimental libc++ testing format")
+import libcxx.test.newformat
+config.test_format = libcxx.test.newformat.CxxStandardLibraryTest()
+else:
+config.test_format = configuration.get_test_format()



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-04-06 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 255456.
Xiangling_L added a comment.

Rebase on the latest master branch;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,55 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
 } t;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: define dso_local void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__dtor_t() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*) #3
+
+// CHECK: define dso_local void @__cxx_global_var_destruct_t() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t)
+// CHECK:   %guard.hasSrterm = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasSrterm, label %destruct.check, label %destruct.end
+
+// CHECK: destruct.check:
+// CHECK:   call void @__dtor_t()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*) #3
+
+// CHECK: define dso_local void @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-priority-attribute.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+
+int foo() __attribute__((constructor(180)));
+int bar() __attribute__((destructor(180)));
+
+class test {
+   int a;
+public:
+test(int c) {a = c;}
+~test() {a = 0;}
+};
+
+__attribute__ ((init_priority (2000)))
+test t(1);
+
+// CHECK: warning: 'constructor' attribute argument not supported:
+// CHECK: int foo() __attribute__((constructor(180)));
+
+// CHECK: warning: 'destructor' attribute argument not supported:
+// check: int bar() __attribute__((destructor(180)));
+
+// CHECK: warning: 'init_priority' attribute argument not supported:
+// CHECK: __attribute__ ((init_priority (2000)))
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6876,13 +6876,19 @@
 handlePassObjectSizeAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Constructor:
-handleConstructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << "";
+else
+  handleConstructorAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Deprecated:
 handleDeprecatedAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Destructor:
-handleDestructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << "";
+else
+  h

[PATCH] D76782: [CodeGenObjC] Fix a crash when attempting to copy a zero-sized bit-field in a non-trivial C struct

2020-04-06 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd33c7de8e11f: [CodeGenObjC] Fix a crash when attempting to 
copy a zero-sized bit-field in a… (authored by erik.pilkington).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76782

Files:
  clang/include/clang/AST/NonTrivialTypeVisitor.h
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/test/CodeGenObjC/strong-in-c-struct.m


Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -887,4 +887,17 @@
   func(0);
 }
 
+struct ZeroBitfield {
+  int : 0;
+  id strong;
+};
+
+
+// CHECK: define linkonce_odr hidden void @__default_constructor_8_sv0
+// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sv0
+void test_zero_bitfield() {
+  struct ZeroBitfield volatile a, b;
+  a = b;
+}
+
 #endif /* USESTRUCT */
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -254,6 +254,10 @@
 
   void visitVolatileTrivial(QualType FT, const FieldDecl *FD,
 CharUnits CurStructOffset) {
+// Zero-length bit-fields don't need to be copied/assigned.
+if (FD && FD->isZeroLengthBitField(this->Ctx))
+  return;
+
 // Because volatile fields can be bit-fields and are individually copied,
 // their offset and width are in bits.
 uint64_t OffsetInBits =
@@ -543,6 +547,10 @@
 std::array Addrs) {
 LValue DstLV, SrcLV;
 if (FD) {
+  // No need to copy zero-length bit-fields.
+  if (FD->isZeroLengthBitField(this->CGF->getContext()))
+return;
+
   QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0);
   llvm::PointerType *PtrTy = this->CGF->ConvertType(RT)->getPointerTo();
   Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset);
Index: clang/include/clang/AST/NonTrivialTypeVisitor.h
===
--- clang/include/clang/AST/NonTrivialTypeVisitor.h
+++ clang/include/clang/AST/NonTrivialTypeVisitor.h
@@ -1,4 +1,4 @@
-//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ 
--*-===//
+//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -887,4 +887,17 @@
   func(0);
 }
 
+struct ZeroBitfield {
+  int : 0;
+  id strong;
+};
+
+
+// CHECK: define linkonce_odr hidden void @__default_constructor_8_sv0
+// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sv0
+void test_zero_bitfield() {
+  struct ZeroBitfield volatile a, b;
+  a = b;
+}
+
 #endif /* USESTRUCT */
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -254,6 +254,10 @@
 
   void visitVolatileTrivial(QualType FT, const FieldDecl *FD,
 CharUnits CurStructOffset) {
+// Zero-length bit-fields don't need to be copied/assigned.
+if (FD && FD->isZeroLengthBitField(this->Ctx))
+  return;
+
 // Because volatile fields can be bit-fields and are individually copied,
 // their offset and width are in bits.
 uint64_t OffsetInBits =
@@ -543,6 +547,10 @@
 std::array Addrs) {
 LValue DstLV, SrcLV;
 if (FD) {
+  // No need to copy zero-length bit-fields.
+  if (FD->isZeroLengthBitField(this->CGF->getContext()))
+return;
+
   QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0);
   llvm::PointerType *PtrTy = this->CGF->ConvertType(RT)->getPointerTo();
   Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset);
Index: clang/include/clang/AST/NonTrivialTypeVisitor.h
===
--- clang/include/clang/AST/NonTrivialTypeVisitor.h
+++ clang/include/clang/AST/NonTrivialTypeVisitor.h
@@ -1,4 +1,4 @@
-//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ --*-===//
+//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

[PATCH] D77581: Add map-type check for target and target data directive

2020-04-06 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77581

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_messages.c
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp

Index: clang/test/OpenMP/target_teams_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_map_messages.cpp
+++ clang/test/OpenMP/target_teams_map_messages.cpp
@@ -580,6 +580,13 @@
 #pragma omp target teams map(*(1+*a+*a)) // expected-error {{indirection requires pointer operand ('int' invalid)}}
   {}
 
+#pragma omp target teams map(delete \
+ : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams'}}
+  {}
+#pragma omp target teams map(release \
+ : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams'}}
+  {}
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
@@ -288,6 +288,14 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for simd map(delete \
+  : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for simd'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target teams distribute parallel for simd map(release \
+  : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for simd'}}
+  for (i = 0; i < argc; ++i)
+foo();
 
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
@@ -288,6 +288,14 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute parallel for map(delete \
+ : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target teams distribute parallel for map(release \
+ : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for'}}
+  for (i = 0; i < argc; ++i)
+foo();
 
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/test/OpenMP/target_teams_distribute_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_map_messages.cpp
@@ -288,6 +288,14 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   for (i = 0; i < argc; ++i) foo();
+#pragma omp target teams distribute map(delete \
+

[PATCH] D77150: [Analyzer] New Option for ContainerModeling: AggressiveEraseModeling

2020-04-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:647-653
 CmdLineOption
   ]>,

Szelethus wrote:
> NoQ wrote:
> > baloghadamsoftware wrote:
> > > Szelethus wrote:
> > > > Ah, okay, I see which one you refer to. We should totally make this 
> > > > non-user facing as well. 
> > > The option is not about state split! It is for choosing between the 
> > > (default) conservative approach and a more aggressive one. It is 
> > > absolutely for the user to set. Some users prefer less false positive for 
> > > the price of losing true positives. However, some other users prefer more 
> > > true positives for the price of additional false positives. This is why 
> > > we have checker options to be able to serve both groups.
> > > 
> > > This feature was explicitly requested by our users who first disabled 
> > > iterator checkers because of the too many false positives but later 
> > > re-enabled them because they run into a bug in a production system which 
> > > could have been prevented by enabling them. However, they run into 
> > > another bug that our checker did not find because of its conservative 
> > > behavior. They requested a more aggressive one but we must not do it for 
> > > everyone. The concept of the Analyzer is that we apply the conservative 
> > > approach by default and the aggressive can be enabled by analyzer and 
> > > checker options.
> > These options are unlikely to be on-by-default in vanilla clang because of 
> > having a fundamentally unfixable class of false positives associated with 
> > them. Honestly, i've never seen users who are actually ok with false 
> > positives. I've regularly seen users say that they are ok with false 
> > positives when they wanted their false negatives fixed, but it always 
> > turned out that they don't understand what they're asking for and they 
> > quickly changed their mind when they saw the result. But you guys basically 
> > vend your own tool to your own customers and bear your own responsibility 
> > and i therefore can't tell you what to do in your realm, and i'm ok with 
> > having options that allow you to disagree with my choices.
> > 
> > inb4, "//`-analyzer-config` is not user-facing!!!11//"
> >inb4, "-analyzer-config is not user-facing!!!11"
> I was starting to breath really heavy and type really fast :D
> 
> Jokes aside, I'll spill the beans, we don't have a really convenient way to 
> tweak these options through CodeChecker just yet, so for the time being, they 
> really aren't, but maybe one day.
> 
> With that said, I also agree with you regarding options that overapproximate 
> the analysis (greater code coverage with more false and true positives). User 
> facing options should be the ones where the nature of the bug itself if 
> subjective, like whether we want to check the initializedness of pointees. We 
> sure can regard them as unwanted, or we could regard them as totally fine, so 
> an option is a great compromise.
> 
> >[...] it always turned out that they don't understand what they're asking 
> >for [...]
> 
> This is why I think this shouldn't be user-facing. You need to be quite 
> knowledgeable about the analyzer, and IteratorChecker in particular to make 
> good judgement about enabling the option added in this patch. That doesn't 
> mean you shouldn't experiment with it, but I'd prefer to not expose it too 
> much.
> 
> I just don't see this feature being that desired by many if they knew the 
> costs, even if one user really wants it. We could however, in that case, say
> "Hey, there is this option you can enable that might help you hunt down more 
> bugs. It does change the actual analysis itself, and experience showed that 
> it might result in more false positives and could impact performance, so we 
> opted not to make it user-facing, but it is there, if you feel adventurous."
Granted, I might be demonizing the cons of these options too much, but the 
description doesn't help on understanding it that much either O:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77150



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


[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-04-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:26-28
+#define ASSERT_STREAMSTATE_OPENED  
\
+  assert(SS->isOpened() && 
\
+ "Create of error node failed (only way to get this state)?");

Szelethus wrote:
> NoQ wrote:
> > `assertStreamStateOpened(SS);` isn't much harder to type. Can we make it a 
> > function please?
> Mind that this is completely stripped from release builds, unlike a function 
> call. I think.
I'd be shocked if that's the case. In LLVM we have a lot of tiny functions all 
over the place and we'd better have them inlined most of the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D77150: [Analyzer] New Option for ContainerModeling: AggressiveEraseModeling

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

Please mind that my inline is NOT an objection to this patch.




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:647-653
 CmdLineOption
   ]>,

NoQ wrote:
> baloghadamsoftware wrote:
> > Szelethus wrote:
> > > Ah, okay, I see which one you refer to. We should totally make this 
> > > non-user facing as well. 
> > The option is not about state split! It is for choosing between the 
> > (default) conservative approach and a more aggressive one. It is absolutely 
> > for the user to set. Some users prefer less false positive for the price of 
> > losing true positives. However, some other users prefer more true positives 
> > for the price of additional false positives. This is why we have checker 
> > options to be able to serve both groups.
> > 
> > This feature was explicitly requested by our users who first disabled 
> > iterator checkers because of the too many false positives but later 
> > re-enabled them because they run into a bug in a production system which 
> > could have been prevented by enabling them. However, they run into another 
> > bug that our checker did not find because of its conservative behavior. 
> > They requested a more aggressive one but we must not do it for everyone. 
> > The concept of the Analyzer is that we apply the conservative approach by 
> > default and the aggressive can be enabled by analyzer and checker options.
> These options are unlikely to be on-by-default in vanilla clang because of 
> having a fundamentally unfixable class of false positives associated with 
> them. Honestly, i've never seen users who are actually ok with false 
> positives. I've regularly seen users say that they are ok with false 
> positives when they wanted their false negatives fixed, but it always turned 
> out that they don't understand what they're asking for and they quickly 
> changed their mind when they saw the result. But you guys basically vend your 
> own tool to your own customers and bear your own responsibility and i 
> therefore can't tell you what to do in your realm, and i'm ok with having 
> options that allow you to disagree with my choices.
> 
> inb4, "//`-analyzer-config` is not user-facing!!!11//"
>inb4, "-analyzer-config is not user-facing!!!11"
I was starting to breath really heavy and type really fast :D

Jokes aside, I'll spill the beans, we don't have a really convenient way to 
tweak these options through CodeChecker just yet, so for the time being, they 
really aren't, but maybe one day.

With that said, I also agree with you regarding options that overapproximate 
the analysis (greater code coverage with more false and true positives). User 
facing options should be the ones where the nature of the bug itself if 
subjective, like whether we want to check the initializedness of pointees. We 
sure can regard them as unwanted, or we could regard them as totally fine, so 
an option is a great compromise.

>[...] it always turned out that they don't understand what they're asking for 
>[...]

This is why I think this shouldn't be user-facing. You need to be quite 
knowledgeable about the analyzer, and IteratorChecker in particular to make 
good judgement about enabling the option added in this patch. That doesn't mean 
you shouldn't experiment with it, but I'd prefer to not expose it too much.

I just don't see this feature being that desired by many if they knew the 
costs, even if one user really wants it. We could however, in that case, say
"Hey, there is this option you can enable that might help you hunt down more 
bugs. It does change the actual analysis itself, and experience showed that it 
might result in more false positives and could impact performance, so we opted 
not to make it user-facing, but it is there, if you feel adventurous."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77150



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


[PATCH] D77451: Accept -x cu to indicate language is CUDA, transfer CUDA language flag to header-file arguments

2020-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

> NVCC uses different options that should be properly translated

Interested to see how this will work. Is clang itself going to support these 
args (act compatibly with nvcc, or is the idea that just tools will be?




Comment at: clang/lib/Driver/Types.cpp:298
   }
-
+  // accept -x cu to indicate CUDA
+  if (strcmp(Name, "cu") == 0) {

I think this could be clearer: "Accept "cu" as an alias for "cuda" for NVCC 
compatibility"



Comment at: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp:119
+  case types::TY_CUDA_DEVICE:
+  case types::TY_CUDA_FATBIN:
+return types::TY_CUDA:

tra wrote:
> I don't think you need CUDA_FATBIN for clangd.  If your input is .fatbin, the 
> source code has been long gone.
This establishes equivalence classes within which it makes sense to transfer 
command-line flags. So if you might have compile_commands.json entries building 
.fatbin inputs, and those flags are a sensible template for building *.cu.cc 
files, then you want fatbin here, otherwise not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77451



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


[PATCH] D77572: [clang-tidy] add new check readability-use-anyofallof

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



Comment at: clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp:26
+AST_MATCHER_P(Stmt, nextStmt, internal::Matcher, InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);
+  if (Parents.size() != 1)

Please don't use auto unless type is spelled in same statement or iterator.



Comment at: clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp:55
+void UseAnyOfAllOfCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

Must be in isLanguageVersionSupported() method.



Comment at: clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp:110
+<< Ranges;
+
+  } else if (const auto *S =

Unnecessary empty line.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:135
+
+  Finds range-based for loops that can be replaced by a call to std::any_of or
+  std::all_of.

Please enclose std::any_of and std::all_of in double back-ticks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77572



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


[clang] d33c7de - [CodeGenObjC] Fix a crash when attempting to copy a zero-sized bit-field in a non-trivial C struct

2020-04-06 Thread Erik Pilkington via cfe-commits

Author: Erik Pilkington
Date: 2020-04-06T16:04:13-04:00
New Revision: d33c7de8e11f2727ef5e325d931ae94af8619bf9

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

LOG: [CodeGenObjC] Fix a crash when attempting to copy a zero-sized bit-field 
in a non-trivial C struct

Zero sized bit-fields aren't included in the CGRecordLayout, so we shouldn't be
calling EmitLValueForField for them. rdar://60695105

Differential revision: https://reviews.llvm.org/D76782

Added: 


Modified: 
clang/include/clang/AST/NonTrivialTypeVisitor.h
clang/lib/CodeGen/CGNonTrivialStruct.cpp
clang/test/CodeGenObjC/strong-in-c-struct.m

Removed: 




diff  --git a/clang/include/clang/AST/NonTrivialTypeVisitor.h 
b/clang/include/clang/AST/NonTrivialTypeVisitor.h
index aafcedb9d10b..c95516538ad1 100644
--- a/clang/include/clang/AST/NonTrivialTypeVisitor.h
+++ b/clang/include/clang/AST/NonTrivialTypeVisitor.h
@@ -1,4 +1,4 @@
-//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ 
--*-===//
+//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp 
b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index 91303cea325f..4a2c3b290382 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -254,6 +254,10 @@ struct GenBinaryFuncName : 
CopyStructVisitor, IsMove>,
 
   void visitVolatileTrivial(QualType FT, const FieldDecl *FD,
 CharUnits CurStructOffset) {
+// Zero-length bit-fields don't need to be copied/assigned.
+if (FD && FD->isZeroLengthBitField(this->Ctx))
+  return;
+
 // Because volatile fields can be bit-fields and are individually copied,
 // their offset and width are in bits.
 uint64_t OffsetInBits =
@@ -543,6 +547,10 @@ struct GenBinaryFunc : CopyStructVisitor,
 std::array Addrs) {
 LValue DstLV, SrcLV;
 if (FD) {
+  // No need to copy zero-length bit-fields.
+  if (FD->isZeroLengthBitField(this->CGF->getContext()))
+return;
+
   QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0);
   llvm::PointerType *PtrTy = this->CGF->ConvertType(RT)->getPointerTo();
   Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset);

diff  --git a/clang/test/CodeGenObjC/strong-in-c-struct.m 
b/clang/test/CodeGenObjC/strong-in-c-struct.m
index ec212c46803d..f0227119279f 100644
--- a/clang/test/CodeGenObjC/strong-in-c-struct.m
+++ b/clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -887,4 +887,17 @@ void test_volatile_variable_reference(volatile StrongSmall 
*a) {
   func(0);
 }
 
+struct ZeroBitfield {
+  int : 0;
+  id strong;
+};
+
+
+// CHECK: define linkonce_odr hidden void @__default_constructor_8_sv0
+// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sv0
+void test_zero_bitfield() {
+  struct ZeroBitfield volatile a, b;
+  a = b;
+}
+
 #endif /* USESTRUCT */



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


[clang-tools-extra] 549e87f - [clangd] Fix bad include

2020-04-06 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-06T21:36:54+02:00
New Revision: 549e87f3d04bbae91bc7bc38609ce7073e2c8a6d

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

LOG: [clangd] Fix bad include

Added: 


Modified: 
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp 
b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
index 0be66884fd66..2a0e6b001c00 100644
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -25,8 +25,8 @@
 #include "gtest/gtest.h"
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 
 namespace clang {



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


[PATCH] D76725: [clangd] Build ASTs only with fresh preambles or after building a new preamble

2020-04-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc31367e95ce1: [clangd] Build ASTs only with fresh preambles 
or after building a new preamble (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76725

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -35,7 +35,7 @@
   Files[ImportThunk] = ThunkContents;
 
   ParseInputs Inputs;
-  auto& Argv = Inputs.CompileCommand.CommandLine;
+  auto &Argv = Inputs.CompileCommand.CommandLine;
   Argv = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
@@ -71,8 +71,7 @@
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   auto Preamble =
-  buildPreamble(testPath(Filename), *CI,
-/*OldPreamble=*/nullptr, Inputs,
+  buildPreamble(testPath(Filename), *CI, Inputs,
 /*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);
   auto AST = buildAST(testPath(Filename), std::move(CI), Diags.take(), Inputs,
   Preamble);
@@ -89,7 +88,7 @@
 if (llvm::StringRef(Code).contains(Marker) ||
 llvm::StringRef(HeaderCode).contains(Marker))
   return true;
-for (const auto& KV : this->AdditionalFiles)
+for (const auto &KV : this->AdditionalFiles)
   if (llvm::StringRef(KV.second).contains(Marker))
 return true;
 return false;
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -24,6 +24,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -283,6 +284,7 @@
 S.runWithPreamble("StaleRead", Path, TUScheduler::Stale,
   [&](Expected Pre) {
 ASSERT_TRUE(bool(Pre));
+ASSERT_TRUE(Pre->Preamble);
 EXPECT_EQ(Pre->Preamble->Version, "A");
 EXPECT_THAT(includes(Pre->Preamble),
 ElementsAre(""));
@@ -292,11 +294,13 @@
 S.runWithPreamble("ConsistentRead", Path, TUScheduler::Consistent,
   [&](Expected Pre) {
 ASSERT_TRUE(bool(Pre));
+ASSERT_TRUE(Pre->Preamble);
 EXPECT_EQ(Pre->Preamble->Version, "B");
 EXPECT_THAT(includes(Pre->Preamble),
 ElementsAre(""));
 ++CallbackCount;
   });
+S.blockUntilIdle(timeoutSeconds(10));
   }
   EXPECT_EQ(2, CallbackCount);
 }
@@ -731,11 +735,14 @@
 )cpp";
 
   ParseInputs Inputs = getInputs(Source, SourceContents);
+  std::atomic DiagCount(0);
 
   // Update the source contents, which should trigger an initial build with
   // the header file missing.
   updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [&DiagCount](std::vector Diags) {
+++DiagCount;
 EXPECT_THAT(Diags,
 ElementsAre(Field(&Diag::Message, "'foo.h' file not found"),
 Field(&Diag::Message,
@@ -751,18 +758,23 @@
   // The addition of the missing header file shouldn't trigger a rebuild since
   // we don't track missing files.
   updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [&DiagCount](std::vector Diags) {
+++DiagCount;
 ADD_FAILURE() << "Did not expect diagnostics for missing header update";
   });
 
   // Forcing the reload should should cause a rebuild which no longer has any
   // errors.
   Inputs.ForceRebuild = true;
-  updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) { EXPECT_THAT(Diags, IsEmpty()); });
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [&DiagCount](std::vector Diags) {
+++DiagCount;
+EXPECT_THAT(Diags, IsEmpty());
+  });
 
   ASSERT_TRU

[PATCH] D77571: Add ClangTidy check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.

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



Comment at: 
clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:35
+
+constexpr StringRef WeakText = "__weak";
+constexpr StringRef StrongText = "__strong";

Please use static instead of anonymous namespace for variable.



Comment at: 
clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:50
+
+llvm::Optional replacementForOwnershipString(StringRef Text,
+CharSourceRange Range,

Please use static instead of anonymous namespace for functions.



Comment at: 
clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:83
+  StringRef VarDeclText = Lexer::getSourceText(Range, SM, LangOpts);
+  if (auto Hint = replacementForOwnershipString(VarDeclText, Range, WeakText)) 
{
+return Hint;

Please don't use auto unless type is spelled in same statement or iterator. 
Please elide braces. Same in other places.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:135
+
+  Finds calls to NSInvocation methods under ARC that don't have proper
+  argument object lifetimes.

Please enclose NSInvocation in double back-ticks.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst:6
+
+Finds calls to NSInvocation methods under ARC that don't have proper
+argument object lifetimes. When passing Objective-C objects as parameters

Please enclose NSInvocation in double back-ticks. Same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77571



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


[PATCH] D76304: [clangd] Update TUStatus api to accommodate preamble thread

2020-04-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b85032c95be: [clangd] Update TUStatus api to accommodate 
preamble thread (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76304

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -24,6 +24,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -40,13 +41,14 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-MATCHER_P2(TUState, State, ActionName, "") {
-  if (arg.Action.S != State) {
-*result_listener << "state is " << arg.Action.S;
+MATCHER_P2(TUState, PreambleActivity, ASTActivity, "") {
+  if (arg.PreambleActivity != PreambleActivity) {
+*result_listener << "preamblestate is "
+ << static_cast(arg.PreambleActivity);
 return false;
   }
-  if (arg.Action.Name != ActionName) {
-*result_listener << "name is " << arg.Action.Name;
+  if (arg.ASTActivity.K != ASTActivity) {
+*result_listener << "aststate is " << arg.ASTActivity.K;
 return false;
   }
   return true;
@@ -732,14 +734,13 @@
 
   // Update the source contents, which should trigger an initial build with
   // the header file missing.
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-EXPECT_THAT(
-Diags,
-ElementsAre(
-Field(&Diag::Message, "'foo.h' file not found"),
-Field(&Diag::Message, "use of undeclared identifier 'a'")));
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+EXPECT_THAT(Diags,
+ElementsAre(Field(&Diag::Message, "'foo.h' file not found"),
+Field(&Diag::Message,
+  "use of undeclared identifier 'a'")));
+  });
 
   // Add the header file. We need to recreate the inputs since we changed a
   // file from underneath the test FS.
@@ -749,18 +750,17 @@
 
   // The addition of the missing header file shouldn't trigger a rebuild since
   // we don't track missing files.
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-ADD_FAILURE() << "Did not expect diagnostics for missing header update";
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+ADD_FAILURE() << "Did not expect diagnostics for missing header update";
+  });
 
   // Forcing the reload should should cause a rebuild which no longer has any
   // errors.
   Inputs.ForceRebuild = true;
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-EXPECT_THAT(Diags, IsEmpty());
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) { EXPECT_THAT(Diags, IsEmpty()); });
 
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 }
@@ -848,14 +848,21 @@
 
   EXPECT_THAT(CaptureTUStatus.allStatus(),
   ElementsAre(
-  // Statuses of "Update" action.
-  TUState(TUAction::RunningAction, "Update (1)"),
-  TUState(TUAction::BuildingPreamble, "Update (1)"),
-  TUState(TUAction::BuildingFile, "Update (1)"),
-
-  // Statuses of "Definitions" action
-  TUState(TUAction::RunningAction, "Definitions"),
-  TUState(TUAction::Idle, /*No action*/ "")));
+  // Everything starts with ASTWorker starting to execute an
+  // update
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // We build the preamble
+  TUState(PreambleAction::Building, ASTAction::RunningAction),
+  // Preamble worker goes idle
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // We start building the ast
+  TUState(PreambleAction::Idle, ASTAction::Building),
+  // Built finished succesffully
+  TUState(PreambleAction::Idle, ASTAction::Building),
+  // Rnning go to def
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // both workers go idle
+  TUState(PreambleAction::Idle, ASTAction::Idle)));
 }
 
 TEST_F(TUSchedulerTests, CommandLineErrors) {
@@ -868,8 +875,7 @@
   TUScheduler S(C

[PATCH] D77503: [ASTMatchers] Fixed CastKind being parsed incorrectly for dynamic matchers

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

- Added support for giving suggestions on invalid inputs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77503

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


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -170,7 +170,7 @@
 private:
   static Optional getCastKind(llvm::StringRef AttrKind) {
 return llvm::StringSwitch>(AttrKind)
-#define CAST_OPERATION(Name) .Case( #Name, CK_##Name)
+#define CAST_OPERATION(Name) .Case("CK_" #Name, CK_##Name)
 #include "clang/AST/OperationKinds.def"
 .Default(llvm::None);
   }
Index: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
@@ -67,11 +67,12 @@
 clang::ast_matchers::dynamic::internal::ArgTypeTraits<
 clang::CastKind>::getBestGuess(const VariantValue &Value) {
   static constexpr llvm::StringRef Allowed[] = {
-#define CAST_OPERATION(Name) #Name,
+#define CAST_OPERATION(Name) "CK_" #Name,
 #include "clang/AST/OperationKinds.def"
   };
   if (Value.isString())
-return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed));
+return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
+  "CK_");
   return llvm::None;
 }
 


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -170,7 +170,7 @@
 private:
   static Optional getCastKind(llvm::StringRef AttrKind) {
 return llvm::StringSwitch>(AttrKind)
-#define CAST_OPERATION(Name) .Case( #Name, CK_##Name)
+#define CAST_OPERATION(Name) .Case("CK_" #Name, CK_##Name)
 #include "clang/AST/OperationKinds.def"
 .Default(llvm::None);
   }
Index: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
@@ -67,11 +67,12 @@
 clang::ast_matchers::dynamic::internal::ArgTypeTraits<
 clang::CastKind>::getBestGuess(const VariantValue &Value) {
   static constexpr llvm::StringRef Allowed[] = {
-#define CAST_OPERATION(Name) #Name,
+#define CAST_OPERATION(Name) "CK_" #Name,
 #include "clang/AST/OperationKinds.def"
   };
   if (Value.isString())
-return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed));
+return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
+  "CK_");
   return llvm::None;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76125: [clangd] Decouple preambleworker from astworker, NFCI

2020-04-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG276a95bdf27c: [clangd] Decouple preambleworker from 
astworker, NFCI (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76125

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp

Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -49,13 +49,16 @@
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
 #include "ParsedAST.h"
+#include "Path.h"
 #include "Preamble.h"
+#include "Threading.h"
 #include "Trace.h"
 #include "index/CanonicalIncludes.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Threading.h"
@@ -149,6 +152,177 @@
 };
 
 namespace {
+/// Responsible for building and providing access to the preamble of a TU.
+/// Whenever the thread is idle and the preamble is outdated, it starts to build
+/// a fresh preamble from the latest inputs. If RunSync is true, preambles are
+/// built synchronously in update() instead.
+class PreambleThread {
+public:
+  PreambleThread(llvm::StringRef FileName, ParsingCallbacks &Callbacks,
+ bool StorePreambleInMemory, bool RunSync)
+  : FileName(FileName), Callbacks(Callbacks),
+StoreInMemory(StorePreambleInMemory), RunSync(RunSync) {}
+
+  size_t getUsedBytes() const {
+auto Preamble = latest();
+return Preamble ? Preamble->Preamble.getSize() : 0;
+  }
+
+  /// It isn't guaranteed that each requested version will be built. If there
+  /// are multiple update requests while building a preamble, only the last one
+  /// will be built.
+  void update(CompilerInvocation *CI, ParseInputs PI) {
+// If compiler invocation was broken, just fail out early.
+if (!CI) {
+  TUStatus::BuildDetails Details;
+  Details.BuildFailed = true;
+  std::string TaskName = llvm::formatv("Update ({0})", PI.Version);
+  emitTUStatus({TUAction::BuildingPreamble, std::move(TaskName)}, &Details);
+  // Make sure anyone waiting for the preamble gets notified it could not be
+  // built.
+  BuiltFirst.notify();
+  return;
+}
+// Make possibly expensive copy while not holding the lock.
+Request Req = {std::make_unique(*CI), std::move(PI)};
+if (RunSync) {
+  build(std::move(Req));
+  return;
+}
+{
+  std::lock_guard Lock(Mutex);
+  assert(!Done && "Build request to PreambleWorker after stop");
+  NextReq = std::move(Req);
+}
+// Let the worker thread know there's a request, notify_one is safe as there
+// should be a single worker thread waiting on it.
+ReqCV.notify_all();
+  }
+
+  /// Blocks until at least a single request has been processed. Note that it
+  /// will unblock even after an unsuccessful build.
+  void waitForFirst() const { BuiltFirst.wait(); }
+
+  /// Returns the latest built preamble, might be null if no preamble has been
+  /// built or latest attempt resulted in a failure.
+  std::shared_ptr latest() const {
+std::lock_guard Lock(Mutex);
+return LatestBuild;
+  }
+
+  void run() {
+dlog("Starting preamble worker for {0}", FileName);
+while (true) {
+  {
+std::unique_lock Lock(Mutex);
+assert(!CurrentReq && "Already processing a request?");
+// Wait until stop is called or there is a request.
+ReqCV.wait(Lock, [this] { return NextReq || Done; });
+if (Done)
+  break;
+CurrentReq = std::move(*NextReq);
+NextReq.reset();
+  }
+  // Build the preamble and let the waiters know about it.
+  build(std::move(*CurrentReq));
+  {
+std::lock_guard Lock(Mutex);
+CurrentReq.reset();
+  }
+  ReqCV.notify_all();
+}
+// We are no longer going to build any preambles, let the waiters know that.
+BuiltFirst.notify();
+dlog("Preamble worker for {0} finished", FileName);
+  }
+
+  /// Signals the run loop to exit.
+  void stop() {
+dlog("Stopping preamble worker for {0}", FileName);
+{
+  std::lock_guard Lock(Mutex);
+  Done = true;
+}
+// Let the worker thread know that it should stop.
+ReqCV.notify_all();
+  }
+
+  bool blockUntilIdle(Deadline Timeout) const {
+std::unique_lock Lock(Mutex);
+return wait(Lock, ReqCV, Timeout, [&] { return !NextReq && !CurrentReq; });
+  }
+
+private:
+  /// Holds inputs required for building a preamble. CI is guaranteed to be
+  /// non-null.
+  struct Request {
+std::unique_ptr CI;
+Pars

  1   2   3   4   >