[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 221210.
plotfi marked an inline comment as done.
plotfi added a comment.

fixed comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978

Files:
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Phases.h
  clang/include/clang/Driver/ToolChain.h
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Phases.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.h
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/class-template-specialization.cpp
  clang/test/InterfaceStubs/externstatic.c
  clang/test/InterfaceStubs/function-template-specialization.cpp
  clang/test/InterfaceStubs/hidden-class-inheritance.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/object.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/virtual.cpp
  clang/test/InterfaceStubs/visibility.cpp
  clang/test/InterfaceStubs/weak.cpp

Index: clang/test/InterfaceStubs/weak.cpp
===
--- clang/test/InterfaceStubs/weak.cpp
+++ clang/test/InterfaceStubs/weak.cpp
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -o - -emit-interface-stubs %s | \
 // RUN: FileCheck %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
Index: clang/test/InterfaceStubs/visibility.cpp
===
--- clang/test/InterfaceStubs/visibility.cpp
+++ clang/test/InterfaceStubs/visibility.cpp
@@ -1,26 +1,20 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 -fvisibility=hidden \
-// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+// RUN: -c -fvisibility=hidden %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 -fvisibility=hidden \
-// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+// RUN: -c -fvisibility=hidden %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD2 %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD2 %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-readelf -s - 2>&1 | \
Index: clang/test/InterfaceStubs/virtual.cpp
===
--- clang/test/InterfaceStubs/virtual.cpp
+++ clang/test/InterfaceStubs/virtual.cpp
@@ -1,9 +1,7 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck -check-prefix=CHECK-TAPI %s
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck -check-prefix=CHECK-TAPI2 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \
 // RUN: llvm-readelf -s - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
Index: clang/test/InterfaceStubs/template-namespace-function.cpp

[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked 7 inline comments as done.
plotfi added inline comments.



Comment at: clang/lib/Driver/Types.cpp:328
+IfsModePhaseList, std::back_inserter(P), [&DAL](phases::ID Phase) {
+  return Phase <= ((DAL.getLastArg(options::OPT_c)) ? phases::Compile
+: 
phases::IfsMerge);

compnerd wrote:
> How does `-c` `-emit-interface-stubs` and multiple input play together?
Dropped the code for -c. For now, to get the straight up ifs I think -cc1 can 
be sufficient.

There are some hairy things regarding getting the correct InputType from 
Driver::BuildInputs that need to be sorted first. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978



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


[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:15
+
+void tools::ifstool::Merger::ConstructJob(Compilation &C, const JobAction &JA,
+  const InputInfo &Output,

compnerd wrote:
> Why not:
> 
> ```
> namespace tools {
> namespace ifstool {
> ```
I could do that, but it would have to be:
```

namespace clang {
namespace driver {
namespace tools {
namespace ifstool {
...
} // namespace ifstool
} // namespace tools
} // namespace driver
} // namespace clang
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978



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


[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2019-09-22 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

ping @rsmith


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

https://reviews.llvm.org/D63960



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


r372495 - Move classes into anonymous namespaces. NFC.

2019-09-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Sep 22 02:28:47 2019
New Revision: 372495

URL: http://llvm.org/viewvc/llvm-project?rev=372495&view=rev
Log:
Move classes into anonymous namespaces. NFC.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=372495&r1=372494&r2=372495&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sun Sep 22 02:28:47 
2019
@@ -662,8 +662,6 @@ private:
   void reportLeak(SymbolRef Sym, ExplodedNode *N, CheckerContext &C) const;
 };
 
-} // end anonymous namespace
-
 
//===--===//
 // Definition of MallocBugVisitor.
 
//===--===//
@@ -793,6 +791,8 @@ private:
   };
 };
 
+} // end anonymous namespace
+
 // A map from the freed symbol to the symbol representing the return value of
 // the free function.
 REGISTER_MAP_WITH_PROGRAMSTATE(FreeReturnValue, SymbolRef, SymbolRef)


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


r372497 - Clang-format: Add Whitesmiths indentation style

2019-09-22 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Sun Sep 22 05:00:34 2019
New Revision: 372497

URL: http://llvm.org/viewvc/llvm-project?rev=372497&view=rev
Log:
Clang-format: Add Whitesmiths indentation style

Summary:
This patch adds support for the Whitesmiths indentation style to clang-format. 
It’s an update to a patch submitted in 2015 (D6833), but reworks it to use the 
newer API.

There are still some issues with this patch, primarily around `switch` and 
`case` support. The added unit test won’t currently pass because of the 
remaining issues.

Reviewers: mboehme, MyDeveloperDay, djasper

Reviewed By: MyDeveloperDay

Subscribers: krasimir, MyDeveloperDay, echristo, cfe-commits

Patch By: @timwoj (Tim Wojtulewicz)

Tags: #clang

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=372497&r1=372496&r2=372497&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Sun Sep 22 05:00:34 2019
@@ -1128,6 +1128,34 @@ the configuration (without a prefix: ``A
 B
   };
 
+  * ``BS_Whitesmiths`` (in configuration: ``Whitesmiths``)
+Like ``Allman`` but always indent braces and line up code with braces.
+
+.. code-block:: c++
+
+  try
+{
+foo();
+}
+  catch ()
+{
+}
+  void foo() { bar(); }
+  class foo
+{
+};
+  if (foo())
+{
+}
+  else
+{
+}
+  enum X : int
+{
+A,
+B
+};
+
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to
 braces of control statements, not to those of class, function

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=372497&r1=372496&r2=372497&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Sun Sep 22 05:00:34 2019
@@ -733,6 +733,32 @@ struct FormatStyle {
 /// B
 ///   };
 /// \endcode
+BS_Whitesmiths,
+/// Like ``Allman`` but always indent braces and line up code with braces.
+/// \code
+///try
+/// {
+/// foo();
+/// }
+///   catch ()
+/// {
+/// }
+///   void foo() { bar(); }
+///   class foo
+/// {
+/// };
+///   if (foo())
+/// {
+/// }
+///   else
+/// {
+/// }
+///   enum X : int
+/// {
+/// A,
+/// B
+/// };
+/// \endcode
 BS_GNU,
 /// Like ``Attach``, but break before functions.
 /// \code

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=372497&r1=372496&r2=372497&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Sun Sep 22 05:00:34 2019
@@ -931,6 +931,11 @@ unsigned ContinuationIndenter::getNewLin
 return std::max(State.Stack.back().LastSpace,
 State.Stack.back().Indent + Style.ContinuationIndentWidth);
 
+  if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
+  State.Line->First->is(tok::kw_enum))
+return (Style.IndentWidth * State.Line->First->IndentLevel) +
+   Style.IndentWidth;
+
   if (NextNonComment->is(tok::l_brace) && NextNonComment->BlockKind == 
BK_Block)
 return Current.NestingLevel == 0 ? State.FirstIndent
  : State.Stack.back().Indent;

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=372497&r1=372496&r2=372497&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sun Sep 22 05:00:34 2019
@@ -165,6 +165,7 @@ template <> struct ScalarEnumerationTrai
 IO.enumCase(Value, "Mozilla", FormatStyle::BS_Mozilla);
 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup);
 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman);
+IO.enumCase(Value, "Whitesmiths", FormatStyle::BS_Whitesmiths);
 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU);
 IO.enumCase(V

[PATCH] D67627: Clang-format: Add Whitesmiths indentation style

2019-09-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372497: Clang-format: Add Whitesmiths indentation style 
(authored by paulhoad, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67627?vs=220610&id=221212#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67627

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -165,6 +165,7 @@
 IO.enumCase(Value, "Mozilla", FormatStyle::BS_Mozilla);
 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup);
 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman);
+IO.enumCase(Value, "Whitesmiths", FormatStyle::BS_Whitesmiths);
 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU);
 IO.enumCase(Value, "WebKit", FormatStyle::BS_WebKit);
 IO.enumCase(Value, "Custom", FormatStyle::BS_Custom);
@@ -657,6 +658,19 @@
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 break;
+  case FormatStyle::BS_Whitesmiths:
+Expanded.BraceWrapping.AfterCaseLabel = true;
+Expanded.BraceWrapping.AfterClass = true;
+Expanded.BraceWrapping.AfterControlStatement = true;
+Expanded.BraceWrapping.AfterEnum = true;
+Expanded.BraceWrapping.AfterFunction = true;
+Expanded.BraceWrapping.AfterNamespace = true;
+Expanded.BraceWrapping.AfterObjCDeclaration = true;
+Expanded.BraceWrapping.AfterStruct = true;
+Expanded.BraceWrapping.AfterExternBlock = true;
+Expanded.BraceWrapping.BeforeCatch = true;
+Expanded.BraceWrapping.BeforeElse = true;
+break;
   case FormatStyle::BS_GNU:
 Expanded.BraceWrapping = {true, true, true, true, true, true, true, true,
   true, true, true, true, true, true, true, true};
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -931,6 +931,11 @@
 return std::max(State.Stack.back().LastSpace,
 State.Stack.back().Indent + Style.ContinuationIndentWidth);
 
+  if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
+  State.Line->First->is(tok::kw_enum))
+return (Style.IndentWidth * State.Line->First->IndentLevel) +
+   Style.IndentWidth;
+
   if (NextNonComment->is(tok::l_brace) && NextNonComment->BlockKind == BK_Block)
 return Current.NestingLevel == 0 ? State.FirstIndent
  : State.Stack.back().Indent;
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -1193,6 +1193,12 @@
   if (Newlines)
 Indent = NewlineIndent;
 
+  // If in Whitemsmiths mode, indent start and end of blocks
+  if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths) {
+if (RootToken.isOneOf(tok::l_brace, tok::r_brace, tok::kw_case))
+  Indent += Style.IndentWidth;
+  }
+
   // Preprocessor directives get indented before the hash only if specified
   if (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
   (Line.Type == LT_PreprocessorDirective ||
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -2401,6 +2401,16 @@
"  // something\n"
"}",
Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
+  verifyFormat("try\n"
+   "  {\n"
+   "  // something white\n"
+   "  }\n"
+   "catch (...)\n"
+   "  {\n"
+   "  // something white\n"
+   "  }",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_GNU;
   verifyFormat("try\n"
"  {\n"
@@ -4880,6 +4890,13 @@
"}",
Style);
 
+  Style.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
+  verifyFormat("void someLongFunction(\n"
+   "int someLongParameter) const\n"
+   "  {\n"
+   "  }",
+   Style);
+
   // Unless these are unknown annotations.
   verifyFormat("void SomeFunction(aa aaa,\n"
"  aa 

[PATCH] D67888: [clang-format] NFC clang-format the clang-format unit tests

2019-09-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, owenpan, timwoj.
MyDeveloperDay added a project: clang-tools-extra.
Herald added a project: clang.

It is annoying that the clang-format tests aren't themselves clang-formatted, 
if you use a format on save option in VS or vim this file gets massively 
changed then you have to `git difftool` all the other changes back out, which 
is risky.

I know people don't like mass clang-format changes but sometimes it becomes 
unmanageable to not. There are no other changes here other than just the 
reformat.

clang-format tests all pass.

  [==] 691 tests from 21 test cases ran. (55990 ms total)
  [  PASSED  ] 691 tests.


Repository:
  rC Clang

https://reviews.llvm.org/D67888

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
@@ -165,6 +165,21 @@
"public string Host {\n  set;\n  get;\n}");
 }
 
+TEST_F(FormatTestCSharp, CSharpUsing) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
+  verifyFormat("public void foo() {\n"
+   "  using (StreamWriter sw = new StreamWriter (filenameA)) {}\n"
+   "}",
+   Style);
+
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
+  verifyFormat("public void foo() {\n"
+   "  using(StreamWriter sw = new StreamWriter(filenameB)) {}\n"
+   "}",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpRegions) {
   verifyFormat("#region aaa a "
"aaa long region");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2611,6 +2611,10 @@
 return Style.Language == FormatStyle::LK_JavaScript ||
!Left.TokenText.endswith("=*/");
   if (Right.is(tok::l_paren)) {
+// using (FileStream fs...
+if (Style.isCSharp() && Left.is(tok::kw_using) &&
+Style.SpaceBeforeParens != FormatStyle::SBPO_Never)
+  return true;
 if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
   return true;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -165,6 +165,21 @@
"public string Host {\n  set;\n  get;\n}");
 }
 
+TEST_F(FormatTestCSharp, CSharpUsing) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
+  verifyFormat("public void foo() {\n"
+   "  using (StreamWriter sw = new StreamWriter (filenameA)) {}\n"
+   "}",
+   Style);
+
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
+  verifyFormat("public void foo() {\n"
+   "  using(StreamWriter sw = new StreamWriter(filenameB)) {}\n"
+   "}",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpRegions) {
   verifyFormat("#region aaa a "
"aaa long region");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2611,6 +2611,10 @@
 return Style.Language == FormatStyle::LK_JavaScript ||
!Left.TokenText.endswith("=*/");
   if (Right.is(tok::l_paren)) {
+// using (FileStream fs...
+if (Style.isCSharp() && Left.is(tok::kw_using) &&
+Style.SpaceBeforeParens != FormatStyle::SBPO_Never)
+  return true;
 if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67888: [clang-format] NFC clang-format the clang-format unit tests

2019-09-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 221214.
MyDeveloperDay added a comment.

wrong patch file


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

https://reviews.llvm.org/D67888

Files:
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -29,11 +29,7 @@
 
 class FormatTest : public ::testing::Test {
 protected:
-  enum StatusCheck {
-SC_ExpectComplete,
-SC_ExpectIncomplete,
-SC_DoNotCheck
-  };
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
 
   std::string format(llvm::StringRef Code,
  const FormatStyle &Style = getLLVMStyle(),
@@ -332,13 +328,15 @@
 format("namespace {\n"
"int i;\n"
"\n"
-   "}", LLVMWithNoNamespaceFix));
+   "}",
+   LLVMWithNoNamespaceFix));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
 "}",
 format("namespace {\n"
"int i;\n"
-   "}", LLVMWithNoNamespaceFix));
+   "}",
+   LLVMWithNoNamespaceFix));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
 "\n"
@@ -346,13 +344,15 @@
 format("namespace {\n"
"int i;\n"
"\n"
-   "};", LLVMWithNoNamespaceFix));
+   "};",
+   LLVMWithNoNamespaceFix));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
 "};",
 format("namespace {\n"
"int i;\n"
-   "};", LLVMWithNoNamespaceFix));
+   "};",
+   LLVMWithNoNamespaceFix));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
 "\n"
@@ -903,7 +903,8 @@
   verifyFormat("for (Foo *x = 0; x != in; x++) {\n}");
   verifyFormat("Foo *x;\nfor (x = 0; x != in; x++) {\n}");
   verifyFormat("Foo *x;\nfor (x in y) {\n}");
-  verifyFormat("for (const Foo &baz = in.value(); !baz.at_end(); ++baz) {\n}");
+  verifyFormat(
+  "for (const Foo &baz = in.value(); !baz.at_end(); ++baz) {\n}");
 
   FormatStyle NoBinPacking = getLLVMStyle();
   NoBinPacking.BinPackParameters = false;
@@ -1295,20 +1296,26 @@
"#endif\n"
"}",
Style));
-  EXPECT_EQ("switch (a) {\n" "case 0:\n"
-"  return; // long long long long long long long long long long long long comment\n"
-"  // line\n" "}",
+  EXPECT_EQ("switch (a) {\n"
+"case 0:\n"
+"  return; // long long long long long long long long long long "
+"long long comment\n"
+"  // line\n"
+"}",
 format("switch (a) {\n"
-   "case 0: return; // long long long long long long long long long long long long comment line\n"
+   "case 0: return; // long long long long long long long long "
+   "long long long long comment line\n"
"}",
Style));
   EXPECT_EQ("switch (a) {\n"
 "case 0:\n"
-"  return; /* long long long long long long long long long long long long comment\n"
+"  return; /* long long long long long long long long long long "
+"long long comment\n"
 " line */\n"
 "}",
 format("switch (a) {\n"
-   "case 0: return; /* long long long long long long long long long long long long comment line */\n"
+   "case 0: return; /* long long long long long long long long "
+   "long long long long comment line */\n"
"}",
Style));
   verifyFormat("switch (a) {\n"
@@ -1596,7 +1603,7 @@
 TEST_F(FormatTest, BreakInheritanceStyle) {
   FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle();
   StyleWithInheritanceBreakBeforeComma.BreakInheritanceList =
-  FormatStyle::BILS_BeforeComma;
+  FormatStyle::BILS_BeforeComma;
   verifyFormat("class MyClass : public X {};",
StyleWithInheritanceBreakBeforeComma);
   verifyFormat("class MyClass\n"
@@ -1614,7 +1621,7 @@
 
   FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle();
   StyleWithInheritanceBreakAfterColon.BreakInheritanceList =
-  FormatStyle::BILS_AfterColon;
+  FormatStyle::BILS_AfterColon;
   verifyFormat("class MyClass : public X {};",
StyleWithInheritanceBreakAfterColon);
   verifyFormat("class MyClass : public X, public Y {};",
@@ -1908,8 +1915,7 @@
   // This code is more common than we thought; if we
   // layout this correctly the semicolon will go into
   // its own line, which is undesirable.
-  verifyFormat("namespace {};",
-   LLVMW

[PATCH] D67889: [clang] fixing conditional explicit for out-of-line definition PR42980

2019-09-22 Thread Tyker via Phabricator via cfe-commits
Tyker created this revision.
Tyker added reviewers: rsmith, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

not every read in CXXConstructorDecl::getExplicitSpecifierInternal() was made 
on the canonical declaration.


Repository:
  rC Clang

https://reviews.llvm.org/D67889

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp


Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -717,3 +717,21 @@
 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
 
 }
+
+namespace PR42980 {
+using size_t = decltype(sizeof(0));
+
+struct Str {// expected-note+ {{candidate constructor}}
+  template 
+  explicit(N > 7)// expected-note {{resolved to true}}
+  Str(char const (&str)[N]);
+};
+
+template 
+Str::Str(char const(&str)[N]) { }
+// expected-note@-1 {{candidate constructor}}
+
+Str a = "short";
+Str b = "not so short";// expected-error {{no viable conversion}}
+
+}
\ No newline at end of file
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2555,9 +2555,9 @@
 
   ExplicitSpecifier getExplicitSpecifierInternal() const {
 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
-  return *getCanonicalDecl()->getTrailingObjects();
+  return *getTrailingObjects();
 return ExplicitSpecifier(
-nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit
+nullptr, CXXConstructorDeclBits.IsSimpleExplicit
  ? ExplicitSpecKind::ResolvedTrue
  : ExplicitSpecKind::ResolvedFalse);
   }
@@ -2598,10 +2598,10 @@
  InheritedConstructor Inherited = InheritedConstructor());
 
   ExplicitSpecifier getExplicitSpecifier() {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
   const ExplicitSpecifier getExplicitSpecifier() const {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
 
   /// Return true if the declartion is already resolved to be explicit.


Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -717,3 +717,21 @@
 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
 
 }
+
+namespace PR42980 {
+using size_t = decltype(sizeof(0));
+
+struct Str {// expected-note+ {{candidate constructor}}
+  template 
+  explicit(N > 7)// expected-note {{resolved to true}}
+  Str(char const (&str)[N]);
+};
+
+template 
+Str::Str(char const(&str)[N]) { }
+// expected-note@-1 {{candidate constructor}}
+
+Str a = "short";
+Str b = "not so short";// expected-error {{no viable conversion}}
+
+}
\ No newline at end of file
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2555,9 +2555,9 @@
 
   ExplicitSpecifier getExplicitSpecifierInternal() const {
 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
-  return *getCanonicalDecl()->getTrailingObjects();
+  return *getTrailingObjects();
 return ExplicitSpecifier(
-nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit
+nullptr, CXXConstructorDeclBits.IsSimpleExplicit
  ? ExplicitSpecKind::ResolvedTrue
  : ExplicitSpecKind::ResolvedFalse);
   }
@@ -2598,10 +2598,10 @@
  InheritedConstructor Inherited = InheritedConstructor());
 
   ExplicitSpecifier getExplicitSpecifier() {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
   const ExplicitSpecifier getExplicitSpecifier() const {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
 
   /// Return true if the declartion is already resolved to be explicit.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67508: [RISCV] support mutilib in baremetal environment

2019-09-22 Thread Kuan Hsu Chen via Phabricator via cfe-commits
khchen added a comment.

ping


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

https://reviews.llvm.org/D67508



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


[PATCH] D67385: Pass -mcmodel to LTO plugin

2019-09-22 Thread Kuan Hsu Chen via Phabricator via cfe-commits
khchen added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D67385



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


[PATCH] D67409: [RISCV] enable LTO support, pass some options to linker.

2019-09-22 Thread Kuan Hsu Chen via Phabricator via cfe-commits
khchen added a comment.

ping


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

https://reviews.llvm.org/D67409



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


[PATCH] D67883: [CLANG][BPF] permit any argument type for __builtin_preserve_access_index()

2019-09-22 Thread Alexei Starovoitov via Phabricator via cfe-commits
ast accepted this revision.
ast added a comment.
This revision is now accepted and ready to land.

I tested few different examples. Generated code and relocations look good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67883



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


r372516 - [CLANG][BPF] permit any argument type for __builtin_preserve_access_index()

2019-09-22 Thread Yonghong Song via cfe-commits
Author: yhs
Date: Sun Sep 22 10:33:48 2019
New Revision: 372516

URL: http://llvm.org/viewvc/llvm-project?rev=372516&view=rev
Log:
[CLANG][BPF] permit any argument type for __builtin_preserve_access_index()

Commit c15aa241f821 ("[CLANG][BPF] change __builtin_preserve_access_index()
signature") changed the builtin function signature to
  PointerT __builtin_preserve_access_index(PointerT ptr)
with a pointer type as the argument/return type, where argument and
return types must be the same.

There is really no reason for this constraint. The builtin just
presented a code region so that IR builtins
  __builtin_{array, struct, union}_preserve_access_index
can be applied.

This patch removed the pointer type restriction to permit any
argument type as long as it is permitted by the compiler.

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

Added:
cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtin-preserve-access-index.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=372516&r1=372515&r2=372516&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Sep 22 10:33:48 2019
@@ -2354,13 +2354,13 @@ array subscript access and structure/uni
 under bpf compile-once run-everywhere framework. Debuginfo (typically
 with ``-g``) is needed, otherwise, the compiler will exit with an error.
 The return type for the intrinsic is the same as the type of the
-argument, and must be a pointer type.
+argument.
 
 **Syntax**:
 
 .. code-block:: c
 
-  PointerT __builtin_preserve_access_index(PointerT ptr)
+  type __builtin_preserve_access_index(type arg)
 
 **Example of Use**:
 
@@ -2375,7 +2375,8 @@ argument, and must be a pointer type.
 } c[4];
   };
   struct t *v = ...;
-  const void *pb =__builtin_preserve_access_index(&v->c[3].b);
+  int *pb =__builtin_preserve_access_index(&v->c[3].b);
+  __builtin_preserve_access_index(v->j);
 
 Multiprecision Arithmetic Builtins
 --

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=372516&r1=372515&r2=372516&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Sep 22 10:33:48 
2019
@@ -9916,7 +9916,4 @@ def err_bit_cast_non_trivially_copyable
   "__builtin_bit_cast %select{source|destination}0 type must be trivially 
copyable">;
 def err_bit_cast_type_size_mismatch : Error<
   "__builtin_bit_cast source size does not equal destination size (%0 vs %1)">;
-
-def err_builtin_preserve_access_index_invalid_arg : Error<
-  "__builtin_preserve_access_index argument must a pointer type instead of 
%0">;
 } // end of sema component.

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=372516&r1=372515&r2=372516&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Sep 22 10:33:48 2019
@@ -191,22 +191,12 @@ static bool SemaBuiltinAddressof(Sema &S
   return false;
 }
 
-/// Check the number of arguments and arg type, and set the result type to
+/// Check the number of arguments and set the result type to
 /// the argument type.
 static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall) {
   if (checkArgCount(S, TheCall, 1))
 return true;
 
-  // The argument type must be a pointer
-  ExprResult Arg = TheCall->getArg(0);
-  QualType Ty = Arg.get()->getType();
-  if (!Ty->isPointerType()) {
-S.Diag(Arg.get()->getBeginLoc(),
-   diag::err_builtin_preserve_access_index_invalid_arg)
-<< Ty << Arg.get()->getSourceRange();
-return true;
-  }
-
   TheCall->setType(TheCall->getArg(0)->getType());
   return false;
 }

Added: cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c?rev=372516&view=auto
==
--- cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c (added)
+++ cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c Sun Sep 22 
10:33:48 2019
@@ -0,0 +1,18 @@
+// RUN: %clang -target x86_64 -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x) (__builtin_preserve_access_index(x))
+
+struct s1 {
+  char a;
+  int b[4];
+};
+
+int unit1(struct s1 *arg) 

[PATCH] D67883: [CLANG][BPF] permit any argument type for __builtin_preserve_access_index()

2019-09-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372516: [CLANG][BPF] permit any argument type for 
__builtin_preserve_access_index() (authored by yhs, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67883?vs=221187&id=221220#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67883

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c
  cfe/trunk/test/Sema/builtin-preserve-access-index.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -191,22 +191,12 @@
   return false;
 }
 
-/// Check the number of arguments and arg type, and set the result type to
+/// Check the number of arguments and set the result type to
 /// the argument type.
 static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall) {
   if (checkArgCount(S, TheCall, 1))
 return true;
 
-  // The argument type must be a pointer
-  ExprResult Arg = TheCall->getArg(0);
-  QualType Ty = Arg.get()->getType();
-  if (!Ty->isPointerType()) {
-S.Diag(Arg.get()->getBeginLoc(),
-   diag::err_builtin_preserve_access_index_invalid_arg)
-<< Ty << Arg.get()->getSourceRange();
-return true;
-  }
-
   TheCall->setType(TheCall->getArg(0)->getType());
   return false;
 }
Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -2354,13 +2354,13 @@
 under bpf compile-once run-everywhere framework. Debuginfo (typically
 with ``-g``) is needed, otherwise, the compiler will exit with an error.
 The return type for the intrinsic is the same as the type of the
-argument, and must be a pointer type.
+argument.
 
 **Syntax**:
 
 .. code-block:: c
 
-  PointerT __builtin_preserve_access_index(PointerT ptr)
+  type __builtin_preserve_access_index(type arg)
 
 **Example of Use**:
 
@@ -2375,7 +2375,8 @@
 } c[4];
   };
   struct t *v = ...;
-  const void *pb =__builtin_preserve_access_index(&v->c[3].b);
+  int *pb =__builtin_preserve_access_index(&v->c[3].b);
+  __builtin_preserve_access_index(v->j);
 
 Multiprecision Arithmetic Builtins
 --
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9916,7 +9916,4 @@
   "__builtin_bit_cast %select{source|destination}0 type must be trivially copyable">;
 def err_bit_cast_type_size_mismatch : Error<
   "__builtin_bit_cast source size does not equal destination size (%0 vs %1)">;
-
-def err_builtin_preserve_access_index_invalid_arg : Error<
-  "__builtin_preserve_access_index argument must a pointer type instead of %0">;
 } // end of sema component.
Index: cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c
===
--- cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c
+++ cfe/trunk/test/CodeGen/builtin-preserve-access-index-nonptr.c
@@ -0,0 +1,18 @@
+// RUN: %clang -target x86_64 -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x) (__builtin_preserve_access_index(x))
+
+struct s1 {
+  char a;
+  int b[4];
+};
+
+int unit1(struct s1 *arg) {
+  return _(arg->b[2]);
+}
+// CHECK: define dso_local i32 @unit1
+// CHECK: call [4 x i32]* @llvm.preserve.struct.access.index.p0a4i32.p0s_struct.s1s(%struct.s1* %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S1:[0-9]+]]
+// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0a4i32([4 x i32]* %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[ARRAY:[0-9]+]]
+//
+// CHECK: ![[ARRAY]] = !DICompositeType(tag: DW_TAG_array_type
+// CHECK: ![[STRUCT_S1]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1"
Index: cfe/trunk/test/Sema/builtin-preserve-access-index.c
===
--- cfe/trunk/test/Sema/builtin-preserve-access-index.c
+++ cfe/trunk/test/Sema/builtin-preserve-access-index.c
@@ -4,8 +4,8 @@
   return __builtin_preserve_access_index(&arg[1], 1); // expected-error {{too many arguments to function call, expected 1, have 2}}
 }
 
-const void *invalid2(const int *arg) {
-  return __builtin_preserve_access_index(1); // expected-error {{__builtin_preserve_access_index argument must a pointer type instead of 'int'}}
+int valid2(void) {
+  return __builtin_preserve_access_index(1);
 

[PATCH] D67854: Ensure AtomicExpr goes through SEMA checking after TreeTransform

2019-09-22 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@erichkeane The atomic-expr.cpp test is failing on some MSVC buildbots, please 
can you take a look? 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67854



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


[PATCH] D67719: [clang] [Basic] Enable __has_feature(leak_sanitizer)

2019-09-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D67719



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


r372527 - [clang] [Basic] Enable __has_feature(leak_sanitizer)

2019-09-22 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Sun Sep 22 13:55:01 2019
New Revision: 372527

URL: http://llvm.org/viewvc/llvm-project?rev=372527&view=rev
Log:
[clang] [Basic] Enable __has_feature(leak_sanitizer)

Add a 'leak_sanitizer' feature akin to existing '*_sanitizer' features
to let programmers switch code paths accounting for leak sanitizers
being enabled.

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

Added:
cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
Modified:
cfe/trunk/include/clang/Basic/Features.def

Modified: cfe/trunk/include/clang/Basic/Features.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=372527&r1=372526&r2=372527&view=diff
==
--- cfe/trunk/include/clang/Basic/Features.def (original)
+++ cfe/trunk/include/clang/Basic/Features.def Sun Sep 22 13:55:01 2019
@@ -39,6 +39,8 @@
 FEATURE(address_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))
+FEATURE(leak_sanitizer,
+LangOpts.Sanitize.has(SanitizerKind::Leak))
 FEATURE(hwaddress_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))

Added: cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp?rev=372527&view=auto
==
--- cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp (added)
+++ cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp Sun Sep 22 13:55:01 2019
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=leak %s -o - | FileCheck 
--check-prefix=CHECK-LSAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-LSAN %s
+
+#if __has_feature(leak_sanitizer)
+int LeakSanitizerEnabled();
+#else
+int LeakSanitizerDisabled();
+#endif
+
+// CHECK-LSAN: LeakSanitizerEnabled
+// CHECK-NO-LSAN: LeakSanitizerDisabled


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


[PATCH] D67719: [clang] [Basic] Enable __has_feature(leak_sanitizer)

2019-09-22 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372527: [clang] [Basic] Enable __has_feature(leak_sanitizer) 
(authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67719?vs=221155&id=221238#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67719

Files:
  cfe/trunk/include/clang/Basic/Features.def
  cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp


Index: cfe/trunk/include/clang/Basic/Features.def
===
--- cfe/trunk/include/clang/Basic/Features.def
+++ cfe/trunk/include/clang/Basic/Features.def
@@ -39,6 +39,8 @@
 FEATURE(address_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))
+FEATURE(leak_sanitizer,
+LangOpts.Sanitize.has(SanitizerKind::Leak))
 FEATURE(hwaddress_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
Index: cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
===
--- cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
+++ cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=leak %s -o - | FileCheck 
--check-prefix=CHECK-LSAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-LSAN %s
+
+#if __has_feature(leak_sanitizer)
+int LeakSanitizerEnabled();
+#else
+int LeakSanitizerDisabled();
+#endif
+
+// CHECK-LSAN: LeakSanitizerEnabled
+// CHECK-NO-LSAN: LeakSanitizerDisabled


Index: cfe/trunk/include/clang/Basic/Features.def
===
--- cfe/trunk/include/clang/Basic/Features.def
+++ cfe/trunk/include/clang/Basic/Features.def
@@ -39,6 +39,8 @@
 FEATURE(address_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))
+FEATURE(leak_sanitizer,
+LangOpts.Sanitize.has(SanitizerKind::Leak))
 FEATURE(hwaddress_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
Index: cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
===
--- cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
+++ cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=leak %s -o - | FileCheck --check-prefix=CHECK-LSAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-LSAN %s
+
+#if __has_feature(leak_sanitizer)
+int LeakSanitizerEnabled();
+#else
+int LeakSanitizerDisabled();
+#endif
+
+// CHECK-LSAN: LeakSanitizerEnabled
+// CHECK-NO-LSAN: LeakSanitizerDisabled
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372530 - [clang] fixing conditional explicit for out-of-line definition PR42980

2019-09-22 Thread Gauthier Harnisch via cfe-commits
Author: tyker
Date: Sun Sep 22 14:59:10 2019
New Revision: 372530

URL: http://llvm.org/viewvc/llvm-project?rev=372530&view=rev
Log:
[clang] fixing conditional explicit for out-of-line definition PR42980

Summary: not every read in CXXConstructorDecl::getExplicitSpecifierInternal() 
was made on the canonical declaration.

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372530&r1=372529&r2=372530&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sun Sep 22 14:59:10 2019
@@ -2555,9 +2555,9 @@ class CXXConstructorDecl final
 
   ExplicitSpecifier getExplicitSpecifierInternal() const {
 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
-  return *getCanonicalDecl()->getTrailingObjects();
+  return *getTrailingObjects();
 return ExplicitSpecifier(
-nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit
+nullptr, CXXConstructorDeclBits.IsSimpleExplicit
  ? ExplicitSpecKind::ResolvedTrue
  : ExplicitSpecKind::ResolvedFalse);
   }
@@ -2598,10 +2598,10 @@ public:
  InheritedConstructor Inherited = InheritedConstructor());
 
   ExplicitSpecifier getExplicitSpecifier() {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
   const ExplicitSpecifier getExplicitSpecifier() const {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
 
   /// Return true if the declartion is already resolved to be explicit.

Modified: cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp?rev=372530&r1=372529&r2=372530&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp Sun Sep 22 14:59:10 2019
@@ -717,3 +717,21 @@ A d2{0, 0};
 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
 
 }
+
+namespace PR42980 {
+using size_t = decltype(sizeof(0));
+
+struct Str {// expected-note+ {{candidate constructor}}
+  template 
+  explicit(N > 7)// expected-note {{resolved to true}}
+  Str(char const (&str)[N]);
+};
+
+template 
+Str::Str(char const(&str)[N]) { }
+// expected-note@-1 {{candidate constructor}}
+
+Str a = "short";
+Str b = "not so short";// expected-error {{no viable conversion}}
+
+}
\ No newline at end of file


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


r372531 - [Diagnostics] Warn if ?: with integer constants always evaluates to true

2019-09-22 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Sun Sep 22 15:00:48 2019
New Revision: 372531

URL: http://llvm.org/viewvc/llvm-project?rev=372531&view=rev
Log:
[Diagnostics] Warn if ?: with integer constants always evaluates to true

Extracted from D63082. GCC has this warning under -Wint-in-bool-context, but as 
noted in the D63082's review, we should put it under 
TautologicalConstantCompare.


Added:
cfe/trunk/test/Sema/warn-integer-constants-in-ternary.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=372531&r1=372530&r2=372531&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Sep 22 15:00:48 
2019
@@ -6137,6 +6137,10 @@ def warn_out_of_range_compare : Warning<
   InGroup;
 def warn_tautological_bool_compare : Warning,
   InGroup;
+def warn_integer_constants_in_conditional_always_true : Warning<
+  "converting the result of '?:' with integer constants to a boolean always "
+  "evaluates to 'true'">,
+  InGroup;
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=372531&r1=372530&r2=372531&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Sep 22 15:00:48 2019
@@ -11256,6 +11256,44 @@ static bool isSameWidthConstantConversio
   return true;
 }
 
+static void DiagnoseIntInBoolContext(Sema &S, const Expr *E) {
+  E = E->IgnoreParenImpCasts();
+  SourceLocation ExprLoc = E->getExprLoc();
+
+  if (const auto *CO = dyn_cast(E)) {
+const auto *LHS = dyn_cast(CO->getTrueExpr());
+if (!LHS) {
+  if (auto *UO = dyn_cast(CO->getTrueExpr())) {
+if (UO->getOpcode() == UO_Minus)
+  LHS = dyn_cast(UO->getSubExpr());
+if (!LHS)
+  return;
+  } else {
+return;
+  }
+}
+
+const auto *RHS = dyn_cast(CO->getFalseExpr());
+if (!RHS) {
+  if (auto *UO = dyn_cast(CO->getFalseExpr())) {
+if (UO->getOpcode() == UO_Minus)
+  RHS = dyn_cast(UO->getSubExpr());
+if (!RHS)
+  return;
+  } else {
+return;
+  }
+}
+
+if ((LHS->getValue() == 0 || LHS->getValue() == 1) &&
+(RHS->getValue() == 0 || RHS->getValue() == 1))
+  // Do not diagnose common idioms
+  return;
+if (LHS->getValue() != 0 && LHS->getValue() != 0)
+  S.Diag(ExprLoc, diag::warn_integer_constants_in_conditional_always_true);
+  }
+}
+
 static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
 SourceLocation CC,
 bool *ICContext = nullptr,
@@ -11708,6 +11746,9 @@ static void CheckConditionalOperator(Sem
   CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
+  if (T->isBooleanType())
+DiagnoseIntInBoolContext(S, E);
+
   // If -Wconversion would have warned about either of the candidates
   // for a signedness conversion to the context type...
   if (!Suspicious) return;

Added: cfe/trunk/test/Sema/warn-integer-constants-in-ternary.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-integer-constants-in-ternary.c?rev=372531&view=auto
==
--- cfe/trunk/test/Sema/warn-integer-constants-in-ternary.c (added)
+++ cfe/trunk/test/Sema/warn-integer-constants-in-ternary.c Sun Sep 22 15:00:48 
2019
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wtautological-constant-compare 
%s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify 
-Wtautological-constant-compare %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+#define ONE 1
+#define TWO 2
+
+#define TERN(c, l, r) c ? l : r
+
+#ifdef __cplusplus
+typedef bool boolean;
+#else
+typedef _Bool boolean;
+#endif
+
+void test(boolean a) {
+  boolean r;
+  r = a ? (1) : TWO;
+  r = a ? 3 : TWO; // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
+  r = a ? -2 : 0;  // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
+  r = a ? 3 : -2;  // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
+  r = a ? 0 : TWO;
+  r = a ? 3 : ONE; // expected-warning {{conve

[PATCH] D67889: [clang] fixing conditional explicit for out-of-line definition PR42980

2019-09-22 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372530: [clang] fixing conditional explicit for out-of-line 
definition PR42980 (authored by Tyker, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67889?vs=221216&id=221241#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67889

Files:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp


Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -2555,9 +2555,9 @@
 
   ExplicitSpecifier getExplicitSpecifierInternal() const {
 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
-  return *getCanonicalDecl()->getTrailingObjects();
+  return *getTrailingObjects();
 return ExplicitSpecifier(
-nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit
+nullptr, CXXConstructorDeclBits.IsSimpleExplicit
  ? ExplicitSpecKind::ResolvedTrue
  : ExplicitSpecKind::ResolvedFalse);
   }
@@ -2598,10 +2598,10 @@
  InheritedConstructor Inherited = InheritedConstructor());
 
   ExplicitSpecifier getExplicitSpecifier() {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
   const ExplicitSpecifier getExplicitSpecifier() const {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
 
   /// Return true if the declartion is already resolved to be explicit.
Index: cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -717,3 +717,21 @@
 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
 
 }
+
+namespace PR42980 {
+using size_t = decltype(sizeof(0));
+
+struct Str {// expected-note+ {{candidate constructor}}
+  template 
+  explicit(N > 7)// expected-note {{resolved to true}}
+  Str(char const (&str)[N]);
+};
+
+template 
+Str::Str(char const(&str)[N]) { }
+// expected-note@-1 {{candidate constructor}}
+
+Str a = "short";
+Str b = "not so short";// expected-error {{no viable conversion}}
+
+}
\ No newline at end of file


Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -2555,9 +2555,9 @@
 
   ExplicitSpecifier getExplicitSpecifierInternal() const {
 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
-  return *getCanonicalDecl()->getTrailingObjects();
+  return *getTrailingObjects();
 return ExplicitSpecifier(
-nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit
+nullptr, CXXConstructorDeclBits.IsSimpleExplicit
  ? ExplicitSpecKind::ResolvedTrue
  : ExplicitSpecKind::ResolvedFalse);
   }
@@ -2598,10 +2598,10 @@
  InheritedConstructor Inherited = InheritedConstructor());
 
   ExplicitSpecifier getExplicitSpecifier() {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
   const ExplicitSpecifier getExplicitSpecifier() const {
-return getExplicitSpecifierInternal();
+return getCanonicalDecl()->getExplicitSpecifierInternal();
   }
 
   /// Return true if the declartion is already resolved to be explicit.
Index: cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -717,3 +717,21 @@
 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
 
 }
+
+namespace PR42980 {
+using size_t = decltype(sizeof(0));
+
+struct Str {// expected-note+ {{candidate constructor}}
+  template 
+  explicit(N > 7)// expected-note {{resolved to true}}
+  Str(char const (&str)[N]);
+};
+
+template 
+Str::Str(char const(&str)[N]) { }
+// expected-note@-1 {{candidate constructor}}
+
+Str a = "short";
+Str b = "not so short";// expected-error {{no viable conversion}}
+
+}
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372533 - [NFC] Fixed failed test

2019-09-22 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Sun Sep 22 15:15:11 2019
New Revision: 372533

URL: http://llvm.org/viewvc/llvm-project?rev=372533&view=rev
Log:
[NFC] Fixed failed test

Modified:
cfe/trunk/test/SemaCXX/constexpr-builtin-bit-cast.cpp

Modified: cfe/trunk/test/SemaCXX/constexpr-builtin-bit-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-builtin-bit-cast.cpp?rev=372533&r1=372532&r2=372533&view=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-builtin-bit-cast.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-builtin-bit-cast.cpp Sun Sep 22 15:15:11 
2019
@@ -220,7 +220,7 @@ void backtrace() {
 void test_array_fill() {
   constexpr unsigned char a[4] = {1, 2};
   constexpr unsigned int i = bit_cast(a);
-  static_assert(i == LITTLE_END ? 0x0201 : 0x0102, "");
+  static_assert(i == LITTLE_END ? 0x0201 : 0x0102, ""); // 
expected-warning {{converting the result of '?:' with integer constants to a 
boolean always evaluates to 'true'}}
 }
 
 typedef decltype(nullptr) nullptr_t;


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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
zoecarver added reviewers: EricWF, rsmith, erichkeane, craig.topper, efriedma.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes the __is_signed builtin type trait to work with floating point 
types. Now, the builtin will return true if it is passed a floating point type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67897

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -56,14 +56,14 @@
 struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
-struct HasNoThrowMoveAssign { 
+struct HasNoThrowMoveAssign {
   HasNoThrowMoveAssign& operator=(
 const HasNoThrowMoveAssign&&) throw(); };
-struct HasNoExceptNoThrowMoveAssign { 
+struct HasNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign& operator=(
-const HasNoExceptNoThrowMoveAssign&&) noexcept; 
+const HasNoExceptNoThrowMoveAssign&&) noexcept;
 };
-struct HasThrowMoveAssign { 
+struct HasThrowMoveAssign {
   HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
 #if __cplusplus <= 201402L
   throw(POD);
@@ -73,7 +73,7 @@
 };
 
 
-struct HasNoExceptFalseMoveAssign { 
+struct HasNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
 struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
@@ -82,17 +82,17 @@
 struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
 struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
 struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
-struct HasMemberNoExceptFalseMoveAssign { 
+struct HasMemberNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign member; };
 struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
-struct HasMemberNoExceptNoThrowMoveAssign { 
+struct HasMemberNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign member; };
 
-struct HasDefaultTrivialCopyAssign { 
+struct HasDefaultTrivialCopyAssign {
   HasDefaultTrivialCopyAssign &operator=(
-const HasDefaultTrivialCopyAssign&) = default; 
+const HasDefaultTrivialCopyAssign&) = default;
 };
-struct TrivialMoveButNotCopy { 
+struct TrivialMoveButNotCopy {
   TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
   TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
 };
@@ -361,7 +361,7 @@
 struct FinalClass final {
 };
 
-template 
+template
 struct PotentiallyFinal { };
 
 template
@@ -1419,12 +1419,12 @@
   int t04[T(__is_signed(short))];
   int t05[T(__is_signed(signed char))];
   int t06[T(__is_signed(wchar_t))];
+  int t07[T(__is_signed(float))];
+  int t08[T(__is_signed(double))];
+  int t09[T(__is_signed(long double))];
 
-  int t10[F(__is_signed(bool))];
-  int t11[F(__is_signed(cvoid))];
-  int t12[F(__is_signed(float))];
-  int t13[F(__is_signed(double))];
-  int t14[F(__is_signed(long double))];
+  int t13[F(__is_signed(bool))];
+  int t14[F(__is_signed(cvoid))];
   int t15[F(__is_signed(unsigned char))];
   int t16[F(__is_signed(unsigned int))];
   int t17[F(__is_signed(unsigned long long))];
@@ -2005,7 +2005,7 @@
 };
 
 template
-struct X0 { 
+struct X0 {
   template X0(const X0&);
 };
 
@@ -2766,7 +2766,7 @@
   char b[7];
 };
 
-static_assert(!has_unique_object_representations::value, 
+static_assert(!has_unique_object_representations::value,
   "non trivial");
 // Can be unique on Itanium, since the is child class' data is 'folded' into the
 // parent's tail padding.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4605,7 +4605,7 @@
   return RD->hasAttr();
 return false;
   case UTT_IsSigned:
-return T->isSignedIntegerType();
+return T->isFloatingType() || T->isSignedIntegerType();
   case UTT_IsUnsigned:
 return T->isUnsignedIntegerType();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372534 - [X86] Require last argument to LWPINS/LWPVAL builtins to be an ICE. Add ImmArg to the llvm intrinsics.

2019-09-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Sep 22 16:48:50 2019
New Revision: 372534

URL: http://llvm.org/viewvc/llvm-project?rev=372534&view=rev
Log:
[X86] Require last argument to LWPINS/LWPVAL builtins to be an ICE. Add ImmArg 
to the llvm intrinsics.

Update the isel patterns to use timm instead of imm.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
cfe/trunk/test/Sema/builtins-x86.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=372534&r1=372533&r2=372534&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Sep 22 16:48:50 2019
@@ -751,8 +751,8 @@ TARGET_BUILTIN(__builtin_ia32_bextri_u32
 // LWP
 TARGET_BUILTIN(__builtin_ia32_llwpcb, "vv*", "n", "lwp")
 TARGET_BUILTIN(__builtin_ia32_slwpcb, "v*", "n", "lwp")
-TARGET_BUILTIN(__builtin_ia32_lwpins32, "UcUiUiUi", "n", "lwp")
-TARGET_BUILTIN(__builtin_ia32_lwpval32, "vUiUiUi", "n", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpins32, "UcUiUiIUi", "n", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpval32, "vUiUiIUi", "n", "lwp")
 
 // SHA
 TARGET_BUILTIN(__builtin_ia32_sha1rnds4, "V4iV4iV4iIc", "ncV:128:", "sha")

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86_64.def?rev=372534&r1=372533&r2=372534&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86_64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86_64.def Sun Sep 22 16:48:50 2019
@@ -86,8 +86,8 @@ TARGET_BUILTIN(__builtin_ia32_bzhi_di, "
 TARGET_BUILTIN(__builtin_ia32_pdep_di, "UOiUOiUOi", "nc", "bmi2")
 TARGET_BUILTIN(__builtin_ia32_pext_di, "UOiUOiUOi", "nc", "bmi2")
 TARGET_BUILTIN(__builtin_ia32_bextri_u64, "UOiUOiIUOi", "nc", "tbm")
-TARGET_BUILTIN(__builtin_ia32_lwpins64, "UcUOiUiUi", "n", "lwp")
-TARGET_BUILTIN(__builtin_ia32_lwpval64, "vUOiUiUi", "n", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpins64, "UcUOiUiIUi", "n", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpval64, "vUOiUiIUi", "n", "lwp")
 TARGET_BUILTIN(__builtin_ia32_vcvtsd2si64, "OiV2dIi", "ncV:128:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvtsd2usi64, "UOiV2dIi", "ncV:128:", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvtss2si64, "OiV4fIi", "ncV:128:", "avx512f")

Modified: cfe/trunk/test/Sema/builtins-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-x86.c?rev=372534&r1=372533&r2=372534&view=diff
==
--- cfe/trunk/test/Sema/builtins-x86.c (original)
+++ cfe/trunk/test/Sema/builtins-x86.c Sun Sep 22 16:48:50 2019
@@ -185,3 +185,19 @@ __m256i test_mm256_shrdi_epi16(__m256i _
 __m128i test_mm128_shrdi_epi16(__m128i __A, __m128i __B) {
   return __builtin_ia32_vpshrdw128(__A, __B, 1024); // expected-error 
{{argument value 1024 is outside the valid range [0, 255]}}
 }
+
+unsigned char test_lwpins32(unsigned int data2, unsigned int data1, unsigned 
int flags) {
+  return __builtin_ia32_lwpins32(data2, data1, flags); // expected-error 
{{argument to '__builtin_ia32_lwpins32' must be a constant integer}}
+}
+
+void test_lwpval32(unsigned int data2, unsigned int data1, unsigned int flags) 
{
+  __builtin_ia32_lwpval32(data2, data1, flags); // expected-error {{argument 
to '__builtin_ia32_lwpval32' must be a constant integer}}
+}
+
+unsigned char test_lwpins64(unsigned long long data2, unsigned long long 
data1, unsigned int flags) {
+  return __builtin_ia32_lwpins64(data2, data1, flags); // expected-error 
{{argument to '__builtin_ia32_lwpins64' must be a constant integer}}
+}
+
+void test_lwpval64(unsigned long long data2, unsigned long long data1, 
unsigned int flags) {
+  __builtin_ia32_lwpval64(data2, data1, flags); // expected-error {{argument 
to '__builtin_ia32_lwpval64' must be a constant integer}}
+}


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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

But `std::is_signed_v` needs to yield `false`. Isn't it cleaner to leave 
the compiler builtin matching the library type-trait, so that the library 
doesn't have to check for integral types separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Looks good, but please also update 
http://clang.llvm.org/docs/LanguageExtensions.html#type-trait-primitives

(Can I interest you in fixing the misbehaviour for enumeration types too?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

In D67897#1678388 , @Quuxplusone wrote:

> But `std::is_signed_v` needs to yield `false`. Isn't it cleaner to 
> leave the compiler builtin matching the library type-trait, so that the 
> library doesn't have to check for integral types separately?


The idea is that these will match the standard. I don't see anywhere where the 
standard says that floating-point types yield `false`. The currently libc++ 
implementation also yields true for your example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D67897#1678388 , @Quuxplusone wrote:

> But `std::is_signed_v` needs to yield `false`.


It should yield `true`; the spec says "If is_­arithmetic_­v is true, the 
same result as T(-1) < T(0); otherwise, false".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D67897#1678392 , @rsmith wrote:

> In D67897#1678388 , @Quuxplusone 
> wrote:
>
> > But `std::is_signed_v` needs to yield `false`.
>
>
> It should yield `true`; the spec says "If is_­arithmetic_­v is true, the 
> same result as T(-1) < T(0); otherwise, false".


Whoops! Never mind me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


[PATCH] D67509: [CUDA][HIP] Fix hostness of defaulted constructor

2019-09-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D67509#1677722 , @yaxunl wrote:

> In D67509#1677586 , @yaxunl wrote:
>
> > In D67509#1677528 , @tra wrote:
> >
> > > Looks like CUDA test-suite is triggering the assertion added by this 
> > > patch:
> > >
> > > http://lab.llvm.org:8011/builders/clang-cuda-build/builds/37301/steps/ninja%20build%20simple%20CUDA%20tests/logs/stdio
> >
> >
> > I am taking a look.
>
>
> I can reproduce similar asserts locally. It seems the assertion I added 
> `assert(!(HasD || HasH) || (NeedsD == HasD && NeedsH == HasH));` is not 
> always true. Since we do not have this assert before, I removed it. I will 
> study what causes it to assert and post it later.


A reduced test case is

  struct A {
A();
  };
  
  template 
  struct B
  {
T a;
constexpr B() = default;
  };
  
  B x;

`B::B()` got implicit `__host__ __device__`  attrs due to constexpr before 
entering Sema::inferCUDATargetForImplicitSpecialMember.
In Sema::inferCUDATargetForImplicitSpecialMember, the inferred hostness of 
`B::B()` is host since `A::A()` is host. This causes discrepancy between the 
inferred hostness and the existing hostness.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67509



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


[PATCH] D67899: Fix __is_fundamental to accept nullptr_t

2019-09-22 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
zoecarver added reviewers: rsmith, EricWF, efriedma, craig.topper, erichkeane.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch updates the __is_fundamental builtin type trait to return true for 
nullptr_t.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67899

Files:
  clang/include/clang/AST/Type.h
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -56,14 +56,14 @@
 struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
-struct HasNoThrowMoveAssign { 
+struct HasNoThrowMoveAssign {
   HasNoThrowMoveAssign& operator=(
 const HasNoThrowMoveAssign&&) throw(); };
-struct HasNoExceptNoThrowMoveAssign { 
+struct HasNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign& operator=(
-const HasNoExceptNoThrowMoveAssign&&) noexcept; 
+const HasNoExceptNoThrowMoveAssign&&) noexcept;
 };
-struct HasThrowMoveAssign { 
+struct HasThrowMoveAssign {
   HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
 #if __cplusplus <= 201402L
   throw(POD);
@@ -73,7 +73,7 @@
 };
 
 
-struct HasNoExceptFalseMoveAssign { 
+struct HasNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
 struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
@@ -82,17 +82,17 @@
 struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
 struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
 struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
-struct HasMemberNoExceptFalseMoveAssign { 
+struct HasMemberNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign member; };
 struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
-struct HasMemberNoExceptNoThrowMoveAssign { 
+struct HasMemberNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign member; };
 
-struct HasDefaultTrivialCopyAssign { 
+struct HasDefaultTrivialCopyAssign {
   HasDefaultTrivialCopyAssign &operator=(
-const HasDefaultTrivialCopyAssign&) = default; 
+const HasDefaultTrivialCopyAssign&) = default;
 };
-struct TrivialMoveButNotCopy { 
+struct TrivialMoveButNotCopy {
   TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
   TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
 };
@@ -361,7 +361,7 @@
 struct FinalClass final {
 };
 
-template 
+template
 struct PotentiallyFinal { };
 
 template
@@ -801,6 +801,7 @@
   int t23[T(__is_fundamental(unsigned long))];
   int t24[T(__is_fundamental(void))];
   int t25[T(__is_fundamental(cvoid))];
+  int t26[T(__is_fundamental(decltype(nullptr)))];
 
   int t30[F(__is_fundamental(Union))];
   int t31[F(__is_fundamental(UnionAr))];
@@ -2005,7 +2006,7 @@
 };
 
 template
-struct X0 { 
+struct X0 {
   template X0(const X0&);
 };
 
@@ -2766,7 +2767,7 @@
   char b[7];
 };
 
-static_assert(!has_unique_object_representations::value, 
+static_assert(!has_unique_object_representations::value,
   "non trivial");
 // Can be unique on Itanium, since the is child class' data is 'folded' into the
 // parent's tail padding.
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6353,6 +6353,7 @@
 /// \returns True for types specified in C++0x [basic.fundamental].
 inline bool Type::isFundamentalType() const {
   return isVoidType() ||
+ isNullPtrType() ||
  // FIXME: It's really annoying that we don't have an
  // 'isArithmeticType()' which agrees with the standard definition.
  (isArithmeticType() && !isEnumeralType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

> (Can I interest you in fixing the misbehaviour for enumeration types too?)

Certainly. You mean that `__is_signed` should return false for enumeration 
types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 221247.
zoecarver added a comment.

- fix docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -56,14 +56,14 @@
 struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
-struct HasNoThrowMoveAssign { 
+struct HasNoThrowMoveAssign {
   HasNoThrowMoveAssign& operator=(
 const HasNoThrowMoveAssign&&) throw(); };
-struct HasNoExceptNoThrowMoveAssign { 
+struct HasNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign& operator=(
-const HasNoExceptNoThrowMoveAssign&&) noexcept; 
+const HasNoExceptNoThrowMoveAssign&&) noexcept;
 };
-struct HasThrowMoveAssign { 
+struct HasThrowMoveAssign {
   HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
 #if __cplusplus <= 201402L
   throw(POD);
@@ -73,7 +73,7 @@
 };
 
 
-struct HasNoExceptFalseMoveAssign { 
+struct HasNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
 struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
@@ -82,17 +82,17 @@
 struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
 struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
 struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
-struct HasMemberNoExceptFalseMoveAssign { 
+struct HasMemberNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign member; };
 struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
-struct HasMemberNoExceptNoThrowMoveAssign { 
+struct HasMemberNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign member; };
 
-struct HasDefaultTrivialCopyAssign { 
+struct HasDefaultTrivialCopyAssign {
   HasDefaultTrivialCopyAssign &operator=(
-const HasDefaultTrivialCopyAssign&) = default; 
+const HasDefaultTrivialCopyAssign&) = default;
 };
-struct TrivialMoveButNotCopy { 
+struct TrivialMoveButNotCopy {
   TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
   TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
 };
@@ -361,7 +361,7 @@
 struct FinalClass final {
 };
 
-template 
+template
 struct PotentiallyFinal { };
 
 template
@@ -1419,12 +1419,12 @@
   int t04[T(__is_signed(short))];
   int t05[T(__is_signed(signed char))];
   int t06[T(__is_signed(wchar_t))];
+  int t07[T(__is_signed(float))];
+  int t08[T(__is_signed(double))];
+  int t09[T(__is_signed(long double))];
 
-  int t10[F(__is_signed(bool))];
-  int t11[F(__is_signed(cvoid))];
-  int t12[F(__is_signed(float))];
-  int t13[F(__is_signed(double))];
-  int t14[F(__is_signed(long double))];
+  int t13[F(__is_signed(bool))];
+  int t14[F(__is_signed(cvoid))];
   int t15[F(__is_signed(unsigned char))];
   int t16[F(__is_signed(unsigned int))];
   int t17[F(__is_signed(unsigned long long))];
@@ -2005,7 +2005,7 @@
 };
 
 template
-struct X0 { 
+struct X0 {
   template X0(const X0&);
 };
 
@@ -2766,7 +2766,7 @@
   char b[7];
 };
 
-static_assert(!has_unique_object_representations::value, 
+static_assert(!has_unique_object_representations::value,
   "non trivial");
 // Can be unique on Itanium, since the is child class' data is 'folded' into the
 // parent's tail padding.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4605,7 +4605,7 @@
   return RD->hasAttr();
 return false;
   case UTT_IsSigned:
-return T->isSignedIntegerType();
+return T->isFloatingType() || T->isSignedIntegerType();
   case UTT_IsUnsigned:
 return T->isUnsignedIntegerType();
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1162,9 +1162,7 @@
   Synonym for ``__is_final``.
 * ``__is_signed`` (C++, Embarcadero):
   Note that this currently returns true for enumeration types if the underlying
-  type is signed, and returns false for floating-point types, in violation of
-  the requirements for ``std::is_signed``. This behavior is likely to change in
-  a future version of Clang.
+  type is signed, and returns true for floating-point types.
 * ``__is_standard_layout`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_trivial`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_trivially_assignable`` (C++, GNU, Microsoft)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht

[PATCH] D67897: Fix __is_signed builtin

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

In D67897#1678420 , @zoecarver wrote:

> > (Can I interest you in fixing the misbehaviour for enumeration types too?)
>
> Certainly. You mean that `__is_signed` should return false for enumeration 
> types?


Yes, exactly.




Comment at: clang/docs/LanguageExtensions.rst:1165
   Note that this currently returns true for enumeration types if the underlying
-  type is signed, and returns false for floating-point types, in violation of
-  the requirements for ``std::is_signed``. This behavior is likely to change in
-  a future version of Clang.
+  type is signed, and returns true for floating-point types.
 * ``__is_standard_layout`` (C++, GNU, Microsoft, Embarcadero)

I'd just drop the second half of this sentence, and keep the "likely to change" 
warning for the non-conformance for enumeration types until that's fixed. (We 
already have an introductory sentence that says we follow the 
standard-specified behavior for traits marked (C++) unless otherwise specified.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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


r372538 - For P0784R7: add support for constexpr destructors, and call them as

2019-09-22 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Sep 22 20:48:44 2019
New Revision: 372538

URL: http://llvm.org/viewvc/llvm-project?rev=372538&view=rev
Log:
For P0784R7: add support for constexpr destructors, and call them as
appropriate during constant evaluation.

Note that the evaluator is sometimes invoked on incomplete expressions.
In such cases, if an object is constructed but we never reach the point
where it would be destroyed (and it has non-trivial destruction), we
treat the expression as having an unmodeled side-effect.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
cfe/trunk/test/CXX/drs/dr2xx.cpp
cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
cfe/trunk/test/SemaCXX/cxx2a-consteval.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372538&r1=372537&r2=372538&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sun Sep 22 20:48:44 2019
@@ -445,6 +445,9 @@ class CXXRecordDecl : public RecordDecl
 /// or an implicitly declared constexpr default constructor.
 unsigned HasConstexprDefaultConstructor : 1;
 
+/// True if a defaulted destructor for this class would be constexpr.
+unsigned DefaultedDestructorIsConstexpr : 1;
+
 /// True when this class contains at least one non-static data
 /// member or base class of non-literal or volatile type.
 unsigned HasNonLiteralTypeFieldsOrBases : 1;
@@ -1441,6 +1444,16 @@ public:
 !(data().HasTrivialSpecialMembers & SMF_MoveAssignment));
   }
 
+  /// Determine whether a defaulted default constructor for this class
+  /// would be constexpr.
+  bool defaultedDestructorIsConstexpr() const {
+return data().DefaultedDestructorIsConstexpr &&
+   getASTContext().getLangOpts().CPlusPlus2a;
+  }
+
+  /// Determine whether this class has a constexpr destructor.
+  bool hasConstexprDestructor() const;
+
   /// Determine whether this class has a trivial destructor
   /// (C++ [class.dtor]p3)
   bool hasTrivialDestructor() const {
@@ -1532,8 +1545,10 @@ public:
   ///
   /// Only in C++17 and beyond, are lambdas literal types.
   bool isLiteral() const {
-return hasTrivialDestructor() &&
-   (!isLambda() || getASTContext().getLangOpts().CPlusPlus17) &&
+ASTContext &Ctx = getASTContext();
+return (Ctx.getLangOpts().CPlusPlus2a ? hasConstexprDestructor()
+  : hasTrivialDestructor()) &&
+   (!isLambda() || Ctx.getLangOpts().CPlusPlus17) &&
!hasNonLiteralTypeFieldsOrBases() &&
(isAggregate() || isLambda() ||
 hasConstexprNonCopyMoveConstructor() ||
@@ -2802,9 +2817,9 @@ class CXXDestructorDecl : public CXXMeth
   CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
 const DeclarationNameInfo &NameInfo, QualType T,
 TypeSourceInfo *TInfo, bool isInline,
-bool isImplicitlyDeclared)
+bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind)
   : CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo,
-  SC_None, isInline, CSK_unspecified, SourceLocation()) {
+  SC_None, isInline, ConstexprKind, SourceLocation()) {
 setImplicit(isImplicitlyDeclared);
   }
 
@@ -2814,9 +2829,9 @@ public:
   static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
-   QualType T, TypeSourceInfo* TInfo,
-   bool isInline,
-   bool isImplicitlyDeclared);
+   QualType T, TypeSourceInfo *TInfo,
+   bool isInline, bool isImplicitlyDeclared,
+   ConstexprSpecKind ConstexprKind);
   static CXXDestructorDecl *CreateDeserialized(ASTContext & C, unsigned ID);
 
   void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/l

[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 221252.
plotfi added a comment.

Adding back -c. Fixing driver for .ifs files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978

Files:
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Phases.h
  clang/include/clang/Driver/ToolChain.h
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Phases.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.h
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/class-template-specialization.cpp
  clang/test/InterfaceStubs/externstatic.c
  clang/test/InterfaceStubs/function-template-specialization.cpp
  clang/test/InterfaceStubs/hidden-class-inheritance.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/object.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/virtual.cpp
  clang/test/InterfaceStubs/visibility.cpp
  clang/test/InterfaceStubs/weak.cpp

Index: clang/test/InterfaceStubs/weak.cpp
===
--- clang/test/InterfaceStubs/weak.cpp
+++ clang/test/InterfaceStubs/weak.cpp
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -c -target x86_64-linux-gnu -o - -emit-interface-stubs %s | \
 // RUN: FileCheck %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
Index: clang/test/InterfaceStubs/visibility.cpp
===
--- clang/test/InterfaceStubs/visibility.cpp
+++ clang/test/InterfaceStubs/visibility.cpp
@@ -1,26 +1,20 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 -fvisibility=hidden \
-// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+// RUN: -c -fvisibility=hidden %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 -fvisibility=hidden \
-// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+// RUN: -c -fvisibility=hidden %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD2 %s
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD2 %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-readelf -s - 2>&1 | \
Index: clang/test/InterfaceStubs/virtual.cpp
===
--- clang/test/InterfaceStubs/virtual.cpp
+++ clang/test/InterfaceStubs/virtual.cpp
@@ -1,9 +1,7 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck -check-prefix=CHECK-TAPI %s
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c %s | \
 // RUN: FileCheck -check-prefix=CHECK-TAPI2 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \
 // RUN: llvm-readelf -s - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
Index: clang/test/InterfaceStubs/template-namespace-function.cpp

[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/lib/Driver/Types.cpp:328
+IfsModePhaseList, std::back_inserter(P), [&DAL](phases::ID Phase) {
+  return Phase <= ((DAL.getLastArg(options::OPT_c)) ? phases::Compile
+: 
phases::IfsMerge);

plotfi wrote:
> compnerd wrote:
> > How does `-c` `-emit-interface-stubs` and multiple input play together?
> Dropped the code for -c. For now, to get the straight up ifs I think -cc1 can 
> be sufficient.
> 
> There are some hairy things regarding getting the correct InputType from 
> Driver::BuildInputs that need to be sorted first. 
I added -c back. Tried this and it works the same as without 
-emit-interface-stubs

```
$ build/bin/clang -c  -o - -emit-interface-stubs 
clang/test/InterfaceStubs/weak.cpp clang/test/InterfaceStubs/virtual.cpp 
clang-10: error: cannot specify -o when generating multiple output files
$ build/bin/clang -c  -o -  clang/test/InterfaceStubs/weak.cpp 
clang/test/InterfaceStubs/virtual.cpp 
clang-10: error: cannot specify -o when generating multiple output files
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 221253.
zoecarver added a comment.

- fix behavior when passed an enumeration type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -12,6 +12,7 @@
 
 // PODs
 enum Enum { EV };
+enum SignedEnum : signed int { };
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 struct IncompleteStruct;
@@ -56,14 +57,14 @@
 struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
-struct HasNoThrowMoveAssign { 
+struct HasNoThrowMoveAssign {
   HasNoThrowMoveAssign& operator=(
 const HasNoThrowMoveAssign&&) throw(); };
-struct HasNoExceptNoThrowMoveAssign { 
+struct HasNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign& operator=(
-const HasNoExceptNoThrowMoveAssign&&) noexcept; 
+const HasNoExceptNoThrowMoveAssign&&) noexcept;
 };
-struct HasThrowMoveAssign { 
+struct HasThrowMoveAssign {
   HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
 #if __cplusplus <= 201402L
   throw(POD);
@@ -73,7 +74,7 @@
 };
 
 
-struct HasNoExceptFalseMoveAssign { 
+struct HasNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
 struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
@@ -82,17 +83,17 @@
 struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
 struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
 struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
-struct HasMemberNoExceptFalseMoveAssign { 
+struct HasMemberNoExceptFalseMoveAssign {
   HasNoExceptFalseMoveAssign member; };
 struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
-struct HasMemberNoExceptNoThrowMoveAssign { 
+struct HasMemberNoExceptNoThrowMoveAssign {
   HasNoExceptNoThrowMoveAssign member; };
 
-struct HasDefaultTrivialCopyAssign { 
+struct HasDefaultTrivialCopyAssign {
   HasDefaultTrivialCopyAssign &operator=(
-const HasDefaultTrivialCopyAssign&) = default; 
+const HasDefaultTrivialCopyAssign&) = default;
 };
-struct TrivialMoveButNotCopy { 
+struct TrivialMoveButNotCopy {
   TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
   TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
 };
@@ -361,7 +362,7 @@
 struct FinalClass final {
 };
 
-template 
+template
 struct PotentiallyFinal { };
 
 template
@@ -1419,12 +1420,12 @@
   int t04[T(__is_signed(short))];
   int t05[T(__is_signed(signed char))];
   int t06[T(__is_signed(wchar_t))];
+  int t07[T(__is_signed(float))];
+  int t08[T(__is_signed(double))];
+  int t09[T(__is_signed(long double))];
 
-  int t10[F(__is_signed(bool))];
-  int t11[F(__is_signed(cvoid))];
-  int t12[F(__is_signed(float))];
-  int t13[F(__is_signed(double))];
-  int t14[F(__is_signed(long double))];
+  int t13[F(__is_signed(bool))];
+  int t14[F(__is_signed(cvoid))];
   int t15[F(__is_signed(unsigned char))];
   int t16[F(__is_signed(unsigned int))];
   int t17[F(__is_signed(unsigned long long))];
@@ -1434,9 +1435,10 @@
   int t21[F(__is_signed(ClassType))];
   int t22[F(__is_signed(Derives))];
   int t23[F(__is_signed(Enum))];
-  int t24[F(__is_signed(IntArNB))];
-  int t25[F(__is_signed(Union))];
-  int t26[F(__is_signed(UnionAr))];
+  int t24[F(__is_signed(SignedEnum))];
+  int t25[F(__is_signed(IntArNB))];
+  int t26[F(__is_signed(Union))];
+  int t27[F(__is_signed(UnionAr))];
 }
 
 void is_unsigned()
@@ -2005,7 +2007,7 @@
 };
 
 template
-struct X0 { 
+struct X0 {
   template X0(const X0&);
 };
 
@@ -2766,7 +2768,7 @@
   char b[7];
 };
 
-static_assert(!has_unique_object_representations::value, 
+static_assert(!has_unique_object_representations::value,
   "non trivial");
 // Can be unique on Itanium, since the is child class' data is 'folded' into the
 // parent's tail padding.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4605,7 +4605,9 @@
   return RD->hasAttr();
 return false;
   case UTT_IsSigned:
-return T->isSignedIntegerType();
+// Enum types should always return false.
+// Floating points should always return true.
+return !T->isEnumeralType() && (T->isFloatingType() || T->isSignedIntegerType());
   case UTT_IsUnsigned:
 return T->isUnsignedIntegerType();
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/Langua

[PATCH] D67901: [clangd] Improve semantic highlighting in dependent contexts (fixes #154)

2019-09-22 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67901

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -175,7 +175,7 @@
   }
   template
   struct $Class[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
-typename $TemplateParameter[[T]]::A* $Field[[D]];
+typename $TemplateParameter[[T]]::$Class[[A]]* $Field[[D]];
   };
   $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Variable[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Class[[AAA]];
@@ -509,6 +509,55 @@
   $Typedef[[Pointer]], $Typedef[[LVReference]], $Typedef[[RVReference]],
   $Typedef[[Array]], $Typedef[[MemberPointer]]);
   };
+)cpp",
+  R"cpp(
+  template 
+  $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
+$Function[[bar]]($Parameter[[P]]);
+  }
+)cpp",
+  R"cpp(
+  class $Class[[A]] {
+template 
+$Primitive[[void]] $Method[[bar]]($TemplateParameter[[T]]);
+  };
+
+  template 
+  $Primitive[[void]] $Function[[foo]]($TemplateParameter[[U]] $Parameter[[P]]) {
+$Class[[A]]().$Method[[bar]]($Parameter[[P]]);
+  }
+)cpp",
+  R"cpp(
+  struct $Class[[A]] {
+template 
+static $Primitive[[void]] $StaticMethod[[foo]]($TemplateParameter[[T]]);
+  };
+
+  template 
+  struct $Class[[B]] {
+$Primitive[[void]] $Method[[bar]]() {
+  $Class[[A]]::$StaticMethod[[foo]]($TemplateParameter[[T]]());
+}
+  };
+)cpp",
+  R"cpp(
+  template 
+  $Primitive[[void]] $Function[[foo]](typename $TemplateParameter[[T]]::$Class[[Type]]
+= $TemplateParameter[[T]]::$StaticField[[val]]);
+)cpp",
+  R"cpp(
+  template 
+  $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
+$Parameter[[P]].$Field[[Field]];
+  }
+)cpp",
+  R"cpp(
+  template 
+  class $Class[[A]] {
+$Primitive[[int]] $Method[[foo]]() {
+  return $TemplateParameter[[T]]::$StaticField[[Field]];
+}
+  };
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -152,6 +152,38 @@
 return true;
   }
 
+  bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+if (canHighlightName(E->getName())) {
+  addToken(E->getNameLoc(), E->getNamingClass()
+? HighlightingKind::StaticMethod
+: HighlightingKind::Function);
+}
+return true;
+  }
+
+  bool VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
+if (canHighlightName(E->getMemberName())) {
+  addToken(E->getNameLoc(), HighlightingKind::Method);
+}
+return true;
+  }
+
+  bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
+if (canHighlightName(E->getDeclName())) {
+  addToken(E->getLocation(), HighlightingKind::StaticField);
+}
+return true;
+  }
+
+  bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E) {
+if (canHighlightName(E->getMember())) {
+  addToken(E->getMemberLoc(), E->getQualifier()
+  ? HighlightingKind::StaticField
+  : HighlightingKind::Field);
+}
+return true;
+  }
+
   bool VisitNamedDecl(NamedDecl *ND) {
 if (canHighlightName(ND->getDeclName()))
   addToken(ND->getLocation(), ND);
@@ -187,6 +219,11 @@
 return true;
   }
 
+  bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
+addToken(L.getNameLoc(), HighlightingKind::Class);
+return true;
+  }
+
   bool VisitTypeLoc(TypeLoc TL) {
 if (auto K = kindForType(TL.getTypePtr()))
   addToken(TL.getBeginLoc(), *K);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372541 - For P0784R7: add further testing of requirements on constexpr

2019-09-22 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Sep 22 22:08:55 2019
New Revision: 372541

URL: http://llvm.org/viewvc/llvm-project?rev=372541&view=rev
Log:
For P0784R7: add further testing of requirements on constexpr
destructors.

Added:
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp

Added: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp?rev=372541&view=auto
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp Sun Sep 22 
22:08:55 2019
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+// p3: if the function is a constructor or destructor, its class shall not have
+// any virtual base classes;
+namespace vbase {
+  struct A {};
+  struct B : virtual A { // expected-note {{virtual}}
+constexpr ~B() {} // expected-error {{constexpr member function not 
allowed in struct with virtual base class}}
+  };
+}
+
+// p3: its function-body shall not enclose
+//  -- a goto statement
+//  -- an identifier label
+//  -- a variable of non-literal type or of static or thread storage duration
+namespace contents {
+  struct A {
+constexpr ~A() {
+  goto x; // expected-error {{statement not allowed in constexpr function}}
+  x: ;
+}
+  };
+  struct B {
+constexpr ~B() {
+  x: ; // expected-error {{statement not allowed in constexpr function}}
+}
+  };
+  struct Nonlit { Nonlit(); }; // expected-note {{not literal}}
+  struct C {
+constexpr ~C() {
+  Nonlit nl; // expected-error {{non-literal}}
+}
+  };
+  struct D {
+constexpr ~D() {
+  static int a; // expected-error {{static variable}}
+}
+  };
+  struct E {
+constexpr ~E() {
+  thread_local int e; // expected-error {{thread_local variable}}
+}
+  };
+  struct F {
+constexpr ~F() {
+  extern int f;
+}
+  };
+}
+
+// p5: for every subobject of class type or (possibly multi-dimensional) array
+// thereof, that class type shall have a constexpr destructor
+namespace subobject {
+  struct A {
+~A();
+  };
+  struct B : A { // expected-note {{here}}
+constexpr ~B() {} // expected-error {{destructor cannot be declared 
constexpr because base class 'subobject::A' does not have a constexpr 
destructor}}
+  };
+  struct C {
+A a; // expected-note {{here}}
+constexpr ~C() {} // expected-error {{destructor cannot be declared 
constexpr because data member 'a' does not have a constexpr destructor}}
+  };
+  struct D : A {
+A a;
+constexpr ~D() = delete;
+  };
+}


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


[PATCH] D67888: [clang-format] NFC clang-format the clang-format unit tests

2019-09-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

I suppose the .clang-format file you used only had `BasedOnStyle: LLVM` in it. 
Did you run clang-format the second time to ensure that the formatted file was 
stable?


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

https://reviews.llvm.org/D67888



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


[PATCH] D67897: Fix __is_signed builtin

2019-09-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!




Comment at: clang/docs/LanguageExtensions.rst:1165
   Note that this currently returns true for enumeration types if the underlying
-  type is signed, and returns false for floating-point types, in violation of
-  the requirements for ``std::is_signed``. This behavior is likely to change in
-  a future version of Clang.
+  type is signed, and returns true for floating-point types.
 * ``__is_standard_layout`` (C++, GNU, Microsoft, Embarcadero)

rsmith wrote:
> I'd just drop the second half of this sentence, and keep the "likely to 
> change" warning for the non-conformance for enumeration types until that's 
> fixed. (We already have an introductory sentence that says we follow the 
> standard-specified behavior for traits marked (C++) unless otherwise 
> specified.)
Now that this does the standard thing, you can delete this text entirely, or 
add a "before Clang 10, returned true for enumeration types if the underlying 
type was signed, and returned false for floating-point types".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67897



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