Re: [PATCH] D24690: Replace __ANDROID__ with __BIONIC__.

2016-09-18 Thread Dan Albert via cfe-commits
danalbert added inline comments.


Comment at: include/__config:90
@@ +89,3 @@
+#if defined(__linux__)
+#include 
+#if !defined(__GLIBC_PREREQ)

EricWF wrote:
> Does MUSL libc have a `features.h`?  This include was previously guarded by 
> if `!defined(_LIBCPP_HAS_MUSL_LIBC)`. 
Yep: https://github.com/wermut/musl/blob/master/include/features.h


Repository:
  rL LLVM

https://reviews.llvm.org/D24690



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


Re: [PATCH] D24690: Replace __ANDROID__ with __BIONIC__.

2016-09-18 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM after addressing the MUSL libc comment.



Comment at: include/__config:90
@@ +89,3 @@
+#if defined(__linux__)
+#include 
+#if !defined(__GLIBC_PREREQ)

Does MUSL libc have a `features.h`?  This include was previously guarded by if 
`!defined(_LIBCPP_HAS_MUSL_LIBC)`. 


Repository:
  rL LLVM

https://reviews.llvm.org/D24690



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


r281881 - [docs] Touch up the code coverage doc

2016-09-18 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Sun Sep 18 20:42:38 2016
New Revision: 281881

URL: http://llvm.org/viewvc/llvm-project?rev=281881=rev
Log:
[docs] Touch up the code coverage doc

Modified:
cfe/trunk/docs/SourceBasedCodeCoverage.rst

Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SourceBasedCodeCoverage.rst?rev=281881=281880=281881=diff
==
--- cfe/trunk/docs/SourceBasedCodeCoverage.rst (original)
+++ cfe/trunk/docs/SourceBasedCodeCoverage.rst Sun Sep 18 20:42:38 2016
@@ -125,24 +125,24 @@ region counts (even in macro expansions)
 
 .. code-block:: none
 
-   20|1|#define BAR(x) ((x) || (x))
+1|   20|#define BAR(x) ((x) || (x))
^20 ^2
 2|2|template  void foo(T x) {
-   22|3|  for (unsigned I = 0; I < 10; ++I) { BAR(I); }
+3|   22|  for (unsigned I = 0; I < 10; ++I) { BAR(I); }
^22 ^20  ^20^20
-2|4|}
+4|2|}
 --
 | void foo(int):
-|  1|2|template  void foo(T x) {
-| 11|3|  for (unsigned I = 0; I < 10; ++I) { BAR(I); }
+|  2|1|template  void foo(T x) {
+|  3|   11|  for (unsigned I = 0; I < 10; ++I) { BAR(I); }
 | ^11 ^10  ^10^10
-|  1|4|}
+|  4|1|}
 --
 | void foo(int):
-|  1|2|template  void foo(T x) {
-| 11|3|  for (unsigned I = 0; I < 10; ++I) { BAR(I); }
+|  2|1|template  void foo(T x) {
+|  3|   11|  for (unsigned I = 0; I < 10; ++I) { BAR(I); }
 | ^11 ^10  ^10^10
-|  1|4|}
+|  4|1|}
 --
 
 It's possible to generate a file-level summary of coverage statistics (instead
@@ -177,6 +177,26 @@ A few final notes:
 
   % llvm-profdata merge -sparse foo1.profraw foo2.profdata -o foo3.profdata
 
+Interpreting reports
+
+
+There are four statistics tracked in a coverage summary:
+
+* Function coverage is the percentage of functions which have been executed at
+  least once. A function is treated as having been executed if any of its
+  instantiations are executed.
+
+* Instantiation coverage is the percentage of function instantiations which
+  have been executed at least once.
+
+* Line coverage is the percentage of code lines which have been executed at
+  least once.
+
+* Region coverage is the percentage of code regions which have been executed at
+  least once. A code region may span multiple lines (e.g a large function with
+  no control flow). However, it's also possible for a single line to contain
+  multiple code regions (e.g some short-circuited logic).
+
 Format compatibility guarantees
 ===
 


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


r281880 - [analyzer] SATestBuild.py: Treat '#' as comment in projectMap.csv

2016-09-18 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Sun Sep 18 20:36:40 2016
New Revision: 281880

URL: http://llvm.org/viewvc/llvm-project?rev=281880=rev
Log:
[analyzer] SATestBuild.py: Treat '#' as comment in projectMap.csv

Treat lines in projectMap.csv that start with '#' as comments. This enables a
workflow where projects can be temporarily disabled with a comment describing
when they should be turned back on.

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

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=281880=281879=281880=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Sun Sep 18 20:36:40 2016
@@ -660,11 +660,17 @@ def testProject(ID, ProjectBuildMode, Is
 print "Completed tests for project %s (time: %.2f)." % \
   (ID, (time.time()-TBegin))
 
+def isCommentCSVLine(Entries):
+  # Treat CSV lines starting with a '#' as a comment.
+  return len(Entries) > 0 and Entries[0].startswith("#")
+
 def testAll(IsReferenceBuild = False, UpdateSVN = False, Strictness = 0):
 PMapFile = open(getProjectMapPath(), "rb")
 try:
 # Validate the input.
 for I in csv.reader(PMapFile):
+if (isCommentCSVLine(I)):
+continue
 if (len(I) != 2) :
 print "Error: Rows in the ProjectMapFile should have 3 
entries."
 raise Exception()
@@ -682,6 +688,8 @@ def testAll(IsReferenceBuild = False, Up
 # Test the projects.
 PMapFile.seek(0)
 for I in csv.reader(PMapFile):
+if isCommentCSVLine(I):
+  continue;
 testProject(I[0], int(I[1]), IsReferenceBuild, None, Strictness)
 
 # Add reference results to SVN.


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


Re: [PATCH] D24709: [analyzer] SATestBuild.py: Treat '#' as comment in projectMap.csv

2016-09-18 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281880: [analyzer] SATestBuild.py: Treat '#' as comment in 
projectMap.csv (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D24709?vs=71757=71766#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24709

Files:
  cfe/trunk/utils/analyzer/SATestBuild.py

Index: cfe/trunk/utils/analyzer/SATestBuild.py
===
--- cfe/trunk/utils/analyzer/SATestBuild.py
+++ cfe/trunk/utils/analyzer/SATestBuild.py
@@ -660,11 +660,17 @@
 print "Completed tests for project %s (time: %.2f)." % \
   (ID, (time.time()-TBegin))
 
+def isCommentCSVLine(Entries):
+  # Treat CSV lines starting with a '#' as a comment.
+  return len(Entries) > 0 and Entries[0].startswith("#")
+
 def testAll(IsReferenceBuild = False, UpdateSVN = False, Strictness = 0):
 PMapFile = open(getProjectMapPath(), "rb")
 try:
 # Validate the input.
 for I in csv.reader(PMapFile):
+if (isCommentCSVLine(I)):
+continue
 if (len(I) != 2) :
 print "Error: Rows in the ProjectMapFile should have 3 
entries."
 raise Exception()
@@ -682,6 +688,8 @@
 # Test the projects.
 PMapFile.seek(0)
 for I in csv.reader(PMapFile):
+if isCommentCSVLine(I):
+  continue;
 testProject(I[0], int(I[1]), IsReferenceBuild, None, Strictness)
 
 # Add reference results to SVN.


Index: cfe/trunk/utils/analyzer/SATestBuild.py
===
--- cfe/trunk/utils/analyzer/SATestBuild.py
+++ cfe/trunk/utils/analyzer/SATestBuild.py
@@ -660,11 +660,17 @@
 print "Completed tests for project %s (time: %.2f)." % \
   (ID, (time.time()-TBegin))
 
+def isCommentCSVLine(Entries):
+  # Treat CSV lines starting with a '#' as a comment.
+  return len(Entries) > 0 and Entries[0].startswith("#")
+
 def testAll(IsReferenceBuild = False, UpdateSVN = False, Strictness = 0):
 PMapFile = open(getProjectMapPath(), "rb")
 try:
 # Validate the input.
 for I in csv.reader(PMapFile):
+if (isCommentCSVLine(I)):
+continue
 if (len(I) != 2) :
 print "Error: Rows in the ProjectMapFile should have 3 entries."
 raise Exception()
@@ -682,6 +688,8 @@
 # Test the projects.
 PMapFile.seek(0)
 for I in csv.reader(PMapFile):
+if isCommentCSVLine(I):
+  continue;
 testProject(I[0], int(I[1]), IsReferenceBuild, None, Strictness)
 
 # Add reference results to SVN.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281879 - [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-18 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Sun Sep 18 19:59:19 2016
New Revision: 281879

URL: http://llvm.org/viewvc/llvm-project?rev=281879=rev
Log:
[XRay] ARM 32-bit no-Thumb support in Clang

Just a test for now, adapted from x86_64 tests of XRay.
This is one of 3 commits to different repositories of XRay ARM port. The other 
2 are:

https://reviews.llvm.org/D23931 (LLVM)
https://reviews.llvm.org/D23933 (compiler-rt)

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

Added:
cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp

Added: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp?rev=281879=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp Sun Sep 18 
19:59:19 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


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


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-18 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281879: [XRay] ARM 32-bit no-Thumb support in Clang 
(authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D23932?vs=71635=71765#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23932

Files:
  cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp

Index: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


Index: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24704: PR30401: Fix substitutions for functions with abi_tag

2016-09-18 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:668
@@ -664,3 +667,3 @@
   llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
   CXXNameMangler FunctionEncodingMangler(*this, FunctionEncodingStream);
   // Output name of the function.

rsmith wrote:
> Maybe it'd be simpler to just override the output stream here rather than 
> creating a new mangler?
I'm not sure that it is simpler because it will also require substitutions 
save/restore for name mangling (mangleNameWithAbiTags) to produce the same 
substitutions twice (without implicate abi_tags and later with implicit 
abi_tags). IMHO, it is almost identical approaches but current one is a bit 
cleaner because it copies explicitly everything required from temp to outer 
mangler.


https://reviews.llvm.org/D24704



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


Re: [PATCH] D24704: PR30401: Fix substitutions for functions with abi_tag

2016-09-18 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:668
@@ -664,3 +667,3 @@
   llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
   CXXNameMangler FunctionEncodingMangler(*this, FunctionEncodingStream);
   // Output name of the function.

DmitryPolukhin wrote:
> rsmith wrote:
> > Maybe it'd be simpler to just override the output stream here rather than 
> > creating a new mangler?
> I'm not sure that it is simpler because it will also require substitutions 
> save/restore for name mangling (mangleNameWithAbiTags) to produce the same 
> substitutions twice (without implicate abi_tags and later with implicit 
> abi_tags). IMHO, it is almost identical approaches but current one is a bit 
> cleaner because it copies explicitly everything required from temp to outer 
> mangler.
I think we'd want to override the output stream to write to a temporary buffer 
at the point when we would otherwise write out the ABI tags, to avoid needing 
to save/restore any substitutions. But I agree, that seems more invasive than 
what you're doing here. I'll leave this up to you.


Comment at: lib/AST/ItaniumMangle.cpp:4439
@@ +4438,3 @@
+  if (Other.SeqID > SeqID) {
+Substitutions = Other.Substitutions;
+SeqID = Other.SeqID;

Please avoid the cost of a full copy here by making this a destructive 
operation on `Other` -- use `swap` or move-assignment here. (We'll still be 
paying for one copy of the substitution set per function mangling, which is 
unfortunate / undesirable.)


https://reviews.llvm.org/D24704



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


[PATCH] D24709: [analyzer] SATestBuild.py: Treat '#' as comment in projectMap.csv

2016-09-18 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, NoQ.
dcoughlin added a subscriber: cfe-commits.

Treat lines in projectMap.csv that start with '#' as comments.

This enables a workflow where projects can be temporarily disabled with a 
comment describing when they should be turned back on.

https://reviews.llvm.org/D24709

Files:
  utils/analyzer/SATestBuild.py

Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -660,11 +660,17 @@
 print "Completed tests for project %s (time: %.2f)." % \
   (ID, (time.time()-TBegin))
 
+def isCommentCSVLine(Entries):
+  # Treat CSV lines starting with a '#' as a comment.
+  return len(Entries) > 0 and Entries[0].startswith("#")
+
 def testAll(IsReferenceBuild = False, UpdateSVN = False, Strictness = 0):
 PMapFile = open(getProjectMapPath(), "rb")
 try:
 # Validate the input.
 for I in csv.reader(PMapFile):
+if (isCommentCSVLine(I)):
+continue
 if (len(I) != 2) :
 print "Error: Rows in the ProjectMapFile should have 3 
entries."
 raise Exception()
@@ -682,6 +688,8 @@
 # Test the projects.
 PMapFile.seek(0)
 for I in csv.reader(PMapFile):
+if isCommentCSVLine(I):
+  continue;
 testProject(I[0], int(I[1]), IsReferenceBuild, None, Strictness)
 
 # Add reference results to SVN.


Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -660,11 +660,17 @@
 print "Completed tests for project %s (time: %.2f)." % \
   (ID, (time.time()-TBegin))
 
+def isCommentCSVLine(Entries):
+  # Treat CSV lines starting with a '#' as a comment.
+  return len(Entries) > 0 and Entries[0].startswith("#")
+
 def testAll(IsReferenceBuild = False, UpdateSVN = False, Strictness = 0):
 PMapFile = open(getProjectMapPath(), "rb")
 try:
 # Validate the input.
 for I in csv.reader(PMapFile):
+if (isCommentCSVLine(I)):
+continue
 if (len(I) != 2) :
 print "Error: Rows in the ProjectMapFile should have 3 entries."
 raise Exception()
@@ -682,6 +688,8 @@
 # Test the projects.
 PMapFile.seek(0)
 for I in csv.reader(PMapFile):
+if isCommentCSVLine(I):
+  continue;
 testProject(I[0], int(I[1]), IsReferenceBuild, None, Strictness)
 
 # Add reference results to SVN.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24704: PR30401: Fix substitutions for functions with abi_tag

2016-09-18 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:668
@@ -664,3 +667,3 @@
   llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
   CXXNameMangler FunctionEncodingMangler(*this, FunctionEncodingStream);
   // Output name of the function.

Maybe it'd be simpler to just override the output stream here rather than 
creating a new mangler?


https://reviews.llvm.org/D24704



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


Re: [PATCH] D24477: clang-format: [JS] Do not wrap taze: IWYU comments

2016-09-18 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281857: clang-format: [JS] Do not wrap taze annotation 
comments. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D24477?vs=71189=71756#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24477

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

Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -613,7 +613,7 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas = "@(export|requirecss|return|see|visibility) ";
+GoogleStyle.CommentPragmas = 
"(taze:|@(export|requirecss|return|see|visibility)) ";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1444,5 +1444,11 @@
"}");
 }
 
+TEST_F(FormatTestJS, ImportComments) {
+  verifyFormat("import {x} from 'x';  // from some location",
+   getGoogleJSStyleWithColumns(25));
+  verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+}
+
 } // end namespace tooling
 } // end namespace clang


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -613,7 +613,7 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas = "@(export|requirecss|return|see|visibility) ";
+GoogleStyle.CommentPragmas = "(taze:|@(export|requirecss|return|see|visibility)) ";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1444,5 +1444,11 @@
"}");
 }
 
+TEST_F(FormatTestJS, ImportComments) {
+  verifyFormat("import {x} from 'x';  // from some location",
+   getGoogleJSStyleWithColumns(25));
+  verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+}
+
 } // end namespace tooling
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281857 - clang-format: [JS] Do not wrap taze annotation comments.

2016-09-18 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Sun Sep 18 12:33:51 2016
New Revision: 281857

URL: http://llvm.org/viewvc/llvm-project?rev=281857=rev
Log:
clang-format: [JS] Do not wrap taze annotation comments.

Summary:
`// taze: ... from ...` comments are used help tools where a
specific global symbol comes from.

Before:
// taze: many, different, symbols from
// 'some_long_location_here'

After:
// taze: many, different, symbols from 'some_long_location_here'

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=281857=281856=281857=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sun Sep 18 12:33:51 2016
@@ -613,7 +613,7 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas = "@(export|requirecss|return|see|visibility) ";
+GoogleStyle.CommentPragmas = 
"(taze:|@(export|requirecss|return|see|visibility)) ";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=281857=281856=281857=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sun Sep 18 12:33:51 2016
@@ -1444,5 +1444,11 @@ TEST_F(FormatTestJS, Conditional) {
"}");
 }
 
+TEST_F(FormatTestJS, ImportComments) {
+  verifyFormat("import {x} from 'x';  // from some location",
+   getGoogleJSStyleWithColumns(25));
+  verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+}
+
 } // end namespace tooling
 } // end namespace clang


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


Re: [PATCH] D24574: clang-format: [JS] ASI insertion after boolean literals.

2016-09-18 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281856: clang-format: [JS] ASI insertion after boolean 
literals. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D24574?vs=71385=71755#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24574

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -681,7 +681,9 @@
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords ,
  const FormatToken *FormatTok) {
-  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+  return FormatTok->Tok.isLiteral() ||
+ FormatTok->isOneOf(tok::kw_true, tok::kw_false) ||
+ mustBeJSIdent(Keywords, FormatTok);
 }
 
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -774,6 +774,18 @@
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("a = true\n"
+   "return 1",
+   "a = true\n"
+   "  return   1");
+  verifyFormat("a = 's'\n"
+   "return 1",
+   "a = 's'\n"
+   "  return   1");
+  verifyFormat("a = null\n"
+   "return 1",
+   "a = null\n"
+   "  return   1");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -681,7 +681,9 @@
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords ,
  const FormatToken *FormatTok) {
-  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+  return FormatTok->Tok.isLiteral() ||
+ FormatTok->isOneOf(tok::kw_true, tok::kw_false) ||
+ mustBeJSIdent(Keywords, FormatTok);
 }
 
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -774,6 +774,18 @@
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("a = true\n"
+   "return 1",
+   "a = true\n"
+   "  return   1");
+  verifyFormat("a = 's'\n"
+   "return 1",
+   "a = 's'\n"
+   "  return   1");
+  verifyFormat("a = null\n"
+   "return 1",
+   "a = null\n"
+   "  return   1");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24708: clang-format: [JS] Fix line breaks before comments when sorting imports.

2016-09-18 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Previously, clang-format would always insert an additional line break after the
import block if the main body started with a comment, due to loosing track of
the first non-import line.

https://reviews.llvm.org/D24708

Files:
  lib/Format/SortJavaScriptImports.cpp
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -121,6 +121,16 @@
  "import {sym} from 'b';  // from //foo:bar\n"
  "// A very important import follows.\n"
  "import {sym} from 'a';  /* more comments */\n");
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "\n"
+ "/** Comment on variable. */\n"
+ "const x = 1;\n",
+ "import {sym} from 'b';\n"
+ "import {sym} from 'a';\n"
+ "\n"
+ "/** Comment on variable. */\n"
+ "const x = 1;\n");
 }
 
 TEST_F(SortImportsTestJS, SortStar) {
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -293,14 +293,19 @@
 // of the import that immediately follows them by using the previously
 // set Start.
 Start = Line->First->Tok.getLocation();
-  if (!Current)
-continue; // Only comments on this line.
+  if (!Current) {
+// Only comments on this line. Could be the first non-import line.
+FirstNonImportLine = Line;
+continue;
+  }
   JsModuleReference Reference;
   Reference.Range.setBegin(Start);
   if (!parseModuleReference(Keywords, Reference)) {
-FirstNonImportLine = Line;
+if (!FirstNonImportLine)
+  FirstNonImportLine = Line; // if no comment before.
 break;
   }
+  FirstNonImportLine = nullptr;
   AnyImportAffected = AnyImportAffected || Line->Affected;
   Reference.Range.setEnd(LineEnd->Tok.getEndLoc());
   DEBUG({


Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -121,6 +121,16 @@
  "import {sym} from 'b';  // from //foo:bar\n"
  "// A very important import follows.\n"
  "import {sym} from 'a';  /* more comments */\n");
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "\n"
+ "/** Comment on variable. */\n"
+ "const x = 1;\n",
+ "import {sym} from 'b';\n"
+ "import {sym} from 'a';\n"
+ "\n"
+ "/** Comment on variable. */\n"
+ "const x = 1;\n");
 }
 
 TEST_F(SortImportsTestJS, SortStar) {
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -293,14 +293,19 @@
 // of the import that immediately follows them by using the previously
 // set Start.
 Start = Line->First->Tok.getLocation();
-  if (!Current)
-continue; // Only comments on this line.
+  if (!Current) {
+// Only comments on this line. Could be the first non-import line.
+FirstNonImportLine = Line;
+continue;
+  }
   JsModuleReference Reference;
   Reference.Range.setBegin(Start);
   if (!parseModuleReference(Keywords, Reference)) {
-FirstNonImportLine = Line;
+if (!FirstNonImportLine)
+  FirstNonImportLine = Line; // if no comment before.
 break;
   }
+  FirstNonImportLine = nullptr;
   AnyImportAffected = AnyImportAffected || Line->Affected;
   Reference.Range.setEnd(LineEnd->Tok.getEndLoc());
   DEBUG({
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281854 - CodeGen: mark ObjC cstring literals as constant

2016-09-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Sep 18 11:12:04 2016
New Revision: 281854

URL: http://llvm.org/viewvc/llvm-project?rev=281854=rev
Log:
CodeGen: mark ObjC cstring literals as constant

These strings are constants, mark them as such.  This doesn't matter too much in
practice on MachO since the constants are placed into a special section and not
referred to directly.

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/boxing.m
cfe/trunk/test/CodeGenObjC/complex-property.m
cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m
cfe/trunk/test/CodeGenObjC/encode-test-6.m
cfe/trunk/test/CodeGenObjC/encode-test.m
cfe/trunk/test/CodeGenObjC/fragile-arc.m
cfe/trunk/test/CodeGenObjC/ivar-layout-64.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-32.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-64.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m
cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m
cfe/trunk/test/CodeGenObjC/property-list-in-extension.m
cfe/trunk/test/CodeGenObjC/reorder-synthesized-ivars.m
cfe/trunk/test/CodeGenObjCXX/encode.mm
cfe/trunk/test/CodeGenObjCXX/lambda-expressions.mm

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=281854=281853=281854=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Sep 18 11:12:04 2016
@@ -3691,7 +3691,8 @@ CGObjCCommonMac::CreateCStringLiteral(St
 
   llvm::Constant *Value = llvm::ConstantDataArray::getString(VMContext, Name);
   llvm::GlobalVariable *GV =
-  new llvm::GlobalVariable(CGM.getModule(), Value->getType(), false,
+  new llvm::GlobalVariable(CGM.getModule(), Value->getType(),
+   /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, Value, 
Label);
   GV->setSection(Section);
   GV->setAlignment(CharUnits::One().getQuantity());

Modified: cfe/trunk/test/CodeGenObjC/boxing.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/boxing.m?rev=281854=281853=281854=diff
==
--- cfe/trunk/test/CodeGenObjC/boxing.m (original)
+++ cfe/trunk/test/CodeGenObjC/boxing.m Sun Sep 18 11:12:04 2016
@@ -53,17 +53,17 @@ typedef signed char BOOL;
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
 @end
 
-// CHECK: [[WithIntMeth:@.*]] = private global [15 x i8] c"numberWithInt:\00"
+// CHECK: [[WithIntMeth:@.*]] = private constant [15 x i8] c"numberWithInt:\00"
 // CHECK: [[WithIntSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([15 x i8], [15 x i8]* [[WithIntMeth]]
-// CHECK: [[WithCharMeth:@.*]] = private global [16 x i8] c"numberWithChar:\00"
+// CHECK: [[WithCharMeth:@.*]] = private constant [16 x i8] 
c"numberWithChar:\00"
 // CHECK: [[WithCharSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([16 x i8], [16 x i8]* [[WithCharMeth]]
-// CHECK: [[WithBoolMeth:@.*]] = private global [16 x i8] c"numberWithBool:\00"
+// CHECK: [[WithBoolMeth:@.*]] = private constant [16 x i8] 
c"numberWithBool:\00"
 // CHECK: [[WithBoolSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([16 x i8], [16 x i8]* [[WithBoolMeth]]
-// CHECK: [[WithIntegerMeth:@.*]] = private global [19 x i8] 
c"numberWithInteger:\00"
+// CHECK: [[WithIntegerMeth:@.*]] = private constant [19 x i8] 
c"numberWithInteger:\00"
 // CHECK: [[WithIntegerSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([19 x i8], [19 x i8]* [[WithIntegerMeth]]
-// CHECK: [[WithUnsignedIntegerMeth:@.*]] = private global [27 x i8] 
c"numberWithUnsignedInteger:\00"
+// CHECK: [[WithUnsignedIntegerMeth:@.*]] = private constant [27 x i8] 
c"numberWithUnsignedInteger:\00"
 // CHECK: [[WithUnsignedIntegerSEL:@.*]] = private externally_initialized 
global i8* getelementptr inbounds ([27 x i8], [27 x i8]* 
[[WithUnsignedIntegerMeth]]
-// CHECK: [[stringWithUTF8StringMeth:@.*]] = private global [22 x i8] 
c"stringWithUTF8String:\00"
+// CHECK: [[stringWithUTF8StringMeth:@.*]] = private constant [22 x i8] 
c"stringWithUTF8String:\00"
 // CHECK: [[stringWithUTF8StringSEL:@.*]] = private externally_initialized 
global i8* getelementptr inbounds ([22 x i8], [22 x i8]* 
[[stringWithUTF8StringMeth]]
 
 int main() {

Modified: cfe/trunk/test/CodeGenObjC/complex-property.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/complex-property.m?rev=281854=281853=281854=diff
==
--- 

r281855 - CodeGen: mark ObjC cstring literals as unnamed_addr

2016-09-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Sep 18 11:12:14 2016
New Revision: 281855

URL: http://llvm.org/viewvc/llvm-project?rev=281855=rev
Log:
CodeGen: mark ObjC cstring literals as unnamed_addr

These are all emitted into a section with a cstring_literal attribute.  The
attribute permits the linker to coalesce the string contents.  The address of
the strings are not important.

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/boxing.m
cfe/trunk/test/CodeGenObjC/complex-property.m
cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m
cfe/trunk/test/CodeGenObjC/encode-test-6.m
cfe/trunk/test/CodeGenObjC/encode-test.m
cfe/trunk/test/CodeGenObjC/fragile-arc.m
cfe/trunk/test/CodeGenObjC/ivar-layout-64.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-32.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-64.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m
cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m
cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m
cfe/trunk/test/CodeGenObjC/property-list-in-extension.m
cfe/trunk/test/CodeGenObjC/reorder-synthesized-ivars.m
cfe/trunk/test/CodeGenObjCXX/encode.mm
cfe/trunk/test/CodeGenObjCXX/lambda-expressions.mm

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=281855=281854=281855=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Sep 18 11:12:14 2016
@@ -3694,7 +3694,9 @@ CGObjCCommonMac::CreateCStringLiteral(St
   new llvm::GlobalVariable(CGM.getModule(), Value->getType(),
/*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, Value, 
Label);
-  GV->setSection(Section);
+  if (CGM.getTriple().isOSBinFormatMachO())
+GV->setSection(Section);
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
   GV->setAlignment(CharUnits::One().getQuantity());
   CGM.addCompilerUsedGlobal(GV);
 

Modified: cfe/trunk/test/CodeGenObjC/boxing.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/boxing.m?rev=281855=281854=281855=diff
==
--- cfe/trunk/test/CodeGenObjC/boxing.m (original)
+++ cfe/trunk/test/CodeGenObjC/boxing.m Sun Sep 18 11:12:14 2016
@@ -53,17 +53,17 @@ typedef signed char BOOL;
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
 @end
 
-// CHECK: [[WithIntMeth:@.*]] = private constant [15 x i8] c"numberWithInt:\00"
+// CHECK: [[WithIntMeth:@.*]] = private unnamed_addr constant [15 x i8] 
c"numberWithInt:\00"
 // CHECK: [[WithIntSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([15 x i8], [15 x i8]* [[WithIntMeth]]
-// CHECK: [[WithCharMeth:@.*]] = private constant [16 x i8] 
c"numberWithChar:\00"
+// CHECK: [[WithCharMeth:@.*]] = private unnamed_addr constant [16 x i8] 
c"numberWithChar:\00"
 // CHECK: [[WithCharSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([16 x i8], [16 x i8]* [[WithCharMeth]]
-// CHECK: [[WithBoolMeth:@.*]] = private constant [16 x i8] 
c"numberWithBool:\00"
+// CHECK: [[WithBoolMeth:@.*]] = private unnamed_addr constant [16 x i8] 
c"numberWithBool:\00"
 // CHECK: [[WithBoolSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([16 x i8], [16 x i8]* [[WithBoolMeth]]
-// CHECK: [[WithIntegerMeth:@.*]] = private constant [19 x i8] 
c"numberWithInteger:\00"
+// CHECK: [[WithIntegerMeth:@.*]] = private unnamed_addr constant [19 x i8] 
c"numberWithInteger:\00"
 // CHECK: [[WithIntegerSEL:@.*]] = private externally_initialized global i8* 
getelementptr inbounds ([19 x i8], [19 x i8]* [[WithIntegerMeth]]
-// CHECK: [[WithUnsignedIntegerMeth:@.*]] = private constant [27 x i8] 
c"numberWithUnsignedInteger:\00"
+// CHECK: [[WithUnsignedIntegerMeth:@.*]] = private unnamed_addr constant [27 
x i8] c"numberWithUnsignedInteger:\00"
 // CHECK: [[WithUnsignedIntegerSEL:@.*]] = private externally_initialized 
global i8* getelementptr inbounds ([27 x i8], [27 x i8]* 
[[WithUnsignedIntegerMeth]]
-// CHECK: [[stringWithUTF8StringMeth:@.*]] = private constant [22 x i8] 
c"stringWithUTF8String:\00"
+// CHECK: [[stringWithUTF8StringMeth:@.*]] = private unnamed_addr constant [22 
x i8] c"stringWithUTF8String:\00"
 // CHECK: [[stringWithUTF8StringSEL:@.*]] = private externally_initialized 
global i8* getelementptr inbounds ([22 x i8], [22 x i8]* 
[[stringWithUTF8StringMeth]]
 
 int main() {

Modified: cfe/trunk/test/CodeGenObjC/complex-property.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/complex-property.m?rev=281855=281854=281855=diff

Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-18 Thread Zoltán Dániel Török via cfe-commits
zdtorok added a comment.

As it's my first contribution I think I have no commit access.
So far I could not test it on larger codebase. I've tried to do so on clang but 
my computer was too slow for that. I will try it again.
What you mean by alpha-phase? What should be the next steps now?


Repository:
  rL LLVM

https://reviews.llvm.org/D21506



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


[PATCH] D24704: PR30401: Fix substitutions for functions with abi_tag

2016-09-18 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rsmith.
DmitryPolukhin added subscribers: cfe-commits, andreybokhanko.

Recursive mangling should use all existing substitutions and newly created 
substitutions should be copied outer mangler.

This patch should fix PR30401 and related cases but unfortunately it is ABI 
breaking change for Clang backward compatibility (I hope it is rare case in 
practice). Perhaps this patch will have to be back ported to 3.9.

https://reviews.llvm.org/D24704

Files:
  lib/AST/ItaniumMangle.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp

Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- test/CodeGenCXX/mangle-abi-tag.cpp
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -203,3 +203,19 @@
 }
 // A18::operator A[abi:A][abi:B]() but GCC adds the same tags twice!
 // CHECK-DAG: define linkonce_odr {{.+}} @_ZN3A18cv1AB1AB1BEv(
+
+namespace N19 {
+  class A {};
+  class __attribute__((abi_tag("B"))) B {};
+  class D {};
+  class F {};
+
+  template
+  class C {};
+
+  B foo(A, D);
+}
+void f19_test(N19::C, N19::F, N19::D) {
+}
+// f19_test(N19::C, N19::F, N19::D)
+// CHECK-DAG: define void 
@_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -405,12 +405,14 @@
   CXXNameMangler(CXXNameMangler , raw_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
+SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
+Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler , llvm::raw_null_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
+SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
+Substitutions(Outer.Substitutions) {}
 
 #if MANGLE_CHECKER
   ~CXXNameMangler() {
@@ -458,6 +460,7 @@
   void addSubstitution(QualType T);
   void addSubstitution(TemplateName Template);
   void addSubstitution(uintptr_t Ptr);
+  void extendSubstitutions(const CXXNameMangler& Other);
 
   void mangleUnresolvedPrefix(NestedNameSpecifier *qualifier,
   bool recursive = false);
@@ -685,6 +688,10 @@
   // Output name with implicit tags and function encoding from temporary 
buffer.
   mangleNameWithAbiTags(FD, );
   Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
+
+  // Function encoding could create new substitutions so we have to add
+  // temp mangled substitutions to main mangler.
+  extendSubstitutions(FunctionEncodingMangler);
 }
 
 void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) {
@@ -4426,6 +4433,14 @@
   Substitutions[Ptr] = SeqID++;
 }
 
+void CXXNameMangler::extendSubstitutions(const CXXNameMangler& Other) {
+  assert(Other.SeqID >= SeqID && "Must be superset of substitutions!");
+  if (Other.SeqID > SeqID) {
+Substitutions = Other.Substitutions;
+SeqID = Other.SeqID;
+  }
+}
+
 CXXNameMangler::AbiTagList
 CXXNameMangler::makeFunctionReturnTypeTags(const FunctionDecl *FD) {
   // When derived abi tags are disabled there is no need to make any list.


Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- test/CodeGenCXX/mangle-abi-tag.cpp
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -203,3 +203,19 @@
 }
 // A18::operator A[abi:A][abi:B]() but GCC adds the same tags twice!
 // CHECK-DAG: define linkonce_odr {{.+}} @_ZN3A18cv1AB1AB1BEv(
+
+namespace N19 {
+  class A {};
+  class __attribute__((abi_tag("B"))) B {};
+  class D {};
+  class F {};
+
+  template
+  class C {};
+
+  B foo(A, D);
+}
+void f19_test(N19::C, N19::F, N19::D) {
+}
+// f19_test(N19::C, N19::F, N19::D)
+// CHECK-DAG: define void @_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -405,12 +405,14 @@
   CXXNameMangler(CXXNameMangler , raw_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
+SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
+Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler , llvm::raw_null_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
+SeqID(Outer.SeqID), 

[PATCH] D24703: [clang-format] BreakBeforeBinaryOperations and AlignAfterOpenBracket conflict, bug 30304

2016-09-18 Thread Daphne Pfister via cfe-commits
daphnediane created this revision.
daphnediane added a reviewer: djasper.
daphnediane added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Fix for the formatting options combination of BreakBeforeBinaryOperators: All, 
AlignAfterOpenBracket: AlwaysBreak not handling long templates correctly. This 
patch allows a break after an opening left parenthesis, TemplateOpener, or 
bracket when both options are enabled.

https://reviews.llvm.org/D24703

Files:
  lib/Format/TokenAnnotator.cpp

Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2513,9 +2513,11 @@
 return true;
   if ((Left.isBinaryOperator() || Left.is(TT_BinaryOperator)) &&
   !Left.isOneOf(tok::arrowstar, tok::lessless) &&
-  Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
-  (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
-   Left.getPrecedence() == prec::Assignment))
+  ((Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak &&
+Left.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square)) ||
+   (Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
+(Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
+ Left.getPrecedence() == prec::Assignment
 return true;
   return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
   tok::kw_class, tok::kw_struct, tok::comment) ||


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2513,9 +2513,11 @@
 return true;
   if ((Left.isBinaryOperator() || Left.is(TT_BinaryOperator)) &&
   !Left.isOneOf(tok::arrowstar, tok::lessless) &&
-  Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
-  (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
-   Left.getPrecedence() == prec::Assignment))
+  ((Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak &&
+Left.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square)) ||
+   (Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
+(Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
+ Left.getPrecedence() == prec::Assignment
 return true;
   return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
   tok::kw_class, tok::kw_struct, tok::comment) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits