[clang] a5040d5 - [SytemZ] Disable vector ABI when using option -march=arch[8|9|10]

2020-02-10 Thread Kai Nacke via cfe-commits

Author: Kai Nacke
Date: 2020-02-10T04:14:05-05:00
New Revision: a5040d5ec97ecac9940275eb59175f0bdbd26ab4

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

LOG: [SytemZ] Disable vector ABI when using option -march=arch[8|9|10]

When specifying -march=arch[8|9|10], those CPU types do NOT support
the vector extension. In this case the vector ABI must be disabled.
The generated data layout should NOT contain 64-v128.

Reviewers: uweigand

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

Added: 


Modified: 
clang/test/CodeGen/target-data.c
llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp

Removed: 




diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index 2c2243c03a6a..e49f8453e360 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -193,6 +193,18 @@
 
 // RUN: %clang_cc1 -triple s390x-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch8 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z196 -o - -emit-llvm %s | 
\
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch9 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu zEC12 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch10 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
 // RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -target-feature 
+soft-float -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ
 // SYSTEMZ: target datalayout = 
"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"

diff  --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp 
b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
index 0f319baff5a6..8a63ffe9e907 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -42,7 +42,8 @@ static bool UsesVectorABI(StringRef CPU, StringRef FS) {
   bool VectorABI = true;
   bool SoftFloat = false;
   if (CPU.empty() || CPU == "generic" ||
-  CPU == "z10" || CPU == "z196" || CPU == "zEC12")
+  CPU == "z10" || CPU == "z196" || CPU == "zEC12" ||
+  CPU == "arch8" || CPU == "arch9" || CPU == "arch10")
 VectorABI = false;
 
   SmallVector Features;



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


[PATCH] D74146: [SytemZ] Disable vector ABI when using option -march=arch[8|9|10]

2020-02-10 Thread Kai Nacke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5040d5ec97e: [SytemZ] Disable vector ABI when using option 
-march=arch[8|9|10] (authored by Kai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74146

Files:
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp


Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
===
--- llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -42,7 +42,8 @@
   bool VectorABI = true;
   bool SoftFloat = false;
   if (CPU.empty() || CPU == "generic" ||
-  CPU == "z10" || CPU == "z196" || CPU == "zEC12")
+  CPU == "z10" || CPU == "z196" || CPU == "zEC12" ||
+  CPU == "arch8" || CPU == "arch9" || CPU == "arch10")
 VectorABI = false;
 
   SmallVector Features;
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -193,6 +193,18 @@
 
 // RUN: %clang_cc1 -triple s390x-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch8 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z196 -o - -emit-llvm %s | 
\
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch9 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu zEC12 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch10 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
 // RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -target-feature 
+soft-float -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ
 // SYSTEMZ: target datalayout = 
"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"


Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
===
--- llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -42,7 +42,8 @@
   bool VectorABI = true;
   bool SoftFloat = false;
   if (CPU.empty() || CPU == "generic" ||
-  CPU == "z10" || CPU == "z196" || CPU == "zEC12")
+  CPU == "z10" || CPU == "z196" || CPU == "zEC12" ||
+  CPU == "arch8" || CPU == "arch9" || CPU == "arch10")
 VectorABI = false;
 
   SmallVector Features;
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -193,6 +193,18 @@
 
 // RUN: %clang_cc1 -triple s390x-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch8 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z196 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch9 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu zEC12 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ
 // RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -target-feature +soft-float -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ
 // SYSTEMZ: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Looks pretty good now, thanks! Test needs to be more precise (doesn't actually 
test the behavior at present, I think).




Comment at: clang-tools-extra/clangd/Compiler.h:41
   bool SuggestMissingIncludes = false;
+  bool ForceRebuild = false;
 };

Hmm, on thinking further I do think this belongs in ParseInputs next to 
Contents or CompileCommands, as these things are things that affect the parse 
but *don't* invalidate caches.



Comment at: clang-tools-extra/clangd/Compiler.h:41
   bool SuggestMissingIncludes = false;
+  bool ForceRebuild = false;
 };

sammccall wrote:
> Hmm, on thinking further I do think this belongs in ParseInputs next to 
> Contents or CompileCommands, as these things are things that affect the parse 
> but *don't* invalidate caches.
this is a good place for a comment explaining what this does specifically 
(prevents reuse of cached preamble/ast)



Comment at: clang-tools-extra/clangd/Protocol.h:660
+  /// This is a clangd extension.
+  bool forceRebuild;
 };

`= false`, and remove "disabled by default" from comment



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:619
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());

This test doesn't actually verify that the preamble was rebuilt, just that the 
AST was.
Checking the actual diagnostics would do that.



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:631
+  // Return value indicates if the updated callback was received.
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild) -> bool {
+std::atomic Updated(false);

I don't think this abstraction is useful since you just have 3 calls and two of 
them need the actual diagnostics.

You could have diag callbacks inline easily enough:

```
vector> diags;
update(..., [] { diags.push_back(...) })
update(..., [] { ADD_FAILURE(...) })
update(..., [] { diags.push_back(...) })
blockUntilIdle();
EXPECT_THAT(diags, ElementsAre(
  /* First */ElementsAre(...missing header...),
  /* Last */IsEmpty());
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-10 Thread George Rimar via Phabricator via cfe-commits
grimar added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.h:120
 
+  std::string BasicBlockSections;
+

MaskRay wrote:
> Comment its allowed values ("all", "labels", "none")
I'd suggest to rewrite it somehow. This set of values did not help me to 
understand what is this field for. The comment could probably be (for example): 
"This is a field for Allowed values are:"



Comment at: clang/lib/CodeGen/BackendUtil.cpp:444
+  while ((std::getline(fin, line)).good()) {
+StringRef S(line);
+// Lines beginning with @, # are not useful here.

Something is wrong with the namings (I am not an expert in lib/CodeGen), but 
you are mixing lower vs upper case styles: "fin", "line", "S", "R". Seems the 
code around prefers upper case.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:450
+  break;
+if (S.consume_front("!")) {
+  if (fi != Options.BBSectionsList.end())

```
if (S.empty() || S[0] == '@' || S[0] == '#')
  continue;
if (!S.consume_front("!") || S.empty())
  break;
if (S.consume_front("!")) {
```

It is looks a bit strange. See: you are testing `S.empty()` condition twice and 
you are checking `S.consume_front("!")` twice.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:461
+  fi = R.first;
+  assert(R.second);
+}

It seems this assert can be triggered for a wrong user input?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:964
+<< Opts.BBSections;
+  }
+

Doesn't seem you need "{}" around this lines. (Its a single call and looks 
inconsistent with the code around).
(The same for the change above)


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

https://reviews.llvm.org/D68049



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


[PATCH] D69043: [RFC] Adding time-trace to LLD?

2020-02-10 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop abandoned this revision.
russell.gallop added a comment.

This was submitted as the sequence of patches:
https://reviews.llvm.org/D70904 - Tidying up in TimeProfiler.cpp
https://reviews.llvm.org/D70950 - Add ProcName to TimeTraceProfiler
https://reviews.llvm.org/D71059 - [LLD][ELF] Add time-trace to ELF LLD (1/2) 
(multi-thread support in TimeProfiler)
https://reviews.llvm.org/D71060 - [LLD][ELF] Add time-trace to ELF LLD (2/2) 
(Add time trace to LLD)

Closing this review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


[clang] 76f888d - Fix handling of destructor names that name typedefs.

2020-02-10 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-10T02:21:01-08:00
New Revision: 76f888d0a5324f4c6ae89cac61077cca4299b159

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

LOG: Fix handling of destructor names that name typedefs.

1) Fix a regression in llvmorg-11-init-2485-g0e3a4877840 that would
reject some cases where a class name is shadowed by a typedef-name
causing a destructor declaration to be rejected. Prefer a tag type over
a typedef in destructor name lookup.

2) Convert the "type in destructor declaration is a typedef" error to an
error-by-default ExtWarn to allow codebases to turn it off. GCC and MSVC
do not enforce this rule.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaCXX/destructor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 82861f0d5d72..5cfd32c57c61 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1909,8 +1909,9 @@ def err_destructor_return_type : Error<"destructor cannot 
have a return type">;
 def err_destructor_redeclared : Error<"destructor cannot be redeclared">;
 def err_destructor_with_params : Error<"destructor cannot have any 
parameters">;
 def err_destructor_variadic : Error<"destructor cannot be variadic">;
-def err_destructor_typedef_name : Error<
-  "destructor cannot be declared using a %select{typedef|type alias}1 %0 of 
the class name">;
+def ext_destructor_typedef_name : ExtWarn<
+  "destructor cannot be declared using a %select{typedef|type alias}1 %0 "
+  "of the class name">, DefaultError, InGroup>;
 def err_undeclared_destructor_name : Error<
   "undeclared identifier %0 in destructor name">;
 def err_destructor_name : Error<

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 99cfd2411ab7..3e6856048725 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3479,6 +3479,9 @@ class Sema final {
 /// operator overloading. This lookup is similar to ordinary name
 /// lookup, but will ignore any declarations that are class members.
 LookupOperatorName,
+/// Look up a name following ~ in a destructor name. This is an ordinary
+/// lookup, but prefers tags to typedefs.
+LookupDestructorName,
 /// Look up of a name that precedes the '::' scope resolution
 /// operator in C++. This lookup completely ignores operator, object,
 /// function, and enumerator names (C++ [basic.lookup.qual]p1).

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a1f7806877c5..7331c3369744 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9986,12 +9986,12 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, 
QualType R,
   //   declaration.
   QualType DeclaratorType = GetTypeFromParser(D.getName().DestructorName);
   if (const TypedefType *TT = DeclaratorType->getAs())
-Diag(D.getIdentifierLoc(), diag::err_destructor_typedef_name)
+Diag(D.getIdentifierLoc(), diag::ext_destructor_typedef_name)
   << DeclaratorType << isa(TT->getDecl());
   else if (const TemplateSpecializationType *TST =
  DeclaratorType->getAs())
 if (TST->isTypeAlias())
-  Diag(D.getIdentifierLoc(), diag::err_destructor_typedef_name)
+  Diag(D.getIdentifierLoc(), diag::ext_destructor_typedef_name)
 << DeclaratorType << 1;
 
   // C++ [class.dtor]p2:

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index a39b0b1f7766..8857234c 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -201,11 +201,9 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
 
 if (TypeDecl *Type = Found.getAsSingle()) {
   QualType T = Context.getTypeDeclType(Type);
-  MarkAnyDeclReferenced(Type->getLocation(), Type, /*OdrUse=*/false);
-
   if (SearchType.isNull() || SearchType->isDependentType() ||
   Context.hasSameUnqualifiedType(T, SearchType)) {
-// We found our type!
+MarkAnyDeclReferenced(Type->getLocation(), Type, /*OdrUse=*/false);
 return CreateParsedType(T,
 Context.getTrivialTypeSourceInfo(T, NameLoc));
   }
@@ -222,7 +220,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
 
 IsDependent |= SearchType->isDependentType();
 
-LookupResult Found(*this, &II, NameLoc, LookupOrdinaryName);
+LookupResult Found(*this, &II, NameLoc, LookupDestructorName);
 DeclContext *LookupCtx = computeDec

Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.

2020-02-10 Thread Richard Smith via cfe-commits
On Sun, 9 Feb 2020 at 11:33, Richard Smith  wrote:

> On Sun, 9 Feb 2020, 01:09 Nico Weber via cfe-commits, <
> cfe-commits@lists.llvm.org> wrote:
>
>> Our code fails to build with "destructor cannot be declared using a type
>> alias" after this, without us changing language mode or anything.
>>
>> Is that intended?
>>
>
> Can you provide a sketch of what you were doing? There are certainly cases
> where I'd expect that now --  where you find a typedef through in "bad"
> (extension) place and find a non-typedef elsewhere.
>

I found that we were rejecting potentially-valid code in some cases:

struct X { ~X(); };
using X = X;
::X::~X() {} // rejected because we find the typedef-name not the class-name

Fixed in llvmorg-11-init-2613-g76f888d0a53.


> Can this be a default-error-mapped warning so that projects have some
>> incremental transition path for this?
>>
>
> That seems reasonable, yes.
>

Now accepted as an error-by-default extension (-Wno-dtor-typedef to disable
the error), in the same commit. (This doesn't have a fixit hint yet,
though.)


> On Fri, Feb 7, 2020 at 9:41 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Richard Smith
>>> Date: 2020-02-07T18:40:41-08:00
>>> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff
>>>
>>> LOG: PR12350: Handle remaining cases permitted by CWG DR 244.
>>>
>>> Also add extension warnings for the cases that are disallowed by the
>>> current rules for destructor name lookup, refactor and simplify the
>>> lookup code, and improve the diagnostic quality when lookup fails.
>>>
>>> The special case we previously supported for converting
>>> p->N::S::~S() from naming a class template into naming a
>>> specialization thereof is subsumed by a more general rule here (which is
>>> also consistent with Clang's historical behavior and that of other
>>> compilers): if we can't find a suitable S in N, also look in N::S.
>>>
>>> The extension warnings are off by default, except for a warning when
>>> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
>>> That seems sufficiently heinous to warn on by default, especially since
>>> we can't support it for a dependent nested-name-specifier.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/include/clang/Basic/DiagnosticGroups.td
>>> clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> clang/lib/AST/NestedNameSpecifier.cpp
>>> clang/lib/Sema/DeclSpec.cpp
>>> clang/lib/Sema/SemaExprCXX.cpp
>>> clang/test/CXX/class/class.mem/p13.cpp
>>> clang/test/CXX/drs/dr2xx.cpp
>>> clang/test/CXX/drs/dr3xx.cpp
>>> clang/test/FixIt/fixit.cpp
>>> clang/test/Parser/cxx-decl.cpp
>>> clang/test/SemaCXX/constructor.cpp
>>> clang/test/SemaCXX/destructor.cpp
>>> clang/test/SemaCXX/pseudo-destructors.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
>>> b/clang/include/clang/Basic/DiagnosticGroups.td
>>> index a2bc29986a07..8c54723cdbab 100644
>>> --- a/clang/include/clang/Basic/DiagnosticGroups.td
>>> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
>>> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">;
>>>  // designators (including the warning controlled by -Wc++2a-designator).
>>>  def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
>>>  def GNUDesignator : DiagGroup<"gnu-designator">;
>>> +def DtorName : DiagGroup<"dtor-name">;
>>>
>>>  def DynamicExceptionSpec
>>>  : DiagGroup<"dynamic-exception-spec",
>>> [DeprecatedDynamicExceptionSpec]>;
>>>
>>> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> index 9de60d3a8d27..82861f0d5d72 100644
>>> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> @@ -1911,17 +1911,33 @@ def err_destructor_with_params :
>>> Error<"destructor cannot have any parameters">;
>>>  def err_destructor_variadic : Error<"destructor cannot be variadic">;
>>>  def err_destructor_typedef_name : Error<
>>>"destructor cannot be declared using a %select{typedef|type alias}1
>>> %0 of the class name">;
>>> +def err_undeclared_destructor_name : Error<
>>> +  "undeclared identifier %0 in destructor name">;
>>>  def err_destructor_name : Error<
>>>"expected the class name after '~' to name the enclosing class">;
>>> -def err_destructor_class_name : Error<
>>> -  "expected the class name after '~' to name a destructor">;
>>> -def err_ident_in_dtor_not_a_type : Error<
>>> +def err_destructor_name_nontype : Error<
>>> +  "identifier %0 after '~' in destructor name does not name a type">;
>>> +def err_dest

[PATCH] D72867: [clangd] Support renaming designated initializers

2020-02-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:639
+void VisitDesignatedInitExpr(const DesignatedInitExpr *DIE) {
+  for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
+if (!D.isFieldDesignator())

kbobyrev wrote:
> sammccall wrote:
> > you're breaking after the first one - I think you'd like to report every 
> > one instead?
> > You'd test this with a DIE like `{ .Foo.Bar = 2 }` where `Foo` has struct 
> > type.
> > 
> > (targetDecl only reports the *last* one, because the Designator can't be a 
> > DynTypedNode, but we don't care about that here)
> Sorry, I tried to understand this comment but I wasn't able to in the end. 
> Could you please elaborate on this?
> 
> I'm adding the test cases that I originally thought you meant, but those work 
> correctly so I assume I didn't understand what case you were referring to.
Sorry, I'm not sure what I was thinking here - code LG.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72867



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


[PATCH] D73359: [analyzer]StreamChecker refactoring (NFC).

2020-02-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 243488.
balazske added a comment.

Rebase and not using "ProgramStateRef &".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73359

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

Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -94,15 +94,15 @@
   void evalFreopen(const CallEvent &Call, CheckerContext &C) const;
   void evalFclose(const CallEvent &Call, CheckerContext &C) const;
   void evalFseek(const CallEvent &Call, CheckerContext &C) const;
-
   void checkArgNullStream(const CallEvent &Call, CheckerContext &C,
   unsigned ArgI) const;
-  bool checkNullStream(SVal SV, CheckerContext &C,
-   ProgramStateRef &State) const;
-  void checkFseekWhence(SVal SV, CheckerContext &C,
-ProgramStateRef &State) const;
-  bool checkDoubleClose(const CallEvent &Call, CheckerContext &C,
-ProgramStateRef &State) const;
+
+  ProgramStateRef checkNullStream(SVal SV, CheckerContext &C,
+  ProgramStateRef State) const;
+  ProgramStateRef checkFseekWhence(SVal SV, CheckerContext &C,
+   ProgramStateRef State) const;
+  ProgramStateRef checkDoubleClose(const CallEvent &Call, CheckerContext &C,
+   ProgramStateRef State) const;
 };
 
 } // end anonymous namespace
@@ -135,31 +135,32 @@
 }
 
 void StreamChecker::evalFopen(const CallEvent &Call, CheckerContext &C) const {
-  ProgramStateRef state = C.getState();
-  SValBuilder &svalBuilder = C.getSValBuilder();
+  ProgramStateRef State = C.getState();
+  SValBuilder &SVB = C.getSValBuilder();
   const LocationContext *LCtx = C.getPredecessor()->getLocationContext();
+
   auto *CE = dyn_cast_or_null(Call.getOriginExpr());
   if (!CE)
 return;
 
   DefinedSVal RetVal =
-  svalBuilder.conjureSymbolVal(nullptr, CE, LCtx, C.blockCount())
+  SVB.conjureSymbolVal(nullptr, CE, LCtx, C.blockCount())
   .castAs();
-  state = state->BindExpr(CE, C.getLocationContext(), RetVal);
+  SymbolRef RetSym = RetVal.getAsSymbol();
+  assert(RetSym && "RetVal must be a symbol here.");
+
+  State = State->BindExpr(CE, C.getLocationContext(), RetVal);
 
-  ConstraintManager &CM = C.getConstraintManager();
   // Bifurcate the state into two: one with a valid FILE* pointer, the other
   // with a NULL.
-  ProgramStateRef stateNotNull, stateNull;
-  std::tie(stateNotNull, stateNull) = CM.assumeDual(state, RetVal);
+  ProgramStateRef StateNotNull, StateNull;
+  std::tie(StateNotNull, StateNull) = C.getConstraintManager().assumeDual(State, RetVal);
 
-  SymbolRef Sym = RetVal.getAsSymbol();
-  assert(Sym && "RetVal must be a symbol here.");
-  stateNotNull = stateNotNull->set(Sym, StreamState::getOpened());
-  stateNull = stateNull->set(Sym, StreamState::getOpenFailed());
+  StateNotNull = StateNotNull->set(RetSym, StreamState::getOpened());
+  StateNull = StateNull->set(RetSym, StreamState::getOpenFailed());
 
-  C.addTransition(stateNotNull);
-  C.addTransition(stateNull);
+  C.addTransition(StateNotNull);
+  C.addTransition(StateNull);
 }
 
 void StreamChecker::evalFreopen(const CallEvent &Call,
@@ -175,9 +176,8 @@
 return;
   // Do not allow NULL as passed stream pointer.
   // This is not specified in the man page but may crash on some system.
-  checkNullStream(*StreamVal, C, State);
-  // Check if error was generated.
-  if (C.isDifferent())
+  State = checkNullStream(*StreamVal, C, State);
+  if (!State)
 return;
 
   SymbolRef StreamSym = StreamVal->getAsSymbol();
@@ -207,7 +207,8 @@
 
 void StreamChecker::evalFclose(const CallEvent &Call, CheckerContext &C) const {
   ProgramStateRef State = C.getState();
-  if (checkDoubleClose(Call, C, State))
+  State = checkDoubleClose(Call, C, State);
+  if (State)
 C.addTransition(State);
 }
 
@@ -218,32 +219,31 @@
 
   ProgramStateRef State = C.getState();
 
-  bool StateChanged = checkNullStream(Call.getArgSVal(0), C, State);
-  // Check if error was generated.
-  if (C.isDifferent())
+  State = checkNullStream(Call.getArgSVal(0), C, State);
+  if (!State)
 return;
 
-  // Check the legality of the 'whence' argument of 'fseek'.
-  checkFseekWhence(State->getSVal(AE2, C.getLocationContext()), C, State);
-
-  if (!C.isDifferent() && StateChanged)
-C.addTransition(State);
+  State =
+  checkFseekWhence(State->getSVal(AE2, C.getLocationContext()), C, State);
+  if (!State)
+return;
 
-  return;
+  C.addTransition(State);
 }
 
 void StreamChecker::checkArgNullStream(const CallEvent &Call, CheckerContext &C,
unsigned ArgI) const {
   ProgramStateRef State = C.getState

[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2020-02-10 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet abandoned this revision.
gchatelet added a comment.

This has been implemented in the following patches:

- https://reviews.llvm.org/D67923
- https://reviews.llvm.org/D74162
- https://reviews.llvm.org/D73543
- https://reviews.llvm.org/D71710


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D73719: [AArch64][SVE] Add SVE2 intrinsics for widening DSP operations

2020-02-10 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e1d7bb6798d: [AArch64][SVE] Add SVE2 intrinsics for 
widening DSP operations (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D73719?vs=241482&id=243489#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73719

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
@@ -0,0 +1,783 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SABALB
+;
+
+define  @sabalb_b( %a,  %b,  %c) {
+; CHECK-LABEL: sabalb_b:
+; CHECK: sabalb z0.h, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalb.nxv8i16( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalb_h( %a,  %b,  %c) {
+; CHECK-LABEL: sabalb_h:
+; CHECK: sabalb z0.s, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalb.nxv4i32( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalb_s( %a,  %b,  %c) {
+; CHECK-LABEL: sabalb_s:
+; CHECK: sabalb z0.d, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalb.nxv2i64( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+;
+; SABALT
+;
+
+define  @sabalt_b( %a,  %b,  %c) {
+; CHECK-LABEL: sabalt_b:
+; CHECK: sabalt z0.h, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalt.nxv8i16( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalt_h( %a,  %b,  %c) {
+; CHECK-LABEL: sabalt_h:
+; CHECK: sabalt z0.s, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalt.nxv4i32( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalt_s( %a,  %b,  %c) {
+; CHECK-LABEL: sabalt_s:
+; CHECK: sabalt z0.d, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalt.nxv2i64( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+;
+; SABDLB
+;
+
+define  @sabdlb_b( %a,  %b) {
+; CHECK-LABEL: sabdlb_b:
+; CHECK: sabdlb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlb_h( %a,  %b) {
+; CHECK-LABEL: sabdlb_h:
+; CHECK: sabdlb z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlb.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlb_s( %a,  %b) {
+; CHECK-LABEL: sabdlb_s:
+; CHECK: sabdlb z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlb.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SABDLT
+;
+
+define  @sabdlt_b( %a,  %b) {
+; CHECK-LABEL: sabdlt_b:
+; CHECK: sabdlt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlt_h( %a,  %b) {
+; CHECK-LABEL: sabdlt_h:
+; CHECK: sabdlt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlt_s( %a,  %b) {
+; CHECK-LABEL: sabdlt_s:
+; CHECK: sabdlt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SADDLB
+;
+
+define  @saddlb_b( %a,  %b) {
+; CHECK-LABEL: saddlb_b:
+; CHECK: saddlb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlb_h( %a,  %b) {
+; CHECK-LABEL: saddlb_h:
+; CHECK: saddlb z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlb.nxv4i32( %a,
+

[PATCH] D74305: [clangd] Expose completion range in code completion results (C++ API)

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

Informative only, useful for positioning UI, interacting with other sources of
completion etc. As requested by an embedder of clangd.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74305

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2134,6 +2134,7 @@
"some text [[scope::more::]][[identif]]^ier",
"some text [[scope::]][[mor]]^e::identifier",
"weird case foo::[[::bar::]][[baz]]^",
+   "/* [[]][[]]^ */",
}) {
 Annotations F(Case);
 auto Offset = cantFail(positionToOffset(F.code(), F.point()));
@@ -2675,6 +2676,28 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, CompletionRange) {
+  const char* WithRange = "auto x = [[abc]]^";
+  auto Completions = completions(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+  Completions = completionsNoCompile(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+
+  const char* EmptyRange = "auto x = [[]]^";
+  Completions = completions(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+  Completions = completionsNoCompile(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+
+  // Sema doesn't trigger at all here, while the no-sema completion runs
+  // heuristics as normal and reports a range. It'd be nice to be consistent.
+  const char* NoCompletion = "/* [[]]^ */";
+  Completions = completions(NoCompletion);
+  EXPECT_EQ(Completions.CompletionRange, llvm::None);
+  Completions = completionsNoCompile(NoCompletion);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(NoCompletion).range());
+}
+
 TEST(NoCompileCompletionTest, Basic) {
   auto Results = completionsNoCompile(R"cpp(
 void func() {
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -216,6 +216,11 @@
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // The text that is being directly completed.
+  // Example: foo.pb^ -> foo.push_back()
+  //  ~~
+  // Typically matches the textEdit.range of Completions, but not guaranteed 
to.
+  llvm::Optional CompletionRange;
   // Usually the source will be parsed with a real C++ parser.
   // But heuristics may be used instead if e.g. the preamble is not ready.
   bool RanParser = true;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1473,6 +1473,7 @@
 }
 Output.HasMore = Incomplete;
 Output.Context = CCContextKind;
+Output.CompletionRange = ReplacedRange;
 return Output;
   }
 


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2134,6 +2134,7 @@
"some text [[scope::more::]][[identif]]^ier",
"some text [[scope::]][[mor]]^e::identifier",
"weird case foo::[[::bar::]][[baz]]^",
+   "/* [[]][[]]^ */",
}) {
 Annotations F(Case);
 auto Offset = cantFail(positionToOffset(F.code(), F.point()));
@@ -2675,6 +2676,28 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, CompletionRange) {
+  const char* WithRange = "auto x = [[abc]]^";
+  auto Completions = completions(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+  Completions = completionsNoCompile(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+
+  const char* EmptyRange = "auto x = [[]]^";
+  Completions = completions(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+  Completions = completionsNoCompile(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+
+  // Sema doesn't trigger at all here, while the no-sema completion runs
+  // heuristics as normal and reports a range. It'd be nice to be consistent.
+  const char* NoComple

[PATCH] D72035: [analyzer][NFC] Use CallEvent checker callback in GenericTaintChecker

2020-02-10 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 243492.
steakhal added a comment.

Rebased on top of master, instead of D71524 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72035

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

Index: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -22,11 +22,14 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "llvm/Support/YAMLTraits.h"
+
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -35,17 +38,15 @@
 using namespace taint;
 
 namespace {
-class GenericTaintChecker
-: public Checker, check::PreStmt> {
+class GenericTaintChecker : public Checker {
 public:
   static void *getTag() {
 static int Tag;
 return &Tag;
   }
 
-  void checkPostStmt(const CallExpr *CE, CheckerContext &C) const;
-
-  void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
 
   void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
   const char *Sep) const override;
@@ -81,7 +82,7 @@
 
   /// Convert SignedArgVector to ArgVector.
   ArgVector convertToArgVector(CheckerManager &Mgr, const std::string &Option,
-   SignedArgVector Args);
+   const SignedArgVector &Args);
 
   /// Parse the config.
   void parseConfiguration(CheckerManager &Mgr, const std::string &Option,
@@ -96,7 +97,8 @@
   mutable std::unique_ptr BT;
   void initBugType() const {
 if (!BT)
-  BT.reset(new BugType(this, "Use of Untrusted Data", "Untrusted Data"));
+  BT = std::make_unique(this, "Use of Untrusted Data",
+ "Untrusted Data");
   }
 
   struct FunctionData {
@@ -106,9 +108,10 @@
 FunctionData &operator=(const FunctionData &) = delete;
 FunctionData &operator=(FunctionData &&) = delete;
 
-static Optional create(const CallExpr *CE,
+static Optional create(const CallEvent &Call,
  const CheckerContext &C) {
-  const FunctionDecl *FDecl = C.getCalleeDecl(CE);
+  assert(Call.getDecl());
+  const FunctionDecl *FDecl = Call.getDecl()->getAsFunction();
   if (!FDecl || (FDecl->getKind() != Decl::Function &&
  FDecl->getKind() != Decl::CXXMethod))
 return None;
@@ -132,33 +135,33 @@
 
   /// Catch taint related bugs. Check if tainted data is passed to a
   /// system call etc. Returns true on matching.
-  bool checkPre(const CallExpr *CE, const FunctionData &FData,
+  bool checkPre(const CallEvent &Call, const FunctionData &FData,
 CheckerContext &C) const;
 
   /// Add taint sources on a pre-visit. Returns true on matching.
-  bool addSourcesPre(const CallExpr *CE, const FunctionData &FData,
+  bool addSourcesPre(const CallEvent &Call, const FunctionData &FData,
  CheckerContext &C) const;
 
   /// Mark filter's arguments not tainted on a pre-visit. Returns true on
   /// matching.
-  bool addFiltersPre(const CallExpr *CE, const FunctionData &FData,
+  bool addFiltersPre(const CallEvent &Call, const FunctionData &FData,
  CheckerContext &C) const;
 
   /// Propagate taint generated at pre-visit. Returns true on matching.
-  bool propagateFromPre(const CallExpr *CE, CheckerContext &C) const;
+  static bool propagateFromPre(const CallEvent &Call, CheckerContext &C);
 
   /// Check if the region the expression evaluates to is the standard input,
   /// and thus, is tainted.
   static bool isStdin(const Expr *E, CheckerContext &C);
 
   /// Given a pointer argument, return the value it points to.
-  static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
+  static Optional getPointeeOf(CheckerContext &C, const Expr *Arg);
 
   /// Check for CWE-134: Uncontrolled Format String.
   static constexpr llvm::StringLiteral MsgUncontrolledFormatString =
   "Untrusted data is used as a format string "
   "(CWE-134: Uncontrolled Format String)";
-  bool checkUncontrolledFormatString(const CallExpr *CE,
+  bool checkUncontrolledFormatString(const CallEvent &Call,
  CheckerContext &C) const;
 
   /// Check for:
@@ -167,7 +170,7 @@
   static constexpr llvm::StringLiteral

[clang-tools-extra] 9f6d8de - [clangd] Support renaming designated initializers

2020-02-10 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-02-10T11:53:17+01:00
New Revision: 9f6d8de28ab6b3ac06658b8cb3236ef220712ed4

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

LOG: [clangd] Support renaming designated initializers

Summary:
Clangd does not find references of designated iniitializers yet and, as a
result, is unable to rename such references. This patch addresses this issue.

Resolves: https://github.com/clangd/clangd/issues/247

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index a9ac4b86d665..685079f0ebe8 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -672,6 +672,17 @@ llvm::SmallVector refInExpr(const Expr 
*E) {
   // Select the getter, setter, or @property depending on the call.
   explicitReferenceTargets(DynTypedNode::create(*E), {})});
 }
+
+void VisitDesignatedInitExpr(const DesignatedInitExpr *DIE) {
+  for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
+if (!D.isFieldDesignator())
+  continue;
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+D.getFieldLoc(),
+/*IsDecl=*/false,
+{D.getField()}});
+  }
+}
   };
 
   Visitor V;

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 074a24d9edbf..1d2ea0f1c0b2 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1162,7 +1162,41 @@ TEST_F(FindExplicitReferencesTest, All) {
   )cpp",
"0: targets = {f}\n"
"1: targets = {I::x}\n"
-   "2: targets = {I::setY:}\n"}};
+   "2: targets = {I::setY:}\n"},
+   // Designated initializers.
+   {R"cpp(
+void foo() {
+  struct $0^Foo {
+int $1^Bar;
+  };
+  $2^Foo $3^f { .$4^Bar = 42 };
+}
+)cpp",
+"0: targets = {Foo}, decl\n"
+"1: targets = {foo()::Foo::Bar}, decl\n"
+"2: targets = {Foo}\n"
+"3: targets = {f}, decl\n"
+"4: targets = {foo()::Foo::Bar}\n"},
+   {R"cpp(
+void foo() {
+  struct $0^Baz {
+int $1^Field;
+  };
+  struct $2^Bar {
+$3^Baz $4^Foo;
+  };
+  $5^Bar $6^bar { .$7^Foo.$8^Field = 42 };
+}
+)cpp",
+"0: targets = {Baz}, decl\n"
+"1: targets = {foo()::Baz::Field}, decl\n"
+"2: targets = {Bar}, decl\n"
+"3: targets = {Baz}\n"
+"4: targets = {foo()::Bar::Foo}, decl\n"
+"5: targets = {Bar}\n"
+"6: targets = {bar}, decl\n"
+"7: targets = {foo()::Bar::Foo}\n"
+"8: targets = {foo()::Baz::Field}\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index a9446865e664..fb6993ef0d40 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -440,6 +440,35 @@ TEST(RenameTest, WithinFileRename) {
 template  class Z> struct Bar { };
 template <> struct Bar<[[Foo]]> {};
   )cpp",
+
+  // Designated initializer.
+  R"cpp(
+struct Bar {
+  int [[Fo^o]];
+};
+Bar bar { .[[^Foo]] = 42 };
+  )cpp",
+
+  // Nested designated initializer.
+  R"cpp(
+struct Baz {
+  int Field;
+};
+struct Bar {
+  Baz [[Fo^o]];
+};
+// FIXME:v selecting here results in renaming Field.
+Bar bar { .[[Foo]].Field = 42 };
+  )cpp",
+  R"cpp(
+struct Baz {
+  int [[Fiel^d]];
+};
+struct Bar {
+  Baz Foo;
+};
+Bar bar { .Foo.[[^Field]] = 42 };
+  )cpp",
   };
   for (llvm::StringRef T : Tests) {
 SCOPED_TRACE(T);



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

[PATCH] D72867: [clangd] Support renaming designated initializers

2020-02-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f6d8de28ab6: [clangd] Support renaming designated 
initializers (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72867

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -440,6 +440,35 @@
 template  class Z> struct Bar { };
 template <> struct Bar<[[Foo]]> {};
   )cpp",
+
+  // Designated initializer.
+  R"cpp(
+struct Bar {
+  int [[Fo^o]];
+};
+Bar bar { .[[^Foo]] = 42 };
+  )cpp",
+
+  // Nested designated initializer.
+  R"cpp(
+struct Baz {
+  int Field;
+};
+struct Bar {
+  Baz [[Fo^o]];
+};
+// FIXME:v selecting here results in renaming Field.
+Bar bar { .[[Foo]].Field = 42 };
+  )cpp",
+  R"cpp(
+struct Baz {
+  int [[Fiel^d]];
+};
+struct Bar {
+  Baz Foo;
+};
+Bar bar { .Foo.[[^Field]] = 42 };
+  )cpp",
   };
   for (llvm::StringRef T : Tests) {
 SCOPED_TRACE(T);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1162,7 +1162,41 @@
   )cpp",
"0: targets = {f}\n"
"1: targets = {I::x}\n"
-   "2: targets = {I::setY:}\n"}};
+   "2: targets = {I::setY:}\n"},
+   // Designated initializers.
+   {R"cpp(
+void foo() {
+  struct $0^Foo {
+int $1^Bar;
+  };
+  $2^Foo $3^f { .$4^Bar = 42 };
+}
+)cpp",
+"0: targets = {Foo}, decl\n"
+"1: targets = {foo()::Foo::Bar}, decl\n"
+"2: targets = {Foo}\n"
+"3: targets = {f}, decl\n"
+"4: targets = {foo()::Foo::Bar}\n"},
+   {R"cpp(
+void foo() {
+  struct $0^Baz {
+int $1^Field;
+  };
+  struct $2^Bar {
+$3^Baz $4^Foo;
+  };
+  $5^Bar $6^bar { .$7^Foo.$8^Field = 42 };
+}
+)cpp",
+"0: targets = {Baz}, decl\n"
+"1: targets = {foo()::Baz::Field}, decl\n"
+"2: targets = {Bar}, decl\n"
+"3: targets = {Baz}\n"
+"4: targets = {foo()::Bar::Foo}, decl\n"
+"5: targets = {Bar}\n"
+"6: targets = {bar}, decl\n"
+"7: targets = {foo()::Bar::Foo}\n"
+"8: targets = {foo()::Baz::Field}\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -672,6 +672,17 @@
   // Select the getter, setter, or @property depending on the call.
   explicitReferenceTargets(DynTypedNode::create(*E), {})});
 }
+
+void VisitDesignatedInitExpr(const DesignatedInitExpr *DIE) {
+  for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
+if (!D.isFieldDesignator())
+  continue;
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+D.getFieldLoc(),
+/*IsDecl=*/false,
+{D.getField()}});
+  }
+}
   };
 
   Visitor V;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73636: [AArch64][SVE] SVE2 intrinsics for complex integer arithmetic

2020-02-10 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Thanks @kmclaughlin , LGTM.




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:1115
   class AdvSIMD_SVE_LOGB_Intrinsic  : AdvSIMD_SVE_CNT_Intrinsic;
+  class SVE2_CADD_Intrinsic : AdvSIMD_2VectorArgIndexed_Intrinsic;
+  class SVE2_CMLA_Intrinsic : AdvSIMD_3VectorArgIndexed_Intrinsic;

nit: The naming is inconsistent not using the `AdvSIMD_` prefix here, although 
we haven't been very consistent with that in this file to begin with.


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

https://reviews.llvm.org/D73636



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


[PATCH] D74117: [AArch64][SVE] SVE2 intrinsics for character match & histogram generation

2020-02-10 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe299a0814956: [AArch64][SVE] SVE2 intrinsics for character 
match & histogram generation (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74117

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-character-match.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-vec-hist-count.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-vec-hist-count.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-vec-hist-count.ll
@@ -0,0 +1,42 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; HISTCNT
+;
+
+define  @histcnt_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: histcnt_i32:
+; CHECK: histcnt z0.s, p0/z, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.histcnt.nxv4i32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @histcnt_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: histcnt_i64:
+; CHECK: histcnt z0.d, p0/z, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.histcnt.nxv2i64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+;
+; HISTSEG
+;
+
+define  @histseg( %a,  %b) {
+; CHECK-LABEL: histseg:
+; CHECK: histseg z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.histseg.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.histcnt.nxv4i32(, , )
+declare  @llvm.aarch64.sve.histcnt.nxv2i64(, , )
+declare  @llvm.aarch64.sve.histseg.nxv16i8(, )
Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-character-match.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-character-match.ll
@@ -0,0 +1,54 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; MATCH
+;
+
+define  @match_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: match_i8:
+; CHECK: match p0.b, p0/z, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.match.nxv16i8( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @match_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: match_i16:
+; CHECK: match p0.h, p0/z, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.match.nxv8i16( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; NMATCH
+;
+
+define  @nmatch_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: nmatch_i8:
+; CHECK: match p0.b, p0/z, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.nmatch.nxv16i8( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @nmatch_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: nmatch_i16:
+; CHECK: match p0.h, p0/z, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.nmatch.nxv8i16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.match.nxv16i8(, , )
+declare  @llvm.aarch64.sve.match.nxv8i16(, , )
+declare  @llvm.aarch64.sve.nmatch.nxv16i8(, , )
+declare  @llvm.aarch64.sve.nmatch.nxv8i16(, , )
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -6828,20 +6828,23 @@
   let Defs = [NZCV];
 }
 
-multiclass sve2_char_match {
+multiclass sve2_char_match {
   def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>;
   def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>;
+
+  def : SVE_3_Op_Pat(NAME # _B)>;
+  def : SVE_3_Op_Pat(NAME # _H)>;
 }
 
 //===--===//
 // SVE2 Histogram Computation - Segment Group
 //===--===//
 
-class sve2_hist_gen_segment
+class sve2_hist_gen_segment
 : I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm),
   asm, "\t$Zd, $Zn, $Zm",
   "",
-  []>, Sched<[]> {
+  [(set nxv16i8:$Zd, (op nxv16i8:$Zn, nxv16i8:$Zm))]>, Sched<[]> {
   bits<5> Zd;
   bits<5> Zn;
   bits<5> Zm;
@@ -6875,9 +6878,12 @@

[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-02-10 Thread Simon Cook via Phabricator via cfe-commits
simoncook updated this revision to Diff 243502.
simoncook added a comment.

Rebase, incorporate changes suggested by Lewis


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73891

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c

Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -264,20 +264,20 @@
 // RV32-IMINOR1: error: invalid arch name 'rv32i2p1', unsupported
 // RV32-IMINOR1: version number 2.1 for extension 'i'
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ix2p -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ixt2p -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XMINOR-MISS %s
-// RV32-XMINOR-MISS: error: invalid arch name 'rv32ix2p',
-// RV32-XMINOR-MISS: minor version number missing after 'p' for extension 'x2p'
+// RV32-XMINOR-MISS: error: invalid arch name 'rv32ixt2p',
+// RV32-XMINOR-MISS: minor version number missing after 'p' for extension 'xt'
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32is2p0 -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ist2p0 -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-SMINOR0 %s
-// RV32-SMINOR0: error: invalid arch name 'rv32is2p0',
-// RV32-SMINOR0: unsupported version number 2.0 for extension 's2p0'
+// RV32-SMINOR0: error: invalid arch name 'rv32ist2p0',
+// RV32-SMINOR0: unsupported version number 2.0 for extension 'st'
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32isx2p1 -### %s \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32isxt2p1 -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-SXMINOR1 %s
-// RV32-SXMINOR1: error: invalid arch name 'rv32isx2p1', unsupported
-// RV32-SXMINOR1: version number 2.1 for extension 'sx2p1'
+// RV32-SXMINOR1: error: invalid arch name 'rv32isxt2p1', unsupported
+// RV32-SXMINOR1: version number 2.1 for extension 'sxt'
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_ -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XSEP %s
@@ -327,3 +327,36 @@
 // RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
 // RV64-TARGET: "-triple" "riscv64-unknown-unknown-elf"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOFLAG %s
+// RV32-EXPERIMENTAL-NOFLAG: error: invalid arch name 'rv32ib'
+// RV32-EXPERIMENTAL-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOVERS %s
+// RV32-EXPERIMENTAL-NOVERS: error: invalid arch name 'rv32ib'
+// RV32-EXPERIMENTAL-NOVERS: experimental extension requires explicit version number
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib0p1 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS %s
+// RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32ib0p1'
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental extension
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib0p92 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
+// RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+b"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-NOFLAG %s
+// RV32-EXPERIMENTAL-ZBB-NOFLAG: error: invalid arch name 'rv32izbb'
+// RV32-EXPERIMENTAL-ZBB-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p92 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB %s
+// RV32-EXPERIMENTAL-ZBB: "-target-feature" "+zbb"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbb0p92_zbp0p92 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP %s
+// RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+zbb"
+// RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+zbp"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -22,6 +22,14 @@
 using namespace clang;
 using namespace llvm::opt;
 
+namespace {
+// Represents the major and version number components of a RISC-V extension
+struct RISCVExtensionVersion {
+  StringRef 

[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

It looks like the current code goes way back, to https://llvm.org/r39093 Do you 
know why it's started failing now?

Consistency is nice though, so I don't see any downside to this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129



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


[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions

2020-02-10 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 243509.
awpandey added a comment.
Herald added a subscriber: ormris.

@probinson I have reimplemented the feature by using DIFlags.


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

https://reviews.llvm.org/D73261

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/constExpr.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/DebugInfo/X86/constExpr.ll

Index: llvm/test/DebugInfo/X86/constExpr.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/constExpr.ll
@@ -0,0 +1,118 @@
+; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; CHECK: .debug_info contents:
+
+; CHECK: DW_TAG_variable
+; CHECK-NEXT: DW_AT_name {{.*}} "bar"
+; CHECK: DW_AT_const_expr {{.*}} (true)
+
+; CHECK: DW_TAG_subprogram
+; CHECK: DW_AT_const_expr {{.*}} (true)
+; CHECK: DW_AT_linkage_name {{.*}} "_Z3funi"
+
+
+; C++ source to regenerate:
+
+;constexpr int bar = 10;
+;
+;constexpr int fun(int x) { return x * 2; }
+;
+;int main(int argc, char **argv) {
+;  int foo = bar;
+;  constexpr int baz = 10;
+;  int constVal = fun(10);
+;  return 0;
+;}
+
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; ModuleID = '/dir/test.cpp'
+source_filename = "/dir/test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+$_Z3funi = comdat any
+; Function Attrs: noinline norecurse optnone uwtable
+
+define dso_local i32 @main(i32 %argc, i8** %argv) #0 !dbg !13 {
+entry:
+  %retval = alloca i32, align 4
+  %argc.addr = alloca i32, align 4
+  %argv.addr = alloca i8**, align 8
+  %foo = alloca i32, align 4
+  %baz = alloca i32, align 4
+  %constVal = alloca i32, align 4
+  store i32 0, i32* %retval, align 4
+  store i32 %argc, i32* %argc.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !19, metadata !DIExpression()), !dbg !20
+  store i8** %argv, i8*** %argv.addr, align 8
+  call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !21, metadata !DIExpression()), !dbg !22
+  call void @llvm.dbg.declare(metadata i32* %foo, metadata !23, metadata !DIExpression()), !dbg !24
+  store i32 10, i32* %foo, align 4, !dbg !24
+  call void @llvm.dbg.declare(metadata i32* %baz, metadata !25, metadata !DIExpression()), !dbg !26
+  store i32 10, i32* %baz, align 4, !dbg !26
+  call void @llvm.dbg.declare(metadata i32* %constVal, metadata !27, metadata !DIExpression()), !dbg !28
+  %call = call i32 @_Z3funi(i32 10), !dbg !29
+  store i32 %call, i32* %constVal, align 4, !dbg !28
+  ret i32 0, !dbg !30
+}
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local i32 @_Z3funi(i32 %x) #2 comdat !dbg !31 {
+entry:
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !34, metadata !DIExpression()), !dbg !35
+  %0 = load i32, i32* %x.addr, align 4, !dbg !36
+  %mul = mul nsw i32 %0, 2, !dbg !37
+  ret i32 %mul, !dbg !38
+}
+
+attributes #0 = { noinline norecurse optnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+attributes #2 = { noinline nounwind optnone uwtable  }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10, !11}
+!llvm.ident = !{!12}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/dir/test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "b973c468913ba52f145c9b21705fe0e0")
+!2 = !{}
+!3 = !{!4}
+!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 10, DW_OP_stack_value))
+!5 = distinct !DIGlobalVariable(name: "bar", scope: !0, file: !6, line: 13, type: !7, isLocal: true, isDefinition: true, flags: DIFlagConstExpr)
+!6 = !DIFile(filename: "/dir/test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "b973c468913ba52f145c9b21705fe0e0")
+!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
+!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!9 = !{i32 7, !"Dwarf Version", i32 5}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{i32 1, !"wchar_size", i32 4}
+!12 = !{!"clang version 11.0.0 "}
+!13 = distinct !DISubprogram(name: "main", scope: !6, file: !6, line: 

[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-02-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

Looking good to me as-is.

- Current naming is okay. But what do you think about reducing name of 
//quarter// intrinsics: `__builtin_msa_ldr_w` instead of 
`__builtin_msa_ldrq_w`? Will it clash with any future intrinsics' names?
- There is almost no documentation on target specific intrinsics. Some articles 
like Using ARM NEON instructions in big endian mode 
 cover specific use cases. It's up to 
you to write an article for these new intrinsics.


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

https://reviews.llvm.org/D73644



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


[PATCH] D73636: [AArch64][SVE] SVE2 intrinsics for complex integer arithmetic

2020-02-10 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92a78750929b: [AArch64][SVE] SVE2 intrinsics for complex 
integer arithmetic (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D73636?vs=242683&id=243511#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73636

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll
@@ -0,0 +1,106 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SADDLBT
+;
+
+define  @saddlbt_b( %a,  %b) {
+; CHECK-LABEL: saddlbt_b:
+; CHECK: saddlbt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlbt_h( %a,  %b) {
+; CHECK-LABEL: saddlbt_h:
+; CHECK: saddlbt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlbt_s( %a,  %b) {
+; CHECK-LABEL: saddlbt_s:
+; CHECK: saddlbt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SSUBLBT
+;
+
+define  @ssublbt_b( %a,  %b) {
+; CHECK-LABEL: ssublbt_b:
+; CHECK: ssublbt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssublbt_h( %a,  %b) {
+; CHECK-LABEL: ssublbt_h:
+; CHECK: ssublbt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssublbt_s( %a,  %b) {
+; CHECK-LABEL: ssublbt_s:
+; CHECK: ssublbt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SSUBLTB
+;
+
+define  @ssubltb_b( %a,  %b) {
+; CHECK-LABEL: ssubltb_b:
+; CHECK: ssubltb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssubltb_h( %a,  %b) {
+; CHECK-LABEL: ssubltb_h:
+; CHECK: ssubltb z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssubltb_s( %a,  %b) {
+; CHECK-LABEL: ssubltb_s:
+; CHECK: ssubltb z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.saddlbt.nxv8i16(, )
+declare  @llvm.aarch64.sve.saddlbt.nxv4i32(, )
+declare  @llvm.aarch64.sve.saddlbt.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.ssublbt.nxv8i16(, )
+declare  @llvm.aarch64.sve.ssublbt.nxv4i32(, )
+declare  @llvm.aarch64.sve.ssublbt.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.ssubltb.nxv8i16(, )
+declare  @llvm.aarch64.sve.ssubltb.nxv4i32(, )
+declare  @llvm.aarch64.sve.ssubltb.nxv2i64(, )
Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
@@ -0,0 +1,267 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; CADD
+;
+
+define  @cadd_b( %a,  %b) {
+; CHECK-LABEL: cadd_b:
+; CHECK: cadd z0.b, z0.b, z1.b, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cadd.x.nxv16i8( %a,
+   %b,
+  i32 90)
+  ret  %out
+}
+
+define  @cadd_h( %a,  %b) {
+; CHECK-LABEL: cadd_h:
+; CHECK: cadd z0.h, z0.h, z1.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cadd.x.nxv8i16( %a,
+   %b,
+  i32 90)
+  ret  %out
+}
+
+define  @cadd_s( %a,  %b) {
+; CHECK-LABEL: cadd_s:
+; CHECK: cadd z0.s, z0.s, z1.s, #270
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sv

[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: steakhal.

Looks good to me. Thanks for writing release notes!

If you have commit access, go ahead and push directly to the branch, otherwise 
let me know and I'll be happy to do it for you.


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

https://reviews.llvm.org/D73966



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong planned changes to this revision.
martong added a subscriber: steakhal.
martong added a comment.

Based on our verbal discussion with @Szelethus and @steakhal and based on the 
mailing archives 
, I am going 
to do the following changes:

- Add a new checker that is implemented in the `StdLibraryFunctionsChecker` 
class.
- This new checker if switched on is responsible for emitting the warning. Even 
if this is turned off, the sink node is generated if the argument violates the 
given condition.
- This means, the new checker has the sole responsibility of emitting the 
warning, but nothing more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava updated this revision to Diff 243520.
adalava added a comment.

fix typo found by @dim


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600

Files:
  clang/lib/AST/ExprConstant.cpp
  compiler-rt/lib/builtins/atomic.c


Index: compiler-rt/lib/builtins/atomic.c
===
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -119,13 +119,20 @@
   return locks + (hash & SPINLOCK_MASK);
 }
 
-/// Macros for determining whether a size is lock free.  Clang can not yet
-/// codegen __atomic_is_lock_free(16), so for now we assume 16-byte values are
-/// not lock free.
+/// Macros for determining whether a size is lock free.
 #define IS_LOCK_FREE_1 __c11_atomic_is_lock_free(1)
 #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2)
 #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4)
+
+/// 32 bit PowerPC doesn't support 8-byte lock_free atomics
+#if !defined(__powerpc64__) && defined(__powerpc__)
+#define IS_LOCK_FREE_8 0
+#else
 #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8)
+#endif
+
+/// Clang can not yet codegen __atomic_is_lock_free(16), so for now we assume
+/// 16-byte values are not lock free.
 #define IS_LOCK_FREE_16 0
 
 /// Macro that calls the compiler-generated lock-free versions of functions
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11206,6 +11206,15 @@
   }
 }
 
+// Avoid emitting call for runtime decision on PowerPC 32-bit
+// The lock free possibilities on this platform are covered by the lines 
+// above and we know in advance other cases require lock.
+// This may need to be restricted to specific operating systems in the 
future,
+// as some (perhaps AIX) might provide libatomic and prefer to use it 
instead
+if (Info.Ctx.getTargetInfo().getTriple().getArch() == llvm::Triple::ppc) {
+return Success(0, E);
+}
+
 return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
 Success(0, E) : Error(E);
   }


Index: compiler-rt/lib/builtins/atomic.c
===
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -119,13 +119,20 @@
   return locks + (hash & SPINLOCK_MASK);
 }
 
-/// Macros for determining whether a size is lock free.  Clang can not yet
-/// codegen __atomic_is_lock_free(16), so for now we assume 16-byte values are
-/// not lock free.
+/// Macros for determining whether a size is lock free.
 #define IS_LOCK_FREE_1 __c11_atomic_is_lock_free(1)
 #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2)
 #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4)
+
+/// 32 bit PowerPC doesn't support 8-byte lock_free atomics
+#if !defined(__powerpc64__) && defined(__powerpc__)
+#define IS_LOCK_FREE_8 0
+#else
 #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8)
+#endif
+
+/// Clang can not yet codegen __atomic_is_lock_free(16), so for now we assume
+/// 16-byte values are not lock free.
 #define IS_LOCK_FREE_16 0
 
 /// Macro that calls the compiler-generated lock-free versions of functions
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11206,6 +11206,15 @@
   }
 }
 
+// Avoid emitting call for runtime decision on PowerPC 32-bit
+// The lock free possibilities on this platform are covered by the lines 
+// above and we know in advance other cases require lock.
+// This may need to be restricted to specific operating systems in the future,
+// as some (perhaps AIX) might provide libatomic and prefer to use it instead
+if (Info.Ctx.getTargetInfo().getTriple().getArch() == llvm::Triple::ppc) {
+return Success(0, E);
+}
+
 return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
 Success(0, E) : Error(E);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74216: [clang-rename] Fix the missing template constructors.

2020-02-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:144
+  template
+  [[Foo]]();
+

nit: Maybe also add `^` to this one and the one below?



Comment at: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp:140
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *MD : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(MD))

nit: The naming is slightly confusing, this probably suggests MethodDecl 
instance, but it's not spelled anywhere and may be better to call it just `D`.



Comment at: clang/test/clang-rename/TemplateCtor.cpp:1
+class Foo { // CHECK: class Bar {
+public:

Nit: not sure if the new file is necessary, maybe just put this under 
.../Ctor.cpp?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74216



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


[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

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

I missed out on the transition to github, so I suspect that the commit access 
will only be extended to it after tagging rc2. I think it would be better if 
you committed this on my behalf, thanks! :)


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

https://reviews.llvm.org/D73966



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


[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added a comment.
Herald added a subscriber: steakhal.

Ping @NoQ




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:42-49
 // The following standard C functions are currently supported:
 //
 //   fgetc  getline   isdigit   isupper
 //   fread  isalnum   isgraph   isxdigit
 //   fwrite isalpha   islower   read
 //   getc   isascii   isprint   write
 //   getcharisblank   ispunct

Szelethus wrote:
> martong wrote:
> > Szelethus wrote:
> > > I would prefer to just have a checker option that could print out the 
> > > currently modeled function rather than these lines of a recipe for 
> > > outdated comments.
> > Yes I agree, especially because I am planning to add a plethora of new 
> > functions in the future. I think that would be the appropriate time to 
> > implement the checker option.
> Totally agreed! Thank you for the cleanup!
No, thanks for the review! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897



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


[clang] fcea7fb - CWG2445: For function template partial ordering, take reversal of

2020-02-10 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-10T06:07:48-08:00
New Revision: fcea7fbdba1bdf26e2a858a6be2865e6267da023

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

LOG: CWG2445: For function template partial ordering, take reversal of
function arguments into account when forming P/A pairs.

Added: 


Modified: 
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/operator-template.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 1394c6236965..a274102ceb11 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -850,6 +850,8 @@ class Sema;
   return static_cast(RewriteKind);
 }
 
+bool isReversed() const { return getRewriteKind() & CRK_Reversed; }
+
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3e6856048725..d664e4822e14 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7964,12 +7964,10 @@ class Sema final {
 SourceLocation ReturnLoc,
 Expr *&RetExpr, AutoType *AT);
 
-  FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
-   FunctionTemplateDecl *FT2,
-   SourceLocation Loc,
-   TemplatePartialOrderingContext TPOC,
-   unsigned NumCallArguments1,
-   unsigned NumCallArguments2);
+  FunctionTemplateDecl *getMoreSpecializedTemplate(
+  FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc,
+  TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
+  unsigned NumCallArguments2, bool Reversed = false);
   UnresolvedSetIterator
   getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
  TemplateSpecCandidateSet &FailedCandidates,

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 858e7ae34a7f..003d9bb3a97d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -8392,7 +8392,7 @@ class BuiltinOperatorOverloadBuilder {
   // We interpret "same parameter-type-list" as applying to the
   // "synthesized candidate, with the order of the two parameters
   // reversed", not to the original function.
-  bool Reversed = C->RewriteKind & CRK_Reversed;
+  bool Reversed = C->isReversed();
   QualType FirstParamType = C->Function->getParamDecl(Reversed ? 1 : 0)
 ->getType()
 .getUnqualifiedType();
@@ -9478,7 +9478,7 @@ bool clang::isBetterOverloadCandidate(
 
 case ImplicitConversionSequence::Worse:
   if (Cand1.Function && Cand1.Function == Cand2.Function &&
-  (Cand2.RewriteKind & CRK_Reversed) != 0) {
+  Cand2.isReversed()) {
 // Work around large-scale breakage caused by considering reversed
 // forms of operator== in C++20:
 //
@@ -9566,14 +9566,13 @@ bool clang::isBetterOverloadCandidate(
   //  according to the partial ordering rules described in 14.5.5.2, or,
   //  if not that,
   if (Cand1IsSpecialization && Cand2IsSpecialization) {
-if (FunctionTemplateDecl *BetterTemplate
-  = S.getMoreSpecializedTemplate(Cand1.Function->getPrimaryTemplate(),
- Cand2.Function->getPrimaryTemplate(),
- Loc,
-   isa(Cand1.Function)? TPOC_Conversion
- : TPOC_Call,
- Cand1.ExplicitCallArguments,
- Cand2.ExplicitCallArguments))
+if (FunctionTemplateDecl *BetterTemplate = S.getMoreSpecializedTemplate(
+Cand1.Function->getPrimaryTemplate(),
+Cand2.Function->getPrimaryTemplate(), Loc,
+isa(Cand1.Function) ? TPOC_Conversion
+   : TPOC_Call,
+Cand1.ExplicitCallArguments, Cand2.ExplicitCallArguments,
+Cand1.isReversed() ^ Cand2.isReversed()))
   return BetterTemplate == Cand1.Function->getPrimaryTemplate();
   }
 
@@ -11

[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Pushed to 10.x in 64515b35844b925bdb76821d03ad4d7ddebe06e7 
. Thanks!


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

https://reviews.llvm.org/D73966



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


[PATCH] D74063: [Clang] Remove #pragma clang __debug handle_crash

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Cherry-picked to 10.x in 793d643f6d69e6908a6ece4aacb07b6573e33e18 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74063



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-02-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 243545.
njames93 added a comment.

- Relaxed corresponding header
- Added support for tag types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-missing-header-file-declaration.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/misc-missing-header-file-declaration.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/wrong_header.h
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration-any-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
@@ -0,0 +1,102 @@
+// RUN: %check_clang_tidy %s misc-missing-header-file-declaration %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN: [{key: misc-missing-header-file-declaration.CheckCorrespondingHeaders, value: 1}]}' \
+// RUN: -- -I%S/Inputs/misc-missing-header-file-declaration
+
+#include "misc-missing-header-file-declaration.h"
+#include "wrong_header.h"
+
+// These declarations should be ignored by the check as they are in the same
+// file.
+extern bool DeclInSource;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInSource' is declared as extern in a source file
+extern void declInSource();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInSource' is declared as extern in a source file
+
+// These declarations should be ignored by the check as they are in the same
+// file, however there is a corresponding decl in the header that will prevent
+// a failing check.
+extern bool DeclInBoth;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInBoth' is declared as extern in a source file
+extern void declInBoth();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInBoth' is declared as extern in a source file
+
+// No external linkage so no warning
+static bool StaticOK = false;
+constexpr bool ConstexprOK = false;
+inline void inlineOK() {}
+static void staticOK() {}
+constexpr bool constexprOK() { return true; }
+
+// External linkage but decl in header so no warning
+bool DeclInHeader = false;
+bool DeclInBoth = false;
+void declInHeader() {}
+void declInBoth() {}
+
+//Decls don't appear in corresponding header so issue a warning
+bool DeclInSource = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInSource' is defined with external linkage
+bool NoDecl = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'NoDecl' is defined with external linkage
+void declInSource() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInSource' is defined with external linkage
+void noDecl() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'noDecl' is defined with external linkage
+
+bool DeclInWrongHeader = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInWrongHeader' is defined with external linkage
+void declInWrongHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInWrongHeader' is defined with external linkage
+
+// Decls in an anonymous namespace don't have external linkage, so no warning
+// should be emitted
+namespace {
+bool AnonNS = false;
+void anonNS() {}
+} // namespace
+
+// Ensure in namespace definitions are correctly resolved
+namespace ns1 {
+bool NS = false;
+void nS() {}
+} // namespace ns1
+
+// Ensure out of namespace definitions are correctly resolved
+bool /*namespace*/ ns2::NS = false;
+void /*namespace*/ ns2::nS() {}
+
+// Static class members declared in the header shouldn't be warned on.
+int /*struct*/ Foo::Bar = 0;
+
+// main is special, don't warn for it.
+int main() {
+}
+
+template 
+void templateFuncNoHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'templateFuncNoHeader' is defined with external linkage
+
+// Warn on explicit instantiations
+template <>
+void templateFuncNoHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'templateFuncNoHeader' is defined with external linkage
+
+static void foo() {
+  // We don't want warnings for these implicit instantations
+  templateFuncNoHeader();
+  templateFuncNoHeader();
+}
+
+struct SNoHeader {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Struct 'SNoHeader' is defined with external linkage
+
+namespace {
+struc

[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

LGTM, thanks again!




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:537-551
+  // The format is as follows:
   //{ "function name",
-  //  { spec:
+  //  { variant0:
   //{ argument types list, ... },
-  //return type, purity, { range set list:
+  //return type, purity, { specification list:
   //  { range list:
   //{ argument index, within or out of, {{from, to}, ...} },

martong wrote:
> NoQ wrote:
> > I suspect that this comment would need a lot more updates.
> Could you please elaborate? Do you mean to add comments e.g. to 
> `ArgumentCondition` and the rest below? Or to rewrite the above comment?
Actually let's ditch it entirely. It was worth it when it was all macros, so 
that it was apparent how macros expanded, but now it's pretty self-explanatory 
all the way.

Otherwise i was thinking about making this a pattern that the user can 
copy-paste and fill in. Like, maybe, include all the constructors explicitly 
(`Summary`, `ArgTypes`, etc.).



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:598
+  Summaries{
+  Summary(ArgTypes{IntTy}, RetType(IntTy), EvalCallAsPure)
+  // Boils down to isupper() or islower() or isdigit().

Just curious, can `RetType` also use curly braces?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897



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


[PATCH] D74070: [Clang] Don't let gen crash diagnostics fail when '#pragma clang __debug crash' is used

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74070#1863989 , @aganea wrote:

> Relanded as rG75f09b54429bee17a96e2ba7a2ac0f0a8a7f7e74 
> .


Pushed that to 10.x as 0e1c734fa5b88ec7efc2bcf8d45ed58f6ba48b91 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74070



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


[PATCH] D74076: [Clang][Driver] Remove -M group options before generating crash diagnostics

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74076#1863987 , @aganea wrote:

> Relanded as rG75f09b54429bee17a96e2ba7a2ac0f0a8a7f7e74 
> 


Pushed that to 10.x as 0e1c734fa5b88ec7efc2bcf8d45ed58f6ba48b91 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74076



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


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> @erichkeane Thanks for filing the bugzilla bug. I was having some problems 
> with my bugzilla login myself and wasn't able to do so. I'll track progress 
> if this bug and decide shortly if my feature should imply no-integraed-cc1. 
> Thanks Guys.

I think that bug was for the problem of high memory usage when doing multiple 
compilations in one clang invocation.

I've filed https://bugs.llvm.org/show_bug.cgi?id=44865 for the interface stubs 
vs asan issue to keep track of it easier. Please cc yourselves and track 
progress there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69825



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-10 Thread John Marshall via cfe-commits
Thanks Aaron (and Hubert).

I've attached an updated patch that now includes new test cases alongside some 
existing "too few / too many" test cases in test/Sema/exprs.c. This splits the 
function declaration over two lines so it can use -verify to validate the 
source location's line (but not column). If you'd prefer a FileCheck approach 
to get the column too, I'm happy to do that but please advise whether it would 
be best to create a new test/Sema/foo.c file for these tests or to add to one 
of the existing test files.

Verified that without the patch, the notes are on the "MY_EXPORT void" line and 
the test cases fail. All tests still pass after this, after adjusting one 
existing FileCheck-based test case that also happens to exercise the patch's 
change.

John


On 7 Feb 2020, at 15:40, Aaron Ballman wrote:
> Thank you for the patch -- I think the changes look reasonable, but it
> should come with some test cases as well. Source location stuff is a
> bit onerous to try to test, but I think the best approach would be to
> add a new test that uses FileCheck instead of -verify so that you can
> validate the source location's line and column are as expected in the
> note. Once you have such a test (and have verified that no other tests
> fail with your changes), I'm happy to commit on your behalf.
> 
> ~Aaron
> 
> On Fri, Feb 7, 2020 at 10:23 AM Hubert Tong
>  wrote:
>> 
>> I think this looks okay. I think Richard or Aaron might be able to provide a 
>> more informed opinion.
>> 
>> -- HT


commit cbd4a4a155b40dc77c2ed82f397fe303dfc10837
Author: John Marshall 
AuthorDate: Mon Jan 20 14:58:14 2020 +
Commit: John Marshall 
CommitDate: Mon Feb 10 14:30:58 2020 +

Use getLocation() in "too few/too many arguments" diagnostic

Use the more accurate location when emitting the location of the
function being called's prototype in diagnostics emitted when calling
a function with an incorrect number of arguments.

In particular, avoids showing a trace of irrelevant macro expansions
for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.

Add test cases alongside other "too few/too many arguments" tests.
Adjust column position in incidentally related FileCheck-based test.

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ffe72c98356..b9d7024f083 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   return true;
 }
@@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);
diff --git a/clang/test/Misc/serialized-diags.c 
b/clang/test/Misc/serialized-diags.c
index e401477a2eb..2f4b86fb42f 100644
--- a/clang/test/Misc/serialized-diags.c
+++ b/clang/test/Misc/serialized-diags.c
@@ -56,7 +56,7 @@ void rdar11040133() {
 // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 
{{.*[/\\]}}serialized-diags.c:22:18
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 
'false' []
 // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 
{{.*[/\\]}}serialized-diags.c:20:16
-// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here []
 // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to 
pointer conversion initializing 'char *' with an expression of type 'int' 
[-Wint-conversion]
 // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 
{{.*[/\\]}}serialized-diags.h:5:17
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from 
{{.*[/\\]}}serialized-diags.c:26: []
diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
index 760c45e02f3..4e144041aca 100644
--- a/clang/test/Sema/exprs.c
+++ b/clang/test/Sema/exprs.c
@@ -163,12 +163,15 @@ void test17(int x) {
   x = sizeof(x/0);  // no warning.
 }
 
-// PR6501 & PR11857
+// PR6501, PR11857, and PR23564
 void test18_a(int a); // expected-note 2 {{'test18_a' declared here}}
 void test18_b(int); // expected-note {{'test18_b' declared here}}
 void test18_c(int a, int b); // expected-note 2 {{'test18_c' declared here}}
 void test18_d(int a, ...); // expected-note {{'test18_d' declared here}}
 void test18_e(int a, int b, ...); // expected-note {{'test18_e' declared here}}
+#define MY_EXPORT __attribute__((v

[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 243552.
martong marked 7 inline comments as done.
martong added a comment.

- Ditch comment about (macro) format
- Use {} with RetType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897

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

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -9,7 +9,7 @@
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //
-// This checker provides a specification format - `FunctionSummaryTy' - and
+// This checker provides a specification format - `Summary' - and
 // contains descriptions of some library functions in this format. Each
 // specification contains a list of branches for splitting the program state
 // upon call, and range constraints on argument and return-value symbols that
@@ -21,7 +21,7 @@
 // consider standard C function `ispunct(int x)', which returns a non-zero value
 // iff `x' is a punctuation character, that is, when `x' is in range
 //   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
-// `FunctionSummaryTy' provides only two branches for this function. However,
+// `Summary' provides only two branches for this function. However,
 // any attempt to describe this range with if-statements in the body farm
 // would result in many more branches. Because each branch needs to be analyzed
 // independently, this significantly reduces performance. Additionally,
@@ -30,13 +30,13 @@
 // which may lead to false positives because considering this particular path
 // was not consciously intended, and therefore it might have been unreachable.
 //
-// This checker uses eval::Call for modeling "pure" functions, for which
-// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
-// invalidation passes. Conflicts with other checkers are unlikely because
-// if the function has no other effects, other checkers would probably never
-// want to improve upon the modeling done by this checker.
+// This checker uses eval::Call for modeling pure functions (functions without
+// side effets), for which their `Summary' is a precise model. This avoids
+// unnecessary invalidation passes. Conflicts with other checkers are unlikely
+// because if the function has no other effects, other checkers would probably
+// never want to improve upon the modeling done by this checker.
 //
-// Non-"pure" functions, for which only partial improvement over the default
+// Non-pure functions, for which only partial improvement over the default
 // behavior is expected, are modeled via check::PostCall, non-intrusively.
 //
 // The following standard C functions are currently supported:
@@ -64,49 +64,48 @@
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
-  struct FunctionSummaryTy;
+  struct Summary;
 
   /// Specify how much the analyzer engine should entrust modeling this function
   /// to us. If he doesn't, he performs additional invalidations.
-  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+  enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// A pair of ValueRangeKind and IntRangeVector would describe a range
   /// imposed on a particular argument or return value symbol.
   ///
   /// Given a range, should the argument stay inside or outside this range?
   /// The special `ComparesToArgument' value indicates that we should
   /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
+  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
 
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
-  typedef uint64_t RangeIntTy;
+  typedef uint64_t RangeInt;
 
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVector;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
   /// obviously uint32_t should be enough for all practical purposes.
-  typedef uint32_t ArgNoTy;
-  static const ArgNoTy Ret = std::numeric_limits::max();
+  typedef uint32_t ArgNo;
+  static const Ar

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-02-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for the review guys!




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:537-551
+  // The format is as follows:
   //{ "function name",
-  //  { spec:
+  //  { variant0:
   //{ argument types list, ... },
-  //return type, purity, { range set list:
+  //return type, purity, { specification list:
   //  { range list:
   //{ argument index, within or out of, {{from, to}, ...} },

NoQ wrote:
> martong wrote:
> > NoQ wrote:
> > > I suspect that this comment would need a lot more updates.
> > Could you please elaborate? Do you mean to add comments e.g. to 
> > `ArgumentCondition` and the rest below? Or to rewrite the above comment?
> Actually let's ditch it entirely. It was worth it when it was all macros, so 
> that it was apparent how macros expanded, but now it's pretty 
> self-explanatory all the way.
> 
> Otherwise i was thinking about making this a pattern that the user can 
> copy-paste and fill in. Like, maybe, include all the constructors explicitly 
> (`Summary`, `ArgTypes`, etc.).
Ok, I ditched it.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:598
+  Summaries{
+  Summary(ArgTypes{IntTy}, RetType(IntTy), EvalCallAsPure)
+  // Boils down to isupper() or islower() or isdigit().

NoQ wrote:
> Just curious, can `RetType` also use curly braces?
Yes. I've changed it to use the curly braces with `RetType` too, now the format 
is more consistent with `ArgTypes`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897



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


[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2020-02-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 243553.
arsenm added a comment.

Rebase and fix check prefix name


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

https://reviews.llvm.org/D69979

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/test/Driver/default-denormal-fp-math.c

Index: clang/test/Driver/default-denormal-fp-math.c
===
--- /dev/null
+++ clang/test/Driver/default-denormal-fp-math.c
@@ -0,0 +1,19 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target i386-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// crtfastmath enables ftz and daz
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-PRESERVESIGN %s
+
+// crt not linked in with nostartfiles
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math -nostartfiles --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// If there's no crtfastmath, don't assume ftz/daz
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=/dev/null -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-PRESERVESIGN %s
+
+
+// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// CHECK-PRESERVESIGN: -fdenormal-fp-math=preserve-sign,preserve-sign
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,14 @@
   // capable of unit splitting.
   bool canSplitThinLTOUnit() const override { return false; }
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList &DriverArgs,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType) const override {
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -300,7 +300,7 @@
 
 if (!Args.hasArg(options::OPT_nostartfiles)) {
   // Add crtfastmath.o if available and fast math is enabled.
-  TC.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
+  TC.addFastMathRuntimeIfAvailable(Args, CmdArgs);
 
   CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
 }
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -46,6 +46,11 @@
 
   std::vector ExtraOpts;
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList &DriverArgs,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType = nullptr) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -988,3 +988,22 @@
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);
 }
+
+llvm::DenormalMode Linux::getDefaultDenormalModeForType(
+  const llvm::opt::ArgList &DriverArgs,
+  Action::OffloadKind DeviceOffloadKind,
+  const llvm::fltSemantics *FPType) const {
+  switch (getTriple().getArch()) {
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64: {
+std::string Unused;
+// DAZ and FTZ are turned on in crtfastmath.o
+if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
+isFastMathRuntimeAvailable(DriverArgs, Unused))
+  return llvm::DenormalMode::getPreserveSign();
+return llvm::DenormalMode::getIEEE();
+  }
+  default:
+return llvm::DenormalMode::getIEEE();
+  }
+}
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -502,7 +502,7 @@
 }
 
 // Add crtfastmath.o if available and fast math is enabled.
-ToolChain.AddFastMath

[PATCH] D72304: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-02-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

this breaks under asan 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/38597/steps/check-clang%20asan/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304



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


[clang] 5731b66 - Revert "[OpenMP] Fix unused variable"

2020-02-10 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-10T16:34:59+01:00
New Revision: 5731b6672ded5615f5489c892d7cdc9f4cf1836a

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

LOG: Revert "[OpenMP] Fix unused variable"

This breaks under asan, see 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/38597/steps/check-clang%20asan/logs/stdio

This reverts commit bb5045429545f47a76980864322a637c31594c7f.

Revert "[FIX] Ordering problem accidentally introduced with D72304"

This reverts commit 08c0a06d8f375e48d4acebac886bfdf19a2276ed.

Revert "[OpenMP][OMPIRBuilder] Add Directives (master and critical) to 
OMPBuilder."

This reverts commit e8a436c5ea26f69378e4c1cf3ddb5b647b201e0f.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/critical_codegen.cpp
clang/test/OpenMP/master_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPConstants.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index b1fc6bb62adb..cd5f7c05 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3143,147 +3143,11 @@ static void emitMaster(CodeGenFunction &CGF, const 
OMPExecutableDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const CapturedStmt *CS = S.getInnermostCapturedStmt();
-const Stmt *MasterRegionBodyStmt = CS->getCapturedStmt();
-
-// TODO: Replace with a generic helper function for finalization
-auto FiniCB = [this](InsertPointTy IP) {
-  CGBuilderTy::InsertPointGuard IPG(Builder);
-  assert(IP.getBlock()->end() != IP.getPoint() &&
- "OpenMP IR Builder should cause terminated block!");
-
-  llvm::BasicBlock *IPBB = IP.getBlock();
-  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
-  assert(DestBB && "Finalization block should have one successor!");
-
-  // erase and replace with cleanup branch.
-  IPBB->getTerminator()->eraseFromParent();
-  Builder.SetInsertPoint(IPBB);
-  CodeGenFunction::JumpDest Dest = getJumpDestInCurrentScope(DestBB);
-  EmitBranchThroughCleanup(Dest);
-};
-
-// TODO: Replace with a generic helper function for emitting body
-auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
-  InsertPointTy CodeGenIP,
-  llvm::BasicBlock &FiniBB) {
-  // Alloca insertion block should be in the entry block of the containing
-  // function So it expects an empty AllocaIP in which case will reuse the
-  // old alloca insertion point, or a new AllocaIP in the same block as the
-  // old one
-  assert((!AllocaIP.isSet() ||
-  AllocaInsertPt->getParent() == AllocaIP.getBlock()) &&
- "Insertion point should be in the entry block of containing "
- "function!");
-  auto OldAllocaIP = AllocaInsertPt;
-  if (AllocaIP.isSet())
-AllocaInsertPt = &*AllocaIP.getPoint();
-  auto OldReturnBlock = ReturnBlock;
-  ReturnBlock = getJumpDestInCurrentScope(&FiniBB);
-
-  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
-  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
-CodeGenIPBBTI->eraseFromParent();
-
-  Builder.SetInsertPoint(CodeGenIPBB);
-
-  EmitStmt(MasterRegionBodyStmt);
-
-  if (Builder.saveIP().isSet())
-Builder.CreateBr(&FiniBB);
-
-  AllocaInsertPt = OldAllocaIP;
-  ReturnBlock = OldReturnBlock;
-};
-CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
-CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
-Builder.restoreIP(OMPBuilder->CreateMaster(Builder, BodyGenCB, FiniCB));
-
-return;
-  }
   OMPLexicalScope Scope(*this, S, OMPD_unknown);
   emitMaster(*this, S);
 }
 
 void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const CapturedStmt *CS = S.getInnermostCapturedStmt();
-const Stmt *CriticalRegionBodyStmt = CS->getCapturedStmt();
-const Expr *Hint = nullptr;
-if (const auto *HintClause = S.getSingleClause())
-  Hint = HintClause->getHint();
-
-// TODO: This is slightly 
diff erent fr

[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma requested changes to this revision.
efriedma added a comment.
This revision now requires changes to proceed.

For the clang change, we should do something like D72579 
, not explicitly check for a specific target 
in target-independent code.

For compiler-rt, are you really disabling COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN?  
Are you sure you understand the implications of that?

I'm also curious: what part of clang is calling __atomic_is_lock_free?  I can't 
find any code in LLVM that calls it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[clang] f5086b3 - [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-02-10T16:45:33+01:00
New Revision: f5086b3803ac2f908a734bbb2c7a50018fb3cd8c

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

LOG: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

Reviewers: NoQ

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 2cdee8da375e..e8668775ab85 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -9,7 +9,7 @@
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //
-// This checker provides a specification format - `FunctionSummaryTy' - and
+// This checker provides a specification format - `Summary' - and
 // contains descriptions of some library functions in this format. Each
 // specification contains a list of branches for splitting the program state
 // upon call, and range constraints on argument and return-value symbols that
@@ -21,7 +21,7 @@
 // consider standard C function `ispunct(int x)', which returns a non-zero 
value
 // iff `x' is a punctuation character, that is, when `x' is in range
 //   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
-// `FunctionSummaryTy' provides only two branches for this function. However,
+// `Summary' provides only two branches for this function. However,
 // any attempt to describe this range with if-statements in the body farm
 // would result in many more branches. Because each branch needs to be analyzed
 // independently, this significantly reduces performance. Additionally,
@@ -30,13 +30,13 @@
 // which may lead to false positives because considering this particular path
 // was not consciously intended, and therefore it might have been unreachable.
 //
-// This checker uses eval::Call for modeling "pure" functions, for which
-// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
-// invalidation passes. Conflicts with other checkers are unlikely because
-// if the function has no other effects, other checkers would probably never
-// want to improve upon the modeling done by this checker.
+// This checker uses eval::Call for modeling pure functions (functions without
+// side effets), for which their `Summary' is a precise model. This avoids
+// unnecessary invalidation passes. Conflicts with other checkers are unlikely
+// because if the function has no other effects, other checkers would probably
+// never want to improve upon the modeling done by this checker.
 //
-// Non-"pure" functions, for which only partial improvement over the default
+// Non-pure functions, for which only partial improvement over the default
 // behavior is expected, are modeled via check::PostCall, non-intrusively.
 //
 // The following standard C functions are currently supported:
@@ -64,49 +64,48 @@ class StdLibraryFunctionsChecker : public 
Checker {
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
-  struct FunctionSummaryTy;
+  struct Summary;
 
   /// Specify how much the analyzer engine should entrust modeling this 
function
   /// to us. If he doesn't, he performs additional invalidations.
-  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+  enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// A pair of ValueRangeKind and IntRangeVector would describe a range
   /// imposed on a particular argument or return value symbol.
   ///
   /// Given a range, should the argument stay inside or outside this range?
   /// The special `ComparesToArgument' value indicates that we should
   /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
+  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
 
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
-  typedef uint64_t RangeIntTy;
+  typedef uint64_t RangeInt;
 
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef st

[clang-tools-extra] 0151ddc - Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.

2020-02-10 Thread Ben Hamilton via cfe-commits

Author: Michael Wyman
Date: 2020-02-10T08:56:28-07:00
New Revision: 0151ddc2e834ab4949789cbed4e03a958284cd54

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

LOG: Create a clang-tidy check to warn when -dealloc is implemented inside an 
ObjC class category.

Summary: Such implementations may override the class's own implementation, and 
even be a danger in case someone later comes and adds one to the class itself. 
Most times this has been encountered have been a mistake.

Reviewers: stephanemoore, benhamilton, dmaclach

Reviewed By: stephanemoore, benhamilton, dmaclach

Subscribers: dmaclach, mgorny, cfe-commits

Tags: #clang-tools-extra, #clang

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

Added: 
clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m

Modified: 
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
index 68dda6530f7f..1e39e02e7b92 100644
--- a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
   AvoidNSErrorInitCheck.cpp
+  DeallocInCategoryCheck.cpp
   ForbiddenSubclassingCheck.cpp
   MissingHashCheck.cpp
   ObjCTidyModule.cpp

diff  --git a/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp 
b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
new file mode 100644
index ..468065742670
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
@@ -0,0 +1,46 @@
+//===--- DeallocInCategoryCheck.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DeallocInCategoryCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+void DeallocInCategoryCheck::registerMatchers(MatchFinder *Finder) {
+  // This check should only be applied to Objective-C sources.
+  if (!getLangOpts().ObjC)
+return;
+
+  // Non-NSObject/NSProxy-derived objects may not have -dealloc as a special
+  // method. However, it seems highly unrealistic to expect many 
false-positives
+  // by warning on -dealloc in categories on classes without one of those
+  // base classes.
+  Finder->addMatcher(
+  objcMethodDecl(isInstanceMethod(), hasName("dealloc"),
+ hasDeclContext(objcCategoryImplDecl().bind("impl")))
+  .bind("dealloc"),
+  this);
+}
+
+void DeallocInCategoryCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *DeallocDecl = Result.Nodes.getNodeAs("dealloc");
+  const auto *CID = Result.Nodes.getNodeAs("impl");
+  assert(DeallocDecl != nullptr);
+  diag(DeallocDecl->getLocation(), "category %0 should not implement -dealloc")
+  << CID;
+}
+
+} // namespace objc
+} // namespace tidy
+} // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h 
b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
new file mode 100644
index ..f8e1f70e216b
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
@@ -0,0 +1,36 @@
+//===--- DeallocInCategoryCheck.h - clang-tidy --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_DEALLOCINCATEGORYCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_DEALLOCINCATEGORYCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds implementations of -dealloc in Objective-C categories. The category
+/// implementation will override any dealloc in the class implementation,
+/// potentially causing issues.
+///

[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5086b3803ac: [analyzer] StdLibraryFunctionsChecker 
refactor: remove macros (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897

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

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -9,7 +9,7 @@
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //
-// This checker provides a specification format - `FunctionSummaryTy' - and
+// This checker provides a specification format - `Summary' - and
 // contains descriptions of some library functions in this format. Each
 // specification contains a list of branches for splitting the program state
 // upon call, and range constraints on argument and return-value symbols that
@@ -21,7 +21,7 @@
 // consider standard C function `ispunct(int x)', which returns a non-zero value
 // iff `x' is a punctuation character, that is, when `x' is in range
 //   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
-// `FunctionSummaryTy' provides only two branches for this function. However,
+// `Summary' provides only two branches for this function. However,
 // any attempt to describe this range with if-statements in the body farm
 // would result in many more branches. Because each branch needs to be analyzed
 // independently, this significantly reduces performance. Additionally,
@@ -30,13 +30,13 @@
 // which may lead to false positives because considering this particular path
 // was not consciously intended, and therefore it might have been unreachable.
 //
-// This checker uses eval::Call for modeling "pure" functions, for which
-// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
-// invalidation passes. Conflicts with other checkers are unlikely because
-// if the function has no other effects, other checkers would probably never
-// want to improve upon the modeling done by this checker.
+// This checker uses eval::Call for modeling pure functions (functions without
+// side effets), for which their `Summary' is a precise model. This avoids
+// unnecessary invalidation passes. Conflicts with other checkers are unlikely
+// because if the function has no other effects, other checkers would probably
+// never want to improve upon the modeling done by this checker.
 //
-// Non-"pure" functions, for which only partial improvement over the default
+// Non-pure functions, for which only partial improvement over the default
 // behavior is expected, are modeled via check::PostCall, non-intrusively.
 //
 // The following standard C functions are currently supported:
@@ -64,49 +64,48 @@
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
-  struct FunctionSummaryTy;
+  struct Summary;
 
   /// Specify how much the analyzer engine should entrust modeling this function
   /// to us. If he doesn't, he performs additional invalidations.
-  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+  enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// A pair of ValueRangeKind and IntRangeVector would describe a range
   /// imposed on a particular argument or return value symbol.
   ///
   /// Given a range, should the argument stay inside or outside this range?
   /// The special `ComparesToArgument' value indicates that we should
   /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
+  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
 
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
-  typedef uint64_t RangeIntTy;
+  typedef uint64_t RangeInt;
 
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVector;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
   /// obviously uint32_t should be enough for all practical purposes.
-  typedef uint32_t ArgNoTy;
-  static const ArgNoTy Ret = std::numeric_limits::max();
+  typedef uint32_t ArgNo;

[PATCH] D72876: Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.

2020-02-10 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0151ddc2e834: Create a clang-tidy check to warn when 
-dealloc is implemented inside an ObjC… (authored by mwyman, committed by 
benhamilton).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72876

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
  clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.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-dealloc-in-category.rst
  clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s objc-dealloc-in-category %t
+
+@interface NSObject
+// Used to quash warning about missing base class.
+- (void)dealloc;
+@end
+
+@interface Foo : NSObject
+@end
+
+@implementation Foo
+- (void)dealloc {
+  // No warning should be generated here.
+}
+@end
+
+@interface Bar : NSObject
+@end
+
+@interface Bar (BarCategory)
+@end
+
+@implementation Bar (BarCategory)
++ (void)dealloc {
+  // Should not trigger on class methods.
+}
+
+- (void)dealloc {
+  // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: category 'BarCategory' should not implement -dealloc [objc-dealloc-in-category]
+}
+@end
+
+@interface Baz : NSObject
+@end
+
+@implementation Baz
+- (void)dealloc {
+  // Should not trigger on implementation in the class itself, even with
+  // it declared in the category (below).
+}
+@end
+
+@interface Baz (BazCategory)
+// A declaration in a category @interface does not by itself provide an
+// overriding implementation, and should not generate a warning.
+- (void)dealloc;
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-dealloc-in-category
+
+objc-dealloc-in-category
+
+
+Finds implementations of ``-dealloc`` in Objective-C categories. The category
+implementation will override any ``-dealloc`` in the class implementation,
+potentially causing issues.
+
+Classes implement ``-dealloc`` to perform important actions to deallocate
+an object. If a category on the class implements ``-dealloc``, it will
+override the class's implementation and unexpected deallocation behavior
+may occur.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -232,6 +232,7 @@
`mpi-buffer-deref `_, "Yes"
`mpi-type-mismatch `_, "Yes"
`objc-avoid-nserror-init `_,
+   `objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
`objc-missing-hash `_,
`objc-property-declaration `_, "Yes"
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -81,13 +81,18 @@
   ` check.
 
   Checks for usages of identifiers reserved for use by the implementation.
-  
+
 - New :doc:`cert-oop57-cpp
   ` check.
-  
+
   Flags use of the `C` standard library functions ``memset``, ``memcpy`` and
   ``memcmp`` and similar derivatives on non-trivial types.
 
+- New :doc:`objc-dealloc-in-category
+  ` check.
+
+  Finds implementations of -dealloc in Objective-C categories.
+
 New check aliases
 ^
 
@@ -111,8 +116,8 @@
 
 - Improved :doc:`readability-redundant-string-init
   ` check now supports a
-  `StringNames` option enabling its application to custom string classes. The 
-  check now detects in class initializers and constructor initializers which 
+  `StringNames` option enabling its application to custom string classes. The
+  check now detects in class initializers and constructor initializers which
   are deemed to be redundant.
 
 Renamed checks
Index: clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "AvoidNSErrorInitCheck.h"
+#include "DeallocInCategoryCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "MissingHashCheck.h"
 #include "P

[PATCH] D74262: [clang-offload-bundler] Enable handling of partially-linked fat objects

2020-02-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Partial linking may lead to some incorrect results with global constructors. 
How are you going to handle this?




Comment at: 
clang/test/Driver/clang-offload-bundler-missing-size-section.cpp:1-44
+// REQUIRES: x86-registered-target
+// RUN: %clangxx -c %s -o %t_fat.o
+// RUN: %clangxx %t_fat.o -o %t.exe
+// RUN: clang-offload-bundler -type=o 
-targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-pc-linux-gnu 
-outputs=%t_host.o,%t_device.o -inputs=%t_fat.o -unbundle
+// RUN: %t.exe %t_device.o | FileCheck %s
+// CHECK:11
+

Very strange test. It should not contain standard includes. Also, it should not 
be an executable test, you have to check for the driver output or something 
similar



Comment at: clang/test/Driver/clang-offload-bundler-oo.cpp:1-18
+// REQUIRES: x86-registered-target
+// RUN: %clangxx -c %s -o %t_fat.o
+// RUN: %clangxx %t_fat.o -o %t.exe
+// RUN: clang-offload-bundler -type=oo 
-targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-pc-linux-gnu 
-outputs=%t.o,%t_list.txt -inputs=%t_fat.o -unbundle
+// RUN: %t.exe %t_list.txt | FileCheck %s
+// CHECK:11
+// CHECK:222

Same about this test



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:84
"  o   - object\n"
+   "  oo  - object; output file is a list of unbundled 
objects\n"
"  gch - precompiled-header\n"

Hmm, are you going to introduce a new kind of output? It really requires RFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74262



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 243571.
baloghadamsoftware added a comment.

Only track the right container. Furthermore, minor updates according to the 
comments.


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -analyzer-output=text -verify
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -analyzer-output=text -verify
 
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
 
@@ -20,14 +20,16 @@
   V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
-  clang_analyzer_express(clang_analyzer_container_begin(V)); //expected-warning{{$V.begin()}}
+  clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
 }
 
 void end(const std::vector &V) {
   V.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
-  clang_analyzer_express(clang_analyzer_container_end(V)); //expected-warning{{$V.end()}}
+  clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end()}}
+   // expected-note@-1{{$V.end()}}
 }
 
 
@@ -48,8 +50,10 @@
   long B2 = clang_analyzer_container_begin(V2);
   long E2 = clang_analyzer_container_end(V2);
   V1 = std::move(V2);
-  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); //expected-warning{{TRUE}}
-  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); // expected-warning{{TRUE}}
+ // expected-note@-1{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); // expected-warning{{TRUE}}
+   // expected-note@-1{{TRUE}}
 }
 
 
@@ -63,6 +67,8 @@
 /// Design decision: extends containers to the ->RIGHT-> (i.e. the
 /// past-the-end position of the container is incremented).
 
+void clang_analyzer_dump(void*);
+
 void push_back(std::vector &V, int n) {
   V.cbegin();
   V.cend();
@@ -70,10 +76,13 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.push_back(n);
+  V.push_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+  // expected-note@-1{{Container 'V' extended to the right by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
   clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end() + 1}}
+   // expected-note@-1{{$V.end() + 1}}
 }
 
 /// emplace_back()
@@ -88,10 +97,14 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.emplace_back(n);
+  V.emplace_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+ // expected-note@-1{{Container 'V' extended to the right 

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 4 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:731
+  }
+  return C.getNoteTag([Text, Name](BugReport &BR) -> std::string {
+  SmallString<256> Msg;

Szelethus wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > Szelethus wrote:
> > > > NoQ wrote:
> > > > > baloghadamsoftware wrote:
> > > > > > NoQ wrote:
> > > > > > > You'll need to check whether the container is actually of 
> > > > > > > interest to the bug report. We don't want notes to be added about 
> > > > > > > changes to irrelevant containers.
> > > > > > > 
> > > > > > > You can use a combination of "Report `BR` was emitted by one of 
> > > > > > > the iterator checkers" and "The memory region of the container is 
> > > > > > > marked as interesting" (while also actually marking it as 
> > > > > > > interesting in the checker).
> > > > > > > 
> > > > > > > Ideally we should instead make a new generic storage inside the 
> > > > > > > `BugReport` object, in order to pass down the interesting 
> > > > > > > information from the call site of `emitReport` ("Hi, i'm an 
> > > > > > > iterator checker who emitted this report and i'm interested in 
> > > > > > > changes made to the size of this container").
> > > > > > Are you sure in this? I already wondered how it works so I added a 
> > > > > > test that checks one container and changes another one and there 
> > > > > > were no note tags displayed for the one we did not check but 
> > > > > > change. See the last test.
> > > > > That's because you didn't do
> > > > > ```lang=c++
> > > > >   V2.cbegin();
> > > > >   V2.cend();
> > > > > ```
> > > > > in the beginning.
> > > > A similar conversation sparked up recently in between @boga95, 
> > > > @steakhal and me regarding reporting taintedness. Bug reports are fine 
> > > > up to the point where (in reverse) the first propagation happens, but 
> > > > finding out which value tainted the one that caused the report isn't 
> > > > handled at the moment. One idea was to mark the initial (again, in 
> > > > reverse) value as interesting, create a `NoteTag` at the point of 
> > > > propagation, where we should know which value was the cause of the 
> > > > spread, mark that interesting as well, etc.
> > > > 
> > > > If `NoteTag`s only emit a message when the concerning value is 
> > > > interesting, this should theoretically solve that problem. I guess you 
> > > > could say that we're propagating interestingness in reverse.
> > > > 
> > > > I'm not immediately sure if this idea was ever mentioned or implemented 
> > > > here.
> > > Yes, that's the intended solution to such problems. 
> > > `trackExpressionValue` works similarly, just with assignments instead of 
> > > taint propagations. And in both cases note tags are a much more 
> > > straightforward solution to the problem.
> > Yes, you are right. My problem now is that how to mark interesting when 
> > debugging? I I filter for interesting containers only, I lose my ability to 
> > debug. Should I create a debug function just for marking a container as 
> > interesting. Or is there such function already?
> I'm not immediately sure how interetingness ties into debugging, what 
> specific scenario are you thinking about?
In the test of the modeling checker we use debug checkers. They should be able 
to mark the container interesting to be able to test the not tags. I managed to 
solve problem, even in a somewhat unorthodox way.


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

https://reviews.llvm.org/D73720



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-02-10 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D72675#1829866 , @hfinkel wrote:

> > I'm not sure whether this is deliberate (but it seems weird) or just a bug. 
> > I can ask the GCC developers ...
>
> Please do. If there's a rationale, we should know.


Sorry for the delay ... I've raised that question on the GCC list, and the 
opinion seems to be that the current behavior is indeed a bug -- however 
there's still discussion ongoing on what the proper fix ought to be.  I'll 
report back once we've agreed on a solution on the GCC side ...


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

https://reviews.llvm.org/D72675



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


[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2020-02-10 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM - the PS4 behavior was confirmed off-list.


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

https://reviews.llvm.org/D69979



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


[libunwind] 14798b4 - unwind: rename `__personality_routine` to `_Unwind_Personality_Fn`

2020-02-10 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-02-10T08:52:31-08:00
New Revision: 14798b44658c8b30b44afae20d0f391e88eb5bec

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

LOG: unwind: rename `__personality_routine` to `_Unwind_Personality_Fn`

This patch renames `__personality_routine` to `_Unwind_Personality_Fn`
in `unwind.h`. Both `unwind.h` from clang and GCC headers use this name
instead of `__personality_routine`. With this patch one is also able to
build libc++abi with libunwind support on Windows.

Patch by Markus Böck!

Added: 


Modified: 
libunwind/include/unwind.h
libunwind/src/Unwind-EHABI.cpp
libunwind/src/Unwind-seh.cpp
libunwind/src/Unwind-sjlj.c
libunwind/src/UnwindLevel1-gcc-ext.c
libunwind/src/UnwindLevel1.c

Removed: 




diff  --git a/libunwind/include/unwind.h b/libunwind/include/unwind.h
index b6cc70498b37..1d3444cd83b4 100644
--- a/libunwind/include/unwind.h
+++ b/libunwind/include/unwind.h
@@ -111,10 +111,9 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
 
-typedef _Unwind_Reason_Code (*__personality_routine)
-  (_Unwind_State state,
-   _Unwind_Exception* exceptionObject,
-   struct _Unwind_Context* context);
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
+_Unwind_State state, _Unwind_Exception *exceptionObject,
+struct _Unwind_Context *context);
 #else
 struct _Unwind_Context;   // opaque
 struct _Unwind_Exception; // forward declaration
@@ -150,12 +149,9 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
  struct _Unwind_Context* context,
  void* stop_parameter );
 
-typedef _Unwind_Reason_Code (*__personality_routine)
-  (int version,
-   _Unwind_Action actions,
-   uint64_t exceptionClass,
-   _Unwind_Exception* exceptionObject,
-   struct _Unwind_Context* context);
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
+int version, _Unwind_Action actions, uint64_t exceptionClass,
+_Unwind_Exception *exceptionObject, struct _Unwind_Context *context);
 #endif
 
 #ifdef __cplusplus
@@ -387,10 +383,9 @@ typedef struct _DISPATCHER_CONTEXT DISPATCHER_CONTEXT;
 #endif
 // This is the common wrapper for GCC-style personality functions with SEH.
 extern EXCEPTION_DISPOSITION _GCC_specific_handler(EXCEPTION_RECORD *exc,
-   void *frame,
-   CONTEXT *ctx,
+   void *frame, CONTEXT *ctx,
DISPATCHER_CONTEXT *disp,
-   __personality_routine pers);
+   _Unwind_Personality_Fn 
pers);
 #endif
 
 #ifdef __cplusplus

diff  --git a/libunwind/src/Unwind-EHABI.cpp b/libunwind/src/Unwind-EHABI.cpp
index a23ba2cc7e0e..a8a64cbfd7e5 100644
--- a/libunwind/src/Unwind-EHABI.cpp
+++ b/libunwind/src/Unwind-EHABI.cpp
@@ -481,8 +481,8 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, 
_Unwind_Exception *except
 // If there is a personality routine, ask it if it will want to stop at
 // this frame.
 if (frameInfo.handler != 0) {
-  __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  _Unwind_Personality_Fn p =
+  (_Unwind_Personality_Fn)(long)(frameInfo.handler);
   _LIBUNWIND_TRACE_UNWINDING(
   "unwind_phase1(ex_ojb=%p): calling personality function %p",
   static_cast(exception_object),
@@ -597,8 +597,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, 
unw_cursor_t *cursor
 
 // If there is a personality routine, tell it we are unwinding.
 if (frameInfo.handler != 0) {
-  __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  _Unwind_Personality_Fn p =
+  (_Unwind_Personality_Fn)(long)(frameInfo.handler);
   struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor);
   // EHABI #7.2
   exception_object->pr_cache.fnstart = frameInfo.start_ip;

diff  --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp
index 7647f2e0db0b..403ab2d77110 100644
--- a/libunwind/src/Unwind-seh.cpp
+++ b/libunwind/src/Unwind-seh.cpp
@@ -69,7 +69,7 @@ static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor,
 ///  b) Initiate a collided unwind to halt unwinding.
 _LIBUNWIND_EXPORT EXCEPTION_DISPOSITION
 _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
-  DISPATCHER_CONTEXT *disp, __personality_routine pers) {
+  DISPATCHER_CONTEXT *disp, _Unwind_Personality_Fn pers) {
   unw_cursor_t cur

[PATCH] D74332: [ARM,MVE] Add intrinsics for int <-> float conversion.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This adds the unpredicated versions of the family of vcvtq intrinsics
that convert between a vector of floats and a vector of the same size
of integer. These are represented in IR using the standard fptosi,
fptoui, sitofp and uitofp operations, which existing LLVM codegen
already handles.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74332

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vcvt.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
@@ -4,6 +4,102 @@
 
 #include 
 
+// CHECK-LABEL: @test_vcvtq_f16_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f16_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_u32(uint32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_u32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_s16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vcvtq_s16_f16(float16x8_t a)
+{
+return vcvtq_s16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_s32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vcvtq_s32_f32(float32x4_t a)
+{
+return vcvtq_s32_f32(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vcvtq_u16_f16(float16x8_t a)
+{
+return vcvtq_u16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vcvtq_u32_f32(float32x4_t a)
+{
+return vcvtq_u32_f32(a);
+}
+
 // CHECK-LABEL: @test_vcvttq_f16_f32(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.arm.mve.vcvt.narrow(<8 x half> [[A:%.*]], <4 x float> [[B:%.*]], i32 1)
Index: clang/include/clang/Basic/arm_mve_defs.td
===
--- clang/include/clang/Basic/arm_mve_defs.td
+++ clang/include/clang/Basic/arm_mve_defs.td
@@ -121,6 +121,10 @@
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;
+def sitofp: IRBuilder<"CreateSIToFP">;
+def uitofp: IRBuilder<"CreateUIToFP">;
+def fptosi: IRBuilder<"CreateFPToSI">;
+def fptoui: IRBuilder<"CreateFPToUI">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.
Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -332,6 +332,23 @@
   } // params = [f32], pnt = PNT_None
 } // loop over half = "b", "t"
 
+multiclass float_int_conversions {
+  defvar FVector = VecOf;
+  defvar IVector = VecOf;
+
+  let params = [IScalar], pnt = PNT_2Type in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # FScalar>;
+  let params = [FScalar], pnt = PNT_None in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # IScalar>;
+}
+
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float

[PATCH] D74334: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q family.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

These intrinsics just reorder the lanes of a vector, so the natural IR
representation is as a shufflevector operation. Existing LLVM codegen
already recognizes those particular shufflevectors and generates the
MVE VREV instruction.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74334

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vrev.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vrev.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrev.c
@@ -0,0 +1,215 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrev16q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev16q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev16q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev16q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev32q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev32q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vrev32q_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vrev32q_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x half> [[A:%.*]], <8 x half> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrev32q_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev64q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev64q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 

[PATCH] D74333: [ARM,MVE] Add intrinsics for FP rounding operations.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

This adds the unpredicated forms of six different MVE intrinsics which
all round a vector of floating-point numbers to integer values,
leaving them still in FP format, differing only in rounding mode and
exception settings.

Five of them map to existing target-independent intrinsics in LLVM IR,
such as @llvm.trunc and @llvm.rint. The sixth, mapping to the `vrintn`
instruction, is done by inventing a target-specific intrinsic.

(`vrintn` behaves the same as `vrintx` in terms of the output value:
the side effects on the FPSCR flags are the only difference between
the two. But ACLE specifies separate user-callable intrinsics for the
two, so the side effects matter enough to make sure we generate the
right one of the two instructions in each case.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74333

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vrndnq_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vrndnq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half> %a)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vrndnq_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vrndnq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float> %a)
+  ret <4 x float> %0
+}
+
+declare <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half>)
+declare <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3179,6 +3179,10 @@
 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
   def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
+  def : Pat<(v4f32 (int_arm_mve_vrintn (v4f32 MQPR:$val1))),
+(v4f32 (MVE_VRINTf32N (v4f32 MQPR:$val1)))>;
+  def : Pat<(v8f16 (int_arm_mve_vrintn (v8f16 MQPR:$val1))),
+(v8f16 (MVE_VRINTf16N (v8f16 MQPR:$val1)))>;
 }
 
 class MVEFloatArithNeon, llvm_anyvector_ty>;
+
+def int_arm_mve_vrintn: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
@@ -0,0 +1,173 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrndaq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.round.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndaq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndaq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.round.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndaq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.floor.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndmq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrn

[PATCH] D74335: [ARM,MVE] Add intrinsics vclzq and vclsq.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

vclzq maps nicely to the existing target-independent @llvm.ctlz IR
intrinsic. But vclsq ('count leading sign bits') has no corresponding
target-independent intrinsic, so I've made up @llvm.arm.mve.vcls.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74335

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vclz.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vclsq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vclsq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8> %a)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vclsq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vclsq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vclsq_s32(<4 x i32> %a) {
+; CHECK-LABEL: test_vclsq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32> %a)
+  ret <4 x i32> %0
+}
+
+declare <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8>)
+declare <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16>)
+declare <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -2076,6 +2076,13 @@
 (v4i32 ( MVE_VCLZs32 (v4i32 MQPR:$val1)))>;
   def : Pat<(v8i16 ( ctlz (v8i16 MQPR:$val1))),
 (v8i16 ( MVE_VCLZs16 (v8i16 MQPR:$val1)))>;
+
+  def : Pat<(v16i8 ( int_arm_mve_vcls (v16i8 MQPR:$val1))),
+(v16i8 ( MVE_VCLSs8 (v16i8 MQPR:$val1)))>;
+  def : Pat<(v4i32 ( int_arm_mve_vcls (v4i32 MQPR:$val1))),
+(v4i32 ( MVE_VCLSs32 (v4i32 MQPR:$val1)))>;
+  def : Pat<(v8i16 ( int_arm_mve_vcls (v8i16 MQPR:$val1))),
+(v8i16 ( MVE_VCLSs16 (v8i16 MQPR:$val1)))>;
 }
 
 class MVE_VABSNEG_int size, bit negate,
Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1161,5 +1161,7 @@
 
 def int_arm_mve_vrintn: Intrinsic<
   [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+def int_arm_mve_vcls: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
 
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vclz.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vclz.c
@@ -0,0 +1,132 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vclzq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vclzq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vclzq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x 

[PATCH] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me, just a nit about one of the comments.

Thanks for making this easier to review by splitting it up!




Comment at: llvm/include/llvm/Support/Process.h:205
+
+  /// When integrated-cc1 is disabled, terminate the current program.
+  /// When integrated-cc1 is enabled, terminates execution of the current

Could the comment be phrased in terms of CrashRecoveryContext instead of 
integrated-cc1, which is a Clang thing?


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

https://reviews.llvm.org/D73742



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


[PATCH] D74331: [ARM,MVE] Add intrinsics for abs, neg and not operations.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This commit adds the unpredicated intrinsics for the unary operations
vabsq (absolute value), vnegq (arithmetic negation), vmvnq (bitwise
complement), vqabsq and vqnegq (saturating versions of abs and neg for
signed integers, in the sense that they give INT_MAX if an input lane
is INT_MIN).

This is done entirely in clang: all of these operations have existing
isel patterns and existing tests for them on the LLVM side, so I've
just made clang emit the same IR that those patterns already match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74331

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/absneg.c

Index: clang/test/CodeGen/arm-mve-intrinsics/absneg.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/absneg.c
@@ -0,0 +1,338 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vabsq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vabsq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.fabs.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vabsq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <16 x i8> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <16 x i8> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP0]], <16 x i8> [[TMP1]], <16 x i8> [[A]]
+// CHECK-NEXT:ret <16 x i8> [[TMP2]]
+//
+int8x16_t test_vabsq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <8 x i16> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <8 x i16> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP0]], <8 x i16> [[TMP1]], <8 x i16> [[A]]
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+int16x8_t test_vabsq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <4 x i32> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <4 x i32> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP0]], <4 x i32> [[TMP1]], <4 x i32> [[A]]
+// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+//
+int32x4_t test_vabsq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vmvnq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i16> [[A:%.*]], 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vmvnq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <4 x i32> [[A:%.*]], 
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vmvnq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_u8(
+// CHECK-NEXT:  e

[PATCH] D74336: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These intrinsics take a vector of 2n elements, and return a vector of
n wider elements obtained by sign- or zero-extending every other
element of the input vector. They're represented in IR as a
shufflevector that extracts the odd or even elements of the input,
followed by a sext or zext.

Existing LLVM codegen already matches this pattern and generates the
VMOVLB instruction (which widens the even-index input lanes). But no
existing isel rule was generating VMOVLT, so I've added some. However,
the new rules currently only work in little-endian MVE, because the
pattern they expect from isel lowering includes a bitconvert which
doesn't have the right semantics in big-endian.

The output of one existing codegen test is improved by those new
rules.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74336

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
  llvm/test/CodeGen/Thumb2/mve-shuffleext.ll

Index: llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
===
--- llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
+++ llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
@@ -15,8 +15,7 @@
 define arm_aapcs_vfpcc <4 x i32> @sext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: sext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -38,8 +37,7 @@
 define arm_aapcs_vfpcc <4 x i32> @zext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: zext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -61,8 +59,7 @@
 define arm_aapcs_vfpcc <8 x i16> @sext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: sext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:vmovlt.s8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
@@ -84,8 +81,7 @@
 define arm_aapcs_vfpcc <8 x i16> @zext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: zext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:vmovlt.u8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
@@ -0,0 +1,90 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovlbq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = sext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovlbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = sext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_u8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovlbq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = zext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_u16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovlbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = zext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovltq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovltq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlt.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector 

[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These are in some sense the inverse of vmovl[bt]q: they take a vector
of n wide elements and truncate each to half its width. So they only
write half a vector's worth of output data, and therefore they also
take an 'inactive' parameter to provide the other half of the data in
the output vector. So vmovnb overwrites the even lanes of 'inactive'
with the narrowed values from the main input, and vmovnt overwrites
the odd lanes.

LLVM had existing codegen which generates these MVE instructions in
response to IR that takes two vectors of wide elements, or two vectors
of narrow ones. But in this case, we have one vector of each. So my
clang codegen strategy is to narrow the input vector of wide elements
by simply reinterpreting it as the output type, and then we have two
narrow vectors and can represent the operation as a vector shuffle
that interleaves lanes from both of them.

Even so, not all the cases I needed ended up being selected as a
single MVE instruction, so I've added a couple more patterns that spot
combinations of the 'MVEvmovn' and 'ARMvrev32' SDNodes which can be
generated as a VMOVN instruction with operands swapped.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74337

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovnbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = bitcast <16 x i8> %0 to <8 x i16>
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovnbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = bitcast <8 x i16> %0 to <4 x i32>
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovnbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = bitcast <16 x i8> %0 to <8 x i16>
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovnbq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = bitcast <8 x i16> %0 to <4 x i32>
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovntq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <16 x i8> %a to <8 x i16>
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovntq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <8 x i16> %a to <4 x i32>
+  %1 = shufflevector <4 x i32> %0, <4 x i32> %b, <8 x i32> 
+  %2 = trunc <8 x i32> %1 to <8 x i16>
+  ret <8 x i16> %2
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovntq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <16 x i8> 

[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava added a comment.

In D71600#1867135 , @efriedma wrote:

> For the clang change, we should do something like D72579 
> , not explicitly check for a specific target 
> in target-independent code.


right, I'll retest everything using D72579 .

> For compiler-rt, are you really disabling COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN? 
>  Are you sure you understand the implications of that?

I didn't  understood "disable COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN", it's not 
intentional. 
If it's the change around atomic.c:131, what I expect is make IS_LOCK_FREE_8 
return false. I don't want it to make to __c11_atomic_is_lock_free(8) as it 
generates code that should be linked with a libatomic at run time.

> I'm also curious: what part of clang is calling __atomic_is_lock_free?  I 
> can't find any code in LLVM that calls it.

hm, I'm afraid I was not clear in this. When generating FreeBSD images, the 
libc cross-compiled by unpatched clang gets an entry to external call to 
__c11_atomic_is_lock_free(). Then, in the resulting system (new sysroot) I get 
this problem (libatomic dependency) when trying to build clang itself.
While testing with D72579  I'll try reproduce 
it again and will post more info here since I don't have the build logs anymore 
(I investigated it ~6 months ago).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

2020-02-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus closed this revision.
Szelethus added a comment.

Cheers!


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

https://reviews.llvm.org/D73966



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


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 243595.
dgoldman marked 3 inline comments as done.
dgoldman added a comment.

- Fixes for tests and InputFiles


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  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
@@ -616,6 +616,52 @@
   ASSERT_FALSE(DoUpdate(OtherSourceContents));
 }
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  auto Source = testPath("foo.cpp");
+  auto Header = testPath("foo.h");
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+)cpp";
+
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild,
+  llvm::unique_function)> CB) {
+ParseInputs Inputs = getInputs(Source, std::string(Contents));
+Inputs.ForceRebuild = ForceRebuild;
+updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes, std::move(CB));
+  };
+
+  // Update the source contents, which should trigger an initial build with
+  // the header file missing.
+  DoUpdate(SourceContents, /*ForceRebuild*/false, [](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.
+  Files[Header] = "int a;";
+  Timestamps[Header] = time_t(1);
+
+  // The addition of the missing header file shouldn't trigger a rebuild since
+  // we don't track missing files.
+  DoUpdate(SourceContents, /*ForceRebuild*/false, [](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.
+  DoUpdate(SourceContents, /*ForceRebuild*/true, [](std::vector Diags) {
+EXPECT_THAT(Diags, IsEmpty());
+  });
+
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
 
@@ -722,7 +768,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
@@ -746,7 +793,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -436,7 +436,8 @@
 }
 
 std::shared_ptr OldPreamble =
-getPossiblyStalePreamble();
+Inputs.ForceRebuild ? std::shared_ptr()
+: getPossiblyStalePreamble();
 std::shared_ptr NewPreamble = buildPreamble(
 FileName, *Invocation, OldPreamble, OldCommand, Inputs,
 StorePreambleInMemory,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -652,6 +652,12 @@
   /// either they will be provided for this version or some subsequent one.
   /// This is a clangd extension.
   llvm::Optional wantDiagnostics;
+
+  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
+  /// This is useful to defeat clangd's assumption that missing headers will
+  /// stay missing.
+  /// This is a clangd extension.
+  bool forceRebuild = false;
 };
 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -430,7 +430,10 @@
 
 bool fromJSON(const llvm::json::Value &

[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 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.

LG, thanks! Just a nit about further simplifying the test, up to you.




Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:630
+
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild,
+  llvm::unique_function)> CB) {

this still feels just a bit obfuscated, what about more directly:

```
ParseInputs I = getInputs(Source, SourceContents);
updateWithDiags(..., I, [] { ... });
Files[Header] = ...;
updateWithDiags(...);
I.ForceRebuild = true;
updateWithDiags(...);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-10 Thread Aaron Ballman via cfe-commits
On Mon, Feb 10, 2020 at 10:06 AM John Marshall
 wrote:
>
> Thanks Aaron (and Hubert).
>
> I've attached an updated patch that now includes new test cases alongside 
> some existing "too few / too many" test cases in test/Sema/exprs.c. This 
> splits the function declaration over two lines so it can use -verify to 
> validate the source location's line (but not column). If you'd prefer a 
> FileCheck approach to get the column too, I'm happy to do that but please 
> advise whether it would be best to create a new test/Sema/foo.c file for 
> these tests or to add to one of the existing test files.
>
> Verified that without the patch, the notes are on the "MY_EXPORT void" line 
> and the test cases fail. All tests still pass after this, after adjusting one 
> existing FileCheck-based test case that also happens to exercise the patch's 
> change.

Thank you for the patch -- I think it is fine to not check the column
for the cases you've added, so this iteration LGTM. I'm happy to
commit this on your behalf, but it will have to wait until next week
because I'm out at wg21 meetings this week. If no one else commits
this before I get home, I'll handle it then.

~Aaron

>
> John
>
>
> On 7 Feb 2020, at 15:40, Aaron Ballman wrote:
> > Thank you for the patch -- I think the changes look reasonable, but it
> > should come with some test cases as well. Source location stuff is a
> > bit onerous to try to test, but I think the best approach would be to
> > add a new test that uses FileCheck instead of -verify so that you can
> > validate the source location's line and column are as expected in the
> > note. Once you have such a test (and have verified that no other tests
> > fail with your changes), I'm happy to commit on your behalf.
> >
> > ~Aaron
> >
> > On Fri, Feb 7, 2020 at 10:23 AM Hubert Tong
> >  wrote:
> >>
> >> I think this looks okay. I think Richard or Aaron might be able to provide 
> >> a more informed opinion.
> >>
> >> -- HT
>
>
> commit cbd4a4a155b40dc77c2ed82f397fe303dfc10837
> Author: John Marshall 
> AuthorDate: Mon Jan 20 14:58:14 2020 +
> Commit: John Marshall 
> CommitDate: Mon Feb 10 14:30:58 2020 +
>
> Use getLocation() in "too few/too many arguments" diagnostic
>
> Use the more accurate location when emitting the location of the
> function being called's prototype in diagnostics emitted when calling
> a function with an incorrect number of arguments.
>
> In particular, avoids showing a trace of irrelevant macro expansions
> for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.
>
> Add test cases alongside other "too few/too many arguments" tests.
> Adjust column position in incidentally related FileCheck-based test.
>
> diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
> index ffe72c98356..b9d7024f083 100644
> --- a/clang/lib/Sema/SemaExpr.cpp
> +++ b/clang/lib/Sema/SemaExpr.cpp
> @@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
>
>// Emit the location of the prototype.
>if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
> -Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
> +Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
>
>return true;
>  }
> @@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
>
>// Emit the location of the prototype.
>if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
> -Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
> +Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
>
>// This deletes the extra arguments.
>Call->shrinkNumArgs(NumParams);
> diff --git a/clang/test/Misc/serialized-diags.c 
> b/clang/test/Misc/serialized-diags.c
> index e401477a2eb..2f4b86fb42f 100644
> --- a/clang/test/Misc/serialized-diags.c
> +++ b/clang/test/Misc/serialized-diags.c
> @@ -56,7 +56,7 @@ void rdar11040133() {
>  // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 
> {{.*[/\\]}}serialized-diags.c:22:18
>  // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 
> 'false' []
>  // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 
> {{.*[/\\]}}serialized-diags.c:20:16
> -// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
> +// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here []
>  // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer 
> to pointer conversion initializing 'char *' with an expression of type 'int' 
> [-Wint-conversion]
>  // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 
> {{.*[/\\]}}serialized-diags.h:5:17
>  // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from 
> {{.*[/\\]}}serialized-diags.c:26: []
> diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
> index 760c45e02f3..4e144041aca 100644
> --- a/clang/test/Sema/exprs.c
> +++ b/clang/test/Sema

[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-10 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram added a comment.

In D68049#1865967 , @MaskRay wrote:

> If you don't mind, I can push a Diff to this Differential which will address 
> these review comments.


Let me update this patch asap as we refactored getBBSectionsList into llvm as 
it is shared by llc, clang and lld.


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

https://reviews.llvm.org/D68049



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


[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-10 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 243614.
tmsriram marked 3 inline comments as done.
tmsriram added a comment.

Removed getBBSectionsList (moved to LLVM) and address other reviewer comments.


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

https://reviews.llvm.org/D68049

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/basicblock-sections.c

Index: clang/test/CodeGen/basicblock-sections.c
===
--- /dev/null
+++ clang/test/CodeGen/basicblock-sections.c
@@ -0,0 +1,47 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -fbasicblock-sections=none -o - < %s | FileCheck %s --check-prefix=PLAIN
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=labels -o - < %s | FileCheck %s --check-prefix=BB_LABELS
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_ALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=%S/basicblock-sections.funcnames -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -funique-bb-section-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
+
+int world(int a) {
+  if (a > 10)
+return 10;
+  else if (a > 5)
+return 5;
+  else
+return 0;
+}
+
+int another(int a) {
+  if (a > 10)
+return 20;
+  return 0;
+}
+
+// PLAIN-NOT: section
+// PLAIN: world
+//
+// BB_LABELS-NOT: section
+// BB_LABELS: world
+// BB_LABELS-LABEL: a.BB.world
+// BB_LABELS-LABEL: aa.BB.world
+// BB_LABEL-LABEL: a.BB.another
+//
+// BB_WORLD: .section .text.world,"ax",@progbits
+// BB_WORLD: world
+// BB_WORLD: .section .text.world,"ax",@progbits,unique
+// BB_WORLD: a.BB.world
+// BB_WORLD: .section .text.another,"ax",@progbits
+// BB_ALL: .section .text.another,"ax",@progbits,unique
+// BB_ALL: a.BB.another
+// BB_LIST-NOT: .section .text.another,"ax",@progbits,unique
+// BB_LIST: another
+// BB_LIST-NOT: a.BB.another
+//
+// UNIQUE: .section .text.world.a.BB.world
+// UNIQUE: .section .text.another.a.BB.another
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -962,10 +962,24 @@
   Opts.TrapFuncName = std::string(Args.getLastArgValue(OPT_ftrap_function_EQ));
   Opts.UseInitArray = !Args.hasArg(OPT_fno_use_init_array);
 
-  Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
+  Opts.BBSections =
+  std::string(Args.getLastArgValue(OPT_fbasicblock_sections_EQ, "none"));
+  if (Opts.BBSections != "all" && Opts.BBSections != "labels" &&
+  Opts.BBSections != "none" && !llvm::sys::fs::exists(Opts.BBSections)) {
+Diags.Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fbasicblock_sections_EQ)->getAsString(Args)
+<< Opts.BBSections;
+  }
+
+  // Basic Block Sections implies Function Sections.
+  Opts.FunctionSections =
+  Args.hasArg(OPT_ffunction_sections) ||
+  (Opts.BBSections != "none" && Opts.BBSections != "labels");
+
   Opts.DataSections = Args.hasArg(OPT_fdata_sections);
   Opts.StackSizeSection = Args.hasArg(OPT_fstack_size_section);
   Opts.UniqueSectionNames = !Args.hasArg(OPT_fno_unique_section_names);
+  Opts.UniqueBBSectionNames = Args.hasArg(OPT_funique_bb_section_names);
 
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4202,8 +4202,11 @@
 options::OPT_fno_function_sections,
 options::OPT_fdata_sections,
 options::OPT_fno_data_sections,
+options::OPT_fbasicblock_sections_EQ,
 options::OPT_funique_section_names,
 options::OPT_fno_unique_section_names,
+options::OPT_funique_bb_section_names,
+options::OPT_fno_unique_bb_section_names,
 options::OPT_mrestrict_it,
 options::OPT_mno_restrict_it,
 options::OPT_mstackrealign,
@@ -4758,6 +4761,11 @@
 CmdArgs.push_back("-ffunction-sections");
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fbasicblock_sections_EQ)) {
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-fbasicblock-sections=") + A->getValue()));
+  }
+
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
UseSeparateS

[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 243619.
dgoldman added a comment.

- Minor test fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  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
@@ -616,6 +616,53 @@
   ASSERT_FALSE(DoUpdate(OtherSourceContents));
 }
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  auto Source = testPath("foo.cpp");
+  auto Header = testPath("foo.h");
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+)cpp";
+
+  ParseInputs Inputs = getInputs(Source, SourceContents);
+
+  // 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'")));
+  });
+
+  // Add the header file. We need to recreate the inputs since we changed a
+  // file from underneath the test FS.
+  Files[Header] = "int a;";
+  Timestamps[Header] = time_t(1);
+  Inputs = getInputs(Source, SourceContents);
+
+  // 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";
+  });
+
+  // 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());
+  });
+
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
 
@@ -722,7 +769,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
@@ -746,7 +794,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -436,7 +436,8 @@
 }
 
 std::shared_ptr OldPreamble =
-getPossiblyStalePreamble();
+Inputs.ForceRebuild ? std::shared_ptr()
+: getPossiblyStalePreamble();
 std::shared_ptr NewPreamble = buildPreamble(
 FileName, *Invocation, OldPreamble, OldCommand, Inputs,
 StorePreambleInMemory,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -652,6 +652,12 @@
   /// either they will be provided for this version or some subsequent one.
   /// This is a clangd extension.
   llvm::Optional wantDiagnostics;
+
+  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
+  /// This is useful to defeat clangd's assumption that missing headers will
+  /// stay missing.
+  /// This is a clangd extension.
+  bool forceRebuild = false;
 };
 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -430,7 +430,10 @@
 
 bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R) {
   llvm

[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked 2 inline comments as done.
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:630
+
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild,
+  llvm::unique_function)> CB) {

sammccall wrote:
> this still feels just a bit obfuscated, what about more directly:
> 
> ```
> ParseInputs I = getInputs(Source, SourceContents);
> updateWithDiags(..., I, [] { ... });
> Files[Header] = ...;
> updateWithDiags(...);
> I.ForceRebuild = true;
> updateWithDiags(...);
> ```
still needed to recreate ParseInputs but done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-02-10 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb created this revision.
broadwaylamb added reviewers: vvereschaka, aorlov, andreil99.
Herald added subscribers: cfe-commits, ldionne, kristof.beyls, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: clang.

D69169 , which was necessary for running 
libc++ tests on remote host, got reverted. I couldn't think of a less invasive 
way to achieve this behavior but specify libc++abi paths in our cache file.

I was wondering though if the assumptions I made in this patch regarding 
directory layout always hold.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74347

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b50431d - fix some typos to cycle bots

2020-02-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-02-10T13:51:23-05:00
New Revision: b50431defbaf80c254244cefdce3813576633ae5

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

LOG: fix some typos to cycle bots

Added: 


Modified: 
clang/docs/Block-ABI-Apple.rst
clang/docs/LanguageExtensions.rst
clang/docs/SourceBasedCodeCoverage.rst

Removed: 




diff  --git a/clang/docs/Block-ABI-Apple.rst b/clang/docs/Block-ABI-Apple.rst
index 0cc14a35b033..d038cdfe9bd2 100644
--- a/clang/docs/Block-ABI-Apple.rst
+++ b/clang/docs/Block-ABI-Apple.rst
@@ -63,7 +63,7 @@ The following flags bits are in use thusly for a possible 
ABI.2010.3.16:
 enum {
 // Set to true on blocks that have captures (and thus are not true
 // global blocks) but are known not to escape for various other
-// reasons. For backward compatiblity with old runtimes, whenever
+// reasons. For backward compatibility with old runtimes, whenever
 // BLOCK_IS_NOESCAPE is set, BLOCK_IS_GLOBAL is set too. Copying a
 // non-escaping block returns the original block and releasing such a
 // block is a no-op, which is exactly how global blocks are handled.

diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 9af49e3a60d7..adef8bb433a1 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2145,7 +2145,7 @@ Checked Arithmetic Builtins
 ---
 
 Clang provides a set of builtins that implement checked arithmetic for security
-critical applications in a manner that is fast and easily expressable in C. As
+critical applications in a manner that is fast and easily expressible in C. As
 an example of their usage:
 
 .. code-block:: c
@@ -2538,7 +2538,7 @@ pointers and integers.
 These builtins can be used to avoid relying on implementation-defined behavior
 of arithmetic on integers derived from pointers.
 Additionally, these builtins retain type information and, unlike bitwise
-arithmentic, they can perform semantic checking on the alignment value.
+arithmetic, they can perform semantic checking on the alignment value.
 
 **Syntax**:
 

diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 1575e4faaa01..0e9c364fbf6b 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -107,14 +107,14 @@ relies on padding and the ability to map a file over the 
existing memory
 mapping which is generally only available on POSIX systems and isn't suitable
 for other platforms.
 
-On Fuchsia, we rely on the the ability to relocate counters at runtime using a
+On Fuchsia, we rely on the ability to relocate counters at runtime using a
 level of indirection. On every counter access, we add a bias to the counter
 address. This bias is stored in ``__llvm_profile_counter_bias`` symbol that's
 provided by the profile runtime and is initially set to zero, meaning no
-relocation. The runtime can map the profile into memory at abitrary location,
+relocation. The runtime can map the profile into memory at arbitrary locations,
 and set bias to the offset between the original and the new counter location,
 at which point every subsequent counter access will be to the new location,
-which allows updating profile directly akin to the continous mode.
+which allows updating profile directly akin to the continuous mode.
 
 The advantage of this approach is that doesn't require any special OS support.
 The disadvantage is the extra overhead due to additional instructions required



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


[clang-tools-extra] 6ff0228 - [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2020-02-10T14:02:02-05:00
New Revision: 6ff0228c6df37e052fa6e8e3927e83b289402cf6

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

LOG: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

Summary:
- This option forces a preamble rebuild to handle the odd case
  of a missing header file being added

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, 
kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 880359f21dda..93609a8852db 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -647,7 +647,7 @@ void ClangdLSPServer::onDocumentDidChange(
 return;
   }
 
-  Server->addDocument(File, *Contents, WantDiags);
+  Server->addDocument(File, *Contents, WantDiags, Params.forceRebuild);
 }
 
 void ClangdLSPServer::onFileEvent(const DidChangeWatchedFilesParams &Params) {

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 3e22a4dfe667..48cf921ff18c 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -170,7 +170,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
 }
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
-   WantDiagnostics WantDiags) {
+   WantDiagnostics WantDiags, bool ForceRebuild) {
   auto FS = FSProvider.getFileSystem();
 
   ParseOptions Opts;
@@ -184,6 +184,7 @@ void ClangdServer::addDocument(PathRef File, 
llvm::StringRef Contents,
   ParseInputs Inputs;
   Inputs.FS = FS;
   Inputs.Contents = std::string(Contents);
+  Inputs.ForceRebuild = ForceRebuild;
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;
   bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 3c3505295a75..5156520e2d07 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -172,7 +172,8 @@ class ClangdServer {
   /// separate thread. When the parsing is complete, DiagConsumer passed in
   /// constructor will receive onDiagnosticsReady callback.
   void addDocument(PathRef File, StringRef Contents,
-   WantDiagnostics WD = WantDiagnostics::Auto);
+   WantDiagnostics WD = WantDiagnostics::Auto,
+   bool ForceRebuild = false);
 
   /// Get the contents of \p File, which should have been added.
   llvm::StringRef getDocument(PathRef File) const;

diff  --git a/clang-tools-extra/clangd/Compiler.h 
b/clang-tools-extra/clangd/Compiler.h
index 51414c37fc04..356293b158f8 100644
--- a/clang-tools-extra/clangd/Compiler.h
+++ b/clang-tools-extra/clangd/Compiler.h
@@ -45,6 +45,9 @@ struct ParseInputs {
   tooling::CompileCommand CompileCommand;
   IntrusiveRefCntPtr FS;
   std::string Contents;
+  // Prevent reuse of the cached preamble/AST. Slow! Useful to workaround
+  // clangd's assumption that missing header files will stay missing.
+  bool ForceRebuild = false;
   // Used to recover from diagnostics (e.g. find missing includes for symbol).
   const SymbolIndex *Index = nullptr;
   ParseOptions Opts;

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index aabf0fa11d45..d607ffbbc815 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -430,7 +430,10 @@ bool fromJSON(const llvm::json::Value &Params, 
DidCloseTextDocumentParams &R) {
 
 bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R) 
{
   llvm::json::ObjectMapper O(Params);
-  return O && O.map("textDocument", R.textDocument) &&
+  if (!O)
+return false;
+  O.map("forceRebuild", R.forceRebuild);  // Optional clangd extension.
+  return O.map("textDocument", R.textDocument) &&
  O.map("contentChanges", R.contentChanges) &&
  O.map("wantDiagnostics", R.wantDiagnostics);
 }

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 255629f0a0ec..3275cbbd17b1 100644
--- 

[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dgoldman marked an inline comment as done.
Closed by commit rG6ff0228c6df3: [clang] Add `forceReload` clangd extension to 
'textDocument/didChange' (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  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
@@ -616,6 +616,53 @@
   ASSERT_FALSE(DoUpdate(OtherSourceContents));
 }
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  auto Source = testPath("foo.cpp");
+  auto Header = testPath("foo.h");
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+)cpp";
+
+  ParseInputs Inputs = getInputs(Source, SourceContents);
+
+  // 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'")));
+  });
+
+  // Add the header file. We need to recreate the inputs since we changed a
+  // file from underneath the test FS.
+  Files[Header] = "int a;";
+  Timestamps[Header] = time_t(1);
+  Inputs = getInputs(Source, SourceContents);
+
+  // 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";
+  });
+
+  // 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());
+  });
+
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
 
@@ -722,7 +769,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
@@ -746,7 +794,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -436,7 +436,8 @@
 }
 
 std::shared_ptr OldPreamble =
-getPossiblyStalePreamble();
+Inputs.ForceRebuild ? std::shared_ptr()
+: getPossiblyStalePreamble();
 std::shared_ptr NewPreamble = buildPreamble(
 FileName, *Invocation, OldPreamble, OldCommand, Inputs,
 StorePreambleInMemory,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -652,6 +652,12 @@
   /// either they will be provided for this version or some subsequent one.
   /// This is a clangd extension.
   llvm::Optional wantDiagnostics;
+
+  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
+  /// This is useful to defeat clangd's assumption that missing headers will
+  /// stay missing.
+  /// This is a clangd extension.
+  bool forceRebuild = false;
 };
 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
++

[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

> Do you know why it's started failing now?

Not quite, probably a gcc update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129



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


[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-10 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3185c30c54d0: Prefer __vector over vector keyword for 
altivec (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D74129?vs=242902&id=243641#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129

Files:
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2552,8 +2552,8 @@
 '/', '/', '/', '/',  '/', '/', '/', '/',
 '/', '/', '/', '/',  '/', '/', '/', '/'
   };
-  while (CurPtr+16 <= BufferEnd &&
- !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))
+  while (CurPtr + 16 <= BufferEnd &&
+ !vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes))
 CurPtr += 16;
 #else
   // Scan for '/' quickly.  Many block comments are very large.


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2552,8 +2552,8 @@
 '/', '/', '/', '/',  '/', '/', '/', '/',
 '/', '/', '/', '/',  '/', '/', '/', '/'
   };
-  while (CurPtr+16 <= BufferEnd &&
- !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))
+  while (CurPtr + 16 <= BufferEnd &&
+ !vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes))
 CurPtr += 16;
 #else
   // Scan for '/' quickly.  Many block comments are very large.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3185c30 - Prefer __vector over vector keyword for altivec

2020-02-10 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-02-10T20:23:26+01:00
New Revision: 3185c30c54d0af5bffbff3bcfd721668d086ff10

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

LOG: Prefer __vector over vector keyword for altivec

`vector' uses the keyword-and-predefine mode from gcc, while __vector is
reliably supported.

As a side effect, it also makes the code consistent in its usage of __vector.

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

Added: 


Modified: 
clang/lib/Lex/Lexer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 9034726560dc..a51745697b11 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2552,8 +2552,8 @@ bool Lexer::SkipBlockComment(Token &Result, const char 
*CurPtr,
 '/', '/', '/', '/',  '/', '/', '/', '/',
 '/', '/', '/', '/',  '/', '/', '/', '/'
   };
-  while (CurPtr+16 <= BufferEnd &&
- !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))
+  while (CurPtr + 16 <= BufferEnd &&
+ !vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes))
 CurPtr += 16;
 #else
   // Scan for '/' quickly.  Many block comments are very large.



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-02-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

For the record: tests have been updated, option handling cleaned up and 
expansive check failure fixed in commit 
e67cbac81211d40332a79d98c9d5953624cc1202 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.

2020-02-10 Thread Nico Weber via cfe-commits
On Sun, Feb 9, 2020 at 2:34 PM Richard Smith  wrote:

> On Sun, 9 Feb 2020, 01:09 Nico Weber via cfe-commits, <
> cfe-commits@lists.llvm.org> wrote:
>
>> Our code fails to build with "destructor cannot be declared using a type
>> alias" after this, without us changing language mode or anything.
>>
>> Is that intended?
>>
>
> Can you provide a sketch of what you were doing? There are certainly cases
> where I'd expect that now --  where you find a typedef through in "bad"
> (extension) place and find a non-typedef elsewhere.
>

namespace perfetto {
class ConsumerEndpoint { . // 1
 public:
  virtual ~ConsumerEndpoint();
};
class TracingService {
 public:
  using ProducerEndpoint = perfetto::ProducerEndpoint;
  using ConsumerEndpoint = perfetto::ConsumerEndpoint;
};
TracingService::ConsumerEndpoint::~ConsumerEndpoint() = default;
}

1:
https://cs.chromium.org/chromium/src/third_party/perfetto/include/perfetto/ext/tracing/core/tracing_service.h?sq=package:chromium&g=0&l=55

2:
https://cs.chromium.org/chromium/src/third_party/perfetto/include/perfetto/ext/tracing/core/tracing_service.h?q=using%5C+ConsumerEndpoint&sq=package:chromium&g=0&l=234

3:
https://android-review.googlesource.com/c/platform/external/perfetto/+/1229901/1/src/tracing/core/virtual_destructors.cc
lhs

Upon closer look, that was the only instance we had.

Can this be a default-error-mapped warning so that projects have some
>> incremental transition path for this?
>>
>
> That seems reasonable, yes.
>
> On Fri, Feb 7, 2020 at 9:41 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Richard Smith
>>> Date: 2020-02-07T18:40:41-08:00
>>> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff
>>>
>>> LOG: PR12350: Handle remaining cases permitted by CWG DR 244.
>>>
>>> Also add extension warnings for the cases that are disallowed by the
>>> current rules for destructor name lookup, refactor and simplify the
>>> lookup code, and improve the diagnostic quality when lookup fails.
>>>
>>> The special case we previously supported for converting
>>> p->N::S::~S() from naming a class template into naming a
>>> specialization thereof is subsumed by a more general rule here (which is
>>> also consistent with Clang's historical behavior and that of other
>>> compilers): if we can't find a suitable S in N, also look in N::S.
>>>
>>> The extension warnings are off by default, except for a warning when
>>> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
>>> That seems sufficiently heinous to warn on by default, especially since
>>> we can't support it for a dependent nested-name-specifier.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/include/clang/Basic/DiagnosticGroups.td
>>> clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> clang/lib/AST/NestedNameSpecifier.cpp
>>> clang/lib/Sema/DeclSpec.cpp
>>> clang/lib/Sema/SemaExprCXX.cpp
>>> clang/test/CXX/class/class.mem/p13.cpp
>>> clang/test/CXX/drs/dr2xx.cpp
>>> clang/test/CXX/drs/dr3xx.cpp
>>> clang/test/FixIt/fixit.cpp
>>> clang/test/Parser/cxx-decl.cpp
>>> clang/test/SemaCXX/constructor.cpp
>>> clang/test/SemaCXX/destructor.cpp
>>> clang/test/SemaCXX/pseudo-destructors.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
>>> b/clang/include/clang/Basic/DiagnosticGroups.td
>>> index a2bc29986a07..8c54723cdbab 100644
>>> --- a/clang/include/clang/Basic/DiagnosticGroups.td
>>> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
>>> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">;
>>>  // designators (including the warning controlled by -Wc++2a-designator).
>>>  def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
>>>  def GNUDesignator : DiagGroup<"gnu-designator">;
>>> +def DtorName : DiagGroup<"dtor-name">;
>>>
>>>  def DynamicExceptionSpec
>>>  : DiagGroup<"dynamic-exception-spec",
>>> [DeprecatedDynamicExceptionSpec]>;
>>>
>>> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> index 9de60d3a8d27..82861f0d5d72 100644
>>> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> @@ -1911,17 +1911,33 @@ def err_destructor_with_params :
>>> Error<"destructor cannot have any parameters">;
>>>  def err_destructor_variadic : Error<"destructor cannot be variadic">;
>>>  def err_destructor_typedef_name : Error<
>>>"destructor cannot be declared using a %select{typedef|type alias}1
>>> %0 of the class name">;
>>> +def err_undeclared_destructor_name : Error<
>>> +  "undeclared identifier %0 in de

[clang] 04a830f - [OPENMP50]Support for acquire clause.

2020-02-10 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-10T14:51:46-05:00
New Revision: 04a830f80af97d1b2d2d652984635a774b23ebda

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

LOG: [OPENMP50]Support for acquire clause.

Added full support for acquire clause in flush|atomic directives.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_capture_codegen.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/test/OpenMP/atomic_read_codegen.c
clang/test/OpenMP/atomic_update_codegen.cpp
clang/test/OpenMP/atomic_write_codegen.c
clang/test/OpenMP/flush_ast_print.cpp
clang/test/OpenMP/flush_codegen.cpp
clang/test/OpenMP/flush_messages.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index f0dddf729309..b9c4389ddd63 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1882,7 +1882,7 @@ class OMPSeqCstClause : public OMPClause {
 /// #pragma omp flush acq_rel
 /// \endcode
 /// In this example directive '#pragma omp flush' has 'acq_rel' clause.
-class OMPAcqRelClause : public OMPClause {
+class OMPAcqRelClause final : public OMPClause {
 public:
   /// Build 'ack_rel' clause.
   ///
@@ -1915,6 +1915,46 @@ class OMPAcqRelClause : public OMPClause {
   }
 };
 
+/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
+/// directives.
+///
+/// \code
+/// #pragma omp flush acquire
+/// \endcode
+/// In this example directive '#pragma omp flush' has 'acquire' clause.
+class OMPAcquireClause final : public OMPClause {
+public:
+  /// Build 'acquire' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPAcquireClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_acquire, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPAcquireClause()
+  : OMPClause(OMPC_acquire, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_acquire;
+  }
+};
+
 /// This represents clause 'private' in the '#pragma omp ...' directives.
 ///
 /// \code

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index d8e6fb6e0254..916fac717dd4 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3126,6 +3126,11 @@ bool 
RecursiveASTVisitor::VisitOMPAcqRelClause(OMPAcqRelClause *) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPAcquireClause(OMPAcquireClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
   return true;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5cfd32c57c61..cc983f750711 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9695,9 +9695,9 @@ def note_omp_atomic_capture: Note<
   "%select{expected assignment expression|expected compound statement|expected 
exactly two expression statements|expected in right hand side of the first 
expression}0">;
 def err_omp_atomic_several_clauses : Error<
   "directive '#pragma omp atomic' cannot contain more than one 'read', 
'write', 'update' or 'capture' clause">;
-def err_omp_atomic_several_mem_order_clauses : Error<
-  "directive '#pragma omp atomic' cannot contain more than one 'seq_cst' or 
'acq_rel' clause">;
-def note_omp_atomic_previous_clause : Note<
+def err_omp_several_mem_order_clauses : Error<
+  "directive '#pragma omp %0' cannot contain more t

[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2020-02-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D67983#1863981 , @jyknight wrote:

> In D67983#1863019 , @arphaman wrote:
>
> > @jyknight @rjmccall I'm not sure this change is 100% fine. For example, the 
> > following code no longer compiles with ARC:
> >
> >   @protocol Delegate
> >   @end
> >  
> >   @interface X 
> >  
> >   @end
> >  
> >   @interface Y
> >   @property id d;
> >   @end
> >  
> >   @implementation X
> >  
> >   + (void)foo:(Y *)y with:(X*)x {
> >y.d = self; // error: assigning to 'id' from incompatible type 
> > 'const Class'
> >y.d = x; // fine
> >   }
> >  
> >   @end
> >
>
>
> Your error looks correct to me -- "self" in a classmethod is not an instance, 
> but the class itself. And while instances of X implement "Delegate", the 
> Class does not.


Got it, thanks! We might need to add a flag to allow the old behavior 
temporarily to accommodate our codebase while it's being updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[PATCH] D74262: [clang-offload-bundler] Enable handling of partially-linked fat objects

2020-02-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

(I'll try to actually review this later but I left a comment below)




Comment at: 
clang/test/Driver/clang-offload-bundler-missing-size-section.cpp:1-44
+// REQUIRES: x86-registered-target
+// RUN: %clangxx -c %s -o %t_fat.o
+// RUN: %clangxx %t_fat.o -o %t.exe
+// RUN: clang-offload-bundler -type=o 
-targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-pc-linux-gnu 
-outputs=%t_host.o,%t_device.o -inputs=%t_fat.o -unbundle
+// RUN: %t.exe %t_device.o | FileCheck %s
+// CHECK:11
+

ABataev wrote:
> Very strange test. It should not contain standard includes. Also, it should 
> not be an executable test, you have to check for the driver output or 
> something similar
We have executable tests in the OpenMP target offloading part, if it cannot 
live with clang it can live there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74262



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


[clang-tools-extra] efcf643 - Reland "[clangd][test] Disable a particular testcase in FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS""

2020-02-10 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-02-10T12:17:02-08:00
New Revision: efcf6430009cc5bcc2024ecec1c4e4bbb328d037

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

LOG: Reland "[clangd][test] Disable a particular testcase in 
FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS""

The test got re-enabled after d54d71b67e60 landed.

However it seems that the order is still not deterministic as it
currently passes with -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF but randomly
fails with expensive checks ON.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 1d2ea0f1c0b2..be4b37c8f453 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -823,6 +823,10 @@ TEST_F(FindExplicitReferencesTest, All) {
 "1: targets = {vector}\n"
 "2: targets = {x}\n"},
// Handle UnresolvedLookupExpr.
+   // FIXME
+   // This case fails when expensive checks are enabled.
+   // Seems like the order of ns1::func and ns2::func isn't defined.
+   #ifndef EXPENSIVE_CHECKS
{R"cpp(
 namespace ns1 { void func(char*); }
 namespace ns2 { void func(int*); }
@@ -836,6 +840,7 @@ TEST_F(FindExplicitReferencesTest, All) {
 )cpp",
 "0: targets = {ns1::func, ns2::func}\n"
 "1: targets = {t}\n"},
+#endif
// Handle UnresolvedMemberExpr.
{R"cpp(
 struct X {



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


Re: [clang-tools-extra] 8a68c40 - [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-02-10 Thread Nico Weber via cfe-commits
This broke sphinx:
http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/54402/steps/docs-clang-tools-html/logs/stdio

Please take a look!

On Sun, Feb 2, 2020 at 4:27 PM Nathan James via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Nathan James
> Date: 2020-02-02T21:27:25Z
> New Revision: 8a68c40a1bf256523993ee97b39f79001eaade91
>
> URL:
> https://github.com/llvm/llvm-project/commit/8a68c40a1bf256523993ee97b39f79001eaade91
> DIFF:
> https://github.com/llvm/llvm-project/commit/8a68c40a1bf256523993ee97b39f79001eaade91.diff
>
> LOG: [clang-tidy] Added option for disabling const qualifiers in
> readability-qualified-auto
>
> Summary: Adds an option called `AddConstToQualified` to
> readability-qualified-auto to toggle adding const to the auto typed
> pointers and references. By default its enabled but in the LLVM module its
> disabled.
>
> Reviewers: aaron.ballman, alexfh, JonasToth, hokein, sammccall
>
> Reviewed By: aaron.ballman
>
> Subscribers: Quuxplusone, merge_guards_bot, lebedev.ri, xazax.hun,
> cfe-commits
>
> Tags: #clang, #clang-tools-extra
>
> Differential Revision: https://reviews.llvm.org/D73548
>
> Added:
> clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
>
> Modified:
> clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.h
> clang-tools-extra/docs/ReleaseNotes.rst
> clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> index 5ae927c2cf5a..2aaf07639267 100644
> --- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> +++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> @@ -36,6 +36,12 @@ class LLVMModule : public ClangTidyModule {
>  "llvm-qualified-auto");
>  CheckFactories.registerCheck("llvm-twine-local");
>}
> +
> +  ClangTidyOptions getModuleOptions() override {
> +ClangTidyOptions Options;
> +Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
> +return Options;
> +  }
>  };
>
>  // Register the LLVMTidyModule using this statically initialized variable.
>
> diff  --git
> a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> index 1d0b85b9c4ce..79885dbe4b43 100644
> --- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> +++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> @@ -102,6 +102,10 @@ bool isAutoPointerConst(QualType QType) {
>
>  } // namespace
>
> +void QualifiedAutoCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
> +  Options.store(Opts, "AddConstToQualified", AddConstToQualified);
> +}
> +
>  void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
>if (!getLangOpts().CPlusPlus11)
>  return; // Auto deduction not used in 'C or C++03 and earlier', so
> don't
> @@ -142,6 +146,8 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder
> *Finder) {
>hasAnyTemplateArgument(IsBoundToType),
>"auto"),
>this);
> +  if (!AddConstToQualified)
> +return;
>Finder->addMatcher(ExplicitSingleVarDecl(
>   hasType(pointerType(pointee(autoType(,
> "auto_ptr"),
>   this);
> @@ -177,11 +183,9 @@ void QualifiedAutoCheck::check(const
> MatchFinder::MatchResult &Result) {
>  bool IsLocalVolatile = Var->getType().isLocalVolatileQualified();
>  bool IsLocalRestrict = Var->getType().isLocalRestrictQualified();
>
> -if (CheckQualifier(IsLocalConst, Qualifier::Const))
> -  return;
> -if (CheckQualifier(IsLocalVolatile, Qualifier::Volatile))
> -  return;
> -if (CheckQualifier(IsLocalRestrict, Qualifier::Restrict))
> +if (CheckQualifier(IsLocalConst, Qualifier::Const) ||
> +CheckQualifier(IsLocalVolatile, Qualifier::Volatile) ||
> +CheckQualifier(IsLocalRestrict, Qualifier::Restrict))
>return;
>
>  // Check for bridging the gap between the asterisk and name.
> @@ -214,8 +218,7 @@ void QualifiedAutoCheck::check(const
> MatchFinder::MatchResult &Result) {
>  << (IsLocalRestrict ? "__restrict " : "") << Var->getName() <<
> ReplStr;
>
>  for (SourceRange &Range : RemoveQualifiersRange) {
> -  Diag << FixItHint::CreateRemoval(
> -  CharSourceRange::getCharRange(Range.getBegin(),
> Range.getEnd()));
> +  Diag <<
> FixItHint::CreateRemoval(CharSourceRange::getCharRange(Range));
>  }
>
>  Diag << FixItHint::CreateReplacement(FixItRange, ReplStr);
> @@ -247,22 +250,17 @@ void QualifiedAutoCheck::check(const
> MatchFinder::MatchResult &Result) {
>  return;
>  }
>
> -  

[PATCH] D73755: [objc_direct] Small updates to help with adoption.

2020-02-10 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder updated this revision to Diff 243649.
MadCoder added a comment.

  Add some errors when direct properties are marked @dynamic.


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

https://reviews.llvm.org/D73755

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/test/FixIt/fixit-objc-direct.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/category-direct-properties.m
  clang/test/SemaObjC/method-direct.m

Index: clang/test/SemaObjC/method-direct.m
===
--- clang/test/SemaObjC/method-direct.m
+++ clang/test/SemaObjC/method-direct.m
@@ -18,6 +18,7 @@
 + (void)classRootDirect __attribute__((objc_direct)); // expected-note {{previous declaration is here}};
 - (void)otherRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherRootDirect' declared here}}
 + (void)otherClassRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherClassRootDirect' declared here}}
++ (void)otherOtherClassRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherOtherClassRootDirect' declared here}}
 - (void)notDirectInIface; // expected-note {{previous declaration is here}}
 + (void)classNotDirectInIface;// expected-note {{previous declaration is here}}
 @end
@@ -48,11 +49,6 @@
 + (void)classRootCategoryDirect2 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
 @end
 
-__attribute__((objc_root_class, objc_direct_members)) // expected-error {{'objc_direct_members' attribute only applies to Objective-C implementation declarations and Objective-C containers}}
-@interface SubDirectFail : Root
-- (instancetype)init;
-@end
-
 @interface Sub : Root 
 /* invalid overrides with directs */
 - (void)rootRegular __attribute__((objc_direct));   // expected-error {{methods that override superclass methods cannot be direct}}
@@ -94,6 +90,8 @@
 + (void)otherClassRootDirect {
   [self someRootDirectMethod]; // expected-error {{messaging a Class with a method that is possibly direct}}
 }
++ (void)otherOtherClassRootDirect {
+}
 - (void)rootExtensionDirect {
 }
 + (void)classRootExtensionDirect {
@@ -135,6 +133,9 @@
 - (void)someValidSubMethod {
   [super otherRootDirect]; // expected-error {{messaging super with a direct method}}
 }
++ (void)someValidSubMethod {
+  [super otherOtherClassRootDirect]; // expected-error {{messaging super with a direct method}}
+}
 @end
 
 extern void callMethod(id obj, Class cls);
Index: clang/test/SemaObjC/category-direct-properties.m
===
--- /dev/null
+++ clang/test/SemaObjC/category-direct-properties.m
@@ -0,0 +1,273 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wselector-type-mismatch %s
+
+__attribute__((objc_root_class))
+@interface Inteface_Implementation
+@property(nonatomic, readonly) int normal_normal;
+@property(nonatomic, readonly, direct) int direct_normal;
+@property(nonatomic, readonly) int normal_direct; // expected-note {{previous declaration is here}}
+@property(nonatomic, readonly, direct) int direct_direct;
+@end
+
+@implementation Inteface_Implementation
+- (int)normal_normal {
+  return 42;
+}
+- (int)direct_normal {
+  return 42;
+}
+- (int)normal_direct __attribute__((objc_direct)) { // expected-error {{direct method implementation was previously declared not direct}}
+  return 42;
+}
+- (int)direct_direct __attribute__((objc_direct)) {
+  return 42;
+}
+@end
+
+__attribute__((objc_root_class))
+@interface Inteface_Extension
+@property(nonatomic, readonly) int normal_normal;
+@property(nonatomic, readonly, direct) int direct_normal;
+@property(nonatomic, readonly) int normal_direct;
+@property(nonatomic, readonly, direct) int direct_direct;
+@end
+
+@interface Inteface_Extension ()
+@property(nonatomic, readwrite) int normal_normal;
+@property(nonatomic, readwrite) int direct_normal;
+@property(nonatomic, readwrite, direct) int normal_direct;
+@property(nonatomic, readwrite, direct) int direct_direct;
+@end
+
+@implementation Inteface_Extension
+@end
+
+__attribute__((objc_root_class))
+@interface Extension_Implementation
+@end
+
+@interface Extension_Implementation ()
+@property(nonatomic, readwrite) int normal_normal;
+@property(nonatomic, readwrite, direct) int direct_normal;
+@property(nonatomic, readwrite) int normal_direct; // expected-note {{previous declaration is here}}
+@property(nonatomic, readwrite, direct) int direct_direct;
+@end
+
+@implementation Extension_Implementation
+- (int)normal_normal {
+  return 42;
+}
+- (int)direct_normal {
+  return 42;
+}
+- (int)normal_direct __attribute__((objc_direct)) { // expected-error {{direct method 

[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2020-02-10 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

>> Your error looks correct to me -- "self" in a classmethod is not an 
>> instance, but the class itself. And while instances of X implement 
>> "Delegate", the Class does not.
> 
> Got it, thanks! We might need to add a flag to allow the old behavior 
> temporarily to accommodate our codebase while it's being updated.

Adding an explicit cast would be the simplest way to allow your code to 
continue being broken in the same way it was previously broken.  E.g.

  // TODO: fix the types here -- self is _not_ actually an id!
  y.d = static_cast>(self);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[clang] 9559834 - [OPENMP50]Add support for 'release' clause.

2020-02-10 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-10T16:01:41-05:00
New Revision: 9559834a5c1286db4e5bc1f5de047bfd67868f4a

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

LOG: [OPENMP50]Add support for 'release' clause.

Added full support for 'release' clause in flush|atomic directives.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_capture_codegen.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/test/OpenMP/atomic_read_codegen.c
clang/test/OpenMP/atomic_update_codegen.cpp
clang/test/OpenMP/atomic_write_codegen.c
clang/test/OpenMP/flush_ast_print.cpp
clang/test/OpenMP/flush_codegen.cpp
clang/test/OpenMP/flush_messages.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index b9c4389ddd63..19a84bd00a36 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1955,6 +1955,46 @@ class OMPAcquireClause final : public OMPClause {
   }
 };
 
+/// This represents 'release' clause in the '#pragma omp atomic|flush'
+/// directives.
+///
+/// \code
+/// #pragma omp flush release
+/// \endcode
+/// In this example directive '#pragma omp flush' has 'release' clause.
+class OMPReleaseClause final : public OMPClause {
+public:
+  /// Build 'release' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPReleaseClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_release, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPReleaseClause()
+  : OMPClause(OMPC_release, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_release;
+  }
+};
+
 /// This represents clause 'private' in the '#pragma omp ...' directives.
 ///
 /// \code

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 916fac717dd4..4ef9528dcf5b 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3131,6 +3131,11 @@ bool 
RecursiveASTVisitor::VisitOMPAcquireClause(OMPAcquireClause *) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPReleaseClause(OMPReleaseClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
   return true;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index cc983f750711..450075f2e927 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9696,7 +9696,7 @@ def note_omp_atomic_capture: Note<
 def err_omp_atomic_several_clauses : Error<
   "directive '#pragma omp atomic' cannot contain more than one 'read', 
'write', 'update' or 'capture' clause">;
 def err_omp_several_mem_order_clauses : Error<
-  "directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 
|}1'acq_rel' or 'acquire' clause">;
+  "directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 
|}1'acq_rel', 'acquire' or 'release' clause">;
 def note_omp_previous_mem_order_clause : Note<
   "'%0' clause used here">;
 def err_omp_target_contains_not_only_teams : Error<

diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 346c0f54971d..19fcf7cfac58 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -259,6 +259,7 @@ OPENMP_CLAUSE(capture, OMPCaptureClause)
 OPENMP_CLAUSE(seq_cst, OMPSeqCstClause)
 OPENMP_CLAUSE(ac

[PATCH] D67588: Add builtin trait for add/remove cv (and similar)

2020-02-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

LGTM other than the inline comments.
I'll take a second pass at this once they're addressed.

Let's land the patch this week!




Comment at: clang/include/clang/Sema/DeclSpec.h:419
   static bool isTypeRep(TST T) {
 return (T == TST_typename || T == TST_typeofType ||
 T == TST_underlyingType || T == TST_atomic||

Is the block of values for these identifiers contiguous? Can we work towards 
writing this as `min <= x <= max`?



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1094
 return DeclSpec::TST_removeReferenceType;
+  case tok::kw___remove_cv:
+return DeclSpec::TST_removeCV;

It would be really cool if we could simplify these conversions to 
`static_cast(Tok.getKind() - base);`

That said, it's probably easier to land this patch as is.



Comment at: clang/lib/Sema/SemaType.cpp:8475
+  }
+  case UnaryTransformType::AddCV: {
+QualType Underlying = BaseType.withConst().withVolatile();

I don't know that we need `add_foo`, because if I want to optimize my 
type-trait, I'll just write `T const`.

Adding code to clang has a maintenance cost; and that's non-trivial. The 
`remove_foo` traits add a lot of value, and that justifies the cost.




Comment at: clang/test/SemaCXX/add_cv.cpp:43
+  static const bool value =
+__is_same(typename remove_const::type, T) &&
+__is_same(typename remove_const::type, volatile T) &&

Clang tests normally test:

(A) The diagnostics that emit when people seriously misuse.
(B) Just some failures.



Comment at: 
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_cv.sh.cpp:2
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.

I think we probably want to keep the libc++ changes in a separate patch.


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

https://reviews.llvm.org/D67588



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


[PATCH] D74355: [ubsan] Null-check TypeLoc before using it

2020-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added reviewers: erik.pilkington, delcypher.
Herald added a subscriber: dexonsmith.

Null-check a TypeLoc before casting it to a FunctionTypeLoc. This fixes
a crash in -fsanitize=nullability-return.

rdar://59263039


https://reviews.llvm.org/D74355

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m


Index: clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK-LABEL: define i8* @foo()
+// CHECK: call i8* @helper()
+// CHECK-NEXT: ret i8*
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) id foo(void) {
+  extern id helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAs())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;


Index: clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK-LABEL: define i8* @foo()
+// CHECK: call i8* @helper()
+// CHECK-NEXT: ret i8*
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) id foo(void) {
+  extern id helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAs())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74355: [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 243672.
vsk retitled this revision from "[ubsan] Null-check TypeLoc before using it" to 
"[ubsan] Null-check and adjust TypeLoc before using it".
vsk edited the summary of this revision.
vsk added a comment.

- Check adjusted return type per Erik's offline feedback.


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

https://reviews.llvm.org/D74355

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void 
@__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void @__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74355: [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D74355



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


[clang] 8b81ebf - [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Vedant Kumar via cfe-commits

Author: Vedant Kumar
Date: 2020-02-10T14:10:06-08:00
New Revision: 8b81ebfe7eba089ed2016d523cc5ee9d05e957a7

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

LOG: [ubsan] Null-check and adjust TypeLoc before using it

Null-check and adjut a TypeLoc before casting it to a FunctionTypeLoc.
This fixes a crash in -fsanitize=nullability-return, and also makes the
location of the nonnull type available when the return type is adjusted.

rdar://59263039

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

Added: 
clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm

Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 9ef2a3b3d099..e6cb4a1fd93f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@ void CodeGenFunction::EmitReturnValueCheck(llvm::Value 
*RV) {
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;

diff  --git a/clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm 
b/clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
new file mode 100644
index ..23025c9eb845
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void 
@__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end



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


[PATCH] D74355: [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b81ebfe7eba: [ubsan] Null-check and adjust TypeLoc before 
using it (authored by vsk).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74355

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void 
@__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void @__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44609: [clang-format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-02-10 Thread Francois JEAN via Phabricator via cfe-commits
Wawha added a comment.

Hi @MyDeveloperDay
Is the last change ok? That is the next step to be able to validate this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D74361: [Clang] Uninitialize attribute on global variables

2020-02-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: kcc, rjmccall, rsmith, glider, vitalybuka, 
pcc, eugenis, vlad.tsyrklevich, jdoerfert, gregrodgers.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[Clang] Uninitialize attribute on global variables

Extends D54604  to permit [[uninitialized]] on 
global and static variables

Initializing global variables is very cheap on hosted implementations. The
C semantics of zero initializing globals work very well there. It is not
necessarily cheap on freestanding implementations. Where there is no loader
available, code must be emitted near the start point to write the appropriate
values into memory.

At present, external variables can be declared in C++ and definitions provided
in assembly (or IR) to achive this effect. This patch removes a restriction on
the existing attribute in order to remove this reason for writing assembly for
performance sensitive freestanding implementations.

A close analogue in tree is LDS memory for amdgcn, where the kernel is
responsible for initializing the memory after it starts executing on the gpu.
Uninitalized variables in LDS are observably cheaper than zero initialized.

Patch follows the cuda __shared__ variable implementation which also produces
undef global variables, and reuses the [[uninitialized]] attribute from auto
variable initialisation. I think the existing docs are still appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74361

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCXX/attribute_uninitialized.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-uninitialized.c

Index: clang/test/Sema/attr-uninitialized.c
===
--- clang/test/Sema/attr-uninitialized.c
+++ clang/test/Sema/attr-uninitialized.c
@@ -6,16 +6,11 @@
 
 void bad() {
   int im_bad __attribute((uninitialized("zero")));  // expected-error {{'uninitialized' attribute takes no arguments}}
-  static int im_baaad __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
 }
 
-extern int come_on __attribute((uninitialized));// expected-warning {{'uninitialized' attribute only applies to local variables}}
-int you_know __attribute((uninitialized));  // expected-warning {{'uninitialized' attribute only applies to local variables}}
-static int and_the_whole_world_has_to __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
-
-void answer_right_now() __attribute((uninitialized)) {}// expected-warning {{'uninitialized' attribute only applies to local variables}}
-void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {} // expected-warning {{'uninitialized' attribute only applies to local variables}}
+void answer_right_now() __attribute((uninitialized)) {}// expected-warning {{'uninitialized' attribute only applies to variables}}
+void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {}
 
 struct TheWordIsOut {
-  __attribute((uninitialized)) int youre_doin_wrong; // expected-warning {{'uninitialized' attribute only applies to local variables}}
-} __attribute((uninitialized));  // expected-warning {{'uninitialized' attribute only applies to local variables}}
+  __attribute((uninitialized)) int youre_doin_wrong; // expected-warning {{'uninitialized' attribute only applies to variables}}
+} __attribute((uninitialized));  // expected-warning {{'uninitialized' attribute only applies to variables}}
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
@@ -148,6 +148,7 @@
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
+// CHECK-NEXT: Uninitialized (SubjectMatchRule_variable)
 // CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)
 // CHECK-NEXT: VecTypeHint (SubjectMatchRule_function)
Index: clang/test/CodeGenCXX/attribute_uninitialized.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attribute_uninitialized.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @_ZZ4funcvE4data = internal global i32 undef
+int* func(void)
+{
+  

[PATCH] D74361: [Clang] Uninitialize attribute on global variables

2020-02-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

FWIW, this would really help us to create an OpenMP device (=GPU) runtime 
written almost entirely in OpenMP, C++, and very few clang builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D74371: [DirectoryWatcher] Fix misuse of FSEvents API and data race

2020-02-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jkorous, akyrtzi.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

I observed two bugs in the DirectoryWatcher on macOS

  

1. We were calling FSEventStreamStop and FSEventStreamInvalidate before we 
called FSEventStreamStart and FSEventStreamSetDispatchQueue, if the 
DirectoryWatcher was destroyed before the initial async work was done. This 
violates the requirements of the FSEvents API.

2. Calls to Receiver could race between the initial work and the invalidation 
during destruction.

The second issue is easier to see when using TSan.

  

rdar://59215667


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74371

Files:
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -449,3 +449,42 @@
 
   checkEventualResultWithTimeout(TestConsumer);
 }
+
+TEST(DirectoryWatcherTest, InvalidatedWatcherAsync) {
+  DirectoryWatcherTestFixture fixture;
+  fixture.addFile("a");
+
+  // This test is checking that we get the initial notification for 'a' before
+  // the final 'invalidated'. Strictly speaking, we do not care whether 'a' is
+  // processed or not, only that it is neither racing with, nor after
+  // 'invalidated'. In practice, it is always processed in our implementations.
+  VerifyingConsumer TestConsumer{
+  {{EventKind::Modified, "a"}},
+  {{EventKind::WatcherGotInvalidated, ""}},
+  // We have to ignore these as it's a race between the test process
+  // which is scanning the directory and kernel which is sending
+  // notification.
+  {{EventKind::Modified, "a"}},
+  };
+
+  // A counter that can help detect data races on the event receiver,
+  // particularly if used with TSan. Expected count will be 2 or 3 depending on
+  // whether we get the kernel event or not (see comment above).
+  unsigned Count = 0;
+  {
+llvm::Expected> DW =
+DirectoryWatcher::create(
+fixture.TestWatchedDir,
+[&TestConsumer,
+ &Count](llvm::ArrayRef Events,
+ bool IsInitial) {
+  Count += 1;
+  TestConsumer.consume(Events, IsInitial);
+},
+/*waitForInitialSync=*/false);
+ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
+  } // DW is destructed here.
+
+  checkEventualResultWithTimeout(TestConsumer);
+  ASSERT_TRUE(Count == 2u || Count == 3u);
+}
Index: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
===
--- clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -43,24 +43,32 @@
 class DirectoryWatcherMac : public clang::DirectoryWatcher {
 public:
   DirectoryWatcherMac(
-  FSEventStreamRef EventStream,
+  dispatch_queue_t Queue, FSEventStreamRef EventStream,
   std::function, bool)>
   Receiver,
   llvm::StringRef WatchedDirPath)
-  : EventStream(EventStream), Receiver(Receiver),
+  : Queue(Queue), EventStream(EventStream), Receiver(Receiver),
 WatchedDirPath(WatchedDirPath) {}
 
   ~DirectoryWatcherMac() override {
-stopFSEventStream(EventStream);
-EventStream = nullptr;
-// Now it's safe to use Receiver as the only other concurrent use would have
-// been in EventStream processing.
-Receiver(DirectoryWatcher::Event(
- DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""),
- false);
+// FSEventStreamStop and Invalidate must be called after Start and
+// SetDispatchQueue to follow FSEvents API contract. The call to Receiver
+// also uses Queue to not race with the initial scan.
+dispatch_sync(Queue, ^{
+  stopFSEventStream(EventStream);
+  EventStream = nullptr;
+  Receiver(
+  DirectoryWatcher::Event(
+  DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""),
+  false);
+});
+
+// Balance initial creation.
+dispatch_release(Queue);
   }
 
 private:
+  dispatch_queue_t Queue;
   FSEventStreamRef EventStream;
   std::function, bool)> Receiver;
   const std::string WatchedDirPath;
@@ -217,7 +225,7 @@
   assert(EventStream && "EventStream expected to be non-null");
 
   std::unique_ptr Result =
-  std::make_unique(EventStream, Receiver, Path);
+  std::make_unique(Queue, EventStream, Receiver, Path);
 
   // We need to copy the data so the lifetime is ok after a const copy is made
   // for the block.
@@ -230,10 +238,6 @@
 // inital scan and handling events ONLY AFTER the scan finishes.
 FSEventStreamSetDispatchQueue(EventStrea

[PATCH] D74371: [DirectoryWatcher] Fix misuse of FSEvents API and data race

2020-02-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous 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/D74371/new/

https://reviews.llvm.org/D74371



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


[clang-tools-extra] 784d441 - Fix Sphinx failure on ReadabilityQualifiedAuto docs

2020-02-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-02-11T02:03:37Z
New Revision: 784d4417453e2bb792e29f5dad462f7fcebab6d1

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

LOG: Fix Sphinx failure on ReadabilityQualifiedAuto docs

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst 
b/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
index 351b333b6dce..413640fb7ca7 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
@@ -36,19 +36,19 @@ Note ``const`` ``volatile`` qualified types will retain 
their ``const`` and
 
 .. code-block:: c++
 
-   const auto Foo = cast(Baz1);
-   const auto Bar = cast(Baz2);
-   volatile auto FooBar = cast(Baz3);
-   auto BarFoo = cast(Baz4);
+  const auto Foo = cast(Baz1);
+  const auto Bar = cast(Baz2);
+  volatile auto FooBar = cast(Baz3);
+  auto BarFoo = cast(Baz4);
 
 Would be transformed into:
 
 .. code-block:: c++
 
-   auto *const Foo = cast(Baz1);
-   const auto *const Bar = cast(Baz2);
-   auto *volatile FooBar = cast(Baz3);
-   auto *BarFoo = cast(Baz4);
+  auto *const Foo = cast(Baz1);
+  const auto *const Bar = cast(Baz2);
+  auto *volatile FooBar = cast(Baz3);
+  auto *BarFoo = cast(Baz4);
 
 Options
 ---
@@ -65,7 +65,7 @@ Options
auto *Foo2 = cast(Bar2);
auto &Foo3 = cast(Bar3);
 
-   If AddConstToQualified is set to `0`,  it will be transformed into:
+If AddConstToQualified is set to `0`,  it will be transformed into:
 
 .. code-block:: c++
 
@@ -73,7 +73,7 @@ Options
auto *Foo2 = cast(Bar2);
auto &Foo3 = cast(Bar3);
 
-   Otherwise it will be transformed into:
+Otherwise it will be transformed into:
 
 .. code-block:: c++
 
@@ -81,4 +81,4 @@ Options
const auto *Foo2 = cast(Bar2);
const auto &Foo3 = cast(Bar3);
 
-   Note in the LLVM alias, the default value is `0`.
+Note in the LLVM alias, the default value is `0`.



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


  1   2   >