[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2019-12-20 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

> Will it make sense to say "I don't want hyper-threads" ?

Not sure I remember correctly, but I believe one motivation behind avoiding 
"hyper-threads" and other virtual cores was that while they improve slightly 
the performance, they also increase the peak memory requirements: using 
heavyweight_hardware_concurrency() seemed like a good default tradeoff for most 
end-users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775



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


[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2019-12-20 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Also: using heavyweight_hardware_concurrency() in the linker but having 
multiple linker jobs schedules by the build system was another reason (I think 
LLVM CMake default to 2 parallel link jobs when using ThinLTO for instance).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775



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


[PATCH] D71746: Fix the "TypeError: a bytes-like object is required, not 'str'" in exploded-graph-rewriter.py on Python 3.5+

2019-12-20 Thread Pavel Samolysov via Phabricator via cfe-commits
psamolysov added a comment.

@NoQ Could you commit, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71746



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


[PATCH] D71686: Fix false positive in magic number checker

2019-12-20 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- marked an inline comment as done.
0x8000- added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-todo.cpp:9
+{
+  if (((int)4) > ProcessSomething(10))
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 4 is a magic number; consider 
replacing it with a named constant [readability-magic-numbers]

This test fails even with clang-tidy-9.


```
$ clang-tidy-9 --checks="-*,readability-magic-numbers" 
clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-todo.cpp

/home/florin/tools/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-todo.cpp:9:35:
 warning: 10 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
  if (((int)4) > ProcessSomething(10))
  ^
```

Nothing about the "4" here.


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

https://reviews.llvm.org/D71686



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


[PATCH] D71686: Fix false positive in magic number checker

2019-12-20 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- updated this revision to Diff 234998.
0x8000- added a comment.

Add a test file for expected failures


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

https://reviews.llvm.org/D71686

Files:
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-todo.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
@@ -59,7 +59,7 @@
   const int anotherConstant;
 };
 
-int ValueArray[] = {3, 5};
+int ValueArray[] = {3, 5, 0, 0, 0};
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider 
replacing it with a named constant [readability-magic-numbers]
 // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider 
replacing it with a named constant [readability-magic-numbers]
 
@@ -215,3 +215,14 @@
 
   return Total;
 }
+
+// prove that using enumerations values don't produce warnings
+enum class Letter : unsigned {
+A, B, C, D, E, F, G, H, I, J
+};
+
+template struct holder  { Letter letter = x;  };
+template struct wrapper { using h_type = holder;  };
+
+template struct wrapper;
+template struct wrapper;
Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-todo.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-todo.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s readability-magic-numbers %t
+// RUN: --
+// XFAIL: *
+
+int ProcessSomething(int input);
+
+int DoWork()
+{
+  if (((int)4) > ProcessSomething(10))
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 4 is a magic number; consider 
replacing it with a named constant [readability-magic-numbers]
+return 0;
+
+   return 0;
+}
+
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -185,6 +185,10 @@
   The check now supports the ``IgnoreBitFieldsWidths`` option to suppress
   the warning for numbers used to specify bit field widths.
 
+  The check was updated to eliminate some false positives (such as using
+  class enumeration as non-type template parameters, or the synthetically
+  computed lengh of a static user string literal.)
+
 - New :doc:`readability-make-member-function-const
   ` check.
 
Index: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -34,7 +34,7 @@
 return AsDecl->isImplicit();
   }
 
-  if (Node.get() != nullptr)
+  if (Node.get())
 return true;
 
   return llvm::any_of(Result.Context->getParents(Node),
@@ -125,8 +125,20 @@
 if (isUsedToInitializeAConstant(Result, Parent))
   return true;
 
-// Ignore this instance, because this match reports the location
-// where the template is defined, not where it is instantiated.
+// Ignore this instance, because this matches an
+// expanded class enumeration value.
+if (Parent.get() &&
+llvm::any_of(
+Result.Context->getParents(Parent),
+[](const DynTypedNode ) {
+  return GrandParent.get() !=
+ nullptr;
+}))
+  return true;
+
+// Ignore this instance, because this match reports the
+// location where the template is defined, not where it
+// is instantiated.
 if (Parent.get())
   return true;
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
@@ -59,7 +59,7 @@
   const int anotherConstant;
 };
 
-int ValueArray[] = {3, 5};
+int ValueArray[] = {3, 5, 0, 0, 0};
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
 // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
 
@@ -215,3 +215,14 @@
 
   return Total;
 }
+
+// prove that using enumerations values don't produce warnings
+enum class Letter : unsigned {
+A, B, C, D, E, F, G, H, I, J
+};
+
+template struct 

[PATCH] D71625: [CMake] Added remote test execution support into CrossWinToARMLinux CMake cache file.

2019-12-20 Thread Andrei Lebedev via Phabricator via cfe-commits
andreil99 accepted this revision.
andreil99 added a comment.
This revision is now accepted and ready to land.

Thanks, Vlad!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71625



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


[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-20 Thread annita.zhang via Phabricator via cfe-commits
annita.zhang added a comment.

In D70157#1793280 , @reames wrote:

> I've gone ahead and landed the patch so that we can iterate in tree.  See 
> commit 14fc20ca62821b5f85582bf76a467d412248c248 
> .
>
> I've also landed a couple of follow up patches to address issues which would 
> have otherwise required iteration on the review.  See commits 
> c148e2e2ef86f53391be459752511684424f331b 
> , 
> 4024d49edc1598a6f8017df541147b38bf1e2818 
> , and 
> 8b725f0459eee468ed7f9935fba3278fcb4997b1 
> .
>
> I still see some room for further cleanup (i.e. the fragment range scheme and 
> tests), but what's in is of reasonable quality.
>
> There's a couple follow up patches which are probably called for, but I think 
> we can work on these in parallel now.
>
> 1. We need to settle on assembler syntax.
> 2. We need a patch for the x86 MI to MC translation to mark regions unsafe to 
> pad.  (Probably best to separate from the above for the moment.)
> 3. We can incrementally add support for prefix padding.


Thanks for landing it! And happy holiday to all!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70157



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


[clang] bab67ba - fix a doc typo to cycle bots

2019-12-20 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2019-12-20T21:39:01-05:00
New Revision: bab67ba6a3c451fbadd6b8b38c5043ef7e316d56

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

LOG: fix a doc typo to cycle bots

Added: 


Modified: 
clang/docs/LibASTMatchersTutorial.rst

Removed: 




diff  --git a/clang/docs/LibASTMatchersTutorial.rst 
b/clang/docs/LibASTMatchersTutorial.rst
index 878f8085de69..22285c5f0fa9 100644
--- a/clang/docs/LibASTMatchersTutorial.rst
+++ b/clang/docs/LibASTMatchersTutorial.rst
@@ -8,7 +8,7 @@ explicitly aimed at people who are new to Clang, so all you 
should need
 is a working knowledge of C++ and the command line.
 
 In order to work on the compiler, you need some basic knowledge of the
-abstract syntax tree (AST). To this end, the reader is incouraged to
+abstract syntax tree (AST). To this end, the reader is encouraged to
 skim the :doc:`Introduction to the Clang
 AST `
 



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


[PATCH] D71686: Fix false positive in magic number checker

2019-12-20 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- marked an inline comment as done.
0x8000- added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp:129
+// expanded class enumeration value.
+if (Parent.get())
+  return true;

0x8000- wrote:
> aaron.ballman wrote:
> > So will this no longer treat *any* C-style cast as being a magic number? 
> > e.g., `int i; i = (int)12;`
> Sadly, it would seem so.
> 
> if (ValueArray[(int)4] > ValueArray[1]) produces the following AST:
> 
> ```
> |   | | | `-ArraySubscriptExpr 0x11545f0  'int' lvalue
> |   | | |   |-ImplicitCastExpr 0x11545d8  'int *' 
> |   | | |   | `-DeclRefExpr 0x1154558  'int [5]' lvalue Var 0x1153cb0 
> 'ValueArray' 'int [5]'
>
> |   | | |   `-CStyleCastExpr 0x11545b0  'int' 
> |   | | | `-IntegerLiteral 0x1154578  'int' 4
> ```
> 
> While the test case we're trying to avoid is:
> ```
> `-TemplateSpecializationType 0x1169ee0 'holder<(Letter)9U>' sugar holder
>   |-TemplateArgument expr
>   | `-ConstantExpr 0x1169dc0  'Letter' 9
>   |   `-SubstNonTypeTemplateParmExpr 0x1169da0  'Letter'
>   | `-CStyleCastExpr 0x1169d78  'Letter' 
>   |   `-IntegerLiteral 0x1169d48  'unsigned int' 9
>   `-RecordType 0x1169ec0 'holder'
> `-ClassTemplateSpecialization 0x1169de0 'holder'
> ```
> 
> Now, the question is - do we care? How many people use a C cast with a bare 
> integer?
> 
> I suppose I can add a check for the grandparent node to be 
> SubstNonTypeTemplateParmExpr, in order to filter this out?
An interesting fact is that the C-style cast does not produce a warning now 
anyway (even before applying this change.) and I don't have any idea why.

Adding these lines does not create a test failure:

```
+  79   if (((int)4) > IntSquarer[10])  
   
+  80 return 0;  
```


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

https://reviews.llvm.org/D71686



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


[PATCH] D71791: [CFG] Fix an assertion failure with static initializers

2019-12-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/Analysis/CFG.cpp:5923
+  if (isa(Cond) || isa(Cond))
 return nullptr;
 

What about the following?:
```lang=c
if (const auto *E = dyn_cast(StmtElem->getStmt()))
  return E->IgnoreParens();
return nullptr;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71791



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


[PATCH] D71791: [CFG] Fix an assertion failure with static initializers

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: Szelethus, NoQ.
xazax.hun added a project: clang.
Herald added subscribers: cfe-commits, Charusso, gamesh411, dkrupp, rnkovacs.

The branches protecting the static initializers have a `DeclStmt` as last 
`Stmt`. Since it is not an expression that will trigger an assertion failure in 
`CFGBlock::getLastCondition`.
This is triggered by the lifetime analysis that is currently in a fork. I am 
not sure what would be the best way to test this change here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71791

Files:
  clang/lib/Analysis/CFG.cpp


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -5919,7 +5919,7 @@
 return nullptr;
 
   const Stmt *Cond = StmtElem->getStmt();
-  if (isa(Cond))
+  if (isa(Cond) || isa(Cond))
 return nullptr;
 
   // Only ObjCForCollectionStmt is known not to be a non-Expr terminator, hence


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -5919,7 +5919,7 @@
 return nullptr;
 
   const Stmt *Cond = StmtElem->getStmt();
-  if (isa(Cond))
+  if (isa(Cond) || isa(Cond))
 return nullptr;
 
   // Only ObjCForCollectionStmt is known not to be a non-Expr terminator, hence
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43357: [Concepts] Function trailing requires clauses

2019-12-20 Thread Saar Raz via Phabricator via cfe-commits
saar.raz added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:2068-2069
 
   if (ParseAsmAttributesAfterDeclarator(D))
 return nullptr;
 

rsmith wrote:
> We should check with GCC to see which side of the requires-clause they expect 
> this.
> 
> For the second and subsequent declarations, we expect the asm label before 
> the requires clause; here we parse the asm label after the requires clause.
They expect the requires clause first.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3799-3810
+if (D.isFunctionDeclarator()) {
+  auto  = D.getFunctionTypeInfo();
+  if (FTI.Params)
+for (auto  : ArrayRef(FTI.Params,
+
FTI.NumParams)){
+  auto *ParamDecl = cast(Param.Param);
+  if (ParamDecl->getIdentifier())

rsmith wrote:
> This scope-building code should be in `Sema`, not in the parser. (Consider 
> adding an `ActOnStartTrailingRequiresClause` / 
> `ActOnFinishTrailingRequiresClause` pair.)
Is there anything that needs to be in ActOnFinishTrailingRequiresClause?



Comment at: clang/lib/Parse/ParseExpr.cpp:349-350
+  if (Tok.is(tok::l_paren) &&
+  isa(RightMostExpr) &&
+  RightMostExpr->isTypeDependent()) {
+// We're facing one of the following cases:

rsmith wrote:
> The parser shouldn't be encoding this kind of semantic knowledge. Please move 
> this to `Sema`. (This is also not really a very general way to detect a 
> function-like name: checking for an expression whose type is a function type 
> or OverloadType would catch more cases.)
Function types and overload types would not reach here (would be eliminated in 
the previous check for 'bool' types). Only dependent types and bools get here, 
and checking for a function type or OverloadType would not catch those cases.

Anyway, moved this to Sema



Comment at: clang/lib/Parse/ParseExpr.cpp:354
+// template void foo() requires func(
+// In the first case, '(' cannot start a declaration, and in the second,
+// '(' cannot follow the requires-clause in a function-definition nor in

rsmith wrote:
> I don't think this is true. Consider:
> 
> ```
> struct A {
>   template requires X
>   (A)() {}
> };
> ```
> 
> For a trailing requires clause, we can be much more aggressive with our error 
> detection here, though, and in that case perhaps we can unconditionally treat 
> a trailing `(` as a function call.
If the cases where this is possible are only very remote - could we maybe turn 
this into a warning instead and keep it here?

Also, if X is a function type or OverloadType, then this is ill-formed 
anyway, right? since the constraint expression can't be a bool.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43357



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


[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D70157#1793280 , @reames wrote:

> I've gone ahead and landed the patch so that we can iterate in tree.  See 
> commit 14fc20ca62821b5f85582bf76a467d412248c248 
> .
>
> I've also landed a couple of follow up patches to address issues which would 
> have otherwise required iteration on the review.  See commits 
> c148e2e2ef86f53391be459752511684424f331b 
> , 
> 4024d49edc1598a6f8017df541147b38bf1e2818 
> , and 
> 8b725f0459eee468ed7f9935fba3278fcb4997b1 
> .
>
> I still see some room for further cleanup (i.e. the fragment range scheme and 
> tests), but what's in is of reasonable quality.
>
> There's a couple follow up patches which are probably called for, but I think 
> we can work on these in parallel now.
>
> 1. We need to settle on assembler syntax.
> 2. We need a patch for the x86 MI to MC translation to mark regions unsafe to 
> pad.  (Probably best to separate from the above for the moment.)
> 3. We can incrementally add support for prefix padding.


If you planned to clean up, you could have made the cleanups in the original 
land:) Though there would be a problem of proper contribution attribution. 
After Subversion->Git transition, we can actually run `git commit --amend 
--author=ask-author-to-provide-name-and- ' (Though changing the author 
may not be fair to your contribution to this commit... oh it is so difficult.) 
Anyway, it is nice to see this feature before Christmas and people can start 
investigating its impact now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70157



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


[PATCH] D70919: [Hexagon] Avoid passing unsupported options to lld when -fuse-ld=lld is used

2019-12-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi! This seems to be causing some test failures on our bots: 
https://ci.chromium.org/p/fuchsia/builders/ci/clang-linux-x64/b8893521019883752048

  : 'RUN: at line 553';   
/b/s/w/ir/k/recipe_cleanup/clangciZYdn/llvm_build_dir/bin/clang -### -target 
hexagon-unknown-elf-ccc-install-dir 
/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/hexagon_tree/Tools/bin
-mcpu=hexagonv60-fuse-ld=lld
/b/s/w/ir/k/llvm-project/clang/test/Driver/hexagon-toolchain-elf.c 2>&1| 
/b/s/w/ir/k/recipe_cleanup/clangciZYdn/llvm_build_dir/bin/FileCheck 
-check-prefix=CHECK082 
/b/s/w/ir/k/llvm-project/clang/test/Driver/hexagon-toolchain-elf.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /b/s/w/ir/k/llvm-project/clang/test/Driver/hexagon-toolchain-elf.c:548:14: 
error: CHECK081: expected string not found in input
  // CHECK081: "-march=hexagon"
   ^
  :1:1: note: scanning from here
  Fuchsia clang version 10.0.0 
(https://fuchsia.googlesource.com/a/third_party/llvm-project 
ddf897fc80499ece298bc33201db6b697d2af50e)
  ^
  :5:193: note: possible intended match here
   "/b/s/w/ir/k/recipe_cleanup/clangciZYdn/llvm_build_dir/bin/clang-10" "-cc1" 
"-triple" "hexagon-unknown-unknown-elf" "-emit-obj" "-mrelax-all" 
"--mrelax-relocations" "-disable-free" "-main-file-name" 
"hexagon-toolchain-elf.c" "-mrelocation-model" "static" "-mthread-model" 
"posix" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" 
"-masm-verbose" "-mconstructor-aliases" "-target-cpu" "hexagonv60" 
"-target-feature" "-long-calls" "-mqdsp6-compat" "-Wreturn-type" 
"-fshort-enums" "-mllvm" "-machine-sink-split=0" "-dwarf-column-info" 
"-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" 
"/b/s/w/ir/k/recipe_cleanup/clangciZYdn/llvm_build_dir/lib/clang/10.0.0" 
"-internal-externc-isystem" 
"/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/hexagon_tree/Tools/bin/../target/hexagon/include"
 "-fdebug-compilation-dir" 
"/b/s/w/ir/k/recipe_cleanup/clangciZYdn/llvm_build_dir/tools/clang/test/Driver" 
"-ferror-limit" "19" "-fmessage-length" "0" "-fshort-enums" "-fno-signed-char" 
"-fgnuc-version=4.2.1" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" 
"-faddrsig" "-o" "/b/s/w/ir/tmp/t/hexagon-toolchain-elf-2999dd.o" "-x" "c" 
"/b/s/w/ir/k/llvm-project/clang/test/Driver/hexagon-toolchain-elf.c"


  ^
  
  --
  
  
  Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  
  Testing Time: 60.03s
  
  Failing Tests (1):
  Clang :: Driver/hexagon-toolchain-elf.c

Would you mind taking a look and either fixing or reverting this patch? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70919



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


[PATCH] D71686: Fix false positive in magic number checker

2019-12-20 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- marked an inline comment as done.
0x8000- added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp:129
+// expanded class enumeration value.
+if (Parent.get())
+  return true;

aaron.ballman wrote:
> So will this no longer treat *any* C-style cast as being a magic number? 
> e.g., `int i; i = (int)12;`
Sadly, it would seem so.

if (ValueArray[(int)4] > ValueArray[1]) produces the following AST:

```
|   | | | `-ArraySubscriptExpr 0x11545f0  'int' lvalue
|   | | |   |-ImplicitCastExpr 0x11545d8  'int *' 
|   | | |   | `-DeclRefExpr 0x1154558  'int [5]' lvalue Var 0x1153cb0 
'ValueArray' 'int [5]'  
 
|   | | |   `-CStyleCastExpr 0x11545b0  'int' 
|   | | | `-IntegerLiteral 0x1154578  'int' 4
```

While the test case we're trying to avoid is:
```
`-TemplateSpecializationType 0x1169ee0 'holder<(Letter)9U>' sugar holder
  |-TemplateArgument expr
  | `-ConstantExpr 0x1169dc0  'Letter' 9
  |   `-SubstNonTypeTemplateParmExpr 0x1169da0  'Letter'
  | `-CStyleCastExpr 0x1169d78  'Letter' 
  |   `-IntegerLiteral 0x1169d48  'unsigned int' 9
  `-RecordType 0x1169ec0 'holder'
`-ClassTemplateSpecialization 0x1169de0 'holder'
```

Now, the question is - do we care? How many people use a C cast with a bare 
integer?

I suppose I can add a check for the grandparent node to be 
SubstNonTypeTemplateParmExpr, in order to filter this out?


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

https://reviews.llvm.org/D71686



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


[PATCH] D70048: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-12-20 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

@MaskRay I will mail you off-list with one question.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70048



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


[PATCH] D70048: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-12-20 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.
Herald added a subscriber: arichardson.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70048



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


[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

2019-12-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> and it seems to involve a lot of AST traversal

I was thinking we'd just call into SemaChecking in appropriate places.  I guess 
there's a little AST traversal to figure whether an expression forms an array 
address.  Your idea seems simpler.

> remove elements from the list of deferred warnings when handling an & operator

For C++, I think you might also need to handle discarded-value expressions?  
Maybe it's okay if we warn anyway in that case. :)

> This would lose the warnings on *[n], but I don't think that's a disaster

And more generally `*(x+n)`, although I guess that isn't implemented now anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71714



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


[PATCH] D71491: [ubsan] Check implicit casts in ObjC for-in statements

2019-12-20 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: compiler-rt/lib/ubsan/ubsan_value.cpp:29
+const char *__ubsan::getObjCClassName(ValueHandle Pointer) {
+#if defined(__APPLE__)
+  // We need to query the ObjC runtime for some information, but do not want

vsk wrote:
> delcypher wrote:
> > vsk wrote:
> > > delcypher wrote:
> > > > The compiler-rt codebase tends to use `SANITIZER_MAC` macro (defined to 
> > > > be 1 if Apple otherwise it's 0) rather than `__APPLE__`.
> > > I see. That seems problematic, as it makes it tricky to add 
> > > macOS-specific (or iOS-specific) functionality down the road. I don't 
> > > think SANITIZER_MAC should be defined unless TARGET_OS_MACOS is true.
> > Sorry I should clarify. `SANITIZER_MAC` is poorly named but it is defined 
> > to be `1` for Apple platforms and `0`. I'm just pointing out the convention 
> > that exists today. You're absolutely right that we might want to do 
> > different things for different Apple platforms but I don't think we want to 
> > start doing a mass re-name until arm64e and arm64_32 support are completed 
> > landed in llvm's master.
> I think 'SANITIZER_MAC' is confusing, and my preference would be to not use 
> it. `__APPLE__` seems clearer to me, and (IIUC) the plan is to replace usage 
> of 'SANITIZER_MAC' with it down the line anyway?
There aren't any plans to do it right now but cleaning this up seems like a 
reasonable thing to do. If you take a look at 
`compiler-rt/lib/sanitizer_common/sanitizer_platform.h` you'll see that we 
actually have `SANITIZER_` for the other platforms that seems to be 
set as you'd expect. It's just `SANITIZER_MAC` that's badly named.

I've filed a radar for this issue (rdar://problem/58124919). So if you prefer 
to use `__APPLE__` could you leave a comment with something like

```
// TODO(dliew): Don't use unclear `SANITIZER_MAC` here. Instead wait for its 
replacement rdar://problem/58124919.
```

Note the `TODO():` style is enforced by the sanitizer specific linter so 
you have to put a name there.


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

https://reviews.llvm.org/D71491



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


[PATCH] D58579: [Sema] SequenceChecker: C++17 sequencing rule for call expressions.

2019-12-20 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

@rsmith Could you take a look at this patch when you have some time? This is 
the last C++17 sequencing rule which is missing from `SequenceChecker` and is 
very similar to the other already accepted patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58579



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


[PATCH] D71463: Implement VectorType conditional operator GNU extension.

2019-12-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 234977.
erichkeane marked 4 inline comments as done.
erichkeane added a comment.

@aaron.ballman s comments done.


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

https://reviews.llvm.org/D71463

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/vector-conditional.cpp
  clang/test/Sema/vector-gcc-compat.cpp
  clang/test/SemaCXX/vector-conditional.cpp

Index: clang/test/SemaCXX/vector-conditional.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/vector-conditional.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++17
+// Note that this test depends on the size of long-long to be different from
+// int, so it specifies a triple.
+
+using FourShorts = short __attribute__((__vector_size__(8)));
+using TwoInts = int __attribute__((__vector_size__(8)));
+using TwoUInts = unsigned __attribute__((__vector_size__(8)));
+using FourInts = int __attribute__((__vector_size__(16)));
+using FourUInts = unsigned __attribute__((__vector_size__(16)));
+using TwoLongLong = long long __attribute__((__vector_size__(16)));
+using FourLongLong = long long __attribute__((__vector_size__(32)));
+using TwoFloats = float __attribute__((__vector_size__(8)));
+using FourFloats = float __attribute__((__vector_size__(16)));
+using TwoDoubles = double __attribute__((__vector_size__(16)));
+using FourDoubles = double __attribute__((__vector_size__(32)));
+
+FourShorts four_shorts;
+TwoInts two_ints;
+TwoUInts two_uints;
+FourInts four_ints;
+FourUInts four_uints;
+TwoLongLong two_ll;
+FourLongLong four_ll;
+TwoFloats two_floats;
+FourFloats four_floats;
+TwoDoubles two_doubles;
+FourDoubles four_doubles;
+
+enum E {};
+enum class SE {};
+E e;
+SE se;
+
+// Check the rules of the condition of the conditional operator.
+void Condition() {
+  // Only int types are allowed here, the rest should fail to convert to bool.
+  (void)(four_floats ? 1 : 1); // expected-error {{is not contextually convertible to 'bool'}}}
+  (void)(two_doubles ? 1 : 1); // expected-error {{is not contextually convertible to 'bool'}}}
+}
+
+// Check the rules of the LHS/RHS of the conditional operator.
+void Operands() {
+  (void)(four_ints ? four_ints : throw 1); // expected-error {{GNU vector conditional operand cannot be a throw expression}}
+  (void)(four_ints ? throw 1 : four_ints); // expected-error {{GNU vector conditional operand cannot be a throw expression}}
+  (void)(four_ints ?: throw 1);// expected-error {{GNU vector conditional operand cannot be a throw expression}}
+  (void)(four_ints ? (void)1 : four_ints); // expected-error {{GNU vector conditional operand cannot be void}}
+  (void)(four_ints ?: (void)1);// expected-error {{GNU vector conditional operand cannot be void}}
+
+  // Vector types must be the same element size as the condition.
+  (void)(four_ints ? two_ll : two_ll); // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type 'TwoLongLong' (vector of 2 'long long' values) do not have the same number of elements}}
+  (void)(four_ints ? four_ll : four_ll);   // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type 'FourLongLong' (vector of 4 'long long' values) do not have elements of the same size}}
+  (void)(four_ints ? two_doubles : two_doubles);   // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type 'TwoDoubles' (vector of 2 'double' values) do not have the same number of elements}}
+  (void)(four_ints ? four_doubles : four_doubles); // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type 'FourDoubles' (vector of 4 'double' values) do not have elements of the same size}}
+  (void)(four_ints ?: two_ints);   // expected-error {{vector operands to the vector conditional must be the same type ('FourInts' (vector of 4 'int' values) and 'TwoInts' (vector of 2 'int' values)}}
+  (void)(four_ints ?: four_doubles);   // expected-error {{vector operands to the vector conditional must be the same type ('FourInts' (vector of 4 'int' values) and 'FourDoubles' (vector of 4 'double' values)}}
+
+  // Scalars are promoted, but must be the same element size.
+  (void)(four_ints ? 3.0f : 3.0); // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type '__attribute__((__vector_size__(4 * sizeof(double double' (vector of 4 'double' values) do not have elements of the same size}}
+  (void)(four_ints ? 5ll : 5);// expected-error {{vector condition type 'FourInts' 

[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2019-12-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/AArch64/SVEInstrFormats.td:5333
+  // We need a layer of indirection because early machine code passes balk at
+  // physical register (i.e. FFR) uses that have no previous definition.
+  let hasSideEffects = 1, hasNoSchedulingInfo = 1, mayLoad = 1 in {

kmclaughlin wrote:
> efriedma wrote:
> > This is depending on hasSideEffects to preserve the correct ordering with 
> > instructions that read/write FFR?  That probably works.  I guess the 
> > alternative is to insert an IMPLICIT_DEF of FFR in the entry block of each 
> > function.
> > 
> > What are the calling convention rules for FFR?  Is it callee-save?  If not, 
> > we might need to do some work to make FFR reads/writes do something sane 
> > across calls inserted by the compiler.
> The FFR is not callee-saved. We will need to add support to save & restore it 
> where appropriate at the point the compiler starts generating reads to the 
> FFR, but for the purpose of the ACLE the user will be required to do this if 
> necessary.
How can the user write correct code to save/restore the FFR?  The compiler can 
move arbitrary readnone/argmemonly calls between the definition and the use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71698



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


[PATCH] D68682: format::cleanupAroundReplacements removes whole line when Removals leave previously non-blank line blank

2019-12-20 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 234976.
poelmanc added a comment.

Address most of the feedback, I'll comment individually.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D68682

Files:
  clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-control-flow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-member-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp
  clang/include/clang/Basic/CharInfo.h
  clang/include/clang/Format/Format.h
  clang/lib/AST/CommentLexer.cpp
  clang/lib/AST/CommentParser.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/CleanupTest.cpp

Index: clang/unittests/Format/CleanupTest.cpp
===
--- clang/unittests/Format/CleanupTest.cpp
+++ clang/unittests/Format/CleanupTest.cpp
@@ -349,11 +349,13 @@
  "namespace C {\n"
  "namespace D { int i; }\n"
  "inline namespace E { namespace { int y; } }\n"
- "int x= 0;"
+ "\n"
+ "int x= 0;\n"
  "}";
-  std::string Expected = "\n\nnamespace C {\n"
- "namespace D { int i; }\n\n"
- "int x= 0;"
+  std::string Expected = "\nnamespace C {\n"
+ "namespace D { int i; }\n"
+ "\n"
+ "int x= 0;\n"
  "}";
   tooling::Replacements Replaces =
   toReplacements({createReplacement(getOffset(Code, 3, 3), 6, ""),
@@ -362,6 +364,87 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, RemoveLineWhenAllNonWhitespaceRemoved) {
+  std::string Code = "namespace A { // Useless comment\n"
+ "  int x\t = 0;\t\n"
+ "  int y\t = 0;\t\n"
+ "} // namespace A\n";
+  std::string Expected = "namespace A {\n"
+ "  int y\t = 0;\n"
+ "} // namespace A\n";
+  tooling::Replacements Replaces =
+  toReplacements({createReplacement(getOffset(Code, 1, 14), 19, ""),
+  createReplacement(getOffset(Code, 2, 3), 3, ""),
+  createReplacement(getOffset(Code, 2, 7), 1, ""),
+  createReplacement(getOffset(Code, 2, 10), 1, ""),
+  createReplacement(getOffset(Code, 2, 12), 2, ""),
+  createReplacement(getOffset(Code, 3, 14), 1, "")});
+
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, RemoveLinesWhenAllNonWhitespaceRemoved) {
+  std::string Code = "struct A {\n"
+ "  A()\n"
+ "  : f(),\n"
+ "g()\n"
+ "  {}\n"
+ "  int f = 0;\n"
+ "  int g = 0;\n"
+ "};";
+  std::string Expected = "struct A {\n"
+ "  A()\n"
+ "  {}\n"
+ "  int f = 0;\n"
+ "  int g = 0;\n"
+ "};";
+  tooling::Replacements Replaces =
+  toReplacements({createReplacement(getOffset(Code, 3, 5), 3, ""),
+  createReplacement(getOffset(Code, 3, 8), 1, ""),
+  createReplacement(getOffset(Code, 3, 3), 1, ""),
+  createReplacement(getOffset(Code, 4, 5), 3, "")});
+
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, KeepLinesWithInsertsOrReplacesEvenIfBlank) {
+  std::string Code = "struct A {\n"
+ "  A() {}\n"
+ "  int f;\n"
+ "  \n"
+ "  \n"
+ "};";
+  std::string Expected = "struct A {\n"
+ "  A() {}\n"
+ "\n"
+ "\n"
+ "  \n"
+ "\t\n"
+ "};";
+  tooling::Replacements Replaces =
+  toReplacements({createReplacement(getOffset(Code, 3, 3), 3, "   "),
+  createReplacement(getOffset(Code, 3, 7), 2, "  "),
+  createReplacement(getOffset(Code, 3, 1), 0, "\n"),
+  createReplacement(getOffset(Code, 5, 1), 2, "\t")});
+
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, 

[PATCH] D70270: clang-tidy: modernize-use-using uses AST and now supports struct defintions and multiple types in a typedef

2019-12-20 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

Any further feedback or thoughts on this?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70270



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


[PATCH] D71463: Implement VectorType conditional operator GNU extension.

2019-12-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 13 inline comments as done.
erichkeane added a comment.

New patch coming as soon as my build finishes.




Comment at: clang/docs/LanguageExtensions.rst:480
 =yes yes yes yes
-:?   yes --  --  --
+:?[*]_  yes --  yes --
 sizeof   yes yes yes yes

aaron.ballman wrote:
> Do these columns line up in the actual source file? They don't appear to line 
> up in the Phab viewer, but I don't know if that's an artifact of Phab or not.
They don't, I had misread the sphinx doc it seems and was doing footnotes 
incorrectly.  A coworker shared the live-sphinx viewer so I corrected this.  
See next patch.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4301
+llvm::Type *condType = ConvertType(condExpr->getType());
+llvm::VectorType *vecTy = cast(condType);
+llvm::Value *zeroVec = llvm::Constant::getNullValue(vecTy);

aaron.ballman wrote:
> `auto *`
> 
> Also, should these three variables have identifiers starting with an 
> uppercase like `CondV` et al?
Probably, I just C'ed this code from the above group :/



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5757
+  const QualType EltTy =
+  cast(CondTy.getCanonicalType().getTypePtr())
+  ->getElementType();

aaron.ballman wrote:
> Do you actually need the `getTypePtr()` bit, or will the `cast<>` suffice to 
> trigger the cast through `Type*`?
TIL!



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5793
+Diag(QuestionLoc, diag::err_conditional_vector_operand_type)
+<< /*isExtVector*/ true << RHSType;
+return {};

aaron.ballman wrote:
> Shouldn't this pass in the `LHSType` instead because that's what's being 
> tested?
Yep!



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5805
+// If both are vector types, they must be the same type.
+if (!Context.hasSameType(LHSType, RHSType)) {
+  Diag(QuestionLoc, diag::err_conditional_vector_mismatched_vectors)

aaron.ballman wrote:
> Do you need to canonicalize these types before comparing them?
No, both versions of this function canonicalize for me: 
https://clang.llvm.org/doxygen/ASTContext_8h_source.html#l02305


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

https://reviews.llvm.org/D71463



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


[PATCH] D71758: [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.

2019-12-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This seems reasonable to me, and matches GCC 10's behavior; `$` is not in the 
basic source character set, so encoding it with a UCN should be permitted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71758



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


[PATCH] D70689: [analyzer] Fix SARIF column locations

2019-12-20 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech updated this revision to Diff 234971.
jranieri-grammatech added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70689

Files:
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
  clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c

Index: clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
===
--- clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
+++ clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
@@ -30,11 +30,17 @@
   return 0;
 }
 
+int unicode() {
+  int løçål = 0;
+  /* ☃ */ return 1 / løçål; // expected-warning {{Division by zero}}
+}
+
 int main(void) {
   f();
   g();
   h(0);
   leak(0);
+  unicode();
   return 0;
 }
 
Index: clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
===
--- clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -4,7 +4,7 @@
 {
   "artifacts": [
 {
-  "length": 951,
+  "length": 1077,
   "location": {
   },
   "mimeType": "text/plain",
@@ -13,6 +13,7 @@
   ]
 }
   ],
+  "columnKind": "unicodeCodePoints",
   "results": [
 {
   "codeFlows": [
@@ -32,9 +33,9 @@
   },
   "region": {
 "endColumn": 6,
-"endLine": 34,
+"endLine": 39,
 "startColumn": 3,
-"startLine": 34
+"startLine": 39
   }
 }
   }
@@ -102,9 +103,9 @@
   },
   "region": {
 "endColumn": 6,
-"endLine": 35,
+"endLine": 40,
 "startColumn": 3,
-"startLine": 35
+"startLine": 40
   }
 }
   }
@@ -120,7 +121,7 @@
 "index": 0,
   },
   "region": {
-"endColumn": 11,
+"endColumn": 12,
 "endLine": 15,
 "startColumn": 3,
 "startLine": 15
@@ -363,6 +364,74 @@
   },
   "ruleId": "unix.Malloc",
   "ruleIndex": 3
+},
+{
+  "codeFlows": [
+{
+  "threadFlows": [
+{
+  "locations": [
+{
+  "importance": "essential",
+  "location": {
+"message": {
+  "text": "'løçål' initialized to 0"
+},
+"physicalLocation": {
+  "artifactLocation": {
+"index": 0,
+  },
+  "region": {
+"endColumn": 12,
+"endLine": 34,
+"startColumn": 3,
+"startLine": 34
+  }
+}
+  }
+},
+{
+  "importance": "essential",
+  "location": {
+"message": {
+  "text": "Division by zero"
+},
+"physicalLocation": {
+  "artifactLocation": {
+"index": 0,
+  },
+  "region": {
+"endColumn": 20,
+"startColumn": 20,
+"startLine": 35
+  }
+}
+  }
+}
+  ]
+}
+  ]
+}
+  ],
+  "locations": [
+{
+  "physicalLocation": {
+"artifactLocation": {
+  "index": 0,
+},
+"region": {
+  "endColumn": 20,
+  

[PATCH] D70689: [analyzer] Fix SARIF column locations

2019-12-20 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech marked 4 inline comments as done.
jranieri-grammatech added inline comments.



Comment at: clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c:35-36
+{
+  int løçål = 0;
+  /* ☃ */ return 1 / løçål; // expected-warning {{Division by zero}}
+}

aaron.ballman wrote:
> What file encoding is used by this file (and is there a BOM)? Have you tried 
> this test on multiple platforms by any chance?
The file is encoded in UTF-8 without a BOM. I have not tried the test on other 
platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70689



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[PATCH] D36051: [clang-tidy] List the checkers with autofix

2019-12-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 234972.
sylvestre.ledru added a comment.

alias => aliases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051

Files:
  clang-tools-extra/docs/clang-tidy/checks/list.rst

Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -3,388 +3,408 @@
 Clang-Tidy Checks
 =
 
+.. Severities are coming from Codechecker:
+   https://github.com/Ericsson/codechecker/blob/master/config/checker_severity_map.json
+   If you change it here, please submit a PR on codechecker too
+
+.. csv-table::
+   :header: "Name", "Offers fixes", "Severity"
+   :widths: 50, 20, 10
+
+   `abseil-duration-addition `_, "Yes", ""
+   `abseil-duration-comparison `_, "Yes", ""
+   `abseil-duration-conversion-cast `_, "Yes", ""
+   `abseil-duration-division `_, "Yes", ""
+   `abseil-duration-factory-float `_, "Yes", ""
+   `abseil-duration-factory-scale `_, "Yes", ""
+   `abseil-duration-subtraction `_, "Yes", ""
+   `abseil-duration-unnecessary-conversion `_, "Yes", ""
+   `abseil-faster-strsplit-delimiter `_, "Yes", ""
+   `abseil-no-internal-dependencies `_, , ""
+   `abseil-no-namespace `_, , ""
+   `abseil-redundant-strcat-calls `_, "Yes", ""
+   `abseil-str-cat-append `_, "Yes", ""
+   `abseil-string-find-startswith `_, "Yes", "style"
+   `abseil-time-comparison `_, "Yes", ""
+   `abseil-time-subtraction `_, "Yes", ""
+   `abseil-upgrade-duration-conversions `_, "Yes", ""
+   `android-cloexec-accept `_, "Yes", ""
+   `android-cloexec-accept4 `_, , ""
+   `android-cloexec-creat `_, , "medium"
+   `android-cloexec-dup `_, , ""
+   `android-cloexec-epoll-create `_, , ""
+   `android-cloexec-epoll-create1 `_, , ""
+   `android-cloexec-fopen `_, , "medium"
+   `android-cloexec-inotify-init `_, , ""
+   `android-cloexec-inotify-init1 `_, , ""
+   `android-cloexec-memfd-create `_, , ""
+   `android-cloexec-open `_, , "medium"
+   `android-cloexec-pipe `_, , ""
+   `android-cloexec-pipe2 `_, , ""
+   `android-cloexec-socket `_, , "medium"
+   `android-comparison-in-temp-failure-retry `_, "Yes", ""
+   `boost-use-to-string `_, "Yes", "low"
+   `bugprone-argument-comment `_, "Yes", "low"
+   `bugprone-assert-side-effect `_, , "medium"
+   `bugprone-bad-signal-to-kill-thread `_, , ""
+   `bugprone-bool-pointer-implicit-conversion `_, "Yes", "low"
+   `bugprone-branch-clone `_, , "low"
+   `bugprone-copy-constructor-init `_, "Yes", "medium"
+   `bugprone-dangling-handle `_, , "high"
+   `bugprone-dynamic-static-initializers `_, , ""
+   `bugprone-exception-escape `_, , "medium"
+   `bugprone-fold-init-type `_, , "high"
+   `bugprone-forward-declaration-namespace `_, , "low"
+   `bugprone-forwarding-reference-overload `_, , "low"
+   `bugprone-inaccurate-erase `_, "Yes", "high"
+   `bugprone-incorrect-roundings `_, , "high"
+   `bugprone-infinite-loop `_, , "medium"
+   `bugprone-integer-division `_, , "medium"
+   `bugprone-lambda-function-name `_, , "low"
+   `bugprone-macro-parentheses `_, "Yes", "medium"
+   `bugprone-macro-repeated-side-effects `_, , "medium"
+   `bugprone-misplaced-operator-in-strlen-in-alloc `_, , "medium"
+   `bugprone-misplaced-widening-cast `_, "Yes", "high"
+   `bugprone-move-forwarding-reference `_, "Yes", "medium"
+   `bugprone-multiple-statement-macro `_, , "medium"
+   `bugprone-not-null-terminated-result `_, "Yes", "medium"
+   `bugprone-parent-virtual-call `_, "Yes", "medium"
+   `bugprone-posix-return `_, "Yes", ""
+   `bugprone-sizeof-container `_, , "high"
+   `bugprone-sizeof-expression `_, , "high"
+   `bugprone-string-constructor `_, "Yes", "high"
+   `bugprone-string-integer-assignment `_, "Yes", "low"
+   `bugprone-string-literal-with-embedded-nul `_, , "medium"
+   `bugprone-suspicious-enum-usage `_, , "high"
+   `bugprone-suspicious-memset-usage `_, "Yes", "high"
+   `bugprone-suspicious-missing-comma `_, , "high"
+   `bugprone-suspicious-semicolon `_, "Yes", "high"
+   `bugprone-suspicious-string-compare `_, "Yes", "medium"
+   `bugprone-swapped-arguments `_, "Yes", "high"
+   `bugprone-terminating-continue `_, "Yes", "medium"
+   `bugprone-throw-keyword-missing `_, , "medium"
+   `bugprone-too-small-loop-variable `_, , "medium"
+   `bugprone-undefined-memory-manipulation `_, , "medium"
+   `bugprone-undelegated-constructor `_, , "medium"
+   `bugprone-unhandled-self-assignment `_, , "medium"
+   `bugprone-unused-raii `_, "Yes", "high"
+   `bugprone-unused-return-value `_, , "medium"
+   `bugprone-use-after-move `_, , "high"
+   `bugprone-virtual-near-miss `_, "Yes", "medium"
+   `cert-dcl21-cpp `_, , "low"
+   `cert-dcl50-cpp `_, , "low"
+   `cert-dcl58-cpp `_, , "high"
+   `cert-env33-c `_, , "medium"
+   `cert-err34-c `_, , "low"
+   `cert-err52-cpp `_, , "low"
+   

[clang] 0378f3a - Revert "Customize simplified dumping and matching of LambdaExpr"

2019-12-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-20T21:33:31Z
New Revision: 0378f3a90341d990236c44f297b923a32b35fab1

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

LOG: Revert "Customize simplified dumping and matching of LambdaExpr"

This reverts commit 494b1318ca77927e919bbf9a61749a58553d738c.

Added: 


Modified: 
clang/include/clang/AST/ASTNodeTraverser.h
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index 9dab814b659b..f097d024c9e8 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -128,12 +128,9 @@ class ASTNodeTraverser
   ConstStmtVisitor::Visit(S);
 
   // Some statements have custom mechanisms for dumping their children.
-  if (isa(S) || isa(S))
-return;
-
-  if (isa(S) &&
-  Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+  if (isa(S) || isa(S)) {
 return;
+  }
 
   for (const Stmt *SubStmt : S->children())
 Visit(SubStmt);
@@ -649,23 +646,7 @@ class ASTNodeTraverser
   }
 
   void VisitLambdaExpr(const LambdaExpr *Node) {
-if (Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
-  for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
-const auto *C = Node->capture_begin() + I;
-if (!C->isExplicit())
-  continue;
-if (Node->isInitCapture(C))
-  Visit(C->getCapturedVar());
-else
-  Visit(Node->capture_init_begin()[I]);
-  }
-  dumpTemplateParameters(Node->getTemplateParameterList());
-  for (const auto *P : Node->getCallOperator()->parameters())
-Visit(P);
-  Visit(Node->getBody());
-} else {
-  return Visit(Node->getLambdaClass());
-}
+Visit(Node->getLambdaClass());
   }
 
   void VisitSizeOfPackExpr(const SizeOfPackExpr *Node) {

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 2a43b4c7049f..8ac35d522843 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -145,9 +145,7 @@ class MatchChildASTVisitor
 
 ScopedIncrement ScopedDepth();
 Stmt *StmtToTraverse = StmtNode;
-if (auto *ExprNode = dyn_cast_or_null(StmtNode))
-  StmtToTraverse = ExprNode;
-else if (auto *ExprNode = dyn_cast_or_null(StmtNode))
+if (auto *ExprNode = dyn_cast_or_null(StmtNode))
   StmtToTraverse = Finder->getASTContext().traverseIgnored(ExprNode);
 if (Traversal ==
 ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
@@ -205,38 +203,6 @@ class MatchChildASTVisitor
 ScopedIncrement ScopedDepth();
 return traverse(*CtorInit);
   }
-  bool TraverseLambdaExpr(LambdaExpr *Node) {
-if (!Node)
-  return true;
-ScopedIncrement ScopedDepth();
-
-for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
-  const auto *C = Node->capture_begin() + I;
-  if (!C->isExplicit())
-continue;
-  if (Node->isInitCapture(C) && !match(*C->getCapturedVar()))
-return false;
-  if (!match(*Node->capture_init_begin()[I]))
-return false;
-}
-
-if (const auto *TPL = Node->getTemplateParameterList()) {
-  for (const auto *TP : *TPL) {
-if (!match(*TP))
-  return false;
-  }
-}
-
-for (const auto *P : Node->getCallOperator()->parameters()) {
-  if (!match(*P))
-return false;
-}
-
-if (!match(*Node->getBody()))
-  return false;
-
-return false;
-  }
 
   bool shouldVisitTemplateInstantiations() const { return true; }
   bool shouldVisitImplicitCode() const { return true; }

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index 4b982431297c..c995f55d3c89 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -479,123 +479,4 @@ FunctionDecl 'func12'
 )cpp");
 }
 
-TEST(Traverse, LambdaUnlessSpelledInSource) {
-
-  auto AST =
-  buildASTFromCodeWithArgs(R"cpp(
-
-void captures() {
-  int a = 0;
-  int b = 0;
-  int d = 0;
-  int f = 0;
-
-  [a, , c = d,  = f](int g, int h = 42) {};
-}
-
-void templated() {
-  int a = 0;
-  [a](T t) {};
-}
-
-struct SomeStruct {
-int a = 0;
-void capture_this() {
-[this]() {};
-}
-void capture_this_copy() {
-[self = *this]() {};
-}
-};
-)cpp",
-   {"-Wno-unused-value", "-Wno-c++2a-extensions"});
-
-  auto getLambdaNode = [](const std::string ) {
-auto BN = 

[PATCH] D71709: Give frontend dump flags consistent names (*-dump instead of dump-*)

2019-12-20 Thread David Herzka via Phabricator via cfe-commits
herzka updated this revision to Diff 234966.
herzka added a comment.
Herald added a reviewer: jdoerfert.

change flags in tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71709

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CoverageMapping/block-storage-starts-region.m
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/casts.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/control-flow-macro.c
  clang/test/CoverageMapping/decl.c
  clang/test/CoverageMapping/default-method.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/empty-destructor.cpp
  clang/test/CoverageMapping/header.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/implicit-def-in-macro.m
  clang/test/CoverageMapping/include-macros.c
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/lambda.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loopmacro.c
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expansion.c
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macro-stringize-twice.cpp
  clang/test/CoverageMapping/macroception.c
  clang/test/CoverageMapping/macroparams.c
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/md.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/nestedclass.cpp
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/openmp.c
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/system_macro.cpp
  clang/test/CoverageMapping/templates.cpp
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/trymacro.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/unused_function.cpp
  clang/test/CoverageMapping/while.c
  clang/test/Lexer/dollar-idents.c
  clang/test/Preprocessor/dumptokens_phyloc.c
  clang/utils/token-delta.py

Index: clang/utils/token-delta.py
===
--- clang/utils/token-delta.py
+++ clang/utils/token-delta.py
@@ -108,7 +108,7 @@
   re.DOTALL | re.MULTILINE)
 
 def getTokens(path):
-p = subprocess.Popen(['clang','-dump-raw-tokens',path],
+p = subprocess.Popen(['clang','-raw-tokens-dump',path],
  stdin=subprocess.PIPE,
  stdout=subprocess.PIPE,
  stderr=subprocess.PIPE)
Index: clang/test/Preprocessor/dumptokens_phyloc.c
===
--- clang/test/Preprocessor/dumptokens_phyloc.c
+++ clang/test/Preprocessor/dumptokens_phyloc.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -dump-tokens %s 2>&1 | grep "Spelling=.*dumptokens_phyloc.c:3:20"
+// RUN: %clang_cc1 -tokens-dump %s 2>&1 | grep "Spelling=.*dumptokens_phyloc.c:3:20"
 
 #define TESTPHYLOC 10
 
Index: clang/test/Lexer/dollar-idents.c
===
--- clang/test/Lexer/dollar-idents.c
+++ clang/test/Lexer/dollar-idents.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -dump-tokens %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -dump-tokens -x assembler-with-cpp %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: %clang_cc1 -tokens-dump %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -tokens-dump -x assembler-with-cpp %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASM
 // PR3808
 
 // CHECK: identifier '$A'
Index: clang/test/CoverageMapping/while.c
===
--- clang/test/CoverageMapping/while.c
+++ clang/test/CoverageMapping/while.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -coverage-mapping-dump -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
 
 // CHECK: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+8]]:2 = #0
Index: clang/test/CoverageMapping/unused_function.cpp
===
--- clang/test/CoverageMapping/unused_function.cpp
+++ clang/test/CoverageMapping/unused_function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 

[PATCH] D71680: Customize simplified dumping and matching of LambdaExpr

2019-12-20 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG494b1318ca77: Customize simplified dumping and matching of 
LambdaExpr (authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D71680?vs=234636=234968#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71680

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1751,6 +1751,17 @@
   return c;
 }
 
+void func13() {
+  int a = 0;
+  int c = 0;
+
+  [a, b = c](int d) { int e = d; };
+}
+
+void func14() {
+  []  (TemplateType t, TemplateType u) { int e = t + u; };
+}
+
 )cpp";
 
   EXPECT_TRUE(matches(
@@ -1821,6 +1832,23 @@
  returnStmt(forFunction(functionDecl(hasName("func12"))),
 hasReturnValue(
 declRefExpr(to(varDecl(hasName("c");
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(
+  ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+  lambdaExpr(forFunction(functionDecl(hasName("func13"))),
+ has(compoundStmt(hasDescendant(varDecl(hasName("e"),
+ has(declRefExpr(to(varDecl(hasName("a"),
+ has(varDecl(hasName("b"), hasInitializer(declRefExpr(to(
+   varDecl(hasName("c"))),
+ has(parmVarDecl(hasName("d")));
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ lambdaExpr(
+ forFunction(functionDecl(hasName("func14"))),
+ has(templateTypeParmDecl(hasName("TemplateType")));
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {
Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -479,4 +479,123 @@
 )cpp");
 }
 
+TEST(Traverse, LambdaUnlessSpelledInSource) {
+
+  auto AST =
+  buildASTFromCodeWithArgs(R"cpp(
+
+void captures() {
+  int a = 0;
+  int b = 0;
+  int d = 0;
+  int f = 0;
+
+  [a, , c = d,  = f](int g, int h = 42) {};
+}
+
+void templated() {
+  int a = 0;
+  [a](T t) {};
+}
+
+struct SomeStruct {
+int a = 0;
+void capture_this() {
+[this]() {};
+}
+void capture_this_copy() {
+[self = *this]() {};
+}
+};
+)cpp",
+   {"-Wno-unused-value", "-Wno-c++2a-extensions"});
+
+  auto getLambdaNode = [](const std::string ) {
+auto BN = ast_matchers::match(
+lambdaExpr(hasAncestor(functionDecl(hasName(name.bind("lambda"),
+AST->getASTContext());
+EXPECT_EQ(BN.size(), 1u);
+return BN[0].getNodeAs("lambda");
+  };
+
+  {
+auto L = getLambdaNode("captures");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-DeclRefExpr 'b'
+|-VarDecl 'c'
+| `-DeclRefExpr 'd'
+|-VarDecl 'e'
+| `-DeclRefExpr 'f'
+|-ParmVarDecl 'g'
+|-ParmVarDecl 'h'
+| `-IntegerLiteral
+`-CompoundStmt
+)cpp");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_AsIs, L),
+  R"cpp(
+LambdaExpr
+|-CXXRecordDecl ''
+| |-CXXMethodDecl 'operator()'
+| | |-ParmVarDecl 'g'
+| | |-ParmVarDecl 'h'
+| | | `-IntegerLiteral
+| | `-CompoundStmt
+| |-FieldDecl ''
+| |-FieldDecl ''
+| |-FieldDecl ''
+| |-FieldDecl ''
+| `-CXXDestructorDecl '~'
+|-ImplicitCastExpr
+| `-DeclRefExpr 'a'
+|-DeclRefExpr 'b'
+|-ImplicitCastExpr
+| `-DeclRefExpr 'd'
+|-DeclRefExpr 'f'
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("templated");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-TemplateTypeParmDecl 'T'
+|-ParmVarDecl 't'
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-CXXThisExpr
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this_copy");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-VarDecl 'self'
+| `-UnaryOperator
+|   `-CXXThisExpr
+`-CompoundStmt
+)cpp");
+  }
+}
+
 } // namespace clang
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp

[PATCH] D71722: Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot

2019-12-20 Thread Adrian Prantl via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44b4b833ad76: Rename DW_AT_LLVM_isysroot to 
DW_AT_LLVM_sysroot (authored by aprantl).
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71722

Files:
  clang/test/Modules/debug-info-moduleimport.m
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Assembler/dimodule.ll
  llvm/test/CodeGen/X86/load-combine-dbg.ll
  llvm/test/DebugInfo/X86/DIModule.ll
  llvm/test/DebugInfo/X86/DIModuleContext.ll
  llvm/test/DebugInfo/X86/clang-module.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2059,7 +2059,7 @@
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(ConfigMacro, N->getConfigurationMacros());
   EXPECT_EQ(Includes, N->getIncludePath());
-  EXPECT_EQ(Sysroot, N->getISysRoot());
+  EXPECT_EQ(Sysroot, N->getSysRoot());
   EXPECT_EQ(N, DIModule::get(Context, Scope, Name,
  ConfigMacro, Includes, Sysroot));
   EXPECT_NE(N, DIModule::get(Context, getFile(), Name,
Index: llvm/test/DebugInfo/X86/clang-module.ll
===
--- llvm/test/DebugInfo/X86/clang-module.ll
+++ llvm/test/DebugInfo/X86/clang-module.ll
@@ -24,7 +24,7 @@
 !1 = !DIFile(filename: "modules.m", directory: "/")
 !3 = !{!4}
 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, line: 122)
-!5 = !DIModule(scope: null, name: "Foo", includePath: ".", isysroot: "/")
+!5 = !DIModule(scope: null, name: "Foo", includePath: ".", sysroot: "/")
 !6 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !7, producer: "clang version 5.0.0 (trunk 308357) (llvm/trunk 308379)", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "/Foo.pcm", emissionKind: FullDebug, dwoId: 1234)
 !7 = !DIFile(filename: "Foo", directory: ".")
 !15 = !{i32 2, !"Dwarf Version", i32 4}
Index: llvm/test/DebugInfo/X86/DIModuleContext.ll
===
--- llvm/test/DebugInfo/X86/DIModuleContext.ll
+++ llvm/test/DebugInfo/X86/DIModuleContext.ll
@@ -25,7 +25,7 @@
 !5 = !{!0}
 !6 = !{!7}
 !7 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !8, file: !3, line: 11)
-!8 = !DIModule(scope: null, name: "Module", includePath: ".", isysroot: "/")
+!8 = !DIModule(scope: null, name: "Module", includePath: ".", sysroot: "/")
 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)
 !10 = !DICompositeType(tag: DW_TAG_structure_type, name: "s", scope: !8, file: !3, line: 1, flags: DIFlagFwdDecl)
 !11 = !{i32 2, !"Dwarf Version", i32 2}
Index: llvm/test/DebugInfo/X86/DIModule.ll
===
--- llvm/test/DebugInfo/X86/DIModule.ll
+++ llvm/test/DebugInfo/X86/DIModule.ll
@@ -6,7 +6,7 @@
 ; CHECK-NEXT: DW_AT_name {{.*}}"DebugModule"
 ; CHECK-NEXT: DW_AT_LLVM_config_macros {{.*}}"-DMODULES=0"
 ; CHECK-NEXT: DW_AT_LLVM_include_path {{.*}}"/llvm/tools/clang/test/Modules/Inputs"
-; CHECK-NEXT: DW_AT_LLVM_isysroot {{.*}}"/"
+; CHECK-NEXT: DW_AT_LLVM_sysroot {{.*}}"/"
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx"
@@ -20,7 +20,7 @@
 !2 = !{}
 !3 = !{!4}
 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, file: !1, line: 5)
-!5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", isysroot: "/")
+!5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", sysroot: "/")
 !6 = !{i32 2, !"Dwarf Version", i32 4}
 !7 = !{i32 2, !"Debug Info Version", i32 3}
 !8 = !{!"LLVM version 3.7.0"}
Index: llvm/test/CodeGen/X86/load-combine-dbg.ll
===
--- llvm/test/CodeGen/X86/load-combine-dbg.ll
+++ llvm/test/CodeGen/X86/load-combine-dbg.ll
@@ -25,7 +25,7 @@
 
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !3, isOptimized: false, emissionKind: FullDebug)
-!2 = !DIModule(scope: null, name: "test", includePath: "", isysroot: "/")
+!2 = !DIModule(scope: null, name: "test", 

[PATCH] D71680: Customize simplified dumping and matching of LambdaExpr

2019-12-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this might break tests: http://45.33.8.238/linux/6150/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71680



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61072 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[clang] 494b131 - Customize simplified dumping and matching of LambdaExpr

2019-12-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-20T21:13:23Z
New Revision: 494b1318ca77927e919bbf9a61749a58553d738c

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

LOG: Customize simplified dumping and matching of LambdaExpr

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/ASTNodeTraverser.h
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index f097d024c9e8..9dab814b659b 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -128,9 +128,12 @@ class ASTNodeTraverser
   ConstStmtVisitor::Visit(S);
 
   // Some statements have custom mechanisms for dumping their children.
-  if (isa(S) || isa(S)) {
+  if (isa(S) || isa(S))
+return;
+
+  if (isa(S) &&
+  Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource)
 return;
-  }
 
   for (const Stmt *SubStmt : S->children())
 Visit(SubStmt);
@@ -646,7 +649,23 @@ class ASTNodeTraverser
   }
 
   void VisitLambdaExpr(const LambdaExpr *Node) {
-Visit(Node->getLambdaClass());
+if (Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
+  for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
+const auto *C = Node->capture_begin() + I;
+if (!C->isExplicit())
+  continue;
+if (Node->isInitCapture(C))
+  Visit(C->getCapturedVar());
+else
+  Visit(Node->capture_init_begin()[I]);
+  }
+  dumpTemplateParameters(Node->getTemplateParameterList());
+  for (const auto *P : Node->getCallOperator()->parameters())
+Visit(P);
+  Visit(Node->getBody());
+} else {
+  return Visit(Node->getLambdaClass());
+}
   }
 
   void VisitSizeOfPackExpr(const SizeOfPackExpr *Node) {

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 8ac35d522843..2a43b4c7049f 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -145,7 +145,9 @@ class MatchChildASTVisitor
 
 ScopedIncrement ScopedDepth();
 Stmt *StmtToTraverse = StmtNode;
-if (auto *ExprNode = dyn_cast_or_null(StmtNode))
+if (auto *ExprNode = dyn_cast_or_null(StmtNode))
+  StmtToTraverse = ExprNode;
+else if (auto *ExprNode = dyn_cast_or_null(StmtNode))
   StmtToTraverse = Finder->getASTContext().traverseIgnored(ExprNode);
 if (Traversal ==
 ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
@@ -203,6 +205,38 @@ class MatchChildASTVisitor
 ScopedIncrement ScopedDepth();
 return traverse(*CtorInit);
   }
+  bool TraverseLambdaExpr(LambdaExpr *Node) {
+if (!Node)
+  return true;
+ScopedIncrement ScopedDepth();
+
+for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
+  const auto *C = Node->capture_begin() + I;
+  if (!C->isExplicit())
+continue;
+  if (Node->isInitCapture(C) && !match(*C->getCapturedVar()))
+return false;
+  if (!match(*Node->capture_init_begin()[I]))
+return false;
+}
+
+if (const auto *TPL = Node->getTemplateParameterList()) {
+  for (const auto *TP : *TPL) {
+if (!match(*TP))
+  return false;
+  }
+}
+
+for (const auto *P : Node->getCallOperator()->parameters()) {
+  if (!match(*P))
+return false;
+}
+
+if (!match(*Node->getBody()))
+  return false;
+
+return false;
+  }
 
   bool shouldVisitTemplateInstantiations() const { return true; }
   bool shouldVisitImplicitCode() const { return true; }

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index c995f55d3c89..4b982431297c 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -479,4 +479,123 @@ FunctionDecl 'func12'
 )cpp");
 }
 
+TEST(Traverse, LambdaUnlessSpelledInSource) {
+
+  auto AST =
+  buildASTFromCodeWithArgs(R"cpp(
+
+void captures() {
+  int a = 0;
+  int b = 0;
+  int d = 0;
+  int f = 0;
+
+  [a, , c = d,  = f](int g, int h = 42) {};
+}
+
+void templated() {
+  int a = 0;
+  [a](T t) {};
+}
+
+struct SomeStruct {
+int a = 0;
+void capture_this() {
+[this]() {};
+}
+void capture_this_copy() {
+[self = *this]() {};
+}
+};
+)cpp",
+   {"-Wno-unused-value", "-Wno-c++2a-extensions"});
+
+  auto getLambdaNode = 

[clang] 44b4b83 - Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot

2019-12-20 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2019-12-20T13:11:17-08:00
New Revision: 44b4b833ad76fc61e43473c581a557f72a4ed8f4

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

LOG: Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot

This is a purely cosmetic change that is NFC in terms of the binary
output. I bugs me that I called the attribute DW_AT_LLVM_isysroot
since the "i" is an artifact of GCC command line option syntax
(-isysroot is in the category of -i options) and doesn't carry any
useful information otherwise.

This attribute only appears in Clang module debug info.

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

Added: 


Modified: 
clang/test/Modules/debug-info-moduleimport.m
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
llvm/include/llvm-c/DebugInfo.h
llvm/include/llvm/BinaryFormat/Dwarf.def
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/test/Assembler/dimodule.ll
llvm/test/CodeGen/X86/load-combine-dbg.ll
llvm/test/DebugInfo/X86/DIModule.ll
llvm/test/DebugInfo/X86/DIModuleContext.ll
llvm/test/DebugInfo/X86/clang-module.ll
llvm/unittests/IR/MetadataTest.cpp

Removed: 




diff  --git a/clang/test/Modules/debug-info-moduleimport.m 
b/clang/test/Modules/debug-info-moduleimport.m
index 16820baebe68..df8a66bebfb6 100644
--- a/clang/test/Modules/debug-info-moduleimport.m
+++ b/clang/test/Modules/debug-info-moduleimport.m
@@ -15,7 +15,7 @@
 // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC",
 // CHECK-SAME:  configMacros: "\22-DGREETING=Hello World\22 \22-UNDEBUG\22",
 // CHECK-SAME:  includePath: "{{.*}}test{{.*}}Modules{{.*}}Inputs",
-// CHECK-SAME:  isysroot: "/tmp/..")
+// CHECK-SAME:  sysroot: "/tmp/..")
 // CHECK: ![[F]] = !DIFile(filename: {{.*}}debug-info-moduleimport.m
 
 // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t \

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 502d1af668c9..466d5ddd23db 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -977,7 +977,7 @@ bool SymbolFileDWARF::ParseImportedModules(
   DW_AT_LLVM_include_path, nullptr))
 module.search_path = ConstString(include_path);
   if (const char *sysroot = module_die.GetAttributeValueAsString(
-  DW_AT_LLVM_isysroot, nullptr))
+  DW_AT_LLVM_sysroot, nullptr))
 module.sysroot = ConstString(sysroot);
   imported_modules.push_back(module);
 }

diff  --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 731f32741e19..e933fe4b3f92 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -283,15 +283,15 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const 
char *Filename,
  * \param ConfigMacrosLen The length of the C string passed to \c ConfigMacros.
  * \param IncludePath The path to the module map file.
  * \param IncludePathLen  The length of the C string passed to \c IncludePath.
- * \param ISysRootThe Clang system root (value of -isysroot).
- * \param ISysRootLen The length of the C string passed to \c ISysRoot.
+ * \param SysRoot The Clang system root (value of -isysroot).
+ * \param SysRootLen  The length of the C string passed to \c SysRoot.
  */
 LLVMMetadataRef
 LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef 
ParentScope,
   const char *Name, size_t NameLen,
   const char *ConfigMacros, size_t ConfigMacrosLen,
   const char *IncludePath, size_t IncludePathLen,
-  const char *ISysRoot, size_t ISysRootLen);
+  const char *SysRoot, size_t SysRootLen);
 
 /**
  * Creates a new descriptor for a namespace with the specified parent scope.

diff  --git a/llvm/include/llvm/BinaryFormat/Dwarf.def 
b/llvm/include/llvm/BinaryFormat/Dwarf.def
index 8b1b14de6f09..cf3eaf433e5d 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -405,7 +405,7 @@ HANDLE_DW_AT(0x3b31, BORLAND_closure, 0, BORLAND)
 // LLVM project extensions.
 HANDLE_DW_AT(0x3e00, LLVM_include_path, 0, LLVM)
 HANDLE_DW_AT(0x3e01, LLVM_config_macros, 0, LLVM)
-HANDLE_DW_AT(0x3e02, LLVM_isysroot, 0, LLVM)
+HANDLE_DW_AT(0x3e02, LLVM_sysroot, 0, LLVM)
 

[PATCH] D71463: Implement VectorType conditional operator GNU extension.

2019-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:480
 =yes yes yes yes
-:?   yes --  --  --
+:?[*]_  yes --  yes --
 sizeof   yes yes yes yes

Do these columns line up in the actual source file? They don't appear to line 
up in the Phab viewer, but I don't know if that's an artifact of Phab or not.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6882
+def err_conditional_vector_operand_type
+: Error<"%select{enumeral|extended vector}0 type %1 is not allowed in a "
+"vector conditional">;

We don't actually use enumeral in diagnostics anywhere -- I think that should 
be enumeration instead.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4301
+llvm::Type *condType = ConvertType(condExpr->getType());
+llvm::VectorType *vecTy = cast(condType);
+llvm::Value *zeroVec = llvm::Constant::getNullValue(vecTy);

`auto *`

Also, should these three variables have identifiers starting with an uppercase 
like `CondV` et al?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5757
+  const QualType EltTy =
+  cast(CondTy.getCanonicalType().getTypePtr())
+  ->getElementType();

Do you actually need the `getTypePtr()` bit, or will the `cast<>` suffice to 
trigger the cast through `Type*`?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5761-5762
+  // isIntegralType doesn't exactly match the the needs here, but would 
function
+  // well enough.  The boolean check is redundant since a vector of type bool
+  // isn't allowed, and the enumeral type check is redundant because
+  // isIntegralType isn't true in 'C++' mode.  Additionally, enumeral types

If these checks are redundant, would you prefer to assert them?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5779
+  QualType CondType = Cond.get()->getType();
+  const VectorType *CondVT = CondType->getAs();
+  QualType CondElementTy = CondVT->getElementType();

`const auto *` (same elsewhere in the function where the type is spelled out in 
the initialization)



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5793
+Diag(QuestionLoc, diag::err_conditional_vector_operand_type)
+<< /*isExtVector*/ true << RHSType;
+return {};

Shouldn't this pass in the `LHSType` instead because that's what's being tested?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5799
+Diag(QuestionLoc, diag::err_conditional_vector_operand_type)
+<< /*isExtVector*/ true << LHSType;
+return {};

And this one do the `RHSType`?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5805
+// If both are vector types, they must be the same type.
+if (!Context.hasSameType(LHSType, RHSType)) {
+  Diag(QuestionLoc, diag::err_conditional_vector_mismatched_vectors)

Do you need to canonicalize these types before comparing them?


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

https://reviews.llvm.org/D71463



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 234950.
ABataev added a comment.

Removed check for isArrow() + added requested test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2458,6 +2458,8 @@
 void OMPClauseEnqueue::VisitOMPNontemporalClause(
 const OMPNontemporalClause *C) {
   VisitOMPClauseList(C);
+  for (const auto *E : C->private_refs())
+Visitor->AddStmt(E);
 }
 }
 
Index: clang/test/OpenMP/teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_simd_codegen.cpp
@@ -177,16 +177,16 @@
   // CK3: define {{.*}}i32 @{{.+}}foo{{.+}}(
   int foo(void) {
 
-  // CK3: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* %{{.+}}, i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 1)
+  // CK3: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 3, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* %{{.+}}, i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 1)
   // CK3: call void @[[OFFL1:.+]]([[SSI]]* %{{.+}})
 #pragma omp target
 #ifdef OMP5
-#pragma omp teams distribute simd if(b)
+#pragma omp teams distribute simd if(b) nontemporal(a, b)
 #else
 #pragma omp teams distribute simd
 #endif // OMP5
 for(int i = 0; i < X; i++) {
-  a[i] = (T)0;
+  a[i] = (T)b;
 }
 
   // outlined target region
@@ -197,6 +197,8 @@
 
   // CK3: define internal void @[[OUTL1]]({{.+}})
   // CK3: call void @__kmpc_for_static_init_4(
+  // OMP3_45-NOT: !nontemporal
+  // OMP3_50: load float,{{.*}}!nontemporal
   // CK3: call void @__kmpc_for_static_fini(
   // CK3: ret void
 
Index: clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
@@ -165,7 +165,7 @@
 
   // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}})
 #ifdef OMP5
-  #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a) if(simd: 1)
+  #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a) if(simd: 1) nontemporal(a)
 #else
   #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a)
 #endif // OMP5
@@ -395,6 +395,8 @@
 // CHECK:   [[AA_ADDR:%.+]] = alloca i[[SZ]], align
 // CHECK:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[AA_ADDR]], align
 // CHECK-64:[[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i32*
+// OMP45-NOT:   !nontemporal
+// OMP50:   load i32,{{.*}}!nontemporal
 // CHECK-64:store i32 10, i32* [[AA_CADDR]], align
 // CHECK-32:store i32 10, i32* [[AA_ADDR]], align
 // CHECK:   ret void
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
@@ -35,20 +35,25 @@
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 #ifdef OMP5
-#pragma omp target teams distribute parallel for simd if(simd: true)
+#pragma omp target teams distribute parallel for simd if(simd: true) nontemporal(Arg)
 #else
 #pragma omp target teams distribute parallel for simd
 #endif // OMP5
-  for(int i = 0 ; i < 100; i++) {}
+  for (int i = 0; i < 100; i++) {
+Arg = 0;
+  }
   // CHECK: define internal void [[OFFLOADING_FUN_0]](
-  // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[OMP_TEAMS_OUTLINED_0:@.+]] to {{.+}})
+  // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}}* [[OMP_TEAMS_OUTLINED_0:@.+]] to {{.+}})
 

[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59878ec8092b: [analyzer] Add path notes to 
FuchsiaHandleCheck. (authored by xazax.hun).

Changed prior to commit:
  https://reviews.llvm.org/D70725?vs=231996=234952#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70725

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/test/Analysis/fuchsia_handle.cpp

Index: clang/test/Analysis/fuchsia_handle.cpp
===
--- clang/test/Analysis/fuchsia_handle.cpp
+++ clang/test/Analysis/fuchsia_handle.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -analyzer-output=text \
+// RUN: -verify %s
 
 typedef __typeof__(sizeof(int)) size_t;
 typedef int zx_status_t;
@@ -116,33 +117,76 @@
 
 void checkLeak01(int tag) {
   zx_handle_t sa, sb;
-  if (zx_channel_create(0, , ))
-return;
+  if (zx_channel_create(0, , )) // expected-note{{Handle allocated here}}
+return;   // expected-note@-1 {{Assuming the condition is false}}
+  // expected-note@-2 {{Taking false branch}}
   use1();
-  if (tag)
+  if (tag) // expected-note {{Assuming 'tag' is 0}}
 zx_handle_close(sa);
+  // expected-note@-2 {{Taking false branch}}
   use2(sb); // expected-warning {{Potential leak of handle}}
+  // expected-note@-1 {{Potential leak of handle}}
+  zx_handle_close(sb);
+}
+
+void checkReportLeakOnOnePath(int tag) {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, , )) // expected-note {{Handle allocated here}}
+return;   // expected-note@-1 {{Assuming the condition is false}}
+  // expected-note@-2 {{Taking false branch}}
   zx_handle_close(sb);
+  switch(tag) { // expected-note {{Control jumps to the 'default' case at line}} 
+case 0:
+  use2(sa);
+  return;
+case 1:
+  use2(sa);
+  return;
+case 2:
+  use2(sa);
+  return;
+case 3:
+  use2(sa);
+  return;
+case 4:
+  use2(sa);
+  return;
+default:
+  use2(sa);
+  return; // expected-warning {{Potential leak of handle}}
+  // expected-note@-1 {{Potential leak of handle}}
+  }
 }
 
 void checkDoubleRelease01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, , );
-  if (tag)
-zx_handle_close(sa);
+  // expected-note@-1 {{Handle allocated here}}
+  if (tag) // expected-note {{Assuming 'tag' is not equal to 0}}
+zx_handle_close(sa); // expected-note {{Handle released here}}
+  // expected-note@-2 {{Taking true branch}}
   zx_handle_close(sa); // expected-warning {{Releasing a previously released handle}}
+  // expected-note@-1 {{Releasing a previously released handle}}
   zx_handle_close(sb);
 }
 
 void checkUseAfterFree01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, , );
+  // expected-note@-1 {{Handle allocated here}}
+  // expected-note@-2 {{Handle allocated here}}
+  // expected-note@+2 {{Taking true branch}}
+  // expected-note@+1 {{Taking false branch}}
   if (tag) {
-zx_handle_close(sa);
+// expected-note@-1 {{Assuming 'tag' is not equal to 0}}
+zx_handle_close(sa); // expected-note {{Handle released here}}
 use1(); // expected-warning {{Using a previously released handle}}
+// expected-note@-1 {{Using a previously released handle}}
   }
-  zx_handle_close(sb);
+  // expected-note@-6 {{Assuming 'tag' is 0}}
+  zx_handle_close(sb); // expected-note {{Handle released here}}
   use2(sb); // expected-warning {{Using a previously released handle}}
+  // expected-note@-1 {{Using a previously released handle}}
 }
 
 void checkMemberOperatorIndices() {
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -199,6 +199,28 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(HStateMap, SymbolRef, HandleState)
 
+static const ExplodedNode *getAcquireSite(const ExplodedNode *N, SymbolRef Sym,
+  CheckerContext ) {
+  ProgramStateRef State = N->getState();
+  // When bug type is handle leak, exploded node N does not have state info for
+  // leaking handle. Get the predecessor of N instead.
+  if (!State->get(Sym))
+N = N->getFirstPred();
+
+  const ExplodedNode *Pred = N;
+  while (N) {
+State = N->getState();
+if (!State->get(Sym)) {
+  const HandleState *HState = Pred->getState()->get(Sym);
+  if (HState && (HState->isAllocated() || HState->maybeAllocated()))
+return N;
+

[PATCH] D71686: Fix false positive in magic number checker

2019-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp:129
+// expanded class enumeration value.
+if (Parent.get())
+  return true;

So will this no longer treat *any* C-style cast as being a magic number? e.g., 
`int i; i = (int)12;`


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

https://reviews.llvm.org/D71686



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


[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Thanks for the reviews!


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

https://reviews.llvm.org/D70725



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


[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Thanks for the reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70470



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


[clang] 59878ec - [analyzer] Add path notes to FuchsiaHandleCheck.

2019-12-20 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-12-20T12:40:41-08:00
New Revision: 59878ec8092bef656a71d22261fd3b70651e8318

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

LOG: [analyzer] Add path notes to FuchsiaHandleCheck.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/test/Analysis/fuchsia_handle.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index e94b544172a0..69593e2b6c93 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -386,7 +386,7 @@ class PathSensitiveBugReport : public BugReport {
   /// to the user. This method allows to rest the location which should be used
   /// for uniquing reports. For example, memory leaks checker, could set this 
to
   /// the allocation site, rather then the location where the bug is reported.
-  PathSensitiveBugReport(BugType , StringRef desc,
+  PathSensitiveBugReport(const BugType , StringRef desc,
  const ExplodedNode *errorNode,
  PathDiagnosticLocation LocationToUnique,
  const Decl *DeclToUnique)

diff  --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
index 25eb4f5ba82d..861dfef02393 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -199,6 +199,28 @@ class FuchsiaHandleChecker
 
 REGISTER_MAP_WITH_PROGRAMSTATE(HStateMap, SymbolRef, HandleState)
 
+static const ExplodedNode *getAcquireSite(const ExplodedNode *N, SymbolRef Sym,
+  CheckerContext ) {
+  ProgramStateRef State = N->getState();
+  // When bug type is handle leak, exploded node N does not have state info for
+  // leaking handle. Get the predecessor of N instead.
+  if (!State->get(Sym))
+N = N->getFirstPred();
+
+  const ExplodedNode *Pred = N;
+  while (N) {
+State = N->getState();
+if (!State->get(Sym)) {
+  const HandleState *HState = Pred->getState()->get(Sym);
+  if (HState && (HState->isAllocated() || HState->maybeAllocated()))
+return N;
+}
+Pred = N;
+N = N->getFirstPred();
+  }
+  return nullptr;
+}
+
 /// Returns the symbols extracted from the argument or null if it cannot be
 /// found.
 SymbolRef getFuchsiaHandleSymbol(QualType QT, SVal Arg, ProgramStateRef State) 
{
@@ -282,6 +304,7 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
,
 
   ProgramStateRef State = C.getState();
 
+  std::vector> Notes;
   SymbolRef ResultSymbol = nullptr;
   if (const auto *TypeDefTy = FuncDecl->getReturnType()->getAs())
 if (TypeDefTy->getDecl()->getName() == ErrorTypeName)
@@ -310,14 +333,45 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
,
   if (HState && HState->isReleased()) {
 reportDoubleRelease(Handle, Call.getArgSourceRange(Arg), C);
 return;
-  } else
+  } else {
+Notes.push_back([Handle](BugReport ) {
+  auto *PathBR = static_cast();
+  if (auto IsInteresting = PathBR->getInterestingnessKind(Handle)) {
+return "Handle released here.";
+  } else
+return "";
+});
 State = State->set(Handle, HandleState::getReleased());
+  }
 } else if (hasFuchsiaAttr(PVD)) {
+  Notes.push_back([Handle](BugReport ) {
+auto *PathBR = static_cast();
+if (auto IsInteresting = PathBR->getInterestingnessKind(Handle)) {
+  return "Handle allocated here.";
+} else
+  return "";
+  });
   State = State->set(
   Handle, HandleState::getMaybeAllocated(ResultSymbol));
 }
   }
-  C.addTransition(State);
+  const NoteTag *T = nullptr;
+  if (!Notes.empty()) {
+T = C.getNoteTag(
+[this, Notes{std::move(Notes)}](BugReport ) -> std::string {
+  if (() !=  &&
+  () !=  &&
+  () != )
+return "";
+  for (auto  : Notes) {
+std::string Text = Note(BR);
+if (!Text.empty())
+  return Text;
+  }
+  return "";
+});
+  }
+  C.addTransition(State, T);
 }
 
 void FuchsiaHandleChecker::checkDeadSymbols(SymbolReaper ,
@@ -353,6 +407,7 @@ void FuchsiaHandleChecker::checkDeadSymbols(SymbolReaper 
,
 ProgramStateRef FuchsiaHandleChecker::evalAssume(ProgramStateRef State,
  

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
xazax.hun marked 2 inline comments as done.
Closed by commit rG82923c71efa5: [analyzer] Add Fuchsia Handle checker 
(authored by xazax.hun).

Changed prior to commit:
  https://reviews.llvm.org/D70470?vs=233691=234948#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70470

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/test/Analysis/fuchsia_handle.cpp

Index: clang/test/Analysis/fuchsia_handle.cpp
===
--- /dev/null
+++ clang/test/Analysis/fuchsia_handle.cpp
@@ -0,0 +1,285 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -verify %s
+
+typedef __typeof__(sizeof(int)) size_t;
+typedef int zx_status_t;
+typedef __typeof__(sizeof(int)) zx_handle_t;
+typedef unsigned int uint32_t;
+#define NULL ((void *)0)
+#define ZX_HANDLE_INVALID 0
+
+#if defined(__clang__)
+#define ZX_HANDLE_ACQUIRE  __attribute__((acquire_handle("Fuchsia")))
+#define ZX_HANDLE_RELEASE  __attribute__((release_handle("Fuchsia")))
+#define ZX_HANDLE_USE  __attribute__((use_handle("Fuchsia")))
+#else
+#define ZX_HANDLE_ACQUIRE
+#define ZX_HANDLE_RELEASE
+#define ZX_HANDLE_USE
+#endif
+
+zx_status_t zx_channel_create(
+uint32_t options,
+zx_handle_t *out0 ZX_HANDLE_ACQUIRE,
+zx_handle_t *out1 ZX_HANDLE_ACQUIRE);
+
+zx_status_t zx_handle_close(
+zx_handle_t handle ZX_HANDLE_RELEASE);
+
+void escape1(zx_handle_t *in);
+void escape2(zx_handle_t in);
+void (*escape3)(zx_handle_t) = escape2; 
+
+void use1(const zx_handle_t *in ZX_HANDLE_USE);
+void use2(zx_handle_t in ZX_HANDLE_USE);
+
+void moreArgs(zx_handle_t, int, ...);
+void lessArgs(zx_handle_t, int a = 5);
+
+// To test if argument indexes are OK for operator calls.
+struct MyType {
+  ZX_HANDLE_ACQUIRE
+  zx_handle_t operator+(zx_handle_t ZX_HANDLE_RELEASE replace);
+};
+
+void checkInvalidHandle01() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  if (sa == ZX_HANDLE_INVALID)
+;
+  // Will we ever see a warning like below?
+  // We eagerly replace the symbol with a constant and lose info...
+  use2(sa); // TODOexpected-warning {{Use of an invalid handle}}
+  zx_handle_close(sb);
+  zx_handle_close(sa);
+}
+
+void checkInvalidHandle2() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  if (sb != ZX_HANDLE_INVALID)
+zx_handle_close(sb);
+  if (sa != ZX_HANDLE_INVALID)
+zx_handle_close(sa);
+}
+
+void checkNoCrash01() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  moreArgs(sa, 1, 2, 3, 4, 5);
+  lessArgs(sa);
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+}
+
+void checkNoLeak01() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+}
+
+void checkNoLeak02() {
+  zx_handle_t ay[2];
+  zx_channel_create(0, [0], [1]);
+  zx_handle_close(ay[0]);
+  zx_handle_close(ay[1]);
+}
+
+void checkNoLeak03() {
+  zx_handle_t ay[2];
+  zx_channel_create(0, [0], [1]);
+  for (int i = 0; i < 2; i++)
+zx_handle_close(ay[i]);
+}
+
+zx_handle_t checkNoLeak04() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  zx_handle_close(sa);
+  return sb; // no warning
+}
+
+zx_handle_t checkNoLeak05(zx_handle_t *out1) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  *out1 = sa;
+  return sb; // no warning
+}
+
+void checkNoLeak06() {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, , ))
+return;
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+} 
+
+void checkLeak01(int tag) {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, , ))
+return;
+  use1();
+  if (tag)
+zx_handle_close(sa);
+  use2(sb); // expected-warning {{Potential leak of handle}}
+  zx_handle_close(sb);
+}
+
+void checkDoubleRelease01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  if (tag)
+zx_handle_close(sa);
+  zx_handle_close(sa); // expected-warning {{Releasing a previously released handle}}
+  zx_handle_close(sb);
+}
+
+void checkUseAfterFree01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, , );
+  if (tag) {
+zx_handle_close(sa);
+use1(); // expected-warning {{Using a previously released handle}}
+  }
+  zx_handle_close(sb);
+  use2(sb); // expected-warning {{Using a previously released handle}}
+}
+
+void checkMemberOperatorIndices() {
+  zx_handle_t sa, sb, sc;
+  zx_channel_create(0, , );
+  zx_handle_close(sb);
+  MyType t;
+  sc = t + sa;
+  zx_handle_close(sc);
+}
+
+// RAII
+
+template 
+struct HandleWrapper {
+  ~HandleWrapper() { close(); }
+  void close() {
+if (handle != ZX_HANDLE_INVALID)
+  zx_handle_close(handle);
+  }
+  T 

[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-20 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

I've gone ahead and landed the patch so that we can iterate in tree.  See 
commit 14fc20ca62821b5f85582bf76a467d412248c248 
.

I've also landed a couple of follow up patches to address issues which would 
have otherwise required iteration on the review.  See commits 
c148e2e2ef86f53391be459752511684424f331b 
, 
4024d49edc1598a6f8017df541147b38bf1e2818 
, and 
8b725f0459eee468ed7f9935fba3278fcb4997b1 
.

I still see some room for further cleanup (i.e. the fragment range scheme and 
tests), but what's in is of reasonable quality.

There's a couple follow up patches which are probably called for, but I think 
we can work on these in parallel now.

1. We need to settle on assembler syntax.
2. We need a patch for the x86 MI to MC translation to mark regions unsafe to 
pad.  (Probably best to separate from the above for the moment.)
3. We can incrementally add support for prefix padding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70157



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


[PATCH] D69876: Allow output constraints on "asm goto"

2019-12-20 Thread Bill Wendling via Phabricator via cfe-commits
void marked an inline comment as done.
void added inline comments.



Comment at: clang/test/CodeGen/asm-goto.c:91
+  return 1;
+}

nickdesaulniers wrote:
> Thanks for adding this test.  I think it doesn't test that `addr` is 
> *clobbered* though?
The `+` modifier indicates that `addr` is used for both input and output, in 
effect being clobbered. Otherwise, we would need to add a "clobber" list, but 
from what I understand that seems to be restricted to registers, memory, and 
`cc`. I wouldn't be able to specify a specific register for `addr` (e.g. 
`"+D"(addr)`) and also have `%rdx` in the clobber list.

Was there something else you were thinking of?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69876



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


[clang] 82923c7 - [analyzer] Add Fuchsia Handle checker

2019-12-20 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-12-20T12:33:16-08:00
New Revision: 82923c71efa57600d015dbc281202941d3d64dde

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

LOG: [analyzer] Add Fuchsia Handle checker

The checker can diagnose handle use after releases, double releases, and
handle leaks.

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

Added: 
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/test/Analysis/fuchsia_handle.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index b410c0858789..34d29ba344c9 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1335,6 +1335,31 @@ Warns if 'CFArray', 'CFDictionary', 'CFSet' are created 
with non-pointer-size va
 ); // warn
  }
 
+Fuchsia
+^^^
+
+Fuchsia is an open source capability-based operating system currently being
+developed by Google. This section describes checkers that can find various
+misuses of Fuchsia APIs.
+
+.. _fuchsia-HandleChecker:
+
+fuchsia.HandleChecker
+
+Handles identify resources. Similar to pointers they can be leaked,
+double freed, or use after freed. This check attempts to find such problems.
+
+.. code-block:: cpp
+
+ void checkLeak08(int tag) {
+   zx_handle_t sa, sb;
+   zx_channel_create(0, , );
+   if (tag)
+ zx_handle_close(sa);
+   use(sb); // Warn: Potential leak of handle
+   zx_handle_close(sb);
+ }
+
 
 .. _alpha-checkers:
 

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 5b23de418999..6d68d8215597 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -108,6 +108,8 @@ def CloneDetectionAlpha : Package<"clone">, 
ParentPackage;
 
 def NonDeterminismAlpha : Package<"nondeterminism">, ParentPackage;
 
+def Fuchsia : Package<"fuchsia">;
+
 
//===--===//
 // Core Checkers.
 
//===--===//
@@ -1423,3 +1425,16 @@ def PointerSortingChecker : Checker<"PointerSorting">,
   Documentation;
 
 } // end alpha.nondeterminism
+
+//===--===//
+// Fuchsia checkers.
+//===--===//
+
+let ParentPackage = Fuchsia in {
+
+def FuchsiaHandleChecker : Checker<"HandleChecker">,
+  HelpText<"A Checker that detect leaks related to Fuchsia handles">,
+  Documentation;
+
+} // end fuchsia
+

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 7f4df0d88def..bd8760cf0ce0 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -213,6 +213,22 @@ class CheckerContext {
 return addTransition(State, (Tag ? Tag : Location.getTag()));
   }
 
+  /// Generate a transition to a node that will be used to report
+  /// an error. This node will not be a sink. That is, exploration will
+  /// continue along this path.
+  ///
+  /// @param State The state of the generated node.
+  /// @param Pred The transition will be generated from the specified Pred node
+  /// to the newly generated node.
+  /// @param Tag The tag to uniquely identify the creation site. If null,
+  ///the default tag for the checker will be used.
+  ExplodedNode *
+  generateNonFatalErrorNode(ProgramStateRef State,
+ExplodedNode *Pred,
+const ProgramPointTag *Tag = nullptr) {
+return addTransition(State, Pred, (Tag ? Tag : Location.getTag()));
+  }
+
   /// Emit the diagnostics report.
   void emitReport(std::unique_ptr R) {
 Changed = true;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1347c3de913e..2ebfc763705f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2794,6 +2794,8 @@ static void RenderAnalyzerOptions(const ArgList , 
ArgStringList ,
   CmdArgs.push_back(
   "-analyzer-checker=security.insecureAPI.decodeValueOfObjCType");
 }
+else if (Triple.isOSFuchsia())

[PATCH] D70919: [Hexagon] Avoid passing unsupported options to lld when -fuse-ld=lld is used

2019-12-20 Thread Sid Manning via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd567b0ba841d: Avoid unsupported LLD options (authored by 
sidneym).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70919

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/Inputs/hexagon_tree/Tools/bin/ld.lld
  clang/test/Driver/hexagon-toolchain-elf.c


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -536,3 +536,25 @@
 // RUN:   | FileCheck -check-prefix=CHECK080 %s
 // CHECK080:  "-cc1"
 // CHECK080:  "-Wreturn-type"
+
+// 
-
+// Default, not passing -fuse-ld
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK081 %s
+// CHECK081:  "-march=hexagon"
+// CHECK081:  "-mcpu=hexagonv60"
+// 
-
+// Passing -fuse-ld=lld
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -fuse-ld=lld \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK082 %s
+// CHECK082-NOT:  -march=
+// CHECK082-NOT:  -mcpu=
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -209,7 +209,11 @@
   bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
   bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
   bool UseG0 = false;
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  bool UseLLD = (llvm::sys::path::filename(Exec).equals_lower("ld.lld") ||
+ llvm::sys::path::stem(Exec).equals_lower("ld.lld"));
   bool UseShared = IsShared && !IsStatic;
+  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
 
   
//
   // Silence warnings for various options
@@ -232,9 +236,10 @@
   for (const auto  : HTC.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
-  CmdArgs.push_back("-march=hexagon");
-  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
-  CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
+  if (!UseLLD) {
+CmdArgs.push_back("-march=hexagon");
+CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
+  }
 
   if (IsShared) {
 CmdArgs.push_back("-shared");


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -536,3 +536,25 @@
 // RUN:   | FileCheck -check-prefix=CHECK080 %s
 // CHECK080:  "-cc1"
 // CHECK080:  "-Wreturn-type"
+
+// -
+// Default, not passing -fuse-ld
+// -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK081 %s
+// CHECK081:  "-march=hexagon"
+// CHECK081:  "-mcpu=hexagonv60"
+// -
+// Passing -fuse-ld=lld
+// -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -fuse-ld=lld \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK082 %s
+// CHECK082-NOT:  -march=
+// CHECK082-NOT:  -mcpu=
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -209,7 +209,11 @@
   bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
   bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
   bool UseG0 = false;
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  bool UseLLD = (llvm::sys::path::filename(Exec).equals_lower("ld.lld") 

[PATCH] D70700: [WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`

2019-12-20 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

__wasm_argc_argv -> __main_argc_argv in the title?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70700



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks.  Could you add some tests that `nontemporal` directives aren't 
disturbed by either (1) nested `nontemporal` directives or (2) nested 
directives of some other kind?




Comment at: clang/lib/CodeGen/CGExpr.cpp:3952
+   CGM.getOpenMPRuntime().isNontemporalDecl(Field)) ||
+  (!E->isArrow() && BaseLV.isNontemporal()))
+LV.setNontemporal(/*Value=*/true);

ABataev wrote:
> rjmccall wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > rjmccall wrote:
> > > > > Is the `!E->isArrow()` condition necessary here?  Why not just 
> > > > > propagate the non-temporality of the base?
> > > > > 
> > > > > Similarly, what's the case in which the declaration is marked 
> > > > > non-temporal and you *don't* want to trust that?
> > > > That's the main question. I try to mimic the behavior we currenty have 
> > > > in the codegen. If the lvalue for the pointer is marked as nontemporal, 
> > > > only loads/stores for the pointer itself are marked as nontemporal. 
> > > > Operations with the memory it points to are not marked as nontemporal. 
> > > > I'm trying to do the same. E.g., if have something like `a.b->c` and 
> > > > `a` is nontemporal, then only `a.b = x;` must be marked as nontemporal, 
> > > > but not `a.b->c = x;`
> > > > Similarly, what's the case in which the declaration is marked 
> > > > non-temporal and you *don't* want to trust that?
> > > 
> > > There is no such case. We can mark `this->member` as nontemporal or 
> > > `declref`. The first check here checks if we have `this->member` marked 
> > > as nontemporal, the second check just propagates the flag if the base is 
> > > marked as nontemporal.
> > Okay.  Then this should just be `(BaseLV.isNontemporal() || 
> > CGM.getOpenMPRuntime().isNontemporalDecl(Field))`.
> Still, `a->c` will be marked as nontemporal if `a` is nontemporal. Also, if 
> we remove the check for the `CXXThis` in the condition, we can erroneously 
> mark the instruction as nontemporal if we reference member of another base, 
> which is nontemporal:
> ```
> struct S;
> extern S s;
> struct S {
>   int a, b;
>   void foo() {
> #pragma omp simd nontemporal(a)
> for (int i = 0; i < 10; ++i)
>   s.a = 0; // Will be marked as nontemporal though it should not?
>   }
> } s;
> 
> ```
> Still, a->c will be marked as nontemporal if a is nontemporal.

No, the base LValue we build in this case will not be related to the LValue for 
`a`; the pointer is loaded from that l-value, but its  properties do not 
propagate to the pointer, just like how `S * volatile s` doesn't mean that 
`s->x` is `volatile`.

> Also, if we remove the check for the CXXThis in the condition, we can 
> erroneously mark the instruction as nontemporal if we reference member of 
> another base, which is nontemporal:

I see, this is specifically part of the semantics that the field only becomes 
non-temporal for `this`.  Okay, I accept that part of the original condition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3952
+   CGM.getOpenMPRuntime().isNontemporalDecl(Field)) ||
+  (!E->isArrow() && BaseLV.isNontemporal()))
+LV.setNontemporal(/*Value=*/true);

rjmccall wrote:
> ABataev wrote:
> > rjmccall wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > rjmccall wrote:
> > > > > > Is the `!E->isArrow()` condition necessary here?  Why not just 
> > > > > > propagate the non-temporality of the base?
> > > > > > 
> > > > > > Similarly, what's the case in which the declaration is marked 
> > > > > > non-temporal and you *don't* want to trust that?
> > > > > That's the main question. I try to mimic the behavior we currenty 
> > > > > have in the codegen. If the lvalue for the pointer is marked as 
> > > > > nontemporal, only loads/stores for the pointer itself are marked as 
> > > > > nontemporal. Operations with the memory it points to are not marked 
> > > > > as nontemporal. I'm trying to do the same. E.g., if have something 
> > > > > like `a.b->c` and `a` is nontemporal, then only `a.b = x;` must be 
> > > > > marked as nontemporal, but not `a.b->c = x;`
> > > > > Similarly, what's the case in which the declaration is marked 
> > > > > non-temporal and you *don't* want to trust that?
> > > > 
> > > > There is no such case. We can mark `this->member` as nontemporal or 
> > > > `declref`. The first check here checks if we have `this->member` marked 
> > > > as nontemporal, the second check just propagates the flag if the base 
> > > > is marked as nontemporal.
> > > Okay.  Then this should just be `(BaseLV.isNontemporal() || 
> > > CGM.getOpenMPRuntime().isNontemporalDecl(Field))`.
> > Still, `a->c` will be marked as nontemporal if `a` is nontemporal. Also, if 
> > we remove the check for the `CXXThis` in the condition, we can erroneously 
> > mark the instruction as nontemporal if we reference member of another base, 
> > which is nontemporal:
> > ```
> > struct S;
> > extern S s;
> > struct S {
> >   int a, b;
> >   void foo() {
> > #pragma omp simd nontemporal(a)
> > for (int i = 0; i < 10; ++i)
> >   s.a = 0; // Will be marked as nontemporal though it should not?
> >   }
> > } s;
> > 
> > ```
> > Still, a->c will be marked as nontemporal if a is nontemporal.
> 
> No, the base LValue we build in this case will not be related to the LValue 
> for `a`; the pointer is loaded from that l-value, but its  properties do not 
> propagate to the pointer, just like how `S * volatile s` doesn't mean that 
> `s->x` is `volatile`.
> 
> > Also, if we remove the check for the CXXThis in the condition, we can 
> > erroneously mark the instruction as nontemporal if we reference member of 
> > another base, which is nontemporal:
> 
> I see, this is specifically part of the semantics that the field only becomes 
> non-temporal for `this`.  Okay, I accept that part of the original condition.
But please add some tests that you don't honor `nontemporal` on base 
expressions not derived from `this`.

Does "wrapped" include looking through derived-to-base conversions?  You should 
test that as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[clang] d567b0b - Avoid unsupported LLD options

2019-12-20 Thread Sid Manning via cfe-commits

Author: Sid Manning
Date: 2019-12-20T14:18:10-06:00
New Revision: d567b0ba841d4b6f4b0d906da350a3bb2b2f769f

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

LOG: Avoid unsupported LLD options

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

Added: 
clang/test/Driver/Inputs/hexagon_tree/Tools/bin/ld.lld

Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 4a735a2a1d59..e4d9ea8a70f9 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -209,7 +209,11 @@ constructHexagonLinkArgs(Compilation , const JobAction 
,
   bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
   bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
   bool UseG0 = false;
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  bool UseLLD = (llvm::sys::path::filename(Exec).equals_lower("ld.lld") ||
+ llvm::sys::path::stem(Exec).equals_lower("ld.lld"));
   bool UseShared = IsShared && !IsStatic;
+  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
 
   
//
   // Silence warnings for various options
@@ -232,9 +236,10 @@ constructHexagonLinkArgs(Compilation , const JobAction 
,
   for (const auto  : HTC.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
-  CmdArgs.push_back("-march=hexagon");
-  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
-  CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
+  if (!UseLLD) {
+CmdArgs.push_back("-march=hexagon");
+CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
+  }
 
   if (IsShared) {
 CmdArgs.push_back("-shared");

diff  --git a/clang/test/Driver/Inputs/hexagon_tree/Tools/bin/ld.lld 
b/clang/test/Driver/Inputs/hexagon_tree/Tools/bin/ld.lld
new file mode 100755
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index 661e758d931b..0339619e1c1f 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -536,3 +536,25 @@
 // RUN:   | FileCheck -check-prefix=CHECK080 %s
 // CHECK080:  "-cc1"
 // CHECK080:  "-Wreturn-type"
+
+// 
-
+// Default, not passing -fuse-ld
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK081 %s
+// CHECK081:  "-march=hexagon"
+// CHECK081:  "-mcpu=hexagonv60"
+// 
-
+// Passing -fuse-ld=lld
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -fuse-ld=lld \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK082 %s
+// CHECK082-NOT:  -march=
+// CHECK082-NOT:  -mcpu=



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 234943.
ABataev added a comment.

Fix + rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2458,6 +2458,8 @@
 void OMPClauseEnqueue::VisitOMPNontemporalClause(
 const OMPNontemporalClause *C) {
   VisitOMPClauseList(C);
+  for (const auto *E : C->private_refs())
+Visitor->AddStmt(E);
 }
 }
 
Index: clang/test/OpenMP/teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_simd_codegen.cpp
@@ -177,16 +177,16 @@
   // CK3: define {{.*}}i32 @{{.+}}foo{{.+}}(
   int foo(void) {
 
-  // CK3: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* %{{.+}}, i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 1)
+  // CK3: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 3, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* %{{.+}}, i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 1)
   // CK3: call void @[[OFFL1:.+]]([[SSI]]* %{{.+}})
 #pragma omp target
 #ifdef OMP5
-#pragma omp teams distribute simd if(b)
+#pragma omp teams distribute simd if(b) nontemporal(a, b)
 #else
 #pragma omp teams distribute simd
 #endif // OMP5
 for(int i = 0; i < X; i++) {
-  a[i] = (T)0;
+  a[i] = (T)b;
 }
 
   // outlined target region
@@ -197,6 +197,8 @@
 
   // CK3: define internal void @[[OUTL1]]({{.+}})
   // CK3: call void @__kmpc_for_static_init_4(
+  // OMP3_45-NOT: !nontemporal
+  // OMP3_50: load float,{{.*}}!nontemporal
   // CK3: call void @__kmpc_for_static_fini(
   // CK3: ret void
 
Index: clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
@@ -165,7 +165,7 @@
 
   // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}})
 #ifdef OMP5
-  #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a) if(simd: 1)
+  #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a) if(simd: 1) nontemporal(a)
 #else
   #pragma omp target teams distribute simd if(target: 0) safelen(32) linear(a)
 #endif // OMP5
@@ -395,6 +395,8 @@
 // CHECK:   [[AA_ADDR:%.+]] = alloca i[[SZ]], align
 // CHECK:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[AA_ADDR]], align
 // CHECK-64:[[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i32*
+// OMP45-NOT:   !nontemporal
+// OMP50:   load i32,{{.*}}!nontemporal
 // CHECK-64:store i32 10, i32* [[AA_CADDR]], align
 // CHECK-32:store i32 10, i32* [[AA_ADDR]], align
 // CHECK:   ret void
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
@@ -35,20 +35,25 @@
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 #ifdef OMP5
-#pragma omp target teams distribute parallel for simd if(simd: true)
+#pragma omp target teams distribute parallel for simd if(simd: true) nontemporal(Arg)
 #else
 #pragma omp target teams distribute parallel for simd
 #endif // OMP5
-  for(int i = 0 ; i < 100; i++) {}
+  for (int i = 0; i < 100; i++) {
+Arg = 0;
+  }
   // CHECK: define internal void [[OFFLOADING_FUN_0]](
-  // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[OMP_TEAMS_OUTLINED_0:@.+]] to {{.+}})
+  // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}}* [[OMP_TEAMS_OUTLINED_0:@.+]] to {{.+}})
   // CHECK: define{{.+}} void 

[PATCH] D70700: [WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`

2019-12-20 Thread Dan Gohman via Phabricator via cfe-commits
sunfish updated this revision to Diff 234942.
sunfish added a comment.

To support a transition to the new system, temporarily define a `__main_void` 
alias for no-argument `main`. This allows libc to detect whether it's calling 
old-style or new-style main and do the right thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70700

Files:
  clang/lib/AST/Mangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/CodeGen/wasm-call-main.c
  clang/test/CodeGen/wasm-main.c
  clang/test/CodeGen/wasm-main_argc_argv.c
  llvm/include/llvm/ADT/Triple.h

Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -730,6 +730,11 @@
 return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
   }
 
+  /// Tests whether the target is wasm (32- and 64-bit).
+  bool isWasm() const {
+return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
+  }
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !isOSBinFormatMachO();
Index: clang/test/CodeGen/wasm-main_argc_argv.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-main_argc_argv.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Mangle the argc/argv form of main.
+
+int main(int argc, char **argv) {
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @__main_argc_argv(i32 %argc, i8** %argv)
Index: clang/test/CodeGen/wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-main.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Don't mangle the no-arg form of main.
+
+int main(void) {
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @main()
Index: clang/test/CodeGen/wasm-call-main.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-call-main.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Mangle argc/argv main even when it's not defined in this TU.
+
+#include 
+
+int main(int argc, char *argv[]);
+
+int foo(void) {
+return main(0, NULL);
+}
+
+// CHECK: call i32 @__main_argc_argv(
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -435,8 +435,7 @@
 break;
 
   case llvm::Triple::UnknownOS:
-if (triple.getArch() == llvm::Triple::wasm32 ||
-triple.getArch() == llvm::Triple::wasm64)
+if (triple.isWasm())
   return;
 break;
   }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1012,6 +1012,9 @@
   /// for the uninstrumented functions.
   void EmitDeferredUnusedCoverageMappings();
 
+  /// Emit an alias for "main" if it has no arguments (needed for wasm).
+  void EmitMainVoidAlias();
+
   /// Tell the consumer that this variable has been instantiated.
   void HandleCXXStaticMemberVarInstantiation(VarDecl *VD);
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -447,6 +447,10 @@
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
+  if (Context.getTargetInfo().getTriple().isWasm() &&
+  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+EmitMainVoidAlias();
+  }
   emitLLVMUsed();
   if (SanStats)
 SanStats->finish();
@@ -5579,6 +5583,17 @@
   }
 }
 
+void CodeGenModule::EmitMainVoidAlias() {
+  // In order to transition away from "__original_main" gracefully, emit an
+  // alias for "main" in the no-argument case so that libc can detect when
+  // new-style no-argument main is in used.
+  if (llvm::Function *F = getModule().getFunction("main")) {
+if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
+F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
+  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+  }
+}
+
 /// Turns the given pointer into a constant.
 static llvm::Constant *GetPointerConstant(llvm::LLVMContext ,
   const void *Ptr) {
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -50,7 +50,8 @@
   CCM_Fast,
   CCM_RegCall,
   CCM_Vector,
-  CCM_Std
+  CCM_Std,
+  CCM_WasmMainArgcArgv
 };
 
 

[PATCH] D69272: Restricted variant of '#pragma STDC FENV_ACCESS'

2019-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D69272#1792928 , @sepavloff wrote:

> In D69272#1792877 , @kpn wrote:
>
> > My understanding of this patch is that it only allows the #pragma at the 
> > top of each function. It doesn't allow it in blocks inside the function. So 
> > if a function has a block inside it that uses strict FP the patch doesn't 
> > change the rest of the function to use constrained FP with the settings 
> > like you said. And my question was asking if there was a way forward with 
> > this patch to a full implementation.
>
>
> @hfinkel proposed to use outlining to extract a block with the #pragma to 
> separate function. It could be a basis for a full implementation.


I don't think outlining is a reasonable approach.  Outlining has a *lot* of 
other performance consequences, and we'd have to support arbitrary control flow 
(e.g. `goto`) in and out of the outlined function, which adds a lot of frontend 
complexity in pursuit of something that ought be handled at the optimizer level.

If a function has any blocks with the `#pragma`, we just need to emit the whole 
function as strictfp.  I believe the constrained FP intrinsics can take 
arguments that make them semantically equivalent to the default rule.  If we 
don't emit code outside of those blocks as efficiently as we would've before, 
well, that's seems like a solvable optimization problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69272



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


[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

LGTM! Yeah, please update the ASCII-art, it's great and every checker should 
have it.




Comment at: clang/docs/analyzer/checkers.rst:1341
+
+Fuchsia Checkers.
+

Maybe explain what `Fuchsia` is so that people don't wonder if they should turn 
it on? (:



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:344
+
+ProgramStateRef FuchsiaHandleChecker::evalAssume(ProgramStateRef State,
+ SVal Cond,

Let's add a high-level comment about what's going on here.


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

https://reviews.llvm.org/D70470



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3952
+   CGM.getOpenMPRuntime().isNontemporalDecl(Field)) ||
+  (!E->isArrow() && BaseLV.isNontemporal()))
+LV.setNontemporal(/*Value=*/true);

rjmccall wrote:
> ABataev wrote:
> > ABataev wrote:
> > > rjmccall wrote:
> > > > Is the `!E->isArrow()` condition necessary here?  Why not just 
> > > > propagate the non-temporality of the base?
> > > > 
> > > > Similarly, what's the case in which the declaration is marked 
> > > > non-temporal and you *don't* want to trust that?
> > > That's the main question. I try to mimic the behavior we currenty have in 
> > > the codegen. If the lvalue for the pointer is marked as nontemporal, only 
> > > loads/stores for the pointer itself are marked as nontemporal. Operations 
> > > with the memory it points to are not marked as nontemporal. I'm trying to 
> > > do the same. E.g., if have something like `a.b->c` and `a` is 
> > > nontemporal, then only `a.b = x;` must be marked as nontemporal, but not 
> > > `a.b->c = x;`
> > > Similarly, what's the case in which the declaration is marked 
> > > non-temporal and you *don't* want to trust that?
> > 
> > There is no such case. We can mark `this->member` as nontemporal or 
> > `declref`. The first check here checks if we have `this->member` marked as 
> > nontemporal, the second check just propagates the flag if the base is 
> > marked as nontemporal.
> Okay.  Then this should just be `(BaseLV.isNontemporal() || 
> CGM.getOpenMPRuntime().isNontemporalDecl(Field))`.
Still, `a->c` will be marked as nontemporal if `a` is nontemporal. Also, if we 
remove the check for the `CXXThis` in the condition, we can erroneously mark 
the instruction as nontemporal if we reference member of another base, which is 
nontemporal:
```
struct S;
extern S s;
struct S {
  int a, b;
  void foo() {
#pragma omp simd nontemporal(a)
for (int i = 0; i < 10; ++i)
  s.a = 0; // Will be marked as nontemporal though it should not?
  }
} s;

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added a comment.

Thanks for the review! :)


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

https://reviews.llvm.org/D70469



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


[PATCH] D71709: Give frontend dump flags consistent names (*-dump instead of dump-*)

2019-12-20 Thread David Herzka via Phabricator via cfe-commits
herzka added a comment.

I worry that repeating all those names in those tests might be noisy. I think 
I'll switch those to use the new name, but add another test that makes sure 
both names still work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71709



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


[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe17b30a7957: [attributes][analyzer] Add annotations for 
handles. (authored by xazax.hun).

Changed prior to commit:
  https://reviews.llvm.org/D70469?vs=234341=234940#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70469

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-handles.cpp

Index: clang/test/Sema/attr-handles.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-handles.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+// Decl annotations.
+void f(int *a __attribute__((acquire_handle("Fuchsia";
+void (*fp)(int handle [[clang::use_handle("Fuchsia")]]);
+auto lambda = [](int handle [[clang::use_handle("Fuchsia")]]){};
+void g(int a __attribute__((acquire_handle("Fuchsia"; // expected-error {{attribute only applies to output parameters}}
+void h(int *a __attribute__((acquire_handle))); // expected-error {{'acquire_handle' attribute takes one argument}}
+void h(int *a __attribute__((acquire_handle(1; // expected-error {{attribute requires a string}}
+void h(int *a __attribute__((acquire_handle("RandomString", "AndAnother"; // expected-error {{'acquire_handle' attribute takes one argument}}
+__attribute__((release_handle("Fuchsia"))) int i(); // expected-warning {{'release_handle' attribute only applies to parameters}}
+__attribute__((use_handle("Fuchsia"))) int j(); // expected-warning {{'use_handle' attribute only applies to parameters}}
+int a __attribute__((acquire_handle("Fuchsia"))); // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}}
+int (* __attribute__((acquire_handle("Fuchsia"))) fpt)(char *); // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}}
+
+// Type annotations.
+auto lambdat = [](int handle __attribute__((use_handle("Fuchsia"
+__attribute__((acquire_handle("Fuchsia"))) -> int { return 0; };
+int __attribute((acquire_handle("Fuchsia"))) ta; // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}}
+
+// Typedefs.
+typedef int callback(char *) __attribute__((acquire_handle("Fuchsia")));
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -9,6 +9,7 @@
 // CHECK-NEXT: AMDGPUWavesPerEU (SubjectMatchRule_function)
 // CHECK-NEXT: AVRSignal (SubjectMatchRule_function)
 // CHECK-NEXT: AbiTag (SubjectMatchRule_record_not_is_union, SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_namespace)
+// CHECK-NEXT: AcquireHandle (SubjectMatchRule_function, SubjectMatchRule_type_alias, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: Alias (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
@@ -128,6 +129,7 @@
 // CHECK-NEXT: ParamTypestate (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: Restrict (SubjectMatchRule_function)
@@ -145,6 +147,7 @@
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
+// CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)
 // CHECK-NEXT: VecTypeHint (SubjectMatchRule_function)
 // CHECK-NEXT: WarnUnused (SubjectMatchRule_record)
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7634,6 +7634,18 @@
   else if (!handleFunctionTypeAttr(state, attr, type))
 distributeFunctionTypeAttr(state, attr, type);
   break;
+case ParsedAttr::AT_AcquireHandle: {
+  if (!type->isFunctionType())
+return;
+  StringRef HandleType;
+  if (!state.getSema().checkStringLiteralArgumentAttr(attr, 0, HandleType))
+return;
+  type = 

[clang] fe17b30 - [attributes][analyzer] Add annotations for handles.

2019-12-20 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-12-20T11:47:55-08:00
New Revision: fe17b30a79572f0d50fe78f6a07d5194cbf90860

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

LOG: [attributes][analyzer] Add annotations for handles.

These annotations will be used in an upcomming static analyzer check
that finds handle leaks, use after releases, and double releases.

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

Added: 
clang/test/Sema/attr-handles.cpp

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/TypePrinter.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 286807ec779f..d9ca121b6510 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3471,3 +3471,27 @@ def NoBuiltin : Attr {
   let Subjects = SubjectList<[Function]>;
   let Documentation = [NoBuiltinDocs];
 }
+
+// FIXME: This attribute is not inheritable, it will not be propagated to
+// redecls. [[clang::lifetimebound]] has the same problems. This should be
+// fixed in TableGen (by probably adding a new inheritable flag).
+def AcquireHandle : DeclOrTypeAttr {
+  let Spellings = [Clang<"acquire_handle">];
+  let Args = [StringArgument<"HandleType">];
+  let Subjects = SubjectList<[Function, TypedefName, ParmVar]>;
+  let Documentation = [AcquireHandleDocs];
+}
+
+def UseHandle : InheritableParamAttr {
+  let Spellings = [Clang<"use_handle">];
+  let Args = [StringArgument<"HandleType">];
+  let Subjects = SubjectList<[ParmVar]>;
+  let Documentation = [UseHandleDocs];
+}
+
+def ReleaseHandle : InheritableParamAttr {
+  let Spellings = [Clang<"release_handle">];
+  let Args = [StringArgument<"HandleType">];
+  let Subjects = SubjectList<[ParmVar]>;
+  let Documentation = [ReleaseHandleDocs];
+}

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 3fa6993a5fd0..9b4afa8f128e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4696,3 +4696,64 @@ once.
   }
   }];
 }
+
+def HandleDocs : DocumentationCategory<"Handle Attributes"> {
+  let Content = [{
+Handles are a way to identify resources like files, sockets, and processes.
+They are more opaque than pointers and widely used in system programming. They
+have similar risks such as never releasing a resource associated with a handle,
+attempting to use a handle that was already released, or trying to release a
+handle twice. Using the annotations below it is possible to make the ownership
+of the handles clear: whose responsibility is to release them. They can also
+aid static analysis tools to find bugs.
+  }];
+}
+
+def AcquireHandleDocs : Documentation {
+  let Category = HandleDocs;
+  let Content = [{
+If this annotation is on a function or a function type it is assumed to return
+a new handle. In case this annotation is on an output parameter,
+the function is assumed to fill the corresponding argument with a new
+handle.
+
+.. code-block:: c++
+
+  // Output arguments from Zircon.
+  zx_status_t zx_socket_create(uint32_t options,
+   zx_handle_t __attribute__((acquire_handle)) * 
out0,
+   zx_handle_t* out1 [[clang::acquire_handle]]);
+
+
+  // Returned handle.
+  [[clang::acquire_handle]] int open(const char *path, int oflag, ... );
+  int open(const char *path, int oflag, ... ) __attribute__((acquire_handle));
+  }];
+}
+
+def UseHandleDocs : Documentation {
+  let Category = HandleDocs;
+  let Content = [{
+A function taking a handle by value might close the handle. If a function
+parameter is annotated with `use_handle` it is assumed to not to change
+the state of the handle. It is also assumed to require an open handle to work 
with.
+
+.. code-block:: c++
+
+  zx_status_t zx_port_wait(zx_handle_t handle [[clang::use_handle]],
+   zx_time_t deadline,
+   zx_port_packet_t* packet);
+  }];
+}
+
+def ReleaseHandleDocs : Documentation {
+  let Category = HandleDocs;
+  let Content = [{
+If a function parameter is annotated with `release_handle` it is assumed to
+close the handle. It is also assumed to require an open handle to work with.
+
+.. code-block:: c++
+
+  zx_status_t zx_handle_close(zx_handle_t handle [[clang::release_handle]]);
+  }];
+}

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b714cb81f0ca..1d81f69a7bd2 100644
--- 

[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D71619#1791961 , @kamleshbhalui 
wrote:

> removed c++11 from the test.
>  I do not have commit access, Can someone commit this for me?


Thank you for the patch! I've commit on your behalf in 
304d1304b7bac190b6c9733eb07be284bfc17030 



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

https://reviews.llvm.org/D71619



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


[clang] 304d130 - Apply the alignment specifier attribute to anonymous unions and structs.

2019-12-20 Thread Aaron Ballman via cfe-commits

Author: Kamlesh Kumar
Date: 2019-12-20T14:42:37-05:00
New Revision: 304d1304b7bac190b6c9733eb07be284bfc17030

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

LOG: Apply the alignment specifier attribute to anonymous unions and structs.

Added: 
clang/test/AST/pr43983.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 715e8757d43f..8f68be716bd3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5025,6 +5025,8 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, 
DeclSpec ,
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5038,6 +5040,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, 
DeclSpec ,
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);

diff  --git a/clang/test/AST/pr43983.cpp b/clang/test/AST/pr43983.cpp
new file mode 100644
index ..0f4f596361aa
--- /dev/null
+++ b/clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64



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


[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-20 Thread Philip Reames via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14fc20ca6282: Align branches within 32-Byte boundary (NOP 
padding) (authored by reames).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70157

Files:
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCAssembler.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-64-1a.s
  llvm/test/MC/X86/align-branch-64-1b.s
  llvm/test/MC/X86/align-branch-64-1c.s
  llvm/test/MC/X86/align-branch-64-1d.s
  llvm/test/MC/X86/align-branch-64-2a.s
  llvm/test/MC/X86/align-branch-64-2b.s
  llvm/test/MC/X86/align-branch-64-2c.s
  llvm/test/MC/X86/align-branch-64-3a.s
  llvm/test/MC/X86/align-branch-64-4a.s
  llvm/test/MC/X86/align-branch-64-5a.s
  llvm/test/MC/X86/align-branch-64-5b.s

Index: llvm/test/MC/X86/align-branch-64-5b.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5b.s
@@ -0,0 +1,50 @@
+# Check option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret can cowork with option --mc-relax-all
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret --mc-relax-all %s | llvm-objdump -d  - > %t1
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:8: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   10: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   18: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   1b: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   1d: 90   nop
+# CHECK-NEXT:   1e: 90   nop
+# CHECK-NEXT:   1f: 90   nop
+# CHECK-NEXT:   20: 0f 85 f5 ff ff ffjne {{.*}}
+# CHECK-NEXT:   26: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   2e: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   36: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   39: 0f 85 e7 ff ff ffjne {{.*}}
+# CHECK-NEXT:   3f: 90   nop
+# CHECK-NEXT:   40: e9 d6 ff ff ff   jmp {{.*}}
+# CHECK-NEXT:   45: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   4d: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   55: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT:   5d: 90   nop
+# CHECK-NEXT:   5e: 90   nop
+# CHECK-NEXT:   5f: 90   nop
+# CHECK-NEXT:   60: e8 9b ff ff ff   callq   {{.*}}
+# CHECK-NEXT:   65: e9 bc ff ff ff   jmp {{.*}}
+.text
+.p2align 4
+foo:
+  .rept 3
+  movl  %eax, %fs:0x1
+  .endr
+  shrl  $2, %ecx
+.L1:
+  movl  %edx, %ecx
+  jne   .L1
+.L2:
+  .rept 2
+  movl  %eax, %fs:0x1
+  .endr
+  testb $2, %dl
+  jne   .L2
+  jmp   .L1
+  .rept 3
+  movl  %eax, %fs:0x1
+  .endr
+  call  foo
+  jmp   .L2
Index: llvm/test/MC/X86/align-branch-64-5a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5a.s
@@ -0,0 +1,43 @@
+# Check no nop is inserted if no branch cross or is against the boundary
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret  %s | llvm-objdump -d  - > %t1
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t2
+# RUN: cmp %t1 %t2
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-COUNT-3:  : 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK:18: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   1b: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   1d: 75 fcjne {{.*}}
+# CHECK-NEXT:   1f: 55   pushq   %rbp
+# CHECK-NEXT:   20: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   23: 75 fajne {{.*}}
+# CHECK-COUNT-2:  : 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK:35: c1 e9 02 shrl   

[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

2019-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D65591#1791876 , @rsmith wrote:

> Summary of an off-line discussion with Ilya:




I think that summary sounds very sensible. Thank you both for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591



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


[PATCH] D71680: Customize simplified dumping and matching of LambdaExpr

2019-12-20 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 aside from some nits.




Comment at: clang/include/clang/AST/ASTNodeTraverser.h:134
+
+  if (isa(S) && Traversal == 
ast_type_traits::TK_IgnoreUnlessSpelledInSource)
 return;

This seems like it may be over the 80 col limit?



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:662
+  dumpTemplateParameters(Node->getTemplateParameterList());
+  auto CallOp = Node->getCallOperator();
+  for (auto *P : CallOp->parameters())

`const CXXMethodDecl *`, or just sink it into the range-based for loop since we 
don't really need the local anyway.



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:663
+  auto CallOp = Node->getCallOperator();
+  for (auto *P : CallOp->parameters())
+Visit(P);

`const auto *`



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:219
+return false;
+  } else if (!match(*Node->capture_init_begin()[I])) {
+return false;

You can elide the braces, also you can remove the `else` after a `return`.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:223-224
+}
+auto *TPL = Node->getTemplateParameterList();
+if (TPL) {
+  for (const auto *TP : *TPL) {

```
if (const TemplateParameterList *TPL = Node->getTemplateParameterList()) {
  ...
}
```



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:226
+  for (const auto *TP : *TPL) {
+if (!match(*TP)) {
+  return false;

Elide braces



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:232
+
+auto CallOp = Node->getCallOperator();
+for (auto *P : CallOp->parameters()) {

`const CXXMethodDecl *`



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:234
+for (auto *P : CallOp->parameters()) {
+  if (!match(*P)) {
+return false;

Elide braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71680



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


[clang] 03512b2 - [NFC][Driver] Add dummy compiler-rt sanitizer dylibs for Darwin.

2019-12-20 Thread Dan Liew via cfe-commits

Author: Dan Liew
Date: 2019-12-20T11:32:21-08:00
New Revision: 03512b267d9abd054d56c6d5fa118e78184cf015

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

LOG: [NFC][Driver] Add dummy compiler-rt sanitizer dylibs for Darwin.

This adds dummy files to the test resource directory used by the Clang
driver tests.

rdar://problem/58118584

Added: 

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_ios_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_osx_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_watchos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_watchossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_ios_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_iossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_tvos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_tvossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_watchos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_watchossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.tsan_iossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.tsan_tvossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_ios_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_iossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_ios_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_iossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_tvos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_tvossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_watchos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_minimal_watchossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_tvos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_tvossim_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_watchos_dynamic.dylib

clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.ubsan_watchossim_dynamic.dylib

Modified: 


Removed: 




diff  --git 
a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_ios_dynamic.dylib
 
b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_ios_dynamic.dylib
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
 
b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
 
b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvos_dynamic.dylib
 
b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvos_dynamic.dylib
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvossim_dynamic.dylib
 
b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvossim_dynamic.dylib
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_watchos_dynamic.dylib
 
b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_watchos_dynamic.dylib
new file mode 100644
index ..e69de29bb2d1

diff  

[PATCH] D71746: Fix the "TypeError: a bytes-like object is required, not 'str'" in exploded-graph-rewriter.py on Python 3.5+

2019-12-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ edited reviewers, added: NoQ; removed: dergachev.a.
NoQ added a comment.

Yay, thanks! It does seem to work on python2 after the fix.

Do you have commit access or should i commit it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71746



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


[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-20 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 with the nits fixed, thank you!




Comment at: clang/include/clang/Basic/Attr.td:3475
+
+def AcquireHandle : DeclOrTypeAttr {
+  let Spellings = [Clang<"acquire_handle">];

aaron.ballman wrote:
> I have no idea whether this is a problem or not (and I'm not certain if you 
> know either) -- how bad is it that this is `DeclOrTypeAttr` in the case where 
> it's an inherited parameter with the attribute? The other attributes use 
> `InheritableParamAttr`, but the only thing they apply to is a parameter so 
> that's easy. I don't know what should be done in this case, or if it's an 
> issue.
> 
> I think a test case for this scenario would be:
> ```
> void func([[clang::acquires_handle("foo") int *a);
> 
> void func(int *a) {
>   // a should be marked as acquires_handle in the AST should you do an AST 
> dump
> }
> ```
I verified that this is an issue, but it's not a new one. 
`[[clang::lifetimebound]]` has the same issue. You should add a FIXME comment 
here and a test case with a FIXME comment so we don't lose track of this, but 
it doesn't seem critical to fix right now.


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

https://reviews.llvm.org/D70469



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


[PATCH] D71666: [clang-tidy] Fix readability-const-return-type identifying the wrong `const` token

2019-12-20 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 with a commenting request.




Comment at: clang-tools-extra/clang-tidy/utils/LexerUtils.h:95-97
+/// Assuming that ``Range`` spans a CVR-qualified type, returns the
+/// token in ``Range`` that is responsible for the qualification. ``Range``
+/// must be valid with respect to ``SM``.  Returns ``None`` if no qualifying

Should we add a comment that this is not for getting a member function 
qualifier? (I am assuming that case was never intended to work, but if it does 
work, should we also support ref qualifiers in that case?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71666



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


[PATCH] D71612: [analyzer] Add PlacementNewChecker

2019-12-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:32
+  const MemRegion *BaseRegion = MRegion->getBaseRegion();
+  assert(BaseRegion == Offset.getRegion());
+

martong wrote:
> This assertion fails on real code quite often (e.g. on LLVM/Clang code). I 
> don't really understand why. @NoQ what is you understanding on this? Perhaps 
> I could try to reduce a case from the real code to see an example.
`RegionOffset` cannot really represent symbolic offsets :( You should be able 
to re-add the assertion after checking for symbolic offsets.

And, yeah, you can always easily reduce any crash with `creduce`.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:22
+ProgramStateRef State) const;
+  mutable std::unique_ptr BT_Placement;
+};

martong wrote:
> xazax.hun wrote:
> > I think now it is safe to have the bugtype by value and use member 
> > initialization.
> Ok, I've made it to be a simple member. Also could remove the `mutable` 
> specifier.
And use a default initializer instead of constructor >.>
`BuiltinBug BT_Placement{this, "Insufficient storage BB"}`

(also i don't understand `BuiltinBug` and i'm afraid of using it, can we just 
have `BugType` with explicit description and category?)



Comment at: clang/test/Analysis/placement-new.cpp:11
+void f() {
+  short s; // expected-note-re {{'s' declared{{.*
+  long *lp = ::new () long; // expected-warning{{Argument of default 
placement new provides storage capacity of 2 bytes, but the allocated type 
requires storage capacity of 8 bytes}} expected-note 3 {{}}

martong wrote:
> NoQ wrote:
> > I'm legit curious what's hidden behind the regex.
> Ok, I removed the regexes.
> But keep in mind that, this note is coming from `trackExpressionValue` and is 
> changing if the initializer of `s` is changing.
> I did not want to formulate expectations on a note that is coming from an 
> implementation detail and can change easily. Also, If `trackExpressionValue` 
> changes than we need to rewrite all these tests, unless a regex is used, 
> perhaps just a simple expected-note {{}} would be the best from this point of 
> view.
Because it's up to the checker whether to use `trackExpressionValue` or provide 
its own visitor, i'd rather keep the notes tested. If the notes provided by 
`trackExpressionValue` aren't good enough, it's ultimately the checker's 
problem (which may or may not be fixed by improving `trackExpressionValue`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71612



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3952
+   CGM.getOpenMPRuntime().isNontemporalDecl(Field)) ||
+  (!E->isArrow() && BaseLV.isNontemporal()))
+LV.setNontemporal(/*Value=*/true);

ABataev wrote:
> ABataev wrote:
> > rjmccall wrote:
> > > Is the `!E->isArrow()` condition necessary here?  Why not just propagate 
> > > the non-temporality of the base?
> > > 
> > > Similarly, what's the case in which the declaration is marked 
> > > non-temporal and you *don't* want to trust that?
> > That's the main question. I try to mimic the behavior we currenty have in 
> > the codegen. If the lvalue for the pointer is marked as nontemporal, only 
> > loads/stores for the pointer itself are marked as nontemporal. Operations 
> > with the memory it points to are not marked as nontemporal. I'm trying to 
> > do the same. E.g., if have something like `a.b->c` and `a` is nontemporal, 
> > then only `a.b = x;` must be marked as nontemporal, but not `a.b->c = x;`
> > Similarly, what's the case in which the declaration is marked non-temporal 
> > and you *don't* want to trust that?
> 
> There is no such case. We can mark `this->member` as nontemporal or 
> `declref`. The first check here checks if we have `this->member` marked as 
> nontemporal, the second check just propagates the flag if the base is marked 
> as nontemporal.
Okay.  Then this should just be `(BaseLV.isNontemporal() || 
CGM.getOpenMPRuntime().isNontemporalDecl(Field))`.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:11349
+  NontemporalDeclsSet  =
+  CGM.getOpenMPRuntime().NontemporalDeclsStack.emplace_back();
+  // No need to check for nontemporal clauses in non-simd directives.

ABataev wrote:
> rjmccall wrote:
> > This is effectively clearing the active non-temporal decls set.  Is that 
> > okay (even for the non-SIMD directives?), or should the current set be 
> > copied?
> Yes, it must be copied, thanks.
Okay.  I see that you're now scanning the whole list, which is probably better 
than copying, but could you leave a comment here saying that that's how it 
works?

I'd also suggest only pushing something onto the stack if you actually have any 
non-temporal clauses; it should be easy enough to remember in the RAII object 
whether you pushed.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:663
+  using NontemporalDeclsSet = llvm::SmallDenseSet>;
+  /// Stack for list of declaration in current context marked as nontemporal.
+  llvm::SmallVector NontemporalDeclsStack;

Please add to this comment that the real set is the union of all the current 
stack elements, not just the innermost set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[PATCH] D71694: [objc_direct] Tigthen checks for direct methods

2019-12-20 Thread Pierre Habouzit via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42f9d0c0bee3: [objc_direct] Tigthen checks for direct 
methods (authored by MadCoder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/direct-method.m
  clang/test/SemaObjC/method-direct-one-definition.m

Index: clang/test/SemaObjC/method-direct-one-definition.m
===
--- /dev/null
+++ clang/test/SemaObjC/method-direct-one-definition.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-protocol-method-implementation %s
+
+__attribute__((objc_root_class))
+@interface A
+@end
+
+@interface A (Cat)
+- (void)A_Cat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation A
+- (void)A_Cat { // expected-error {{direct method was declared in a category but is implemented in the primary interface}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface B
+- (void)B_primary __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B ()
+- (void)B_extension __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@interface B (Cat)
+- (void)B_Cat __attribute__((objc_direct));
+@end
+
+@interface B (OtherCat)
+- (void)B_OtherCat __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+@end
+
+@implementation B (Cat)
+- (void)B_primary { // expected-error {{direct method was declared in the primary interface but is implemented in a category}}
+}
+- (void)B_extension { // expected-error {{direct method was declared in an extension but is implemented in a different category}}
+}
+- (void)B_Cat {
+}
+- (void)B_OtherCat { // expected-error {{direct method was declared in a category but is implemented in a different category}}
+}
+@end
+
+__attribute__((objc_root_class))
+@interface C
+- (void)C1 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
+- (void)C2;  // expected-note {{previous declaration is here}}
+@end
+
+@interface C (Cat)
+- (void)C1;  // expected-error {{method declaration conflicts with previous direct declaration of method 'C1'}}
+- (void)C2 __attribute__((objc_direct)); // expected-error {{direct method declaration conflicts with previous declaration of method 'C2'}}
+@end
Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -172,10 +172,19 @@
 @interface Foo ()
 @property(nonatomic, readwrite) int getDirect_setDynamic;
 @property(nonatomic, readwrite, direct) int getDynamic_setDirect;
+- (int)directMethodInExtension __attribute__((objc_direct));
+@end
+
+@interface Foo (Cat)
+- (int)directMethodInCategory __attribute__((objc_direct));
 @end
 
 __attribute__((objc_direct_members))
 @implementation Foo
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]"(
+- (int)directMethodInExtension {
+  return 42;
+}
 // CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]"(
 // CHECK-LABEL: define internal void @"\01-[Foo setGetDirect_setDynamic:]"(
 // CHECK-LABEL: define internal i32 @"\01-[Foo getDynamic_setDirect]"(
@@ -183,6 +192,17 @@
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
 
+@implementation Foo (Cat)
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategory]"(
+- (int)directMethodInCategory {
+  return 42;
+}
+// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategoryNoDecl]"(
+- (int)directMethodInCategoryNoDecl __attribute__((objc_direct)) {
+  return 42;
+}
+@end
+
 int useRoot(Root *r) {
   // CHECK-LABEL: define i32 @useRoot
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Root getInt]"
@@ -195,8 +215,14 @@
   // CHECK-LABEL: define i32 @useFoo
   // CHECK: call void bitcast {{.*}} @"\01-[Foo setGetDynamic_setDirect:]"
   // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo getDirect_setDynamic]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo directMethodInExtension]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo directMethodInCategory]"
+  // CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Foo directMethodInCategoryNoDecl]"
   [f setGetDynamic_setDirect:1];
-  return [f getDirect_setDynamic];
+  return [f getDirect_setDynamic] +
+ [f directMethodInExtension] +
+ [f directMethodInCategory] +
+ [f directMethodInCategoryNoDecl];
 }
 
 __attribute__((objc_root_class))
Index: clang/lib/Sema/SemaDeclObjC.cpp

[PATCH] D71778: [RISCV] Add Clang Builtins for Accessing CSRs

2019-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary created this revision.
lenary added reviewers: asb, luismarques.
Herald added subscribers: llvm-commits, cfe-commits, apazos, sameer.abuasal, 
pzheng, s.egerton, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
Herald added projects: clang, LLVM.

As of clang 9.0, the only way to access the RISC-V Control and Status Registers
is to use inline assembly, which is ugly and hinders optimisations.

This patch adds some Clang Builtins and LLVM Intrinsics to allow programmers
to access the CSRs without using inline assembly, which should therefore be
safer.

I hope to build a slightly nicer interface to this, to support the read-only or
write-only CSR operations (akin to the `csrr`, `csrw`, `csrs` and `csrc`
pseudo-instructions) via these builtins, which will eventually be available via
``.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71778

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/riscv-csr-builtins.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp
  llvm/test/CodeGen/RISCV/intrinsics/csr_accesses_rv32.ll
  llvm/test/CodeGen/RISCV/intrinsics/csr_accesses_rv64.ll

Index: llvm/test/CodeGen/RISCV/intrinsics/csr_accesses_rv64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/intrinsics/csr_accesses_rv64.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
+; RUN:   | FileCheck -check-prefix=RV64I %s
+
+declare i64 @llvm.riscv.csr.read.write.i64(i64, i64)
+declare i64 @llvm.riscv.csr.read.set.i64(i64, i64)
+declare i64 @llvm.riscv.csr.read.clear.i64(i64, i64)
+
+define i64 @test_csr_read_ustatus(i64 %a) nounwind {
+; RV64I-LABEL: test_csr_read_ustatus:
+; RV64I:   # %bb.0:
+; RV64I-NEXT:csrrw a0, ustatus, a0
+; RV64I-NEXT:ret
+  %1 = call i64 @llvm.riscv.csr.read.write.i64(i64 0, i64 %a)
+  ret i64 %1
+}
+
+define i64 @test_csr_set_ustatus(i64 %a) nounwind {
+; RV64I-LABEL: test_csr_set_ustatus:
+; RV64I:   # %bb.0:
+; RV64I-NEXT:csrrs a0, ustatus, a0
+; RV64I-NEXT:ret
+  %1 = call i64 @llvm.riscv.csr.read.set.i64(i64 0, i64 %a)
+  ret i64 %1
+}
+
+define i64 @test_csr_clear_ustatus(i64 %a) nounwind {
+; RV64I-LABEL: test_csr_clear_ustatus:
+; RV64I:   # %bb.0:
+; RV64I-NEXT:csrrc a0, ustatus, a0
+; RV64I-NEXT:ret
+  %1 = call i64 @llvm.riscv.csr.read.clear.i64(i64 0, i64 %a)
+  ret i64 %1
+}
Index: llvm/test/CodeGen/RISCV/intrinsics/csr_accesses_rv32.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/intrinsics/csr_accesses_rv32.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
+; RUN:   | FileCheck -check-prefix=RV32I %s
+
+declare i32 @llvm.riscv.csr.read.write.i32(i32, i32)
+declare i32 @llvm.riscv.csr.read.set.i32(i32, i32)
+declare i32 @llvm.riscv.csr.read.clear.i32(i32, i32)
+
+define i32 @test_csr_read_ustatus(i32 %a) nounwind {
+; RV32I-LABEL: test_csr_read_ustatus:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:csrrw a0, ustatus, a0
+; RV32I-NEXT:ret
+  %1 = call i32 @llvm.riscv.csr.read.write.i32(i32 0, i32 %a)
+  ret i32 %1
+}
+
+define i32 @test_csr_set_ustatus(i32 %a) nounwind {
+; RV32I-LABEL: test_csr_set_ustatus:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:csrrs a0, ustatus, a0
+; RV32I-NEXT:ret
+  %1 = call i32 @llvm.riscv.csr.read.set.i32(i32 0, i32 %a)
+  ret i32 %1
+}
+
+define i32 @test_csr_clear_ustatus(i32 %a) nounwind {
+; RV32I-LABEL: test_csr_clear_ustatus:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:csrrc a0, ustatus, a0
+; RV32I-NEXT:ret
+  %1 = call i32 @llvm.riscv.csr.read.clear.i32(i32 0, i32 %a)
+  ret i32 %1
+}
Index: llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp
===
--- llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp
+++ llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp
@@ -16,6 +16,7 @@
 #include "RISCVTargetMachine.h"
 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
 #include "llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h"
+#include "llvm/IR/IntrinsicsRISCV.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "riscv-isel"
Index: llvm/lib/Target/RISCV/RISCVInstrInfo.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -1087,6 

[clang] 42f9d0c - [objc_direct] Tigthen checks for direct methods

2019-12-20 Thread Pierre Habouzit via cfe-commits

Author: Pierre Habouzit
Date: 2019-12-20T10:57:36-08:00
New Revision: 42f9d0c0bee32a1a48a45c039988d27115f30da9

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

LOG: [objc_direct] Tigthen checks for direct methods

Because the name of a direct method must be agreed upon by the caller
and the implementation, certain bad practices that one can get away with
when using dynamism are fatal with direct methods.

To avoid really weird and unscruttable linker error, tighten the
front-end error reporting.

Rule 1:
  Direct methods can only have at most one declaration in an @interface
  container. Any redeclaration is strictly forbidden.

  Today some amount of redeclaration is tolerated between the main
  interface and categories for dynamic methods, but we can't have that.

Rule 2:
  Direct method implementations can only be declared in a matching
  @interface container: when implemented in the primary @implementation
  then the declaration must be in the primary @interface or an
  extension, and when implemented in a category, the declaration must be
  in the @interface for the same category.

Also fix another issue with ObjCMethod::getCanonicalDecl(): when an
implementation lives in the primary @interface, then its canonical
declaration can be in any extension, even when it's not an accessor.

Add Sema tests to cover the new errors, and CG tests to beef up testing
around function names for categories and extensions.

Radar-Id: 

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

Added: 
clang/test/SemaObjC/method-direct-one-definition.m

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/DeclObjC.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/test/CodeGenObjC/direct-method.m

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 315e836cd397..b714cb81f0ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -995,6 +995,12 @@ def warn_objc_boxing_invalid_utf8_string : Warning<
 def err_objc_direct_on_protocol : Error<
   "'objc_direct' attribute cannot be applied to %select{methods|properties}0 "
   "declared in an Objective-C protocol">;
+def err_objc_direct_duplicate_decl : Error<
+  "%select{|direct }0method declaration conflicts "
+  "with previous %select{|direct }1declaration of method %2">;
+def err_objc_direct_impl_decl_mismatch : Error<
+  "direct method was declared in %select{the primary interface|an extension|a 
category}0 "
+  "but is implemented in %select{the primary interface|a category|a 
diff erent category}1">;
 def err_objc_direct_missing_on_decl : Error<
   "direct method implementation was previously declared not direct">;
 def err_objc_direct_on_override : Error<

diff  --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index ca70afd9db25..9a84e3c4a510 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -956,32 +956,32 @@ ObjCMethodDecl 
*ObjCMethodDecl::getNextRedeclarationImpl() {
 
 ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
   auto *CtxD = cast(getDeclContext());
+  const auto  = getSelector();
 
   if (auto *ImplD = dyn_cast(CtxD)) {
 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) {
-  if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
-  isInstanceMethod()))
+  // When the container is the ObjCImplementationDecl (the primary
+  // @implementation), then the canonical Decl is either in
+  // the class Interface, or in any of its extension.
+  //
+  // So when we don't find it in the ObjCInterfaceDecl,
+  // sift through extensions too.
+  if (ObjCMethodDecl *MD = IFD->getMethod(Sel, isInstanceMethod()))
 return MD;
-  // readwrite properties may have been re-declared in an extension.
-  // look harder.
-  if (isPropertyAccessor())
-for (auto *Ext : IFD->known_extensions())
-  if (ObjCMethodDecl *MD =
-  Ext->getMethod(getSelector(), isInstanceMethod()))
-return MD;
+  for (auto *Ext : IFD->known_extensions())
+if (ObjCMethodDecl *MD = Ext->getMethod(Sel, isInstanceMethod()))
+  return MD;
 }
   } else if (auto *CImplD = dyn_cast(CtxD)) {
 if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
-  if (ObjCMethodDecl *MD = CatD->getMethod(getSelector(),
-   isInstanceMethod()))
+  if (ObjCMethodDecl *MD = CatD->getMethod(Sel, isInstanceMethod()))
 return MD;
   }
 
   if (isRedeclaration()) {
 // It is possible that we have not done deserializing the 

[PATCH] D69876: Allow output constraints on "asm goto"

2019-12-20 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/CodeGen/asm-goto.c:91
+  return 1;
+}

Thanks for adding this test.  I think it doesn't test that `addr` is 
*clobbered* though?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69876



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


[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3475
+
+def AcquireHandle : DeclOrTypeAttr {
+  let Spellings = [Clang<"acquire_handle">];

I have no idea whether this is a problem or not (and I'm not certain if you 
know either) -- how bad is it that this is `DeclOrTypeAttr` in the case where 
it's an inherited parameter with the attribute? The other attributes use 
`InheritableParamAttr`, but the only thing they apply to is a parameter so 
that's easy. I don't know what should be done in this case, or if it's an issue.

I think a test case for this scenario would be:
```
void func([[clang::acquires_handle("foo") int *a);

void func(int *a) {
  // a should be marked as acquires_handle in the AST should you do an AST dump
}
```



Comment at: clang/lib/Sema/SemaType.cpp:7618
+case ParsedAttr::AT_AcquireHandle: {
+  if (!type->isFunctionType())
+return;

Can you be sure to add a test where the attribute is written in the type 
position for a non-function type to ensure you get a reasonable diagnostic?

e.g.,  `int [[clang::acquire_handle("")]] a;`


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

https://reviews.llvm.org/D70469



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61055 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D70973: [OPENMP50]Treat context selectors as expressions, not just strings.

2019-12-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I haven't forgotten about this! With the other two changes to the declare 
variant going to happen now,as well, I figured we should look at this again 
from a high-level.

My plan now is:

1. Move all of the declare variant context stuff out of clang into the 
libFrontendOpenMP. This has various benefits, including reuse capabilities and 
the problem of where to put it (which was discussed briefly in my other declare 
variant patches), is gone.
2. Set it up to accept *constant* strings and non-string alike from the 
beginning. I'll also make it completely OMPKinds.def based with all the trait 
sets and selectors at least parsed properly. Rules what can be nested together, 
what can have a score, etc. are all reusable and mostly generated.
3. Introduce the declare variant begin/end stuff to get math support before the 
10 fork.
4. Make all declare variant decisions in SemaOverload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70973



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


[PATCH] D71221: [HIP] Add option --gpu-max-threads-per-block=n

2019-12-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8067
+unsigned MaxThreadsPerBlock =
+IsHIPKernel ? M.getLangOpts().GPUMaxThreadsPerBlock : 256;
+std::string AttrVal = std::string("1,") + llvm::utostr(MaxThreadsPerBlock);

yaxunl wrote:
> tra wrote:
> > The magic value of 256 should be defined as a constant or macro somewhere 
> > -- you're using it in multiple places.
> > Alternatively, always set LangOpts.GPUMaxThreadsPerBlock to something and 
> > skip figuring out the default everywhere else.
> For the default value of LangOpts.GPUMaxThreadsPerBlock, it tends to be 
> target dependent. I am thinking probably should add 
> TargetInfo.getDefaultMaxThreadsPerBlock() and use it to set the default value 
> for LangOpts.GPUMaxThreadsPerBlock.
That could be an option. I just want to have an unambiguous source for that 
number.
BTW, does the value need to be hardcoded for OpenCL?

I think it would make sense for --gpu-max-threads-per-block=n to control the 
value for OpenCL, too.
Then you would always get the value from LangOpts.GPUMaxThreadsPerBlock  and 
will have only one place where you set the default, which would be OK until we 
make the default target-specific.


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

https://reviews.llvm.org/D71221



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-20 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 234921.
arichardson added a comment.

- Add documentation for the new alignment builtins


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/Sema/builtin-align.c
  clang/test/SemaCXX/builtin-align-cxx.cpp

Index: clang/test/SemaCXX/builtin-align-cxx.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-align-cxx.cpp
@@ -0,0 +1,236 @@
+// C++-specific checks for the alignment builtins
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -std=c++11 -o - %s -fsyntax-only -verify
+
+// Check that we don't crash when using dependent types in __builtin_align:
+template 
+void *c(void *d) { // expected-note{{candidate template ignored}}
+  return __builtin_align_down(d, b);
+}
+
+struct x {};
+x foo;
+void test(void *value) {
+  c(value);
+  c(value); // expected-error{{no matching function for call to 'c'}}
+}
+
+template 
+void test_templated_arguments() {
+  T array[ArraySize];   // expected-error{{variable has incomplete type 'fwddecl'}}
+  static_assert(__is_same(decltype(__builtin_align_up(array, Alignment)), T *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, Alignment)), T *),
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, Alignment)), bool),
+"return type should be bool");
+  T *x1 = __builtin_align_up(array, Alignment);
+  T *x2 = __builtin_align_down(array, Alignment);
+  bool x3 = __builtin_align_up(array, Alignment);
+}
+
+void test() {
+  test_templated_arguments(); // fine
+  test_templated_arguments();
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+  // expected-note@-2{{forward declaration of 'fwddecl'}}
+  test_templated_arguments(); // invalid alignment value
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+}
+
+template 
+void test_incorrect_alignment_without_instatiation(T value) {
+  int array[32];
+  static_assert(__is_same(decltype(__builtin_align_up(array, 31)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, 7)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, -1)), bool), // expected-error{{requested alignment must be 1 or greater}}
+"return type should be bool");
+  __builtin_align_up(array);   // expected-error{{too few arguments to function call, expected 2, have 1}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_down(array, 31); // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(value, 31);   // This shouldn't want since the type is dependent
+  __builtin_align_up(value);   // Same here
+}
+
+// The original fix for the issue above broke some legitimate code.
+// Here is a regression test:
+typedef __SIZE_TYPE__ size_t;
+void *allocate_impl(size_t size);
+template 
+T *allocate() {
+  constexpr size_t allocation_size =
+  __builtin_align_up(sizeof(T), sizeof(void *));
+  return static_cast(
+  __builtin_assume_aligned(allocate_impl(allocation_size), sizeof(void *)));
+}
+struct Foo {
+  int value;
+};
+void *test2() {
+  return allocate();
+}
+
+// Check that pointers-to-members cannot be used
+class MemPtr {
+public:
+  int data;
+  void func();
+  virtual void vfunc();
+};
+void test_member_ptr() {
+  __builtin_align_up(::data, 64);// expected-error{{operand of type 'int MemPtr::*' where arithmetic or pointer type is required}}
+  __builtin_align_down(::func, 64);  // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer type is required}}
+  __builtin_is_aligned(::vfunc, 64); // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer type is required}}
+}
+
+void test_references(Foo ) {
+  // 

[PATCH] D36051: [clang-tidy] List the checkers with autofix

2019-12-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:291
+
+.. csv-table:: Alias..
+   :header: "Name", "Redirect", "Offers fixes", "Severity"

Aliases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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


[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2019-12-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61057 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775



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


[PATCH] D36051: [clang-tidy] List the checkers with autofix

2019-12-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 234918.
sylvestre.ledru added a comment.

Fix a rst warning + update the clang link "Clang Static Analyzer"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051

Files:
  clang-tools-extra/docs/clang-tidy/checks/list.rst

Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -3,388 +3,408 @@
 Clang-Tidy Checks
 =
 
+.. Severities are coming from Codechecker:
+   https://github.com/Ericsson/codechecker/blob/master/config/checker_severity_map.json
+   If you change it here, please submit a PR on codechecker too
+
+.. csv-table::
+   :header: "Name", "Offers fixes", "Severity"
+   :widths: 50, 20, 10
+
+   `abseil-duration-addition `_, "Yes", ""
+   `abseil-duration-comparison `_, "Yes", ""
+   `abseil-duration-conversion-cast `_, "Yes", ""
+   `abseil-duration-division `_, "Yes", ""
+   `abseil-duration-factory-float `_, "Yes", ""
+   `abseil-duration-factory-scale `_, "Yes", ""
+   `abseil-duration-subtraction `_, "Yes", ""
+   `abseil-duration-unnecessary-conversion `_, "Yes", ""
+   `abseil-faster-strsplit-delimiter `_, "Yes", ""
+   `abseil-no-internal-dependencies `_, , ""
+   `abseil-no-namespace `_, , ""
+   `abseil-redundant-strcat-calls `_, "Yes", ""
+   `abseil-str-cat-append `_, "Yes", ""
+   `abseil-string-find-startswith `_, "Yes", "style"
+   `abseil-time-comparison `_, "Yes", ""
+   `abseil-time-subtraction `_, "Yes", ""
+   `abseil-upgrade-duration-conversions `_, "Yes", ""
+   `android-cloexec-accept `_, "Yes", ""
+   `android-cloexec-accept4 `_, , ""
+   `android-cloexec-creat `_, , "medium"
+   `android-cloexec-dup `_, , ""
+   `android-cloexec-epoll-create `_, , ""
+   `android-cloexec-epoll-create1 `_, , ""
+   `android-cloexec-fopen `_, , "medium"
+   `android-cloexec-inotify-init `_, , ""
+   `android-cloexec-inotify-init1 `_, , ""
+   `android-cloexec-memfd-create `_, , ""
+   `android-cloexec-open `_, , "medium"
+   `android-cloexec-pipe `_, , ""
+   `android-cloexec-pipe2 `_, , ""
+   `android-cloexec-socket `_, , "medium"
+   `android-comparison-in-temp-failure-retry `_, "Yes", ""
+   `boost-use-to-string `_, "Yes", "low"
+   `bugprone-argument-comment `_, "Yes", "low"
+   `bugprone-assert-side-effect `_, , "medium"
+   `bugprone-bad-signal-to-kill-thread `_, , ""
+   `bugprone-bool-pointer-implicit-conversion `_, "Yes", "low"
+   `bugprone-branch-clone `_, , "low"
+   `bugprone-copy-constructor-init `_, "Yes", "medium"
+   `bugprone-dangling-handle `_, , "high"
+   `bugprone-dynamic-static-initializers `_, , ""
+   `bugprone-exception-escape `_, , "medium"
+   `bugprone-fold-init-type `_, , "high"
+   `bugprone-forward-declaration-namespace `_, , "low"
+   `bugprone-forwarding-reference-overload `_, , "low"
+   `bugprone-inaccurate-erase `_, "Yes", "high"
+   `bugprone-incorrect-roundings `_, , "high"
+   `bugprone-infinite-loop `_, , "medium"
+   `bugprone-integer-division `_, , "medium"
+   `bugprone-lambda-function-name `_, , "low"
+   `bugprone-macro-parentheses `_, "Yes", "medium"
+   `bugprone-macro-repeated-side-effects `_, , "medium"
+   `bugprone-misplaced-operator-in-strlen-in-alloc `_, , "medium"
+   `bugprone-misplaced-widening-cast `_, "Yes", "high"
+   `bugprone-move-forwarding-reference `_, "Yes", "medium"
+   `bugprone-multiple-statement-macro `_, , "medium"
+   `bugprone-not-null-terminated-result `_, "Yes", "medium"
+   `bugprone-parent-virtual-call `_, "Yes", "medium"
+   `bugprone-posix-return `_, "Yes", ""
+   `bugprone-sizeof-container `_, , "high"
+   `bugprone-sizeof-expression `_, , "high"
+   `bugprone-string-constructor `_, "Yes", "high"
+   `bugprone-string-integer-assignment `_, "Yes", "low"
+   `bugprone-string-literal-with-embedded-nul `_, , "medium"
+   `bugprone-suspicious-enum-usage `_, , "high"
+   `bugprone-suspicious-memset-usage `_, "Yes", "high"
+   `bugprone-suspicious-missing-comma `_, , "high"
+   `bugprone-suspicious-semicolon `_, "Yes", "high"
+   `bugprone-suspicious-string-compare `_, "Yes", "medium"
+   `bugprone-swapped-arguments `_, "Yes", "high"
+   `bugprone-terminating-continue `_, "Yes", "medium"
+   `bugprone-throw-keyword-missing `_, , "medium"
+   `bugprone-too-small-loop-variable `_, , "medium"
+   `bugprone-undefined-memory-manipulation `_, , "medium"
+   `bugprone-undelegated-constructor `_, , "medium"
+   `bugprone-unhandled-self-assignment `_, , "medium"
+   `bugprone-unused-raii `_, "Yes", "high"
+   `bugprone-unused-return-value `_, , "medium"
+   `bugprone-use-after-move `_, , "high"
+   `bugprone-virtual-near-miss `_, "Yes", "medium"
+   `cert-dcl21-cpp `_, , "low"
+   `cert-dcl50-cpp `_, , "low"
+   `cert-dcl58-cpp `_, , "high"
+   `cert-env33-c `_, , "medium"
+   `cert-err34-c `_, , "low"
+ 

[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2019-12-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: mehdi_amini, rnk, tejohnson, russell.gallop, dexonsmith.
Herald added subscribers: llvm-commits, cfe-commits, usaxena95, dang, jfb, 
kadircet, arphaman, steven_wu, jkorous, MaskRay, javed.absar, hiraditya, 
kristof.beyls, arichardson, emaste.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: espindola.
Herald added projects: clang, LLVM.

**TL;DR:** This patches ensures that, on Windows, all CPU sockets and all NUMA 
nodes are used by the `ThreadPool`. The goal was to have LLD/ThinLTO use all 
hardware threads in the system, which isn't the case currently on multi-socket 
or large CPU count systems.

(this could possibly be split into a few patches, but I just wanted an overall 
opinion)

Background
--

Windows doesn't have a flat `cpu_set_t` like Linux. Instead, it projects 
hardware CPUs (or NUMA nodes) to applications through a concept of "processor 
groups". A "processor" is the smallest unit of execution on a CPU, that is, an 
hyper-thread if SMT is active; a core otherwise. There's a limit of 32-bit 
processors on older 32-bit versions of Windows, which later was raised to 
64-processors with 64-bit versions of Windows. This limit comes from the 
affinity mask, which historically was represented by the `sizeof(void*)` (still 
is that way). Consequently, the concept of "processor groups" was introduced 
for dealing with systems with more than 64 hyper-threads.

By default, the Windows OS assigns only one "processor group" to each starting 
application, in a round-robin manner. If the application wants to use more 
processors, it needs to programmatically enable it, by assigning threads to 
other "processor groups". This also means that affinity cannot cross "processor 
group" boundaries; one can only specify a "preferred" group on startup, but the 
application is free to allocate more groups if it wants to.

This creates a peculiar situation, where newer CPUs like the AMD EPYC 7702P 
(64-cores, 128-hyperthreads) are projected by the OS as two (2) "processor 
groups". This means that by default, an application can only use half of the 
cores. This situation will only get worse in the years to come, as dies with 
more cores will appear on the market.

The changes in this patch
-

Previously, the problem was that `heavyweight_hardware_concurrency()` API was 
introduced so that only one hardware thread per core was used. Once that API 
returns, //that original intention is lost//. Consider a situation, on Windows, 
where the system has 2 CPU sockets, 18 cores each, each core having 2 
hyper-threads, for a total of 72 hyper-threads. Both 
`heavyweight_hardware_concurrency()` and `hardware_concurrency()` currently 
return 36, because on Windows they are simply wrappers over 
`std::thread::hardware_concurrency()` -- which returns only processors from the 
current "processor group".

What if we wanted to use all "processor groups" ? Even if we implemented 
properly `heavyweight_hardware_concurrency()` to returns 18, what should it 
then return ? 18 or 36 ?
What if user specified `/opt:lldltojobs=36` ? Should we assign 36 threads on 
the current "processor group" or should we dispatch extra threads on the second 
"processor groups" ?

To solve this situation, we capture (and retain) the initial intention until 
the point of usage, through a new `ThreadPoolStrategy` class. The number of 
threads to use is deferred as late as possible, until the moment where the 
`std::thread`s are created (`ThreadPool` in the case of ThinLTO).

Discussion
--

Ideally, we should consider all "processors" (on Windows) or all "CPUs" (Linux) 
as all equal, in which case `heavyweight_hardware_concurrency()` wouldn't be 
needed. I'm not sure how micro-managing threads, cores and NUMA nodes will 
scale in the years to come (probably not well). Will it make sense to say "I 
don't want hyper-threads" ? Or saying `/opt:lldltojobs=whatever` when you have 
a thousand(s)-core system ? How would that work with NUMA affinity ? For 
example the Fujitsu A64FX 

 has 4x "12-core tiles" on the same die, each tile being connected to an 
internal 8-GB HBM2 memory (each located internally on the CPU die). How would 
we dispatch threads in that case ? The AMD EPYC uses the same concept of 
"tiles", however it doesn't have internal memory yet, but most likely the EPYC 
v3 will use the same architecture.

@tejohnson : Teresa, since you added `heavyweight_hardware_concurrency()`, do 
you have a benchmark which compares ThinLTO running with 
`heavyweight_hardware_concurrency()` or with `hardware_concurrency()` ? (I 
haven't done that test yet)
It would make things a lot simpler if we didn't have that API, and in general 
considered that we could use all hardware threads in the system; and that they 
can perform equally.


Repository:
  rG LLVM Github 

[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2019-12-20 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added inline comments.



Comment at: llvm/lib/Target/AArch64/SVEInstrFormats.td:5333
+  // We need a layer of indirection because early machine code passes balk at
+  // physical register (i.e. FFR) uses that have no previous definition.
+  let hasSideEffects = 1, hasNoSchedulingInfo = 1, mayLoad = 1 in {

efriedma wrote:
> This is depending on hasSideEffects to preserve the correct ordering with 
> instructions that read/write FFR?  That probably works.  I guess the 
> alternative is to insert an IMPLICIT_DEF of FFR in the entry block of each 
> function.
> 
> What are the calling convention rules for FFR?  Is it callee-save?  If not, 
> we might need to do some work to make FFR reads/writes do something sane 
> across calls inserted by the compiler.
The FFR is not callee-saved. We will need to add support to save & restore it 
where appropriate at the point the compiler starts generating reads to the FFR, 
but for the purpose of the ACLE the user will be required to do this if 
necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71698



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


[PATCH] D71769: [clang-format] C# formatting a class with inheritance followed by an attribute specifier assume its a braces initializer

2019-12-20 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f209ccfbe5e: [clang-format] C# formatting a class with 
inheritance followed by an attribute… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71769

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -316,6 +316,27 @@
"}\n"
"}\n",
Style);
+
+  verifyFormat("public A : Base\n"
+   "{\n"
+   "}\n"
+   "[Test]\n"
+   "public Foo()\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  verifyFormat("namespace\n"
+   "{\n"
+   "public A : Base\n"
+   "{\n"
+   "}\n"
+   "[Test]\n"
+   "public Foo()\n"
+   "{\n"
+   "}\n"
+   "}\n",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpSpaceBefore) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -466,7 +466,7 @@
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
   (NextTok->isBinaryOperator() && !NextIsObjCMethod);
-  if (NextTok->is(tok::l_square)) {
+  if (!Style.isCSharp() && NextTok->is(tok::l_square)) {
 // We can have an array subscript after a braced init
 // list, but C++11 attributes are expected after blocks.
 NextTok = Tokens->getNextToken();


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -316,6 +316,27 @@
"}\n"
"}\n",
Style);
+
+  verifyFormat("public A : Base\n"
+   "{\n"
+   "}\n"
+   "[Test]\n"
+   "public Foo()\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  verifyFormat("namespace\n"
+   "{\n"
+   "public A : Base\n"
+   "{\n"
+   "}\n"
+   "[Test]\n"
+   "public Foo()\n"
+   "{\n"
+   "}\n"
+   "}\n",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpSpaceBefore) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -466,7 +466,7 @@
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
   (NextTok->isBinaryOperator() && !NextIsObjCMethod);
-  if (NextTok->is(tok::l_square)) {
+  if (!Style.isCSharp() && NextTok->is(tok::l_square)) {
 // We can have an array subscript after a braced init
 // list, but C++11 attributes are expected after blocks.
 NextTok = Tokens->getNextToken();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36051: [clang-tidy] List the checkers with autofix

2019-12-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

In D36051#1792909 , @whisperity wrote:

> I am a little bit conflicted about the //Severity// column. While I know our 
> people put a great deal of effort into keeping this classification sane, what 
> was put into CodeChecker is, at the end of the day, a pretty arbitrary 
> classification.


Sure, static analysis is often subjective... Coverity has some classification 
too. From my experience, the one from code checker matches pretty well.

> I think RSTs support comments, right? Maybe it should be indicated in the 
> code (as a comment only) where the severity was taken from, so if someone 
> comes up with a reason to change a checker's severity, they could also submit 
> a patch to CodeChecker's knowledge-base.

Added, thanks for the idea!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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


[PATCH] D70073: [ConstExprPreter] Implemented function calls and if statements

2019-12-20 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70073



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


[clang] 2f209cc - [clang-format] C# formatting a class with inheritance followed by an attribute specifier assume its a braces initializer

2019-12-20 Thread via cfe-commits

Author: mydeveloperday
Date: 2019-12-20T17:07:00Z
New Revision: 2f209ccfbe5e6b33088763b1e022ba876fb0f35c

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

LOG: [clang-format] C# formatting a class with inheritance followed by an 
attribute specifier assume its a braces initializer

Summary:
https://bugs.llvm.org/show_bug.cgi?id=44340

The rule that prevents `... {} [[]]`  being treated as a braced initializer 
for C++ causes problems for C# with attributes, causing it to be incorrectly 
classified and then messing up the subsequent formatting. (see bug for details 
of formatting)

Reviewers: mitchell-stellar, klimek, sammccall

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 1e27eab1e744..ead6b4743207 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -466,7 +466,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool 
ExpectClassBody) {
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
   (NextTok->isBinaryOperator() && !NextIsObjCMethod);
-  if (NextTok->is(tok::l_square)) {
+  if (!Style.isCSharp() && NextTok->is(tok::l_square)) {
 // We can have an array subscript after a braced init
 // list, but C++11 attributes are expected after blocks.
 NextTok = Tokens->getNextToken();

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index a2f381078d42..d8311d269647 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -316,6 +316,27 @@ TEST_F(FormatTestCSharp, AttributesIndentation) {
"}\n"
"}\n",
Style);
+
+  verifyFormat("public A : Base\n"
+   "{\n"
+   "}\n"
+   "[Test]\n"
+   "public Foo()\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  verifyFormat("namespace\n"
+   "{\n"
+   "public A : Base\n"
+   "{\n"
+   "}\n"
+   "[Test]\n"
+   "public Foo()\n"
+   "{\n"
+   "}\n"
+   "}\n",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpSpaceBefore) {



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


[PATCH] D71513: [compiler-rt] [test] Disable MPROTECT on two builtin tests

2019-12-20 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG190b9110c23c: [compiler-rt] [test] Disable MPROTECT on two 
builtin tests (authored by mgorny).
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71513

Files:
  compiler-rt/test/builtins/Unit/clear_cache_test.c
  compiler-rt/test/builtins/Unit/enable_execute_stack_test.c
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/sanitizer_common/netbsd_commands/run_nomprotect.sh


Index: compiler-rt/test/sanitizer_common/netbsd_commands/run_nomprotect.sh
===
--- /dev/null
+++ compiler-rt/test/sanitizer_common/netbsd_commands/run_nomprotect.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/sbin/paxctl +m "${1}"
+exec "${@}"
Index: compiler-rt/test/lit.common.cfg.py
===
--- compiler-rt/test/lit.common.cfg.py
+++ compiler-rt/test/lit.common.cfg.py
@@ -112,6 +112,19 @@
 (' clang', """\n\n*** Do not use 'clangXXX' in tests,
  instead define '%clangXXX' substitution in lit config. ***\n\n""") )
 
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.netbsd_noaslr_prefix = ('sh ' +
+ os.path.join(nb_commands_dir, 
'run_noaslr.sh'))
+  config.netbsd_nomprotect_prefix = ('sh ' +
+ os.path.join(nb_commands_dir,
+  'run_nomprotect.sh'))
+  config.substitutions.append( ('%run_nomprotect',
+config.netbsd_nomprotect_prefix) )
+else:
+  config.substitutions.append( ('%run_nomprotect', '%run') )
+
 # Allow tests to be executed on a simulator or remotely.
 if config.emulator:
   config.substitutions.append( ('%run', config.emulator) )
@@ -498,9 +511,3 @@
 
 config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, 
config.clang]) + " "
 config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "
-
-if config.host_os == 'NetBSD':
-  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
- "test", "sanitizer_common", "netbsd_commands")
-  config.netbsd_noaslr_prefix = ('sh ' +
- os.path.join(nb_commands_dir, 
'run_noaslr.sh'))
Index: compiler-rt/test/builtins/Unit/enable_execute_stack_test.c
===
--- compiler-rt/test/builtins/Unit/enable_execute_stack_test.c
+++ compiler-rt/test/builtins/Unit/enable_execute_stack_test.c
@@ -1,5 +1,5 @@
 // REQUIRES: native-run
-// RUN: %clang_builtins %s %librt -o %t && %run %t
+// RUN: %clang_builtins %s %librt -o %t && %run_nomprotect %t
 // REQUIRES: librt_has_enable_execute_stack
 //===-- enable_execute_stack_test.c - Test __enable_execute_stack 
--===//
 //
Index: compiler-rt/test/builtins/Unit/clear_cache_test.c
===
--- compiler-rt/test/builtins/Unit/clear_cache_test.c
+++ compiler-rt/test/builtins/Unit/clear_cache_test.c
@@ -1,6 +1,6 @@
 // REQUIRES: native-run
 // UNSUPPORTED: arm, aarch64
-// RUN: %clang_builtins %s %librt -o %t && %run %t
+// RUN: %clang_builtins %s %librt -o %t && %run_nomprotect %t
 // REQUIRES: librt_has_clear_cache
 //===-- clear_cache_test.c - Test clear_cache 
-===//
 //


Index: compiler-rt/test/sanitizer_common/netbsd_commands/run_nomprotect.sh
===
--- /dev/null
+++ compiler-rt/test/sanitizer_common/netbsd_commands/run_nomprotect.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/sbin/paxctl +m "${1}"
+exec "${@}"
Index: compiler-rt/test/lit.common.cfg.py
===
--- compiler-rt/test/lit.common.cfg.py
+++ compiler-rt/test/lit.common.cfg.py
@@ -112,6 +112,19 @@
 (' clang', """\n\n*** Do not use 'clangXXX' in tests,
  instead define '%clangXXX' substitution in lit config. ***\n\n""") )
 
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.netbsd_noaslr_prefix = ('sh ' +
+ os.path.join(nb_commands_dir, 'run_noaslr.sh'))
+  config.netbsd_nomprotect_prefix = ('sh ' +
+ os.path.join(nb_commands_dir,
+  'run_nomprotect.sh'))
+  config.substitutions.append( ('%run_nomprotect',
+config.netbsd_nomprotect_prefix) )
+else:
+  config.substitutions.append( ('%run_nomprotect', '%run') )
+
 

[PATCH] D36051: [clang-tidy] List the checkers with autofix

2019-12-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 234911.
sylvestre.ledru added a comment.

Add a comment about codechecker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051

Files:
  clang-tools-extra/docs/clang-tidy/checks/list.rst

Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -3,388 +3,403 @@
 Clang-Tidy Checks
 =
 
-.. toctree::
-   abseil-duration-addition
-   abseil-duration-comparison
-   abseil-duration-conversion-cast
-   abseil-duration-division
-   abseil-duration-factory-float
-   abseil-duration-factory-scale
-   abseil-duration-subtraction
-   abseil-duration-unnecessary-conversion
-   abseil-faster-strsplit-delimiter
-   abseil-no-internal-dependencies
-   abseil-no-namespace
-   abseil-redundant-strcat-calls
-   abseil-str-cat-append
-   abseil-string-find-startswith
-   abseil-time-comparison
-   abseil-time-subtraction
-   abseil-upgrade-duration-conversions
-   android-cloexec-accept
-   android-cloexec-accept4
-   android-cloexec-creat
-   android-cloexec-dup
-   android-cloexec-epoll-create
-   android-cloexec-epoll-create1
-   android-cloexec-fopen
-   android-cloexec-inotify-init
-   android-cloexec-inotify-init1
-   android-cloexec-memfd-create
-   android-cloexec-open
-   android-cloexec-pipe
-   android-cloexec-pipe2
-   android-cloexec-socket
-   android-comparison-in-temp-failure-retry
-   boost-use-to-string
-   bugprone-argument-comment
-   bugprone-assert-side-effect
-   bugprone-bad-signal-to-kill-thread
-   bugprone-bool-pointer-implicit-conversion
-   bugprone-branch-clone
-   bugprone-copy-constructor-init
-   bugprone-dangling-handle
-   bugprone-dynamic-static-initializers
-   bugprone-exception-escape
-   bugprone-fold-init-type
-   bugprone-forward-declaration-namespace
-   bugprone-forwarding-reference-overload
-   bugprone-inaccurate-erase
-   bugprone-incorrect-roundings
-   bugprone-infinite-loop
-   bugprone-integer-division
-   bugprone-lambda-function-name
-   bugprone-macro-parentheses
-   bugprone-macro-repeated-side-effects
-   bugprone-misplaced-operator-in-strlen-in-alloc
-   bugprone-misplaced-widening-cast
-   bugprone-move-forwarding-reference
-   bugprone-multiple-statement-macro
-   bugprone-not-null-terminated-result
-   bugprone-parent-virtual-call
-   bugprone-posix-return
-   bugprone-sizeof-container
-   bugprone-sizeof-expression
-   bugprone-string-constructor
-   bugprone-string-integer-assignment
-   bugprone-string-literal-with-embedded-nul
-   bugprone-suspicious-enum-usage
-   bugprone-suspicious-memset-usage
-   bugprone-suspicious-missing-comma
-   bugprone-suspicious-semicolon
-   bugprone-suspicious-string-compare
-   bugprone-swapped-arguments
-   bugprone-terminating-continue
-   bugprone-throw-keyword-missing
-   bugprone-too-small-loop-variable
-   bugprone-undefined-memory-manipulation
-   bugprone-undelegated-constructor
-   bugprone-unhandled-self-assignment
-   bugprone-unused-raii
-   bugprone-unused-return-value
-   bugprone-use-after-move
-   bugprone-virtual-near-miss
-   cert-dcl03-c (redirects to misc-static-assert) 
-   cert-dcl16-c (redirects to readability-uppercase-literal-suffix) 
-   cert-dcl21-cpp
-   cert-dcl50-cpp
-   cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
-   cert-dcl58-cpp
-   cert-dcl59-cpp (redirects to google-build-namespaces) 
-   cert-env33-c
-   cert-err09-cpp (redirects to misc-throw-by-value-catch-by-reference) 
-   cert-err34-c
-   cert-err52-cpp
-   cert-err58-cpp
-   cert-err60-cpp
-   cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) 
-   cert-fio38-c (redirects to misc-non-copyable-objects) 
-   cert-flp30-c
-   cert-mem57-cpp
-   cert-msc30-c (redirects to cert-msc50-cpp) 
-   cert-msc32-c (redirects to cert-msc51-cpp) 
-   cert-msc50-cpp
-   cert-msc51-cpp
-   cert-oop11-cpp (redirects to performance-move-constructor-init) 
-   cert-oop54-cpp (redirects to bugprone-unhandled-self-assignment) 
-   cert-oop58-cpp
-   cert-pos44-c (redirects to bugprone-bad-signal-to-kill-thread) 
-   clang-analyzer-core.CallAndMessage (redirects to https://clang.llvm.org/docs/analyzer/checkers.html) 
-   clang-analyzer-core.DivideZero (redirects to https://clang.llvm.org/docs/analyzer/checkers.html) 
-   clang-analyzer-core.DynamicTypePropagation
-   clang-analyzer-core.NonNullParamChecker (redirects to https://clang.llvm.org/docs/analyzer/checkers.html) 
-   clang-analyzer-core.NullDereference (redirects to https://clang.llvm.org/docs/analyzer/checkers.html) 
-   clang-analyzer-core.StackAddressEscape (redirects to https://clang.llvm.org/docs/analyzer/checkers.html) 
-   clang-analyzer-core.UndefinedBinaryOperatorResult (redirects to https://clang.llvm.org/docs/analyzer/checkers.html) 
-   

[PATCH] D69272: Restricted variant of '#pragma STDC FENV_ACCESS'

2019-12-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D69272#1792877 , @kpn wrote:

> My understanding of this patch is that it only allows the #pragma at the top 
> of each function. It doesn't allow it in blocks inside the function. So if a 
> function has a block inside it that uses strict FP the patch doesn't change 
> the rest of the function to use constrained FP with the settings like you 
> said. And my question was asking if there was a way forward with this patch 
> to a full implementation.


@hfinkel proposed to use outlining to extract a block with the #pragma to 
separate function. It could be a basis for a full implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69272



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


[PATCH] D71612: [analyzer] Add PlacementNewChecker

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:472
+def PlacementNewChecker : Checker<"PlacementNew">,
+  HelpText<"Check if default placement new is provided with pointers to "
+   "sufficient storage capacity">,

Probably you want to add documentation to `clang/docs/analyzer/checkers.rst` as 
well for better visibility.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:51
+SVal PlacementNewChecker::getExtentSizeOfNewTarget(
+CheckerContext , const CXXNewExpr *NE, ProgramStateRef State) const {
+  SValBuilder  = C.getSValBuilder();

A very minor nit, but checker APIs tend to have `CheckerContext` as the last 
parameter. Maybe following this guideline within the checkers as well makes 
them a bit more natural.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:59
+SVal ElementCount = C.getSVal(SizeExpr);
+Optional ElementCountNL = ElementCount.getAs();
+if (ElementCountNL) {

You can move this line into the if condition.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:91
+  SVal SizeOfPlace = getExtentSizeOfPlace(C, Place, State);
+  const auto SizeOfTargetCI = SizeOfTarget.getAs();
+  if (!SizeOfTargetCI)

Here, instead of getting `SizeOfTarget` and `SizeOfPlace` as `ConcreteInt`s, I 
think you should rather use `evalBinOp` to compare them. That method is more 
future proof as if we cannot constraint these values down to a single integer 
but we still have some information about them a sufficiently smart solver could 
prove the relationship between the symbolic values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71612



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


[PATCH] D36051: [clang-tidy] List the checkers with autofix

2019-12-20 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

I am a little bit conflicted about the //Severity// column. While I know our 
people put a great deal of effort into keeping this classification sane, what 
was put into CodeChecker is, at the end of the day, a pretty arbitrary 
classification.

I think RSTs support comments, right? Maybe it should be indicated in the code 
(as a comment only) where the severity was taken from, so if someone comes up 
with a reason to change a checker's severity, they could also submit a patch to 
CodeChecker's knowledge-base.

Maybe not //just// in the code comment, but also in the markup that gets 
rendered for the users, too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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


[PATCH] D71708: [OPENMP50]Codegen for nontemporal clause.

2019-12-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61052 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71708



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


[clang] ff92c56 - [OPENMP]Remove unused OPENMP_MATCH_KIND, NFC.

2019-12-20 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-20T11:17:55-05:00
New Revision: ff92c56ef97c62e6350531fd45ec1ad36ed25a3c

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

LOG: [OPENMP]Remove unused OPENMP_MATCH_KIND, NFC.

Added: 


Modified: 
clang/include/clang/Basic/OpenMPKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index b015826f0e29..e7c1cbad2b9a 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -206,9 +206,6 @@
 #ifndef OPENMP_DECLARE_VARIANT_CLAUSE
 #define OPENMP_DECLARE_VARIANT_CLAUSE(Name)
 #endif
-#ifndef OPENMP_MATCH_KIND
-#define OPENMP_MATCH_KIND(Name)
-#endif
 #ifndef OPENMP_CONTEXT_SELECTOR_SET
 #define OPENMP_CONTEXT_SELECTOR_SET(Name)
 #endif
@@ -1060,13 +1057,8 @@ OPENMP_DEVICE_TYPE_KIND(any)
 // Clauses allowed for OpenMP directive 'declare variant'.
 OPENMP_DECLARE_VARIANT_CLAUSE(match)
 
-// Context selectors for 'match' clause.
-// TODO: add other context selectors.
-OPENMP_MATCH_KIND(implementation)
-
 #undef OPENMP_CONTEXT_SELECTOR
 #undef OPENMP_CONTEXT_SELECTOR_SET
-#undef OPENMP_MATCH_KIND
 #undef OPENMP_DECLARE_VARIANT_CLAUSE
 #undef OPENMP_DEVICE_TYPE_KIND
 #undef OPENMP_ALLOCATE_CLAUSE



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


  1   2   >