[PATCH] D79290: Update suffix check and cast non-suffix types

2020-05-02 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@hubert.reinterpretcast, this patch is part of our internal forks which we 
would like to put upstream. The author of the previous patch does not have 
bandwidth to work on it and @reikdas kindly volunteered to take over. I can 
close the previous one if that's preferable.


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

https://reviews.llvm.org/D79290



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


[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

2020-05-02 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D79279#2016573 , @rjmccall wrote:

> In D79279#2016570 , @rjmccall wrote:
>
> > I do think this is a somewhat debatable change in the behavior of these 
> > builtins, though.
>
>
> Let me put more weight on this.  You need to propose this on cfe-dev.


Happy to do so. Is this more about the change in the builtin, or about spelling 
it `__builtin_volatile_memcpy` and such? I've thought about this, and when the 
builtin has two potentially volatile arguments I've concluded that the IR 
builtin really wasn't sufficient in semantics, but in practice it is sufficient 
today. So putting `volatile` in a function name (versus overloading) seems to 
not really be what makes sense here. I'd therefore rather overload, and as you 
say we could support more than just `volatile` in doing so. Is that the main 
thing you'd suggest going for in an RFC (`volatile` as well as address space 
overloads and whatever else)? Again, I'm happy to do that, but I want to make 
sure I reflect your feedback correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

2020-05-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D79279#2016570 , @rjmccall wrote:

> I do think this is a somewhat debatable change in the behavior of these 
> builtins, though.


Let me put more weight on this.  You need to propose this on cfe-dev.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

2020-05-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D79279#2016496 , @jfb wrote:

> In D79279#2015983 , @rjmccall wrote:
>
> > Most of the complexity of this patch is introduced by the decision to 
> > type-check these calls with a volatile-typed parameter, which seems like it 
> > does nothing but cause problems.  If your goal is to make these functions 
> > do the right thing when given arbitrary pointer types, I think you need to 
> > give these calls special type-checking semantics.  Done right, that will 
> > also let you e.g. accept pointers into arbitrary address spaces.  But I'm 
> > not sure how good of an idea this actually is at base, since these builtins 
> > are typically used for direct calls to their associated library functions.
>
>
> You mean: in `Builtins,def` allow a `?` modifier on `volatile` (so, `D?`) to 
> denote overloading on `volatile`, and consume that overload directly while 
> type checking? That seems fine to me. Just want to make sure that's what you 
> have in mind.


I don't know how that `?` would actually work, but more importantly, no, that's 
not really what I meant.  The current semantics of these builtins are that they 
are not polymorphic.  I think the right way to understand what you're trying to 
do is that you're trying to make them polymorphic over qualifiers.  That means 
that we can do a `__builtin_memset` of a `volatile void *`, yes, but it also 
means that we can do a `__builtin_memset` of a `volatile restrict __local void 
*`.  (Now, some qualifiers don't make sense to honor because they'd be a 
radical change in behavior — we wouldn't want to honor `__strong` by doing a 
bunch of ARC assignments, for example.  But most qualifiers do still make sense 
for these operations.)  And in fact there's a certain amount of precedent for 
this because we already honor the presumed alignment of the pointer before it's 
converted to `void*`.

Unfortunately, the only way to do this kind of polymorphism in Clang today is 
to give the entire builtin custom type-checking with `t`.  And you'll need to 
do a bunch of work to make sure that the behavior of this builtin is consistent 
with an ordinary call to `memcpy` when e.g. the argument is a class type with 
overloaded conversion operators to pointer types.  But I think that's what 
you're signing up for.

I do think this is a somewhat debatable change in the behavior of these 
builtins, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-05-02 Thread Ryan Mansfield via Phabricator via cfe-commits
rmansfield added a comment.

They're overly reduced examples ;) but embedded programmers tend to make heavy 
use of shift operators, including within for loops and if stmts


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

https://reviews.llvm.org/D79293



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


[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

2020-05-02 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D79279#2015983 , @rjmccall wrote:

> Most of the complexity of this patch is introduced by the decision to 
> type-check these calls with a volatile-typed parameter, which seems like it 
> does nothing but cause problems.  If your goal is to make these functions do 
> the right thing when given arbitrary pointer types, I think you need to give 
> these calls special type-checking semantics.  Done right, that will also let 
> you e.g. accept pointers into arbitrary address spaces.  But I'm not sure how 
> good of an idea this actually is at base, since these builtins are typically 
> used for direct calls to their associated library functions.


You mean: in `Builtins,def` allow a `?` modifier on `volatile` (so, `D?`) to 
denote overloading on `volatile`, and consume that overload directly while type 
checking? That seems fine to me. Just want to make sure that's what you have in 
mind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D79232: [analyzer] Refactor range inference for symbolic expressions

2020-05-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D79232#2016065 , @NoQ wrote:

> @baloghadamsoftware @steakhal @ASDenysPetrov will you be able to plug D49074 
> /D50256 
> /D77792 
> /D77802 
> /D78933  
> into this so that to separate algebra from pattern-matching and ensure no 
> performance regressions? Or is something still missing?


Sure. I'll plug my changes D77802 /D78933 
 as soon as this patch is available in the 
master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79232



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


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-05-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D79293#2016410 , @rmansfield wrote:

> Couple examples:
>
> void foo(int x) {
>
>   for (unsigned int i = 0; i < x >> 1; i++) { }
>
> }
>
> and
>
>   int i = 0; 
>   
>   if (i < x >> 1) {}
>   
>
> }


I don't deny there are places where this will fail, but that is clang-format 
all over its a series of rules or the arrangement of token to produce the 
desired result

I think we also have to say.. "who writes code like this"  ;-)


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

https://reviews.llvm.org/D79293



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


[PATCH] D78000: [ASTImporter] Fix handling of not defined FromRecord in ImportContext(...)

2020-05-02 Thread Abhinav Gaba via Phabricator via cfe-commits
abhinavgaba added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5974
+   SmallVectorImpl ) override {}
+};
+

Overloading `CompleteType(TagDecl*)` is causing a warning:
virtual void 
`clang::ExternalASTSource::CompleteType(clang::ObjCInterfaceDecl*)’ was hidden 
[-Woverloaded-virtual]`

One way to get rid of it would be to add this here :
  private:
using ExternalASTSource::CompleteType;



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78000



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


[PATCH] D78213: [libclang]: visit BindingDecl in DecompositionDecl

2020-05-02 Thread Benjamin Kramer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4597e3bd475b: [libclang]: visit BindingDecl in 
DecompositionDecl (authored by milianw, committed by bkramer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78213

Files:
  clang/test/Index/cxx17-structured-binding.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CursorVisitor.h


Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1295,6 +1295,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
Index: clang/test/Index/cxx17-structured-binding.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-structured-binding.cpp
@@ -0,0 +1,25 @@
+// Test is line- and column-sensitive; see below.
+int main() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:5: FunctionDecl=main:2:5 
(Definition) Extent=[2:1 - 5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:12: CompoundStmt= Extent=[2:12 - 
5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:3: DeclStmt= Extent=[3:3 - 3:21]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:7: VarDecl=a:3:7 (Definition) 
Extent=[3:3 - 3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:9: IntegerLiteral= Extent=[3:9 - 
3:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:14: InitListExpr= Extent=[3:14 - 
3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:15: IntegerLiteral= Extent=[3:15 
- 3:16]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:18: IntegerLiteral= Extent=[3:18 
- 3:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:3: DeclStmt= Extent=[4:3 - 4:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:8: UnexposedDecl=[x, y]:4:8 
(Definition) Extent=[4:3 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:9: UnexposedDecl=x:4:9 
(Definition) Extent=[4:9 - 4:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:12: UnexposedDecl=y:4:12 
(Definition) Extent=[4:12 - 4:13]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: ArraySubscriptExpr= 
Extent=[4:17 - 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]


Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1295,6 +1295,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
Index: clang/test/Index/cxx17-structured-binding.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-structured-binding.cpp
@@ -0,0 +1,25 @@
+// Test is 

[PATCH] D78214: [libclang]: visit C++17 if init statements

2020-05-02 Thread Benjamin Kramer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08e181264318: [libclang]: visit C++17 if init statements 
(authored by milianw, committed by bkramer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78214

Files:
  clang/test/Index/cxx17-if-with-initializer.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2680,6 +2680,7 @@
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
Index: clang/test/Index/cxx17-if-with-initializer.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 
(Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 
- 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 
(Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= 
Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 
- 5:4]


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2680,6 +2680,7 @@
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
Index: clang/test/Index/cxx17-if-with-initializer.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck -check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 (Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 (Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 - 5:4]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78214: [libclang]: visit C++17 if init statements

2020-05-02 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78214



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


[PATCH] D78213: [libclang]: visit BindingDecl in DecompositionDecl

2020-05-02 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78213



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


[clang] 4597e3b - [libclang]: visit BindingDecl in DecompositionDecl

2020-05-02 Thread Benjamin Kramer via cfe-commits

Author: Milian Wolff
Date: 2020-05-02T22:18:31+02:00
New Revision: 4597e3bd475badff9f81e5d738913cd841bc3c1d

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

LOG: [libclang]: visit BindingDecl in DecompositionDecl

This makes the BindingDecl accessible to consumers of libclang
as CXCursor_UnexposedDecl where previously these AST nodes were
not visited at all from the libclang API.

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

Added: 
clang/test/Index/cxx17-structured-binding.cpp

Modified: 
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CursorVisitor.h

Removed: 




diff  --git a/clang/test/Index/cxx17-structured-binding.cpp 
b/clang/test/Index/cxx17-structured-binding.cpp
new file mode 100644
index ..3fbd262eadae
--- /dev/null
+++ b/clang/test/Index/cxx17-structured-binding.cpp
@@ -0,0 +1,25 @@
+// Test is line- and column-sensitive; see below.
+int main() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:5: FunctionDecl=main:2:5 
(Definition) Extent=[2:1 - 5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:12: CompoundStmt= Extent=[2:12 - 
5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:3: DeclStmt= Extent=[3:3 - 3:21]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:7: VarDecl=a:3:7 (Definition) 
Extent=[3:3 - 3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:9: IntegerLiteral= Extent=[3:9 - 
3:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:14: InitListExpr= Extent=[3:14 - 
3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:15: IntegerLiteral= Extent=[3:15 
- 3:16]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:18: IntegerLiteral= Extent=[3:18 
- 3:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:3: DeclStmt= Extent=[4:3 - 4:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:8: UnexposedDecl=[x, y]:4:8 
(Definition) Extent=[4:3 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:9: UnexposedDecl=x:4:9 
(Definition) Extent=[4:9 - 4:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:12: UnexposedDecl=y:4:12 
(Definition) Extent=[4:12 - 4:13]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: ArraySubscriptExpr= 
Extent=[4:17 - 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index f09d40115a74..f99cc5a8a6fd 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -1295,6 +1295,14 @@ bool CursorVisitor::VisitFriendDecl(FriendDecl *D) {
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:

diff  --git a/clang/tools/libclang/CursorVisitor.h 
b/clang/tools/libclang/CursorVisitor.h
index 3337fecd0db3..364d9fdebdbc 100644
--- a/clang/tools/libclang/CursorVisitor.h
+++ b/clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@ class CursorVisitor : public DeclVisitor,
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);



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


[clang] 08e1812 - [libclang]: visit C++17 if init statements

2020-05-02 Thread Benjamin Kramer via cfe-commits

Author: Milian Wolff
Date: 2020-05-02T22:18:36+02:00
New Revision: 08e18126431878373abfa33136768d0ec7c13def

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

LOG: [libclang]: visit C++17 if init statements

This makes the previously unaccessible AST nodes for C++17 "if with
init statements" accessible to consumers of libclang.

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

Added: 
clang/test/Index/cxx17-if-with-initializer.cpp

Modified: 
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/test/Index/cxx17-if-with-initializer.cpp 
b/clang/test/Index/cxx17-if-with-initializer.cpp
new file mode 100644
index ..fb34434117d5
--- /dev/null
+++ b/clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 
(Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 
- 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 
(Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= 
Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 
- 5:4]

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index f99cc5a8a6fd..2afc5a4eb842 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2680,6 +2680,7 @@ void EnqueueVisitor::VisitIfStmt(const IfStmt *If) {
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {



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


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-05-02 Thread Ryan Mansfield via Phabricator via cfe-commits
rmansfield added a comment.

Couple examples:

void foo(int x) { 
 for (unsigned int i = 0; i < x >> 1; i++) { }
}

and

int i = 0;

if (i < x >> 1) {}

}


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

https://reviews.llvm.org/D79293



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


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-05-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 261656.
MyDeveloperDay added a comment.

Update for pre-merge checks


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

https://reviews.llvm.org/D79293

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7065,6 +7065,8 @@
   verifyFormat("static_assert(is_convertible::value, \"AAA\");");
   verifyFormat("Constructor(A... a) : a_(X{std::forward(a)}...) {}");
   verifyFormat("< < < < < < < < < < < < < < < < < < < < < < < < < < < < < <");
+
+  verifyFormat("for (unsigned i = 0; i < i; ++i, v = v >> 1)");
 }
 
 TEST_F(FormatTest, BitshiftOperatorWidth) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -145,6 +145,10 @@
   Contexts[Contexts.size() - 2].IsExpression &&
   !Line.startsWith(tok::kw_template))
 return false;
+  // If we see a ; then likely this is a for loop and not the template
+  if (CurrentToken->is(tok::semi))
+return false;
+
   updateParameterCount(Left, CurrentToken);
   if (Style.Language == FormatStyle::LK_Proto) {
 if (FormatToken *Previous = CurrentToken->getPreviousNonComment()) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7065,6 +7065,8 @@
   verifyFormat("static_assert(is_convertible::value, \"AAA\");");
   verifyFormat("Constructor(A... a) : a_(X{std::forward(a)}...) {}");
   verifyFormat("< < < < < < < < < < < < < < < < < < < < < < < < < < < < < <");
+
+  verifyFormat("for (unsigned i = 0; i < i; ++i, v = v >> 1)");
 }
 
 TEST_F(FormatTest, BitshiftOperatorWidth) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -145,6 +145,10 @@
   Contexts[Contexts.size() - 2].IsExpression &&
   !Line.startsWith(tok::kw_template))
 return false;
+  // If we see a ; then likely this is a for loop and not the template
+  if (CurrentToken->is(tok::semi))
+return false;
+
   updateParameterCount(Left, CurrentToken);
   if (Style.Language == FormatStyle::LK_Proto) {
 if (FormatToken *Previous = CurrentToken->getPreviousNonComment()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79292: [sema] NFC Unable to build Sema library with MSVC Debug target due to missing /bigobj

2020-05-02 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e194a3b9356: [sema] NFC Unable to build Sema library with 
MSVC Debug target due to missing… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79292

Files:
  clang/lib/Sema/CMakeLists.txt


Index: clang/lib/Sema/CMakeLists.txt
===
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@ -9,6 +9,7 @@
   set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
   set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
+  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins


Index: clang/lib/Sema/CMakeLists.txt
===
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@ -9,6 +9,7 @@
   set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES COMPILE_FLAGS /bigobj)
+  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9e194a3 - [sema] NFC Unable to build Sema library with MSVC Debug target due to missing /bigobj

2020-05-02 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-02T19:34:58+01:00
New Revision: 9e194a3b9356c6ef0498609c1779043d1b6bb9e1

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

LOG: [sema] NFC Unable to build Sema library with MSVC Debug target due to 
missing /bigobj

Summary:
Unable to build sema library on MSVC with Debug target

```
C:\clang\llvm-project\clang\lib\Sema\SemaOpenMP.cpp : fatal error C1128: number 
of sections exceeded object file format limit: compile with /bigobj
```

Reviewed By: aaron.ballman

Subscribers: mgorny, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index 98f121f4b6f0..71def7129beb 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -9,6 +9,7 @@ if (MSVC)
   set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
   set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
+  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins



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


[clang] c0f210d - Don't stash types that aren't copyable or moveable into a SmallVector

2020-05-02 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-05-02T19:13:06+02:00
New Revision: c0f210d636300abe891cf7e5f07d13f5f4c0102e

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

LOG: Don't stash types that aren't copyable or moveable into a SmallVector

This seems to be working by accident.

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
llvm/tools/llvm-exegesis/lib/SnippetGenerator.h

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 79f21515a8ee..7cda60ba7598 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5121,20 +5121,19 @@ static bool evaluateTypeTrait(Sema , TypeTrait Kind, 
SourceLocation KWLoc,
 if (RD && RD->isAbstract())
   return false;
 
-SmallVector OpaqueArgExprs;
+llvm::BumpPtrAllocator OpaqueExprAllocator;
 SmallVector ArgExprs;
 ArgExprs.reserve(Args.size() - 1);
 for (unsigned I = 1, N = Args.size(); I != N; ++I) {
   QualType ArgTy = Args[I]->getType();
   if (ArgTy->isObjectType() || ArgTy->isFunctionType())
 ArgTy = S.Context.getRValueReferenceType(ArgTy);
-  OpaqueArgExprs.push_back(
-  OpaqueValueExpr(Args[I]->getTypeLoc().getBeginLoc(),
-  ArgTy.getNonLValueExprType(S.Context),
-  Expr::getValueKindForType(ArgTy)));
+  ArgExprs.push_back(
+  new (OpaqueExprAllocator.Allocate())
+  OpaqueValueExpr(Args[I]->getTypeLoc().getBeginLoc(),
+  ArgTy.getNonLValueExprType(S.Context),
+  Expr::getValueKindForType(ArgTy)));
 }
-for (Expr  : OpaqueArgExprs)
-  ArgExprs.push_back();
 
 // Perform the initialization in an unevaluated context within a SFINAE
 // trap at translation unit scope.

diff  --git a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h 
b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h
index 19a1ed0c401e..5f67b396ad95 100644
--- a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h
+++ b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h
@@ -145,13 +145,6 @@ class CombinationGenerator {
   assert(!Range.empty() && "The range must not be empty.");
   rewind();
 }
-
-// Only allow using our custom constructor.
-WrappingIterator() = delete;
-WrappingIterator(const WrappingIterator &) = delete;
-WrappingIterator(WrappingIterator &&) = delete;
-WrappingIterator =(const WrappingIterator &) = delete;
-WrappingIterator =(WrappingIterator &&) = delete;
   };
 
   const ArrayRef VariablesChoices;



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


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-05-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: owenpan, hans, krasimir, mitchell-stellar, 
sammccall, pawels.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay edited the summary of this revision.

Fix to address https://bugs.llvm.org/show_bug.cgi?id=45218

The `<>` in the following code means the  `i < bits`  and  `v >` in the 
following code gets incorrectly determined as a TemplateOpener/Closer (see 
debug output below)

While this became more prevalent after D66332: [clang-format] Fix the bug that 
joins template closer and > or >>  this isn't 
the root cause, but instead as called out by PR45218  it's more to do with 
`parseAngle()` and how it labels `<` and `>`

`
for (unsigned i = 0; i < nbits; ++i, bIt.next(), v = v >> 1)
`

This can be seen by the following debug output for the line, where we can see 
that the <> have the wrong `T` value.

The tests pass and various directories within LLVM which are currently already 
clang-formatted don't show any new errors (although that far from exhaustive 
testing)

  M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=for L=3 PPK=2 FakeLParens= 
FakeRParens=0 II=0x1e0bf1b7c80 Text='for'
  M=0 C=0 T=Unknown S=1 B=0 BK=0 P=23 Name=l_paren L=5 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=1040 Name=unsigned L=13 PPK=2 
FakeLParens=2/0/ FakeRParens=0 II=0x1e0bf1b7fc0 Text='unsigned'
  M=0 C=1 T=StartOfName S=1 B=0 BK=0 P=240 Name=identifier L=15 PPK=2 
FakeLParens= FakeRParens=0 II=0x1e0bf1f12a0 Text='i'
  M=0 C=0 T=BinaryOperator S=1 B=0 BK=0 P=42 Name=equal L=17 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='='
  M=0 C=1 T=Unknown S=1 B=0 BK=0 P=44 Name=numeric_constant L=19 PPK=2 
FakeLParens= FakeRParens=1 II=0x0 Text='0'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=43 Name=semi L=20 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=';'
  M=0 C=1 T=Unknown S=1 B=0 BK=0 P=40 Name=identifier L=22 PPK=2 
FakeLParens=10/ FakeRParens=0 II=0x1e0bf1f12a0 Text='i'
  M=0 C=0 T=TemplateOpener S=0 B=0 BK=0 P=50 Name=less L=23 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='<'
  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=380 Name=identifier L=28 PPK=2 
FakeLParens=0/ FakeRParens=0 II=0x1e0bf1f12d0 Text='nbits'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=283 Name=semi L=29 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=';'
  M=0 C=1 T=UnaryOperator S=1 B=0 BK=0 P=280 Name=plusplus L=32 PPK=2 
FakeLParens=0/1/ FakeRParens=0 II=0x0 Text='++'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=340 Name=identifier L=33 PPK=2 FakeLParens= 
FakeRParens=1 II=0x1e0bf1f12a0 Text='i'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=281 Name=comma L=34 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=','
  M=0 C=1 T=Unknown S=1 B=0 BK=0 P=281 Name=identifier L=38 PPK=2 
FakeLParens=0/ FakeRParens=0 II=0x1e0bf1f1300 Text='bIt'
  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=430 Name=period L=39 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='.'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=283 Name=identifier L=43 PPK=2 FakeLParens= 
FakeRParens=0 II=0x1e0bf1f1330 Text='next'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=283 Name=l_paren L=44 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=319 Name=r_paren L=45 PPK=2 FakeLParens= 
FakeRParens=1 II=0x0 Text=')'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=281 Name=comma L=46 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=','
  M=0 C=1 T=Unknown S=1 B=0 BK=0 P=281 Name=identifier L=48 PPK=2 
FakeLParens=2/ FakeRParens=0 II=0x1e0bf1f1360 Text='v'
  M=0 C=0 T=BinaryOperator S=1 B=0 BK=0 P=282 Name=equal L=50 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='='
  M=0 C=1 T=Unknown S=1 B=0 BK=0 P=284 Name=identifier L=52 PPK=2 FakeLParens= 
FakeRParens=3 II=0x1e0bf1f1360 Text='v'
  M=0 C=0 T=TemplateCloser S=0 B=0 BK=0 P=290 Name=greater L=53 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='>'
  M=0 C=0 T=BinaryOperator S=0 B=0 BK=0 P=50 Name=greater L=54 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='>'
  M=0 C=1 T=Unknown S=1 B=0 BK=0 P=50 Name=numeric_constant L=56 PPK=2 
FakeLParens= FakeRParens=2 II=0x0 Text='1'
  M=0 C=0 T=Unknown S=0 B=0 BK=0 P=43 Name=r_paren L=57 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=')'

This fix tries to avoid that issue by determining that a ";" between the `<` 
and `>` would not be a template (I couldn't think of an example where that 
would be the case, but I'm sure there are..

Afterwards the token are interpreted correctly for this line.  (

  M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=for L=3 PPK=2 FakeLParens= 
FakeRParens=0 II=0x1c891ac41b0 Text='for'
  M=0 C=0 T=Unknown S=1 B=0 BK=0 P=23 Name=l_paren L=5 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=1040 Name=unsigned L=13 PPK=2 
FakeLParens=2/0/ FakeRParens=0 II=0x1c891ac44f0 Text='unsigned'
  M=0 C=1 T=StartOfName S=1 B=0 BK=0 P=240 Name=identifier L=15 PPK=2 
FakeLParens= FakeRParens=0 II=0x1c891abce10 Text='i'
  M=0 C=0 T=BinaryOperator S=1 B=0 BK=0 P=42 Name=equal L=17 PPK=2 FakeLParens= 

[PATCH] D77910: AMDGPU: Define cl_khr_gl_sharing as a supported extension

2020-05-02 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In D77910#2015225 , @arsenm wrote:

> In D77910#1989163 , @b-sumner wrote:
>
> > In D77910#1988807 , @arsenm wrote:
> >
> > > In D77910#1981828 , @b-sumner 
> > > wrote:
> > >
> > > > In D77910#1981429 , @arsenm 
> > > > wrote:
> > > >
> > > > > In D77910#1976171 , 
> > > > > @b-sumner wrote:
> > > > >
> > > > > > I don't think we can guarantee this is or will be supported on all 
> > > > > > devices.  The language runtime makes this decision.
> > > > >
> > > > >
> > > > > We don't need to worry about theoretical devices. We should know the 
> > > > > properties of the driver from -amdhsa, -amdpal, -mesa3d
> > > >
> > > >
> > > > It takes more than support in the ISA for some features.  The OpenCL 
> > > > driver may not want to support a given optional feature, e.g. images.  
> > > > I'm not opposed to defaults, but if the driver chooses to not support 
> > > > images, it needs to be able to prevent `__IMAGE_SUPPORT__` from being 
> > > > defined.  Conformance will fail if the runtime and compiler are not 
> > > > consistent.
> > >
> > >
> > > The driver details should be captured by the the triple. If some weird 
> > > driver decided to do something different, we would need to add a new 
> > > triple for it. We don't have such a driver, so I don't see why worry 
> > > about it. It's possible to work around with undef and redef in an 
> > > implicitly included header. We need to fix properties of the driver based 
> > > on the target to have perfectly matching offline compilation
> >
> >
> > I don't see anywhere in the triple talking about driver specific details, 
> > unless you would use the environment?  That seems like overkill to me.  But 
> > again, I'm not opposed to defaults, and as long as the driver can override 
> > them, this should be OK.
>
>
> The OS is the driver. It doesn't need to specifically encode these details; 
> the OS should encode properties of the driver environment. Anything using 
> -amdhsa should be reporting image support


But that's not how things work now or are likely to work in the future.  The 
language runtime is what decides if it is going to report the availability of 
image support.  For offline compilation, I suppose it is OK to assume images 
are supported, but for online compilation, the language runtime needs to be 
able to reflect its own decision.


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

https://reviews.llvm.org/D77910



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


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2020-05-02 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D70500#134 , @bernhard wrote:

> > Would it work to increase the memory size, and then put your data in the 
> > new space this creates at the end of memory?
>
>
>
> > `__data_end` and `__heap_base` aren't things you can move around once the 
> > linker has defined them. Their values can be baked in elsewhere in the wasm 
> > module, so it's not safe in general to insert new memory in between them 
> > and shift things around.
>
> My plan was to embed arbitrary sized files directly into the data memory 
> after the wasm file was created. But I think you're right, it ends up only 
> working with simple wasm programs, more complex code crashes somewhere during 
> `__wasm_call_ctors` with the approach I took.


I think the way to embed data blobs in your final binary is to pass them to the 
linker as inputs.  There are various techniques listed here: 
https://csl.name/post/embedding-binary-data/.   I imagine not all them them 
will work with today's toolchain but we should strive to make those approaches 
work where possible.

> I guess custom sections would be the official route but I was hoping to avoid 
> having to pass the entire data through JavaScript before it reaches WASM land.
> 
> Also I'm very sorry to have hijacked this patch discussion with something 
> very different. If you have some more hints for me how I could accomplish 
> this I'd very gladly hear them, but if this is the wrong place we should 
> probably leave it at that. Thank you for your time!




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[PATCH] D79290: Update suffix check and cast non-suffix types

2020-05-02 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D79290#2016278 , @reikdas wrote:

> In D79290#2016273 , 
> @hubert.reinterpretcast wrote:
>
> > @reikdas, please upload the full copy of your combined changes to D77598 
> >  where the review is still active and 
> > close this.
>
>
> I am unable to add a diff/edit the old diff in the other revision(I think 
> since I am not the author of that review). Clicking on "Update Diff" only 
> allowed me to create a new revision.


Have you consulted with the author on the status of the other revision? The 
"Commandeer Revision" option under "Add Action" in the menu above the comment 
submission box might work from the technical side.


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

https://reviews.llvm.org/D79290



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


[PATCH] D79292: [sema] NFC Unable to build Sema library with MSVC Debug target due to missing /bigobj

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79292



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


[PATCH] D77925: Revert "[TLI] Per-function fveclib for math library used for vectorization"

2020-05-02 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D77925#2016299 , @wenlei wrote:

> @mehdi_amini @tejohnson When can we re-land this (with tweaks)? I'm under the 
> impression that a test case demonstrating the 3rd party usage will be added 
> very soon after this revert, then we can tweak the original patch to 
> accommodate that usage, and re-land asap. Or am I missing something there? 
> I'd like to get this unblocked asap. Currently we have to keep this as a 
> private patch on our end which is a bit cumbersome, and I think this one can 
> be useful for others too. Thanks..


@bkramer can you work with Wenlei on this (original patch is D77632 
).

@wenlei, in the meantime you can see the use case here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/xla/service/cpu/compiler_functor.cc#L198
for revising the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77925



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


[PATCH] D79292: [sema] NFC Unable to build Sema library with MSVC Debug target due to missing /bigobj

2020-05-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: ABataev, jdoerfert, aaron.ballman, rnk.
MyDeveloperDay added a project: clang.
Herald added a subscriber: mgorny.

Unable to build sema library on MSVC with Debug target

  C:\clang\llvm-project\clang\lib\Sema\SemaOpenMP.cpp : fatal error C1128: 
number of sections exceeded object file format limit: compile with /bigobj




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79292

Files:
  clang/lib/Sema/CMakeLists.txt


Index: clang/lib/Sema/CMakeLists.txt
===
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@ -9,6 +9,7 @@
   set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
   set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
+  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins


Index: clang/lib/Sema/CMakeLists.txt
===
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@ -9,6 +9,7 @@
   set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS /bigobj)
   set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES COMPILE_FLAGS /bigobj)
+  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77925: Revert "[TLI] Per-function fveclib for math library used for vectorization"

2020-05-02 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

@mehdi_amini @tejohnson When can we re-land this (with tweaks)? I'm under the 
impression that a test case demonstrating the 3rd party usage will be added 
very soon after this revert, then we can tweak the original patch to 
accommodate that usage, and re-land asap. Or am I missing something there? I'd 
like to get this unblocked asap. Currently we have to keep this as a private 
patch on our end which is a bit cumbersome, and I think this one can be useful 
for others too. Thanks..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77925



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


[PATCH] D79094: [SemaObjC] Warn on visibility attributes on an @implementation

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

This seems reasonable to me. I agree that this feels like it's something that 
should be written on the declaration in the header, not just magically appear 
on the definition, but I'm not an expert in ObjC to know if there are use cases 
where this may be useful.


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

https://reviews.llvm.org/D79094



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


[PATCH] D79113: Revert "Remove false positive in AvoidNonConstGlobalVariables."

2020-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I only see a comment on the issue, but not that the issue was resolved in favor 
of that comment (unless I've missed something). If the issue gets resolved in 
the direction that comment is going, then the revert makes sense (though we 
should add an explicit test case showing that we want the diagnostic).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79113



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


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

2020-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6898
   case ParsedAttr::AT_Constructor:
-handleConstructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << "";

This change (and the others like it) should be done within Attr.td and not 
exposed here. You should make these attributes target-specific.

You should also update AttrDocs.td for these attributes to document that 
they're not supported on AIX.



Comment at: clang/test/CodeGen/aix-priority-attribute.cpp:1-4
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | 
\
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 
| \
+// RUN: FileCheck %s

I think this test file should live in SemaCXX instead, as this is not testing 
the codegen behavior, but testing the semantic checking behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[clang] cc1c516 - Use realloc for NestedNameSpecifierLocBuilder

2020-05-02 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-05-02T17:12:44+02:00
New Revision: cc1c51655854627c126daf9ead4c701616564bde

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

LOG: Use realloc for NestedNameSpecifierLocBuilder

These allocations are so tiny that the buffer can be grown in-place most
of the time.

Added: 


Modified: 
clang/lib/AST/NestedNameSpecifier.cpp

Removed: 




diff  --git a/clang/lib/AST/NestedNameSpecifier.cpp 
b/clang/lib/AST/NestedNameSpecifier.cpp
index e28463516a9f..87bf4e122ec8 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -464,13 +464,14 @@ static void Append(char *Start, char *End, char *, 
unsigned ,
 unsigned NewCapacity = std::max(
 (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
 (unsigned)(BufferSize + (End - Start)));
-char *NewBuffer = static_cast(llvm::safe_malloc(NewCapacity));
-if (Buffer) {
-  memcpy(NewBuffer, Buffer, BufferSize);
-  if (BufferCapacity)
-free(Buffer);
+if (!BufferCapacity) {
+  char *NewBuffer = static_cast(llvm::safe_malloc(NewCapacity));
+  if (Buffer)
+memcpy(NewBuffer, Buffer, BufferSize);
+  Buffer = NewBuffer;
+} else {
+  Buffer = static_cast(llvm::safe_realloc(Buffer, NewCapacity));
 }
-Buffer = NewBuffer;
 BufferCapacity = NewCapacity;
   }
   assert(Buffer && Start && End && End > Start && "Illegal memory buffer 
copy");



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


[PATCH] D79121: Add nomerge function attribute to clang

2020-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This is missing Sema tests ensuring that the attribute only appertains to the 
correct subject, does not accept arguments, etc.




Comment at: clang/include/clang/Basic/AttrDocs.td:356
+  let Content = [{
+Calls to functions marked `nomerge` will not be merged during optimization.
+This attribute can be used to prevent the optimizer from obscuring the source

Looks like the docs need updating still. The functions aren't marked `nomerge`, 
statements are. This should explain the behavior of how we are lowering the 
`nomerge` attribute on call sites.



Comment at: clang/lib/CodeGen/CGCall.cpp:4526
 
+  // Add call-site nomerge attribute if exists
+  if (NoMerge)

Missing a full stop at the end of the comment.



Comment at: clang/lib/CodeGen/CGStmt.cpp:611
 void CodeGenFunction::EmitAttributedStmt(const AttributedStmt ) {
+  for (const auto *Attr: S.getAttrs())
+if (Attr->getKind() == attr::NoMerge) {

Please don't name the declaration `Attr` as that's a type name.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:175
+   SourceRange Range) {
+  return ::new (S.Context) NoMergeAttr(S.Context, A);
+}

Should there be semantic checking here? For instance, I would expect that 
writing a `nomerge` attribute on a statement which contains no call expressions 
should be diagnosed because something unexpected has happened.


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

https://reviews.llvm.org/D79121



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


[PATCH] D79204: [clang-format] NFC - clang-format the FormatTests

2020-05-02 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGece7e95f02cd: [clang-format] NFC - clang-format the 
FormatTests (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79204

Files:
  clang/unittests/Format/CleanupTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp
  clang/unittests/Format/FormatTestComments.cpp
  clang/unittests/Format/FormatTestJS.cpp
  clang/unittests/Format/FormatTestJava.cpp
  clang/unittests/Format/FormatTestObjC.cpp
  clang/unittests/Format/FormatTestProto.cpp
  clang/unittests/Format/FormatTestRawStrings.cpp
  clang/unittests/Format/FormatTestSelective.cpp
  clang/unittests/Format/FormatTestTextProto.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
  clang/unittests/Format/SortIncludesTest.cpp
  clang/unittests/Format/UsingDeclarationsSorterTest.cpp

Index: clang/unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- clang/unittests/Format/UsingDeclarationsSorterTest.cpp
+++ clang/unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -343,7 +343,8 @@
   {tooling::Range(19, 1)}));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsUsingDeclarationsWithLeadingkComments) {
+TEST_F(UsingDeclarationsSorterTest,
+   SortsUsingDeclarationsWithLeadingkComments) {
   EXPECT_EQ("/* comment */ using a;\n"
 "/* comment */ using b;",
 sortUsingDeclarations("/* comment */ using b;\n"
@@ -366,7 +367,6 @@
   "using e;\n"
   "using a;\n"
   "using e;"));
-
 }
 
 } // end namespace
Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -38,8 +38,7 @@
 return *Result;
   }
 
-  std::string sort(StringRef Code,
-   StringRef FileName = "input.cpp",
+  std::string sort(StringRef Code, StringRef FileName = "input.cpp",
unsigned ExpectedNumRanges = 1) {
 return sort(Code, GetCodeRange(Code), FileName, ExpectedNumRanges);
   }
@@ -227,7 +226,8 @@
  "#include \n"
  "#include \n"
  "#include \n"
- "/* clang-format onwards */\n", "input.h", 2));
+ "/* clang-format onwards */\n",
+ "input.h", 2));
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
@@ -291,7 +291,8 @@
 sort("#include \"a.h\"\n"
  "#include \"c.h\"\n"
  "\n"
- "#include \"b.h\"\n", "input.h", 0));
+ "#include \"b.h\"\n",
+ "input.h", 0));
 }
 
 TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
@@ -762,7 +763,8 @@
 sort("", "input.h", 0));
+ "-->",
+ "input.h", 0));
 }
 
 TEST_F(SortIncludesTest, DoNotOutputReplacementsForSortedBlocksWithRegrouping) {
Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -423,8 +423,7 @@
 TEST_F(NamespaceEndCommentsFixerTest, DoesNotAddEndCommentForShortNamespace) {
   EXPECT_EQ("namespace {}", fixNamespaceEndComments("namespace {}"));
   EXPECT_EQ("namespace A {}", fixNamespaceEndComments("namespace A {}"));
-  EXPECT_EQ("namespace A { a }",
-fixNamespaceEndComments("namespace A { a }"));
+  EXPECT_EQ("namespace A { a }", fixNamespaceEndComments("namespace A { a }"));
   EXPECT_EQ("namespace A { a };",
 fixNamespaceEndComments("namespace A { a };"));
 }
Index: clang/unittests/Format/FormatTestTextProto.cpp
===
--- clang/unittests/Format/FormatTestTextProto.cpp
+++ clang/unittests/Format/FormatTestTextProto.cpp
@@ -199,7 +199,7 @@
"field_c: {}");
 
   verifyFormat("field_a < field_b: 1 >,\n"
-   "msg_fid: < fiel_b: 123 >,\n" 
+   "msg_fid: < fiel_b: 123 >,\n"
"field_c <>");
 
   verifyFormat("field_a < field_b: 1 >\n"
@@ -450,14 +450,16 @@
" bb] { key: value }");
   // These go over the column limit intentionally, since the alternative
   // [aa..a\n] is worse.
-  verifyFormat("[] {\n"
-   "  key: value\n"
-   "}");
-  verifyFormat("[] {\n"
-   "  [type.type] {\n"
-   "keyy: value\n"
-   "  }\n"
- 

[PATCH] D79290: Update suffix check and cast non-suffix types

2020-05-02 Thread Pratyush Das via Phabricator via cfe-commits
reikdas added a comment.

In D79290#2016273 , 
@hubert.reinterpretcast wrote:

> @reikdas, please upload the full copy of your combined changes to D77598 
>  where the review is still active and close 
> this. This still doesn't address the `long long` versus 64-bit `long` that 
> was also mentioned.


I am unable to add a diff/edit the old diff in the other revision. Clicking on 
"Update Diff" only allowed me to create a new revision.


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

https://reviews.llvm.org/D79290



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


[clang] ece7e95 - [clang-format] NFC - clang-format the FormatTests

2020-05-02 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-02T15:42:20+01:00
New Revision: ece7e95f02cdcdf9fa7c6fdfbf6db92e4cc0c87e

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

LOG: [clang-format] NFC - clang-format the FormatTests

Summary:
Ensure the clang-format unit tests are themselves clang-formatted

Having areas of the llvm code which are clang-format clean, give us more areas 
to run new clang-format binaries on ensuring we haven't broken anything.

It seems to me we SHOULD have this clang-formatted at a minimum, otherwise how 
can we expect others to use clang-format if we "don't eat our own dogfood", 
also if the tests are dependent on the formatting of the code then that would 
also be bad!

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/unittests/Format/CleanupTest.cpp
clang/unittests/Format/FormatTestCSharp.cpp
clang/unittests/Format/FormatTestComments.cpp
clang/unittests/Format/FormatTestJS.cpp
clang/unittests/Format/FormatTestJava.cpp
clang/unittests/Format/FormatTestObjC.cpp
clang/unittests/Format/FormatTestProto.cpp
clang/unittests/Format/FormatTestRawStrings.cpp
clang/unittests/Format/FormatTestSelective.cpp
clang/unittests/Format/FormatTestTextProto.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
clang/unittests/Format/SortIncludesTest.cpp
clang/unittests/Format/UsingDeclarationsSorterTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/CleanupTest.cpp 
b/clang/unittests/Format/CleanupTest.cpp
index 70741d239c82..9649b981d558 100644
--- a/clang/unittests/Format/CleanupTest.cpp
+++ b/clang/unittests/Format/CleanupTest.cpp
@@ -479,7 +479,6 @@ TEST_F(CleanUpReplacementsTest, 
NoNewLineAtTheEndOfCodeMultipleInsertions) {
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-
 TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
   std::string Code = "\n"
  "int x;\n"

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 40367906c423..d8d992e091d9 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -761,7 +761,8 @@ TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) {
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new() {})", Style);
+where T : new() {})",
+   Style);
 
   verifyFormat(R"(//
 class Dictionary

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index 6dbc364fd255..d5b9f8e0885a 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -28,11 +28,7 @@ FormatStyle getGoogleStyle() { return 
getGoogleStyle(FormatStyle::LK_Cpp); }
 
 class FormatTestComments : public ::testing::Test {
 protected:
-  enum StatusCheck {
-SC_ExpectComplete,
-SC_ExpectIncomplete,
-SC_DoNotCheck
-  };
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
 
   std::string format(llvm::StringRef Code,
  const FormatStyle  = getLLVMStyle(),
@@ -649,7 +645,8 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
"//!line 4\n"
"//!line 5\n"
"// line 6\n"
-   "//line 7", getLLVMStyleWithColumns(20)));
+   "//line 7",
+   getLLVMStyleWithColumns(20)));
 
   EXPECT_EQ("// aa bb cc dd",
 format("// aa bb cc dd   ",
@@ -1346,7 +1343,8 @@ TEST_F(FormatTestComments, 
KeepsTrailingPPCommentsAndSectionCommentsSeparate) {
"  // section comment 3\n"
"  i = 4;\n"
"#endif\n"
-   "}", getLLVMStyleWithColumns(80));
+   "}",
+   getLLVMStyleWithColumns(80));
 }
 
 TEST_F(FormatTestComments, AlignsPPElseEndifComments) {
@@ -1824,14 +1822,13 @@ TEST_F(FormatTestComments, ReflowsComments) {
 
   // Reflow the last two lines of a section that starts with a line having
   // 
diff erent indentation.
-  EXPECT_EQ(
-  "// long\n"
-  "// long long long\n"
-  "// long long",
-  format("// long\n"
- "// long long long long\n"
- "// long",
- getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// long\n"
+"// long long long\n"
+"// long long",
+format("// long\n"
+   "// long long long long\n"
+   "// long",
+   getLLVMStyleWithColumns(20)));
 
   // Keep the block comment endling '*/' while reflowing.
   EXPECT_EQ("/* 

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-05-02 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D74051#2016101 , @mgorny wrote:

> In D74051#2016085 , @lebedev.ri 
> wrote:
>
> > In D74051#2016078 , @mgorny wrote:
> >
> > > This broke running clang tests stand-alone:
> > >
> > >   Traceback (most recent call last):
> > > File 
> > > "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang-abi_x86_64.amd64/bin/../../llvm/utils/lit/lit/TestingConfig.py",
> > >  line 89, in load_from_path
> > >   exec(compile(data, path, 'exec'), cfg_globals, None)
> > > File 
> > > "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang/test/utils/update_cc_test_checks/lit.local.cfg",
> > >  line 21, in 
> > >   assert os.path.isfile(script_path)
> > >   AssertionError
> > > 
> > >   FAILED: test/CMakeFiles/check-clang
> > >  
> > >
> > >
> > > Obviously this fails when LLVM source tree is not available.
> >
> >
> > Is that a supported build mode for clang?
>
>
> Yes, and I don't see why that would change today.
>
> > 
> > 
> >> If this is used only in clang, the script should be moved to clang as well.
> > 
> > I was under impression that it is exactly what this change did.
>
> My bad. In that case, the path needs to be updated to refer to clang source 
> tree and not llvm's.


The update_cc_test_checks.py script depends on files in 
llvm/utils/UpdateTestChecks, so moving the script to clang doesn't help.
I assumed that having clang as part of the monorepo meant llvm would be 
available.
I building a tarball of only the clang source directory is supported, then we 
should skip the clang/tests/utils/update_cc_test_checks tests subdirectory if 
LLVM sources are not available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[clang-tools-extra] d10c995 - std::isspace -> llvm::isSpace (where locale should be ignored)

2020-05-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-05-02T15:36:04+02:00
New Revision: d10c995b4ddf6be8f3a9c5ad61dd0becb5355cbe

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

LOG: std::isspace -> llvm::isSpace (where locale should be ignored)

I've left out some cases where I wasn't totally sure this was right or
whether the include was ok (compiler-rt) or idiomatic (flang).

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/CodeGen/TargetInstrInfo.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/lib/Support/FileUtilities.cpp
llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/tools/llvm-rc/ResourceScriptToken.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
index b2f514265177..acc258a5bc56 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
@@ -76,7 +76,7 @@ static std::string getExprAsString(const clang::Expr ,
   Text.erase(
   llvm::remove_if(
   Text,
-  [](char C) { return std::isspace(static_cast(C)); }),
+  [](char C) { return llvm::isSpace(static_cast(C)); }),
   Text.end());
   return Text;
 }

diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 87be93252227..e3953c5d8404 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/FixIt.h"
+#include "llvm/ADT/StringExtras.h"
 
 #include 
 
@@ -356,10 +357,10 @@ bool UseTrailingReturnTypeCheck::keepSpecifiers(
 unsigned int TOffsetInRT = TOffset - ReturnTypeBeginOffset - DeletedChars;
 unsigned int TLengthWithWS = CT.T.getLength();
 while (TOffsetInRT + TLengthWithWS < ReturnType.size() &&
-   std::isspace(ReturnType[TOffsetInRT + TLengthWithWS]))
+   llvm::isSpace(ReturnType[TOffsetInRT + TLengthWithWS]))
   TLengthWithWS++;
 std::string Specifier = ReturnType.substr(TOffsetInRT, TLengthWithWS);
-if (!std::isspace(Specifier.back()))
+if (!llvm::isSpace(Specifier.back()))
   Specifier.push_back(' ');
 Auto.insert(Auto.size() - InitialAutoLength, Specifier);
 ReturnType.erase(TOffsetInRT, TLengthWithWS);
@@ -459,7 +460,7 @@ void UseTrailingReturnTypeCheck::check(const 
MatchFinder::MatchResult ) {
 ReturnTypeEnd.getLocWithOffset(1)),
   SM, LangOpts);
   bool NeedSpaceAfterAuto =
-  CharAfterReturnType.empty() || !std::isspace(CharAfterReturnType[0]);
+  CharAfterReturnType.empty() || !llvm::isSpace(CharAfterReturnType[0]);
 
   std::string Auto = NeedSpaceAfterAuto ? "auto " : "auto";
   std::string ReturnType =

diff  --git a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp 
b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
index 1c3e00ca4ae8..4df2a9bf736a 100644
--- a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -75,7 +75,7 @@ mutatedBy(const SmallVectorImpl , ASTUnit 
*AST) {
 
 std::string removeSpace(std::string s) {
   s.erase(std::remove_if(s.begin(), s.end(),
- [](char c) { return std::isspace(c); }),
+ [](char c) { return llvm::isSpace(c); }),
   s.end());
   return s;
 }

diff  --git a/llvm/include/llvm/Support/YAMLTraits.h 
b/llvm/include/llvm/Support/YAMLTraits.h
index 316a6ad5d094..f93f36037679 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -649,8 +649,8 @@ inline bool isBool(StringRef S) {
 inline QuotingType needsQuotes(StringRef S) {
   if (S.empty())
 return QuotingType::Single;
-  if (isspace(static_cast(S.front())) ||
-  isspace(static_cast(S.back(
+  if (isSpace(static_cast(S.front())) ||
+  isSpace(static_cast(S.back(
 return QuotingType::Single;
   if (isNull(S))
 return QuotingType::Single;

diff  --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp 
b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 

[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-05-02 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked an inline comment as done.
sepavloff added inline comments.



Comment at: clang/docs/UsersManual.rst:770
+   $ cat abc
+   clang-11,"/tmp/foo-123456.o",92000,84000,87536
+   ld,"a.out",900,8000,53568

aganea wrote:
> sepavloff wrote:
> > aganea wrote:
> > > Please add a header to the output .CSV, specifying the units of measure 
> > > where relevant.
> > CSV was chosen because such file is a simple union of records. It is 
> > convenient if multiple processes write to it. A process locks the file, 
> > writes to it and unlock it.
> > 
> > If header is required, thing get more complicated. A process locks file, 
> > then moves to the end and get current position. If it is the beginning of 
> > the file, this process if the first writer, so it writes header. Then it 
> > writes line of data and unlock file.
> > 
> > On the other hand, CSV file is proposed for parsing by scripts. Does such 
> > complication really makes sense?
> Thanks for the explanation! Yes, it would be more complicated indeed if 
> locking is required. Let's forget the header if it's not practical.
> 
> However that raises a question: is it up to the user/build system to delete 
> the log file on startup? Otherwise each build would indefintely append, you 
> wouldn't know where your last build started in the log? How do you address 
> that currently?
> However that raises a question: is it up to the user/build system to delete 
> the log file on startup? Otherwise each build would indefintely append, you 
> wouldn't know where your last build started in the log? How do you address 
> that currently?

Yes, the log file is only appended. Users need to delete it if they want it 
contains results of one run only. However this feature is also used to collect 
statistics. User runs the same build several times and average needed metric 
for the same output file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78903



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


[clang-tools-extra] b283ae7 - [ADT] Add locale-independent isSpace() to StringExtras. NFC

2020-05-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-05-02T15:20:05+02:00
New Revision: b283ae7af8261c994a62b17b0eaf90cf649228fe

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

LOG: [ADT] Add locale-independent isSpace() to StringExtras. NFC

Use this in clangd, will follow up with replacements for isspace where
locale-dependent is clearly not intended.

Added: 


Modified: 
clang-tools-extra/clangd/support/Markup.cpp
llvm/include/llvm/ADT/StringExtras.h
llvm/unittests/ADT/StringExtrasTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Markup.cpp 
b/clang-tools-extra/clangd/support/Markup.cpp
index 94081b399a20..9dffdf675d3e 100644
--- a/clang-tools-extra/clangd/support/Markup.cpp
+++ b/clang-tools-extra/clangd/support/Markup.cpp
@@ -26,13 +26,6 @@ namespace clangd {
 namespace markup {
 namespace {
 
-/// Like std::isspace but for "C" locale.
-/// FIXME: move to StringExtras?
-bool isSpace(char C) {
-  return C == ' ' || C == '\f' || C == '\n' || C == '\r' || C == '\t' ||
- C == '\v';
-}
-
 // Is ' || Contents.startswith("/>"))
   return true; // May close the tag.
@@ -75,7 +68,7 @@ bool looksLikeTag(llvm::StringRef Contents) {
 // a markdown grammar construct.
 bool needsLeadingEscape(char C, llvm::StringRef Before, llvm::StringRef After,
 bool StartsLine) {
-  assert(Before.take_while(isSpace).empty());
+  assert(Before.take_while(llvm::isSpace).empty());
   auto RulerLength = [&]() -> /*Length*/ unsigned {
 if (!StartsLine || !Before.empty())
   return false;
@@ -87,8 +80,8 @@ bool needsLeadingEscape(char C, llvm::StringRef Before, 
llvm::StringRef After,
(After.empty() || After.startswith(" "));
   };
   auto SpaceSurrounds = [&]() {
-return (After.empty() || isSpace(After.front())) &&
-   (Before.empty() || isSpace(Before.back()));
+return (After.empty() || llvm::isSpace(After.front())) &&
+   (Before.empty() || llvm::isSpace(Before.back()));
   };
   auto WordSurrounds = [&]() {
 return (!After.empty() && llvm::isAlnum(After.front())) &&
@@ -434,8 +427,8 @@ Paragraph ::appendText(llvm::StringRef Text) {
   Chunk  = Chunks.back();
   C.Contents = std::move(Norm);
   C.Kind = Chunk::PlainText;
-  C.SpaceBefore = isSpace(Text.front());
-  C.SpaceAfter = isSpace(Text.back());
+  C.SpaceBefore = llvm::isSpace(Text.front());
+  C.SpaceAfter = llvm::isSpace(Text.back());
   return *this;
 }
 

diff  --git a/llvm/include/llvm/ADT/StringExtras.h 
b/llvm/include/llvm/ADT/StringExtras.h
index 3f73c0f3d456..56d5f3d05857 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -107,6 +107,14 @@ inline bool isPrint(char C) {
   return (0x20 <= UC) && (UC <= 0x7E);
 }
 
+/// Checks whether character \p C is whitespace in the "C" locale.
+///
+/// Locale-independent version of the C standard library isspace.
+inline bool isSpace(char C) {
+  return C == ' ' || C == '\f' || C == '\n' || C == '\r' || C == '\t' ||
+ C == '\v';
+}
+
 /// Returns the corresponding lowercase character if \p x is uppercase.
 inline char toLower(char x) {
   if (x >= 'A' && x <= 'Z')

diff  --git a/llvm/unittests/ADT/StringExtrasTest.cpp 
b/llvm/unittests/ADT/StringExtrasTest.cpp
index 681464e7e7c3..67d573d64975 100644
--- a/llvm/unittests/ADT/StringExtrasTest.cpp
+++ b/llvm/unittests/ADT/StringExtrasTest.cpp
@@ -23,6 +23,17 @@ TEST(StringExtrasTest, isPrint) {
   EXPECT_TRUE(isPrint('?'));
 }
 
+TEST(StringExtrasTest, isSpace) {
+  EXPECT_TRUE(isSpace(' '));
+  EXPECT_TRUE(isSpace('\t'));
+  EXPECT_TRUE(isSpace('\n'));
+  EXPECT_TRUE(isSpace('\v'));
+  EXPECT_TRUE(isSpace('\f'));
+  EXPECT_TRUE(isSpace('\v'));
+  EXPECT_FALSE(isSpace('\0'));
+  EXPECT_FALSE(isSpace('_'));
+}
+
 TEST(StringExtrasTest, Join) {
   std::vector Items;
   EXPECT_EQ("", join(Items.begin(), Items.end(), "  "));



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


[PATCH] D79139: [clangd] Fix whitespace between chunks in markdown paragraphs.

2020-05-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rGec170b7ccd5b: [clangd] Fix whitespace between chunks in 
markdown paragraphs. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79139

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2019,10 +2019,9 @@
"foo bar",
},
{
-   // FIXME: we insert spaces between code and text chunk.
"Tests primality of `p`.",
-   "Tests primality of `p` .",
-   "Tests primality of `p` .",
+   "Tests primality of `p`.",
+   "Tests primality of `p`.",
},
{
"'`' should not occur in `Code`",
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -155,11 +155,11 @@
   Paragraph P = Paragraph();
   P.appendText("One ");
   P.appendCode("fish");
-  P.appendText(", two");
+  P.appendText(", two ");
   P.appendCode("fish", /*Preserve=*/true);
 
-  EXPECT_EQ(P.asMarkdown(), "One `fish` , two `fish`");
-  EXPECT_EQ(P.asPlainText(), "One fish , two `fish`");
+  EXPECT_EQ(P.asMarkdown(), "One `fish`, two `fish`");
+  EXPECT_EQ(P.asPlainText(), "One fish, two `fish`");
 }
 
 TEST(Paragraph, SeparationOfChunks) {
@@ -168,17 +168,21 @@
   // Purpose is to check for separation between different chunks.
   Paragraph P;
 
-  P.appendText("after");
+  P.appendText("after ");
   EXPECT_EQ(P.asMarkdown(), "after");
   EXPECT_EQ(P.asPlainText(), "after");
 
-  P.appendCode("foobar");
+  P.appendCode("foobar").appendSpace();
   EXPECT_EQ(P.asMarkdown(), "after `foobar`");
   EXPECT_EQ(P.asPlainText(), "after foobar");
 
   P.appendText("bat");
   EXPECT_EQ(P.asMarkdown(), "after `foobar` bat");
   EXPECT_EQ(P.asPlainText(), "after foobar bat");
+
+  P.appendCode("no").appendCode("space");
+  EXPECT_EQ(P.asMarkdown(), "after `foobar` bat`no` `space`");
+  EXPECT_EQ(P.asPlainText(), "after foobar batno space");
 }
 
 TEST(Paragraph, ExtraSpaces) {
@@ -186,8 +190,16 @@
   Paragraph P;
   P.appendText("foo\n   \t   baz");
   P.appendCode(" bar\n");
-  EXPECT_EQ(P.asMarkdown(), "foo baz `bar`");
-  EXPECT_EQ(P.asPlainText(), "foo baz bar");
+  EXPECT_EQ(P.asMarkdown(), "foo baz`bar`");
+  EXPECT_EQ(P.asPlainText(), "foo bazbar");
+}
+
+TEST(Paragraph, SpacesCollapsed) {
+  Paragraph P;
+  P.appendText(" foo bar ");
+  P.appendText(" baz ");
+  EXPECT_EQ(P.asMarkdown(), "foo bar baz");
+  EXPECT_EQ(P.asPlainText(), "foo bar baz");
 }
 
 TEST(Paragraph, NewLines) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -773,7 +773,7 @@
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph  = Output.addHeading(3);
   if (Kind != index::SymbolKind::Unknown)
-Header.appendText(index::getSymbolKindString(Kind));
+Header.appendText(index::getSymbolKindString(Kind)).appendSpace();
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 
@@ -787,9 +787,9 @@
 // Parameters:
 // - `bool param1`
 // - `int param2 = 5`
-Output.addParagraph().appendText("→").appendCode(*ReturnType);
+Output.addParagraph().appendText("→ ").appendCode(*ReturnType);
 if (Parameters && !Parameters->empty()) {
-  Output.addParagraph().appendText("Parameters:");
+  Output.addParagraph().appendText("Parameters: ");
   markup::BulletList  = Output.addBulletList();
   for (const auto  : *Parameters) {
 std::string Buffer;
@@ -804,7 +804,7 @@
 
   if (Value) {
 markup::Paragraph  = Output.addParagraph();
-P.appendText("Value =");
+P.appendText("Value = ");
 P.appendCode(*Value);
   }
 
@@ -883,7 +883,7 @@
 break;
 }
   }
-  Out.appendText(Line);
+  Out.appendText(Line).appendSpace();
 }
 
 void parseDocumentation(llvm::StringRef Input, markup::Document ) {
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ 

[PATCH] D77598: Integral template argument suffix printing

2020-05-02 Thread Pratyush Das via Phabricator via cfe-commits
reikdas added a comment.

I updated the diff here - https://reviews.llvm.org/D79290.


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

https://reviews.llvm.org/D77598



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


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2020-05-02 Thread bernhard via Phabricator via cfe-commits
bernhard added a comment.

I had an application crash with optimizations enabled, so I wanted to keep the 
debug info but the automatic wasm-opt kept removing it and I lost another 30 
minutes to this, so I'm back :-)

Can we get clang not to automatically call wasm-opt if it is called without 
`-Xlinker -strip-all`, or when called with `-g` ?
Or at the very least, could it forward the `-g` along the `-O*` to wasm-opt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[clang-tools-extra] fa1f4cf - [clangd] Rename FormattedString -> Markup, move to support. NFC

2020-05-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-05-02T14:53:47+02:00
New Revision: fa1f4cf84326b59f917bccde784875c742e71740

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

LOG: [clangd] Rename FormattedString -> Markup, move to support. NFC

Added: 
clang-tools-extra/clangd/support/Markup.cpp
clang-tools-extra/clangd/support/Markup.h
clang-tools-extra/clangd/unittests/support/MarkupTests.cpp

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Hover.h
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/support/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 
clang-tools-extra/clangd/FormattedString.cpp
clang-tools-extra/clangd/FormattedString.h
clang-tools-extra/clangd/unittests/FormattedStringTests.cpp



diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index b8e179855b9d..dd3e02713559 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -44,7 +44,6 @@ add_clang_library(clangDaemon
   FileDistance.cpp
   Format.cpp
   FS.cpp
-  FormattedString.cpp
   FuzzyMatch.cpp
   GlobalCompilationDatabase.cpp
   Headers.cpp

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 882df4abf1ce..b0fc35bb632b 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -9,7 +9,6 @@
 #include "ClangdLSPServer.h"
 #include "Diagnostics.h"
 #include "DraftStore.h"
-#include "FormattedString.h"
 #include "GlobalCompilationDatabase.h"
 #include "Protocol.h"
 #include "SemanticHighlighting.h"

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 3dce7fec86c5..8cf0d863689f 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -10,7 +10,6 @@
 #include "CodeComplete.h"
 #include "FindSymbols.h"
 #include "Format.h"
-#include "FormattedString.h"
 #include "HeaderSourceSwitch.h"
 #include "Headers.h"
 #include "ParsedAST.h"
@@ -27,6 +26,7 @@
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Logger.h"
+#include "support/Markup.h"
 #include "support/Trace.h"
 #include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index d36dfd1e9a88..76fa64b5a314 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -11,7 +11,6 @@
 
 #include "../clang-tidy/ClangTidyOptions.h"
 #include "CodeComplete.h"
-#include "FormattedString.h"
 #include "GlobalCompilationDatabase.h"
 #include "Hover.h"
 #include "Protocol.h"

diff  --git a/clang-tools-extra/clangd/CodeComplete.h 
b/clang-tools-extra/clangd/CodeComplete.h
index 8c2908e445ae..7070aec79b79 100644
--- a/clang-tools-extra/clangd/CodeComplete.h
+++ b/clang-tools-extra/clangd/CodeComplete.h
@@ -15,7 +15,6 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 
-#include "FormattedString.h"
 #include "Headers.h"
 #include "Protocol.h"
 #include "Quality.h"
@@ -23,6 +22,7 @@
 #include "index/Symbol.h"
 #include "index/SymbolOrigin.h"
 #include "support/Logger.h"
+#include "support/Markup.h"
 #include "support/Path.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/CodeCompleteOptions.h"

diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 5e92ee189035..799d37626489 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -11,12 +11,12 @@
 #include "AST.h"
 #include "CodeCompletionStrings.h"
 #include "FindTarget.h"
-#include "FormattedString.h"
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
+#include "support/Markup.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"

diff  --git a/clang-tools-extra/clangd/Hover.h 
b/clang-tools-extra/clangd/Hover.h
index 73138c284b6c..931e1c2363a4 100644
--- a/clang-tools-extra/clangd/Hover.h
+++ b/clang-tools-extra/clangd/Hover.h
@@ -9,9 +9,9 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_HOVER_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_HOVER_H
 
-#include "FormattedString.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
+#include "support/Markup.h"
 #include 

[clang-tools-extra] ec170b7 - [clangd] Fix whitespace between chunks in markdown paragraphs.

2020-05-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-05-02T14:39:54+02:00
New Revision: ec170b7ccd5bf7aa05dea80e6f246964fd081e98

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

LOG: [clangd] Fix whitespace between chunks in markdown paragraphs.

Summary:
Old model: chunks are always separated by one space.
   This makes it impossible to render "Foo `bar`." correctly.

New model: chunks are separated by space if the left had trailing space, or
   the right had leading space, or space was explicitly requested.
   (Only leading/trailing space in plaintext chunks count, not code)

Reviewers: kadircet

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FormattedString.cpp
clang-tools-extra/clangd/FormattedString.h
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FormattedString.cpp 
b/clang-tools-extra/clangd/FormattedString.cpp
index 309cb69a2bfc..ae6eb1e31354 100644
--- a/clang-tools-extra/clangd/FormattedString.cpp
+++ b/clang-tools-extra/clangd/FormattedString.cpp
@@ -346,18 +346,21 @@ std::string Block::asPlainText() const {
 }
 
 void Paragraph::renderMarkdown(llvm::raw_ostream ) const {
-  llvm::StringRef Sep = "";
+  bool NeedsSpace = false;
+  bool HasChunks = false;
   for (auto  : Chunks) {
-OS << Sep;
+if (C.SpaceBefore || NeedsSpace)
+  OS << " ";
 switch (C.Kind) {
 case Chunk::PlainText:
-  OS << renderText(C.Contents, Sep.empty());
+  OS << renderText(C.Contents, !HasChunks);
   break;
 case Chunk::InlineCode:
   OS << renderInlineBlock(C.Contents);
   break;
 }
-Sep = " ";
+HasChunks = true;
+NeedsSpace = C.SpaceAfter;
   }
   // Paragraphs are translated into markdown lines, not markdown paragraphs.
   // Therefore it only has a single linebreak afterwards.
@@ -381,13 +384,15 @@ llvm::StringRef 
chooseMarker(llvm::ArrayRef Options,
 }
 
 void Paragraph::renderPlainText(llvm::raw_ostream ) const {
-  llvm::StringRef Sep = "";
+  bool NeedsSpace = false;
   for (auto  : Chunks) {
+if (C.SpaceBefore || NeedsSpace)
+  OS << " ";
 llvm::StringRef Marker = "";
 if (C.Preserve && C.Kind == Chunk::InlineCode)
   Marker = chooseMarker({"`", "'", "\""}, C.Contents);
-OS << Sep << Marker << C.Contents << Marker;
-Sep = " ";
+OS << Marker << C.Contents << Marker;
+NeedsSpace = C.SpaceAfter;
   }
   OS << '\n';
 }
@@ -410,6 +415,12 @@ void BulletList::renderPlainText(llvm::raw_ostream ) 
const {
   }
 }
 
+Paragraph ::appendSpace() {
+  if (!Chunks.empty())
+Chunks.back().SpaceAfter = true;
+  return *this;
+}
+
 Paragraph ::appendText(llvm::StringRef Text) {
   std::string Norm = canonicalizeSpaces(Text);
   if (Norm.empty())
@@ -418,10 +429,14 @@ Paragraph ::appendText(llvm::StringRef Text) {
   Chunk  = Chunks.back();
   C.Contents = std::move(Norm);
   C.Kind = Chunk::PlainText;
+  C.SpaceBefore = isWhitespace(Text.front());
+  C.SpaceAfter = isWhitespace(Text.back());
   return *this;
 }
 
 Paragraph ::appendCode(llvm::StringRef Code, bool Preserve) {
+  bool AdjacentCode =
+  !Chunks.empty() && Chunks.back().Kind == Chunk::InlineCode;
   std::string Norm = canonicalizeSpaces(std::move(Code));
   if (Norm.empty())
 return *this;
@@ -430,6 +445,8 @@ Paragraph ::appendCode(llvm::StringRef Code, bool 
Preserve) {
   C.Contents = std::move(Norm);
   C.Kind = Chunk::InlineCode;
   C.Preserve = Preserve;
+  // Disallow adjacent code spans without spaces, markdown can't render them.
+  C.SpaceBefore = AdjacentCode;
   return *this;
 }
 

diff  --git a/clang-tools-extra/clangd/FormattedString.h 
b/clang-tools-extra/clangd/FormattedString.h
index 295b22db8dab..06a8fd9052e6 100644
--- a/clang-tools-extra/clangd/FormattedString.h
+++ b/clang-tools-extra/clangd/FormattedString.h
@@ -54,6 +54,10 @@ class Paragraph : public Block {
   /// \p Preserve indicates the code span must be apparent even in plaintext.
   Paragraph (llvm::StringRef Code, bool Preserve = false);
 
+  /// Ensure there is space between the surrounding chunks.
+  /// Has no effect at the beginning or end of a paragraph.
+  Paragraph ();
+
 private:
   struct Chunk {
 enum {
@@ -63,6 +67,11 @@ class Paragraph : public Block {
 // Preserve chunk markers in plaintext.
 bool Preserve = false;
 std::string Contents;
+// Whether this chunk should be surrounded by whitespace.
+// Consecutive SpaceAfter and SpaceBefore will be collapsed into one space.
+// Code spans don't usually 

[PATCH] D78904: [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

2020-05-02 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas updated this revision to Diff 261634.
ztamas added a comment.

Spelling / grammar fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78904

Files:
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
@@ -3,6 +3,16 @@
 ///
 /// Test cases correctly caught by the check.
 
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+template 
+struct array {
+  T [](size_t n);
+  T (size_t n);
+};
+} // namespace std
+
 int SimpleVarDeclaration() {
   signed char CCharacter = -5;
   int NCharacter = CCharacter;
@@ -90,6 +100,16 @@
   return 0;
 }
 
+int SignedCharCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
+int SignedCharSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -207,3 +227,23 @@
 return 1;
   return 0;
 }
+
+int UnsignedCharCArraySubscript(unsigned char USCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)];
+}
+
+int UnsignedCharSTDArraySubscript(std::array Array, unsigned char USCharacter) {
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)];
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
@@ -31,11 +31,10 @@
 by default and so it is caught by this check or not. To change the default behavior
 you can use ``-funsigned-char`` and ``-fsigned-char`` compilation options.
 
-Currently, this check is limited to assignments and variable declarations,
-where a ``signed char`` is assigned to an integer variable and to
-equality/inequality comparisons between ``signed char`` and ``unsigned char``.
-There are other use cases where the unexpected value ranges might lead to
-similar bogus behavior.
+Currently, this check warns in the following cases:
+- ``signed char`` is assigned to an integer variable
+- ``signed char`` and ``unsigned char`` are compared with equality/inequality operator
+- ``signed char`` is converted to an integer in the array subscript
 
 See also:
 `STR34-C. Cast characters to unsigned char before converting to larger integer sizes
Index: clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -102,11 +102,31 @@
   .bind("comparison");
 
   Finder->addMatcher(CompareOperator, this);
+
+  // Catch array subscripts with signed char -> integer conversion.
+  // Matcher for C arrays.
+  const auto CArraySubscript =
+  arraySubscriptExpr(hasIndex(SignedCharCastExpr)).bind("arraySubscript");
+
+  Finder->addMatcher(CArraySubscript, this);
+
+  // Matcher for std arrays.
+  const auto STDArraySubscript =
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("[]"),
+  hasArgument(0, hasType(cxxRecordDecl(hasName("::std::array",
+  hasArgument(1, SignedCharCastExpr))
+  .bind("arraySubscript");
+
+  Finder->addMatcher(STDArraySubscript, this);
 }
 
 void SignedCharMisuseCheck::check(const MatchFinder::MatchResult ) {
   const auto *SignedCastExpression =
   Result.Nodes.getNodeAs("signedCastExpression");
+  const auto *IntegerType = Result.Nodes.getNodeAs("integerType");
+  assert(SignedCastExpression);
+  assert(IntegerType);
 
   // Ignore the match if we know that the signed char's value is 

[PATCH] D78429: [clangd] Metric tracking through Tracer

2020-05-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Still LG




Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:1047
   Server, FooHPath, RenamePos, NewName, {/*CrossFile=*/true}));
+  EXPECT_THAT(Tracer.takeMetric("rename_files"), SizeIs(1));
   EXPECT_THAT(

I think this one should be elementsAre(2) though rather than just asserting 
that there's some measurement?



Comment at: clang-tools-extra/clangd/unittests/support/TestTracer.cpp:33
+return {};
+  return std::move(ValuesIt->getValue());
+}

nit: vector's moved-from state is unspecified :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78429



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


[PATCH] D78904: [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

2020-05-02 Thread Tamás Zolnai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG030ff901f432: [clang-tidy] extend 
bugprone-signed-char-misuse check with array subscript case. (authored by 
ztamas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78904

Files:
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
@@ -3,6 +3,16 @@
 ///
 /// Test cases correctly caught by the check.
 
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+template 
+struct array {
+  T [](size_t n);
+  T (size_t n);
+};
+} // namespace std
+
 int SimpleVarDeclaration() {
   signed char CCharacter = -5;
   int NCharacter = CCharacter;
@@ -90,6 +100,16 @@
   return 0;
 }
 
+int SignedCharCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
+int SignedCharSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -207,3 +227,23 @@
 return 1;
   return 0;
 }
+
+int UnsignedCharCArraySubscript(unsigned char USCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)];
+}
+
+int UnsignedCharSTDArraySubscript(std::array Array, unsigned char USCharacter) {
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)];
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
@@ -31,11 +31,10 @@
 by default and so it is caught by this check or not. To change the default behavior
 you can use ``-funsigned-char`` and ``-fsigned-char`` compilation options.
 
-Currently, this check is limited to assignments and variable declarations,
-where a ``signed char`` is assigned to an integer variable and to
-equality/inequality comparisons between ``signed char`` and ``unsigned char``.
-There are other use cases where the unexpected value ranges might lead to
-similar bogus behavior.
+Currently, this check warns in the following cases:
+- ``signed char`` is assigned to an integer variable
+- ``signed char`` and ``unsigned char`` are compared with equality/inequality operator
+- ``signed char`` is converted to an integer in the array subscript
 
 See also:
 `STR34-C. Cast characters to unsigned char before converting to larger integer sizes
Index: clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -102,11 +102,31 @@
   .bind("comparison");
 
   Finder->addMatcher(CompareOperator, this);
+
+  // Catch array subscripts with signed char -> integer conversion.
+  // Matcher for C arrays.
+  const auto CArraySubscript =
+  arraySubscriptExpr(hasIndex(SignedCharCastExpr)).bind("arraySubscript");
+
+  Finder->addMatcher(CArraySubscript, this);
+
+  // Matcher for std arrays.
+  const auto STDArraySubscript =
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("[]"),
+  hasArgument(0, hasType(cxxRecordDecl(hasName("::std::array",
+  hasArgument(1, SignedCharCastExpr))
+  .bind("arraySubscript");
+
+  Finder->addMatcher(STDArraySubscript, this);
 }
 
 void SignedCharMisuseCheck::check(const MatchFinder::MatchResult ) {
   const auto *SignedCastExpression =
   Result.Nodes.getNodeAs("signedCastExpression");
+  const auto *IntegerType = Result.Nodes.getNodeAs("integerType");
+  

[clang-tools-extra] 030ff90 - [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

2020-05-02 Thread Tamás Zolnai via cfe-commits

Author: Tamás Zolnai
Date: 2020-05-02T14:05:05+02:00
New Revision: 030ff901f43258d18b68a77b0085d0fae2a0fbc6

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

LOG: [clang-tidy] extend bugprone-signed-char-misuse check with array subscript 
case.

Summary:
To cover STR34-C rule's second use case, where ``signed char`` is
used for array subscript after an integer conversion. In the case
of non-ASCII character this conversion will result in a value
in excess of UCHAR_MAX.

There is another clang-tidy check which catches these cases.
cppcoreguidelines-pro-bounds-constant-array-index catches any
indexing which is not integer constant. I think this check is
very strict about the index (e.g. constant), so it's still useful
to cover the ``signed char`` use case in this check, so we
can provide a way to catch the SEI cert rule's use cases on a
codebase, where this CPP guideline is not used.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
index 732ccbc9dd2a..66f00e35c7e7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -102,11 +102,31 @@ void SignedCharMisuseCheck::registerMatchers(MatchFinder 
*Finder) {
   .bind("comparison");
 
   Finder->addMatcher(CompareOperator, this);
+
+  // Catch array subscripts with signed char -> integer conversion.
+  // Matcher for C arrays.
+  const auto CArraySubscript =
+  arraySubscriptExpr(hasIndex(SignedCharCastExpr)).bind("arraySubscript");
+
+  Finder->addMatcher(CArraySubscript, this);
+
+  // Matcher for std arrays.
+  const auto STDArraySubscript =
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("[]"),
+  hasArgument(0, hasType(cxxRecordDecl(hasName("::std::array",
+  hasArgument(1, SignedCharCastExpr))
+  .bind("arraySubscript");
+
+  Finder->addMatcher(STDArraySubscript, this);
 }
 
 void SignedCharMisuseCheck::check(const MatchFinder::MatchResult ) {
   const auto *SignedCastExpression =
   Result.Nodes.getNodeAs("signedCastExpression");
+  const auto *IntegerType = Result.Nodes.getNodeAs("integerType");
+  assert(SignedCastExpression);
+  assert(IntegerType);
 
   // Ignore the match if we know that the signed char's value is not negative.
   // The potential misinterpretation happens for negative values only.
@@ -135,14 +155,17 @@ void SignedCharMisuseCheck::check(const 
MatchFinder::MatchResult ) {
 
 diag(Comparison->getBeginLoc(),
  "comparison between 'signed char' and 'unsigned char'");
-  } else if (const auto *IntegerType =
- Result.Nodes.getNodeAs("integerType")) {
+  } else if (Result.Nodes.getNodeAs("arraySubscript")) {
+diag(SignedCastExpression->getBeginLoc(),
+ "'signed char' to %0 conversion in array subscript; "
+ "consider casting to 'unsigned char' first.")
+<< *IntegerType;
+  } else {
 diag(SignedCastExpression->getBeginLoc(),
  "'signed char' to %0 conversion; "
  "consider casting to 'unsigned char' first.")
 << *IntegerType;
-  } else
-llvm_unreachable("Unexpected match");
+  }
 }
 
 } // namespace bugprone

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
index e3ecf75a3a52..c2bd2df062b1 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
@@ -31,11 +31,10 @@ It depends on the actual platform whether plain ``char`` is 
handled as ``signed
 by default and so it is caught by this check or not. To change the default 
behavior
 you can use ``-funsigned-char`` and ``-fsigned-char`` compilation options.
 
-Currently, this check is limited to assignments and variable declarations,
-where a ``signed char`` is assigned to an integer variable and to
-equality/inequality comparisons between ``signed char`` and ``unsigned char``.
-There are other use cases where the unexpected value ranges might lead to
-similar bogus behavior.
+Currently, this check warns in the following cases:
+- ``signed char`` is assigned to an integer 

[PATCH] D79285: [clang-tidy] Add diagnostics level to YAML output

2020-05-02 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: alexfh, gribozavr2.
DmitryPolukhin added projects: clang-tools-extra, clang.
Herald added a subscriber: xazax.hun.

Also added BuildDirectory for completness and removed unused `Fix`.

Test Plan: check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79285

Files:
  clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
  clang/include/clang/Tooling/DiagnosticsYaml.h
  clang/unittests/Tooling/DiagnosticsYamlTest.cpp

Index: clang/unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- clang/unittests/Tooling/DiagnosticsYamlTest.cpp
+++ clang/unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -65,6 +65,8 @@
 "  Offset:  100\n"
 "  Length:  12\n"
 "  ReplacementText: 'replacement #1'\n"
+"Level:   Warning\n"
+"BuildDirectory:  'path/to/build/directory'\n"
 "  - DiagnosticName:  'diagnostic#2'\n"
 "DiagnosticMessage:\n"
 "  Message: 'message #2'\n"
@@ -75,6 +77,8 @@
 "  Offset:  62\n"
 "  Length:  2\n"
 "  ReplacementText: 'replacement #2'\n"
+"Level:   Warning\n"
+"BuildDirectory:  'path/to/build/directory'\n"
 "Ranges:\n"
 "  - FilePath:'path/to/source.cpp'\n"
 "FileOffset:  10\n"
@@ -94,6 +98,8 @@
 "FilePath:'path/to/note2.cpp'\n"
 "FileOffset:  99\n"
 "Replacements:[]\n"
+"Level:   Warning\n"
+"BuildDirectory:  'path/to/build/directory'\n"
 "...\n";
 
 TEST(DiagnosticsYamlTest, serializesDiagnostics) {
Index: clang/include/clang/Tooling/DiagnosticsYaml.h
===
--- clang/include/clang/Tooling/DiagnosticsYaml.h
+++ clang/include/clang/Tooling/DiagnosticsYaml.h
@@ -77,7 +77,6 @@
 
 std::string DiagnosticName;
 clang::tooling::DiagnosticMessage Message;
-llvm::StringMap Fix;
 SmallVector Notes;
 clang::tooling::Diagnostic::Level DiagLevel;
 std::string BuildDirectory;
@@ -90,9 +89,9 @@
 Io.mapRequired("DiagnosticName", Keys->DiagnosticName);
 Io.mapRequired("DiagnosticMessage", Keys->Message);
 Io.mapOptional("Notes", Keys->Notes);
+Io.mapOptional("Level", Keys->DiagLevel);
+Io.mapOptional("BuildDirectory", Keys->BuildDirectory);
 Io.mapOptional("Ranges", Keys->Ranges);
-
-// FIXME: Export properly all the different fields.
   }
 };
 
@@ -104,6 +103,14 @@
 Io.mapRequired("Diagnostics", Doc.Diagnostics);
   }
 };
+
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO , clang::tooling::Diagnostic::Level ) {
+IO.enumCase(Value, "Warning", clang::tooling::Diagnostic::Warning);
+IO.enumCase(Value, "Error", clang::tooling::Diagnostic::Error);
+  }
+};
+
 } // end namespace yaml
 } // end namespace llvm
 
Index: clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
@@ -1,15 +1,17 @@
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t-input.cpp
-// RUN: clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes' -export-fixes=%t.yaml -- -Wmissing-prototypes > %t.msg 2>&1
+// RUN: not clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes' -export-fixes=%t.yaml -- -Wmissing-prototypes > %t.msg 2>&1
 // RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s -implicit-check-not='{{warning|error|note}}:'
 // RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
 #define X(n) void n ## n() {}
 X(f)
+int a[-1];
 
 // CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes]
 // CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
 // CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
 // CHECK-MESSAGES: -input.cpp:2:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
 // CHECK-MESSAGES: -input.cpp:1:14: note: expanded from macro 'X'
+// CHECK-MESSAGES: -input.cpp:3:7: error: 'a' declared as an array with a negative size [clang-diagnostic-error]
 
 // CHECK-YAML: ---
 // CHECK-YAML-NEXT: MainSourceFile:  '{{.*}}-input.cpp'
@@ -42,4 +44,18 @@
 // CHECK-YAML-NEXT: FilePath:'{{.*}}-input.cpp'
 // CHECK-YAML-NEXT: FileOffset:  13
 // CHECK-YAML-NEXT: Replacements:[]
+// CHECK-YAML-NEXT: Level:   Warning
+// CHECK-YAML-NEXT: BuildDirectory:  '{{.*}}'
+// CHECK-YAML-NEXT:   - DiagnosticName:  clang-diagnostic-error
+// 

[PATCH] D79232: [analyzer] Refactor range inference for symbolic expressions

2020-05-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked 3 inline comments as done.
vsavchenko added a comment.

> Very nice, i like this architecture.

Aww, thanks 

> @baloghadamsoftware @steakhal @ASDenysPetrov will you be able to plug D49074 
> /D50256 
> /D77792 
> /D77802 
> /D78933  
> into this so that to separate algebra from pattern-matching and ensure no 
> performance regressions? Or is something still missing?

Yeah, I'll be happy to hear what will be good to have for all the different 
cases we have and might have in the future.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:271-281
+  RangeSet VisitSymIntExpr(const SymIntExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }
+
+  RangeSet VisitIntSymExpr(const IntSymExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }

NoQ wrote:
> Can we replace these three with a single `VisitBinarySymExpr()`? Or is there 
> too much template duck typing involved?
Unfortunately no, we need to know more derived types in order to use `getLHS` 
and `getRHS` methods. And that's why `VisitBinaryOperator` function is a 
template.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:340-345
+// TODO #2: We didn't go into the nested expressions before, so it
+// might cause us spending much more time doing the inference.
+// This can be a problem for deeply nested expressions that are
+// involved in conditions and get tested continuously.  We definitely
+// need to address this issue and introduce some sort of caching
+// in here.

NoQ wrote:
> I think this is a must-have, at least in some form. We've been exploding like 
> this before on real-world code, well, probably not with bitwise ops but i'm 
> still worried.
It will be pretty easy to introduce a limit on how deep we go into a tree of 
the given symbolic expression. That can also be a solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79232



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


[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-05-02 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:83
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 

https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78903



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


[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-05-02 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 261621.
sepavloff added a comment.

Updated patch

- added variant of the option without file, it is used to print statistics on 
stdout.
- Updated file locking mechanism.
- Updated test and documentation accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78903

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Job.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Job.cpp
  clang/test/Driver/report-stat.c

Index: clang/test/Driver/report-stat.c
===
--- /dev/null
+++ clang/test/Driver/report-stat.c
@@ -0,0 +1,6 @@
+// RUN: %clang -c -fproc-stat-report %s | FileCheck %s
+// CHECK: clang{{.*}}: output={{.*}}.o, total={{[0-9.]+}} ms, user={{[0-9.]+}} ms, mem={{[0-9]+}} Kb
+
+// RUN: %clang -c -fproc-stat-report=%t %s
+// RUN: cat %t | FileCheck --check-prefix=CSV %s
+// CSV: clang{{.*}},"{{.*}}.o",{{[0-9]+}},{{[0-9]+}},{{[0-9]+}}
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -370,8 +370,8 @@
 
   auto Args = llvm::toStringRefArray(Argv.data());
   return llvm::sys::ExecuteAndWait(Executable, Args, Env, Redirects,
-   /*secondsToWait*/ 0,
-   /*memoryLimit*/ 0, ErrMsg, ExecutionFailed);
+  /*secondsToWait*/ 0, /*memoryLimit*/ 0, ErrMsg, ExecutionFailed,
+  );
 }
 
 CC1Command::CC1Command(const Action , const Tool ,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -80,6 +80,7 @@
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 #include 
 #include 
@@ -3757,11 +3758,70 @@
/*TargetDeviceOffloadKind*/ Action::OFK_None);
   }
 
-  // If we have more than one job, then disable integrated-cc1 for now.
-  if (C.getJobs().size() > 1)
+  StringRef StatReportFile;
+  bool PrintProcessStat = false;
+  if (const Arg *A = C.getArgs().getLastArg(options::OPT_fproc_stat_report_EQ))
+StatReportFile = A->getValue();
+  if (C.getArgs().hasArg(options::OPT_fproc_stat_report))
+PrintProcessStat = true;
+
+  // If we have more than one job, then disable integrated-cc1 for now. Do this
+  // also when we need to report process execution statistics.
+  if (C.getJobs().size() > 1 || !StatReportFile.empty() || PrintProcessStat)
 for (auto  : C.getJobs())
   J.InProcess = false;
 
+  if (!StatReportFile.empty() || PrintProcessStat) {
+C.setPostCallback([=](const Command , int Res) {
+  Optional ProcStat
+  = Cmd.getProcessStatistics();
+  if (ProcStat) {
+if (PrintProcessStat) {
+  using namespace llvm;
+  // Human readable output.
+  outs() << sys::path::filename(Cmd.getExecutable()) << ": "
+ << "output=";
+  if (Cmd.getOutputFilenames().empty())
+outs() << "\"\"";
+  else
+outs() << Cmd.getOutputFilenames().front();
+  outs() << ", total="
+ << format("%.3f", ProcStat->TotalTime.count() / 1000.) << " ms"
+ << ", user="
+ << format("%.3f", ProcStat->UserTime.count() / 1000.) << " ms"
+ << ", mem=" << ProcStat->PeakMemory << " Kb\n";
+}
+if (!StatReportFile.empty()) {
+  // CSV format.
+  std::string Buffer;
+  llvm::raw_string_ostream Out(Buffer);
+  Out << llvm::sys::path::filename(Cmd.getExecutable()) << ',';
+  if (Cmd.getOutputFilenames().empty())
+Out << "\"\"";
+  else
+Command::printArg(Out, Cmd.getOutputFilenames().front(), true);
+  Out << ','
+  << ProcStat->TotalTime.count() << ','
+  << ProcStat->UserTime.count() << ','
+  << ProcStat->PeakMemory << '\n';
+  Out.flush();
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(StatReportFile, EC, llvm::sys::fs::OF_Append);
+  if (!EC) {
+if (auto L = llvm::sys::fs::tryLock(OS.getFD()))
+  OS << Buffer;
+else
+  handleAllErrors(std::move(L.takeError()),
+  [&](llvm::ErrorInfoBase ) {
+llvm::errs() << "ERROR: Cannot lock file " << StatReportFile
+ << "n";
+  });
+  }
+}
+  }
+});
+  }
+
   // If the user passed -Qunused-arguments or there were errors, don't warn
   // about any unused arguments.
   if (Diags.hasErrorOccurred() ||
Index: clang/include/clang/Driver/Options.td

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-05-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D74051#2016085 , @lebedev.ri wrote:

> In D74051#2016078 , @mgorny wrote:
>
> > This broke running clang tests stand-alone:
> >
> >   Traceback (most recent call last):
> > File 
> > "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang-abi_x86_64.amd64/bin/../../llvm/utils/lit/lit/TestingConfig.py",
> >  line 89, in load_from_path
> >   exec(compile(data, path, 'exec'), cfg_globals, None)
> > File 
> > "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang/test/utils/update_cc_test_checks/lit.local.cfg",
> >  line 21, in 
> >   assert os.path.isfile(script_path)
> >   AssertionError
> > 
> >   FAILED: test/CMakeFiles/check-clang
> >  
> >
> >
> > Obviously this fails when LLVM source tree is not available.
>
>
> Is that a supported build mode for clang?


Yes, and I don't see why that would change today.

> 
> 
>> If this is used only in clang, the script should be moved to clang as well.
> 
> I was under impression that it is exactly what this change did.

My bad. In that case, the path needs to be updated to refer to clang source 
tree and not llvm's.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-05-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D74051#2016078 , @mgorny wrote:

> This broke running clang tests stand-alone:
>
>   Traceback (most recent call last):
> File 
> "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang-abi_x86_64.amd64/bin/../../llvm/utils/lit/lit/TestingConfig.py",
>  line 89, in load_from_path
>   exec(compile(data, path, 'exec'), cfg_globals, None)
> File 
> "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang/test/utils/update_cc_test_checks/lit.local.cfg",
>  line 21, in 
>   assert os.path.isfile(script_path)
>   AssertionError
> 
>   FAILED: test/CMakeFiles/check-clang
>  
>
>
> Obviously this fails when LLVM source tree is not available.


Is that a supported build mode for clang?

> If this is used only in clang, the script should be moved to clang as well.

I was under impression that it is exactly what this change did.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


LLVM lab network works on May 2nd at 11:00 am PDT

2020-05-02 Thread Galina Kistanova via cfe-commits
Hello everyone,


LLVM buildmaster will be unavailable tomorrow on Saturday, May 2nd at
11:00AM PDT due to network maintenance works.

Hopefully this will take about half hour.


Thank you for understanding.


Thanks


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


[PATCH] D79232: [analyzer] Refactor range inference for symbolic expressions

2020-05-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a subscriber: steakhal.
NoQ added a comment.

Very nice, i like this architecture.

@baloghadamsoftware @steakhal @ASDenysPetrov will you be able to plug D49074 
/D50256 
/D77792 
/D77802 
/D78933  into 
this so that to separate algebra from pattern-matching and ensure no 
performance regressions? Or is something still missing?




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:271-281
+  RangeSet VisitSymIntExpr(const SymIntExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }
+
+  RangeSet VisitIntSymExpr(const IntSymExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }

Can we replace these three with a single `VisitBinarySymExpr()`? Or is there 
too much template duck typing involved?



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:340-345
+// TODO #2: We didn't go into the nested expressions before, so it
+// might cause us spending much more time doing the inference.
+// This can be a problem for deeply nested expressions that are
+// involved in conditions and get tested continuously.  We definitely
+// need to address this issue and introduce some sort of caching
+// in here.

I think this is a must-have, at least in some form. We've been exploding like 
this before on real-world code, well, probably not with bitwise ops but i'm 
still worried.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79232



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


[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-05-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

This broke running clang tests stand-alone:

  Traceback (most recent call last):
File 
"/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang-abi_x86_64.amd64/bin/../../llvm/utils/lit/lit/TestingConfig.py",
 line 89, in load_from_path
  exec(compile(data, path, 'exec'), cfg_globals, None)
File 
"/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang/test/utils/update_cc_test_checks/lit.local.cfg",
 line 21, in 
  assert os.path.isfile(script_path)
  AssertionError
 
  FAILED: test/CMakeFiles/check-clang

Obviously this fails when LLVM source tree is not available. If this is used 
only in clang, the script should be moved to clang as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[PATCH] D79118: Implement _ExtInt ABI for all ABIs in Clang, enable type for ABIs

2020-05-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

A little cavalier with `byval`; I gave it a thorough audit, but you might want 
your own pass.




Comment at: clang/lib/CodeGen/ABIInfo.h:107
+// only difference is that this considers _ExtInt as well.
+bool isPromotableIntegerType(QualType Ty) const;
+

Maybe add a "ForABI" suffix here so that it's clearer that this is a 
specialized use-case.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:719
+ !getContext().getTargetInfo().hasInt128Type()))
+  return getNaturalAlignIndirect(Ty);
+

It's very weird for 64 and 128 to be showing up as constants in the default ABI 
rule.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1537
+  return (isPromotableIntegerType(RetTy) ? ABIArgInfo::getExtend(RetTy)
+ : ABIArgInfo::getDirect());
 }

Won't this treat literally all ExtInt types as either extend or direct?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4938
+if (EIT->getNumBits() > 128)
+  return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
+

Does this need to consider the aggregate-as-array logic below?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:5014
+if (EIT->getNumBits() > 128)
+  return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);
+

`byval` is not legal on return values.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:6339
+  if (EIT->getNumBits() > 64)
+return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);
+

`byval` is not legal on return types.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:6658
 /// Checks if the type is unsupported directly by the current target.
 static bool isUnsupportedType(ASTContext , QualType T) {
   if (!Context.getTargetInfo().hasFloat16Type() && T->isFloat16Type())

Ugh.  Please go ahead and rename this to make it clear that it's an NVPTX 
helper function.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7921
+if (Size > 64 && RetTy->isExtIntType())
+  return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);
+

`byval` is not legal on a return.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8988
 
-  uint64_t Size = getContext().getTypeSize(Ty);
+  uint64_t Size = getContext().getIntWidth(Ty);
 

Why this change?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10297
+   EIT->getNumBits() > 64))
+return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
+}

Looks like this shouldn't be `byval`.


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

https://reviews.llvm.org/D79118



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