[PATCH] D67613: [DWARF-5] Support for DWARF-5 C++ language tags

2019-09-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX updated this revision to Diff 220613.
SouraVX added a comment.

Updated AST to use DWARF language enums.


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

https://reviews.llvm.org/D67613

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclPrinter.cpp
  lib/AST/JSONNodeDumper.cpp
  lib/AST/TextNodeDumper.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaModule.cpp
  test/Modules/ModuleDebugInfo.cpp

Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
-// RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-CXX %s
 // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 #ifdef MODULES
@@ -23,6 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:
Index: lib/Sema/SemaModule.cpp
===
--- lib/Sema/SemaModule.cpp
+++ lib/Sema/SemaModule.cpp
@@ -31,6 +31,8 @@
 ExternCLoc = LSD->getBeginLoc();
   break;
 case LinkageSpecDecl::lang_cxx:
+case LinkageSpecDecl::lang_cxx_11:
+case LinkageSpecDecl::lang_cxx_14:
   break;
 }
 DC = LSD->getParent();
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13911,6 +13911,10 @@
 Language = LinkageSpecDecl::lang_c;
   else if (Lang == "C++")
 Language = LinkageSpecDecl::lang_cxx;
+  else if (Lang == "C++11")
+Language = LinkageSpecDecl::lang_cxx_11;
+  else if (Lang == "C++14")
+Language = LinkageSpecDecl::lang_cxx_14;
   else {
 Diag(LangStr->getExprLoc(), diag::err_language_linkage_spec_unknown)
   << LangStr->getSourceRange();
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -5132,7 +5132,9 @@
 // EmitLinkageSpec - Emit all declarations in a linkage spec.
 void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) {
   if (LSD->getLanguage() != LinkageSpecDecl::lang_c &&
-  LSD->getLanguage() != LinkageSpecDecl::lang_cxx) {
+  LSD->getLanguage() != LinkageSpecDecl::lang_cxx &&
+  LSD->getLanguage() != LinkageSpecDecl::lang_cxx_11 &&
+  LSD->getLanguage() != LinkageSpecDecl::lang_cxx_14) {
 ErrorUnsupported(LSD, "linkage spec");
 return;
   }
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -561,6 +561,10 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
+else if (LO.CPlusPlus14)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
+else if (LO.CPlusPlus11)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC) {
@@ -878,6 +882,8 @@
 static bool hasCXXMangling(const TagDecl *TD, llvm::DICompileUnit *TheCU) {
   switch (TheCU->getSourceLanguage()) {
   case llvm::dwarf::DW_LANG_C_plus_plus:
+  case llvm::dwarf::DW_LANG_C_plus_plus_11:
+  case llvm::dwarf::DW_LANG_C_plus_plus_14:
 return true;
   case llvm::dwarf::DW_LANG_ObjC_plus_plus:
 return isa(TD) || isa(TD);
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -1767,6 +1767,12 @@
   case LinkageSpecDecl::lang_cxx:
 OS << " C++";
 break;
+  case LinkageSpecDecl::lang_cxx_11:
+OS << " C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+OS << " C++14";
+break;
   }
 }
 
Index: lib/AST/JSONNodeDumper.cpp
===
--- lib/AST/JSONNodeDumper.cpp
+++ lib/AST/JSONNodeDumper.cpp
@@ -850,6 +850,12 @@
   switch (LSD->getLanguage()) {
   case LinkageSpecDecl::lang_c: Lang = "C"; break;
   case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
+  case LinkageSpecDecl::lang_cxx_11:
+Lang = "C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+Lang = "C++14";
+break;
   }
   JOS.attribute("language", Lang);
   attributeOnlyIfTrue("hasBraces", LSD->hasBraces());
Index: 

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

2019-09-17 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj updated this revision to Diff 220610.
timwoj added a comment.

Marked failing tests as FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67627

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/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 aaa)\n"
@@ -11347,6 +11364,251 @@
BreakBeforeBraceShortIfs);
 }
 
+TEST_F(FormatTest, WhitesmithsBraceBreaking) {
+  FormatStyle WhitesmithsBraceStyle = getLLVMStyle();
+  WhitesmithsBraceStyle.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
+
+  // Make a few changes to the style for testing purposes
+  WhitesmithsBraceStyle.AllowShortFunctionsOnASingleLine =
+  FormatStyle::SFS_Empty;
+  WhitesmithsBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+  WhitesmithsBraceStyle.ColumnLimit = 0;
+
+  // FIXME: this test case can't decide whether there should be a blank line
+  // after the ~D() line or not. It adds one if one doesn't exist in the test
+  // and it removes the line if one exists.
+  /*
+  verifyFormat("class A;\n"
+   "namespace B\n"
+   "  {\n"
+   "class C;\n"
+   "// Comment\n"
+   "class D\n"
+   "  {\n"
+   "public:\n"
+   "  D();\n"
+   "  ~D() {}\n"
+   "private:\n"
+   "  enum E\n"
+   "{\n"
+   "F\n"
+   "}\n"
+   "  };\n"
+   "  } // namespace B\n",
+   WhitesmithsBraceStyle);
+  */
+
+  verifyFormat("namespace a\n"
+   "  {\n"
+   "class A\n"
+   "  {\n"
+   "  void f()\n"
+   "{\n"
+   "if (true)\n"
+   "  {\n"
+   "  a();\n"
+   "  b();\n"
+   "  }\n"
+   "}\n"
+   "  void g()\n"
+   "{\n"
+   "return;\n"
+   "}\n"
+   "  };\n"
+   "struct B\n"
+   "  {\n"
+   "  int x;\n"
+   "  };\n"
+   "  } // namespace a",
+   WhitesmithsBraceStyle);
+
+  verifyFormat("void f()\n"
+   "  {\n"
+   "  if (true)\n"
+   "{\n"
+   "a();\n"
+   "}\n"
+   "  else if (false)\n"
+   "{\n"
+   "b();\n"
+   "}\n"
+   "  else\n"
+   "{\n"
+   "c();\n"
+   "}\n"
+   "  }\n",
+   WhitesmithsBraceStyle);
+
+  verifyFormat("void f()\n"
+   "  {\n"
+   "  for (int i = 0; i < 10; ++i)\n"
+   "{\n"
+   "a();\n"
+   "}\n"
+   "  while (false)\n"
+   "{\n"
+   "b();\n"
+   "}\n"
+   "  do\n"
+   "{\n"
+   "c();\n"
+   "} while (false)\n"
+   "  }\n",
+   WhitesmithsBraceStyle);
+
+  // FIXME: the block and the break under case 2 in this test don't get indented correctly
+  /*
+  verifyFormat("void switchTest1(int a)\n"
+   "  {\n"
+   "  switch (a)\n"
+   "{\n"
+   "case 2:\n"
+   "  {\n"
+   "  }\n"
+   "  break;\n"
+   "}\n"
+   "  }\n",
+   

Re: r372185 - Revert "Create UsersManual section entitled 'Controlling Floating Point"

2019-09-17 Thread Richard Smith via cfe-commits
On Tue, 17 Sep 2019, 15:25 Erich Keane via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Tue Sep 17 14:27:07 2019
> New Revision: 372185
>
> URL: http://llvm.org/viewvc/llvm-project?rev=372185=rev
> Log:
> Revert "Create UsersManual section entitled 'Controlling Floating Point"
>

When reverting a change, please include a reason for the revert in your
commit message.

This reverts commit a08d5a4b0ebd44dc64f41049ed4e97a3c6d31498.
>
> Modified:
> cfe/trunk/docs/UsersManual.rst
>
> Modified: cfe/trunk/docs/UsersManual.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=372185=372184=372185=diff
>
> ==
> --- cfe/trunk/docs/UsersManual.rst (original)
> +++ cfe/trunk/docs/UsersManual.rst Tue Sep 17 14:27:07 2019
> @@ -1128,165 +1128,6 @@ number of cases where the compilation en
>  and the precompiled header cannot be generated after headers have been
>  installed.
>
> -.. _controlling-fp-behavior:
> -
> -Controlling Floating Point Behavior
> 
> -
> -Clang provides a number of ways to control floating point behavior. The
> options
> -are listed below.
> -
> -.. option:: -ffast-math
> -
> -   Enable fast-math mode.  This option lets the
> -   compiler make aggressive, potentially-lossy assumptions about
> -   floating-point math.  These include:
> -
> -   * Floating-point math obeys regular algebraic rules for real numbers
> (e.g.
> - ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
> - ``(a + b) * c == a * c + b * c``),
> -   * Operands to floating-point operations are not equal to ``NaN`` and
> - ``Inf``, and
> -   * ``+0`` and ``-0`` are interchangeable.
> -
> -   ``-ffast-math`` also defines the ``__FAST_MATH__`` preprocessor
> -   macro. Some math libraries recognize this macro and change their
> behavior.
> -   With the exception of ``-ffp-contract=fast``, using any of the options
> -   below to disable any of the individual optimizations in ``-ffast-math``
> -   will cause ``__FAST_MATH__`` to no longer be set.
> -
> -  This option implies:
> -
> -   * ``-fno-honor-infinities``
> -
> -   * ``-fno-honor-nans``
> -
> -   * ``-fno-math-errno``
> -
> -   * ``-ffinite-math``
> -
> -   * ``-fassociative-math``
> -
> -   * ``-freciprocal-math``
> -
> -   * ``-fno-signed-zeros``
> -
> -   * ``-fno-trapping-math``
> -
> -   * ``-ffp-contract=fast``
> -
> -.. option:: -fdenormal-fp-math=
> -
> -   Select which denormal numbers the code is permitted to require.
> -
> -   Valid values are:
> -
> -   * ``ieee`` - IEEE 754 denormal numbers
> -   * ``preserve-sign`` - the sign of a flushed-to-zero number is
> preserved in the sign of 0
> -   * ``positive-zero`` - denormals are flushed to positive zero
> -
> -   Defaults to ``ieee``.
> -
> -.. option:: -f[no-]strict-float-cast-overflow
> -
> -   When a floating-point value is not representable in a destination
> integer
> -   type, the code has undefined behavior according to the language
> standard.
> -   By default, Clang will not guarantee any particular result in that
> case.
> -   With the 'no-strict' option, Clang attempts to match the overflowing
> behavior
> -   of the target's native float-to-int conversion instructions.
> -
> -.. option:: -f[no-]math-errno
> -
> -   Require math functions to indicate errors by setting errno.
> -   The default varies by ToolChain.  ``-fno-math-errno`` allows
> optimizations
> -   that might cause standard C math functions to not set ``errno``.
> -   For example, on some systems, the math function ``sqrt`` is specified
> -   as setting ``errno`` to ``EDOM`` when the input is negative. On these
> -   systems, the compiler cannot normally optimize a call to ``sqrt`` to
> use
> -   inline code (e.g. the x86 ``sqrtsd`` instruction) without additional
> -   checking to ensure that ``errno`` is set appropriately.
> -   ``-fno-math-errno`` permits these transformations.
> -
> -   On some targets, math library functions never set ``errno``, and so
> -   ``-fno-math-errno`` is the default. This includes most BSD-derived
> -   systems, including Darwin.
> -
> -.. option:: -f[no-]trapping-math
> -
> -   ``-fno-trapping-math`` allows optimizations that assume that
> -   floating point operations cannot generate traps such as divide-by-zero,
> -   overflow and underflow. Defaults to ``-ftrapping-math``.
> -   Currently this option has no effect.
> -
> -.. option:: -ffp-contract=
> -
> -   Specify when the compiler is permitted to form fused floating-point
> -   operations, such as fused multiply-add (FMA). Fused operations are
> -   permitted to produce more precise results than performing the same
> -   operations separately.
> -
> -   The C standard permits intermediate floating-point results within an
> -   expression to be computed with more precision than their type would
> -   normally allow. This permits operation fusing, and Clang 

r372197 - [X86] Prevent assertion when calling a function that returns double with -mno-sse2 on x86-64.

2019-09-17 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Sep 17 18:57:46 2019
New Revision: 372197

URL: http://llvm.org/viewvc/llvm-project?rev=372197=rev
Log:
[X86] Prevent assertion when calling a function that returns double with 
-mno-sse2 on x86-64.

As seen in the most recent updates to PR10498

Added:
cfe/trunk/test/CodeGen/x86_64-mno-sse2.c

Added: cfe/trunk/test/CodeGen/x86_64-mno-sse2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-mno-sse2.c?rev=372197=auto
==
--- cfe/trunk/test/CodeGen/x86_64-mno-sse2.c (added)
+++ cfe/trunk/test/CodeGen/x86_64-mno-sse2.c Tue Sep 17 18:57:46 2019
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-linux -target-feature -sse2 -S -o /dev/null 
-verify %s
+// REQUIRES: x86-registered-target
+
+double f1(void) { // expected-error {{SSE2 register return with SSE2 disabled}}
+  return 1.4;
+}
+extern double g;
+void f2(void) { // expected-error {{SSE2 register return with SSE2 disabled}}
+  g = f1();
+}
+void take_double(double);
+void pass_double(void) {
+  // FIXME: Still asserts.
+  //take_double(1.5);
+}
+
+double return_double();
+void call_double(double *a) { // expected-error {{SSE2 register return with 
SSE2 disabled}}
+  *a = return_double();
+}


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


[PATCH] D66121: Debug Info: Nest Objective-C property function decls inside their container.

2019-09-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D66121#1673233 , @aprantl wrote:

> I'm afraid I'm going to give up on fixing the AST and return to my 
> debuginfo-only patch.
>
> While I was correct in figuring out that ObjCMethodDecl implementations are 
> not linked up as redeclarations of ObjCMethodDecl decls in the interface, 
> that wasn't the whole story: `ObjCMethodDecl::getNextRedeclarationImpl()` 
> links them up *implicitly* by finding the implementation for a decl and vice 
> versa by looking up the selector in the interface/implementation (See 
> https://github.com/llvm/llvm-project/blob/244e738485445fa4b72bfef9b9b2f9625cee989e/clang/lib/AST/DeclObjC.cpp#L905).
>
> I can make this mechanism work by adding the method to the 
> ObjCImplementationDecl, so it gets found by getNextRedeclarationImpl(). But 
> if I do that, CodeGen falls over completely, because the new property 
> accessor redeclarations don't actually have any function bodies. CodeGen in 
> several places special-cases property accessors to generate them on-the-fly. 
> I think this may work neatly if we actually created an AST for the function 
> body in SemaObjCProperty too, and remove the functionality from CodeGen, but 
> that is beyond what I'm prepared to do.


Can you just check for a method that doesn't have a body and use that as the 
trigger for emitting the synthetic getter/setter body, and get rid of the old 
IRGen code that looks for property implementations and emits them?


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

https://reviews.llvm.org/D66121



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


[PATCH] D67647: [Consumed] Refactor handleCall to take function argument list. NFC.

2019-09-17 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added a comment.

Ugh, it looks like `getArgs()` is a massive strict aliasing violation.  And 
it's used in enough different places in Clang that fixing the violation may 
require extensive refactoring... I've reported the issue as 
https://bugs.llvm.org/show_bug.cgi?id=43344, but I don't really want to fix it 
:)

However, I can at least update this patch to avoid using getArgs().


Repository:
  rC Clang

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

https://reviews.llvm.org/D67647



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


[PATCH] D67683: [Timers] Fix printing some `-ftime-report` sections twice. Fixes PR40328.

2019-09-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the fast review.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67683



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


[PATCH] D67683: [Timers] Fix printing some `-ftime-report` sections twice. Fixes PR40328.

2019-09-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372191: [Timers] Fix printing some `-ftime-report` sections 
twice. Fixes PR40328. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67683?vs=220582=220590#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67683

Files:
  cfe/trunk/tools/driver/cc1_main.cpp
  cfe/trunk/tools/driver/cc1as_main.cpp
  cfe/trunk/tools/driver/driver.cpp


Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -609,6 +609,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.
   TimerGroup::printAll(errs());
+  TimerGroup::clearAll();
 
   return !!Failed;
 }
Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -499,6 +499,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
Index: cfe/trunk/tools/driver/cc1_main.cpp
===
--- cfe/trunk/tools/driver/cc1_main.cpp
+++ cfe/trunk/tools/driver/cc1_main.cpp
@@ -253,6 +253,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);


Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -609,6 +609,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.
   TimerGroup::printAll(errs());
+  TimerGroup::clearAll();
 
   return !!Failed;
 }
Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -499,6 +499,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
Index: cfe/trunk/tools/driver/cc1_main.cpp
===
--- cfe/trunk/tools/driver/cc1_main.cpp
+++ cfe/trunk/tools/driver/cc1_main.cpp
@@ -253,6 +253,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372191 - [Timers] Fix printing some `-ftime-report` sections twice. Fixes PR40328.

2019-09-17 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Sep 17 17:05:45 2019
New Revision: 372191

URL: http://llvm.org/viewvc/llvm-project?rev=372191=rev
Log:
[Timers] Fix printing some `-ftime-report` sections twice. Fixes PR40328.

Starting from r324788 timer groups aren't cleared automatically when
printed out. As a result some timer groups were printed one more time.
For example, "Pass execution timing report" was printed again in
`ManagedStatic` destructor, "DWARF Emission" in
`ManagedStatic NamedGroupedTimers` destructor.

Fix by clearing timer groups manually.

Reviewers: thegameg, george.karpenkov

Reviewed By: thegameg

Subscribers: aprantl, jkorous, dexonsmith, ributzka, aras-p, cfe-commits

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

Modified:
cfe/trunk/tools/driver/cc1_main.cpp
cfe/trunk/tools/driver/cc1as_main.cpp
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=372191=372190=372191=diff
==
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Tue Sep 17 17:05:45 2019
@@ -253,6 +253,7 @@ int cc1_main(ArrayRef Argv
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=372191=372190=372191=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Sep 17 17:05:45 2019
@@ -609,6 +609,7 @@ int cc1as_main(ArrayRef Ar
   // If any timers were active but haven't been destroyed yet, print their
   // results now.
   TimerGroup::printAll(errs());
+  TimerGroup::clearAll();
 
   return !!Failed;
 }

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=372191=372190=372191=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Tue Sep 17 17:05:45 2019
@@ -499,6 +499,7 @@ int main(int argc_, const char **argv_)
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.


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


[PATCH] D67683: [Timers] Fix printing some `-ftime-report` sections twice. Fixes PR40328.

2019-09-17 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg accepted this revision.
thegameg added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D67683



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


[PATCH] D67683: [Timers] Fix printing some `-ftime-report` sections twice. Fixes PR40328.

2019-09-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: thegameg, george.karpenkov.
Herald added subscribers: ributzka, dexonsmith, jkorous, aprantl.

Starting from r324788 timer groups aren't cleared automatically when
printed out. As a result some timer groups were printed one more time.
For example, "Pass execution timing report" was printed again in
`ManagedStatic` destructor, "DWARF Emission" in
`ManagedStatic NamedGroupedTimers` destructor.

Fix by clearing timer groups manually.


https://reviews.llvm.org/D67683

Files:
  clang/tools/driver/cc1_main.cpp
  clang/tools/driver/cc1as_main.cpp
  clang/tools/driver/driver.cpp


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -499,6 +499,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -609,6 +609,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.
   TimerGroup::printAll(errs());
+  TimerGroup::clearAll();
 
   return !!Failed;
 }
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -253,6 +253,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -499,6 +499,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -609,6 +609,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.
   TimerGroup::printAll(errs());
+  TimerGroup::clearAll();
 
   return !!Failed;
 }
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -253,6 +253,7 @@
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
+  llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
___
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-17 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:1548
+{M.gccSuffix(),
+ "/../../../../riscv64-unknown-elf/lib" + M.gccSuffix()});
+  });

It could be "riscv32-unknown-elf" other than "riscv64-unknown-elf".



Comment at: clang/lib/Driver/ToolChains/RISCVToolchain.cpp:129
+  }
+
   std::string Linker = getToolChain().GetProgramPath(getShortName());

This change seems like unrelated to multi-lib, could you split this change into 
new patch and add a test for that?



Comment at: clang/lib/Driver/ToolChains/RISCVToolchain.cpp:132
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");

This part will conflict when apply patch, you might generate patch with 
https://reviews.llvm.org/D67409, could you rebase the patch with current trunk?


Repository:
  rC Clang

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] D67467: [ARM] Update clang for removal of vfp2d16 and vfp2d16sp

2019-09-17 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372187: [ARM] Update clang for removal of vfp2d16 and 
vfp2d16sp (authored by efriedma, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67467?vs=219805=220578#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67467

Files:
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
  cfe/trunk/test/CodeGen/arm-target-features.c
  cfe/trunk/test/Driver/arm-mfpu.c

Index: cfe/trunk/test/CodeGen/arm-target-features.c
===
--- cfe/trunk/test/CodeGen/arm-target-features.c
+++ cfe/trunk/test/CodeGen/arm-target-features.c
@@ -1,23 +1,23 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+armv7-a,+d32,+dsp,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp"
+// CHECK-VFP3: "target-features"="+armv7-a,+d32,+dsp,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4: "target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-2
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: "target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
-// CHECK-VFP4-DIV-2: "target-features"="+armv7s,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4-DIV: "target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4-DIV-2: "target-features"="+armv7s,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
 
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
-// CHECK-VFP4-DIV-ARM: "target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp,-thumb-mode"
+// CHECK-VFP4-DIV-ARM: "target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp,-thumb-mode"
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a32 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
@@ -28,34 +28,34 @@
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m2 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m3 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
-// CHECK-BASIC-V8: "target-features"="+armv8-a,+crc,+crypto,+d32,+dsp,+fp-armv8,+fp-armv8d16,+fp-armv8d16sp,+fp-armv8sp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-BASIC-V8: 

r372187 - [ARM] Update clang for removal of vfp2d16 and vfp2d16sp

2019-09-17 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Tue Sep 17 14:43:19 2019
New Revision: 372187

URL: http://llvm.org/viewvc/llvm-project?rev=372187=rev
Log:
[ARM] Update clang for removal of vfp2d16 and vfp2d16sp

Matching fix for https://reviews.llvm.org/D67375 (r372186).

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


Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/Driver/arm-mfpu.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=372187=372186=372187=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue Sep 17 14:43:19 2019
@@ -428,11 +428,10 @@ bool ARMTargetInfo::handleTargetFeatures
   for (const auto  : Features) {
 if (Feature == "+soft-float") {
   SoftFloat = true;
-} else if (Feature == "+vfp2sp" || Feature == "+vfp2d16sp" ||
-   Feature == "+vfp2" || Feature == "+vfp2d16") {
+} else if (Feature == "+vfp2sp" || Feature == "+vfp2") {
   FPU |= VFP2FPU;
   HW_FP |= HW_FP_SP;
-  if (Feature == "+vfp2" || Feature == "+vfp2d16")
+  if (Feature == "+vfp2")
   HW_FP |= HW_FP_DP;
 } else if (Feature == "+vfp3sp" || Feature == "+vfp3d16sp" ||
Feature == "+vfp3" || Feature == "+vfp3d16") {

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=372187=372186=372187=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Tue Sep 17 14:43:19 2019
@@ -460,7 +460,7 @@ fp16_fml_fallthrough:
 //now just be explicit and disable all known dependent features
 //as well.
 for (std::string Feature : {
-"vfp2", "vfp2sp", "vfp2d16", "vfp2d16sp",
+"vfp2", "vfp2sp",
 "vfp3", "vfp3sp", "vfp3d16", "vfp3d16sp",
 "vfp4", "vfp4sp", "vfp4d16", "vfp4d16sp",
 "fp-armv8", "fp-armv8sp", "fp-armv8d16", "fp-armv8d16sp",

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=372187=372186=372187=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Tue Sep 17 14:43:19 2019
@@ -1,23 +1,23 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: 
"target-features"="+armv7-a,+d32,+dsp,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp"
+// CHECK-VFP3: 
"target-features"="+armv7-a,+d32,+dsp,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm 
-o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-2
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
-// CHECK-VFP4-DIV-2: 
"target-features"="+armv7s,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4-DIV: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4-DIV-2: 

[PATCH] D66121: Debug Info: Nest Objective-C property function decls inside their container.

2019-09-17 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I'm afraid I'm going to give up on fixing the AST and return to my 
debuginfo-only patch.

While I was correct in figuring out that ObjCMethodDecl implementations are not 
linked up as redeclarations of ObjCMethodDecl decls in the interface, that 
wasn't the whole story: `ObjCMethodDecl::getNextRedeclarationImpl()` links them 
up *implicitly* by finding the implementation for a decl and vice versa by 
looking up the selector in the interface/implementation (See 
https://github.com/llvm/llvm-project/blob/244e738485445fa4b72bfef9b9b2f9625cee989e/clang/lib/AST/DeclObjC.cpp#L905).

I can make this mechanism work by adding the method to the 
ObjCImplementationDecl, so it gets found by getNextRedeclarationImpl(). But if 
I do that, CodeGen falls over completely, because the new property accessor 
redeclarations don't actually have any function bodies. CodeGen in several 
places special-cases property accessors to generate them on-the-fly. I think 
this may work neatly if we actually created an AST for the function body in 
SemaObjCProperty too, and remove the functionality from CodeGen, but that is 
beyond what I'm prepared to do.


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

https://reviews.llvm.org/D66121



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


r372185 - Revert "Create UsersManual section entitled 'Controlling Floating Point"

2019-09-17 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 17 14:27:07 2019
New Revision: 372185

URL: http://llvm.org/viewvc/llvm-project?rev=372185=rev
Log:
Revert "Create UsersManual section entitled 'Controlling Floating Point"

This reverts commit a08d5a4b0ebd44dc64f41049ed4e97a3c6d31498.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=372185=372184=372185=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Sep 17 14:27:07 2019
@@ -1128,165 +1128,6 @@ number of cases where the compilation en
 and the precompiled header cannot be generated after headers have been
 installed.
 
-.. _controlling-fp-behavior:
-
-Controlling Floating Point Behavior

-
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
-
-.. option:: -ffast-math
-
-   Enable fast-math mode.  This option lets the
-   compiler make aggressive, potentially-lossy assumptions about
-   floating-point math.  These include:
-
-   * Floating-point math obeys regular algebraic rules for real numbers (e.g.
- ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
- ``(a + b) * c == a * c + b * c``),
-   * Operands to floating-point operations are not equal to ``NaN`` and
- ``Inf``, and
-   * ``+0`` and ``-0`` are interchangeable.
-
-   ``-ffast-math`` also defines the ``__FAST_MATH__`` preprocessor
-   macro. Some math libraries recognize this macro and change their behavior.
-   With the exception of ``-ffp-contract=fast``, using any of the options
-   below to disable any of the individual optimizations in ``-ffast-math``
-   will cause ``__FAST_MATH__`` to no longer be set.
-
-  This option implies:
-
-   * ``-fno-honor-infinities``
-
-   * ``-fno-honor-nans``
-
-   * ``-fno-math-errno``
-
-   * ``-ffinite-math``
-
-   * ``-fassociative-math``
-
-   * ``-freciprocal-math``
-
-   * ``-fno-signed-zeros``
-
-   * ``-fno-trapping-math``
-
-   * ``-ffp-contract=fast``
-
-.. option:: -fdenormal-fp-math=
-
-   Select which denormal numbers the code is permitted to require.
-
-   Valid values are: 
-
-   * ``ieee`` - IEEE 754 denormal numbers
-   * ``preserve-sign`` - the sign of a flushed-to-zero number is preserved in 
the sign of 0
-   * ``positive-zero`` - denormals are flushed to positive zero
-
-   Defaults to ``ieee``.
-
-.. option:: -f[no-]strict-float-cast-overflow
-
-   When a floating-point value is not representable in a destination integer 
-   type, the code has undefined behavior according to the language standard.
-   By default, Clang will not guarantee any particular result in that case.
-   With the 'no-strict' option, Clang attempts to match the overflowing 
behavior
-   of the target's native float-to-int conversion instructions.
-
-.. option:: -f[no-]math-errno
-
-   Require math functions to indicate errors by setting errno.
-   The default varies by ToolChain.  ``-fno-math-errno`` allows optimizations
-   that might cause standard C math functions to not set ``errno``.
-   For example, on some systems, the math function ``sqrt`` is specified
-   as setting ``errno`` to ``EDOM`` when the input is negative. On these
-   systems, the compiler cannot normally optimize a call to ``sqrt`` to use
-   inline code (e.g. the x86 ``sqrtsd`` instruction) without additional
-   checking to ensure that ``errno`` is set appropriately.
-   ``-fno-math-errno`` permits these transformations.
-
-   On some targets, math library functions never set ``errno``, and so
-   ``-fno-math-errno`` is the default. This includes most BSD-derived
-   systems, including Darwin.
-
-.. option:: -f[no-]trapping-math
-
-   ``-fno-trapping-math`` allows optimizations that assume that
-   floating point operations cannot generate traps such as divide-by-zero,
-   overflow and underflow. Defaults to ``-ftrapping-math``.
-   Currently this option has no effect.
-
-.. option:: -ffp-contract=
-
-   Specify when the compiler is permitted to form fused floating-point
-   operations, such as fused multiply-add (FMA). Fused operations are
-   permitted to produce more precise results than performing the same
-   operations separately.
-
-   The C standard permits intermediate floating-point results within an
-   expression to be computed with more precision than their type would
-   normally allow. This permits operation fusing, and Clang takes advantage
-   of this by default. This behavior can be controlled with the
-   ``FP_CONTRACT`` pragma. Please refer to the pragma documentation for a
-   description of how the pragma interacts with this option.
-
-   Valid values are:
-
-   * ``fast`` (everywhere)
-   * ``on`` (according to FP_CONTRACT pragma, default)
-   * ``off`` (never fuse)
-
-.. option:: -f[no-]honor-infinities
-
-   If both ``-fno-honor-infinities`` and 

[PATCH] D66121: Debug Info: Nest Objective-C property function decls inside their container.

2019-09-17 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

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

https://reviews.llvm.org/D66121



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


[PATCH] D53768: Add VerboseOutputStream to CompilerInstance

2019-09-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: include/clang/Frontend/CompilerInstance.h:158-159
 
+  /// Whether we should delete VerboseOutputStream on destruction.
+  bool OwnsVerboseOutputStream = false;
+

Rather than a bool, this could be a unique_ptr, perhaps? (null when non-owning)



Comment at: include/clang/Frontend/CompilerInstance.h:362-363
+  /// If not set, this stream defaults to \c llvm::errs().
+  void setVerboseOutputStream(raw_ostream ,
+  bool OwnsOutputStream = false);
+

Two functions - one that takes a raw_ostream& and another that takes a 
unique_ptr?


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

https://reviews.llvm.org/D53768



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


[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington marked an inline comment as done.
erik.pilkington added inline comments.



Comment at: clang/test/Sema/objc-bool-constant-conversion-fixit.m:37
+
+  b = 1 ? 2 : 3;
+  // CHECK: b = 1 ? 2 ? YES : NO : 3 ? YES : NO;

aaron.ballman wrote:
> What about:
> ```
> b = 1 ? (2 ? 3 : 4) : 5;
> ```
> Will it YES/NO all the way down?
Yeah, we produce the following for this:

`b = 1 ? (2 ? 3 ? YES : NO : 4 ? YES : NO) : 5 ? YES : NO;`

Not pretty, but not incorrect.


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

https://reviews.llvm.org/D67559



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


[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372183: [Sema] Split of versions of 
-Wimplicit-{float,int}-conversion for Objective-C… (authored by epilk, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67559?vs=220534=220574#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67559

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/objc-bool-constant-conversion-fixit.m
  cfe/trunk/test/SemaObjC/signed-char-bool-conversion.m

Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -61,9 +61,16 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
-def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ObjCSignedCharBoolImplicitIntConversion :
+  DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",
+ [ObjCSignedCharBoolImplicitIntConversion]>;
 def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion">;
-def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion", [ImplicitIntFloatConversion]>;
+def ObjCSignedCharBoolImplicitFloatConversion :
+  DiagGroup<"objc-signed-char-bool-implicit-float-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion",
+  [ImplicitIntFloatConversion,
+   ObjCSignedCharBoolImplicitFloatConversion]>;
 def ImplicitFixedPointConversion : DiagGroup<"implicit-fixed-point-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
@@ -1015,6 +1022,12 @@
 ObjCStringComparison
   ]>;
 
+def ObjCSignedCharBool : DiagGroup<"objc-signed-char-bool",
+  [ObjCSignedCharBoolImplicitIntConversion,
+   ObjCSignedCharBoolImplicitFloatConversion,
+   ObjCBoolConstantConversion,
+   TautologicalObjCBoolCompare]>;
+
 // Inline ASM warnings.
 def ASMOperandWidths : DiagGroup<"asm-operand-widths">;
 def ASMIgnoredQualifier : DiagGroup<"asm-ignored-qualifier">;
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3290,7 +3290,7 @@
 def warn_impcast_bitfield_precision_constant : Warning<
   "implicit truncation from %2 to bit-field changes value from %0 to %1">,
   InGroup;
-def warn_impcast_constant_int_to_objc_bool : Warning<
+def warn_impcast_constant_value_to_objc_bool : Warning<
   "implicit conversion from constant value %0 to 'BOOL'; "
   "the only well defined values for 'BOOL' are YES and NO">,
   InGroup;
@@ -3308,6 +3308,12 @@
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_objc_signed_char_bool : Warning<
+  "implicit conversion from floating-point type %0 to 'BOOL'">,
+  InGroup;
+def warn_impcast_int_to_objc_signed_char_bool : Warning<
+  "implicit conversion from integral type %0 to 'BOOL'">,
+  InGroup, DefaultIgnore;
 
 // Implicit int -> float conversion precision loss warnings.
 def warn_impcast_integer_float_precision : Warning<
Index: cfe/trunk/test/Sema/objc-bool-constant-conversion-fixit.m
===
--- cfe/trunk/test/Sema/objc-bool-constant-conversion-fixit.m
+++ cfe/trunk/test/Sema/objc-bool-constant-conversion-fixit.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Werror=constant-conversion %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
+// RUN: %clang_cc1 -Werror=objc-signed-char-bool %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
 
 typedef signed char BOOL;
 
@@ -25,6 +25,17 @@
 
   b = 1 << 1;
   // CHECK: b = (1 << 1) ? YES : NO;
+
+  int i;
+
+  b = i;
+  // CHECK: b = i ? YES : NO;
+
+  b = i * 2;
+  // CHECK b = (i * 2) ? YES : NO;
+
+  b = 1 ? 2 : 3;
+  // CHECK: b = 1 ? 2 ? YES : NO : 3 ? YES : NO;
 }
 
 @interface BoolProp
@@ -37,4 +48,12 @@
 
   [bp setB:43];
   // CHECK: [bp setB:43 ? YES : NO];
+
+  int i;
+
+  bp.b = i;
+  // CHECK: bp.b = i ? YES : NO;
+
+  bp.b = i + 1;
+  // CHECK: bp.b = (i + 1) ? YES : NO;
 }
Index: cfe/trunk/test/SemaObjC/signed-char-bool-conversion.m
===
--- cfe/trunk/test/SemaObjC/signed-char-bool-conversion.m
+++ 

r372183 - [Sema] Split of versions of -Wimplicit-{float, int}-conversion for Objective-C BOOL

2019-09-17 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Sep 17 14:11:51 2019
New Revision: 372183

URL: http://llvm.org/viewvc/llvm-project?rev=372183=rev
Log:
[Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C 
BOOL

Also, add a diagnostic group, -Wobjc-signed-char-bool, to control all these
related diagnostics.

rdar://51954400

Differential revision: https://reviews.llvm.org/D67559

Added:
cfe/trunk/test/SemaObjC/signed-char-bool-conversion.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/objc-bool-constant-conversion-fixit.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=372183=372182=372183=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Sep 17 14:11:51 2019
@@ -61,9 +61,16 @@ def BoolConversion : DiagGroup<"bool-con
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
-def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ObjCSignedCharBoolImplicitIntConversion :
+  DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",
+ 
[ObjCSignedCharBoolImplicitIntConversion]>;
 def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion">;
-def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion", 
[ImplicitIntFloatConversion]>;
+def ObjCSignedCharBoolImplicitFloatConversion :
+  DiagGroup<"objc-signed-char-bool-implicit-float-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion",
+  [ImplicitIntFloatConversion,
+   ObjCSignedCharBoolImplicitFloatConversion]>;
 def ImplicitFixedPointConversion : 
DiagGroup<"implicit-fixed-point-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
@@ -1015,6 +1022,12 @@ def ObjCLiteralComparison : DiagGroup<"o
 ObjCStringComparison
   ]>;
 
+def ObjCSignedCharBool : DiagGroup<"objc-signed-char-bool",
+  [ObjCSignedCharBoolImplicitIntConversion,
+   ObjCSignedCharBoolImplicitFloatConversion,
+   ObjCBoolConstantConversion,
+   TautologicalObjCBoolCompare]>;
+
 // Inline ASM warnings.
 def ASMOperandWidths : DiagGroup<"asm-operand-widths">;
 def ASMIgnoredQualifier : DiagGroup<"asm-ignored-qualifier">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=372183=372182=372183=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 17 14:11:51 
2019
@@ -3290,7 +3290,7 @@ def warn_impcast_integer_precision_const
 def warn_impcast_bitfield_precision_constant : Warning<
   "implicit truncation from %2 to bit-field changes value from %0 to %1">,
   InGroup;
-def warn_impcast_constant_int_to_objc_bool : Warning<
+def warn_impcast_constant_value_to_objc_bool : Warning<
   "implicit conversion from constant value %0 to 'BOOL'; "
   "the only well defined values for 'BOOL' are YES and NO">,
   InGroup;
@@ -3308,6 +3308,12 @@ def warn_impcast_literal_float_to_intege
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_objc_signed_char_bool : Warning<
+  "implicit conversion from floating-point type %0 to 'BOOL'">,
+  InGroup;
+def warn_impcast_int_to_objc_signed_char_bool : Warning<
+  "implicit conversion from integral type %0 to 'BOOL'">,
+  InGroup, DefaultIgnore;
 
 // Implicit int -> float conversion precision loss warnings.
 def warn_impcast_integer_float_precision : Warning<

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=372183=372182=372183=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Sep 17 14:11:51 2019
@@ -185,6 +185,12 @@ bool Expr::isKnownToHaveBooleanValue() c
 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
CO->getFalseExpr()->isKnownToHaveBooleanValue();
 
+  if (isa(E))
+return true;
+
+  if (const auto *OVE = dyn_cast(E))
+return OVE->getSourceExpr()->isKnownToHaveBooleanValue();
+
   return false;
 }
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 

[PATCH] D52281: [clang-tidy] Add modernize check to use std::invoke in generic code

2019-09-17 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 abandoned this revision.
boga95 marked 4 inline comments as done.
boga95 added inline comments.



Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:72
+
+const Expr *Obj = BinOp->getLHS();
+const std::string ObjName =

I found an interesting behavior with source location:

```
const SourceManager *Source = Result.SourceManager;

const char *StartPos = Source->getCharacterData(Obj->getLocStart());
const char *EndPos = Source->getCharacterData(Obj->getLocEnd());
```
`StartPos` and `EndPos` point to the exact same location. Is this the expected 
behavior or it is a bug?



Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:70
+const auto *Paren = dyn_cast(MFunctor->getCallee());
+const auto *BinOp = dyn_cast(Paren->getSubExpr());
+

aaron.ballman wrote:
> How do you know `Paren` won't be null? If it cannot be null, please use 
> `cast<>` instead, otherwise, you should be checking for null before 
> dereferencing.
It cannot be null because of the matcher.



Comment at: test/clang-tidy/modernize-replace-generic-functor-call.cpp:24
+template 
+void func2(T func) {
+  func(1);

JonasToth wrote:
> Please add tests that include the usage of macros to do the function call.
> In my opinions these should be excluded from the FIXITs and only the warning 
> should be emitted.
Please show me some example of that.


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

https://reviews.llvm.org/D52281



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


[PATCH] D67670: [clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line starts with tab

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

I should have known it was more involved.

v % 0 and v / 0 are both undefined behavior


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

https://reviews.llvm.org/D67670

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1596,7 +1596,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 +1614,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 {};",
@@ -2086,8 +2086,8 @@
   Style.NamespaceMacros.push_back("TESTSUITE");
 
   verifyFormat("namespace A { namespace B {\n"
-			   "}} // namespace A::B",
-			   Style);
+   "}} // namespace A::B",
+   Style);
 
   EXPECT_EQ("namespace out { namespace in {\n"
 "}} // namespace out::in",
@@ -4450,28 +4450,28 @@
   "SomeClass::Constructor() :\n"
   "aa(aa),\n"
   "aaa() {}",
-	  Style);
+  Style);
   verifyFormat("Constructor(aa ,\n"
"aa ) :\n"
"aa(aa) {}",
-			   Style);
+   Style);
 
   verifyFormat("Constructor() :\n"
"(aaa),\n"
"(aaa,\n"
" aaa),\n"
"aaa() {}",
-			   Style);
+   Style);
 
   verifyFormat("Constructor() :\n"
"(\n"
"a) {}",
-			   Style);
+   Style);
 
   verifyFormat("Constructor(int Parameter = 0) :\n"
"aa(a),\n"
"(a) {}",
-			   Style);
+   Style);
   verifyFormat("Constructor() :\n"
"aa(a), (b) {\n"
"}",
@@ -4479,7 +4479,7 @@
   verifyFormat("Constructor() :\n"
"a(\n"
"a(, )) {}",
-			   Style);
+   Style);
 
   // Here a line could be saved by splitting the second initializer onto two
   // lines, but that is not desirable.
@@ -4487,7 +4487,7 @@
"(),\n"
"aaa(aaa),\n"
"at() {}",
-			   Style);
+   Style);
 
   FormatStyle OnePerLine = Style;
   OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
@@ -4521,10 +4521,10 @@
   OnePerLine.BinPackParameters = false;
   verifyFormat(
   "Constructor() :\n"
-  "(\n"
-  "aaa().aaa(),\n"
-  "a) {}",
-  OnePerLine);
+   "(\n"
+   "aaa().aaa(),\n"
+   "a) {}",
+   OnePerLine);
   OnePerLine.ColumnLimit = 60;
   verifyFormat("Constructor() :\n"
"(a),\n"
@@ -4537,7 +4537,7 @@
 format("Constructor() :\n"
"// Comment forcing unwanted break.\n"
"() {}",
-   Style));
+   Style));
 
   Style.ColumnLimit = 0;
   verifyFormat("SomeClass::Constructor() :\n"
@@ -4547,7 +4547,7 @@
"a(a) {}",
Style);
   verifyFormat("SomeClass::Constructor() :\n"
-			   "a(a), b(b), c(c) {}",
+   "a(a), b(b), c(c) {}",
Style);
   

[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-17 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst:41
+
+.. option:: ExpectedPrefixes
+

aaron.ballman wrote:
> stephanemoore wrote:
> > This option seems to describe a list of class prefixes that are 
> > whitelisted. If that is the case, perhaps `WhitelistedPrefixes` or 
> > `WhitelistedClassPrefixes` would be a better name for the option? WDYT?
> No, please. We should try to avoid "white" and "black" lists in favor of more 
> descriptive terms with less social connotations. I'd be fine with 
> `ExpectedClassPrefixes`, `AllowedPrefixes`, `KnownPrefixes`, etc.
Makes sense. Would `ExemptClassPrefixes` work?


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

https://reviews.llvm.org/D65917



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


[PATCH] D67647: [Consumed] Refactor handleCall to take function argument list. NFC.

2019-09-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: lib/Analysis/Consumed.cpp:752
+  handleCall(Call, nullptr,
+ llvm::makeArrayRef(Call->getArgs(), Call->getNumArgs()),
+ FunDecl);

probably use "Call->arguments()" here & in the other places that need an range 
of the arguments? (& if that can be an ArrayRef - updating CallExpr's 
arguments() and the arg_range and const_arg_range to use/be ArrayRef would be 
good)


Repository:
  rC Clang

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

https://reviews.llvm.org/D67647



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


r372180 - Create UsersManual section entitled 'Controlling Floating Point

2019-09-17 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 17 13:45:23 2019
New Revision: 372180

URL: http://llvm.org/viewvc/llvm-project?rev=372180=rev
Log:
Create UsersManual section entitled 'Controlling Floating Point
Behavior'

Create a new section for documenting the floating point options. Move
all the floating point options into this section, and add new entries
for the floating point options that exist but weren't previously
  described in the UsersManual.

Patch By: mibintc
Differential Revision: https://reviews.llvm.org/D67517

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=372180=372179=372180=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Sep 17 13:45:23 2019
@@ -1128,6 +1128,165 @@ number of cases where the compilation en
 and the precompiled header cannot be generated after headers have been
 installed.
 
+.. _controlling-fp-behavior:
+
+Controlling Floating Point Behavior
+---
+
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
+
+.. option:: -ffast-math
+
+   Enable fast-math mode.  This option lets the
+   compiler make aggressive, potentially-lossy assumptions about
+   floating-point math.  These include:
+
+   * Floating-point math obeys regular algebraic rules for real numbers (e.g.
+ ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
+ ``(a + b) * c == a * c + b * c``),
+   * Operands to floating-point operations are not equal to ``NaN`` and
+ ``Inf``, and
+   * ``+0`` and ``-0`` are interchangeable.
+
+   ``-ffast-math`` also defines the ``__FAST_MATH__`` preprocessor
+   macro. Some math libraries recognize this macro and change their behavior.
+   With the exception of ``-ffp-contract=fast``, using any of the options
+   below to disable any of the individual optimizations in ``-ffast-math``
+   will cause ``__FAST_MATH__`` to no longer be set.
+
+  This option implies:
+
+   * ``-fno-honor-infinities``
+
+   * ``-fno-honor-nans``
+
+   * ``-fno-math-errno``
+
+   * ``-ffinite-math``
+
+   * ``-fassociative-math``
+
+   * ``-freciprocal-math``
+
+   * ``-fno-signed-zeros``
+
+   * ``-fno-trapping-math``
+
+   * ``-ffp-contract=fast``
+
+.. option:: -fdenormal-fp-math=
+
+   Select which denormal numbers the code is permitted to require.
+
+   Valid values are: 
+
+   * ``ieee`` - IEEE 754 denormal numbers
+   * ``preserve-sign`` - the sign of a flushed-to-zero number is preserved in 
the sign of 0
+   * ``positive-zero`` - denormals are flushed to positive zero
+
+   Defaults to ``ieee``.
+
+.. option:: -f[no-]strict-float-cast-overflow
+
+   When a floating-point value is not representable in a destination integer 
+   type, the code has undefined behavior according to the language standard.
+   By default, Clang will not guarantee any particular result in that case.
+   With the 'no-strict' option, Clang attempts to match the overflowing 
behavior
+   of the target's native float-to-int conversion instructions.
+
+.. option:: -f[no-]math-errno
+
+   Require math functions to indicate errors by setting errno.
+   The default varies by ToolChain.  ``-fno-math-errno`` allows optimizations
+   that might cause standard C math functions to not set ``errno``.
+   For example, on some systems, the math function ``sqrt`` is specified
+   as setting ``errno`` to ``EDOM`` when the input is negative. On these
+   systems, the compiler cannot normally optimize a call to ``sqrt`` to use
+   inline code (e.g. the x86 ``sqrtsd`` instruction) without additional
+   checking to ensure that ``errno`` is set appropriately.
+   ``-fno-math-errno`` permits these transformations.
+
+   On some targets, math library functions never set ``errno``, and so
+   ``-fno-math-errno`` is the default. This includes most BSD-derived
+   systems, including Darwin.
+
+.. option:: -f[no-]trapping-math
+
+   ``-fno-trapping-math`` allows optimizations that assume that
+   floating point operations cannot generate traps such as divide-by-zero,
+   overflow and underflow. Defaults to ``-ftrapping-math``.
+   Currently this option has no effect.
+
+.. option:: -ffp-contract=
+
+   Specify when the compiler is permitted to form fused floating-point
+   operations, such as fused multiply-add (FMA). Fused operations are
+   permitted to produce more precise results than performing the same
+   operations separately.
+
+   The C standard permits intermediate floating-point results within an
+   expression to be computed with more precision than their type would
+   normally allow. This permits operation fusing, and Clang takes advantage
+   of this by default. This behavior can be controlled with the
+   ``FP_CONTRACT`` pragma. Please refer to the pragma documentation for a
+   description of how the pragma 

[PATCH] D62394: [ARM][CMSE] Add CMSE header & builtins

2019-09-17 Thread Sigvart Hovland via Phabricator via cfe-commits
sigvartmh resigned from this revision.
sigvartmh added a comment.

Not used to phabricator  tried to remove my request for change. So no one is 
working on upstreaming CMSE to LLVM now?


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

https://reviews.llvm.org/D62394



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


[PATCH] D67678: PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2019-09-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: SjoerdMeijer.
Herald added a subscriber: kristof.beyls.
Herald added a project: clang.

For ARM compilations with NEON enabled, for now we retain the old
default of -flax-vector-conversions=all, because our intrinsic header
 relies on it, and it appears to be far from straightforward
to fix that. (See PR43341.)

See proposal on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2019-April/062030.html


Repository:
  rC Clang

https://reviews.llvm.org/D67678

Files:
  include/clang/Basic/LangOptions.def
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/ARM.h
  lib/Frontend/CompilerInvocation.cpp
  test/Headers/altivec-header.c
  test/Headers/arm-neon-header.c
  test/Headers/x86-intrinsics-headers.c
  test/Headers/x86intrin-2.c
  test/Headers/x86intrin.c
  test/Sema/vector-assign.c
  test/Sema/vector-cast.c
  test/Sema/vector-ops.c

Index: test/Sema/vector-ops.c
===
--- test/Sema/vector-ops.c
+++ test/Sema/vector-ops.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 -flax-vector-conversions=all
 typedef unsigned int v2u __attribute__ ((vector_size (8)));
 typedef int v2s __attribute__ ((vector_size (8)));
 typedef float v2f __attribute__ ((vector_size(8)));
Index: test/Sema/vector-cast.c
===
--- test/Sema/vector-cast.c
+++ test/Sema/vector-cast.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion
+// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion -flax-vector-conversions=all
 
 typedef long long t1 __attribute__ ((vector_size (8)));
 typedef char t2 __attribute__ ((vector_size (16)));
Index: test/Sema/vector-assign.c
===
--- test/Sema/vector-assign.c
+++ test/Sema/vector-assign.c
@@ -14,12 +14,12 @@
   
   v1 = v2; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2u' (vector of 2 'unsigned int' values)}}
   v1 = v3; // expected-error {{assigning to 'v2s' (vector of 2 'int' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
-  v1 = v4; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2f' (vector of 2 'float' values)}}
+  v1 = v4; // expected-error {{assigning to 'v2s' (vector of 2 'int' values) from incompatible type 'v2f' (vector of 2 'float' values)}}
   v1 = v5; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v4ss' (vector of 4 'short' values)}}
   
   v2 = v1; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v2s' (vector of 2 'int' values)}}
   v2 = v3; // expected-error {{assigning to 'v2u' (vector of 2 'unsigned int' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
-  v2 = v4; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v2f' (vector of 2 'float' values)}}
+  v2 = v4; // expected-error {{assigning to 'v2u' (vector of 2 'unsigned int' values) from incompatible type 'v2f' (vector of 2 'float' values)}}
   v2 = v5; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v4ss' (vector of 4 'short' values)}}
   
   v3 = v1; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2s' (vector of 2 'int' values)}}
@@ -27,15 +27,15 @@
   v3 = v4; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2f' (vector of 2 'float' values)}}
   v3 = v5; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v4ss'}}
   
-  v4 = v1; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v2s' (vector of 2 'int' values)}}
-  v4 = v2; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v2u' (vector of 2 'unsigned int' values)}}
+  v4 = v1; // expected-error {{assigning to 'v2f' (vector of 2 'float' values) from incompatible type 'v2s' (vector of 2 'int' values)}}
+  v4 = v2; // expected-error {{assigning to 'v2f' (vector of 2 'float' values) from incompatible type 'v2u' (vector of 2 'unsigned int' values)}}
   v4 = v3; // expected-error {{assigning to 'v2f' (vector of 2 'float' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
-  v4 = v5; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v4ss' (vector of 4 'short' values)}}
+  v4 = v5; // expected-error {{assigning to 'v2f' (vector of 2 'float' values) from 

[PATCH] D61717: Fix arm_neon.h to be clean under -fno-lax-vector-conversions.

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

In D61717#1668980 , @SjoerdMeijer 
wrote:

> Do you perhaps have a test case or error that I can look at? Perhaps I or 
> someone else here can help out a bit here.


You can reproduce the problem with, for example:

  echo '#include ' | clang -target arm64-linux-gnu -arch +neon 
-fsyntax-only -x c - -fno-lax-vector-conversions

I've cleaned up all our other intrinsics headers to be clean under at least 
`-flax-vector-conversions=integer`. I'll be switching the default for all 
targets other than ARM NEON to that imminently. (It'll take a bit more work to 
be able to switch to `-fno-lax-vector-conversions` by default, but getting 
there should be our goal.)

I've filed PR43341 for this issue.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61717



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


[PATCH] D67590: Properly ignore mismatched exception specifiers in MSVC Compat mode.

2019-09-17 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372178: Ignore exception specifier mismatch when merging 
redeclarations (authored by rnk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67590?vs=220564=220565#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67590

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/ms-exception-spec.cpp


Index: cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
===
--- cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
+++ cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
@@ -1,9 +1,36 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions 
-fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
 
+// FIXME: Should -fms-compatibility soften these errors into warnings to match
+// MSVC? In practice, MSVC never implemented dynamic exception specifiers, so
+// there isn't much Windows code in the wild that uses them.
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception 
specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void f() throw(...) { }
 
 namespace PR28080 {
 struct S;   // expected-note {{forward declaration}}
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception 
specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void fn() throw(S); // expected-warning {{incomplete type}} 
expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+template  struct FooPtr {
+  template  FooPtr(U *p) : m_pT(nullptr) {}
+
+  template <>
+  // FIXME: It would be better if this note pointed at the primary template
+  // above.
+  // expected-note@+1 {{previous declaration is here}}
+  FooPtr(T *pInterface) throw() // expected-warning {{exception specification 
in declaration does not match previous declaration}}
+  : m_pT(pInterface) {}
+
+  T *m_pT;
+};
+struct Bar {};
+template struct FooPtr; // expected-note {{requested here}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3562,7 +3562,12 @@
   }
 }
 
-if (OldQTypeForComparison == NewQType)
+// If the function types are compatible, merge the declarations. Ignore the
+// exception specifier because it was already checked above in
+// CheckEquivalentExceptionSpec, and we don't want follow-on diagnostics
+// about incompatible types under -fms-compatibility.
+if (Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
+ NewQType))
   return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
 
 // If the types are imprecise (due to dependent constructs in friends or


Index: cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
===
--- cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
+++ cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
@@ -1,9 +1,36 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
+// FIXME: Should -fms-compatibility soften these errors into warnings to match
+// MSVC? In practice, MSVC never implemented dynamic exception specifiers, so
+// there isn't much Windows code in the wild that uses them.
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void f() throw(...) { }
 
 namespace PR28080 {
 struct S;   // expected-note {{forward declaration}}
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+template  struct FooPtr {
+  template  FooPtr(U *p) : m_pT(nullptr) {}
+
+  template <>
+  // FIXME: It would be better if this note pointed at the primary template
+  // above.
+  // expected-note@+1 {{previous declaration is here}}
+  

r372178 - Ignore exception specifier mismatch when merging redeclarations

2019-09-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Sep 17 13:29:10 2019
New Revision: 372178

URL: http://llvm.org/viewvc/llvm-project?rev=372178=rev
Log:
Ignore exception specifier mismatch when merging redeclarations

Exception specifiers are now part of the function type in C++17.
Normally, it is illegal to redeclare the same function or specialize a
template with a different exception specifier, but under
-fms-compatibility, we accept it with a warning. Without this change,
the function types would not match due to the exception specifier, and
clang would claim that the types were "incompatible". Now we emit the
warning and merge the redeclaration as we would in C++14 and earlier.

Fixes PR42842, which is about compiling _com_ptr_t in C++17.

Based on a patch by Alex Fusco !

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/ms-exception-spec.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=372178=372177=372178=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 17 13:29:10 2019
@@ -3562,7 +3562,12 @@ bool Sema::MergeFunctionDecl(FunctionDec
   }
 }
 
-if (OldQTypeForComparison == NewQType)
+// If the function types are compatible, merge the declarations. Ignore the
+// exception specifier because it was already checked above in
+// CheckEquivalentExceptionSpec, and we don't want follow-on diagnostics
+// about incompatible types under -fms-compatibility.
+if (Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
+ NewQType))
   return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
 
 // If the types are imprecise (due to dependent constructs in friends or

Modified: cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-exception-spec.cpp?rev=372178=372177=372178=diff
==
--- cfe/trunk/test/SemaCXX/ms-exception-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-exception-spec.cpp Tue Sep 17 13:29:10 2019
@@ -1,9 +1,36 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions 
-fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
 
+// FIXME: Should -fms-compatibility soften these errors into warnings to match
+// MSVC? In practice, MSVC never implemented dynamic exception specifiers, so
+// there isn't much Windows code in the wild that uses them.
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception 
specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void f() throw(...) { }
 
 namespace PR28080 {
 struct S;   // expected-note {{forward declaration}}
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception 
specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void fn() throw(S); // expected-warning {{incomplete type}} 
expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+template  struct FooPtr {
+  template  FooPtr(U *p) : m_pT(nullptr) {}
+
+  template <>
+  // FIXME: It would be better if this note pointed at the primary template
+  // above.
+  // expected-note@+1 {{previous declaration is here}}
+  FooPtr(T *pInterface) throw() // expected-warning {{exception specification 
in declaration does not match previous declaration}}
+  : m_pT(pInterface) {}
+
+  T *m_pT;
+};
+struct Bar {};
+template struct FooPtr; // expected-note {{requested here}}


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


[PATCH] D67590: Properly ignore mismatched exception specifiers in MSVC Compat mode.

2019-09-17 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 220564.
rnk added a comment.

- simplify merging check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67590

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/ms-exception-spec.cpp


Index: clang/test/SemaCXX/ms-exception-spec.cpp
===
--- clang/test/SemaCXX/ms-exception-spec.cpp
+++ clang/test/SemaCXX/ms-exception-spec.cpp
@@ -1,9 +1,36 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions 
-fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
 
+// FIXME: Should -fms-compatibility soften these errors into warnings to match
+// MSVC? In practice, MSVC never implemented dynamic exception specifiers, so 
it
+// doesn't seem to cause compatibility issues.
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception 
specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void f() throw(...) { }
 
 namespace PR28080 {
 struct S;   // expected-note {{forward declaration}}
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception 
specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void fn() throw(S); // expected-warning {{incomplete type}} 
expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+template  struct FooPtr {
+  template  FooPtr(U *p) : m_pT(nullptr) {}
+
+  template <>
+  // FIXME: It would be better if this note pointed at the primary template
+  // above.
+  // expected-note@+1 {{previous declaration is here}}
+  FooPtr(T *pInterface) throw() // expected-warning {{exception specification 
in declaration does not match previous declaration}}
+  : m_pT(pInterface) {}
+
+  T *m_pT;
+};
+struct Bar {};
+template struct FooPtr; // expected-note {{requested here}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3562,7 +3562,12 @@
   }
 }
 
-if (OldQTypeForComparison == NewQType)
+// If the function types are compatible, merge the declarations. Ignore the
+// exception specifier because it was already checked above in
+// CheckEquivalentExceptionSpec, and we don't want follow-on diagnostics
+// about incompatible types under -fms-compatibility.
+if (Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
+ NewQType))
   return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
 
 // If the types are imprecise (due to dependent constructs in friends or


Index: clang/test/SemaCXX/ms-exception-spec.cpp
===
--- clang/test/SemaCXX/ms-exception-spec.cpp
+++ clang/test/SemaCXX/ms-exception-spec.cpp
@@ -1,9 +1,36 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
+// FIXME: Should -fms-compatibility soften these errors into warnings to match
+// MSVC? In practice, MSVC never implemented dynamic exception specifiers, so it
+// doesn't seem to cause compatibility issues.
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void f() throw(...) { }
 
 namespace PR28080 {
 struct S;   // expected-note {{forward declaration}}
+#if __cplusplus >= 201703L
+// expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
+// expected-note@+2 {{use 'noexcept(false)' instead}}
+#endif
 void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+template  struct FooPtr {
+  template  FooPtr(U *p) : m_pT(nullptr) {}
+
+  template <>
+  // FIXME: It would be better if this note pointed at the primary template
+  // above.
+  // expected-note@+1 {{previous declaration is here}}
+  FooPtr(T *pInterface) throw() // expected-warning {{exception specification in declaration does not match previous declaration}}
+  : m_pT(pInterface) {}
+
+  T *m_pT;
+};
+struct Bar {};
+template struct FooPtr; // expected-note {{requested here}}
Index: clang/lib/Sema/SemaDecl.cpp

[PATCH] D67522: [clang-scan-deps] Verbose mode

2019-09-17 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b87364f511a: [clang-scan-deps] Add verbose mode (authored 
by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67522?vs=219995=220557#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67522

Files:
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -177,6 +177,11 @@
 "until reaching the end directive."),
 llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt Verbose("v", llvm::cl::Optional,
+llvm::cl::desc("Use verbose output."),
+llvm::cl::init(false),
+llvm::cl::cat(DependencyScannerCategory));
+
 } // end anonymous namespace
 
 /// \returns object-file path derived from source-file path.
@@ -284,8 +289,10 @@
   std::mutex Lock;
   size_t Index = 0;
 
-  llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
-   << " files using " << NumWorkers << " workers\n";
+  if (Verbose) {
+llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
+ << " files using " << NumWorkers << " workers\n";
+  }
   for (unsigned I = 0; I < NumWorkers; ++I) {
 auto Worker = [I, , , , , ]() {
   while (true) {


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -177,6 +177,11 @@
 "until reaching the end directive."),
 llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt Verbose("v", llvm::cl::Optional,
+llvm::cl::desc("Use verbose output."),
+llvm::cl::init(false),
+llvm::cl::cat(DependencyScannerCategory));
+
 } // end anonymous namespace
 
 /// \returns object-file path derived from source-file path.
@@ -284,8 +289,10 @@
   std::mutex Lock;
   size_t Index = 0;
 
-  llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
-   << " files using " << NumWorkers << " workers\n";
+  if (Verbose) {
+llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
+ << " files using " << NumWorkers << " workers\n";
+  }
   for (unsigned I = 0; I < NumWorkers; ++I) {
 auto Worker = [I, , , , , ]() {
   while (true) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372174 - [clang-scan-deps] Add verbose mode

2019-09-17 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Sep 17 12:45:24 2019
New Revision: 372174

URL: http://llvm.org/viewvc/llvm-project?rev=372174=rev
Log:
[clang-scan-deps] Add verbose mode

When running in the default mode we don't print anything other than actual 
output to stdout to make automated processing easier.

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

Modified:
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp

Modified: cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp?rev=372174=372173=372174=diff
==
--- cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp (original)
+++ cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp Tue Sep 17 12:45:24 2019
@@ -177,6 +177,11 @@ llvm::cl::opt SkipExcludedPPRanges
 "until reaching the end directive."),
 llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt Verbose("v", llvm::cl::Optional,
+llvm::cl::desc("Use verbose output."),
+llvm::cl::init(false),
+llvm::cl::cat(DependencyScannerCategory));
+
 } // end anonymous namespace
 
 /// \returns object-file path derived from source-file path.
@@ -284,8 +289,10 @@ int main(int argc, const char **argv) {
   std::mutex Lock;
   size_t Index = 0;
 
-  llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
-   << " files using " << NumWorkers << " workers\n";
+  if (Verbose) {
+llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
+ << " files using " << NumWorkers << " workers\n";
+  }
   for (unsigned I = 0; I < NumWorkers; ++I) {
 auto Worker = [I, , , , , ]() {
   while (true) {


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


[PATCH] D67670: [clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line starts with tab

2019-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/FormatTokenLexer.cpp:660
   case '\t':
-Column += Style.TabWidth - Column % Style.TabWidth;
+Column += Style.TabWidth - (Column ? Column % Style.TabWidth : 0);
 break;

klimek wrote:
> Shouldn't that be (Style.TabWidth ? Column % Style.TabWidth)?
> Otherwise can't that still crash when Column != 0 and TabWidth is 0?
let me add some tests...


Repository:
  rC Clang

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

https://reviews.llvm.org/D67670



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


[PATCH] D66564: [clang-tidy] new FPGA struct pack align check

2019-09-17 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies added a subscriber: alexandre.isoard.
ffrankies added a comment.
Herald added a subscriber: usaxena95.

@alexandre.isoard wrote:

> I'm not sure what is the advantage of this compared to -Wpadded?


This option only warns when padding exists. Our check does two things; it warns 
when there is //too much// padding applied to a struct, and when the alignment 
of the struct isn’t optimal.

In D66564#1670659 , @lebedev.ri wrote:

> I, too, don't believe this is FPGA specific; it should likely go into `misc-` 
> or even `performance-`.


The check can definitely be moved into another module (probably `performance-` 
is a better bet, since it deals with efficiency).

In D66564#1670659 , @lebedev.ri wrote:

> Forgot the most important question.
>  Right now this will fire on every single struct.
>  But it won't matter unless the alignment/size actually matters, and most 
> often that will happen when you have e.g. a vector of such structs.
>  What i'm asking is - should this be more picky, and complain only about the 
> cases where this matters?


I may need to give some context for this lint check (and the ones to follow, 
since we have a few others we’d like to upstream once we figure out the 
process/iron out some bugs).

Our checks are written from the perspective of programmers that write OpenCL 
code specifically for FPGAs, typically in a SIMD context. There is a compiler 
framework that performs the necessary compilation for that to work, but due to 
the nature of the FPGA hardware, it takes a long time for this compilation 
process to complete. Because of this, it is much preferable to use a static 
code analysis tool (clang-tidy) to catch errors/inefficiencies in the code 
before the expensive compilation process starts.

This specific check is based off of the documentation from Intel FPGA SDK for 
OpenCL Pro Edition: Best Practices Guide 
.
 The TLDR version is that if structs are not aligned and/or padded correctly, 
the resulting FPGA configuration becomes inefficient.

To answer the question; the size and alignment of the struct will matter when 
the struct is in an array, but also when the struct’s elements are accessed as 
part of an uncached loop.


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

https://reviews.llvm.org/D66564



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


[PATCH] D67670: [clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line starts with tab

2019-09-17 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/lib/Format/FormatTokenLexer.cpp:660
   case '\t':
-Column += Style.TabWidth - Column % Style.TabWidth;
+Column += Style.TabWidth - (Column ? Column % Style.TabWidth : 0);
 break;

Shouldn't that be (Style.TabWidth ? Column % Style.TabWidth)?
Otherwise can't that still crash when Column != 0 and TabWidth is 0?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67670



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


[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

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

LGTM.




Comment at: clang/test/Sema/objc-bool-constant-conversion-fixit.m:37
+
+  b = 1 ? 2 : 3;
+  // CHECK: b = 1 ? 2 ? YES : NO : 3 ? YES : NO;

What about:
```
b = 1 ? (2 ? 3 : 4) : 5;
```
Will it YES/NO all the way down?



Comment at: clang/test/SemaObjC/signed-char-bool-conversion.m:48
+  bp.p = 1;
+  bp.p = 2; // expected-warning {{implicit conversion from constant value 2 to 
BOOL; the only well defined values for BOOL are YES and NO}}
+}

'BOOL', 'YES', and 'NO' at some point (doesn't have to be in this patch).


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

https://reviews.llvm.org/D67559



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


[PATCH] D63607: [clang][driver] Add basic --driver-mode=fortran support for flang

2019-09-17 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added a comment.
Herald added a subscriber: usaxena95.

Hi Peter

The overall approach seems good to me and matches how the driver is integrated 
in the original flang project so not too many surprises. I left a few comments 
mostly about the scope of the original patch. I wonder how much sense it makes 
to add support for routing options on to (f18) flang that it does not support 
yet? Would it not be better to add these options to the clang driver at the 
same time as they arrive in flang -fc1?

Ta
Rich




Comment at: clang/lib/Driver/Driver.cpp:4788
+bool Driver::ShouldUseFlangCompiler(const JobAction ) const {
+  // Say "no" if there is not exactly one input of a type flang understands.
+  if (JA.size() != 1 ||

This first clause surprised me. Is this a temporary measure or do we never 
intend to support compiling more than one fortran file at once?



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:37
+  if (isa(JA)) {
+CmdArgs.push_back("-emit-obj");
+  } else if (isa(JA)) {

F18 does not currently support these options that control the output like 
-emit-llvm and -emit-obj so this code doesn't do anything sensible at present. 
Would it not make more sense to add this later on once F18 or llvm/flang grows 
support for such options?



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:44
+if (JA.getType() == types::TY_Nothing) {
+  CmdArgs.push_back("-fsyntax-only");
+} else if (JA.getType() == types::TY_LLVM_IR ||

Looks like the F18 option spelling for this is -fparse-only? Or maybe 
-fdebug-semantics? I know the intention is to throw away the 'throwaway driver' 
in F18, so perhaps you are preparing to replace this option spelling in the 
throwaway driver with -fsyntax-only so this would highlight that perhaps adding 
the code here before the F18 driver is ready to accept it is not the right 
approach?



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:67
+  Args.AddAllArgs(CmdArgs, options::OPT_R_Group); // "Rpass-"" options 
passthrough.
+  Args.AddAllArgs(CmdArgs, options::OPT_gfortran_Group); // gfortran options 
passthrough.
+

Similarly to previous comment, do we want to be passing all gfortran options 
through to F18 in the immediate term or even the long term? I don't think there 
has been any agreement yet on what the options that F18 will support are 
(although I agree that gfortran-like options would be most sensible and in 
keeping with clang's philosophy)



Comment at: clang/test/Driver/fortran.f95:1
-// Check that the clang driver can invoke gcc to compile Fortran.
+! Check that the clang driver can invoke gcc to compile Fortran.
 

... when not in --driver-mode=fortran


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

https://reviews.llvm.org/D63607



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


r372152 - Use 'BOOL' instead of BOOL in diagnostic messages

2019-09-17 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Sep 17 11:02:45 2019
New Revision: 372152

URL: http://llvm.org/viewvc/llvm-project?rev=372152=rev
Log:
Use 'BOOL' instead of BOOL in diagnostic messages

Type names should be enclosed in single quotes.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Sema/objc-bool-constant-conversion.m
cfe/trunk/test/Sema/tautological-objc-bool-compare.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=372152=372151=372152=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 17 11:02:45 
2019
@@ -3291,8 +3291,8 @@ def warn_impcast_bitfield_precision_cons
   "implicit truncation from %2 to bit-field changes value from %0 to %1">,
   InGroup;
 def warn_impcast_constant_int_to_objc_bool : Warning<
-  "implicit conversion from constant value %0 to BOOL; "
-  "the only well defined values for BOOL are YES and NO">,
+  "implicit conversion from constant value %0 to 'BOOL'; "
+  "the only well defined values for 'BOOL' are YES and NO">,
   InGroup;
 
 def warn_impcast_fixed_point_range : Warning<
@@ -6109,8 +6109,8 @@ def warn_tautological_constant_compare :
   "%select{%1|%3}0 is always %4">,
   InGroup, DefaultIgnore;
 def warn_tautological_compare_objc_bool : Warning<
-  "result of comparison of constant %0 with expression of type BOOL"
-  " is always %1, as the only well defined values for BOOL are YES and NO">,
+  "result of comparison of constant %0 with expression of type 'BOOL'"
+  " is always %1, as the only well defined values for 'BOOL' are YES and NO">,
   InGroup;
 
 def warn_mixed_sign_comparison : Warning<

Modified: cfe/trunk/test/Sema/objc-bool-constant-conversion.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-bool-constant-conversion.m?rev=372152=372151=372152=diff
==
--- cfe/trunk/test/Sema/objc-bool-constant-conversion.m (original)
+++ cfe/trunk/test/Sema/objc-bool-constant-conversion.m Tue Sep 17 11:02:45 2019
@@ -12,20 +12,20 @@ int main() {
   B = YES;
   B = NO;
 
-  B = -1; // expected-warning{{implicit conversion from constant value -1 to 
BOOL; the only well defined values for BOOL are YES and NO}}
-  B = 0 - 1; // expected-warning{{implicit conversion from constant value -1 
to BOOL; the only well defined values for BOOL are YES and NO}}
-  B = YES + YES; // expected-warning {{implicit conversion from constant value 
2 to BOOL; the only well defined values for BOOL are YES and NO}}
+  B = -1; // expected-warning{{implicit conversion from constant value -1 to 
'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
+  B = 0 - 1; // expected-warning{{implicit conversion from constant value -1 
to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
+  B = YES + YES; // expected-warning {{implicit conversion from constant value 
2 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
   B = YES | YES;
 
-  B = B ? 2 : 2; // expected-warning 2 {{implicit conversion from constant 
value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+  B = B ? 2 : 2; // expected-warning 2 {{implicit conversion from constant 
value 2 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
 
-  BOOL Init = -1; // expected-warning{{implicit conversion from constant value 
-1 to BOOL; the only well defined values for BOOL are YES and NO}}
-  BOOL Init2 = B ? 2 : 2; // expected-warning 2 {{implicit conversion from 
constant value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+  BOOL Init = -1; // expected-warning{{implicit conversion from constant value 
-1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
+  BOOL Init2 = B ? 2 : 2; // expected-warning 2 {{implicit conversion from 
constant value 2 to 'BOOL'; the only well defined values for 'BOOL' are YES and 
NO}}
 
   void takesbool(BOOL);
-  takesbool(43); // expected-warning {{implicit conversion from constant value 
43 to BOOL; the only well defined values for BOOL are YES and NO}}
+  takesbool(43); // expected-warning {{implicit conversion from constant value 
43 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
 
-  BOOL OutOfRange = 400; // expected-warning{{implicit conversion from 
constant value 400 to BOOL; the only well defined values for BOOL are YES and 
NO}}
+  BOOL OutOfRange = 400; // expected-warning{{implicit conversion from 
constant value 400 to 'BOOL'; the only well defined values for 'BOOL' are YES 
and NO}}
 }
 
 @interface BoolProp
@@ -33,6 +33,6 @@ int main() {
 @end
 
 void f(BoolProp *bp) {
-  bp.b = 43; // expected-warning {{implicit conversion from constant value 43 
to BOOL; the only well 

[PATCH] D62394: [ARM][CMSE] Add CMSE header & builtins

2019-09-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a subscriber: chill.
dmgreen added a comment.

I'm afraid the upstreaming of CMSE has stalled, and this is not all that would 
be needed to get it working. This adds some header files and clang builtins, 
the selection of them in the backend isn't yet present, hence the error you are 
seeing. There are more patches to follow around lowering intrinsics and 
clearing registers correctly.


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

https://reviews.llvm.org/D62394



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


[PATCH] D67613: [DWARF-5] Support for DWARF-5 C++ language tags

2019-09-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX marked 2 inline comments as done.
SouraVX added inline comments.



Comment at: include/clang/AST/DeclCXX.h:2931
+lang_cxx_11 = /* DW_LANG_C_plus_plus_11 */ 0x001a,
+lang_cxx_14 = /* DW_LANG_C_plus_plus_14 */ 0x0021
   };

aprantl wrote:
> SouraVX wrote:
> > aprantl wrote:
> > > SouraVX wrote:
> > > > aprantl wrote:
> > > > > I understand that DWARF does not define a C++17 language constant, 
> > > > > but in the AST I fell like we should represent it, even if it is 
> > > > > being lowered into C++14 for the debug info.
> > > > It's represented in AST as enum in LangStandard.h file. We didn't add 
> > > > it here, as DWARF5 has no opcode for C++17. If we add it here some 
> > > > opcode, this might cause conflict with future upcoming DWARF standard.
> > > Since these are the DWARF DW_lang constants, we shouldn't repeat their 
> > > numeric values here. Can we write this as
> > > `lang_c = llvm::dwarf::DW_LANG_C`, etc?
> > We can do this, but not sure whether, we should do this in AST ?
> > Since it's a language specific part, if we integrate this from DWARF 
> > opcodes it will unnecessary pollute AST ?  Other language opcodes will also 
> > be visible here. 
> I'm not sure I understand the concern here. Are you worried about #Including 
> "llvm/BinaryFormat/DWARF.h" and making these definitions visible to users of 
> DeclCXX.h? All symbols there are in a separate namespace.
Thanks @aprantl  for your review.
I was sceptical about,  introducing DWARF related changes to AST, however 
you're correct, those are just language enums. 
This will be heplfull in future, while adding language tag.  If more C/C++ 
versions become part of DWARF standard.
Will address this change in next revision.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67613



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


[PATCH] D67670: [clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line starts with tab

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

clang-format 8.0 crashes with SIGFPE (floating point exception) when formatting 
following file:
app.cpp:
void a() {
//line starts with '\t'
}

$ clang-format -style='{TabWidth: 0}' app.cpp


Repository:
  rC Clang

https://reviews.llvm.org/D67670

Files:
  clang/lib/Format/FormatTokenLexer.cpp


Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -657,7 +657,7 @@
 ++Column;
 break;
   case '\t':
-Column += Style.TabWidth - Column % Style.TabWidth;
+Column += Style.TabWidth - (Column ? Column % Style.TabWidth : 0);
 break;
   case '\\':
 if (i + 1 == e || (Text[i + 1] != '\r' && Text[i + 1] != '\n'))


Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -657,7 +657,7 @@
 ++Column;
 break;
   case '\t':
-Column += Style.TabWidth - Column % Style.TabWidth;
+Column += Style.TabWidth - (Column ? Column % Style.TabWidth : 0);
 break;
   case '\\':
 if (i + 1 == e || (Text[i + 1] != '\r' && Text[i + 1] != '\n'))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67584: [Support] Replace function with function_ref in writeFileAtomically. NFC

2019-09-17 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

Good point! Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67584



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


r372148 - [OPENMP] Rework the test, NFC.

2019-09-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 17 10:44:27 2019
New Revision: 372148

URL: http://llvm.org/viewvc/llvm-project?rev=372148=rev
Log:
[OPENMP] Rework the test, NFC.

Modified:
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372148=372147=372148=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Tue Sep 17 10:44:27 2019
@@ -387,14 +387,12 @@ void parallel_for(float *a, const int n)
 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-18]],
 
 #else // OMP5
-// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 
0, i32 514, i32 0, i32 0, i8*
-
 // OMP5-LABEL: increment
 int increment () {
 // OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
[[DEFAULT_LOC:[@%].+]])
   #pragma omp for
 // Determine UB = min(UB, GlobalUB)
-// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* [[LOOP_LOC]], 
i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
+// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* 
[[LOOP_LOC:[@%].+]], i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* 
[[OMP_LB:%[^,]+]], i32* [[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // OMP5-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
 // OMP5-NEXT: [[UBCMP:%.+]] = icmp sgt i32 [[UB]], 4
 // OMP5-NEXT: br i1 [[UBCMP]], label [[UB_TRUE:%[^,]+]], label 
[[UB_FALSE:%[^,]+]]


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


r372147 - [OPENMP5.0]Introduce attribute for declare variant directive.

2019-09-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 17 10:36:49 2019
New Revision: 372147

URL: http://llvm.org/viewvc/llvm-project?rev=372147=rev
Log:
[OPENMP5.0]Introduce attribute for declare variant directive.

Added attribute for declare variant directive. It will allow to handle
declare variant directive at the codegen and will allow to add extra
checks.

Added:
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Sep 17 10:36:49 2019
@@ -3265,6 +3265,29 @@ def OMPAllocateDecl : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def OMPDeclareVariant : Attr {
+  let Spellings = [Pragma<"omp", "declare variant">];
+  let Subjects = SubjectList<[Function]>;
+  let SemaHandler = 0;
+  let HasCustomParsing = 1;
+  let Documentation = [OMPDeclareVariantDocs];
+  let Args = [
+ExprArgument<"VariantFuncRef">
+  ];
+  let AdditionalMembers = [{
+void printPrettyPragma(raw_ostream & OS, const PrintingPolicy )
+const {
+  if (const Expr *E = getVariantFuncRef()) {
+OS << "(";
+E->printPretty(OS, nullptr, Policy);
+OS << ")";
+  }
+  // TODO: add printing of real context selectors.
+  OS << " match(unknown={})";
+}
+  }];
+}
+
 def InternalLinkage : InheritableAttr {
   let Spellings = [Clang<"internal_linkage">];
   let Subjects = SubjectList<[Var, Function, CXXRecord]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Sep 17 10:36:49 2019
@@ -3208,6 +3208,34 @@ where clause is one of the following:
   }];
 }
 
+def OMPDeclareVariantDocs : Documentation {
+  let Category = DocCatFunction;
+  let Heading = "#pragma omp declare variant";
+  let Content = [{
+The `declare variant` directive declares a specialized variant of a base
+ function and specifies the context in which that specialized variant is used.
+ The declare variant directive is a declarative directive.
+The syntax of the `declare variant` construct is as follows:
+
+  .. code-block:: none
+
+#pragma omp declare variant(variant-func-id) clause new-line
+[#pragma omp declare variant(variant-func-id) clause new-line]
+[...]
+function definition or declaration
+
+where clause is one of the following:
+
+  .. code-block:: none
+
+match(context-selector-specification)
+
+and where `variant-func-id` is the name of a function variant that is either a
+ base language identifier or, for C++, a template-id.
+
+  }];
+}
+
 def NoStackProtectorDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 17 10:36:49 
2019
@@ -9429,6 +9429,10 @@ def err_omp_declare_variant_diff : Error
 def err_omp_declare_variant_incompat_types : Error<
   "variant in '#pragma omp declare variant' with type %0 is incompatible with 
type %1"
   >;
+def warn_omp_declare_variant_marked_as_declare_variant : Warning<
+  "variant function in '#pragma omp declare variant' is itself marked as 
'#pragma omp declare variant'"
+  >, InGroup;
+def note_omp_marked_declare_variant_here : Note<"marked as 'declare variant' 
here">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Sep 17 10:36:49 2019
@@ -9089,6 +9089,12 @@ private:
  MapT , unsigned Selector = 0,
  

[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3312
+def warn_impcast_float_to_objc_signed_char_bool : Warning<
+  "implicit conversion from floating-point type %0 to BOOL">,
+  InGroup;

aaron.ballman wrote:
> Can you put single quotes around `BOOL` since it's a type name? Same below.
Sure, this also needs to be fixed for 
`warn_impcast_constant_value_to_objc_bool` and 
`warn_tautological_compare_objc_bool`, I'll do that separately. 



Comment at: clang/test/SemaObjC/signed-char-bool-conversion.m:3
+// RUN: %clang_cc1 -xobjective-c++ %s -verify -Wobjc-signed-char-bool
+
+typedef signed char BOOL;

aaron.ballman wrote:
> Can you add a test verifying the fix-it behaviors (with and without parens)?
Sure, while testing this I noticed that we don't handle parens with 
`OpaqueValueExpr`s properly, so I added a case.


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

https://reviews.llvm.org/D67559



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


[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 220534.
erik.pilkington marked 5 inline comments as done.
erik.pilkington added a comment.

Address review comments.


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

https://reviews.llvm.org/D67559

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/objc-bool-constant-conversion-fixit.m
  clang/test/SemaObjC/signed-char-bool-conversion.m

Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- /dev/null
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -verify -Wobjc-signed-char-bool
+// RUN: %clang_cc1 -xobjective-c++ %s -verify -Wobjc-signed-char-bool
+
+typedef signed char BOOL;
+#define YES __objc_yes
+#define NO __objc_no
+
+typedef unsigned char Boolean;
+
+BOOL b;
+Boolean boolean;
+float fl;
+int i;
+int *ptr;
+
+void t1() {
+  b = boolean;
+  b = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}}
+  b = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = 1.0;
+  b = 0.0;
+  b = 1.1; // expected-warning {{implicit conversion from 'double' to 'BOOL' (aka 'signed char') changes value from 1.1 to 1}}
+  b = 2.1; // expected-warning {{implicit conversion from constant value 2.1 to BOOL; the only well defined values for BOOL are YES and NO}}
+
+  b = YES;
+#ifndef __cplusplus
+  b = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
+#endif
+}
+
+@interface BoolProp
+@property BOOL p;
+@end
+
+void t2(BoolProp *bp) {
+  bp.p = YES;
+  bp.p = NO;
+  bp.p = boolean;
+  bp.p = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}}
+  bp.p = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  bp.p = b;
+  bp.p = bp.p;
+#ifndef __cplusplus
+  bp.p = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
+#endif
+  bp.p = 1;
+  bp.p = 2; // expected-warning {{implicit conversion from constant value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+}
Index: clang/test/Sema/objc-bool-constant-conversion-fixit.m
===
--- clang/test/Sema/objc-bool-constant-conversion-fixit.m
+++ clang/test/Sema/objc-bool-constant-conversion-fixit.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Werror=constant-conversion %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
+// RUN: %clang_cc1 -Werror=objc-signed-char-bool %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
 
 typedef signed char BOOL;
 
@@ -25,6 +25,17 @@
 
   b = 1 << 1;
   // CHECK: b = (1 << 1) ? YES : NO;
+
+  int i;
+
+  b = i;
+  // CHECK: b = i ? YES : NO;
+
+  b = i * 2;
+  // CHECK b = (i * 2) ? YES : NO;
+
+  b = 1 ? 2 : 3;
+  // CHECK: b = 1 ? 2 ? YES : NO : 3 ? YES : NO;
 }
 
 @interface BoolProp
@@ -37,4 +48,12 @@
 
   [bp setB:43];
   // CHECK: [bp setB:43 ? YES : NO];
+
+  int i;
+
+  bp.b = i;
+  // CHECK: bp.b = i ? YES : NO;
+
+  bp.b = i + 1;
+  // CHECK: bp.b = (i + 1) ? YES : NO;
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10840,6 +10840,26 @@
   DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
 }
 
+static bool isObjCSignedCharBool(Sema , QualType Ty) {
+  return Ty->isSpecificBuiltinType(BuiltinType::SChar) &&
+  S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty);
+}
+
+static void adornObjCBoolConversionDiagWithTernaryFixit(
+Sema , Expr *SourceExpr, const Sema::SemaDiagnosticBuilder ) {
+  Expr *Ignored = SourceExpr->IgnoreImplicit();
+  if (const auto *OVE = dyn_cast(Ignored))
+Ignored = OVE->getSourceExpr();
+  bool NeedsParens = isa(Ignored) ||
+ isa(Ignored) ||
+ isa(Ignored);
+  SourceLocation EndLoc = S.getLocForEndOfToken(SourceExpr->getEndLoc());
+  if (NeedsParens)
+Builder << FixItHint::CreateInsertion(SourceExpr->getBeginLoc(), "(")
+<< FixItHint::CreateInsertion(EndLoc, ")");
+  Builder << FixItHint::CreateInsertion(EndLoc, " ? YES : NO");
+}
+
 /// Diagnose an implicit cast from a floating point value to an integer value.
 static void DiagnoseFloatingImpCast(Sema , Expr *E, QualType T,
 SourceLocation CContext) {
@@ -10859,6 +10879,13 @@
   bool IsConstant =
 E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects);
   if (!IsConstant) {
+if (isObjCSignedCharBool(S, T)) {
+  return adornObjCBoolConversionDiagWithTernaryFixit(
+  S, E,
+  

[PATCH] D67613: [DWARF-5] Support for DWARF-5 C++ language tags

2019-09-17 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: include/clang/AST/DeclCXX.h:2931
+lang_cxx_11 = /* DW_LANG_C_plus_plus_11 */ 0x001a,
+lang_cxx_14 = /* DW_LANG_C_plus_plus_14 */ 0x0021
   };

SouraVX wrote:
> aprantl wrote:
> > SouraVX wrote:
> > > aprantl wrote:
> > > > I understand that DWARF does not define a C++17 language constant, but 
> > > > in the AST I fell like we should represent it, even if it is being 
> > > > lowered into C++14 for the debug info.
> > > It's represented in AST as enum in LangStandard.h file. We didn't add it 
> > > here, as DWARF5 has no opcode for C++17. If we add it here some opcode, 
> > > this might cause conflict with future upcoming DWARF standard.
> > Since these are the DWARF DW_lang constants, we shouldn't repeat their 
> > numeric values here. Can we write this as
> > `lang_c = llvm::dwarf::DW_LANG_C`, etc?
> We can do this, but not sure whether, we should do this in AST ?
> Since it's a language specific part, if we integrate this from DWARF opcodes 
> it will unnecessary pollute AST ?  Other language opcodes will also be 
> visible here. 
I'm not sure I understand the concern here. Are you worried about #Including 
"llvm/BinaryFormat/DWARF.h" and making these definitions visible to users of 
DeclCXX.h? All symbols there are in a separate namespace.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67613



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


[PATCH] D67661: [RISCV] Headers: Add Bitmanip extension Clang header files and rvintrin.h

2019-09-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Inline asm is //really// unfriendly to the optimizer.
Ideally the plan should be to incrementally getting rid of it as soon as 
backend learns to properly match particular builtin.




Comment at: 
clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp:59-68
+  {"include/rv32bintrin-builtins.h$", "rv32bintrin-builtins.h"},
+  {"include/rv32bintrin-emulation.h$", "rv32bintrin-emulation.h"},
+  {"include/rv32bintrin.h$", "rv32bintrin.h"},
+  {"include/rv64bintrin-asm.h$", "rv64bintrin-asm.h"},
+  {"include/rv64bintrin-builtins.h$", "rv64bintrin-builtins.h"},
+  {"include/rv64bintrin-emulation.h$", "rv64bintrin-emulation.h"},
+  {"include/rv64bintrin.h$", "rv64bintrin.h"},

`<>` missing?



Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.cpp:157-166
+  {"include/rv32bintrin-builtins.h", "rv32bintrin-builtins.h"},
+  {"include/rv32bintrin-emulation.h", "rv32bintrin-emulation.h"},
+  {"include/rv32bintrin.h", "rv32bintrin.h"},
+  {"include/rv64bintrin-asm.h", "rv64bintrin-asm.h"},
+  {"include/rv64bintrin-builtins.h", "rv64bintrin-builtins.h"},
+  {"include/rv64bintrin-emulation.h", "rv64bintrin-emulation.h"},
+  {"include/rv64bintrin.h", "rv64bintrin.h"},

`<>` missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67661



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


[PATCH] D67613: [DWARF-5] Support for DWARF-5 C++ language tags

2019-09-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX marked an inline comment as done.
SouraVX added inline comments.



Comment at: include/clang/AST/DeclCXX.h:2931
+lang_cxx_11 = /* DW_LANG_C_plus_plus_11 */ 0x001a,
+lang_cxx_14 = /* DW_LANG_C_plus_plus_14 */ 0x0021
   };

aprantl wrote:
> SouraVX wrote:
> > aprantl wrote:
> > > I understand that DWARF does not define a C++17 language constant, but in 
> > > the AST I fell like we should represent it, even if it is being lowered 
> > > into C++14 for the debug info.
> > It's represented in AST as enum in LangStandard.h file. We didn't add it 
> > here, as DWARF5 has no opcode for C++17. If we add it here some opcode, 
> > this might cause conflict with future upcoming DWARF standard.
> Since these are the DWARF DW_lang constants, we shouldn't repeat their 
> numeric values here. Can we write this as
> `lang_c = llvm::dwarf::DW_LANG_C`, etc?
We can do this, but not sure whether, we should do this in AST ?
Since it's a language specific part, if we integrate this from DWARF opcodes it 
will unnecessary pollute AST ?  Other language opcodes will also be visible 
here. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D67613



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


[PATCH] D67590: Properly ignore mismatched exception specifiers in MSVC Compat mode.

2019-09-17 Thread Zachary Henkel via Phabricator via cfe-commits
zahen added a comment.

I just checked a trivial mismatch example in clang 8.0 
(https://godbolt.org/z/wiSAp6) and I missed how the compatibility mode 
operates.  I withdraw my suggestion since the patch keeps consistency with the 
existing behavior.  Thanks for the `-Werror=microsoft-exception-spec` 
suggestion that's exactly what our project wants.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67590



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


[PATCH] D67613: [DWARF-5] Support for DWARF-5 C++ language tags

2019-09-17 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: include/clang/AST/DeclCXX.h:2931
+lang_cxx_11 = /* DW_LANG_C_plus_plus_11 */ 0x001a,
+lang_cxx_14 = /* DW_LANG_C_plus_plus_14 */ 0x0021
   };

SouraVX wrote:
> aprantl wrote:
> > I understand that DWARF does not define a C++17 language constant, but in 
> > the AST I fell like we should represent it, even if it is being lowered 
> > into C++14 for the debug info.
> It's represented in AST as enum in LangStandard.h file. We didn't add it 
> here, as DWARF5 has no opcode for C++17. If we add it here some opcode, this 
> might cause conflict with future upcoming DWARF standard.
Since these are the DWARF DW_lang constants, we shouldn't repeat their numeric 
values here. Can we write this as
`lang_c = llvm::dwarf::DW_LANG_C`, etc?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67613



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


[PATCH] D67590: Properly ignore mismatched exception specifiers in MSVC Compat mode.

2019-09-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D67590#1672691 , @zahen wrote:

> Is there any interest in supporting the cl.exe flag `/permissive-`?  I 
> considered a hard error on mismatched exception specifier in clang-cl a 
> feature, not a bug.  If msvc compat mode respected that flag this could 
> continue to be an error with that flag set (and upgraded strictness in other 
> cases).


Does `/permissive-` in cl.exe turn this specific thing into an error? If not, 
we don't want to add this under that flag.

You can always use `-Werror=microsoft-exception-spec` to turn this into an 
error.

This behavior is necessary to parse system headers, and the general strategy 
for system headers is "accept enough to be able to parse system headers, but 
emit a warning". 
https://docs.google.com/presentation/d/1oxNHaVjA9Gn_rTzX6HIpJHP7nXRua_0URXxxJ3oYRq0/edit#slide=id.p
 has some more words on this (slides 26/27).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67590



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


[PATCH] D67659: [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

2019-09-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372129: [clang-format] Fix cleanup of `AnnotatedLine` to 
include children nodes. (authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67659?vs=220504=220506#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67659

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1417,22 +1417,29 @@
 
 checkEmptyNamespace(AnnotatedLines);
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto *Line : AnnotatedLines)
+  cleanupLine(Line);
 
 return {generateFixes(), 0};
   }
 
 private:
+  void cleanupLine(AnnotatedLine *Line) {
+for (auto *Child : Line->Children) {
+  cleanupLine(Child);
+}
+
+if (Line->Affected) {
+  cleanupRight(Line->First, tok::comma, tok::comma);
+  cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
+  cleanupRight(Line->First, tok::l_paren, tok::comma);
+  cleanupLeft(Line->First, tok::comma, tok::r_paren);
+  cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
+}
+  }
+
   bool containsOnlyComments(const AnnotatedLine ) {
 for (FormatToken *Tok = Line.First; Tok != nullptr; Tok = Tok->Next) {
   if (Tok->isNot(tok::comment))
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -183,10 +183,15 @@
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";
   EXPECT_EQ(Expected, cleanupAroundOffsets({15, 18, 29, 33}, Code));
+
+  // Lambda contents are also checked for trailing commas.
+  Code = "int main() { [](){f(,1,,2,3,f(1,2,),4,,);}();}";
+  Expected = "int main() { [](){f(1,2,3,f(1,2),4);}();}";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({20, 23, 34, 38}, Code));
 }
 
 TEST_F(CleanupTest, TrailingCommaInBraces) {
-  // Trainling comma is allowed in brace list.
+  // Trailing comma is allowed in brace list.
   // If there was trailing comma in the original code, then trailing comma is
   // preserved. In this example, element between the last two commas is deleted
   // causing the second-last comma to be redundant.
@@ -194,7 +199,7 @@
   std::string Expected = "void f() { std::vector v = {1,2,3,}; }";
   EXPECT_EQ(Expected, cleanupAroundOffsets({39}, Code));
 
-  // If there was no trailing comma in the original code, then trainling comma
+  // If there was no trailing comma in the original code, then trailing comma
   // introduced by replacements should be cleaned up. In this example, the
   // element after the last comma is deleted causing the last comma to be
   // redundant.


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1417,22 +1417,29 @@
 
 checkEmptyNamespace(AnnotatedLines);
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto *Line : AnnotatedLines)
+  cleanupLine(Line);
 
 return {generateFixes(), 0};
   }
 
 private:
+  void cleanupLine(AnnotatedLine *Line) {
+for (auto *Child : Line->Children) {
+  cleanupLine(Child);
+}
+
+if (Line->Affected) {
+  cleanupRight(Line->First, tok::comma, tok::comma);
+  cleanupRight(Line->First, TT_CtorInitializerColon, 

r372130 - [OPENMP]Try to rework the test to pacify the buildbots, NFC.

2019-09-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 17 08:11:52 2019
New Revision: 372130

URL: http://llvm.org/viewvc/llvm-project?rev=372130=rev
Log:
[OPENMP]Try to rework the test to pacify the buildbots, NFC.

Modified:
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372130=372129=372130=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Tue Sep 17 08:11:52 2019
@@ -387,15 +387,14 @@ void parallel_for(float *a, const int n)
 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-18]],
 
 #else // OMP5
-// OMP5: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { i32 
0, i32 514, i32 0, i32 0, i8*
+// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 
0, i32 514, i32 0, i32 0, i8*
 
 // OMP5-LABEL: increment
 int increment () {
-// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* 
[[DEFAULT_LOC:[@%].+]])
+// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
[[DEFAULT_LOC:[@%].+]])
   #pragma omp for
 // Determine UB = min(UB, GlobalUB)
-// OMP5: call void @__kmpc_for_static_init_4([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
+// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* [[LOOP_LOC]], 
i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // OMP5-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
 // OMP5-NEXT: [[UBCMP:%.+]] = icmp sgt i32 [[UB]], 4
 // OMP5-NEXT: br i1 [[UBCMP]], label [[UB_TRUE:%[^,]+]], label 
[[UB_FALSE:%[^,]+]]
@@ -425,7 +424,7 @@ int increment () {
 // OMP5-NEXT: br label %[[LOOP1_HEAD]]
 ;
 // OMP5: [[LOOP1_END]]
-// OMP5: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
+// OMP5: call void @__kmpc_for_static_fini(%struct.ident_t* [[LOOP_LOC]], i32 
[[GTID]])
 // OMP5: __kmpc_barrier
   return 0;
 // OMP5: ret i32 0
@@ -433,10 +432,10 @@ int increment () {
 
 // OMP5-LABEL: decrement_nowait
 int decrement_nowait () {
-// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* 
[[DEFAULT_LOC:[@%].+]])
+// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
[[DEFAULT_LOC:[@%].+]])
   #pragma omp for nowait
 // Determine UB = min(UB, GlobalUB)
-// OMP5: call void @__kmpc_for_static_init_4([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
+// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* [[LOOP_LOC]], 
i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // OMP5-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
 // OMP5-NEXT: [[UBCMP:%.+]] = icmp sgt i32 [[UB]], 4
 // OMP5-NEXT: br i1 [[UBCMP]], label [[UB_TRUE:%[^,]+]], label 
[[UB_FALSE:%[^,]+]]
@@ -465,7 +464,7 @@ int decrement_nowait () {
 // OMP5-NEXT: br label %[[LOOP1_HEAD]]
 ;
 // OMP5: [[LOOP1_END]]
-// OMP5: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
+// OMP5: call void @__kmpc_for_static_fini(%struct.ident_t* [[LOOP_LOC]], i32 
[[GTID]])
 // OMP5-NOT: __kmpc_barrier
   return 0;
 // OMP5: ret i32 0


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


r372129 - [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

2019-09-17 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Tue Sep 17 08:10:39 2019
New Revision: 372129

URL: http://llvm.org/viewvc/llvm-project?rev=372129=rev
Log:
[clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

Summary:
AnnotatedLine has a tree structure, and things like the body of a lambda will be
a child of the lambda expression. For example,

[&]() { foo(a); };

will have an AnnotatedLine with a child:

[&]() {};
 '- foo(a);

Currently, when the `Cleaner` class analyzes the affected lines, it does not
cleanup the lines' children nodes, which results in missed cleanup
opportunities, like the lambda body in the example above.

This revision extends the algorithm to visit children, thereby fixing the above 
problem.

Patch by Eric Li.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=372129=372128=372129=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Sep 17 08:10:39 2019
@@ -1417,22 +1417,29 @@ public:
 
 checkEmptyNamespace(AnnotatedLines);
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto *Line : AnnotatedLines)
+  cleanupLine(Line);
 
 return {generateFixes(), 0};
   }
 
 private:
+  void cleanupLine(AnnotatedLine *Line) {
+for (auto *Child : Line->Children) {
+  cleanupLine(Child);
+}
+
+if (Line->Affected) {
+  cleanupRight(Line->First, tok::comma, tok::comma);
+  cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
+  cleanupRight(Line->First, tok::l_paren, tok::comma);
+  cleanupLeft(Line->First, tok::comma, tok::r_paren);
+  cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
+}
+  }
+
   bool containsOnlyComments(const AnnotatedLine ) {
 for (FormatToken *Tok = Line.First; Tok != nullptr; Tok = Tok->Next) {
   if (Tok->isNot(tok::comment))

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=372129=372128=372129=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Tue Sep 17 08:10:39 2019
@@ -183,10 +183,15 @@ TEST_F(CleanupTest, TrailingCommaInParen
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";
   EXPECT_EQ(Expected, cleanupAroundOffsets({15, 18, 29, 33}, Code));
+
+  // Lambda contents are also checked for trailing commas.
+  Code = "int main() { [](){f(,1,,2,3,f(1,2,),4,,);}();}";
+  Expected = "int main() { [](){f(1,2,3,f(1,2),4);}();}";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({20, 23, 34, 38}, Code));
 }
 
 TEST_F(CleanupTest, TrailingCommaInBraces) {
-  // Trainling comma is allowed in brace list.
+  // Trailing comma is allowed in brace list.
   // If there was trailing comma in the original code, then trailing comma is
   // preserved. In this example, element between the last two commas is deleted
   // causing the second-last comma to be redundant.
@@ -194,7 +199,7 @@ TEST_F(CleanupTest, TrailingCommaInBrace
   std::string Expected = "void f() { std::vector v = {1,2,3,}; }";
   EXPECT_EQ(Expected, cleanupAroundOffsets({39}, Code));
 
-  // If there was no trailing comma in the original code, then trainling comma
+  // If there was no trailing comma in the original code, then trailing comma
   // introduced by replacements should be cleaned up. In this example, the
   // element after the last comma is deleted causing the last comma to be
   // redundant.


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


[PATCH] D67590: Properly ignore mismatched exception specifiers in MSVC Compat mode.

2019-09-17 Thread Zachary Henkel via Phabricator via cfe-commits
zahen added a comment.

Is there any interest in supporting the cl.exe flag `/permissive-`?  I 
considered a hard error on mismatched exception specifier in clang-cl a 
feature, not a bug.  If msvc compat mode respected that flag this could 
continue to be an error with that flag set (and upgraded strictness in other 
cases).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67590



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


[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:53
+CheckFactories.registerCheck(
+"cert-default-operator-new");
 CheckFactories.registerCheck(

balazske wrote:
> aaron.ballman wrote:
> > balazske wrote:
> > > The checker should be renamed to `cert-mem57-cpp` to comply with the 
> > > others.
> > Yes, please. It should also be moved under a `// MEM` comment instead of 
> > `OOP` (and kept in alphabetical order).
> I will move it, but should I change the order of the commented sections? 
> These are currently not in alphabetic order.
Not for this patch, but that could be done in a separate patch (as an NFC 
change).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67545



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


[PATCH] D67659: [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

2019-09-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 220504.
ymandel added a comment.

Fixed auto use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67659

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/CleanupTest.cpp


Index: clang/unittests/Format/CleanupTest.cpp
===
--- clang/unittests/Format/CleanupTest.cpp
+++ clang/unittests/Format/CleanupTest.cpp
@@ -183,10 +183,15 @@
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";
   EXPECT_EQ(Expected, cleanupAroundOffsets({15, 18, 29, 33}, Code));
+
+  // Lambda contents are also checked for trailing commas.
+  Code = "int main() { [](){f(,1,,2,3,f(1,2,),4,,);}();}";
+  Expected = "int main() { [](){f(1,2,3,f(1,2),4);}();}";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({20, 23, 34, 38}, Code));
 }
 
 TEST_F(CleanupTest, TrailingCommaInBraces) {
-  // Trainling comma is allowed in brace list.
+  // Trailing comma is allowed in brace list.
   // If there was trailing comma in the original code, then trailing comma is
   // preserved. In this example, element between the last two commas is deleted
   // causing the second-last comma to be redundant.
@@ -194,7 +199,7 @@
   std::string Expected = "void f() { std::vector v = {1,2,3,}; }";
   EXPECT_EQ(Expected, cleanupAroundOffsets({39}, Code));
 
-  // If there was no trailing comma in the original code, then trainling comma
+  // If there was no trailing comma in the original code, then trailing comma
   // introduced by replacements should be cleaned up. In this example, the
   // element after the last comma is deleted causing the last comma to be
   // redundant.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1417,22 +1417,29 @@
 
 checkEmptyNamespace(AnnotatedLines);
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto *Line : AnnotatedLines)
+  cleanupLine(Line);
 
 return {generateFixes(), 0};
   }
 
 private:
+  void cleanupLine(AnnotatedLine *Line) {
+for (auto *Child : Line->Children) {
+  cleanupLine(Child);
+}
+
+if (Line->Affected) {
+  cleanupRight(Line->First, tok::comma, tok::comma);
+  cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
+  cleanupRight(Line->First, tok::l_paren, tok::comma);
+  cleanupLeft(Line->First, tok::comma, tok::r_paren);
+  cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
+}
+  }
+
   bool containsOnlyComments(const AnnotatedLine ) {
 for (FormatToken *Tok = Line.First; Tok != nullptr; Tok = Tok->Next) {
   if (Tok->isNot(tok::comment))


Index: clang/unittests/Format/CleanupTest.cpp
===
--- clang/unittests/Format/CleanupTest.cpp
+++ clang/unittests/Format/CleanupTest.cpp
@@ -183,10 +183,15 @@
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";
   EXPECT_EQ(Expected, cleanupAroundOffsets({15, 18, 29, 33}, Code));
+
+  // Lambda contents are also checked for trailing commas.
+  Code = "int main() { [](){f(,1,,2,3,f(1,2,),4,,);}();}";
+  Expected = "int main() { [](){f(1,2,3,f(1,2),4);}();}";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({20, 23, 34, 38}, Code));
 }
 
 TEST_F(CleanupTest, TrailingCommaInBraces) {
-  // Trainling comma is allowed in brace list.
+  // Trailing comma is allowed in brace list.
   // If there was trailing comma in the original code, then trailing comma is
   // preserved. In this example, element between the last two commas is deleted
   // causing the second-last comma to be redundant.
@@ -194,7 +199,7 @@
   std::string Expected = "void f() { std::vector v = {1,2,3,}; }";
   EXPECT_EQ(Expected, cleanupAroundOffsets({39}, Code));
 
-  // If there was no trailing comma in the original code, then trainling comma
+  // If there was no trailing comma in the original code, then trailing comma
   // introduced by replacements should be cleaned up. In this example, the
   // element after the last comma is deleted causing the last comma to be

[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-09-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:53
+CheckFactories.registerCheck(
+"cert-default-operator-new");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> balazske wrote:
> > The checker should be renamed to `cert-mem57-cpp` to comply with the others.
> Yes, please. It should also be moved under a `// MEM` comment instead of 
> `OOP` (and kept in alphabetical order).
I will move it, but should I change the order of the commented sections? These 
are currently not in alphabetic order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67545



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


[PATCH] D67659: [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

2019-09-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang/lib/Format/Format.cpp:1420
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto  : AnnotatedLines)
+  cleanupLine(Line);

krasimir wrote:
> nit: (I realize this code was like this before, but,)
> I find it more useful to have `auto *Line` instead of `auto ` (and 
> similarly `auto *Child` instead of `auto ` at line 1028 below) as that 
> makes it immediately clear that inside the body of the for loop we need to 
> use `->` to access members of the object.
Agreed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67659



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


[clang-tools-extra] r372128 - [clangd] Fix another TSAN issue

2019-09-17 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Sep 17 07:56:11 2019
New Revision: 372128

URL: http://llvm.org/viewvc/llvm-project?rev=372128=rev
Log:
[clangd] Fix another TSAN issue

Modified:
clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp?rev=372128=372127=372128=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp Tue Sep 17 
07:56:11 2019
@@ -769,12 +769,14 @@ TEST_F(TUSchedulerTests, CommandLineWarn
   // We should not see warnings from command-line parsing.
   CDB.ExtraClangFlags = {"-Wsome-unknown-warning"};
 
+  // (!) 'Ready' must live longer than TUScheduler.
+  Notification Ready;
+
   TUScheduler S(CDB, /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
 /*StorePreambleInMemory=*/true, 
/*ASTCallbacks=*/captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
 
-  Notification Ready;
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
   WantDiagnostics::Yes, [&](std::vector D) {


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


[PATCH] D67660: [clang-format]

2019-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D67660

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  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
@@ -58,6 +58,7 @@
"while (true) f();\n"
"for (;;) f();\n"
"if (true) f();\n"
+   "foreach (x in y) f();\n"
"  }\n"
"}");
 }
@@ -119,13 +120,25 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpNullConditional) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
+
   verifyFormat(
   "public Person(string firstName, string lastName, int? age=null)");
 
-  verifyFormat("switch(args?.Length)");
+  verifyFormat("foo () {\n"
+   "  switch (args?.Length) {}\n"
+   "}",
+   Style);
+
+  verifyFormat("switch (args?.Length) {}", Style);
 
   verifyFormat("public static void Main(string[] args) { string dirPath "
"= args?[0]; }");
+
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
+
+  verifyFormat("switch(args?.Length) {}", Style);
 }
 
 TEST_F(FormatTestCSharp, Attributes) {
@@ -168,16 +181,22 @@
 TEST_F(FormatTestCSharp, CSharpUsing) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
-  verifyFormat("public void foo() {\n"
+  verifyFormat("public void foo () {\n"
"  using (StreamWriter sw = new StreamWriter (filenameA)) {}\n"
"}",
Style);
 
+  verifyFormat("using (StreamWriter sw = new StreamWriter (filenameB)) {}",
+   Style);
+
   Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
   verifyFormat("public void foo() {\n"
"  using(StreamWriter sw = new StreamWriter(filenameB)) {}\n"
"}",
Style);
+
+  verifyFormat("using(StreamWriter sw = new StreamWriter(filenameB)) {}",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpRegions) {
@@ -195,5 +214,40 @@
   verifyFormat("return _name ?? \"DEF\";");
 }
 
+TEST_F(FormatTestCSharp, CSharpSpaceBefore) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
+
+  verifyFormat("List list;", Style);
+  verifyFormat("Dictionary dict;", Style);
+
+  verifyFormat("for (int i = 0; i < size (); i++) {\n"
+   "}",
+   Style);
+  verifyFormat("foreach (var x in y) {\n"
+   "}",
+   Style);
+  verifyFormat("switch (x) {}", Style);
+  verifyFormat("do {\n"
+   "} while (x);",
+   Style);
+
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
+
+  verifyFormat("List list;", Style);
+  verifyFormat("Dictionary dict;", Style);
+
+  verifyFormat("for(int i = 0; i < size(); i++) {\n"
+   "}",
+   Style);
+  verifyFormat("foreach(var x in y) {\n"
+   "}",
+   Style);
+  verifyFormat("switch(x) {}", Style);
+  verifyFormat("do {\n"
+   "} while(x);",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2624,10 +2624,6 @@
 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;
@@ -2718,7 +2714,15 @@
 // and "%d %d"
 if (Left.is(tok::numeric_constant) && Right.is(tok::percent))
   return Right.WhitespaceRange.getEnd() != Right.WhitespaceRange.getBegin();
-  } else if (Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
+  } else if (Style.isCSharp()) {
+// space between type and variable e.g. Dictionary foo;
+if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName))
+  return true;
+// space between keywords and paren e.g. "using ("
+if (Right.is(tok::l_paren))
+  if (Left.is(tok::kw_using))
+return spaceRequiredBeforeParens(Left);
+  } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
 // for await ( ...
Index: 

[PATCH] D63508: make -frewrite-includes also rewrite conditions in #if/#elif

2019-09-17 Thread Tor Arne Vestbø via Phabricator via cfe-commits
torarnv added a comment.

Thank you for the explanation! 


Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D67659: [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

2019-09-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!




Comment at: clang/lib/Format/Format.cpp:1420
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto  : AnnotatedLines)
+  cleanupLine(Line);

nit: (I realize this code was like this before, but,)
I find it more useful to have `auto *Line` instead of `auto ` (and 
similarly `auto *Child` instead of `auto ` at line 1028 below) as that 
makes it immediately clear that inside the body of the for loop we need to use 
`->` to access members of the object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67659



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


[PATCH] D62394: [ARM][CMSE] Add CMSE header & builtins

2019-09-17 Thread Sigvart Hovland via Phabricator via cfe-commits
sigvartmh added a comment.

In D62394#1672570 , @javed.absar wrote:

> In D62394#1672551 , @sigvartmh wrote:
>
> > Maybe I'm doing something wrong tried to apply these patches but when 
> > trying to build code which uses cmse I get
> >
> > Cannot select: intrinsic %llvm.arm.cmse.tt
> >  fatal error: error in backend: Cannot select: intrinsic %llvm.arm.cmse.tt
> >  clang-10: error: clang frontend command failed with exit code 70 (use -v 
> > to see invocation)
> >
> > Built llvm with clang,compiler-rt,lld from master.
>
>
> Did you try to build and run lit tests successfully with this patch before 
> trying your own tests?


Unfortunately I did not will try to run the test first. I assumed that this 
patch was working, is it?


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

https://reviews.llvm.org/D62394



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


[PATCH] D67659: [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

2019-09-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: krasimir.
Herald added a project: clang.

AnnotatedLine has a tree structure, and things like the body of a lambda will be
a child of the lambda expression. For example,

  [&]() { foo(a); };

will have an AnnotatedLine with a child:

  [&]() {};
   '- foo(a);

Currently, when the `Cleaner` class analyzes the affected lines, it does not
cleanup the lines' children nodes, which results in missed cleanup
opportunities, like the lambda body in the example above.

This revision extends the algorithm to visit children, thereby fixing the above 
problem.

Patch by Eric Li.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67659

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/CleanupTest.cpp


Index: clang/unittests/Format/CleanupTest.cpp
===
--- clang/unittests/Format/CleanupTest.cpp
+++ clang/unittests/Format/CleanupTest.cpp
@@ -183,10 +183,15 @@
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";
   EXPECT_EQ(Expected, cleanupAroundOffsets({15, 18, 29, 33}, Code));
+
+  // Lambda contents are also checked for trailing commas.
+  Code = "int main() { [](){f(,1,,2,3,f(1,2,),4,,);}();}";
+  Expected = "int main() { [](){f(1,2,3,f(1,2),4);}();}";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({20, 23, 34, 38}, Code));
 }
 
 TEST_F(CleanupTest, TrailingCommaInBraces) {
-  // Trainling comma is allowed in brace list.
+  // Trailing comma is allowed in brace list.
   // If there was trailing comma in the original code, then trailing comma is
   // preserved. In this example, element between the last two commas is deleted
   // causing the second-last comma to be redundant.
@@ -194,7 +199,7 @@
   std::string Expected = "void f() { std::vector v = {1,2,3,}; }";
   EXPECT_EQ(Expected, cleanupAroundOffsets({39}, Code));
 
-  // If there was no trailing comma in the original code, then trainling comma
+  // If there was no trailing comma in the original code, then trailing comma
   // introduced by replacements should be cleaned up. In this example, the
   // element after the last comma is deleted causing the last comma to be
   // redundant.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1417,22 +1417,29 @@
 
 checkEmptyNamespace(AnnotatedLines);
 
-for (auto  : AnnotatedLines) {
-  if (Line->Affected) {
-cleanupRight(Line->First, tok::comma, tok::comma);
-cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-cleanupRight(Line->First, tok::l_paren, tok::comma);
-cleanupLeft(Line->First, tok::comma, tok::r_paren);
-cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-  }
-}
+for (auto  : AnnotatedLines)
+  cleanupLine(Line);
 
 return {generateFixes(), 0};
   }
 
 private:
+  void cleanupLine(AnnotatedLine *Line) {
+for (auto  : Line->Children) {
+  cleanupLine(Child);
+}
+
+if (Line->Affected) {
+  cleanupRight(Line->First, tok::comma, tok::comma);
+  cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
+  cleanupRight(Line->First, tok::l_paren, tok::comma);
+  cleanupLeft(Line->First, tok::comma, tok::r_paren);
+  cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+  cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
+}
+  }
+
   bool containsOnlyComments(const AnnotatedLine ) {
 for (FormatToken *Tok = Line.First; Tok != nullptr; Tok = Tok->Next) {
   if (Tok->isNot(tok::comment))


Index: clang/unittests/Format/CleanupTest.cpp
===
--- clang/unittests/Format/CleanupTest.cpp
+++ clang/unittests/Format/CleanupTest.cpp
@@ -183,10 +183,15 @@
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";
   EXPECT_EQ(Expected, cleanupAroundOffsets({15, 18, 29, 33}, Code));
+
+  // Lambda contents are also checked for trailing commas.
+  Code = "int main() { [](){f(,1,,2,3,f(1,2,),4,,);}();}";
+  Expected = "int main() { [](){f(1,2,3,f(1,2),4);}();}";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({20, 23, 34, 38}, Code));
 }
 
 TEST_F(CleanupTest, TrailingCommaInBraces) {
-  // Trainling comma is allowed in brace list.
+  // Trailing comma is allowed in brace list.
   // If there was trailing comma in the original code, then trailing comma is
   // preserved. In this example, element between the last two commas is deleted
   // causing the second-last comma to be 

[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this check!

In D67545#1672106 , @balazske wrote:

> C++17 makes things more difficult because the align is probably handled by 
> `operator new`, probably not, depending on the defined allocation functions.


Correct.

> This can be observed only with a non clang-tidy checker (we could compute the 
> used alignment?).

I'm less certain of this. We should be able to look up which `operator new` 
overload was selected for the `new` expression and check to see if it has an 
alignment parameter. If it does, I think it's reasonable to assume that the 
function behaves correctly wrt alignment.

> Probably the CERT rule is from the time before C++17. It looks like that by 
> default the alignment is handled correctly in C++17 so the whole check is out 
> of scope for that language version.

Yeah, the CERT C++ rules were written for C++14: 
https://wiki.sei.cmu.edu/confluence/display/cplusplus/Scope

The check may be out of scope for C++17, I've not analyzed it for that. There 
are times when new with align is not called 
(http://eel.is/c++draft/cpp.predefined#1.6) and user overloads to consider as 
well, but I think those should be trying to call the aligned new version when 
given an over-aligned type.




Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:53
+CheckFactories.registerCheck(
+"cert-default-operator-new");
 CheckFactories.registerCheck(

balazske wrote:
> The checker should be renamed to `cert-mem57-cpp` to comply with the others.
Yes, please. It should also be moved under a `// MEM` comment instead of `OOP` 
(and kept in alphabetical order).



Comment at: clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.cpp:26
+
+  if (NewExpr->getNumPlacementArgs() > 0)
+return;

balazske wrote:
> martong wrote:
> > Perhaps we should add in the docs that placement new is not supported. Or 
> > add a fixme here.
> > Anyway, I feel this code simply could work with placement new as well. What 
> > is the reason you disabled it for placement new?
> Placement new provides already a memory location that is specified by the 
> user (or some custom allocation function) so this is not a default case for 
> which the warning should be provided.
That would correspond to MEM54-CPP: 
https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM54-CPP.+Provide+placement+new+with+properly+aligned+pointers+to+sufficient+storage+capacity

I think this should be hoisted into a local AST matcher rather than be part of 
the `check()` call. Something like `unless(isPlacementNew())` when registering 
the check.



Comment at: clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.cpp:41
+  unsigned SpecifiedAlignment = D->getMaxAlignment();
+  unsigned DefaultAlignment = Context.getTargetInfo().getCharAlign();
+  if (!SpecifiedAlignment)

balazske wrote:
> martong wrote:
> > This might not be what we want... `getCharAlign()` theoretically could 
> > return even with `1`, I think, though it would be a very strange 
> > architecture.
> > Perhaps we should use `getSuitableAlign()` instead?
> > 
> > Also, I think we should call the variable as `FundamentalAlignment`. 
> > Fundamental and default alignment can differ, I guess.
> I wanted to use `Context.getTargetInfo().getNewAlign()` here, is it correct? 
> (Or `getNewAlign()/getCharWidth()`?)
I think `getNewAlign()` is the correct thing to use here. If the alignment 
requirements of the allocated type are greater than what `getNewAlign()` 
returns, there are problems (unless calling the C++17 aligned allocation 
operator).



Comment at: clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.cpp:49
+  if (HasDefaultOperatorNew && OverAligned)
+diag(NewExpr->getBeginLoc(), "using default 'operator new' with 
over-aligned type %0 may result in undefined behavior")
+  << D;

balazske wrote:
> martong wrote:
> > I think it would be useful to add the value of the fundamental alignment to 
> > the diagnostics too.
> Should be this the correct error message? "Allocation with standard new: too 
> long alignment for a user type." Or "Allocation with standard new: too long 
> alignment (//user_align//) for a user type, default is //default_align//."
I'd go with: `allocation function returns a pointer with alignment %0 but the 
over-aligned type being allocated requires alignment %1`



Comment at: clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.h:18
+
+/// FIXME: Write a short description.
+///

FIXME needs fixing.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:79
+
+  FIXME: add release notes.
+

You should fix this fixme.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cert-default-operator-new.rst:6
+
+FIXME: 

[PATCH] D38446: update comments in clang-format.py for python3 compatibility

2019-09-17 Thread Paul Seyfert via Phabricator via cfe-commits
pseyfert added a comment.

ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D38446



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


r372124 - Add SpellingNotCalculated to Attribute Enums to suppress UBSan warnings

2019-09-17 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 17 07:11:51 2019
New Revision: 372124

URL: http://llvm.org/viewvc/llvm-project?rev=372124=rev
Log:
Add SpellingNotCalculated to Attribute Enums to suppress UBSan warnings

UBSan downstreams noticed that the assignment of SpellingNotCalculated
to the spellings caused warnings.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=372124=372123=372124=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Sep 17 07:11:51 2019
@@ -615,6 +615,8 @@ void MicrosoftCXXNameMangler::mangleMemb
   case MSInheritanceAttr::Keyword_multiple_inheritance:Code = '0'; break;
   case MSInheritanceAttr::Keyword_virtual_inheritance: Code = 'F'; break;
   case MSInheritanceAttr::Keyword_unspecified_inheritance: Code = 'G'; break;
+  case MSInheritanceAttr::SpellingNotCalculated:
+llvm_unreachable("not reachable");
   }
 
   Out << '$' << Code;
@@ -646,6 +648,8 @@ MicrosoftCXXNameMangler::mangleMemberFun
   case MSInheritanceAttr::Keyword_multiple_inheritance:Code = 'H'; break;
   case MSInheritanceAttr::Keyword_virtual_inheritance: Code = 'I'; break;
   case MSInheritanceAttr::Keyword_unspecified_inheritance: Code = 'J'; break;
+  case MSInheritanceAttr::SpellingNotCalculated:
+llvm_unreachable("not reachable");
   }
 
   // If non-virtual, mangle the name.  If virtual, mangle as a virtual memptr

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=372124=372123=372124=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 17 07:11:51 2019
@@ -2711,6 +2711,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
 break;
   case MSInheritanceAttr::Keyword_unspecified_inheritance:
 break;
+  case MSInheritanceAttr::SpellingNotCalculated:
+llvm_unreachable("Spelling not yet calculated");
   }
 }
   }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=372124=372123=372124=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Sep 17 07:11:51 2019
@@ -1633,6 +1633,8 @@ static QualType ConvertDeclSpecToType(Ty
 case OpenCLAccessAttr::Keyword_read_only:  
\
   Result = Context.Id##ROTy;   
\
   break;   
\
+case OpenCLAccessAttr::SpellingNotCalculated:  
\
+  llvm_unreachable("Spelling not yet calculated"); 
\
 }  
\
 break;
 #include "clang/Basic/OpenCLImageTypes.def"

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=372124=372123=372124=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Sep 17 07:11:51 2019
@@ -1596,6 +1596,13 @@ CreateSemanticSpellings(const std::vecto
   std::string Ret("  enum Spelling {\n");
   std::set Uniques;
   unsigned Idx = 0;
+
+  // If we have a need to have this many spellings we likely need to add an
+  // extra bit to the SpellingIndex in AttributeCommonInfo, then increase the
+  // value of SpellingNotCalculated there and here.
+  assert(Spellings.size() < 15 &&
+ "Too many spellings, would step on SpellingNotCalculated in "
+ "AttributeCommonInfo");
   for (auto I = Spellings.begin(), E = Spellings.end(); I != E; ++I, ++Idx) {
 const FlattenedSpelling  = *I;
 const std::string  = S.variety();
@@ -1629,6 +1636,7 @@ CreateSemanticSpellings(const std::vecto
 // enumerator.
 Ret += "" + EnumName + " = " + llvm::utostr(Idx);
   }
+  Ret += ",\n  SpellingNotCalculated = 15\n";
   Ret += "\n  };\n\n";
   return Ret;
 }


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


[PATCH] D62394: [ARM][CMSE] Add CMSE header & builtins

2019-09-17 Thread Javed Absar via Phabricator via cfe-commits
javed.absar added a comment.

In D62394#1672551 , @sigvartmh wrote:

> Maybe I'm doing something wrong tried to apply these patches but when trying 
> to build code which uses cmse I get
>
> Cannot select: intrinsic %llvm.arm.cmse.tt
>  fatal error: error in backend: Cannot select: intrinsic %llvm.arm.cmse.tt
>  clang-10: error: clang frontend command failed with exit code 70 (use -v to 
> see invocation)
>
> Built llvm with clang,compiler-rt,lld from master.


Did you try to build and run lit tests successfully with this patch before 
trying your own tests?


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

https://reviews.llvm.org/D62394



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


[PATCH] D62394: [ARM][CMSE] Add CMSE header & builtins

2019-09-17 Thread Sigvart Hovland via Phabricator via cfe-commits
sigvartmh requested changes to this revision.
sigvartmh added a comment.
This revision now requires changes to proceed.

Maybe I'm doing something wrong tried to apply these patches but when trying to 
build code which uses cmse I get

Cannot select: intrinsic %llvm.arm.cmse.tt
fatal error: error in backend: Cannot select: intrinsic %llvm.arm.cmse.tt
clang-10: error: clang frontend command failed with exit code 70 (use -v to see 
invocation)

Built llvm with clang,compiler-rt,lld from master.


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

https://reviews.llvm.org/D62394



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length

2019-09-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

A couple of drive-by comments.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:22-33
+constexpr llvm::StringLiteral FuncExprName = "entire-called-function-expr";
+constexpr llvm::StringLiteral CastExprName = "cast-expr";
+constexpr llvm::StringLiteral UnknownDestName = 
"destination-length-is-unknown";
+constexpr llvm::StringLiteral DestArrayTyName = "destination-is-array-type";
+constexpr llvm::StringLiteral DestVarDeclName = "destination-variable-decl";
+constexpr llvm::StringLiteral SrcVarDeclName = "source-variable-declaration";
+constexpr llvm::StringLiteral DestMallocExprName = "destination-malloc-expr";

Binding names are copied/read a lot (for memoization purposes, see 
BoundNodesMap) during matching. It makes sense to make them shorter. Ideally 
they should fit into the inline std::string buffer (15 characters in libc++ on 
x86-64, https://gcc.godbolt.org/z/oNBghM).



Comment at: 
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:276-277
+
+  if (DestCapacityExprStr != "" && DestCapacityExprStr == LengthExprStr)
+return true;
+

This conditional statement never affects the result of the function. Either 
there's a typo somewhere or this statement can be removed.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D45050



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


r372119 - [OpenCL] Tidy up some comments; NFC

2019-09-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Sep 17 06:32:56 2019
New Revision: 372119

URL: http://llvm.org/viewvc/llvm-project?rev=372119=rev
Log:
[OpenCL] Tidy up some comments; NFC

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=372119=372118=372119=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Tue Sep 17 06:32:56 2019
@@ -61,10 +61,8 @@ class IntList _L
 //  OpenCL C classes for types
 
//===--===//
 // OpenCL C basic data types (int, float, image2d_t, ...).
-// Its Child classes can represent concrete types (e.g.: VectorType) or
-// custom types (e.g.: GenType).
-// Instances of these child classes should be used in Builtin function
-// arguments.  See the definition of the "read_imagef" function as example.
+// Its child classes can represent concrete types (e.g. VectorType) or
+// abstract types (e.g. GenType).
 class Type {
   // Name of the Type.
   string Name = _Name;
@@ -150,12 +148,8 @@ class TypeList
 // A GenericType is an abstract type that defines a set of types as a
 // combination of Types and vector sizes.
 //
-// E.g.: If TypeList =  and VectorList = <1, 2, 4>, then it
-//   represents .
-// _Ty  : Name of the GenType.
-// _TypeList: List of basic data Types.
-// _VectorList  : Sizes of the vector for each type of the _TypeList, 1 being a
-//scalar.
+// For example, if TypeList =  and VectorList = <1, 2, 4>, then it
+// represents .
 //
 // Some rules apply when using multiple GenericType arguments in a declaration:
 //   1. The number of vector sizes must be equal or 1 for all gentypes in a


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


[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst:40
+
+Options
+---

This is still missing the documentation for `MathHeader` and its default value.


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

https://reviews.llvm.org/D64671



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


[PATCH] D67159: [clang] New __attribute__((__clang_arm_mve_alias)).

2019-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:596
 }
+def ArmMveAlias : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [Clang<"__clang_arm_mve_alias">];

Add a newline before the attribute definition for some separation.



Comment at: clang/include/clang/Basic/AttrDocs.td:4350
+as clang builtins equivalent to the underlying name. For example,
+``arm_mve.h`` will declare the function ``vaddq_u32`` with
+``__attribute__((__clang_arm_mve_alias(__builtin_arm_mve_vaddq_u32)))``,

will declare -> declares



Comment at: clang/include/clang/Basic/DiagnosticASTKinds.td:453
+def err_attribute_arm_mve_alias : Error<
+  "__clang_arm_mve_alias attribute can only be used for Arm MVE builtins">;
+

How about: `"'__clang_arm_mve_alias' attribute can only be applied to an ARM 
MVE builtin"`



Comment at: clang/lib/AST/Decl.cpp:3082
+static bool ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  // This will be filled in by Tablegen which isn't written yet
+  return false;

Comment should have a `FIXME` prefix, but tbh, I'm a little uncomfortable 
adopting the attribute without this being implemented. I assume the plan is to 
tablegen a header file that gets included here to provide the lookup?



Comment at: clang/lib/AST/Decl.cpp:3102-3103
+
+  if (hasAttr()) {
+IdentifierInfo *II = getAttr()->getBuiltinName();
+BuiltinID = II->getBuiltinID();

```
if (const auto *AMAA = getAttr) {
  IdentifierInfo *II = AMAA->getBuiltinName();
  ...
}
```



Comment at: clang/lib/AST/Decl.cpp:3107
+if (!ArmMveAliasValid(BuiltinID, getIdentifier()->getName())) {
+  getASTContext().getDiagnostics().Report(
+getLocation(), diag::err_attribute_arm_mve_alias);

I'm not certain how comfortable I am with having this function produce a 
diagnostic. That seems like unexpected behavior for a function attempting to 
get a builtin ID. I think this should be the responsibility of the caller.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/alias-attr.c:1
+// RUN: %clang_cc1 -triple armv8.1m.main-arm-none-eabi -verify -fsyntax-only %s
+

This seems like a Sema test, not a CodeGen test.

There are other Sema tests missing: the attribute only accepts one arg instead 
of zero or two+, only accepts identifier args (test with a string literal and 
an integer literal), only applies to functions, etc.

Should there be a diagnostic if the attribute is applied to a function with 
internal linkage (or are there static builtins)? What about member functions of 
a class?

Once the builtin hookup is complete, there should also be tests for the 
attribute being accepted properly, and codegen tests demonstrating the proper 
builtin is called.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


[libclc] r372115 - Creating release candidate rc6 from release_900 branch

2019-09-17 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep 17 06:09:16 2019
New Revision: 372115

URL: http://llvm.org/viewvc/llvm-project?rev=372115=rev
Log:
Creating release candidate rc6 from release_900 branch

Added:
libclc/tags/RELEASE_900/rc6/
  - copied from r372114, libclc/branches/release_90/

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


[libunwind] r372115 - Creating release candidate rc6 from release_900 branch

2019-09-17 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep 17 06:09:16 2019
New Revision: 372115

URL: http://llvm.org/viewvc/llvm-project?rev=372115=rev
Log:
Creating release candidate rc6 from release_900 branch

Added:
libunwind/tags/RELEASE_900/rc6/
  - copied from r372114, libunwind/branches/release_90/

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


r372113 - Hide implementation details in namespaces.

2019-09-17 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Sep 17 05:56:29 2019
New Revision: 372113

URL: http://llvm.org/viewvc/llvm-project?rev=372113=rev
Log:
Hide implementation details in namespaces.

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=372113=372112=372113=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Sep 17 05:56:29 2019
@@ -3701,6 +3701,7 @@ NamedDecl *VisibleDeclsRecord::checkHidd
   return nullptr;
 }
 
+namespace {
 class LookupVisibleHelper {
 public:
   LookupVisibleHelper(VisibleDeclConsumer , bool 
IncludeDependentBases,
@@ -4025,6 +4026,7 @@ private:
   bool IncludeDependentBases;
   bool LoadExternal;
 };
+} // namespace
 
 void Sema::LookupVisibleDecls(Scope *S, LookupNameKind Kind,
   VisibleDeclConsumer ,


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


[PATCH] D67632: [libTooling] Introduce new library of source-code builders.

2019-09-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added inline comments.



Comment at: clang/lib/Tooling/Refactoring/SourceCodeBuilders.cpp:77
+
+  if (Text.empty()) return std::string();
+  // Add leading '*'.

Eugene.Zelenko wrote:
> Could return {}. Same in other places. By the word, did you run Clang-format 
> over code?
No, thanks for pointing that out.

I find `return std::string()` more readable, because it doesn't require that I 
check/know the return type of the function. But, if `return {}` is standard, 
I'm fine changing it. What's most common in the clang source?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67632



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


[PATCH] D67651: [clangd] No ExtractFunction on empty selections.

2019-09-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D67651#1672403 , @kadircet wrote:

> this one is actually specific to vardecl's and has a pending fix in D66872 
> 
>
> I would rather wait for it to land, instead of adding another branch. WDYT?


fair enough, didn't notice that fix before, the testcase here probably doesn't 
work after that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67651



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


[PATCH] D67632: [libTooling] Introduce new library of source-code builders.

2019-09-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 220488.
ymandel added a comment.

ran clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67632

Files:
  clang/include/clang/Tooling/Refactoring/SourceCodeBuilders.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/SourceCodeBuilders.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/SourceCodeBuildersTest.cpp

Index: clang/unittests/Tooling/SourceCodeBuildersTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -0,0 +1,181 @@
+//===- unittest/Tooling/SourceCodeBuildersTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/SourceCodeBuilders.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using MatchResult = MatchFinder::MatchResult;
+
+// Create a valid translation-unit from a statement.
+static std::string wrapSnippet(StringRef StatementCode) {
+  return ("struct S { int field; }; "
+  "S operator+(const S , const S ); "
+  "auto test_snippet = []{" +
+  StatementCode + "};")
+  .str();
+}
+
+static DeclarationMatcher wrapMatcher(const StatementMatcher ) {
+  return varDecl(hasName("test_snippet"),
+ hasDescendant(compoundStmt(hasAnySubstatement(Matcher;
+}
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr AstUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+// Matches `Matcher` against the statement `StatementCode` and returns the
+// result. Handles putting the statement inside a function and modifying the
+// matcher correspondingly. `Matcher` should match one of the statements in
+// `StatementCode` exactly -- that is, produce exactly one match. However,
+// `StatementCode` may contain other statements not described by `Matcher`.
+static llvm::Optional matchStmt(StringRef StatementCode,
+   StatementMatcher Matcher) {
+  auto AstUnit = buildASTFromCode(wrapSnippet(StatementCode));
+  if (AstUnit == nullptr) {
+ADD_FAILURE() << "AST construction failed";
+return llvm::None;
+  }
+  ASTContext  = AstUnit->getASTContext();
+  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  // We expect a single, exact match for the statement.
+  if (Matches.size() != 1) {
+ADD_FAILURE() << "Wrong number of matches: " << Matches.size();
+return llvm::None;
+  }
+  return TestMatch{std::move(AstUnit), MatchResult(Matches[0], )};
+}
+
+static void testPredicate(bool (*Pred)(const Expr ), StringRef Snippet,
+  bool Expected) {
+  auto StmtMatch = matchStmt(Snippet, expr().bind("expr"));
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_EQ(Expected, Pred(*StmtMatch->Result.Nodes.getNodeAs("expr")));
+}
+
+TEST(SourceCodeBuildersTest, needParensAfterUnaryOperator) {
+  testPredicate(needParensAfterUnaryOperator, "3 + 5;", true);
+  testPredicate(needParensAfterUnaryOperator, "true ? 3 : 5;", true);
+
+  testPredicate(needParensAfterUnaryOperator, "int x; x;", false);
+  testPredicate(needParensAfterUnaryOperator, "int(3.0);", false);
+  testPredicate(needParensAfterUnaryOperator, "void f(); f();", false);
+  testPredicate(needParensAfterUnaryOperator, "int a[3]; a[0];", false);
+  testPredicate(needParensAfterUnaryOperator, "S x; x.field;", false);
+  testPredicate(needParensAfterUnaryOperator, "int x = 1; --x;", false);
+  testPredicate(needParensAfterUnaryOperator, "int x = 1; -x;", false);
+}
+
+TEST(SourceCodeBuildersTest, mayNeedParens) {
+  testPredicate(mayNeedParens, "3 + 5;", true);
+  testPredicate(mayNeedParens, "true ? 3 : 5;", true);
+  testPredicate(mayNeedParens, "int x = 1; --x;", true);
+  testPredicate(mayNeedParens, "int x = 1; -x;", true);
+
+  testPredicate(mayNeedParens, "int x; x;", false);
+  testPredicate(mayNeedParens, "int(3.0);", false);
+  testPredicate(mayNeedParens, "void f(); f();", false);
+  testPredicate(mayNeedParens, "int a[3]; a[0];", false);
+  testPredicate(mayNeedParens, "S x; x.field;", false);
+}
+
+static void testBuilder(std::string (*Builder)(const ASTContext ,
+   const Expr ),
+StringRef Snippet, 

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

2019-09-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Adding @djasper  as this is really a re-implementation of 
https://reviews.llvm.org/D6833.
Agree with @MyDeveloperDay that in general we should aim to document all the 
known cases where a style doesn't work (with FIXMEs etc.), but not submit 
failing tests. We can have tests that demonstrate the current (bad) behavior 
together with a FIXME comment about what is the expected good outcome instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67627



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


[PATCH] D67654: [clang-tidy] Fix a potential infinite loop in readability-isolate-declaration check.

2019-09-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67654

Files:
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  
clang-tools-extra/test/clang-tidy/readability-isolate-declaration-no-infinite-loop.cpp


Index: 
clang-tools-extra/test/clang-tidy/readability-isolate-declaration-no-infinite-loop.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/readability-isolate-declaration-no-infinite-loop.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s 
readability-isolate-declaration %t
+
+int main(){
+int a, b
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a 
single statement reduces readability
+// CHECK-MESSAGES: [[@LINE-2]]:11: error: expected ';' at end of 
declaration [clang-diagnostic-error]
+}
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.h
===
--- clang-tools-extra/clang-tidy/utils/LexerUtils.h
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Lexer.h"
 
 namespace clang {
@@ -62,14 +63,12 @@
 TokenKinds... TKs) {
   while (true) {
 Optional CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
-
-if (!CurrentToken)
+if (!CurrentToken || CurrentToken->is(tok::eof))
   return SourceLocation();
 
 Token PotentialMatch = *CurrentToken;
 if (PotentialMatch.isOneOf(TK, TKs...))
   return PotentialMatch.getLocation();
-
 Start = PotentialMatch.getLastLoc();
   }
 }


Index: clang-tools-extra/test/clang-tidy/readability-isolate-declaration-no-infinite-loop.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-isolate-declaration-no-infinite-loop.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s readability-isolate-declaration %t
+
+int main(){
+int a, b
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+// CHECK-MESSAGES: [[@LINE-2]]:11: error: expected ';' at end of declaration [clang-diagnostic-error]
+}
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.h
===
--- clang-tools-extra/clang-tidy/utils/LexerUtils.h
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Lexer.h"
 
 namespace clang {
@@ -62,14 +63,12 @@
 TokenKinds... TKs) {
   while (true) {
 Optional CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
-
-if (!CurrentToken)
+if (!CurrentToken || CurrentToken->is(tok::eof))
   return SourceLocation();
 
 Token PotentialMatch = *CurrentToken;
 if (PotentialMatch.isOneOf(TK, TKs...))
   return PotentialMatch.getLocation();
-
 Start = PotentialMatch.getLastLoc();
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67651: [clangd] No ExtractFunction on empty selections.

2019-09-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

this one is actually specific to vardecl's and has a pending fix in D66872 


I would rather wait for it to land, instead of adding another branch. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67651



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


[PATCH] D67613: [DWARF-5] Support for DWARF-5 C++ language tags

2019-09-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX updated this revision to Diff 220472.
SouraVX set the repository for this revision to rC Clang.
SouraVX added a comment.

Removed underscores from names.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67613

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclPrinter.cpp
  lib/AST/JSONNodeDumper.cpp
  lib/AST/TextNodeDumper.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaModule.cpp
  test/Modules/ModuleDebugInfo.cpp

Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
-// RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-CXX %s
 // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 #ifdef MODULES
@@ -23,6 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:
Index: lib/Sema/SemaModule.cpp
===
--- lib/Sema/SemaModule.cpp
+++ lib/Sema/SemaModule.cpp
@@ -31,6 +31,8 @@
 ExternCLoc = LSD->getBeginLoc();
   break;
 case LinkageSpecDecl::lang_cxx:
+case LinkageSpecDecl::lang_cxx_11:
+case LinkageSpecDecl::lang_cxx_14:
   break;
 }
 DC = LSD->getParent();
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13911,6 +13911,10 @@
 Language = LinkageSpecDecl::lang_c;
   else if (Lang == "C++")
 Language = LinkageSpecDecl::lang_cxx;
+  else if (Lang == "C++11")
+Language = LinkageSpecDecl::lang_cxx_11;
+  else if (Lang == "C++14")
+Language = LinkageSpecDecl::lang_cxx_14;
   else {
 Diag(LangStr->getExprLoc(), diag::err_language_linkage_spec_unknown)
   << LangStr->getSourceRange();
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -5132,7 +5132,9 @@
 // EmitLinkageSpec - Emit all declarations in a linkage spec.
 void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) {
   if (LSD->getLanguage() != LinkageSpecDecl::lang_c &&
-  LSD->getLanguage() != LinkageSpecDecl::lang_cxx) {
+  LSD->getLanguage() != LinkageSpecDecl::lang_cxx &&
+  LSD->getLanguage() != LinkageSpecDecl::lang_cxx_11 &&
+  LSD->getLanguage() != LinkageSpecDecl::lang_cxx_14) {
 ErrorUnsupported(LSD, "linkage spec");
 return;
   }
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -561,6 +561,10 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
+else if (LO.CPlusPlus14)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
+else if (LO.CPlusPlus11)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC) {
@@ -878,6 +882,8 @@
 static bool hasCXXMangling(const TagDecl *TD, llvm::DICompileUnit *TheCU) {
   switch (TheCU->getSourceLanguage()) {
   case llvm::dwarf::DW_LANG_C_plus_plus:
+  case llvm::dwarf::DW_LANG_C_plus_plus_11:
+  case llvm::dwarf::DW_LANG_C_plus_plus_14:
 return true;
   case llvm::dwarf::DW_LANG_ObjC_plus_plus:
 return isa(TD) || isa(TD);
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -1767,6 +1767,12 @@
   case LinkageSpecDecl::lang_cxx:
 OS << " C++";
 break;
+  case LinkageSpecDecl::lang_cxx_11:
+OS << " C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+OS << " C++14";
+break;
   }
 }
 
Index: lib/AST/JSONNodeDumper.cpp
===
--- lib/AST/JSONNodeDumper.cpp
+++ lib/AST/JSONNodeDumper.cpp
@@ -850,6 +850,12 @@
   switch (LSD->getLanguage()) {
   case LinkageSpecDecl::lang_c: Lang = "C"; break;
   case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
+  case LinkageSpecDecl::lang_cxx_11:
+Lang = "C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+Lang = "C++14";
+break;
   }
   

[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst:41
+
+.. option:: ExpectedPrefixes
+

stephanemoore wrote:
> This option seems to describe a list of class prefixes that are whitelisted. 
> If that is the case, perhaps `WhitelistedPrefixes` or 
> `WhitelistedClassPrefixes` would be a better name for the option? WDYT?
No, please. We should try to avoid "white" and "black" lists in favor of more 
descriptive terms with less social connotations. I'd be fine with 
`ExpectedClassPrefixes`, `AllowedPrefixes`, `KnownPrefixes`, etc.


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

https://reviews.llvm.org/D65917



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


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

2019-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

when/if you commit can you abandon D6833: Clang-format: Braces Indent Style 
Whitesmith 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67627



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


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

2019-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Thank you for this patch

This LGTM, ensure you comment out the failing unit tests and add a FIXME to the 
test as to why they don't currently work (or fix them if possible), the tests 
need to keep passing or others will not know they haven't broken things.

Normally there always would be a comment saying please state a public style 
guide that uses a new style, but as Whitesmiths style is mentioned on the 
Wikipedia page about Indentation style so I would think you were good to add it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67627



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


[clang-tools-extra] r372102 - Add SemanticRanges to Clangd server.

2019-09-17 Thread Utkarsh Saxena via cfe-commits
Author: usaxena95
Date: Tue Sep 17 03:28:05 2019
New Revision: 372102

URL: http://llvm.org/viewvc/llvm-project?rev=372102=rev
Log:
Add SemanticRanges to Clangd server.

Summary:
Adds Semantic Ranges capabilities to Clangd server.
Also adds tests for running it via clangd server.

This differs from the LSP spec as the spec needs this to be evaluated on 
multiple 'pos' and the expected output is an list of list of semantic ranges.
This is majorly for multi cursor and assuming this is a rare thing, we don't 
want to optimize make things complicated just for this.
This should be done in the LSP level by queueing one request per 'pos' in the 
input.

LSP Spec:
https://github.com/microsoft/language-server-protocol/blob/dbaeumer/3.15/specification.md#textDocument_selectionRange

Reviewers: hokein

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp
clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
clang-tools-extra/trunk/clangd/unittests/SyncAPI.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=372102=372101=372102=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Sep 17 03:28:05 2019
@@ -17,6 +17,7 @@
 #include "Preamble.h"
 #include "Protocol.h"
 #include "SemanticHighlighting.h"
+#include "SemanticSelection.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
 #include "Trace.h"
@@ -125,8 +126,8 @@ ClangdServer::ClangdServer(const GlobalC
   // critical paths.
   WorkScheduler(
   CDB, Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory,
-  std::make_unique(
-  DynamicIdx.get(), DiagConsumer, Opts.SemanticHighlighting),
+  std::make_unique(DynamicIdx.get(), 
DiagConsumer,
+ Opts.SemanticHighlighting),
   Opts.UpdateDebounce, Opts.RetentionPolicy) {
   // Adds an index to the stack, at higher priority than existing indexes.
   auto AddIndex = [&](SymbolIndex *Idx) {
@@ -620,6 +621,17 @@ void ClangdServer::symbolInfo(PathRef Fi
   WorkScheduler.runWithAST("SymbolInfo", File, std::move(Action));
 }
 
+void ClangdServer::semanticRanges(PathRef File, Position Pos,
+  Callback> CB) {
+  auto Action =
+  [Pos, CB = std::move(CB)](llvm::Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::getSemanticRanges(InpAST->AST, Pos));
+  };
+  WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action));
+}
+
 std::vector>
 ClangdServer::getUsedBytesPerFile() const {
   return WorkScheduler.getUsedBytesPerFile();

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=372102=372101=372102=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Tue Sep 17 03:28:05 2019
@@ -277,6 +277,10 @@ public:
   void symbolInfo(PathRef File, Position Pos,
   Callback> CB);
 
+  /// Get semantic ranges around a specified position in a file.
+  void semanticRanges(PathRef File, Position Pos,
+  Callback> CB);
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   /// Overall memory usage of clangd may be significantly more than reported

Modified: clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp?rev=372102=372101=372102=diff
==
--- clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp 
(original)
+++ clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp Tue Sep 
17 03:28:05 2019
@@ -7,10 +7,13 @@
 
//===--===//
 
 #include "Annotations.h"
+#include "ClangdServer.h"
 #include "Matchers.h"
 #include "Protocol.h"
 #include "SemanticSelection.h"
 #include "SourceCode.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -23,6 +26,11 @@ namespace clangd {
 namespace {
 using ::testing::ElementsAreArray;
 
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void 

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

2019-09-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I have some nits about explicit comments for arguments and default argument 
values for backwards compatibility. Other than that, it looks like a nice code 
cleanup.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6071
   // Add the target features
-  getTargetFeatures(getToolChain(), Triple, Args, CmdArgs, true);
+  getTargetFeatures(getToolChain(), Triple, Args, CmdArgs, true, false);
 

This needs `/*ForAS=*/true, /*ForLTOPlugin=*/false)` so it's clear what the 
booleans are for. Same for other calls to `getTargetFeatures`.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.h:134
+   llvm::opt::ArgStringList , bool ForAS,
+   bool ForLTOPlugin);
+

The final argument here should probably default to `false`, so that out-of-tree 
backends do not break immediately when this patch lands.


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] D67650: [clangd] Add SemanticRanges to Clangd server.

2019-09-17 Thread UTKARSH SAXENA via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372102: Add SemanticRanges to Clangd server. (authored by 
usaxena95, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67650?vs=220465=220466#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67650

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/trunk/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -17,6 +17,7 @@
 #include "Preamble.h"
 #include "Protocol.h"
 #include "SemanticHighlighting.h"
+#include "SemanticSelection.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
 #include "Trace.h"
@@ -125,8 +126,8 @@
   // critical paths.
   WorkScheduler(
   CDB, Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory,
-  std::make_unique(
-  DynamicIdx.get(), DiagConsumer, Opts.SemanticHighlighting),
+  std::make_unique(DynamicIdx.get(), DiagConsumer,
+ Opts.SemanticHighlighting),
   Opts.UpdateDebounce, Opts.RetentionPolicy) {
   // Adds an index to the stack, at higher priority than existing indexes.
   auto AddIndex = [&](SymbolIndex *Idx) {
@@ -620,6 +621,17 @@
   WorkScheduler.runWithAST("SymbolInfo", File, std::move(Action));
 }
 
+void ClangdServer::semanticRanges(PathRef File, Position Pos,
+  Callback> CB) {
+  auto Action =
+  [Pos, CB = std::move(CB)](llvm::Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::getSemanticRanges(InpAST->AST, Pos));
+  };
+  WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action));
+}
+
 std::vector>
 ClangdServer::getUsedBytesPerFile() const {
   return WorkScheduler.getUsedBytesPerFile();
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -277,6 +277,10 @@
   void symbolInfo(PathRef File, Position Pos,
   Callback> CB);
 
+  /// Get semantic ranges around a specified position in a file.
+  void semanticRanges(PathRef File, Position Pos,
+  Callback> CB);
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   /// Overall memory usage of clangd may be significantly more than reported
Index: clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
@@ -145,5 +145,12 @@
   return std::move(Slab).build();
 }
 
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File, Position Pos) {
+  llvm::Optional>> Result;
+  Server.semanticRanges(File, Pos, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/SemanticSelectionTests.cpp
@@ -7,10 +7,13 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdServer.h"
 #include "Matchers.h"
 #include "Protocol.h"
 #include "SemanticSelection.h"
 #include "SourceCode.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -23,6 +26,11 @@
 namespace {
 using ::testing::ElementsAreArray;
 
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
 TEST(SemanticSelection, All) {
   const char *Tests[] = {
   R"cpp( // Single statement in a function body.
@@ -138,6 +146,36 @@
 << Test;
   }
 }
+
+TEST(SemanticSelection, RunViaClangDServer) {
+  MockFSProvider FS;
+  IgnoreDiagnostics DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooH = testPath("foo.h");
+  FS.Files[FooH] = R"cpp(
+int foo(int x);
+#define HASH(x) ((x) % 10)
+  )cpp";
+
+  auto FooCpp = 

[PATCH] D67650: [clangd] Add SemanticRanges to Clangd server.

2019-09-17 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 220465.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67650

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -53,6 +53,9 @@
 SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest );
 RefSlab getRefs(const SymbolIndex , SymbolID ID);
 
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File, Position Pos);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -145,5 +145,12 @@
   return std::move(Slab).build();
 }
 
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File, Position Pos) {
+  llvm::Optional>> Result;
+  Server.semanticRanges(File, Pos, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -7,10 +7,13 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdServer.h"
 #include "Matchers.h"
 #include "Protocol.h"
 #include "SemanticSelection.h"
 #include "SourceCode.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -23,6 +26,11 @@
 namespace {
 using ::testing::ElementsAreArray;
 
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
 TEST(SemanticSelection, All) {
   const char *Tests[] = {
   R"cpp( // Single statement in a function body.
@@ -138,6 +146,36 @@
 << Test;
   }
 }
+
+TEST(SemanticSelection, RunViaClangDServer) {
+  MockFSProvider FS;
+  IgnoreDiagnostics DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooH = testPath("foo.h");
+  FS.Files[FooH] = R"cpp(
+int foo(int x);
+#define HASH(x) ((x) % 10)
+  )cpp";
+
+  auto FooCpp = testPath("Foo.cpp");
+  const char *SourceContents = R"cpp(
+  #include "foo.h"
+  [[void bar(int& inp) [[{
+// inp = HASH(foo(inp));
+[[inp = [[HASH([[foo([[in^p]])]]);
+  }
+  )cpp";
+  Annotations SourceAnnotations(SourceContents);
+  FS.Files[FooCpp] = SourceAnnotations.code();
+  Server.addDocument(FooCpp, SourceAnnotations.code());
+
+  auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.point());
+  ASSERT_TRUE(bool(Ranges))
+  << "getSemanticRange returned an error: " << Ranges.takeError();
+  EXPECT_THAT(*Ranges, ElementsAreArray(SourceAnnotations.ranges()));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -279,6 +279,10 @@
   void symbolInfo(PathRef File, Position Pos,
   Callback> CB);
 
+  /// Get semantic ranges around a specified position in a file.
+  void semanticRanges(PathRef File, Position Pos,
+  Callback> CB);
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   /// Overall memory usage of clangd may be significantly more than reported
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -17,6 +17,7 @@
 #include "Preamble.h"
 #include "Protocol.h"
 #include "SemanticHighlighting.h"
+#include "SemanticSelection.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
 #include "Trace.h"
@@ -125,8 +126,8 @@
   // critical paths.
   WorkScheduler(
   CDB, Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory,
-  std::make_unique(
-  DynamicIdx.get(), DiagConsumer, Opts.SemanticHighlighting),
+  

[PATCH] D67651: [clangd] No ExtractFunction on empty selections.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67651

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -540,6 +540,8 @@
   EXPECT_EQ(apply("int x = 0; [[x++;]]"), "unavailable");
   // We don't support extraction from lambdas.
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
+  // no selection.
+  EXPECT_EQ(apply("int ^x;"), "unavailable");
 
   // Ensure that end of Zone and Beginning of PostZone being adjacent doesn't
   // lead to break being included in the extraction zone.
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -623,6 +623,9 @@
 }
 
 bool ExtractFunction::prepare(const Selection ) {
+  // Don't trigger the tweak on an empty selection.
+  if (Inputs.SelectionBegin == Inputs.SelectionEnd)
+return false;
   const Node *CommonAnc = Inputs.ASTSelection.commonAncestor();
   const SourceManager  = Inputs.AST.getSourceManager();
   const LangOptions  = Inputs.AST.getASTContext().getLangOpts();


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -540,6 +540,8 @@
   EXPECT_EQ(apply("int x = 0; [[x++;]]"), "unavailable");
   // We don't support extraction from lambdas.
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
+  // no selection.
+  EXPECT_EQ(apply("int ^x;"), "unavailable");
 
   // Ensure that end of Zone and Beginning of PostZone being adjacent doesn't
   // lead to break being included in the extraction zone.
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -623,6 +623,9 @@
 }
 
 bool ExtractFunction::prepare(const Selection ) {
+  // Don't trigger the tweak on an empty selection.
+  if (Inputs.SelectionBegin == Inputs.SelectionEnd)
+return false;
   const Node *CommonAnc = Inputs.ASTSelection.commonAncestor();
   const SourceManager  = Inputs.AST.getSourceManager();
   const LangOptions  = Inputs.AST.getASTContext().getLangOpts();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r371969 - Change signature of __builtin_rotateright64 back to unsigned

2019-09-17 Thread Hans Wennborg via cfe-commits
Merged to release_90 in r372100.

On Mon, Sep 16, 2019 at 11:50 AM Karl-Johan Karlsson via cfe-commits
 wrote:
>
> Author: karka
> Date: Mon Sep 16 02:52:23 2019
> New Revision: 371969
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371969=rev
> Log:
> Change signature of __builtin_rotateright64 back to unsigned
>
> The signature of __builtin_rotateright64 was by misstake changed from
> unsigned to signed in r360863, this patch will change it back to
> unsigned as intended.
>
> This fixes pr43309
>
> Reviewers: efriedma, hans
>
> Reviewed By: hans
>
> Differential Revision: https://reviews.llvm.org/D67606
>
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/test/CodeGen/avr-builtins.c
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=371969=371968=371969=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Sep 16 02:52:23 2019
> @@ -461,7 +461,7 @@ BUILTIN(__builtin_rotateleft64, "UWiUWiU
>  BUILTIN(__builtin_rotateright8, "UcUcUc", "nc")
>  BUILTIN(__builtin_rotateright16, "UsUsUs", "nc")
>  BUILTIN(__builtin_rotateright32, "UZiUZiUZi", "nc")
> -BUILTIN(__builtin_rotateright64, "UWiUWiWi", "nc")
> +BUILTIN(__builtin_rotateright64, "UWiUWiUWi", "nc")
>
>  // Random GCC builtins
>  BUILTIN(__builtin_constant_p, "i.", "nctu")
>
> Modified: cfe/trunk/test/CodeGen/avr-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avr-builtins.c?rev=371969=371968=371969=diff
> ==
> --- cfe/trunk/test/CodeGen/avr-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avr-builtins.c Mon Sep 16 02:52:23 2019
> @@ -1,5 +1,9 @@
>  // RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm -o - %s | 
> FileCheck %s
>
> +// Check that the parameter types match. This verifies pr43309.
> +// RUN: %clang_cc1 -triple avr-unknown-unknown -Wconversion -verify %s
> +// expected-no-diagnostics
> +
>  unsigned char bitrev8(unsigned char data) {
>  return __builtin_bitreverse8(data);
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67650: [clangd] Add SemanticRanges to Clangd server.

2019-09-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks! looks good. I think next step is to implement it in the LSP layer.




Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:161
+  )cpp";
+  Annotations HeaderAnnotations(HeaderContents);
+  FS.Files[FooH] = HeaderAnnotations.code();

nit: we can remove the annotation since we don't use it in the test, just 

```
 FS.Files[FooH] = R"cpp(...)cpp";
```



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:163
+  FS.Files[FooH] = HeaderAnnotations.code();
+  Server.addDocument(FooH, HeaderAnnotations.code());
+

nit: we can get rid of this statement as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67650



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


[PATCH] D67650: Add SemanticRanges to Clangd server.

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

Adds Semantic Ranges capabilities to Clangd server.
Also adds tests for running it via clangd server.

This differs from the LSP spec as the spec needs this to be evaluated on 
multiple 'pos' and the expected output is an list of list of semantic ranges.
This is majorly for multi cursor and assuming this is a rare thing, we don't 
want to optimize make things complicated just for this. 
This should be done in the LSP level by queueing one request per 'pos' in the 
input.

LSP Spec:
https://github.com/microsoft/language-server-protocol/blob/dbaeumer/3.15/specification.md#textDocument_selectionRange


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67650

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -53,6 +53,9 @@
 SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest );
 RefSlab getRefs(const SymbolIndex , SymbolID ID);
 
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File, Position Pos);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -145,5 +145,12 @@
   return std::move(Slab).build();
 }
 
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File, Position Pos) {
+  llvm::Optional>> Result;
+  Server.semanticRanges(File, Pos, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -7,10 +7,13 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdServer.h"
 #include "Matchers.h"
 #include "Protocol.h"
 #include "SemanticSelection.h"
 #include "SourceCode.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -23,6 +26,11 @@
 namespace {
 using ::testing::ElementsAreArray;
 
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
 TEST(SemanticSelection, All) {
   const char *Tests[] = {
   R"cpp( // Single statement in a function body.
@@ -138,6 +146,39 @@
 << Test;
   }
 }
+
+TEST(SemanticSelection, RunViaClangDServer) {
+  MockFSProvider FS;
+  IgnoreDiagnostics DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooH = testPath("foo.h");
+  const char *HeaderContents =  R"cpp(
+int foo(int x);
+#define HASH(x) ((x) % 10)
+  )cpp";
+  Annotations HeaderAnnotations(HeaderContents);
+  FS.Files[FooH] = HeaderAnnotations.code();
+  Server.addDocument(FooH, HeaderAnnotations.code());
+
+  auto FooCpp = testPath("Foo.cpp");
+  const char *SourceContents = R"cpp(
+  #include "foo.h"
+  [[void bar(int& inp) [[{
+// inp = HASH(foo(inp));
+[[inp = [[HASH([[foo([[in^p]])]]);
+  }
+  )cpp";
+  Annotations SourceAnnotations(SourceContents);
+  FS.Files[FooCpp] = SourceAnnotations.code();
+  Server.addDocument(FooCpp, SourceAnnotations.code());
+
+  auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.point());
+  ASSERT_TRUE(bool(Ranges))
+  << "getSemanticRange returned an error: " << Ranges.takeError();
+  EXPECT_THAT(*Ranges, ElementsAreArray(SourceAnnotations.ranges()));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -279,6 +279,10 @@
   void symbolInfo(PathRef File, Position Pos,
   Callback> CB);
 
+  /// Get semantic ranges around a specified position in a file.
+  void semanticRanges(PathRef File, Position Pos,
+  Callback> CB);
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   

r372095 - [NFC] Updated test

2019-09-17 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Tue Sep 17 02:53:14 2019
New Revision: 372095

URL: http://llvm.org/viewvc/llvm-project?rev=372095=rev
Log:
[NFC] Updated test

Modified:
cfe/trunk/test/CodeGen/tbaa-struct.cpp

Modified: cfe/trunk/test/CodeGen/tbaa-struct.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-struct.cpp?rev=372095=372094=372095=diff
==
--- cfe/trunk/test/CodeGen/tbaa-struct.cpp (original)
+++ cfe/trunk/test/CodeGen/tbaa-struct.cpp Tue Sep 17 02:53:14 2019
@@ -17,7 +17,7 @@ typedef A __attribute__((may_alias)) AA;
 
 void copy(A *a1, A *a2) {
 // CHECK-LABEL: _Z4copyP1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(16) 
%{{.*}}, i8* align 4 dereferenceable(16) %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 
dereferenceable(16) %{{.*}}, i8* nonnull align 4 dereferenceable(16) %{{.*}}, 
i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_A:![0-9]*]]
   *a1 = *a2;
@@ -31,7 +31,7 @@ struct B {
 
 void copy2(B *b1, B *b2) {
 // CHECK-LABEL: _Z5copy2P1BS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(24) 
%{{.*}}, i8* align 4 dereferenceable(24) %{{.*}}, i64 24, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 
dereferenceable(24) %{{.*}}, i8* nonnull align 4 dereferenceable(24) %{{.*}}, 
i64 24, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS2:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_B:![0-9]*]]
   *b1 = *b2;
@@ -49,7 +49,7 @@ union U {
 
 void copy3(U *u1, U *u2) {
 // CHECK-LABEL: _Z5copy3P1US0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(12) 
%{{.*}}, i8* align 4 dereferenceable(12) %{{.*}}, i64 12, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 
dereferenceable(12) %{{.*}}, i8* nonnull align 4 dereferenceable(12) %{{.*}}, 
i64 12, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS3:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_U:![0-9]*]]
   *u1 = *u2;
@@ -65,7 +65,7 @@ struct C {
 
 void copy4(C *c1, C *c2) {
 // CHECK-LABEL: _Z5copy4P1CS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) 
{{.*}}, i8* align 1 dereferenceable(3) {{.*}}, i64 3, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(3) {{.*}}, i8* nonnull align 1 dereferenceable(3) {{.*}}, i64 
3, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS4:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_C:![0-9]*]]
   *c1 = *c2;
@@ -80,7 +80,7 @@ struct D {
 
 void copy5(D *d1, D *d2) {
 // CHECK-LABEL: _Z5copy5P1DS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(6) 
{{.*}}, i8* align 1 dereferenceable(6) {{.*}}, i64 6, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(6) {{.*}}, i8* nonnull align 1 dereferenceable(6) {{.*}}, i64 
6, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS5:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_D:![0-9]*]]
   *d1 = *d2;
@@ -88,7 +88,7 @@ void copy5(D *d1, D *d2) {
 
 void copy6(AA *a1, A *a2) {
 // CHECK-LABEL: _Z5copy6P1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(16) 
%{{.*}}, i8* align 4 dereferenceable(16) %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 
dereferenceable(16) %{{.*}}, i8* nonnull align 4 dereferenceable(16) %{{.*}}, 
i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS]]
 // CHECK-NEW-SAME: !tbaa [[TAG_char:![0-9]*]]
   *a1 = *a2;
@@ -96,7 +96,7 @@ void copy6(AA *a1, A *a2) {
 
 void copy7(A *a1, AA *a2) {
 // CHECK-LABEL: _Z5copy7P1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(16) 
%{{.*}}, i8* align 4 dereferenceable(16) %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 
dereferenceable(16) %{{.*}}, i8* nonnull align 4 dereferenceable(16) %{{.*}}, 
i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS]]
 // CHECK-NEW-SAME: !tbaa [[TAG_char]]
   *a1 = *a2;


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


[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-09-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.cpp:49
+  if (HasDefaultOperatorNew && OverAligned)
+diag(NewExpr->getBeginLoc(), "using default 'operator new' with 
over-aligned type %0 may result in undefined behavior")
+  << D;

martong wrote:
> I think it would be useful to add the value of the fundamental alignment to 
> the diagnostics too.
Should be this the correct error message? "Allocation with standard new: too 
long alignment for a user type." Or "Allocation with standard new: too long 
alignment (//user_align//) for a user type, default is //default_align//."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67545



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


  1   2   >