[PATCH] D72993: [NFC][Codegen] Use MaybeAlign + APInt::getLimitedValue() when creating Alignment attr

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, gchatelet, courbet, jdoerfert.
lebedev.ri added a project: clang.
lebedev.ri added a parent revision: D72979: [Codegen] Emit both 
AssumeAlignedAttr and AllocAlignAttr assumptions if they exist.

Just an NFC code cleanup i stumbled upon when stumbling through clang alignment 
attribute handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72993

Files:
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2441,9 +2441,8 @@
   EmitScalarExpr(AVAttr->getAlignment());
 llvm::ConstantInt *AlignmentCI =
   cast(AlignmentValue);
-unsigned Alignment = 
std::min((unsigned)AlignmentCI->getZExtValue(),
-  +llvm::Value::MaximumAlignment);
-AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(llvm::MaybeAlign(
+AlignmentCI->getLimitedValue(llvm::Value::MaximumAlignment;
   }
 }
 


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2441,9 +2441,8 @@
   EmitScalarExpr(AVAttr->getAlignment());
 llvm::ConstantInt *AlignmentCI =
   cast(AlignmentValue);
-unsigned Alignment = std::min((unsigned)AlignmentCI->getZExtValue(),
-  +llvm::Value::MaximumAlignment);
-AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(llvm::MaybeAlign(
+AlignmentCI->getLimitedValue(llvm::Value::MaximumAlignment;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72994: [Sema] Sanitize alignment requested via `__attribute__((assume_aligned(imm)))`

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, aaron.ballman, hfinkel, rsmith, 
jdoerfert.
lebedev.ri added a project: LLVM.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
lebedev.ri added a parent revision: D72993: [NFC][Codegen] Use MaybeAlign + 
APInt::getLimitedValue() when creating Alignment attr.

For `__builtin_assume_aligned()`, we do validate that the alignment
is not greater than `536870912` (D68824 ), but 
we don't do that for
`__attribute__((assume_aligned(N)))` attribute.
I suspect we should.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72994

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/builtin-assume-aligned.c


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -46,6 +46,7 @@
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning
+void *test_ptr_assume_aligned(void) 
__attribute__((assume_aligned(1073741824))); // expected-warning {{requested 
alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
 
 int j __attribute__((assume_aligned(8))); // expected-warning 
{{'assume_aligned' attribute only applies to Objective-C methods and functions}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32))); // no-warning
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1625,6 +1625,12 @@
 << E->getSourceRange();
   return;
 }
+
+// Alignment calculations can wrap around if it's greater than 2**29.
+unsigned MaximumAlignment = 536870912;
+if (I > MaximumAlignment)
+  Diag(CI.getLoc(), diag::warn_assume_aligned_too_great)
+  << CI.getRange() << MaximumAlignment;
   }
 
   if (OE) {


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -46,6 +46,7 @@
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
+void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(1073741824))); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
 
 int j __attribute__((assume_aligned(8))); // expected-warning {{'assume_aligned' attribute only applies to Objective-C methods and functions}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32))); // no-warning
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1625,6 +1625,12 @@
 << E->getSourceRange();
   return;
 }
+
+// Alignment calculations can wrap around if it's greater than 2**29.
+unsigned MaximumAlignment = 536870912;
+if (I > MaximumAlignment)
+  Diag(CI.getLoc(), diag::warn_assume_aligned_too_great)
+  << CI.getRange() << MaximumAlignment;
   }
 
   if (OE) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72996: [Sema] Attempt to perform call-size-specific `__attribute__((alloc_align(param_idx)))` validation

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, aaron.ballman, hfinkel, rsmith, 
jdoerfert.
lebedev.ri added a project: LLVM.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
lebedev.ri added a parent revision: D72994: [Sema] Sanity-check alignment 
requested via `__attribute__((assume_aligned(imm)))`.

`alloc_align` attribute takes parameter number, not the alignment itself,
so given **just** the attribute/function declaration we can't do any
sanity checking for said alignment.

However, at call site, given the actual `Expr` that is passed
into that parameter, we //might// be able to evaluate said `Expr`
as Integer Constant Expression, and perform the sanity checks.
But since there is no requirement for that argument to be an immediate,
we may fail, and that's okay.

However if we did evaluate, we should enforce the same constraints
as with `__builtin_assume_aligned()`/`__attribute__((assume_aligned(imm)))`:
said alignment is a power of two, and is not greater than our magic threshold


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72996

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/SemaCXX/alloc-align-attr.cpp


Index: clang/test/SemaCXX/alloc-align-attr.cpp
===
--- clang/test/SemaCXX/alloc-align-attr.cpp
+++ clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,13 +23,19 @@
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // 
expected-error {{'alloc_align' attribute requires parameter 1 to be an integer 
constant}}
 
-void dependent_impl() {
+void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 
'dependent_ret' requested here}}
   a.Foo(1);
   a.Foo2(1);
-  dependent_ret b; 
-  a.Foo(1);
-  a.Foo2(1);
+  dependent_ret b;
+  b.Foo(1);
+  b.Foo2(1);
+  b.Foo(3);   // expected-error {{requested alignment is not a power 
of 2}}
+  b.Foo2(3);  // expected-error {{requested alignment is not a power 
of 2}}
+  b.Foo(1073741824);  // expected-warning {{requested alignment must be 
536870912 bytes or smaller; maximum alignment assumed}}
+  b.Foo2(1073741824); // expected-warning {{requested alignment must be 
536870912 bytes or smaller; maximum alignment assumed}}
+  b.Foo(align);
+  b.Foo2(align);
 
   dependent_param_struct c; 
   c.Foo(1);
Index: clang/test/Sema/alloc-align-attr.c
===
--- clang/test/Sema/alloc-align-attr.c
+++ clang/test/Sema/alloc-align-attr.c
@@ -17,3 +17,15 @@
 void *test_no_fn_proto(int x, int y) __attribute__((alloc_align())); // 
expected-error {{'alloc_align' attribute takes one argument}}
 void *test_no_fn_proto(int x, int y) __attribute__((alloc_align(32, 45, 37))); 
// expected-error {{'alloc_align' attribute takes one argument}}
 
+void *passthrought(int a) {
+  return test_ptr_alloc_align(a);
+}
+void *align16() {
+  return test_ptr_alloc_align(16);
+}
+void *align15() {
+  return test_ptr_alloc_align(15); // expected-error {{requested alignment is 
not a power of 2}}
+}
+void *align536870912() {
+  return test_ptr_alloc_align(1073741824); // expected-warning {{requested 
alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4473,6 +4473,27 @@
 }
   }
 
+  if (FDecl && FDecl->hasAttr()) {
+auto *AA = FDecl->getAttr();
+const Expr *Arg = Args[AA->getParamIndex().getASTIndex()];
+if (!Arg->isTypeDependent() && !Arg->isValueDependent()) {
+  llvm::APSInt I(64);
+  if (Arg->isIntegerConstantExpr(I, Context)) {
+if (!I.isPowerOf2()) {
+  Diag(Arg->getExprLoc(), diag::err_alignment_not_power_of_two)
+  << Arg->getSourceRange();
+  return;
+}
+
+// Alignment calculations can wrap around if it's greater than 2**29.
+unsigned MaximumAlignment = 536870912;
+if (I > MaximumAlignment)
+  Diag(Arg->getExprLoc(), diag::warn_assume_aligned_too_great)
+  << Arg->getSourceRange() << MaximumAlignment;
+  }
+}
+  }
+
   if (FD)
 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
 }


Index: clang/test/SemaCXX/alloc-align-attr.cpp
===
--- clang/test/SemaCXX/alloc-align-attr.cpp
+++ clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,13 +23,19 @@
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // expected-error {{'alloc_align' attribute requires parameter 1 to be an integer constant}}
 
-void dependent_impl() {
+void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 'dependent_ret' requested here}}
   a

[PATCH] D72793: [clang-format] Expand the SpacesAroundConditions option to include catch statements

2020-01-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72793



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


[PATCH] D72998: [IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, hfinkel, jdoerfert, gchatelet, courbet.
lebedev.ri added a project: LLVM.
Herald added subscribers: cfe-commits, hiraditya.
Herald added a project: clang.
lebedev.ri added a parent revision: D72996: [Sema] Attempt to perform 
call-size-specific `__attribute__((alloc_align(param_idx)))` validation.

I initially encountered those assertions when trying to create
this IR `alignment` attribute from clang's 
`__attribute__((assume_aligned(imm)))`,
because until D72994  there is no sanity 
checking for the value of `imm`.

But even then, we have `llvm::Value::MaximumAlignment` constant (which is 
`536870912`),
which is enforced for clang attributes, and then there are some other magical 
constant
(`0x4000` i.e. `1073741824` i.e. `2 * 536870912`) in
`Attribute::getWithAlignment()`/`AttrBuilder::addAlignmentAttr()`.

I strongly suspect that `0x4000` is incorrect,
and that also should be `llvm::Value::MaximumAlignment`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72998

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  llvm/lib/IR/Attributes.cpp


Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -143,7 +143,7 @@
 }
 
 Attribute Attribute::getWithAlignment(LLVMContext &Context, Align A) {
-  assert(A <= 0x4000 && "Alignment too large.");
+  assert(A <= llvm::Value::MaximumAlignment && "Alignment too large.");
   return get(Context, Alignment, A.value());
 }
 
@@ -1521,7 +1521,7 @@
   if (!Align)
 return *this;
 
-  assert(*Align <= 0x4000 && "Alignment too large.");
+  assert(*Align <= llvm::Value::MaximumAlignment && "Alignment too large.");
 
   Attrs[Attribute::Alignment] = true;
   Alignment = Align;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1627,7 +1627,7 @@
 }
 
 // Alignment calculations can wrap around if it's greater than 2**29.
-unsigned MaximumAlignment = 536870912;
+unsigned MaximumAlignment = 536870912; // See llvm::Value::MaximumAlignment
 if (I > MaximumAlignment)
   Diag(CI.getLoc(), diag::warn_assume_aligned_too_great)
   << CI.getRange() << MaximumAlignment;
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4486,7 +4486,8 @@
 }
 
 // Alignment calculations can wrap around if it's greater than 2**29.
-unsigned MaximumAlignment = 536870912;
+unsigned MaximumAlignment =
+536870912; // See llvm::Value::MaximumAlignment
 if (I > MaximumAlignment)
   Diag(Arg->getExprLoc(), diag::warn_assume_aligned_too_great)
   << Arg->getSourceRange() << MaximumAlignment;
@@ -6215,7 +6216,7 @@
  << Arg->getSourceRange();
 
 // Alignment calculations can wrap around if it's greater than 2**29.
-unsigned MaximumAlignment = 536870912;
+unsigned MaximumAlignment = 536870912; // See llvm::Value::MaximumAlignment
 if (Result > MaximumAlignment)
   Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
   << Arg->getSourceRange() << MaximumAlignment;


Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -143,7 +143,7 @@
 }
 
 Attribute Attribute::getWithAlignment(LLVMContext &Context, Align A) {
-  assert(A <= 0x4000 && "Alignment too large.");
+  assert(A <= llvm::Value::MaximumAlignment && "Alignment too large.");
   return get(Context, Alignment, A.value());
 }
 
@@ -1521,7 +1521,7 @@
   if (!Align)
 return *this;
 
-  assert(*Align <= 0x4000 && "Alignment too large.");
+  assert(*Align <= llvm::Value::MaximumAlignment && "Alignment too large.");
 
   Attrs[Attribute::Alignment] = true;
   Alignment = Align;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1627,7 +1627,7 @@
 }
 
 // Alignment calculations can wrap around if it's greater than 2**29.
-unsigned MaximumAlignment = 536870912;
+unsigned MaximumAlignment = 536870912; // See llvm::Value::MaximumAlignment
 if (I > MaximumAlignment)
   Diag(CI.getLoc(), diag::warn_assume_aligned_too_great)
   << CI.getRange() << MaximumAlignment;
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4486,7 +4486,8 @@
 }
 
 // Alignment calcul

[clang] 46be168 - fix doc typos to cycle bots

2020-01-19 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-01-19T09:51:25-05:00
New Revision: 46be16897706fa21ac0868746291444ca2461ce7

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

LOG: fix doc typos to cycle bots

Added: 


Modified: 
clang/docs/SanitizerCoverage.rst

Removed: 




diff  --git a/clang/docs/SanitizerCoverage.rst 
b/clang/docs/SanitizerCoverage.rst
index c7cd853dd66b..303152309e1a 100644
--- a/clang/docs/SanitizerCoverage.rst
+++ b/clang/docs/SanitizerCoverage.rst
@@ -27,7 +27,7 @@ on every edge:
 
 Every edge will have its own `guard_variable` (uint32_t).
 
-The compler will also insert calls to a module constructor:
+The compiler will also insert calls to a module constructor:
 
 .. code-block:: c++
 
@@ -376,7 +376,7 @@ to produce a ``.symcov`` file first:
 
 sancov -symbolize my_program.123.sancov my_program > my_program.123.symcov
 
-The ``.symcov`` file can be browsed overlayed over the source code by
+The ``.symcov`` file can be browsed overlaid over the source code by
 running ``tools/sancov/coverage-report-server.py`` script that will start
 an HTTP server.
 



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


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

2020-01-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@wenlei Taking a look now.
@hans I remember now why I was re-entering main() in the first iteration of 
this path. Response files were one reason. And handling /MP was another, which 
triggers the re-entrance twice (once for CL driver, and once for cc1).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69825



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


[clang] d82adf3 - Allow space after C-style cast in C# code

2020-01-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-01-19T15:41:40Z
New Revision: d82adf328fb556e1e6d318608b683824c8badf22

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

LOG: Allow space after C-style cast in C# code

Reviewed By: MyDeveloperDay, krasimir

Patch By: jbcoe

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 21a2184bf1d8..a8f33e62f994 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1640,8 +1640,9 @@ class AnnotatingParser {
 
   /// Determine whether ')' is ending a cast.
   bool rParenEndsCast(const FormatToken &Tok) {
-// C-style casts are only used in C++ and Java.
-if (!Style.isCpp() && Style.Language != FormatStyle::LK_Java)
+// C-style casts are only used in C++, C# and Java.
+if (!Style.isCSharp() && !Style.isCpp() &&
+Style.Language != FormatStyle::LK_Java)
   return false;
 
 // Empty parens aren't casts and there are no casts at the end of the line.

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index d8311d269647..95b14d0f0aa4 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -374,5 +374,14 @@ TEST_F(FormatTestCSharp, CSharpSpaceBefore) {
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpSpaceAfterCStyleCast) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("(int)x / y;", Style);
+
+  Style.SpaceAfterCStyleCast = true;
+  verifyFormat("(int) x / y;", Style);
+}
+
 } // namespace format
 } // end namespace clang



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


[PATCH] D72150: Allow space after C-style cast in C# code

2020-01-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd82adf328fb5: Allow space after C-style cast in C# code 
(authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D72150?vs=236048&id=238991#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72150

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -374,5 +374,14 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpSpaceAfterCStyleCast) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("(int)x / y;", Style);
+
+  Style.SpaceAfterCStyleCast = true;
+  verifyFormat("(int) x / y;", Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1640,8 +1640,9 @@
 
   /// Determine whether ')' is ending a cast.
   bool rParenEndsCast(const FormatToken &Tok) {
-// C-style casts are only used in C++ and Java.
-if (!Style.isCpp() && Style.Language != FormatStyle::LK_Java)
+// C-style casts are only used in C++, C# and Java.
+if (!Style.isCSharp() && !Style.isCpp() &&
+Style.Language != FormatStyle::LK_Java)
   return false;
 
 // Empty parens aren't casts and there are no casts at the end of the line.


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -374,5 +374,14 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpSpaceAfterCStyleCast) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("(int)x / y;", Style);
+
+  Style.SpaceAfterCStyleCast = true;
+  verifyFormat("(int) x / y;", Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1640,8 +1640,9 @@
 
   /// Determine whether ')' is ending a cast.
   bool rParenEndsCast(const FormatToken &Tok) {
-// C-style casts are only used in C++ and Java.
-if (!Style.isCpp() && Style.Language != FormatStyle::LK_Java)
+// C-style casts are only used in C++, C# and Java.
+if (!Style.isCSharp() && !Style.isCpp() &&
+Style.Language != FormatStyle::LK_Java)
   return false;
 
 // Empty parens aren't casts and there are no casts at the end of the line.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 14c0447 - [clang-format] Add IndentCaseBlocks option

2020-01-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-01-19T15:52:26Z
New Revision: 14c044756e771eb9160d5809b4381bdeb0fc210c

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

LOG: [clang-format] Add IndentCaseBlocks option

Summary:
The documentation for IndentCaseLabels claimed that the "Switch
statement body is always indented one level more than case labels". This
is technically false for the code block immediately following the label.
Its closing bracket aligns with the start of the label.

If the case label are not indented, it leads to a style where the
closing bracket of the block aligns with the closing bracket of the
switch statement, which can be hard to parse.

This change introduces a new option, IndentCaseBlocks, which when true
treats the block as a scope block (which it technically is).

(Note: regenerated ClangFormatStyleOptions.rst using tools/dump_style.py)

Reviewed By: MyDeveloperDay

Patch By: capn

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 18cdc54a370f..fd77e1e727a9 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1605,12 +1605,36 @@ the configuration (without a prefix: ``Auto``).
   ``ClassImpl.hpp`` would not have the main include file put on top
   before any other include.
 
+**IndentCaseBlocks** (``bool``)
+  Indent case label blocks one level from the case label.
+
+  When ``false``, the block following the case label uses the same
+  indentation level as for the case label, treating the case label the same
+  as an if-statement.
+  When ``true``, the block gets indented as a scope block.
+
+  .. code-block:: c++
+
+ false: true:
+ switch (fool) {vs. switch (fool) {
+ case 1: {  case 1:
+   bar(); {
+ } break;   bar();
+ default: {   }
+   plop();break;
+ }  default:
+ }{
+plop();
+  }
+}
+
 **IndentCaseLabels** (``bool``)
   Indent case labels one level from the switch statement.
 
   When ``false``, use the same indentation level as for the switch
   statement. Switch statement body is always indented one level more than
-  case labels.
+  case labels (except the first block following the case label, which
+  itself indents the code - unless IndentCaseBlocks is enabled).
 
   .. code-block:: c++
 
@@ -2329,7 +2353,14 @@ the configuration (without a prefix: ``Auto``).
  x = ( int32 )y vs. x = (int32)y
 
 **SpacesInConditionalStatement** (``bool``)
-  If ``true``, spaces will be inserted around if/for/while (and similar) 
conditions.
+  If ``true``, spaces will be inserted around if/for/switch/while
+  conditions.
+
+  .. code-block:: c++
+
+ true:  false:
+ if ( a )  { ... }  vs. if (a) { ... }
+ while ( i < 5 )  { ... }   while (i < 5) { ... }
 
 **SpacesInContainerLiterals** (``bool``)
   If ``true``, spaces are inserted inside container literals (e.g.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 35132cecee57..76a1d748b604 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,6 +177,25 @@ clang-format
 
 
 
+- Option ``IndentCaseBlocks`` has been added to support treating the block
+  following a switch case label as a scope block which gets indented itself.
+  It helps avoid having the closing bracket align with the switch statement's
+  closing bracket (when ``IndentCaseLabels`` is ``false``).
+
+  .. code-block:: c++
+  
+switch (fool) {vs. switch (fool) {
+case 1:case 1: {
+  {  bar();
+ bar();} break;
+  }default: {
+  break; plop();
+default:   }
+  {}
+plop();
+  }
+}
+
 libclang
 
 

diff  --g

[PATCH] D72276: [clang-format] Add IndentCaseBlocks option

2020-01-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14c044756e77: [clang-format] Add IndentCaseBlocks option 
(authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D72276?vs=236740&id=238992#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72276

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1211,6 +1211,58 @@
"  }\n"
"}",
Style));
+  Style.IndentCaseLabels = false;
+  Style.IndentCaseBlocks = true;
+  EXPECT_EQ("switch (n)\n"
+"{\n"
+"case 0:\n"
+"  {\n"
+"return false;\n"
+"  }\n"
+"case 1:\n"
+"  break;\n"
+"default:\n"
+"  {\n"
+"return true;\n"
+"  }\n"
+"}",
+format("switch (n) {\n"
+   "case 0: {\n"
+   "  return false;\n"
+   "}\n"
+   "case 1:\n"
+   "  break;\n"
+   "default: {\n"
+   "  return true;\n"
+   "}\n"
+   "}",
+   Style));
+  Style.IndentCaseLabels = true;
+  Style.IndentCaseBlocks = true;
+  EXPECT_EQ("switch (n)\n"
+"{\n"
+"  case 0:\n"
+"{\n"
+"  return false;\n"
+"}\n"
+"  case 1:\n"
+"break;\n"
+"  default:\n"
+"{\n"
+"  return true;\n"
+"}\n"
+"}",
+format("switch (n) {\n"
+   "case 0: {\n"
+   "  return false;\n"
+   "}\n"
+   "case 1:\n"
+   "  break;\n"
+   "default: {\n"
+   "  return true;\n"
+   "}\n"
+   "}",
+   Style));
 }
 
 TEST_F(FormatTest, CaseRanges) {
@@ -12578,6 +12630,7 @@
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
   CHECK_PARSE_BOOL(IndentCaseLabels);
+  CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2003,7 +2003,8 @@
 --Line->Level;
   if (LeftAlignLabel)
 Line->Level = 0;
-  if (CommentsBeforeNextToken.empty() && FormatTok->Tok.is(tok::l_brace)) {
+  if (!Style.IndentCaseBlocks && CommentsBeforeNextToken.empty() &&
+  FormatTok->Tok.is(tok::l_brace)) {
 CompoundStatementIndenter Indenter(this, Line->Level,
Style.BraceWrapping.AfterCaseLabel,
Style.BraceWrapping.IndentBraces);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -480,6 +480,7 @@
 IO.mapOptional("IncludeIsMainSourceRegex",
Style.IncludeStyle.IncludeIsMainSourceRegex);
 IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
+IO.mapOptional("IndentCaseBlocks", Style.IndentCaseBlocks);
 IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels);
 IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives);
 IO.mapOptional("IndentWidth", Style.IndentWidth);
@@ -782,6 +783,7 @@
   LLVMStyle.IncludeStyle.IncludeIsMainRegex = "(Test)?$";
   LLVMStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve;
   LLVMStyle.IndentCaseLabels = false;
+  LLVMStyle.IndentCaseBlocks = false;
   LLVMStyle.IndentGotoLabels = true;
   LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
   LLVMStyle.IndentWrappedFunctionNames = false;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1314,7 +1314,8 @@
   ///
   /// When ``false``, use the same indentation level as for the switch
   /// statement. Switch statement body is always indented one level more than
-  /// case labels.
+  /// case labels (except the first block following the case label, which

[clang] ea2be45 - [clang-format] Expand the SpacesAroundConditions option to include catch statements

2020-01-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-01-19T15:56:04Z
New Revision: ea2be452542c81b04621e26c0d5e83be565f07e2

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

LOG: [clang-format] Expand the SpacesAroundConditions option to include catch 
statements

Summary: This diff expands the SpacesAroundConditions option added in D68346 to 
include adding spaces to catch statements.

Reviewed By: MyDeveloperDay

Patch by: timwoj

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index a8f33e62f994..7dbde9a8d6a8 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2597,7 +2597,7 @@ bool TokenAnnotator::spaceRequiredBeforeParens(const 
FormatToken &Right) const {
 /// otherwise.
 static bool isKeywordWithCondition(const FormatToken &Tok) {
   return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
- tok::kw_constexpr);
+ tok::kw_constexpr, tok::kw_catch);
 }
 
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 43e75dde6806..53d543728fb9 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -14980,6 +14980,7 @@ TEST_F(FormatTest, SpacesInConditionalStatement) {
   verifyFormat("while ( a )\n  return;", Spaces);
   verifyFormat("while ( (a && b) )\n  return;", Spaces);
   verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+  verifyFormat("try {\n} catch ( const std::exception & ) {\n}", Spaces);
   // Check that space on the left of "::" is inserted as expected at beginning
   // of condition.
   verifyFormat("while ( ::func() )\n  return;", Spaces);



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


[PATCH] D72793: [clang-format] Expand the SpacesAroundConditions option to include catch statements

2020-01-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea2be452542c: [clang-format] Expand the 
SpacesAroundConditions option to include catch… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72793

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14980,6 +14980,7 @@
   verifyFormat("while ( a )\n  return;", Spaces);
   verifyFormat("while ( (a && b) )\n  return;", Spaces);
   verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+  verifyFormat("try {\n} catch ( const std::exception & ) {\n}", Spaces);
   // Check that space on the left of "::" is inserted as expected at beginning
   // of condition.
   verifyFormat("while ( ::func() )\n  return;", Spaces);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2597,7 +2597,7 @@
 /// otherwise.
 static bool isKeywordWithCondition(const FormatToken &Tok) {
   return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
- tok::kw_constexpr);
+ tok::kw_constexpr, tok::kw_catch);
 }
 
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14980,6 +14980,7 @@
   verifyFormat("while ( a )\n  return;", Spaces);
   verifyFormat("while ( (a && b) )\n  return;", Spaces);
   verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+  verifyFormat("try {\n} catch ( const std::exception & ) {\n}", Spaces);
   // Check that space on the left of "::" is inserted as expected at beginning
   // of condition.
   verifyFormat("while ( ::func() )\n  return;", Spaces);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2597,7 +2597,7 @@
 /// otherwise.
 static bool isKeywordWithCondition(const FormatToken &Tok) {
   return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
- tok::kw_constexpr);
+ tok::kw_constexpr, tok::kw_catch);
 }
 
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2020-01-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

I need you to rebase this fix, also you need to clang-format it as well. 
Format.h/ContinuationIndenter.cpp and FormatTestObjC.cpp all failed 
clang-format check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926



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


[PATCH] D72998: [IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant

2020-01-19 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Can we, at least, put this constant in a header file so we don't repeat it in 
several places? Also, can we write it as 0x2000 so that it's more obvious 
what the value is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72998



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


[PATCH] D72998: [IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D72998#1828559 , @hfinkel wrote:

> Can we, at least, put this constant in a header file so we don't repeat it in 
> several places?


Remember, we can't use `llvm::Value::MaximumAlignment` itself in clang sema.
Which header do you have in mind?

> Also, can we write it as 0x2000 so that it's more obvious what the value 
> is.

Sure, will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72998



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


[clang] 70b53a3 - Fix gcc `-Wunused-variable` warning. NFC.

2020-01-19 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-01-19T12:24:21-05:00
New Revision: 70b53a301888fe2be36996b41a7dd5aa7c256dc9

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

LOG: Fix gcc `-Wunused-variable` warning. NFC.

Added: 


Modified: 
clang/lib/Serialization/ASTReaderStmt.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp 
b/clang/lib/Serialization/ASTReaderStmt.cpp
index 5dd0ef9d43c3..99dc1e9172c4 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -732,7 +732,7 @@ readConstraintSatisfaction(ASTRecordReader &Record) {
 unsigned NumDetailRecords = Record.readInt();
 for (unsigned i = 0; i != NumDetailRecords; ++i) {
   Expr *ConstraintExpr = Record.readExpr();
-  if (bool IsDiagnostic = Record.readInt()) {
+  if (/* IsDiagnostic */Record.readInt()) {
 SourceLocation DiagLocation = Record.readSourceLocation();
 std::string DiagMessage = Record.readString();
 Satisfaction.Details.emplace_back(
@@ -822,7 +822,7 @@ void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
   Req.emplace();
 } else {
   NoexceptLoc = Record.readSourceLocation();
-  switch (auto returnTypeRequirementKind = Record.readInt()) {
+  switch (/* returnTypeRequirementKind */Record.readInt()) {
 case 0:
   // No return type requirement.
   Req.emplace();
@@ -853,7 +853,7 @@ void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
   std::move(*Req));
   } break;
   case concepts::Requirement::RK_Nested: {
-if (bool IsSubstitutionDiagnostic = Record.readInt()) {
+if (/* IsSubstitutionDiagnostic */Record.readInt()) {
   R = new (Record.getContext()) concepts::NestedRequirement(
   readSubstitutionDiagnostic(Record));
   break;



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


[PATCH] D72982: [Clang] Un-break scan-build after integrated-cc1 change

2020-01-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72982



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


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-01-19 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

The patch looks good. Thanks! I would prefer to see more tests for other 
TypeLoc cases, but I think they could be added in the following patches.
@shafik Shafik, do you have any suggestions for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[PATCH] D73006: [Codegen] If reasonable, materialize clang's `AllocAlignAttr` as llvm's Alignment Attribute on call-site function return value

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, jdoerfert, hfinkel, aaron.ballman, 
rsmith.
lebedev.ri added a project: clang.
lebedev.ri added a parent revision: D73005: [Codegen] If reasonable, 
materialize clang's `AssumeAlignedAttr` as llvm's Alignment Attribute on 
call-site function return value.

Much like with the previous patch (D73005 ) 
with `AssumeAlignedAttr`
handling, results in mildly more readable IR,
and will improve test coverage in upcoming patch.

Note that in `AllocAlignAttr`'s case, there is no requirement
for that alignment parameter to end up being an I-C-E.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73006

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp

Index: clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
===
--- clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
+++ clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
@@ -26,21 +26,22 @@
   // CHECK-NEXT:%[[X_ADDR:.*]] = alloca i8**, align 8
   // CHECK-NEXT:store i8** %[[X]], i8*** %[[X_ADDR]], align 8
   // CHECK-NEXT:%[[X_RELOADED:.*]] = load i8**, i8*** %[[X_ADDR]], align 8
-  // CHECK-NEXT:%[[X_RETURNED:.*]] = call i8** @[[PASSTHROUGH]](i8** %[[X_RELOADED]], i64 2147483648)
-  // CHECK-NEXT:%[[PTRINT:.*]] = ptrtoint i8** %[[X_RETURNED]] to i64
-  // CHECK-NEXT:%[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 2147483647
-  // CHECK-NEXT:%[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-NOSANITIZE-NEXT: %[[X_RETURNED:.*]] = call align 128 i8** @[[PASSTHROUGH]](i8** %[[X_RELOADED]], i64 128)
+  // CHECK-SANITIZE-NEXT:   %[[X_RETURNED:.*]] = call i8** @[[PASSTHROUGH]](i8** %[[X_RELOADED]], i64 128)
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8** %[[X_RETURNED]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 127
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
   // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8** %[[X_RETURNED]] to i64, !nosanitize
   // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
-  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 2147483648, i64 0){{.*}}, !nosanitize
-  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 2147483648, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 128, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 128, i64 0){{.*}}, !nosanitize
   // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
   // CHECK-SANITIZE:  [[CONT]]:
-  // CHECK-NEXT:call void @llvm.assume(i1 %[[MASKCOND]])
+  // CHECK-SANITIZE-NEXT:   call void @llvm.assume(i1 %[[MASKCOND]])
   // CHECK-NEXT:ret i8** %[[X_RETURNED]]
   // CHECK-NEXT:  }
 #line 100
-  return passthrough(x, 0x8000);
+  return passthrough(x, 128);
 }
Index: clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
===
--- clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
+++ clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
@@ -6,10 +6,6 @@
 // CHECK-LABEL: @t0_immediate0(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[CALL:%.*]] = call align 32 i8* @my_aligned_alloc(i32 320, i32 16)
-// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint i8* [[CALL]] to i64
-// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 15
-// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
-// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])

[PATCH] D73005: [Codegen] If reasonable, materialize clang's `AssumeAlignedAttr` as llvm's Alignment Attribute on call-site function return value

2020-01-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, jdoerfert, hfinkel, aaron.ballman, 
rsmith.
lebedev.ri added a project: clang.
lebedev.ri added a child revision: D73006: [Codegen] If reasonable, materialize 
clang's `AllocAlignAttr` as llvm's Alignment Attribute on call-site function 
return value.
lebedev.ri added a parent revision: D72998: [IR] Attribute/AttrBuilder: use 
Value::MaximumAlignment magic constant.

This should be mostly NFC - we still lower the same alignment
knowledge to the IR. The main reasoning here is that
this somewhat improves readability of IR like this,
and will improve test coverage in upcoming patch.

Even though the alignment is guaranteed to always be an I-C-E,
we don't always materialize it as llvm's Alignment Attribute because:

1. There may be a non-zero offset
2. We may be sanitizing for alignment

Note that if there already was an IR alignment attribute
on return value, we union them, and thus the alignment
only ever rises.

Also, there is a second relevant clang attribute `AllocAlignAttr`,
so that is why `AbstractAssumeAlignedAttrEmitter` is templated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73005

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp

Index: clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
===
--- clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
+++ clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
@@ -6,7 +6,7 @@
 // CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char **'\00" }
 // CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}* @[[CHAR]] }
 
-char **__attribute__((assume_aligned(0x8000))) passthrough(char **x) {
+char **__attribute__((assume_aligned(128))) passthrough(char **x) {
   // CHECK:  define i8** @[[PASSTHROUGH:.*]](i8** %[[X:.*]])
   // CHECK-NEXT: entry:
   // CHECK-NEXT:   %[[X_ADDR:.*]] = alloca i8**, align 8
@@ -23,19 +23,20 @@
   // CHECK-NEXT:%[[X_ADDR]] = alloca i8**, align 8
   // CHECK-NEXT:store i8** %[[X]], i8*** %[[X_ADDR]], align 8
   // CHECK-NEXT:%[[X_RELOADED:.*]] = load i8**, i8*** %[[X_ADDR]], align 8
-  // CHECK-NEXT:%[[X_RETURNED:.*]] = call i8** @[[PASSTHROUGH]](i8** %[[X_RELOADED]])
-  // CHECK-NEXT:%[[PTRINT:.*]] = ptrtoint i8** %[[X_RETURNED]] to i64
-  // CHECK-NEXT:%[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 2147483647
-  // CHECK-NEXT:%[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-NOSANITIZE-NEXT: %[[X_RETURNED:.*]] = call align 128 i8** @[[PASSTHROUGH]](i8** %[[X_RELOADED]])
+  // CHECK-SANITIZE-NEXT:   %[[X_RETURNED:.*]] = call i8** @[[PASSTHROUGH]](i8** %[[X_RELOADED]])
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8** %[[X_RETURNED]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 127
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
   // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8** %[[X_RETURNED]] to i64, !nosanitize
   // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
-  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 2147483648, i64 0){{.*}}, !nosanitize
-  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 2147483648, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 128, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 128, i64 0){{.*}}, !nosanitize
   // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
   // CHECK-SANITIZE:  [[CONT]]:
-  // CHECK-NEXT:  

[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-19 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: rsmith, rtrieu, aaron.ballman, xbolva00.
Mordante added a project: clang.

When Wrange-loop-analysis issues a diagnostic on a dependent type in a template 
the diagnostic may not be valid for all instantiations. Therefore the 
diagnostic is suppressed during the instantiation. Non dependent types still 
issue a diagnostic.

The same can happen when using macros. Therefore the diagnostic is disabled for 
macros.

Fixes https://bugs.llvm.org/show_bug.cgi?id=44556


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73007

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/warn-range-loop-analysis.cpp

Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -454,3 +454,75 @@
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
+
+template 
+void test_template_function() {
+  // In a template instantiation the diagnostics should not be emitted for
+  // loops with dependent types.
+  Container C;
+  for (const Bar &x : C) {}
+  // expected-warning@-1 {{always a copy}}
+  // expected-note@-2 {{'Bar'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
+
+  Container Dependent;
+  for (const T &x : Dependent) {}
+}
+template void test_template_function();
+
+template 
+struct test_template_struct {
+  static void static_member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+
+Container Dependent;
+for (const T &x : Dependent) {}
+  }
+
+  void member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+
+Container Dependent;
+for (const T &x : Dependent) {}
+  }
+};
+template struct test_template_struct;
+
+struct test_struct_with_templated_member {
+  void member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+  }
+
+  template 
+  void template_member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+
+Container Dependent;
+for (const T &x : Dependent) {}
+  }
+};
+template void test_struct_with_templated_member::template_member();
+
+#define TEST_MACRO\
+  void test_macro() { \
+Container C; \
+for (const Bar &x : C) {} \
+  }
+
+TEST_MACRO
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2838,6 +2838,9 @@
 ///Suggest "const foo &x" to prevent the copy.
 static void DiagnoseForRangeVariableCopies(Sema &SemaRef,
const CXXForRangeStmt *ForStmt) {
+  if (SemaRef.inTemplateInstantiation())
+return;
+
   if (SemaRef.Diags.isIgnored(diag::warn_for_range_const_reference_copy,
   ForStmt->getBeginLoc()) &&
   SemaRef.Diags.isIgnored(diag::warn_for_range_variable_always_copy,
@@ -2860,6 +2863,9 @@
   if (!InitExpr)
 return;
 
+  if (InitExpr->getExprLoc().isMacroID())
+return;
+
   if (VariableType->isReferenceType()) {
 DiagnoseForRangeReferenceVariableCopies(SemaRef, VD,
 ForStmt->getRangeInit()->getType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72793: [clang-format] Expand the SpacesAroundConditions option to include catch statements

2020-01-19 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj added a comment.

I know that 10.0 was branch recently. Any chance this can make it over?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72793



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


[PATCH] D50360: [Concepts] Requires Expressions

2020-01-19 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D50360#1828329 , @thakis wrote:

> Doesn't this still break check-clang everywhere? See e.g. 
> http://45.33.8.238/linux/7860/step_7.txt


It looks like this is some incremental build issue; after a clean build 
everything's happy. I'll see if I can repro which sequence of builds gets me in 
the bad state, but it's possibly unrelated to this CL. If that changes, I'll 
comment here again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50360



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


[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2020-01-19 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

I proposed D73007  as fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68912



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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-19 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

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

{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-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-19 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 added a comment.

> Do you have any reason to believe these patches would reduce the size of the 
> debug info? It seems like they only add more debug info, and don't remove 
> anything - so we'd expect an increase in the size, certainly not a decrease. 
> That means, to me, there's probably a mistake in the measurement somehow?

Yes, In clang binary DW_AT_linkage_name attribute is missing for "None" and 
"__default_lock_policy" two variable because of that size is reduced. For that 
fixed files are updated.
Now size is same with and without D71451  and 
D71599 .


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

https://reviews.llvm.org/D71451



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


[clang] a7818e6 - fix doc typos to cycle bots

2020-01-19 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-01-19T18:13:08-05:00
New Revision: a7818e6f29c136bfe60ce7af0ac3c35b5d9da7d6

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

LOG: fix doc typos to cycle bots

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index dd2365e873fd..f39bf1f7b2b8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -439,7 +439,7 @@ optin.cplusplus.UninitializedObject (C++)
 This checker reports uninitialized fields in objects created after a 
constructor
 call. It doesn't only find direct uninitialized fields, but rather makes a deep
 inspection of the object, analyzing all of it's fields subfields.
-The checker regards inherited fields as direct fields, so one will recieve
+The checker regards inherited fields as direct fields, so one will receive
 warnings for uninitialized inherited data members as well.
 
 .. code-block:: cpp
@@ -525,7 +525,7 @@ This checker has several options which can be set from 
command line (e.g.
   objects that don't have at least one initialized field. Defaults to false.
 
 * ``NotesAsWarnings``  (boolean). If set to true, the checker will emit a
-  warning for each uninitalized field, as opposed to emitting one warning per
+  warning for each uninitialized field, as opposed to emitting one warning per
   constructor call, and listing the uninitialized fields that belongs to it in
   notes. *Defaults to false*.
 



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


[clang] 13fa4e2 - PR42108 Consistently diagnose binding a reference template parameter to

2020-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-19T18:16:36-08:00
New Revision: 13fa4e2e5ae6ab5403be19e24415e0c7a5569681

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

LOG: PR42108 Consistently diagnose binding a reference template parameter to
a temporary.

We previously failed to materialize a temporary when performing an
implicit conversion to a reference type, resulting in our thinking the
argument was a value rather than a reference in some cases.

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 192c237b6c1c..b609bd904cee 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3866,7 +3866,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
 ICS.DiagnoseAmbiguousConversion(*this, From->getExprLoc(),
   PDiag(diag::err_typecheck_ambiguous_condition)
 << From->getSourceRange());
- return ExprError();
+return ExprError();
 
   case ImplicitConversionSequence::EllipsisConversion:
 llvm_unreachable("Cannot perform an ellipsis conversion");
@@ -4349,6 +4349,16 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
  VK_RValue, nullptr, CCK).get();
   }
 
+  // Materialize a temporary if we're implicitly converting to a reference
+  // type. This is not required by the C++ rules but is necessary to maintain
+  // AST invariants.
+  if (ToType->isReferenceType() && From->isRValue()) {
+ExprResult Res = TemporaryMaterializationConversion(From);
+if (Res.isInvalid())
+  return ExprError();
+From = Res.get();
+  }
+
   // If this conversion sequence succeeded and involved implicitly converting a
   // _Nullable type to a _Nonnull one, complain.
   if (!isCast(CCK))

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 661a66246a53..2d87e7b367f3 100755
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6670,7 +6670,7 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
   // -- a predefined __func__ variable
   APValue::LValueBase Base = Value.getLValueBase();
   auto *VD = const_cast(Base.dyn_cast());
-  if (Base && !VD) {
+  if (Base && (!VD || isa(VD))) {
 auto *E = Base.dyn_cast();
 if (E && isa(E)) {
   Converted = TemplateArgument(ArgResult.get()->IgnoreImpCasts());

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
index 7232598215ac..253ad7bc5606 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -434,3 +434,17 @@ namespace VoidPtr {
   int n;
   template void f<(void*)&n>();
 }
+
+namespace PR42108 {
+  struct R {};
+  struct S { constexpr S() {} constexpr S(R) {} };
+  struct T { constexpr operator S() { return {}; } };
+  template  struct A {};
+  void f() {
+A(); // expected-error {{would bind reference to a temporary}}
+A(); // expected-error {{non-type template argument is not a constant 
expression}} expected-note 2{{temporary}}
+// FIXME: We could diagnose this better if we treated this as not binding
+// directly. It's unclear whether that's the intent.
+A(); // expected-error {{non-type template argument is not a constant 
expression}} expected-note 2{{temporary}}
+  }
+}



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


[clang] add2b7e - List implicit operator== after implicit destructors in a vtable.

2020-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-19T18:31:36-08:00
New Revision: add2b7e44ada46f30715b5c48823a9e9e317e0c3

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

LOG: List implicit operator== after implicit destructors in a vtable.

Summary:
We previously listed first declared members, then implicit operator=,
then implicit operator==, then implicit destructors. Per discussion on
https://github.com/itanium-cxx-abi/cxx-abi/issues/88, put the implicit
equality comparison operators at the very end, after all special member
functions.

Reviewers: rjmccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGenCXX/virtual-compare.cpp

Modified: 
clang/lib/AST/VTableBuilder.cpp

Removed: 




diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 2b5b74be5961..0bff976905fc 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -1474,11 +1474,11 @@ void ItaniumVTableBuilder::AddMethods(
   llvm_unreachable("Found a duplicate primary base!");
   }
 
-  const CXXDestructorDecl *ImplicitVirtualDtor = nullptr;
-
   typedef llvm::SmallVector NewVirtualFunctionsTy;
   NewVirtualFunctionsTy NewVirtualFunctions;
 
+  llvm::SmallVector NewImplicitVirtualFunctions;
+
   // Now go through all virtual member functions and add them.
   for (const auto *MD : RD->methods()) {
 if (!MD->isVirtual())
@@ -1542,24 +1542,30 @@ void ItaniumVTableBuilder::AddMethods(
   }
 }
 
-if (const CXXDestructorDecl *DD = dyn_cast(MD)) {
-  if (MD->isImplicit()) {
-// Itanium C++ ABI 2.5.2:
-//   If a class has an implicitly-defined virtual destructor,
-//   its entries come after the declared virtual function pointers.
-
-assert(!ImplicitVirtualDtor &&
-   "Did already see an implicit virtual dtor!");
-ImplicitVirtualDtor = DD;
-continue;
-  }
-}
-
-NewVirtualFunctions.push_back(MD);
-  }
-
-  if (ImplicitVirtualDtor)
-NewVirtualFunctions.push_back(ImplicitVirtualDtor);
+if (MD->isImplicit())
+  NewImplicitVirtualFunctions.push_back(MD);
+else
+  NewVirtualFunctions.push_back(MD);
+  }
+
+  std::stable_sort(
+  NewImplicitVirtualFunctions.begin(), NewImplicitVirtualFunctions.end(),
+  [](const CXXMethodDecl *A, const CXXMethodDecl *B) {
+if (A->isCopyAssignmentOperator() != B->isCopyAssignmentOperator())
+  return A->isCopyAssignmentOperator();
+if (A->isMoveAssignmentOperator() != B->isMoveAssignmentOperator())
+  return A->isMoveAssignmentOperator();
+if (isa(A) != isa(B))
+  return isa(A);
+assert(A->getOverloadedOperator() == OO_EqualEqual &&
+   B->getOverloadedOperator() == OO_EqualEqual &&
+   "unexpected or duplicate implicit virtual function");
+// We rely on Sema to have declared the operator== members in the
+// same order as the corresponding operator<=> members.
+return false;
+  });
+  NewVirtualFunctions.append(NewImplicitVirtualFunctions.begin(),
+ NewImplicitVirtualFunctions.end());
 
   for (const CXXMethodDecl *MD : NewVirtualFunctions) {
 // Get the final overrider.

diff  --git a/clang/test/CodeGenCXX/virtual-compare.cpp 
b/clang/test/CodeGenCXX/virtual-compare.cpp
new file mode 100644
index ..6ffbe8eb86ae
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-compare.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -triple %itanium_abi_triple -emit-llvm %s -o - | 
FileCheck %s
+
+#include "Inputs/std-compare.h"
+
+// CHECK: @_ZTV1A =
+struct A;
+struct X {
+  // CHECK-SAME: @_ZN1X1xEv
+  virtual void x();
+  friend auto operator<=>(X, X) = default;
+};
+struct Y {
+  virtual ~Y();
+  virtual A &operator=(const A &);
+  friend auto operator<=>(Y, Y) = default;
+};
+struct A : X, Y {
+  // CHECK-SAME: @_ZN1A1fEv
+  virtual void f();
+  // CHECK-SAME: @_ZNKR1AssERKS_
+  virtual std::strong_ordering operator<=>(const A &) const & = default;
+  // CHECK-SAME: @_ZN1A1gEv
+  virtual void g();
+  // CHECK-SAME: @_ZNKO1AssERKS_
+  virtual std::strong_ordering operator<=>(const A &) const && = default;
+  // CHECK-SAME: @_ZN1A1hEv
+  virtual void h();
+
+  // CHECK-SAME: @_ZN1AaSERKS_
+  // implicit virtual A &operator=(const A&) = default;
+
+  // CHECK-SAME: @_ZN1AD1Ev
+  // CHECK-SAME: @_ZN1AD0Ev
+  // implicit virtual ~A();
+
+  // CHECK-SAME: @_ZNKR1AeqERKS_
+  // implicit virtual A &operator==(const A&) const & = default;
+
+  // CHECK-SAME: @_ZNKO1AeqERKS_
+  // implicit virtual A &operator==(const A&) const && = default;
+};
+
+// For Y:
+// CHECK-SAME: @_ZTI1A
+
+// CHECK-SAME: @_ZThn8_N1AD1Ev
+// CHEC

[clang] 7a9fa76 - Undo changes to release notes intended for the Clang 10 branch, not master.

2020-01-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-19T18:33:42-08:00
New Revision: 7a9fa76be7425b5a6fb3dfe7fc4f9e16892628cb

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

LOG: Undo changes to release notes intended for the Clang 10 branch, not master.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 76a1d748b604..6219d6b072cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -57,15 +57,6 @@ Non-comprehensive list of changes in this release
 -
 
 
-* Lax vector conversions involving floating-point vectors have been disabled
-  by default, and can no longer be enabled with ``-flax-vector-conversions``.
-  This matches the behavior of these flags in GCC, but code relying on implicit
-  vector bitcasts between integer and floating-point types that used to compile
-  with older versions of Clang is no longer accepted by default in Clang 10.
-  The old behavior can be restored with ``-flax-vector-conversions=all``.
-  In a future release of Clang, we intend to change the default to
-  ``-fno-lax-vector-conversions``.
-
 New Compiler Flags
 --
 
@@ -82,21 +73,6 @@ Modified Compiler Flags
 ---
 
 
-- ``-flax-vector-conversions`` has been split into three 
diff erent levels of
-  laxness:
-
-  - ``-flax-vector-conversions=all``: This is Clang's historical default, and
-permits implicit vector conversions (performed as bitcasts) between any
-two vector types of the same overall bit-width.
-
-  - ``-flax-vector-conversions=integer``: This is Clang's current default,
-and permits implicit vector conversions (performed as bitcasts) between
-any two integer vector types of the same overall bit-width.
-Synonym: ``-flax-vector-conversions``.
-
-  - ``-flax-vector-conversions=none``: Do not perform any implicit bitcasts
-between vector types. Synonym: ``-fno-lax-vector-conversions``.
-
 New Pragmas in Clang
 
 



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


[PATCH] D72897: List implicit operator== after implicit destructors in a vtable.

2020-01-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGadd2b7e44ada: List implicit operator== after implicit 
destructors in a vtable. (authored by rsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72897

Files:
  clang/lib/AST/VTableBuilder.cpp
  clang/test/CodeGenCXX/virtual-compare.cpp

Index: clang/test/CodeGenCXX/virtual-compare.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/virtual-compare.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/std-compare.h"
+
+// CHECK: @_ZTV1A =
+struct A;
+struct X {
+  // CHECK-SAME: @_ZN1X1xEv
+  virtual void x();
+  friend auto operator<=>(X, X) = default;
+};
+struct Y {
+  virtual ~Y();
+  virtual A &operator=(const A &);
+  friend auto operator<=>(Y, Y) = default;
+};
+struct A : X, Y {
+  // CHECK-SAME: @_ZN1A1fEv
+  virtual void f();
+  // CHECK-SAME: @_ZNKR1AssERKS_
+  virtual std::strong_ordering operator<=>(const A &) const & = default;
+  // CHECK-SAME: @_ZN1A1gEv
+  virtual void g();
+  // CHECK-SAME: @_ZNKO1AssERKS_
+  virtual std::strong_ordering operator<=>(const A &) const && = default;
+  // CHECK-SAME: @_ZN1A1hEv
+  virtual void h();
+
+  // CHECK-SAME: @_ZN1AaSERKS_
+  // implicit virtual A &operator=(const A&) = default;
+
+  // CHECK-SAME: @_ZN1AD1Ev
+  // CHECK-SAME: @_ZN1AD0Ev
+  // implicit virtual ~A();
+
+  // CHECK-SAME: @_ZNKR1AeqERKS_
+  // implicit virtual A &operator==(const A&) const & = default;
+
+  // CHECK-SAME: @_ZNKO1AeqERKS_
+  // implicit virtual A &operator==(const A&) const && = default;
+};
+
+// For Y:
+// CHECK-SAME: @_ZTI1A
+
+// CHECK-SAME: @_ZThn8_N1AD1Ev
+// CHECK-SAME: @_ZThn8_N1AD0Ev
+// virtual ~Y();
+
+// CHECK-SAME: @_ZThn8_N1AaSERKS_
+// virtual A &operator=(const A &);
+
+void A::f() {}
Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -1474,11 +1474,11 @@
   llvm_unreachable("Found a duplicate primary base!");
   }
 
-  const CXXDestructorDecl *ImplicitVirtualDtor = nullptr;
-
   typedef llvm::SmallVector NewVirtualFunctionsTy;
   NewVirtualFunctionsTy NewVirtualFunctions;
 
+  llvm::SmallVector NewImplicitVirtualFunctions;
+
   // Now go through all virtual member functions and add them.
   for (const auto *MD : RD->methods()) {
 if (!MD->isVirtual())
@@ -1542,24 +1542,30 @@
   }
 }
 
-if (const CXXDestructorDecl *DD = dyn_cast(MD)) {
-  if (MD->isImplicit()) {
-// Itanium C++ ABI 2.5.2:
-//   If a class has an implicitly-defined virtual destructor,
-//   its entries come after the declared virtual function pointers.
-
-assert(!ImplicitVirtualDtor &&
-   "Did already see an implicit virtual dtor!");
-ImplicitVirtualDtor = DD;
-continue;
-  }
-}
-
-NewVirtualFunctions.push_back(MD);
-  }
-
-  if (ImplicitVirtualDtor)
-NewVirtualFunctions.push_back(ImplicitVirtualDtor);
+if (MD->isImplicit())
+  NewImplicitVirtualFunctions.push_back(MD);
+else
+  NewVirtualFunctions.push_back(MD);
+  }
+
+  std::stable_sort(
+  NewImplicitVirtualFunctions.begin(), NewImplicitVirtualFunctions.end(),
+  [](const CXXMethodDecl *A, const CXXMethodDecl *B) {
+if (A->isCopyAssignmentOperator() != B->isCopyAssignmentOperator())
+  return A->isCopyAssignmentOperator();
+if (A->isMoveAssignmentOperator() != B->isMoveAssignmentOperator())
+  return A->isMoveAssignmentOperator();
+if (isa(A) != isa(B))
+  return isa(A);
+assert(A->getOverloadedOperator() == OO_EqualEqual &&
+   B->getOverloadedOperator() == OO_EqualEqual &&
+   "unexpected or duplicate implicit virtual function");
+// We rely on Sema to have declared the operator== members in the
+// same order as the corresponding operator<=> members.
+return false;
+  });
+  NewVirtualFunctions.append(NewImplicitVirtualFunctions.begin(),
+ NewImplicitVirtualFunctions.end());
 
   for (const CXXMethodDecl *MD : NewVirtualFunctions) {
 // Get the final overrider.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D71451#1828647 , @Jac1494 wrote:

> > Do you have any reason to believe these patches would reduce the size of 
> > the debug info? It seems like they only add more debug info, and don't 
> > remove anything - so we'd expect an increase in the size, certainly not a 
> > decrease. That means, to me, there's probably a mistake in the measurement 
> > somehow?
>
> Yes, In clang binary DW_AT_linkage_name attribute is missing for "None" and 
> "__default_lock_policy" two variable because of that size is reduced. For 
> that fixed files are updated.
>  Now size is same with and without D71451  
> and D71599 .


that still seems very surprising - this change is specifically intended to add 
more debug info, is it not? So do you have any ideas/theories as to why that's 
not showing up in the data?


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

https://reviews.llvm.org/D71451



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-19 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 added a comment.



> that still seems very surprising - this change is specifically intended to 
> add more debug info, is it not? So do you have any ideas/theories as to why 
> that's not showing up in the data?

Yes, In clang and llvm  extern variable are there inside header file ,So that 
it will not add debug info.And in test side only two test 
case(virtual-methods.ll, cl-options.c)  are there which is  using 
"-fstandalone-debug" option and but in this test cases there is no extern 
variable.


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

https://reviews.llvm.org/D71451



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-01-19 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 239026.
void added a comment.

Update so that each MBB has a list of indirect dests of INLINEASM_BR 
instructions.


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

https://reviews.llvm.org/D69868

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/CodeGen/X86/callbr-asm-outputs.ll
  llvm/test/CodeGen/X86/callbr-asm.ll

Index: llvm/test/CodeGen/X86/callbr-asm.ll
===
--- llvm/test/CodeGen/X86/callbr-asm.ll
+++ llvm/test/CodeGen/X86/callbr-asm.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-- -O3 | FileCheck %s
+; RUN: llc < %s -mtriple=i686-- -O3 -verify-machineinstrs | FileCheck %s
 
 ; Tests for using callbr as an asm-goto wrapper
 
@@ -159,3 +159,54 @@
 cleanup:  ; preds = %asm.fallthrough, %quux
   ret void
 }
+
+define i32 @test5(i32 %out1, i32 %out2) {
+; Test 5 - asm-goto with output constraints.
+; CHECK-LABEL: test5:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:  movl $-1, %eax
+; CHECK-NEXT:  movl 4(%esp), %ecx
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  testl %ecx, %ecx
+; CHECK-NEXT:  testl %edx, %ecx
+; CHECK-NEXT:  jne .Ltmp6
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB4_1:
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  testl %ecx, %edx
+; CHECK-NEXT:  testl %ecx, %edx
+; CHECK-NEXT:  jne .Ltmp7
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB4_2:
+; CHECK-NEXT:  addl %edx, %ecx
+; CHECK-NEXT:  movl %ecx, %eax
+; CHECK-NEXT:  retl
+; CHECK-NEXT:  .Ltmp6:
+; CHECK-NEXT:  .LBB4_3:
+; CHECK-NEXT:  movl $-2, %eax
+; CHECK-NEXT:  .Ltmp7:
+; CHECK-NEXT:  .LBB4_4:
+; CHECK-NEXT:  retl
+entry:
+  %0 = callbr { i32, i32 } asm sideeffect "testl $0, $0; testl $1, $2; jne ${3:l}", "=r,=r,r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %out1, i8* blockaddress(@test5, %label_true), i8* blockaddress(@test5, %return))
+  to label %asm.fallthrough [label %label_true, label %return]
+
+asm.fallthrough:  ; preds = %entry
+  %asmresult = extractvalue { i32, i32 } %0, 0
+  %asmresult1 = extractvalue { i32, i32 } %0, 1
+  %1 = callbr { i32, i32 } asm sideeffect "testl $0, $1; testl $2, $3; jne ${5:l}", "=r,=r,r,r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %asmresult, i32 %asmresult1, i8* blockaddress(@test5, %label_true), i8* blockaddress(@test5, %return))
+  to label %asm.fallthrough2 [label %label_true, label %return]
+
+asm.fallthrough2: ; preds = %asm.fallthrough
+  %asmresult3 = extractvalue { i32, i32 } %1, 0
+  %asmresult4 = extractvalue { i32, i32 } %1, 1
+  %add = add nsw i32 %asmresult3, %asmresult4
+  br label %return
+
+label_true:   ; preds = %asm.fallthrough, %entry
+  br label %return
+
+return:   ; preds = %entry, %asm.fallthrough, %label_true, %asm.fallthrough2
+  %retval.0 = phi i32 [ %add, %asm.fallthrough2 ], [ -2, %label_true ], [ -1, %asm.fallthrough ], [ -1, %entry ]
+  ret i32 %retval.0
+}
Index: llvm/test/CodeGen/X86/callbr-asm-outputs.ll
===
--- llvm/test/CodeGen/X86/callbr-asm-outputs.ll
+++ llvm/test/CodeGen/X86/callbr-asm-outputs.ll
@@ -1,18 +1,118 @@
-; RUN: not llc -mtriple=i686-- < %s 2> %t
-; RUN: FileCheck %s < %t
+; RUN: llc -mtriple=i686-- -verify-machineinstrs < %s | FileCheck %s
 
-; CHECK: error: asm-goto outputs not supported
+; A test for asm-goto output
 
-; A test for asm-goto output prohibition
-
-define i32 @test(i32 %a) {
+; CHECK-LABEL: test1:
+; CHECK:   movl 4(%esp), %eax
+; CHECK-NEXT:  addl $4, %eax
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  xorl %eax, %eax
+; CHECK-NEXT:  jmp .Ltmp0
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB0_1:
+; CHECK-NEXT:  retl
+; CHECK-NEXT:  .Ltmp0:
+define i32 @test1(i32 %x) {
 entry:
-  %0 = add i32 %a, 4
-  %1 = callbr i32 asm "xorl $1, $1; jmp ${1:l}", "=&r,r,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@test, %fail)) to label %normal [label %fail]
+  %add = add nsw i32 %x, 4
+  %ret = callbr i32 asm "xorl $1, $0; jmp ${2:l}", "=r,r,X,~{dirflag},~{fpsr},~{flags}"(i32 %add, i8* blockaddress(@test1, %abnormal))
+  to label %normal [label %abnormal]
 
 normal:
-  ret i32 %1
+  ret i32 %ret
 
-fail:
+abnormal:
   ret i32 1
 }
+
+; CHECK-LABEL: test2:
+; CHECK:   # %bb.1: # %if.then
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  testl %esi, %esi
+; CHECK-NEXT:  testl %edi, %esi
+; CHECK-NEXT:  jne .Ltmp1
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB1_2:
+; CHECK-NEXT:  jmp .LBB1_4
+; CHECK-

[PATCH] D69475: [clang] Provide better fix-it on exception spec error

2020-01-19 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule added a comment.

Kindly ping reviewer.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69475



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


[PATCH] D69282: [RFC] Add a VCS conflict marker format printing on tooling::ReplacementError

2020-01-19 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule added a comment.

Kindly ping reviewers.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69282



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


[PATCH] D71980: [clang-tidy] Disable Checks on If constexpr statements in template Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements

2020-01-19 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D71980#1810086 , @njames93 wrote:

> Is this good to land and if so anyone able to commit?


I marked this patch for porting into the release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71980



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


[PATCH] D72793: [clang-format] Expand the SpacesAroundConditions option to include catch statements

2020-01-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: hans.
MyDeveloperDay added a comment.

In D72793#1828625 , @timwoj wrote:

> I know that 10.0 was branch recently. Any chance this can make it over?


I don't personally ever do this because I only use the snapshot builds. I think 
if you need it in 10 then you need to ask @hans what the process is and how 
they decide what makes it in?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72793



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