Re: r349010 - Portable Python script across Python version

2018-12-12 Thread Roman Lebedev via cfe-commits
On Thu, Dec 13, 2018 at 10:48 AM Serge Guelton via cfe-commits
 wrote:
>
> Author: serge_sans_paille
> Date: Wed Dec 12 23:45:55 2018
> New Revision: 349010
>
> URL: http://llvm.org/viewvc/llvm-project?rev=349010=rev
> Log:
> Portable Python script across Python version
>
> SocketServer has been renamed socketserver in Python3.
>
> Differential Revision: https://reviews.llvm.org/D55258
>
> Modified:
> cfe/trunk/tools/scan-view/bin/scan-view
It would be useful to state *what* script is being update by the
particular commit,
since it's one-commit-per-script.

> Modified: cfe/trunk/tools/scan-view/bin/scan-view
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=349010=349009=349010=diff
> ==
> --- cfe/trunk/tools/scan-view/bin/scan-view (original)
> +++ cfe/trunk/tools/scan-view/bin/scan-view Wed Dec 12 23:45:55 2018
> @@ -80,9 +80,12 @@ def run(port, options, root):
>
>
>  def port_is_open(port):
> -import SocketServer
>  try:
> -t = SocketServer.TCPServer((kDefaultHost, port), None)
> +import socketserver
> +except ImportError:
> +import SocketServer as socketserver
> +try:
> +t = socketserver.TCPServer((kDefaultHost, port), None)
>  except:
>  return False
>  t.server_close()
Roman.

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


r349010 - Portable Python script across Python version

2018-12-12 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 12 23:45:55 2018
New Revision: 349010

URL: http://llvm.org/viewvc/llvm-project?rev=349010=rev
Log:
Portable Python script across Python version

SocketServer has been renamed socketserver in Python3.

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

Modified:
cfe/trunk/tools/scan-view/bin/scan-view

Modified: cfe/trunk/tools/scan-view/bin/scan-view
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=349010=349009=349010=diff
==
--- cfe/trunk/tools/scan-view/bin/scan-view (original)
+++ cfe/trunk/tools/scan-view/bin/scan-view Wed Dec 12 23:45:55 2018
@@ -80,9 +80,12 @@ def run(port, options, root):
 
 
 def port_is_open(port):
-import SocketServer
 try:
-t = SocketServer.TCPServer((kDefaultHost, port), None)
+import socketserver
+except ImportError:
+import SocketServer as socketserver
+try:
+t = socketserver.TCPServer((kDefaultHost, port), None)
 except:
 return False
 t.server_close()


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


r349009 - Portable Python script across Python version

2018-12-12 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 12 23:44:19 2018
New Revision: 349009

URL: http://llvm.org/viewvc/llvm-project?rev=349009=rev
Log:
Portable Python script across Python version

Queue module as been renamed into queue in Python3

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

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=349009=349008=349009=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Wed Dec 12 23:44:19 2018
@@ -58,7 +58,10 @@ import shutil
 import sys
 import threading
 import time
-import Queue
+try:
+import queue
+except ImportError:
+import Queue as queue
 
 ###
 # Helper functions.
@@ -742,7 +745,7 @@ def multiThreadedTestAll(Args, ProjectsT
 
 :return: whether tests have passed.
 """
-TasksQueue = Queue.Queue()
+TasksQueue = queue.Queue()
 
 for ProjArgs in ProjectsToTest:
 TasksQueue.put(ProjArgs)


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


[PATCH] D55202: Python 2/3 compat - Queue

2018-12-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC349009: Portable Python script across Python version 
(authored by serge_sans_paille, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

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

https://reviews.llvm.org/D55202

Files:
  utils/analyzer/SATestBuild.py


Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -58,7 +58,10 @@
 import sys
 import threading
 import time
-import Queue
+try:
+import queue
+except ImportError:
+import Queue as queue
 
 ###
 # Helper functions.
@@ -742,7 +745,7 @@
 
 :return: whether tests have passed.
 """
-TasksQueue = Queue.Queue()
+TasksQueue = queue.Queue()
 
 for ProjArgs in ProjectsToTest:
 TasksQueue.put(ProjArgs)


Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -58,7 +58,10 @@
 import sys
 import threading
 import time
-import Queue
+try:
+import queue
+except ImportError:
+import Queue as queue
 
 ###
 # Helper functions.
@@ -742,7 +745,7 @@
 
 :return: whether tests have passed.
 """
-TasksQueue = Queue.Queue()
+TasksQueue = queue.Queue()
 
 for ProjArgs in ProjectsToTest:
 TasksQueue.put(ProjArgs)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349008 - Portable Python script across Python version

2018-12-12 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 12 23:42:30 2018
New Revision: 349008

URL: http://llvm.org/viewvc/llvm-project?rev=349008=rev
Log:
Portable Python script across Python version

Use higher-level and more compatible threading module to start a new thread.

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

Modified:
cfe/trunk/tools/scan-view/bin/scan-view

Modified: cfe/trunk/tools/scan-view/bin/scan-view
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=349008=349007=349008=diff
==
--- cfe/trunk/tools/scan-view/bin/scan-view (original)
+++ cfe/trunk/tools/scan-view/bin/scan-view Wed Dec 12 23:42:30 2018
@@ -7,7 +7,7 @@ import sys
 import imp
 import os
 import posixpath
-import thread
+import threading
 import time
 import urllib
 import webbrowser
@@ -135,7 +135,7 @@ def main():
 # Kick off thread to wait for server and start web browser, if
 # requested.
 if args.startBrowser:
-t = thread.start_new_thread(start_browser, (port, args))
+threading.Thread(target=start_browser, args=(port, args)).start()
 
 run(port, args, args.root)
 


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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

2018-12-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/abseil/MakeUniqueCheck.h:29
+/// \endcode
+class MakeUniqueCheck : public modernize::MakeSmartPtrCheck {
+public:

Ah, so there is a check already, i missed that somehow.
If the `modernize::MakeSmartPtrCheck` is not sufficient to the needs, **it** 
needs to be extended.

You should be adding an **alias**, and this isn't the right way to do so.
E.g. see D53771 on how to do that.



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

https://reviews.llvm.org/D55044



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


[PATCH] D54429: [analyzer] Creating standard Sphinx documentation

2018-12-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I poked Devin offline. It kinda seems to both of us that Sphinx is great for 
documentation that is updated regularly, but our fancy front page should 
probably stay. Similarly to how we still have the llvm.org front page, despite 
all the documentation. It's kinda atmospheric and friendly and people like it 
and/or are used to it.

Pretty much all other pages will look great in Sphinx. Everything under "User 
Manual" would indeed look like a manual, everything under "Development" would 
look more technical and trustworthy, the "Filing Bugs" page is pretty weird and 
unfriendly and should probably be reworked or removed anyway, the 
"Obtaining..." page is pretty much outdated and contains no useful info apart 
from "If you want the latest Analyzer, compile Clang from source and add it to 
your `PATH`". I'm a bit unsure about the FAQ page, it kinda feels like it 
should be as close to the front page and visible on the front page as possible, 
in order to inspire people to actually read it. We should give it more 
visibility, not hide it within the manual.


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

https://reviews.llvm.org/D54429



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


[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p

2018-12-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

That example cannot be expected to ever evaluate the expression as "1" -- it 
doesn't in GCC, nor should it in Clang. An asm constraint of "n" or "i" (but 
not, e.g., "nr") must require a constant expression, and evaluating the 
argument as a constant expression necessarily means always evaluating it to -1.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54355



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


[PATCH] D55616: Emit ASM input in a constant context

2018-12-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

This seems like a good start, but not complete.

"n" and "i" both should require that their argument is a constant expression. 
For "n", it actually must be an immediate constant integer, so 
setRequiresImmediate() should be used there. For "i", you may use an lvalue 
constant as well. The way we seem to indicate that, today, is with `if 
(!Info.allowsRegister() && !Info.allowsMemory())`. However the code in that 
block does not today *require* that the evaluation as a constant succeed...and 
it should.

It should also only require that the result is an integer when 
`requiresImmediateConstant()`.

Additionally, the Sema code needs to have the same conditions as the CodeGen 
code for when a constant expression is required, but it doesn't. (before or 
after your change).


Repository:
  rC Clang

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

https://reviews.llvm.org/D55616



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


[PATCH] D55543: [CodeGen] Fix assertion on throwing object with inlined inherited constructor and non-trivial destructor.

2018-12-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D55543#1328034 , @smeenai wrote:

> I'd tried this exact same patch back in https://reviews.llvm.org/D44619, but 
> I was running into a bunch of check-clang failures with it, and I was never 
> able to figure them out. It looks like it works now though, so I'm glad :) 
> Richard's comment from that diff might still be relevant:
>
> > Please add a test to ensure that we still destroy function parameters in 
> > the right order and at the right times (for both the exceptional and 
> > non-exceptional cleanup cases).
>
> This will also resolve https://bugs.llvm.org/show_bug.cgi?id=36748


Thanks, Shoaib, for extra information. Maybe I don't see any failing tests 
because I'm not testing on Windows. At least I want to try a sample you've 
provided in https://reviews.llvm.org/D44619#1056458


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

https://reviews.llvm.org/D55543



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


[PATCH] D55543: [CodeGen] Fix assertion on throwing object with inlined inherited constructor and non-trivial destructor.

2018-12-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D55543#1328025 , @rjmccall wrote:

> Nice catch.  This also fixes problems where there might be cleanups entered 
> by `EmitParmDecl`, e.g. in ObjC++ with a parameter of type `struct A { 
> __strong id x; }`; could you please add a test for that and verify that the 
> parameter is destroyed at an appropriate point in the inlined call?


Aha, I see we have at least `EHStack.pushCleanup` in 
`EmitParmDecl`. Will make sure to add a test that executes this code path.


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

https://reviews.llvm.org/D55543



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


[PATCH] D55546: [clang] Add AST matcher for block expressions 

2018-12-12 Thread Stephane Moore via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349004: [clang] Add AST matcher for block expressions  
(authored by stephanemoore, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55546?vs=177654=177998#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55546

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -139,6 +139,7 @@
   REGISTER_MATCHER(binaryConditionalOperator);
   REGISTER_MATCHER(binaryOperator);
   REGISTER_MATCHER(blockDecl);
+  REGISTER_MATCHER(blockExpr);
   REGISTER_MATCHER(blockPointerType);
   REGISTER_MATCHER(booleanType);
   REGISTER_MATCHER(breakStmt);
Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -688,6 +688,7 @@
 const internal::VariadicDynCastAllOfMatcher expr;
 const internal::VariadicDynCastAllOfMatcher declRefExpr;
 const internal::VariadicDynCastAllOfMatcher 
objcIvarRefExpr;
+const internal::VariadicDynCastAllOfMatcher blockExpr;
 const internal::VariadicDynCastAllOfMatcher ifStmt;
 const internal::VariadicDynCastAllOfMatcher forStmt;
 const internal::VariadicDynCastAllOfMatcher
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1386,6 +1386,10 @@
 hasDeclaration(namedDecl(hasName("y"));
 }
 
+TEST(BlockExprMatcher, BlockExpr) {
+  EXPECT_TRUE(matchesObjC("void f() { ^{}(); }", blockExpr()));
+}
+
 TEST(StatementCountIs, FindsNoStatementsInAnEmptyCompoundStatement) {
   EXPECT_TRUE(matches("void f() { }",
   compoundStmt(statementCountIs(0;
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -707,6 +707,14 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtblockExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1BlockExpr.html;>BlockExpr...
+MAtches a reference to a 
block.
+
+Example: matches "^{}":
+  void f() { ^{}(); }
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtbreakStmtMatcherhttps://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html;>BreakStmt...
 Matches break statements.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -1798,6 +1798,14 @@
 extern const internal::VariadicDynCastAllOfMatcher
 objcIvarRefExpr;
 
+/// Matches a reference to a block.
+///
+/// Example: matches "^{}":
+/// \code
+///   void f() { ^{}(); }
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher blockExpr;
+
 /// Matches if statements.
 ///
 /// Example matches 'if (x) {}'


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -139,6 +139,7 @@
   REGISTER_MATCHER(binaryConditionalOperator);
   REGISTER_MATCHER(binaryOperator);
   REGISTER_MATCHER(blockDecl);
+  REGISTER_MATCHER(blockExpr);
   REGISTER_MATCHER(blockPointerType);
   REGISTER_MATCHER(booleanType);
   REGISTER_MATCHER(breakStmt);
Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -688,6 +688,7 @@
 const internal::VariadicDynCastAllOfMatcher expr;
 const internal::VariadicDynCastAllOfMatcher declRefExpr;
 const internal::VariadicDynCastAllOfMatcher objcIvarRefExpr;
+const internal::VariadicDynCastAllOfMatcher blockExpr;
 const internal::VariadicDynCastAllOfMatcher ifStmt;
 const internal::VariadicDynCastAllOfMatcher forStmt;
 const internal::VariadicDynCastAllOfMatcher
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===

[PATCH] D55544: Warning: objc-encodings-larger-than=

2018-12-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In D55544#1326606 , @stephanemoore 
wrote:

> FYI:
>  I have a clang-tidy check almost ready for review that aims to flag large 
> Objective-C type encodings.


https://reviews.llvm.org/D55640


Repository:
  rC Clang

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

https://reviews.llvm.org/D55544



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


[PATCH] D55640: [clang-tidy] Implement a check for large Objective-C type encodings 

2018-12-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore created this revision.
Herald added subscribers: cfe-commits, jfb, xazax.hun, mgorny.

Objective-C type encodings are normally pretty small but they it is
pretty easy for them to bloat to undesirable levels. Bloated Objective-C
type encodings are particularly common for Objective-C methods with
templated C++ types in their interface in Objective-C++. For example,
in Objective-C type encodings `std::string` expands to 277 bytes and
`std::map` expands to 1219 bytes. The bloat
isn't particularly important for larger binaries but SDKs sometimes
optimize their binary size to ease adoption. This check aims to provide
some level of visibility into the size of generated Objective-C type
encodings so that developers can address them if they want.

Related article:
https://medium.com/@dmaclach/objective-c-encoding-and-you-866624cc02de

Test Notes:
Verified clang-tidy tests pass successfully.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55640

Files:
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  clang-tidy/objc/TypeEncodingSizeCheck.cpp
  clang-tidy/objc/TypeEncodingSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-type-encoding-size.rst
  test/clang-tidy/objc-type-encoding-size.m

Index: test/clang-tidy/objc-type-encoding-size.m
===
--- /dev/null
+++ test/clang-tidy/objc-type-encoding-size.m
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s objc-type-encoding-size %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: objc-type-encoding-size.Threshold, value: 15}]}' \
+// RUN: -- -fblocks
+
+typedef struct {
+  int a1;
+  int a2;
+  int a3;
+  int a4;
+  int a5;
+  int a6;
+  int a7;
+  int a8;
+  int a9;
+  int a10;
+  int a11;
+  int a12;
+} SixteenCharStruct;
+
+typedef struct {
+  int a1;
+} FiveCharStruct;
+
+typedef void (^BlockType)(SixteenCharStruct);
+
+@interface Foo {
+  SixteenCharStruct _someStruct;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: Objective-C type encoding for
+  // '_someStruct' exceeds 15 characters [objc-type-encoding-size]
+
+  int _anInteger;
+}
+
+@property(nonatomic) SixteenCharStruct anotherStruct;
+// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: Objective-C type encoding for
+// 'anotherStruct' exceeds 15 characters [objc-type-encoding-size]
+// CHECK-MESSAGES: :[[@LINE-3]]:40: warning: Objective-C type encoding for
+// 'setAnotherStruct:' exceeds 15 characters [objc-type-encoding-size]
+
+@property(nonatomic, setter=setAsparagus:) FiveCharStruct bananas;
+// CHECK-MESSAGES: :[[@LINE-1]]:59: warning: Objective-C type encoding for
+// 'bananas' exceeds 15 characters [objc-type-encoding-size]
+
+@end
+
+@implementation Foo
+
+- (void)bar:(SixteenCharStruct)a {
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: Objective-C type encoding for 'bar:'
+// exceeds 15 characters [objc-type-encoding-size]
+}
+
+- (int)doThing {
+  int (^block)(SixteenCharStruct) = ^(SixteenCharStruct a) {
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: Objective-C type encoding for
+// block expression exceeds 15 characters [objc-type-encoding-size]
+return a.a4 + 5;
+  };
+
+  return block(_someStruct);
+}
+
+- (const char *)str {
+  // We should not flag explicit encoding statements.
+  return @encode(SixteenCharStruct);
+}
+
+@end
Index: docs/clang-tidy/checks/objc-type-encoding-size.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-type-encoding-size.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-type-encoding-size
+
+objc-type-encoding-size
+===
+
+Finds Objective-C type encodings that exceed a configured threshold.
+
+Options
+---
+
+.. option:: Threshold
+
+   Flag Objective-C type encodings that exceed this number of bytes.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -217,6 +217,7 @@
objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
+   objc-type-encoding-size
performance-faster-string-find
performance-for-range-copy
performance-implicit-conversion-in-loop
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -167,6 +167,11 @@
   Detects usage of the deprecated member types of ``std::ios_base`` and replaces
   those that have a non-deprecated equivalent.
 
+- New :doc:`objc-type-encoding-size
+  ` check.
+
+  Detects Objective-C type encodings that exceed a configured threshold.
+
 - New :doc:`readability-isolate-decl
   ` check.
 
Index: clang-tidy/objc/TypeEncodingSizeCheck.h
===
--- /dev/null
+++ clang-tidy/objc/TypeEncodingSizeCheck.h
@@ -0,0 +1,34 @@
+//===--- TypeEncodingSizeCheck.h - 

[PATCH] D54681: [Driver] Avoid including -lm on the link line with -nostdlib++

2018-12-12 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D54681#1329240 , @thakis wrote:

> -lm is kind of the reason -nostdlib++ exists at all -- if you don't want 
> _any_ stdlibs, you can just -nostdlib, no?


We still want standard libraries like `-lc` and compiler builtins, `-nostdlib` 
would remove those. Keeping `-lm` around is assuming that user is going to link 
against C++ library that needs `-lm` which is a lot of assumptions that IMHO 
driver shouldn't be doing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54681



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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

2018-12-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked an inline comment as done.
EricWF added a comment.

I'm not sure how you're building this, but it doesn't link for me. We need to 
add a dependency on `clangTidyModernizeModule` since we're deriving from its 
`MakeSmartPtrCheck`.




Comment at: clang-tidy/abseil/MakeUniqueCheck.cpp:28
+  recordType(hasDeclaration(classTemplateSpecializationDecl(
+  hasName("::std::unique_ptr"), templateArgumentCountIs(2),
+  hasTemplateArgument(

Eugene.Zelenko wrote:
> EricWF wrote:
> > Does this catch `std::__1::unique_ptr`, where `__1` is an inline namespace? 
> > (Either way, we should add a test)
> > 
> > Maybe it's better to first filter declarations using an `isInStdNamespace` 
> > matcher and then check for the name `unique_ptr`.
> Tests for other checks don't contain libc++ specific, so if problems existed 
> they were resolved long time ago.
Using versioning namespaces is not specific to libc++. But, as you suggested, 
this case appears to work.

I also see that this is just a copy of `modernize/MakeUniqueCheck.cpp`. Can we 
find a way to share the matcher between these two implementations?


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

https://reviews.llvm.org/D55044



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


[PATCH] D54681: [Driver] Avoid including -lm on the link line with -nostdlib++

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

-lm is kind of the reason -nostdlib++ exists at all -- if you don't want _any_ 
stdlibs, you can just -nostdlib, no?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54681



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


[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check

2018-12-12 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked 2 inline comments as done.
hwright added inline comments.



Comment at: test/clang-tidy/abseil-duration-subtraction.cpp:12
+  // CHECK-FIXES: absl::ToDoubleSeconds(d - absl::Seconds(1))
+  x = absl::ToDoubleSeconds(d) - absl::ToDoubleSeconds(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the 
duration domain [abseil-duration-subtraction]

JonasToth wrote:
> hwright wrote:
> > JonasToth wrote:
> > > hwright wrote:
> > > > JonasToth wrote:
> > > > > From this example starting:
> > > > > 
> > > > > - The RHS should be a nested expression with function calls, as the 
> > > > > RHS is transformed to create the adversary example i mean in the 
> > > > > transformation function above.
> > > > > 
> > > > > ```
> > > > > absl::ToDoubleSeconds(d) - 
> > > > > absl::ToDoubleSeconds(absl::ToDoubleSeconds(d) - 
> > > > > absl::ToDoubleSeconds(d1));
> > > > > ```
> > > > > I think you need the proper conversion function, as the result of the 
> > > > > expression is `double` and you need a `Duration`, right?
> > > > > 
> > > > > But in principle starting from this idea the transformation might 
> > > > > break.
> > > > I think there may be some confusion here (and that's entirely my fault. 
> > > > :) )
> > > > 
> > > > We should never get this expression as input to the check, since it 
> > > > doesn't compile (as you point out):
> > > > ```
> > > > absl::ToDoubleSeconds(d) - 
> > > > absl::ToDoubleSeconds(absl::ToDoubleSeconds(d) - 
> > > > absl::ToDoubleSeconds(d1));
> > > > ```
> > > > 
> > > > Since `absl::ToDoubleSeconds` requires that its argument is an 
> > > > `absl::Duration`, but the expression `absl::ToDoubleSeconds(d) - 
> > > > absl::ToDoubleSeconds(d1)` results in a `double`, we can't get this as 
> > > > input.
> > > > 
> > > > There may be other expressions which could be input, but in practice 
> > > > they don't really happen.  I've added a contrived example to the tests, 
> > > > but at some point the tests get too complex and confuse the fix 
> > > > matching infrastructure.
> > > Your last sentence is the thing ;) Murphies Law will hit this check, too. 
> > > In my opinion wrong transformations are very unfortunate and should be 
> > > avoided if possible (in this case possible).
> > > You can simply require that the expression of type double does not 
> > > contain any duration subtraction calls.
> > > 
> > > This is even possible in the matcher-part of the check.
> > I've written a test (which the testing infrastructure fails to handle well, 
> > so I haven't included it in the diff), and it produces these results:
> > 
> > ```
> >//
> >//
> > -  x = absl::ToDoubleSeconds(d) - (absl::ToDoubleSeconds(d1) - 5);
> > +  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1) - 
> > 5));
> >//
> >//
> > -  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1) - 
> > 5));
> > +  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1 - 
> > absl::Seconds(5;
> > ```
> > 
> > Those results are correct.  There is a cosmetic issue of round tripping 
> > through the `double` conversion in the 
> > `absl::Seconds(absl::ToDoubleSeconds(...))` phrase, but untangling that is 
> > 1) difficult (because of order of operations issues) and thus; 2) probably 
> > the subject of a separate check.
> > 
> > This is still such a rare case (as in, we've not encountered it in Google's 
> > codebase), that I'm not really concerned.  But if it's worth it to 
> > explicitly exclude it from the traversal matcher, I can do that.
> Can you say what the direct issue is? I would bet its the overlapping?
> A note in the documentation would be ok from my side. When the conflicting 
> transformations are tried to be applied clang-tidy does not crash but print a 
> nice diagnostic and continue its life?
Another example I've verified:
```
-  x = absl::ToDoubleSeconds(d) - 
absl::ToDoubleSeconds(absl::Seconds(absl::ToDoubleSeconds(d1) - 5));
+  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1) - 5));
```

This a nested case, and while `clang-tidy` finds both of them, it only applies 
the outer most one (presumably the one it finds first in its AST traversal):
```
note: this fix will not be applied because it overlaps with another fix
```

The new code can then be checked again to fix the internal instance.

It's not possible to express this case in a test because testing infrastructure 
uses regular expressions, and the repeated strings in the test expectation 
cause it to get a bit confused.

Given all the of the above, I'm unsure what content would go in the 
documentation which is specific to this check.


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

https://reviews.llvm.org/D55245



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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

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



Comment at: clang-tidy/abseil/MakeUniqueCheck.cpp:28
+  recordType(hasDeclaration(classTemplateSpecializationDecl(
+  hasName("::std::unique_ptr"), templateArgumentCountIs(2),
+  hasTemplateArgument(

EricWF wrote:
> Does this catch `std::__1::unique_ptr`, where `__1` is an inline namespace? 
> (Either way, we should add a test)
> 
> Maybe it's better to first filter declarations using an `isInStdNamespace` 
> matcher and then check for the name `unique_ptr`.
Tests for other checks don't contain libc++ specific, so if problems existed 
they were resolved long time ago.


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

https://reviews.llvm.org/D55044



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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

2018-12-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: clang-tidy/abseil/MakeUniqueCheck.cpp:28
+  recordType(hasDeclaration(classTemplateSpecializationDecl(
+  hasName("::std::unique_ptr"), templateArgumentCountIs(2),
+  hasTemplateArgument(

Does this catch `std::__1::unique_ptr`, where `__1` is an inline namespace? 
(Either way, we should add a test)

Maybe it's better to first filter declarations using an `isInStdNamespace` 
matcher and then check for the name `unique_ptr`.


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

https://reviews.llvm.org/D55044



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


r349001 - Remove unused Args parameter from EmitFunctionBody, NFC

2018-12-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Dec 12 17:33:20 2018
New Revision: 349001

URL: http://llvm.org/viewvc/llvm-project?rev=349001=rev
Log:
Remove unused Args parameter from EmitFunctionBody, NFC

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=349001=349000=349001=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Dec 12 17:33:20 2018
@@ -1202,8 +1202,7 @@ void CodeGenFunction::StartFunction(Glob
   LargestVectorWidth = VecWidth->getVectorWidth();
 }
 
-void CodeGenFunction::EmitFunctionBody(FunctionArgList ,
-   const Stmt *Body) {
+void CodeGenFunction::EmitFunctionBody(const Stmt *Body) {
   incrementProfileCounter(Body);
   if (const CompoundStmt *S = dyn_cast(Body))
 EmitCompoundStmtWithoutScope(*S);
@@ -1371,7 +1370,7 @@ void CodeGenFunction::GenerateCode(Globa
 // copy-constructors.
 emitImplicitAssignmentOperatorBody(Args);
   } else if (Body) {
-EmitFunctionBody(Args, Body);
+EmitFunctionBody(Body);
   } else
 llvm_unreachable("no definition for emitted function");
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=349001=349000=349001=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Dec 12 17:33:20 2018
@@ -1827,7 +1827,7 @@ public:
   void EmitConstructorBody(FunctionArgList );
   void EmitDestructorBody(FunctionArgList );
   void emitImplicitAssignmentOperatorBody(FunctionArgList );
-  void EmitFunctionBody(FunctionArgList , const Stmt *Body);
+  void EmitFunctionBody(const Stmt *Body);
   void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
 
   void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,


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


[PATCH] D54921: [analyzer] Remove memoization from RunLoopAutoreleaseLeakChecker

2018-12-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Added a test in rC349000 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D54921



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


r349000 - [analyzer] RunLoopAutoreleaseLeakChecker: Come up with a test for r348822.

2018-12-12 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Dec 12 17:30:47 2018
New Revision: 349000

URL: http://llvm.org/viewvc/llvm-project?rev=349000=rev
Log:
[analyzer] RunLoopAutoreleaseLeakChecker: Come up with a test for r348822.

Statement memoization was removed in r348822 because it was noticed to cause
memory corruption. This was happening because a reference to an object
in a DenseMap was used after being invalidated by inserting a new key
into the map.

This test case crashes reliably under ASan (i.e., when Clang is built with
-DLLVM_USE_SANITIZER="Address") on at least some machines before r348822
and doesn't crash after it.

Modified:
cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m

Modified: cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m?rev=349000=348999=349000=diff
==
--- cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m (original)
+++ cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Wed Dec 12 
17:30:47 2018
@@ -1,9 +1,15 @@
-// UNSUPPORTED: system-windows
-// RUN: %clang_analyze_cc1 -fobjc-arc 
-analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple 
x86_64-darwin -verify
-// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP1=1 -fobjc-arc 
-analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple 
x86_64-darwin -verify
-// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP2=1 -fobjc-arc 
-analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple 
x86_64-darwin -verify
-// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP3=1 -fobjc-arc 
-analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple 
x86_64-darwin -verify
-// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP4=1 -fobjc-arc 
-analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple 
x86_64-darwin -verify
+// RUN: %clang_analyze_cc1 -fobjc-arc -triple x86_64-darwin\
+// RUN:   -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak -verify %s
+// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP1=1 -fobjc-arc -triple x86_64-darwin\
+// RUN:   -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak -verify %s
+// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP2=1 -fobjc-arc -triple x86_64-darwin\
+// RUN:   -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak -verify %s
+// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP3=1 -fobjc-arc -triple x86_64-darwin\
+// RUN:   -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak -verify %s
+// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP4=1 -fobjc-arc -triple x86_64-darwin\
+// RUN:   -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak -verify %s
+// RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP5=1 -fobjc-arc -triple x86_64-darwin\
+// RUN:   -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak -verify %s
 
 #include "../Inputs/system-header-simulator-for-objc-dealloc.h"
 
@@ -122,3 +128,34 @@ int main() {
 return 0;
 }
 #endif
+
+#ifdef AP5
+@class NSString;
+@class NSConstantString;
+#define CF_BRIDGED_TYPE(T)__attribute__((objc_bridge(T)))
+typedef const CF_BRIDGED_TYPE(id) void * CFTypeRef;
+typedef const struct CF_BRIDGED_TYPE(NSString) __CFString * CFStringRef;
+
+typedef enum { WARNING } Level;
+id do_log(Level, const char *);
+#define log(level, msg) __extension__({ (do_log(level, msg)); })
+
+@interface I
+- foo;
+@end
+
+CFStringRef processString(const __NSConstantString *, void *);
+
+#define CFSTR __builtin___CFStringMakeConstantString
+
+int main() {
+  I *i;
+  @autoreleasepool {
+NSString *s1 = (__bridge_transfer NSString *)processString(0, 0);
+NSString *s2 = (__bridge_transfer NSString *)processString((CFSTR("")), 
((void *)0));
+log(WARNING, "Hello world!");
+  }
+  [[NSRunLoop mainRunLoop] run];
+  [i foo]; // no-crash // expected-warning{{Temporary objects allocated in the 
autorelease pool of last resort followed by the launch of main run loop may 
never get released; consider moving them to a separate autorelease pool}}
+}
+#endif


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


[PATCH] D50563: Fixed frontend clang tests in windows read-only container

2018-12-12 Thread Justice Adams via Phabricator via cfe-commits
justice_adams added a comment.

@cfe-commits Re-pinging this group to request a review on this patch


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

https://reviews.llvm.org/D50563



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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

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



Comment at: docs/ReleaseNotes.rst:93
+
+  Checks for instances of initializing a `unique_ptr` with a direct call to
+  `new` and suggests using `absl::make_unique` instead.

Please use double `, not single ones to hightlight language constructs. Same in 
documentation.



Comment at: docs/clang-tidy/checks/abseil-make-unique.rst:10
+Replaces initialization of smart pointers:
+\code
+  std::unique_ptr ptr = std::unique_ptr(new int(1));

Please use .. code-block:: c++. See other checks documentation as example.



Comment at: docs/clang-tidy/checks/abseil-make-unique.rst:19
+
+per the Abseil tips and guidelines at https://abseil.io/tips/126.

Please use hyperlink like:

The `Abseil Style Guide `_ discusses this issue in 
more detail.


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

https://reviews.llvm.org/D55044



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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

2018-12-12 Thread Andy Zhang via Phabricator via cfe-commits
axzhang updated this revision to Diff 177972.
axzhang added a comment.

Per the suggestions of reviewers, change the check so that it uses 
modernize-make-smart-pointer instead.


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

https://reviews.llvm.org/D55044

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/MakeUniqueCheck.cpp
  clang-tidy/abseil/MakeUniqueCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-make-unique.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-make-unique.cpp

Index: test/clang-tidy/abseil-make-unique.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-make-unique.cpp
@@ -0,0 +1,130 @@
+// RUN: %check_clang_tidy %s abseil-make-unique %t -- -- -std=c++11 \
+
+// CHECK-FIXES: #include 
+
+namespace std {
+
+template 
+class default_delete {};
+
+template >
+class unique_ptr {
+public:
+  unique_ptr() {}
+  unique_ptr(type *ptr) {}
+  unique_ptr(const unique_ptr ) = delete;
+  unique_ptr(unique_ptr &) {}
+  ~unique_ptr() {}
+  type *() { return *ptr; }
+  type *operator->() { return ptr; }
+  type *release() { return ptr; }
+  void reset() {}
+  void reset(type *pt) {}
+  void reset(type pt) {}
+  unique_ptr =(unique_ptr &&) { return *this; }
+  template 
+  unique_ptr =(unique_ptr &&) { return *this; }
+
+private:
+  type *ptr;
+};
+
+}  // namespace std
+
+class A {
+ int x;
+ int y;
+
+ public:
+   A(int _x, int _y): x(_x), y(_y) {}
+};
+
+struct Base {
+  Base();
+};
+
+struct Derived : public Base {
+  Derived();
+};
+
+int* returnPointer();
+void expectPointer(std::unique_ptr p);
+
+std::unique_ptr makeAndReturnPointer() {
+  // Make smart pointer in return statement
+  return std::unique_ptr(new int(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: return absl::make_unique(0);
+}
+
+void Positives() {
+  std::unique_ptr P1 = std::unique_ptr(new int(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: std::unique_ptr P1 = absl::make_unique(1);
+
+  P1.reset(new int(2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: P1 = absl::make_unique(2);
+
+  // Non-primitive paramter
+  std::unique_ptr P2 = std::unique_ptr(new A(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: std::unique_ptr P2 = absl::make_unique(1, 2);
+
+  P2.reset(new A(3, 4));
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: P2 = absl::make_unique(3, 4);
+
+  // No arguments to new expression
+  std::unique_ptr P3 = std::unique_ptr(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: std::unique_ptr P3 = absl::make_unique();
+
+  P3.reset(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: P3 = absl::make_unique();
+
+  // Nested parentheses
+  std::unique_ptr P4 = std::unique_ptr((new int(3)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: std::unique_ptr P4 = absl::make_unique(3);
+
+  P4 = std::unique_ptr(((new int(4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: P4 = absl::make_unique(4);
+
+  P4.reset((new int(5)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: P4 = absl::make_unique(5);
+
+  // With auto
+  auto P5 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: auto P5 = absl::make_unique();
+
+  {
+// No std
+using namespace std;
+unique_ptr Q = unique_ptr(new int());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use absl::make_unique instead [abseil-make-unique]
+// CHECK-FIXES: unique_ptr Q = absl::make_unique();
+
+Q = unique_ptr(new int());
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use absl::make_unique instead [abseil-make-unique]
+// CHECK-FIXES: Q = absl::make_unique();
+  }
+
+  // Create the unique_ptr as a parameter to a function
+  expectPointer(std::unique_ptr(new int()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use absl::make_unique instead [abseil-make-unique]
+  // CHECK-FIXES: expectPointer(absl::make_unique());
+}
+
+void Negatives() {
+  // Only warn if explicitly allocating a new object
+  std::unique_ptr R = std::unique_ptr(returnPointer());
+  R.reset(returnPointer());
+
+  // Only replace if the template type is same as new type
+  auto Pderived = std::unique_ptr(new Derived());

[PATCH] D55628: Add support for "labels" on push/pop directives in #pragma clang attribute

2018-12-12 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: arphaman, aaron.ballman.
Herald added subscribers: dexonsmith, jkorous.

One problem with defining macros that expand to _Pragma("clang attribute")` is 
that they don't nest very well:

  // In some header...
  #define ASSUME_X_BEGIN _Pragma ("clang attribute push(__attribute__((x)), 
apply_to=variable)")
  #define ASSUME_X_END _Pragma ("clang attribute pop")
  
  #define ASSUME_Y_BEGIN _Pragma("clang attribute push(__attribute__((y)), 
apply_to=variable)")
  #define ASSUME_Y_END _Pragma("clang attribute pop")
  
  // in some source file...
  
  ASSUME_X_BEGIN
  // lots of code
  ASSUME_Y_BEGIN
  // some more code
  ASSUME_X_END // oops! Popped Y, but meant to pop X.
  // some other code
  ASSUME_Y_END // ditto

This patch adds a way to fix this by adding labels to push/pop directives. A 
`clang attribute pop`s with a label will only pop a `push`ed group with that 
same label. Macro authors can then add a unique label to their BEGIN/END 
functions, which would cause the code above to work fine.

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D55628

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/Sema/pragma-attribute-label.c

Index: clang/test/Sema/pragma-attribute-label.c
===
--- /dev/null
+++ clang/test/Sema/pragma-attribute-label.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#pragma clang attribute push MY_LABEL (__attribute__((annotate)), apply_to=function) // expected-error 2 {{'annotate' attribute}}
+
+int some_func(); // expected-note{{when applied to this declaration}}
+
+#pragma clang attribute pop // expected-error{{'#pragma clang attribute pop' with no matching '#pragma clang attribute push'}}
+#pragma clang attribute pop NOT_MY_LABEL // expected-error{{'#pragma clang attribute pop NOT_MY_LABEL' with no matching '#pragma clang attribute push NOT_MY_LABEL'}}
+
+#pragma clang attribute push MY_OTHER_LABEL (__attribute__((annotate)), apply_to=function) // expected-error 2 {{'annotate' attribute}}
+
+int some_other_func(); // expected-note 2 {{when applied to this declaration}}
+
+// Out of order!
+#pragma clang attribute pop MY_LABEL
+
+int some_other_other_func(); // expected-note 1 {{when applied to this declaration}}
+
+#pragma clang attribute pop MY_OTHER_LABEL
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -631,28 +631,45 @@
   {PragmaLoc, , std::move(SubjectMatchRules), /*IsUsed=*/false});
 }
 
-void Sema::ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc) {
+void Sema::ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc,
+ IdentifierInfo *PushLabel) {
   PragmaAttributeStack.emplace_back();
   PragmaAttributeStack.back().Loc = PragmaLoc;
+  PragmaAttributeStack.back().Label = PushLabel;
 }
 
-void Sema::ActOnPragmaAttributePop(SourceLocation PragmaLoc) {
+void Sema::ActOnPragmaAttributePop(SourceLocation PragmaLoc,
+   IdentifierInfo *PushLabel) {
   if (PragmaAttributeStack.empty()) {
 Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch);
 return;
   }
 
-  for (const PragmaAttributeEntry  :
-   PragmaAttributeStack.back().Entries) {
-if (!Entry.IsUsed) {
-  assert(Entry.Attribute && "Expected an attribute");
-  Diag(Entry.Attribute->getLoc(), diag::warn_pragma_attribute_unused)
-  << Entry.Attribute->getName();
-  Diag(PragmaLoc, diag::note_pragma_attribute_region_ends_here);
+  // Dig back through the stack trying to find the group that corrisponds to
+  // PushLabel. Note that this works fine if no label is present, think of
+  // unlabeled push/pops as having an implicit "nullptr" label.
+  for (size_t Index = PragmaAttributeStack.size(); Index;) {
+--Index;
+if (PragmaAttributeStack[Index].Label == PushLabel) {
+  for (const PragmaAttributeEntry  :
+   PragmaAttributeStack[Index].Entries) {
+if (!Entry.IsUsed) {
+  assert(Entry.Attribute && "Expected an attribute");
+  Diag(Entry.Attribute->getLoc(), diag::warn_pragma_attribute_unused)
+  << Entry.Attribute->getName();
+  Diag(PragmaLoc, diag::note_pragma_attribute_region_ends_here);
+}
+  }
+  PragmaAttributeStack.erase(PragmaAttributeStack.begin() + Index);
+  return;
 }
   }
 
-  PragmaAttributeStack.pop_back();
+  if (PushLabel)
+Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch_label)
+<< PushLabel->getName();
+  else
+Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch);
 }
 
 void Sema::AddPragmaAttributes(Scope *S, Decl *D) 

r348991 - Emit a proper diagnostic when attempting to forward inalloca arguments

2018-12-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Dec 12 15:46:06 2018
New Revision: 348991

URL: http://llvm.org/viewvc/llvm-project?rev=348991=rev
Log:
Emit a proper diagnostic when attempting to forward inalloca arguments

The previous assertion was relatively easy to trigger, and likely will
be easy to trigger going forward. EmitDelegateCallArg is relatively
popular.

This cleanly diagnoses PR28299 while I work on a proper solution.

Added:
cfe/trunk/test/CodeGenCXX/inalloca-lambda.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=348991=348990=348991=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Dec 12 15:46:06 2018
@@ -3076,8 +3076,9 @@ void CodeGenFunction::EmitDelegateCallAr
 
   QualType type = param->getType();
 
-  assert(!isInAllocaArgument(CGM.getCXXABI(), type) &&
- "cannot emit delegate call arguments for inalloca arguments!");
+  if (isInAllocaArgument(CGM.getCXXABI(), type)) {
+CGM.ErrorUnsupported(param, "forwarded non-trivially copyable parameter");
+  }
 
   // GetAddrOfLocalVar returns a pointer-to-pointer for references,
   // but the argument needs to be the original pointer.

Added: cfe/trunk/test/CodeGenCXX/inalloca-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/inalloca-lambda.cpp?rev=348991=auto
==
--- cfe/trunk/test/CodeGenCXX/inalloca-lambda.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/inalloca-lambda.cpp Wed Dec 12 15:46:06 2018
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -triple i686-windows-msvc -emit-llvm -o /dev/null %s  
2>&1 | FileCheck %s
+
+// PR28299
+// CHECK: error: cannot compile this forwarded non-trivially copyable 
parameter yet
+
+class A {
+  A(const A &);
+};
+typedef void (*fptr_t)(A);
+fptr_t fn1() { return [](A) {}; }
+


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


[PATCH] D55413: [ExprConstant] Handle compound assignment when LHS has integral type and RHS has floating point type

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



Comment at: clang/lib/AST/ExprConstant.cpp:3441
+  Value);
+}
 APSInt LHS = HandleIntToIntCast(Info, E, PromotedLHSType,

cpplearner wrote:
> rjmccall wrote:
> > Can we more fundamentally restructure this entire handler so that, if the 
> > compound assignment's computation result type is an arithmetic type, we 
> > just promote both operands to that type, do the arithmetic there, and then 
> > coerce back down?  This is C++, so the LHS type imposes almost no 
> > restrictions on the RHS type; also, this is Clang, where we support way too 
> > many arithmetic types for our own good.
> It seems the conditional statement is unavoidable, because `APSInt` and 
> `APFloat` can't be handled at the same time (i.e. you need to choose among 
> `Handle{Int,Float}To{Int,Float}Cast`, and between 
> `handleIntIntBinOp`/`handleFloatFloatBinOp`). Maybe it's possible to add a 
> layer that can accept both `APSInt` and `APFloat`, but it seems like an 
> overkill if it's only used in the compound assignment case.
But we can have `HandleValueTo{Int,Float}Cast` functions that start with an 
arbitrary `APValue` and do the switch on that type, and we can have a 
`HandleValueValueBinOp` function that asserts that its operands have the same 
type and does the switch, and those two together should be good enough for what 
we need here.



Comment at: clang/lib/AST/ExprConstant.cpp:3453
   Value) &&
handleFloatFloatBinOp(Info, E, Value, Opcode, RHS.getFloat()) &&
HandleFloatToFloatCast(Info, E, PromotedLHSType, SubobjType, Value);

rsmith wrote:
> Does this work for the float += int case?
IIRC, the RHS gets promoted to the computation type in Sema.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55413



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


r348982 - Revert "Declares __cpu_model as dso local"

2018-12-12 Thread Haibo Huang via cfe-commits
Author: hhb
Date: Wed Dec 12 14:39:51 2018
New Revision: 348982

URL: http://llvm.org/viewvc/llvm-project?rev=348982=rev
Log:
Revert "Declares __cpu_model as dso local"

This reverts r348978


Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtin-cpu-is.c
cfe/trunk/test/CodeGen/builtin-cpu-supports.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=348982=348981=348982=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Dec 12 14:39:51 2018
@@ -9465,7 +9465,6 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
 
   // Grab the global __cpu_model.
   llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
-  cast(CpuModel)->setDSOLocal(true);
 
   // Calculate the index needed to access the correct field based on the
   // range. Also adjust the expected value.
@@ -9538,7 +9537,6 @@ llvm::Value *CodeGenFunction::EmitX86Cpu
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
-cast(CpuModel)->setDSOLocal(true);
 
 // Grab the first (0th) element from the field __cpu_features off of the
 // global in the struct STy.
@@ -9558,8 +9556,6 @@ llvm::Value *CodeGenFunction::EmitX86Cpu
   if (Features2 != 0) {
 llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty,
  
"__cpu_features2");
-cast(CpuFeatures2)->setDSOLocal(true);
-
 Value *Features =
 Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4));
 
@@ -9577,7 +9573,6 @@ Value *CodeGenFunction::EmitX86CpuInit()
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
 /*Variadic*/ false);
   llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, 
"__cpu_indicator_init");
-  cast(Func)->setDSOLocal(true);
   return Builder.CreateCall(Func);
 }
 

Modified: cfe/trunk/test/CodeGen/builtin-cpu-is.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-is.c?rev=348982=348981=348982=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-is.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-is.c Wed Dec 12 14:39:51 2018
@@ -4,8 +4,6 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
-// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
-
 void intel() {
   if (__builtin_cpu_is("intel"))
 a("intel");

Modified: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-supports.c?rev=348982=348981=348982=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c Wed Dec 12 14:39:51 2018
@@ -4,9 +4,6 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
-// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
-// CHECK: @__cpu_features2 = external dso_local global i32
-
 int main() {
   __builtin_cpu_init();
 
@@ -28,5 +25,3 @@ int main() {
 
   return 0;
 }
-
-// CHECK: declare dso_local void @__cpu_indicator_init()


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


[PATCH] D55616: Emit ASM input in a constant context

2018-12-12 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Addressed Eli's comment.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55616



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


[PATCH] D55616: Emit ASM input in a constant context

2018-12-12 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 177936.
void marked an inline comment as done.
void added a comment.

Don't look at the optimization level here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55616

Files:
  include/clang/AST/Expr.h
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/builtin-constant-p.c

Index: test/CodeGen/builtin-constant-p.c
===
--- test/CodeGen/builtin-constant-p.c
+++ test/CodeGen/builtin-constant-p.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O2 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O2 | FileCheck --check-prefix=O2 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck --check-prefix=O0 %s
 
 int a = 42;
 
@@ -14,8 +15,8 @@
 struct foo f = (struct foo){ __builtin_constant_p(y), 42 };
 
 struct foo test0(int expr) {
-  // CHECK: define i64 @test0(i32 %expr)
-  // CHECK: call i1 @llvm.is.constant.i32(i32 %expr)
+  // O2: define i64 @test0(i32 %expr)
+  // O2: call i1 @llvm.is.constant.i32(i32 %expr)
   struct foo f = (struct foo){ __builtin_constant_p(expr), 42 };
   return f;
 }
@@ -27,15 +28,15 @@
 }
 
 int test1() {
-  // CHECK: define i32 @test1
-  // CHECK: add nsw i32 %0, -13
-  // CHECK-NEXT: call i1 @llvm.is.constant.i32(i32 %sub)
+  // O2: define i32 @test1
+  // O2: add nsw i32 %0, -13
+  // O2-NEXT: call i1 @llvm.is.constant.i32(i32 %sub)
   return bcp(test1_i() - 13);
 }
 
 int test2() {
-  // CHECK: define i32 @test2
-  // CHECK: ret i32 0
+  // O2: define i32 @test2
+  // O2: ret i32 0
   return __builtin_constant_p( - 13);
 }
 
@@ -44,8 +45,8 @@
 }
 
 int test3() {
-  // CHECK: define i32 @test3
-  // CHECK: ret i32 1
+  // O2: define i32 @test3
+  // O2: ret i32 1
   return bcp(test3_i() - 13);
 }
 
@@ -54,16 +55,16 @@
 int b[] = {1, 2, 3};
 
 int test4() {
-  // CHECK: define i32 @test4
-  // CHECK: ret i32 0
+  // O2: define i32 @test4
+  // O2: ret i32 0
   return __builtin_constant_p(b);
 }
 
 const char test5_c[] = {1, 2, 3, 0};
 
 int test5() {
-  // CHECK: define i32 @test5
-  // CHECK: ret i32 0
+  // O2: define i32 @test5
+  // O2: ret i32 0
   return __builtin_constant_p(test5_c);
 }
 
@@ -72,16 +73,16 @@
 }
 
 int test6() {
-  // CHECK: define i32 @test6
-  // CHECK: ret i32 0
+  // O2: define i32 @test6
+  // O2: ret i32 0
   return __builtin_constant_p(test6_i(test5_c));
 }
 
 /* --- Non-constant global variables */
 
 int test7() {
-  // CHECK: define i32 @test7
-  // CHECK: call i1 @llvm.is.constant.i32(i32 %0)
+  // O2: define i32 @test7
+  // O2: call i1 @llvm.is.constant.i32(i32 %0)
   return bcp(a);
 }
 
@@ -90,8 +91,8 @@
 const int c = 42;
 
 int test8() {
-  // CHECK: define i32 @test8
-  // CHECK: ret i32 1
+  // O2: define i32 @test8
+  // O2: ret i32 1
   return bcp(c);
 }
 
@@ -101,34 +102,34 @@
 const int c_arr[] = { 1, 2, 3 };
 
 int test9() {
-  // CHECK: define i32 @test9
-  // CHECK: call i1 @llvm.is.constant.i32(i32 %0)
+  // O2: define i32 @test9
+  // O2: call i1 @llvm.is.constant.i32(i32 %0)
   return __builtin_constant_p(arr[2]);
 }
 
 int test10() {
-  // CHECK: define i32 @test10
-  // CHECK: ret i32 1
+  // O2: define i32 @test10
+  // O2: ret i32 1
   return __builtin_constant_p(c_arr[2]);
 }
 
 int test11() {
-  // CHECK: define i32 @test11
-  // CHECK: ret i32 0
+  // O2: define i32 @test11
+  // O2: ret i32 0
   return __builtin_constant_p(c_arr);
 }
 
 /* --- Function pointers */
 
 int test12() {
-  // CHECK: define i32 @test12
-  // CHECK: ret i32 0
+  // O2: define i32 @test12
+  // O2: ret i32 0
   return __builtin_constant_p();
 }
 
 int test13() {
-  // CHECK: define i32 @test13
-  // CHECK: ret i32 1
+  // O2: define i32 @test13
+  // O2: ret i32 1
   return __builtin_constant_p( != 0);
 }
 
@@ -166,3 +167,13 @@
 
 extern char test16_v;
 struct { int a; } test16 = { __builtin_constant_p(test16_v) };
+
+extern unsigned long long test17_v;
+
+void test17() {
+  // O0: define void @test17
+  // O0: call void asm sideeffect "", {{.*}}(i32 -1) 
+  // O0: call void asm sideeffect "", {{.*}}(i32 -1) 
+  __asm__ __volatile__("" :: "n"( (__builtin_constant_p(test17_v) || 0) ? 1 : -1));
+  __asm__ __volatile__("" :: "i"( (__builtin_constant_p(test17_v) || 0) ? 1 : -1));
+}
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1821,7 +1821,7 @@
   // (immediate or symbolic), try to emit it as such.
   if (!Info.allowsRegister() && !Info.allowsMemory()) {
 Expr::EvalResult Result;
-if (InputExpr->EvaluateAsInt(Result, getContext()))
+if (InputExpr->EvaluateAsIntInConstantContext(Result, getContext()))
   return llvm::ConstantInt::get(getLLVMContext(), Result.Val.getInt());
 assert(!Info.requiresImmediateConstant() &&

[PATCH] D55616: Emit ASM input in a constant context

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



Comment at: lib/CodeGen/CGStmt.cpp:1825
+bool Success = false;
+if (CGM.getCodeGenOpts().OptimizationLevel > 0)
+  Success = InputExpr->EvaluateAsInt(Result, getContext());

Checking the optimization level here doesn't make sense. If a value is required 
to be constant in some context, we should evaluate it the same way at all 
optimization levels.

It's also important that the evaluation here computes the same result as 
Sema::ActOnGCCAsmStmt; otherwise you could hit an assertion failure.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55616



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


[PATCH] D53280: [analyzer] Emit an error for invalid -analyzer-config inputs

2018-12-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

>> The deadline is around the creation of the 8.0.0. release branch, right?
> 
> I'd feel slightly more comfortable if some sort of fix gets in before the 
> Christmas break.

Sure! :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D53280



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


[libunwind] r348981 - Avoid code duplication in the SEH version of UnwindCursor::getRegisterName. NFC.

2018-12-12 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Dec 12 14:24:42 2018
New Revision: 348981

URL: http://llvm.org/viewvc/llvm-project?rev=348981=rev
Log:
Avoid code duplication in the SEH version of UnwindCursor::getRegisterName. NFC.

This requires making Registers_*::getRegisterName static.

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

Modified:
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=348981=348980=348981=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Wed Dec 12 14:24:42 2018
@@ -42,7 +42,7 @@ public:
   boolvalidVectorRegister(int) const { return false; }
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_X86; }
 
@@ -248,7 +248,7 @@ public:
   boolvalidVectorRegister(int) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64; }
 
@@ -561,7 +561,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC; }
 
@@ -1126,7 +1126,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64; }
 
@@ -1768,7 +1768,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64; }
 
@@ -2038,7 +2038,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto() {
 restoreSavedFloatRegisters();
 restoreCoreAndJumpTo();
@@ -2518,7 +2518,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K; }
 
@@ -2714,7 +2714,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS; }
 
@@ -3035,7 +3035,7 @@ public:
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
-  const char *getRegisterName(int num);
+  static const char *getRegisterName(int num);
   voidjumpto();
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS; }
 

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=348981=348980=348981=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Wed Dec 12 14:24:42 2018
@@ -804,113 +804,7 @@ template  void U
 
 template 
 const char *UnwindCursor::getRegisterName(int regNum) {
-  switch (regNum) {
-#if defined(_LIBUNWIND_TARGET_X86_64)
-  case UNW_REG_IP: return "rip";
-  case UNW_X86_64_RAX: return "rax";
-  case UNW_X86_64_RDX: return "rdx";
-  case UNW_X86_64_RCX: return "rcx";
-  case UNW_X86_64_RBX: return "rbx";
-  case UNW_REG_SP:
-  case UNW_X86_64_RSP: return "rsp";
-  case 

[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check

2018-12-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:601
 
+static bool compareToks(Token , Token , const SourceManager ) {
+  if (T1.getLength() != T2.getLength())

Szelethus wrote:
> alexfh wrote:
> > Should this function compare token kinds first?
> I personally prefer to see boolean functions to have a name that starts with 
> either "should", "is", "does", "has", or anything that clearly indicates that 
> it returns with either `true` or `false`. In this case, "compare" is 
> especially misleading, since it might as well return `-1`, `0` or `1`.
> 
> Maybe `hasSameLength`?
Sorry, upon closer inspection, `isSameToken` would be more fitting. Mind you, 
there already is a function somewhere for this, but due to the lack of a 
`Preprocessor` object, we can't use it.
https://clang.llvm.org/doxygen/RewriteMacros_8cpp.html#a0ba058873ae3930f71b19b4dee4b1cbb


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55125



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


[PATCH] D55620: [ThinLTO] Clang changes to utilize new pass to handle chains of aliases

2018-12-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: pcc, davidxl.
Herald added subscribers: dexonsmith, steven_wu, inglorion, mehdi_amini.

As with NameAnonGlobals, invoke the new CanonicalizeAliases via clang
when using the new PM.

Depends on D54507 .


Repository:
  rC Clang

https://reviews.llvm.org/D55620

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/lto-newpm-pipeline.c


Index: test/CodeGen/lto-newpm-pipeline.c
===
--- test/CodeGen/lto-newpm-pipeline.c
+++ test/CodeGen/lto-newpm-pipeline.c
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -59,6 +59,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -996,8 +997,10 @@
 MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass()));
 
   // Lastly, add a semantically necessary pass for LTO.
-  if (IsLTO || IsThinLTO)
+  if (IsLTO || IsThinLTO) {
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
+  }
 } else {
   // Map our optimization levels into one of the distinct levels used to
   // configure the pipeline.
@@ -1018,10 +1021,12 @@
   if (IsThinLTO) {
 MPM = PB.buildThinLTOPreLinkDefaultPipeline(
 Level, CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else if (IsLTO) {
 MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
 CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else {
 MPM = PB.buildPerModuleDefaultPipeline(Level,


Index: test/CodeGen/lto-newpm-pipeline.c
===
--- test/CodeGen/lto-newpm-pipeline.c
+++ test/CodeGen/lto-newpm-pipeline.c
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -59,6 +59,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -996,8 +997,10 @@
 

[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check

2018-12-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:601
 
+static bool compareToks(Token , Token , const SourceManager ) {
+  if (T1.getLength() != T2.getLength())

alexfh wrote:
> Should this function compare token kinds first?
I personally prefer to see boolean functions to have a name that starts with 
either "should", "is", "does", "has", or anything that clearly indicates that 
it returns with either `true` or `false`. In this case, "compare" is especially 
misleading, since it might as well return `-1`, `0` or `1`.

Maybe `hasSameLength`?



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:602
+static bool compareToks(Token , Token , const SourceManager ) {
+  if (T1.getLength() != T2.getLength())
+return false;

alexfh wrote:
> `Token::getLength()` will assert-fail for annotation tokens.
I guess if `T1.isNot(tok::raw_identifier)` (or `T2`) we could get away with 
simply comparing token kinds. If they are, it wouldn't assert. :)



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:638
+  SourceLocation LLoc, RLoc;
+  int LRem, RRem;
+  do {//we compare the expressions token-by-token

It seems like we're only checking whether these values are `0` or not, maybe 
make them `bool`? Also, I find `Rem` a little cryptic, what is it referring to? 
Maybe `RemainingCharCount`?

Maybe we should just make a simple function, so we could both boost 
readability, and get rid of some these variables (`LLoc`, `RLoc`) entirely:

```
unsinged getCharCountUntilEndOfExpr(SourceRange ExprSR, Token T,
const SourceManager ) {

  assert((ExprSR.getBegin() > T.getLocation() ||
  ExprSR.getEnd() < T.getLocation()) &&
 "Token is not within the expression range!");

  return SM.getCharacterData(SM.getExpansionLoc(ExprSR.getEnd())) -
 SM.getCharacterData(T.getLocation());
}
```




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

https://reviews.llvm.org/D55125



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


[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p

2018-12-12 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D54355#1328786 , @jyknight wrote:

> In D54355#1328557 , @void wrote:
>
> > The issue is that "`n`" is expecting an immediate value, but the result of 
> > the ternary operator isn't calculated by the front-end, because it doesn't 
> > "know" that the evaluation of `__builtin_constant_p` shouldn't be delayed 
> > (it being compiled at `-O0`). I suspect that this issue will also happen 
> > with the "`i`" constraint.
>
>
> Indeed. We _do_ actually already know that in clang too, however -- clang 
> already knows that "n" requires an immediate, and does constant expression 
> evaluation for it, e.g. to expand constexpr functions. Grep for 
> "requiresImmediateConstant". I guess it's just not hooked up to the __b_c_p 
> correctly, though.
>
> (Note, as a workaround, you could use `|` instead of `||`, or put the 
> expression as the value of an enumeration constant).


I looked at `requiresImmediateConstant`, but when I set it for `n` and `i` 
things broke all over the place. I sent out a patch for review. It's limited to 
`-O0`, since we can compile with optimizations without complaint. And there may 
be instances where it's necessary:

  inline void foo(int x) {
asm("" : : "n" (__builtin_constant_p(n) ? 1 : -1));
  }
  
  void bar() {
foo(37);
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D54355



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


[PATCH] D53850: Declares __cpu_model as dso local

2018-12-12 Thread Haibo Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348978: Declares __cpu_model as dso local (authored by hhb, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53850?vs=171789=177915#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D53850

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtin-cpu-is.c
  cfe/trunk/test/CodeGen/builtin-cpu-supports.c


Index: cfe/trunk/test/CodeGen/builtin-cpu-is.c
===
--- cfe/trunk/test/CodeGen/builtin-cpu-is.c
+++ cfe/trunk/test/CodeGen/builtin-cpu-is.c
@@ -4,6 +4,8 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+
 void intel() {
   if (__builtin_cpu_is("intel"))
 a("intel");
Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
===
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c
@@ -4,6 +4,9 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+// CHECK: @__cpu_features2 = external dso_local global i32
+
 int main() {
   __builtin_cpu_init();
 
@@ -25,3 +28,5 @@
 
   return 0;
 }
+
+// CHECK: declare dso_local void @__cpu_indicator_init()
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -9465,6 +9465,7 @@
 
   // Grab the global __cpu_model.
   llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
+  cast(CpuModel)->setDSOLocal(true);
 
   // Calculate the index needed to access the correct field based on the
   // range. Also adjust the expected value.
@@ -9537,6 +9538,7 @@
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
+cast(CpuModel)->setDSOLocal(true);
 
 // Grab the first (0th) element from the field __cpu_features off of the
 // global in the struct STy.
@@ -9556,6 +9558,8 @@
   if (Features2 != 0) {
 llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty,
  
"__cpu_features2");
+cast(CpuFeatures2)->setDSOLocal(true);
+
 Value *Features =
 Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4));
 
@@ -9573,6 +9577,7 @@
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
 /*Variadic*/ false);
   llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, 
"__cpu_indicator_init");
+  cast(Func)->setDSOLocal(true);
   return Builder.CreateCall(Func);
 }
 


Index: cfe/trunk/test/CodeGen/builtin-cpu-is.c
===
--- cfe/trunk/test/CodeGen/builtin-cpu-is.c
+++ cfe/trunk/test/CodeGen/builtin-cpu-is.c
@@ -4,6 +4,8 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+
 void intel() {
   if (__builtin_cpu_is("intel"))
 a("intel");
Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
===
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c
@@ -4,6 +4,9 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+// CHECK: @__cpu_features2 = external dso_local global i32
+
 int main() {
   __builtin_cpu_init();
 
@@ -25,3 +28,5 @@
 
   return 0;
 }
+
+// CHECK: declare dso_local void @__cpu_indicator_init()
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -9465,6 +9465,7 @@
 
   // Grab the global __cpu_model.
   llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
+  cast(CpuModel)->setDSOLocal(true);
 
   // Calculate the index needed to access the correct field based on the
   // range. Also adjust the expected value.
@@ -9537,6 +9538,7 @@
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
+cast(CpuModel)->setDSOLocal(true);
 
 // Grab the first (0th) element from the field __cpu_features off of the
 // global in the struct STy.
@@ -9556,6 +9558,8 @@
   if (Features2 != 0) {
 llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty,
  

[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p

2018-12-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D54355#1328557 , @void wrote:

> The issue is that "`n`" is expecting an immediate value, but the result of 
> the ternary operator isn't calculated by the front-end, because it doesn't 
> "know" that the evaluation of `__builtin_constant_p` shouldn't be delayed (it 
> being compiled at `-O0`). I suspect that this issue will also happen with the 
> "`i`" constraint.


Indeed. We _do_ actually already know that in clang too, however -- clang 
already knows that "n" requires an immediate, and does constant expression 
evaluation for it, e.g. to expand constexpr functions. Grep for 
"requiresImmediateConstant". I guess it's just not hooked up to the __b_c_p 
correctly, though.

(Note, as a workaround, you could use `|` instead of `||`, or put the 
expression as the value of an enumeration constant).


Repository:
  rC Clang

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

https://reviews.llvm.org/D54355



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


[PATCH] D55616: Emit ASM input in a constant context

2018-12-12 Thread Bill Wendling via Phabricator via cfe-commits
void created this revision.
void added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.
void added subscribers: jyknight, craig.topper.
void added a comment.

As a side note, the number of ways to evaluate a constant expression are legion 
in clang. They should really be unified...


Some ASM input constraints (e.g., "i" and "n") require immediate values. At O0,
very few code transformations are performed. So if we cannot resolve to an
immediate when emitting the ASM input we shouldn't delay its processing.


Repository:
  rC Clang

https://reviews.llvm.org/D55616

Files:
  include/clang/AST/Expr.h
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/builtin-constant-p.c

Index: test/CodeGen/builtin-constant-p.c
===
--- test/CodeGen/builtin-constant-p.c
+++ test/CodeGen/builtin-constant-p.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O2 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O2 | FileCheck --check-prefix=O2 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck --check-prefix=O0 %s
 
 int a = 42;
 
@@ -14,8 +15,8 @@
 struct foo f = (struct foo){ __builtin_constant_p(y), 42 };
 
 struct foo test0(int expr) {
-  // CHECK: define i64 @test0(i32 %expr)
-  // CHECK: call i1 @llvm.is.constant.i32(i32 %expr)
+  // O2: define i64 @test0(i32 %expr)
+  // O2: call i1 @llvm.is.constant.i32(i32 %expr)
   struct foo f = (struct foo){ __builtin_constant_p(expr), 42 };
   return f;
 }
@@ -27,15 +28,15 @@
 }
 
 int test1() {
-  // CHECK: define i32 @test1
-  // CHECK: add nsw i32 %0, -13
-  // CHECK-NEXT: call i1 @llvm.is.constant.i32(i32 %sub)
+  // O2: define i32 @test1
+  // O2: add nsw i32 %0, -13
+  // O2-NEXT: call i1 @llvm.is.constant.i32(i32 %sub)
   return bcp(test1_i() - 13);
 }
 
 int test2() {
-  // CHECK: define i32 @test2
-  // CHECK: ret i32 0
+  // O2: define i32 @test2
+  // O2: ret i32 0
   return __builtin_constant_p( - 13);
 }
 
@@ -44,8 +45,8 @@
 }
 
 int test3() {
-  // CHECK: define i32 @test3
-  // CHECK: ret i32 1
+  // O2: define i32 @test3
+  // O2: ret i32 1
   return bcp(test3_i() - 13);
 }
 
@@ -54,16 +55,16 @@
 int b[] = {1, 2, 3};
 
 int test4() {
-  // CHECK: define i32 @test4
-  // CHECK: ret i32 0
+  // O2: define i32 @test4
+  // O2: ret i32 0
   return __builtin_constant_p(b);
 }
 
 const char test5_c[] = {1, 2, 3, 0};
 
 int test5() {
-  // CHECK: define i32 @test5
-  // CHECK: ret i32 0
+  // O2: define i32 @test5
+  // O2: ret i32 0
   return __builtin_constant_p(test5_c);
 }
 
@@ -72,16 +73,16 @@
 }
 
 int test6() {
-  // CHECK: define i32 @test6
-  // CHECK: ret i32 0
+  // O2: define i32 @test6
+  // O2: ret i32 0
   return __builtin_constant_p(test6_i(test5_c));
 }
 
 /* --- Non-constant global variables */
 
 int test7() {
-  // CHECK: define i32 @test7
-  // CHECK: call i1 @llvm.is.constant.i32(i32 %0)
+  // O2: define i32 @test7
+  // O2: call i1 @llvm.is.constant.i32(i32 %0)
   return bcp(a);
 }
 
@@ -90,8 +91,8 @@
 const int c = 42;
 
 int test8() {
-  // CHECK: define i32 @test8
-  // CHECK: ret i32 1
+  // O2: define i32 @test8
+  // O2: ret i32 1
   return bcp(c);
 }
 
@@ -101,34 +102,34 @@
 const int c_arr[] = { 1, 2, 3 };
 
 int test9() {
-  // CHECK: define i32 @test9
-  // CHECK: call i1 @llvm.is.constant.i32(i32 %0)
+  // O2: define i32 @test9
+  // O2: call i1 @llvm.is.constant.i32(i32 %0)
   return __builtin_constant_p(arr[2]);
 }
 
 int test10() {
-  // CHECK: define i32 @test10
-  // CHECK: ret i32 1
+  // O2: define i32 @test10
+  // O2: ret i32 1
   return __builtin_constant_p(c_arr[2]);
 }
 
 int test11() {
-  // CHECK: define i32 @test11
-  // CHECK: ret i32 0
+  // O2: define i32 @test11
+  // O2: ret i32 0
   return __builtin_constant_p(c_arr);
 }
 
 /* --- Function pointers */
 
 int test12() {
-  // CHECK: define i32 @test12
-  // CHECK: ret i32 0
+  // O2: define i32 @test12
+  // O2: ret i32 0
   return __builtin_constant_p();
 }
 
 int test13() {
-  // CHECK: define i32 @test13
-  // CHECK: ret i32 1
+  // O2: define i32 @test13
+  // O2: ret i32 1
   return __builtin_constant_p( != 0);
 }
 
@@ -166,3 +167,13 @@
 
 extern char test16_v;
 struct { int a; } test16 = { __builtin_constant_p(test16_v) };
+
+extern unsigned long long test17_v;
+
+void test17() {
+  // O0: define void @test17
+  // O0: call void asm sideeffect "", {{.*}}(i32 -1) 
+  // O0: call void asm sideeffect "", {{.*}}(i32 -1) 
+  __asm__ __volatile__("" :: "n"( (__builtin_constant_p(test17_v) || 0) ? 1 : -1));
+  __asm__ __volatile__("" :: "i"( (__builtin_constant_p(test17_v) || 0) ? 1 : -1));
+}
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1821,7 +1821,12 @@
   // (immediate or symbolic), try to emit it as such.
   if (!Info.allowsRegister() && 

[PATCH] D55616: Emit ASM input in a constant context

2018-12-12 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

As a side note, the number of ways to evaluate a constant expression are legion 
in clang. They should really be unified...


Repository:
  rC Clang

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

https://reviews.llvm.org/D55616



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


[PATCH] D55534: [AST] Store "UsesADL" information in CallExpr.

2018-12-12 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348977: [AST] Store UsesADL information in 
CallExpr. (authored by EricWF, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D55534

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/AST/ast-dump-expr.cpp
  test/Import/call-expr/Inputs/F.cpp
  test/Import/call-expr/test.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2562,6 +2562,28 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExprusesADL
+Matches call expressions which were resolved using ADL.
+
+Example matches y(x) but not y(42) or NS::y(x).
+  namespace NS {
+struct X {};
+void y(X);
+  }
+
+  void y(...);
+
+  void test() {
+NS::X x;
+y(x); // Matches
+NS::y(x); // Doesn't match
+y(42); // Doesn't match
+using NS::y;
+y(x); // Found by both unqualified lookup and ADL, doesn't match
+   }
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CastExpr.html;>CastExprhasCastKindCastKind Kind
 Matches casts that has a given cast kind.
 
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -430,6 +430,9 @@
 unsigned : NumExprBits;
 
 unsigned NumPreArgs : 1;
+
+/// True if the callee of the call expression was found using ADL.
+unsigned UsesADL : 1;
   };
 
   class MemberExprBitfields {
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -2412,14 +2412,20 @@
 
   void updateDependenciesFromArg(Expr *Arg);
 
+public:
+  enum class ADLCallKind : bool { NotADL, UsesADL };
+  static constexpr ADLCallKind NotADL = ADLCallKind::NotADL;
+  static constexpr ADLCallKind UsesADL = ADLCallKind::UsesADL;
+
 protected:
   // These versions of the constructor are for derived classes.
   CallExpr(const ASTContext , StmtClass SC, Expr *fn,
ArrayRef preargs, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0);
+   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
+   ADLCallKind UsesADL = NotADL);
   CallExpr(const ASTContext , StmtClass SC, Expr *fn, ArrayRef args,
QualType t, ExprValueKind VK, SourceLocation rparenloc,
-   unsigned MinNumArgs = 0);
+   unsigned MinNumArgs = 0, ADLCallKind UsesADL = NotADL);
   CallExpr(const ASTContext , StmtClass SC, unsigned NumPreArgs,
unsigned NumArgs, EmptyShell Empty);
 
@@ -2443,7 +2449,8 @@
   /// arguments. The actual number of arguments will be the greater of
   /// args.size() and MinNumArgs.
   CallExpr(const ASTContext , Expr *fn, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0);
+   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
+   ADLCallKind UsesADL = NotADL);
 
   /// Build an empty call expression.
   CallExpr(const ASTContext , unsigned NumArgs, EmptyShell Empty);
@@ -2452,6 +2459,14 @@
   Expr *getCallee() { return cast(SubExprs[FN]); }
   void setCallee(Expr *F) { SubExprs[FN] = F; }
 
+  ADLCallKind getADLCallKind() const {
+return static_cast(CallExprBits.UsesADL);
+  }
+  void setADLCallKind(ADLCallKind V = UsesADL) {
+CallExprBits.UsesADL = static_cast(V);
+  }
+  bool usesADL() const { return getADLCallKind() == UsesADL; }
+
   Decl *getCalleeDecl();
   const Decl *getCalleeDecl() const {
 return const_cast(this)->getCalleeDecl();
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -90,10 +90,12 @@
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 
-  CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
-  ArrayRef args, QualType t, ExprValueKind VK,
-  SourceLocation operatorloc, FPOptions FPFeatures)
-  : CallExpr(C, CXXOperatorCallExprClass, fn, args, t, VK, operatorloc),
+  CXXOperatorCallExpr(ASTContext , OverloadedOperatorKind Op, Expr *fn,
+  ArrayRef args, QualType t, 

r348977 - [AST] Store "UsesADL" information in CallExpr.

2018-12-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 12 13:50:55 2018
New Revision: 348977

URL: http://llvm.org/viewvc/llvm-project?rev=348977=rev
Log:
[AST] Store "UsesADL" information in CallExpr.

Summary:
Currently the Clang AST doesn't store information about how the callee of a 
CallExpr was found. Specifically if it was found using ADL.

However, this information is invaluable to tooling. Consider a tool which 
renames usages of a function. If the originally CallExpr was formed using ADL, 
then the tooling may need to additionally qualify the replacement.
Without information about how the callee was found, the tooling is left 
scratching it's head. Additionally, we want to be able to match ADL calls as 
quickly as possible, which means avoiding computing the answer on the fly.

This patch changes `CallExpr` to store whether it's callee was found using ADL. 
It does not change the size of any AST nodes.


Reviewers: fowles, rsmith, klimek, shafik

Reviewed By: rsmith

Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits

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

Added:
cfe/trunk/test/Import/call-expr/
cfe/trunk/test/Import/call-expr/Inputs/
cfe/trunk/test/Import/call-expr/Inputs/F.cpp
cfe/trunk/test/Import/call-expr/test.cpp
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/AST/ast-dump-expr.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=348977=348976=348977=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed Dec 12 13:50:55 2018
@@ -2562,6 +2562,28 @@ Example matches f(0, 0) (matcher = callE
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExprusesADL
+Matches call expressions 
which were resolved using ADL.
+
+Example matches y(x) but not y(42) or NS::y(x).
+  namespace NS {
+struct X {};
+void y(X);
+  }
+
+  void y(...);
+
+  void test() {
+NS::X x;
+y(x); // Matches
+NS::y(x); // Doesn't match
+y(42); // Doesn't match
+using NS::y;
+y(x); // Found by both unqualified lookup and ADL, doesn't match
+   }
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CastExpr.html;>CastExprhasCastKindCastKind Kind
 Matches casts that has 
a given cast kind.
 

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=348977=348976=348977=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Dec 12 13:50:55 2018
@@ -2412,14 +2412,20 @@ class CallExpr : public Expr {
 
   void updateDependenciesFromArg(Expr *Arg);
 
+public:
+  enum class ADLCallKind : bool { NotADL, UsesADL };
+  static constexpr ADLCallKind NotADL = ADLCallKind::NotADL;
+  static constexpr ADLCallKind UsesADL = ADLCallKind::UsesADL;
+
 protected:
   // These versions of the constructor are for derived classes.
   CallExpr(const ASTContext , StmtClass SC, Expr *fn,
ArrayRef preargs, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 
0);
+   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
+   ADLCallKind UsesADL = NotADL);
   CallExpr(const ASTContext , StmtClass SC, Expr *fn, ArrayRef args,
QualType t, ExprValueKind VK, SourceLocation rparenloc,
-   unsigned MinNumArgs = 0);
+   unsigned MinNumArgs = 0, ADLCallKind UsesADL = NotADL);
   CallExpr(const ASTContext , StmtClass SC, unsigned NumPreArgs,
unsigned NumArgs, EmptyShell Empty);
 
@@ -2443,7 +2449,8 @@ public:
   /// arguments. The actual number of arguments will be the greater of
   /// args.size() and MinNumArgs.
   CallExpr(const ASTContext , Expr *fn, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 
0);
+   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
+   ADLCallKind UsesADL = NotADL);
 
   /// Build an empty call expression.
   CallExpr(const ASTContext , unsigned 

[PATCH] D55534: [AST] Store "UsesADL" information in CallExpr.

2018-12-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 177907.
EricWF marked an inline comment as done.
EricWF added a comment.

Address final review comments.


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

https://reviews.llvm.org/D55534

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/AST/ast-dump-expr.cpp
  test/Import/call-expr/Inputs/F.cpp
  test/Import/call-expr/test.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -199,6 +199,40 @@
"-fno-delayed-template-parsing"));
 }
 
+TEST(Matcher, ADLCall) {
+  StatementMatcher ADLMatch = callExpr(usesADL());
+  StatementMatcher ADLMatchOper = cxxOperatorCallExpr(usesADL());
+  auto NS_Str = R"cpp(
+  namespace NS {
+struct X {};
+void f(X);
+void operator+(X, X);
+  }
+  struct MyX {};
+  void f(...);
+  void operator+(MyX, MyX);
+)cpp";
+
+  auto MkStr = [&](std::string Body) -> std::string {
+std::string S = NS_Str;
+S += "void test_fn() { " + Body + " }";
+return S;
+  };
+
+  EXPECT_TRUE(matches(MkStr("NS::X x; f(x);"), ADLMatch));
+  EXPECT_TRUE(notMatches(MkStr("NS::X x; NS::f(x);"), ADLMatch));
+  EXPECT_TRUE(notMatches(MkStr("MyX x; f(x);"), ADLMatch));
+  EXPECT_TRUE(notMatches(MkStr("NS::X x; using NS::f; f(x);"), ADLMatch));
+
+  // Operator call expressions
+  EXPECT_TRUE(matches(MkStr("NS::X x; x + x;"), ADLMatch));
+  EXPECT_TRUE(matches(MkStr("NS::X x; x + x;"), ADLMatchOper));
+  EXPECT_TRUE(notMatches(MkStr("MyX x; x + x;"), ADLMatch));
+  EXPECT_TRUE(notMatches(MkStr("MyX x; x + x;"), ADLMatchOper));
+  EXPECT_TRUE(matches(MkStr("NS::X x; operator+(x, x);"), ADLMatch));
+  EXPECT_TRUE(notMatches(MkStr("NS::X x; NS::operator+(x, x);"), ADLMatch));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: test/Import/call-expr/test.cpp
===
--- /dev/null
+++ test/Import/call-expr/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+void expr() {
+  f();
+}
+
+// CHECK: FunctionDecl 0x{{[^ ]*}} <{{[^>]*}}> line:{{.*}}:{{[^ ]*}} used f 'void ()'
+// CHECK: -CallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl
+// CHECK: -CXXOperatorCallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl
Index: test/Import/call-expr/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/call-expr/Inputs/F.cpp
@@ -0,0 +1,10 @@
+namespace NS {
+struct X {};
+void f(X) {}
+void operator+(X, X) {}
+} // namespace NS
+void f() {
+  NS::X x;
+  f(x);
+  x + x;
+}
Index: test/AST/ast-dump-expr.cpp
===
--- test/AST/ast-dump-expr.cpp
+++ test/AST/ast-dump-expr.cpp
@@ -508,3 +508,46 @@
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'Ts...' lvalue ParmVar 0x{{[^ ]*}} 'a' 'Ts...'
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue Var 0x{{[^ ]*}} 'b' 'int'
 }
+
+
+namespace NS {
+struct X {};
+void f(X);
+void y(...);
+} // namespace NS
+
+// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}ADLCall 'void ()'
+void ADLCall() {
+  NS::X x;
+  // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void' adl{{$}}
+  f(x);
+  // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void' adl{{$}}
+  y(x);
+}
+
+// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall 'void ()'
+void NonADLCall() {
+  NS::X x;
+  // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void'{{$}}
+  NS::f(x);
+}
+
+// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall2 'void ()'
+void NonADLCall2() {
+  NS::X x;
+  using NS::f;
+  // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void'{{$}}
+  f(x);
+  // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void' adl{{$}}
+  y(x);
+}
+
+namespace test_adl_call_three {
+using namespace NS;
+// CHECK-LABEL: FunctionDecl 0x{{[^ ]*}} {{.*}}NonADLCall3 'void ()'
+void NonADLCall3() {
+  X x;
+  // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void'{{$}}
+  f(x);
+}
+} // namespace test_adl_call_three
\ No newline at end of file
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -651,6 +651,7 @@
   for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg)
 Record.AddStmt(*Arg);
+  

[PATCH] D53280: [analyzer] Emit an error for invalid -analyzer-config inputs

2018-12-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D53280#1325375 , @Szelethus wrote:

> I guess the solution would be to check whether there are any user supplied 
> flags with "analyze" substring, and add the compatibility flag then. It is 
> possible if not probable that a non-static-analyzer related flag with a name 
> like that will eventually be added, but I guess we can live with it.


Yeah, that's pretty much the easiest solution that i see (i guess we need to 
look for `-analyzer-config` specifically), but it's still pretty gross.

> The deadline is around the creation of the 8.0.0. release branch, right?

I'd feel slightly more comfortable if some sort of fix gets in before the 
Christmas break.

In D53280#1319524 , @Szelethus wrote:

> We could just add the flag back, and do nothing with it. (...) Edit: I just 
> realized that this could easily be an issue for other users of the static 
> analyzer (or clang in general) as well.


It doesn't sound appealing to bring back all the flags that we've removed 
recently, but i guess it's not that hard to track back all the options that we 
removed since, say, 6.0.0 and add them back, marked as "deprecated" somehow, 
and remove them later when either we have a solution for the general case or we 
don't care anymore :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D53280



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


r348969 - Teach __builtin_unpredictable to work through implicit casts.

2018-12-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Dec 12 12:30:53 2018
New Revision: 348969

URL: http://llvm.org/viewvc/llvm-project?rev=348969=rev
Log:
Teach __builtin_unpredictable to work through implicit casts.

The __builtin_unpredictable implementation is confused by any implicit
casts, which happen in C++.  This patch strips those off so that
if/switch statements now work with it in C++.

Change-Id: I73c3bf4f1775cd906703880944f4fcdc29fffb0a

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/builtin-unpredictable.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=348969=348968=348969=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Dec 12 12:30:53 2018
@@ -1701,7 +1701,7 @@ void CodeGenFunction::EmitBranchOnBoolEx
   // create metadata that specifies that the branch is unpredictable.
   // Don't bother if not optimizing because that metadata would not be used.
   llvm::MDNode *Unpredictable = nullptr;
-  auto *Call = dyn_cast(Cond);
+  auto *Call = dyn_cast(Cond->IgnoreImpCasts());
   if (Call && CGM.getCodeGenOpts().OptimizationLevel != 0) {
 auto *FD = dyn_cast_or_null(Call->getCalleeDecl());
 if (FD && FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {

Modified: cfe/trunk/test/CodeGen/builtin-unpredictable.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-unpredictable.c?rev=348969=348968=348969=diff
==
--- cfe/trunk/test/CodeGen/builtin-unpredictable.c (original)
+++ cfe/trunk/test/CodeGen/builtin-unpredictable.c Wed Dec 12 12:30:53 2018
@@ -1,10 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-disable-llvm-passes -o - %s -O1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-disable-llvm-passes -o - %s -O1 | FileCheck %s 
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-disable-llvm-passes -o - -x c++ %s -O1 | FileCheck %s 
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | 
FileCheck %s --check-prefix=CHECK_O0
 
 // When optimizing, the builtin should be converted to metadata.
 // When not optimizing, there should be no metadata created for the builtin.
 // In both cases, the builtin should be removed from the code.
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void foo();
 void branch(int x) {
 // CHECK-LABEL: define void @branch(
@@ -42,5 +47,10 @@ int unpredictable_switch(int x) {
   return 0;
 }
 
+#ifdef __cplusplus
+}
+#endif
+
+
 // CHECK: [[METADATA]] = !{}
 


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


[PATCH] D55534: [AST] Store "UsesADL" information in CallExpr.

2018-12-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1276
+/// y(42); // Doesn't match
+///   }
+/// \endcode

I think it would be useful to add to the example:
```
using NS::y;
y(x); // Found by both unqualified lookup and ADL, doesn't match
```


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

https://reviews.llvm.org/D55534



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


[PATCH] D55039: [sema] Warn of mangling change if function parameters are noexcept.

2018-12-12 Thread Matt Davis via Phabricator via cfe-commits
mattd marked 2 inline comments as done.
mattd added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10266
   auto *FPT = NewFD->getType()->castAs();
-  bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
-  for (QualType T : FPT->param_types())
-AnyNoexcept |= HasNoexcept(T);
-  if (AnyNoexcept)
+  if (hasNoexcept(FPT->getReturnType()) ||
+  llvm::any_of(FPT->param_types(),

mattd wrote:
> Rakete wrote:
> > What you're doing here is a subset of what `hasNoexcept` is doing for 
> > function types. Do you think it would make sense to use `!FPT->isNothrow() 
> > && hasNoexcept(NewFW->getType())` or something like that?
> Thanks for the comments @Rakete.
> 
> I do see the similarity and was trying to implement a solution to take 
> advantage of that.  However, I was running into trouble on assert/debug 
> builds.  `llvm_unreachable`, called in `FunctionProtoType::canThrow`, will 
> trigger on FunctionProtoType instances that have not yet had their 
> exception-spec type evaluated.  `canThrow` is called on behalf of 
> `isNothrow`.  Some of the test cases will fail in assert/debug builds if we 
> place a call to to `FPT->isNothrow` here. 
> 
> The original code avoided this assertion by not calling `isNothrow` on FPT 
> here, but instead just evaluating the return and parameter types of FPT.  I 
> made this patch similar to what was already in place, but with the more  
> thorough check in `hasNoexcept.`  I'd be pleased to remove this 
> duplication/similarity if I can avoid this assertion.
I just got back into looking at this issue.  Given that I was unable to 
implement `!FPT->isNoThrow() && hasNoexcept(NewFW->getType())` without 
triggering an assertion (discussed in my reply immediately above), is there 
anything we should be doing differently here?  The change, as it sits now (with 
the duplication), seems to work fine.


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

https://reviews.llvm.org/D55039



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


[PATCH] D55413: [ExprConstant] Handle compound assignment when LHS has integral type and RHS has floating point type

2018-12-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:3453
   Value) &&
handleFloatFloatBinOp(Info, E, Value, Opcode, RHS.getFloat()) &&
HandleFloatToFloatCast(Info, E, PromotedLHSType, SubobjType, Value);

Does this work for the float += int case?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55413



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


[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p

2018-12-12 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

The issue is that "`n`" is expecting an immediate value, but the result of the 
ternary operator isn't calculated by the front-end, because it doesn't "know" 
that the evaluation of `__builtin_constant_p` shouldn't be delayed (it being 
compiled at `-O0`). I suspect that this issue will also happen with the "`i`" 
constraint.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54355



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


[PATCH] D53699: [ASTImporter] Fix inequality of functions with different attributes

2018-12-12 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: lib/AST/ASTStructuralEquivalence.cpp:302
+/// is inspired by ASTContext::mergeFunctionTypes(), we compare calling
+/// conventions bits but must not compare some other bits, e.g. the noreturn
+/// bit.

This comment is confusing b/c it looks like the noreturn bits are the only one 
you are not checking.



Comment at: unittests/AST/StructuralEquivalenceTest.cpp:373
 
+TEST_F(StructuralEquivalenceFunctionTest,
+FunctionsWithDifferentAttributesButSameTypesShouldBeEqual) {

Can we get some more tests to be a little more thorough and can we also get a 
test where it is expected to to be false as well?


Repository:
  rC Clang

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

https://reviews.llvm.org/D53699



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


[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-12-12 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Sounds good!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53755



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


r348950 - Change CallGraph print to show the fully qualified name

2018-12-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Dec 12 10:11:36 2018
New Revision: 348950

URL: http://llvm.org/viewvc/llvm-project?rev=348950=rev
Log:
Change CallGraph print to show the fully qualified name

CallGraph previously would just show the normal name of a function,
which gets really confusing when using it on large C++ projects.  This
patch switches the printName call to a printQualifiedName, so that the
namespaces are included.

Change-Id: Ie086d863f6b2251be92109ea1b0946825b28b49a

Modified:
cfe/trunk/lib/Analysis/CallGraph.cpp
cfe/trunk/test/Analysis/debug-CallGraph.cpp

Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=348950=348949=348950=diff
==
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Wed Dec 12 10:11:36 2018
@@ -212,7 +212,7 @@ void CallGraph::viewGraph() const {
 
 void CallGraphNode::print(raw_ostream ) const {
   if (const NamedDecl *ND = dyn_cast_or_null(FD))
-  return ND->printName(os);
+  return ND->printQualifiedName(os);
   os << "< >";
 }
 

Modified: cfe/trunk/test/Analysis/debug-CallGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/debug-CallGraph.cpp?rev=348950=348949=348950=diff
==
--- cfe/trunk/test/Analysis/debug-CallGraph.cpp (original)
+++ cfe/trunk/test/Analysis/debug-CallGraph.cpp Wed Dec 12 10:11:36 2018
@@ -51,6 +51,7 @@ void test_single_call() {
   do_nothing();
 }
 
+namespace SomeNS {
 template
 void templ(T t) {
   ccc();
@@ -61,17 +62,17 @@ void templ(double t) {
   eee();
 }
 
-
 void templUser() {
   templ(5);
   templ(5.5);
 }
+}
 
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call templ templ templUser $}}
-// CHECK-NEXT: {{Function: templUser calls: templ templ $}}
-// CHECK-NEXT: {{Function: templ calls: eee $}}
-// CHECK-NEXT: {{Function: templ calls: ccc $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ 
SomeNS::templUser $}}
+// CHECK-NEXT: {{Function: SomeNS::templUser calls: SomeNS::templ 
SomeNS::templ $}}
+// CHECK-NEXT: {{Function: SomeNS::templ calls: eee $}}
+// CHECK-NEXT: {{Function: SomeNS::templ calls: ccc $}}
 // CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}}
 // CHECK-NEXT: {{Function: do_nothing calls: $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}


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


[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

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

In D54862#1328290 , @mikael wrote:

> Seems like my this commit broke: 
> http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-buildserver/builds/33176
>
> But since I don't really know what anything about lldb, I probably won't be 
> able to fix it fast enough.
>
>   
> /lldb-buildbot/buildServerSlave/lldb-android-buildserver/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp:2208:24:
>  error: no viable overloaded '='
> proto_info.TypeQuals = type_quals;
>  ^ ~~
>   
> /lldb-buildbot/buildServerSlave/lldb-android-buildserver/llvm/tools/clang/include/clang/AST/Type.h:141:7:
>  note: candidate function (the implicit copy assignment operator) not viable: 
> no known conversion from 'unsigned int' to 'const clang::Qualifiers' for 1st 
> argument
>   class Qualifiers {
> ^
>   
> /lldb-buildbot/buildServerSlave/lldb-android-buildserver/llvm/tools/clang/include/clang/AST/Type.h:141:7:
>  note: candidate function (the implicit move assignment operator) not viable: 
> no known conversion from 'unsigned int' to 'clang::Qualifiers' for 1st 
> argument
>   1 error generated.
>
>
> I think it can be easily solved by Qualifiers::fromFastMask(type_quals); also 
> updating the variable name since it changed.


I think that's exactly what you need to do, and you'd be welcome to commit that 
instead of reverting this.




Comment at: lib/Index/USRGeneration.cpp:274
+if (unsigned quals = MD->getTypeQualifiers().getCVRUQualifiers())
   Out << (char)('0' + quals);
 switch (MD->getRefQualifier()) {

akyrtzi wrote:
> rjmccall wrote:
> > akyrtzi wrote:
> > > rjmccall wrote:
> > > > Paging @akyrtzi here.  The address-space qualifier should be part of 
> > > > the USR but I don't think if there's a defined schema for that.
> > > If I understand correctly from other comments you can't add special 
> > > mangling and USR generation yet and intend to add FIXME for doing 
> > > mangling support later ? If yes, could you also add FIXME here and 
> > > re-visit ?
> > While you're here, can you described the right way for us to extend USR 
> > generation here to potentially add an address space?
> I'm not familiar with the mechanism, is address space supposed to be 
> identified via a single integer ? If so, then I think adding '-' character 
> plus the integer as character for the address space, immediately after the 
> type qualifiers, should be a way to go.
Okay.  Some of them are integers; others are identified in the language as more 
of a keyword and so there's no stable mapping from an integer value.  Should we 
just come up with some simple schema for that following `-` that's unambiguous 
with a digit?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54862



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


[PATCH] D49281: [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.

2018-12-12 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348944: [Unroll/UnrollAndJam/Vectorizer/Distribute] Add 
followup loop attributes. (authored by Meinersbur, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49281?vs=177820=177870#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D49281

Files:
  test/Misc/backend-optimization-failure-nodbg.cpp
  test/Misc/backend-optimization-failure.cpp


Index: test/Misc/backend-optimization-failure.cpp
===
--- test/Misc/backend-optimization-failure.cpp
+++ test/Misc/backend-optimization-failure.cpp
@@ -7,7 +7,7 @@
 void test_switch(int *A, int *B, int Length,int J) {
 #pragma clang loop vectorize(enable) unroll(disable)
   for (int i = 0; i < Length; i++) {
-/* expected-warning@-1 {{loop not vectorized: failed explicitly specified loop 
vectorization}} */ switch (A[i]) {
+/* expected-warning@-1 {{loop not vectorized: the optimizer was unable to 
perform the requested transformation; the transformation might be disabled or 
specified as part of an unsupported transformation ordering}} */ switch (A[i]) {
 case 0:
   B[i] = 1;
   break;
Index: test/Misc/backend-optimization-failure-nodbg.cpp
===
--- test/Misc/backend-optimization-failure-nodbg.cpp
+++ test/Misc/backend-optimization-failure-nodbg.cpp
@@ -4,7 +4,7 @@
 // Test verifies optimization failures generated by the backend are handled
 // correctly by clang. LLVM tests verify all of the failure conditions.
 
-void test_switch(int *A, int *B, int Length, int J) { /* expected-warning 
{{loop not vectorized: failed explicitly specified loop vectorization}} */
+void test_switch(int *A, int *B, int Length, int J) { /* expected-warning 
{{loop not vectorized: the optimizer was unable to perform the requested 
transformation; the transformation might be disabled or specified as part of an 
unsupported transformation ordering}} */
 #pragma clang loop vectorize(enable) unroll(disable)
   for (int i = 0; i < Length; i++) {
 switch (A[i]) {


Index: test/Misc/backend-optimization-failure.cpp
===
--- test/Misc/backend-optimization-failure.cpp
+++ test/Misc/backend-optimization-failure.cpp
@@ -7,7 +7,7 @@
 void test_switch(int *A, int *B, int Length,int J) {
 #pragma clang loop vectorize(enable) unroll(disable)
   for (int i = 0; i < Length; i++) {
-/* expected-warning@-1 {{loop not vectorized: failed explicitly specified loop vectorization}} */ switch (A[i]) {
+/* expected-warning@-1 {{loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering}} */ switch (A[i]) {
 case 0:
   B[i] = 1;
   break;
Index: test/Misc/backend-optimization-failure-nodbg.cpp
===
--- test/Misc/backend-optimization-failure-nodbg.cpp
+++ test/Misc/backend-optimization-failure-nodbg.cpp
@@ -4,7 +4,7 @@
 // Test verifies optimization failures generated by the backend are handled
 // correctly by clang. LLVM tests verify all of the failure conditions.
 
-void test_switch(int *A, int *B, int Length, int J) { /* expected-warning {{loop not vectorized: failed explicitly specified loop vectorization}} */
+void test_switch(int *A, int *B, int Length, int J) { /* expected-warning {{loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering}} */
 #pragma clang loop vectorize(enable) unroll(disable)
   for (int i = 0; i < Length; i++) {
 switch (A[i]) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348944 - [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.

2018-12-12 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Wed Dec 12 09:32:52 2018
New Revision: 348944

URL: http://llvm.org/viewvc/llvm-project?rev=348944=rev
Log:
[Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.

When multiple loop transformation are defined in a loop's metadata, their order 
of execution is defined by the order of their respective passes in the pass 
pipeline. For instance, e.g.

#pragma clang loop unroll_and_jam(enable)
#pragma clang loop distribute(enable)

is the same as

#pragma clang loop distribute(enable)
#pragma clang loop unroll_and_jam(enable)

and will try to loop-distribute before Unroll-And-Jam because the 
LoopDistribute pass is scheduled after UnrollAndJam pass. UnrollAndJamPass only 
supports one inner loop, i.e. it will necessarily fail after loop distribution. 
It is not possible to specify another execution order. Also,t the order of 
passes in the pipeline is subject to change between versions of LLVM, 
optimization options and which pass manager is used.

This patch adds 'followup' attributes to various loop transformation passes. 
These attributes define which attributes the resulting loop of a transformation 
should have. For instance,

!0 = !{!0, !1, !2}
!1 = !{!"llvm.loop.unroll_and_jam.enable"}
!2 = !{!"llvm.loop.unroll_and_jam.followup_inner", !3}
!3 = !{!"llvm.loop.distribute.enable"}

defines a loop ID (!0) to be unrolled-and-jammed (!1) and then the attribute !3 
to be added to the jammed inner loop, which contains the instruction to 
distribute the inner loop.

Currently, in both pass managers, pass execution is in a fixed order and 
UnrollAndJamPass will not execute again after LoopDistribute. We hope to fix 
this in the future by allowing pass managers to run passes until a fixpoint is 
reached, use Polly to perform these transformations, or add a loop 
transformation pass which takes the order issue into account.

For mandatory/forced transformations (e.g. by having been declared by #pragma 
omp simd), the user must be notified when a transformation could not be 
performed. It is not possible that the responsible pass emits such a warning 
because the transformation might be 'hidden' in a followup attribute when it is 
executed, or it is not present in the pipeline at all. For this reason, this 
patche introduces a WarnMissedTransformations pass, to warn about orphaned 
transformations.

Since this changes the user-visible diagnostic message when a transformation is 
applied, two test cases in the clang repository need to be updated.

To ensure that no other transformation is executed before the intended one, the 
attribute `llvm.loop.disable_nonforced` can be added which should disable 
transformation heuristics before the intended transformation is applied. E.g. 
it would be surprising if a loop is distributed before a #pragma unroll_and_jam 
is applied.

With more supported code transformations (loop fusion, interchange, 
stripmining, offloading, etc.), transformations can be used as building blocks 
for more complex transformations (e.g. stripmining+stripmining+interchange -> 
tiling).

Reviewed By: hfinkel, dmgreen

Differential Revision: https://reviews.llvm.org/D49281
Differential Revision: https://reviews.llvm.org/D55288

Modified:
cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp
cfe/trunk/test/Misc/backend-optimization-failure.cpp

Modified: cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp?rev=348944=348943=348944=diff
==
--- cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp (original)
+++ cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp Wed Dec 12 
09:32:52 2018
@@ -4,7 +4,7 @@
 // Test verifies optimization failures generated by the backend are handled
 // correctly by clang. LLVM tests verify all of the failure conditions.
 
-void test_switch(int *A, int *B, int Length, int J) { /* expected-warning 
{{loop not vectorized: failed explicitly specified loop vectorization}} */
+void test_switch(int *A, int *B, int Length, int J) { /* expected-warning 
{{loop not vectorized: the optimizer was unable to perform the requested 
transformation; the transformation might be disabled or specified as part of an 
unsupported transformation ordering}} */
 #pragma clang loop vectorize(enable) unroll(disable)
   for (int i = 0; i < Length; i++) {
 switch (A[i]) {

Modified: cfe/trunk/test/Misc/backend-optimization-failure.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-optimization-failure.cpp?rev=348944=348943=348944=diff
==
--- cfe/trunk/test/Misc/backend-optimization-failure.cpp (original)
+++ cfe/trunk/test/Misc/backend-optimization-failure.cpp Wed Dec 12 09:32:52 
2018
@@ -7,7 +7,7 @@
 void 

[PATCH] D55525: [Driver] Add support for -fembed-bitcode for assembly file

2018-12-12 Thread Steven Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348943: [Driver] Add support for -fembed-bitcode for 
assembly file (authored by steven_wu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55525?vs=177563=177867#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55525

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/embed-bitcode.s
  tools/driver/cc1as_main.cpp

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -675,7 +675,7 @@
   Flags<[DriverOption]>;
 
 def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">,
-Group, Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
+Group, Flags<[DriverOption, CC1Option, CC1AsOption]>, MetaVarName<"">,
 HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">;
 def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group,
   Alias, AliasArgs<["all"]>,
Index: test/Driver/embed-bitcode.s
===
--- test/Driver/embed-bitcode.s
+++ test/Driver/embed-bitcode.s
@@ -0,0 +1,12 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode -### 2>&1 | FileCheck %s -check-prefix=CHECK-AS
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode-marker -### 2>&1 | FileCheck %s -check-prefix=CHECK-AS-MARKER
+// CHECK-AS: -cc1as
+// CHECK-AS: -fembed-bitcode=all
+// CHECK-AS-MARKER: -fembed-bitcode=marker
+
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode -o %t.o
+// RUN: llvm-readobj -section-headers %t.o | FileCheck --check-prefix=CHECK-SECTION %s
+// CHECK-SECTION: Name: __asm
+// CHECK-SECTION-NEXT: Segment: __LLVM
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2167,6 +2167,11 @@
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back(MipsTargetFeature);
   }
+
+  // forward -fembed-bitcode to assmebler
+  if (C.getDriver().embedBitcodeEnabled() ||
+  C.getDriver().embedBitcodeMarkerOnly())
+Args.AddLastArg(CmdArgs, options::OPT_fembed_bitcode_EQ);
 }
 
 static void RenderFloatingPointOptions(const ToolChain , const Driver ,
Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -33,6 +33,7 @@
 #include "llvm/MC/MCParser/MCAsmParser.h"
 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
 #include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCSectionMachO.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
@@ -132,6 +133,7 @@
   unsigned NoExecStack : 1;
   unsigned FatalWarnings : 1;
   unsigned IncrementalLinkerCompatible : 1;
+  unsigned EmbedBitcode : 1;
 
   /// The name of the relocation model to use.
   std::string RelocationModel;
@@ -153,6 +155,7 @@
 FatalWarnings = 0;
 IncrementalLinkerCompatible = 0;
 DwarfVersion = 0;
+EmbedBitcode = 0;
   }
 
   static bool CreateFromArgs(AssemblerInvocation ,
@@ -284,6 +287,16 @@
   Args.hasArg(OPT_mincremental_linker_compatible);
   Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
 
+  // EmbedBitcode Option. If -fembed-bitcode is enabled, set the flag.
+  // EmbedBitcode behaves the same for all embed options for assembly files.
+  if (auto *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
+Opts.EmbedBitcode = llvm::StringSwitch(A->getValue())
+.Case("all", 1)
+.Case("bitcode", 1)
+.Case("marker", 1)
+.Default(0);
+  }
+
   return Success;
 }
 
@@ -449,6 +462,16 @@
 Str.get()->InitSections(Opts.NoExecStack);
   }
 
+  // When -fembed-bitcode is passed to clang_as, a 1-byte marker
+  // is emitted in __LLVM,__asm section if the object file is MachO format.
+  if (Opts.EmbedBitcode && Ctx.getObjectFileInfo()->getObjectFileType() ==
+   MCObjectFileInfo::IsMachO) {
+MCSection *AsmLabel = Ctx.getMachOSection(
+"__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
+Str.get()->SwitchSection(AsmLabel);
+Str.get()->EmitZeros(1);
+  }
+
   // Assembly to object compilation should leverage assembly info.
   Str->setUseAssemblerInfoForParsing(true);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348943 - [Driver] Add support for -fembed-bitcode for assembly file

2018-12-12 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Wed Dec 12 09:30:16 2018
New Revision: 348943

URL: http://llvm.org/viewvc/llvm-project?rev=348943=rev
Log:
[Driver] Add support for -fembed-bitcode for assembly file

Summary:
Handle -fembed-bitcode for assembly inputs. When the input file is
assembly, write a marker as "__LLVM,__asm" section.

Fix llvm.org/pr39659

Reviewers: compnerd, dexonsmith

Reviewed By: compnerd

Subscribers: rjmccall, dblaikie, jkorous, cfe-commits

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

Added:
cfe/trunk/test/Driver/embed-bitcode.s
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=348943=348942=348943=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Dec 12 09:30:16 2018
@@ -675,7 +675,7 @@ def fno_coroutines_ts : Flag <["-"], "fn
   Flags<[DriverOption]>;
 
 def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">,
-Group, Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
+Group, Flags<[DriverOption, CC1Option, CC1AsOption]>, 
MetaVarName<"">,
 HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">;
 def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group,
   Alias, AliasArgs<["all"]>,

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=348943=348942=348943=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Dec 12 09:30:16 2018
@@ -2167,6 +2167,11 @@ static void CollectArgsForIntegratedAsse
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back(MipsTargetFeature);
   }
+
+  // forward -fembed-bitcode to assmebler
+  if (C.getDriver().embedBitcodeEnabled() ||
+  C.getDriver().embedBitcodeMarkerOnly())
+Args.AddLastArg(CmdArgs, options::OPT_fembed_bitcode_EQ);
 }
 
 static void RenderFloatingPointOptions(const ToolChain , const Driver ,

Added: cfe/trunk/test/Driver/embed-bitcode.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-bitcode.s?rev=348943=auto
==
--- cfe/trunk/test/Driver/embed-bitcode.s (added)
+++ cfe/trunk/test/Driver/embed-bitcode.s Wed Dec 12 09:30:16 2018
@@ -0,0 +1,12 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode -### 2>&1 | 
FileCheck %s -check-prefix=CHECK-AS
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode-marker -### 
2>&1 | FileCheck %s -check-prefix=CHECK-AS-MARKER
+// CHECK-AS: -cc1as
+// CHECK-AS: -fembed-bitcode=all
+// CHECK-AS-MARKER: -fembed-bitcode=marker
+
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode -o %t.o
+// RUN: llvm-readobj -section-headers %t.o | FileCheck 
--check-prefix=CHECK-SECTION %s
+// CHECK-SECTION: Name: __asm
+// CHECK-SECTION-NEXT: Segment: __LLVM

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=348943=348942=348943=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Wed Dec 12 09:30:16 2018
@@ -33,6 +33,7 @@
 #include "llvm/MC/MCParser/MCAsmParser.h"
 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
 #include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCSectionMachO.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
@@ -132,6 +133,7 @@ struct AssemblerInvocation {
   unsigned NoExecStack : 1;
   unsigned FatalWarnings : 1;
   unsigned IncrementalLinkerCompatible : 1;
+  unsigned EmbedBitcode : 1;
 
   /// The name of the relocation model to use.
   std::string RelocationModel;
@@ -153,6 +155,7 @@ public:
 FatalWarnings = 0;
 IncrementalLinkerCompatible = 0;
 DwarfVersion = 0;
+EmbedBitcode = 0;
   }
 
   static bool CreateFromArgs(AssemblerInvocation ,
@@ -284,6 +287,16 @@ bool AssemblerInvocation::CreateFromArgs
   Args.hasArg(OPT_mincremental_linker_compatible);
   Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
 
+  // EmbedBitcode Option. If -fembed-bitcode is enabled, set the flag.
+  // EmbedBitcode behaves the same for all embed options for assembly files.
+  if (auto *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
+Opts.EmbedBitcode = llvm::StringSwitch(A->getValue())
+.Case("all", 1)
+.Case("bitcode", 1)
+.Case("marker", 1)

r348942 - Make clang::CallGraph look into template instantiations

2018-12-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Dec 12 09:22:52 2018
New Revision: 348942

URL: http://llvm.org/viewvc/llvm-project?rev=348942=rev
Log:
Make clang::CallGraph look into template instantiations

Clang's CallGraph analysis doesn't use the RecursiveASTVisitor's setting
togo into template instantiations.  The result is that anything wanting
to do call graph analysis ends up missing any template function calls.

Change-Id: Ib4af44ed59f15d43f37af91622a203146a3c3189

Added:
cfe/trunk/test/Analysis/debug-CallGraph.cpp   (contents, props changed)
  - copied, changed from r348932, cfe/trunk/test/Analysis/debug-CallGraph.c
Removed:
cfe/trunk/test/Analysis/debug-CallGraph.c
Modified:
cfe/trunk/include/clang/Analysis/CallGraph.h

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=348942=348941=348942=diff
==
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Wed Dec 12 09:22:52 2018
@@ -131,6 +131,7 @@ public:
   bool TraverseStmt(Stmt *S) { return true; }
 
   bool shouldWalkTypesOfTypeLocs() const { return false; }
+  bool shouldVisitTemplateInstantiations() const { return true; }
 
 private:
   /// Add the given declaration to the call graph.

Removed: cfe/trunk/test/Analysis/debug-CallGraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/debug-CallGraph.c?rev=348941=auto
==
--- cfe/trunk/test/Analysis/debug-CallGraph.c (original)
+++ cfe/trunk/test/Analysis/debug-CallGraph.c (removed)
@@ -1,69 +0,0 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCallGraph %s -fblocks 
2>&1 | FileCheck %s
-
-int get5() {
-  return 5;
-}
-
-int add(int val1, int val2) {
-  return val1 + val2;
-}
-
-int test_add() {
-  return add(10, get5());
-}
-
-static void mmm(int y) {
-  if (y != 0)
-  y++;
-  y = y/y;
-}
-
-static int foo(int x, int y) {
-mmm(y);
-if (x != 0)
-  x++;
-return 5/x;
-}
-
-void aaa() {
-  foo(1,2);
-}
-
-void bbb(int y) {
-  int x = (y > 2);
-  ^ {
-  foo(x, y);
-  }();
-}
-void ccc();
-void ddd() { ccc(); }
-void ccc() {}
-
-void eee();
-void eee() {}
-void fff() { eee(); }
-
-// This test case tests that forward declaration for the top-level function
-// does not affect call graph construction.
-void do_nothing() {}
-void test_single_call();
-void test_single_call() {
-  do_nothing();
-}
-
-// CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call $}}
-// CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}}
-// CHECK-NEXT: {{Function: do_nothing calls: $}}
-// CHECK-NEXT: {{Function: fff calls: eee $}}
-// CHECK-NEXT: {{Function: eee calls: $}}
-// CHECK-NEXT: {{Function: ddd calls: ccc $}}
-// CHECK-NEXT: {{Function: ccc calls: $}}
-// CHECK-NEXT: {{Function: bbb calls: < > $}}
-// CHECK-NEXT: {{Function: < > calls: foo $}}
-// CHECK-NEXT: {{Function: aaa calls: foo $}}
-// CHECK-NEXT: {{Function: foo calls: mmm $}}
-// CHECK-NEXT: {{Function: mmm calls: $}}
-// CHECK-NEXT: {{Function: test_add calls: add get5 $}}
-// CHECK-NEXT: {{Function: add calls: $}}
-// CHECK-NEXT: {{Function: get5 calls: $}}

Copied: cfe/trunk/test/Analysis/debug-CallGraph.cpp (from r348932, 
cfe/trunk/test/Analysis/debug-CallGraph.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/debug-CallGraph.cpp?p2=cfe/trunk/test/Analysis/debug-CallGraph.cpp=cfe/trunk/test/Analysis/debug-CallGraph.c=348932=348942=348942=diff
==
--- cfe/trunk/test/Analysis/debug-CallGraph.c (original)
+++ cfe/trunk/test/Analysis/debug-CallGraph.cpp Wed Dec 12 09:22:52 2018
@@ -51,8 +51,27 @@ void test_single_call() {
   do_nothing();
 }
 
+template
+void templ(T t) {
+  ccc();
+}
+
+template<>
+void templ(double t) {
+  eee();
+}
+
+
+void templUser() {
+  templ(5);
+  templ(5.5);
+}
+
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call templ templ templUser $}}
+// CHECK-NEXT: {{Function: templUser calls: templ templ $}}
+// CHECK-NEXT: {{Function: templ calls: eee $}}
+// CHECK-NEXT: {{Function: templ calls: ccc $}}
 // CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}}
 // CHECK-NEXT: {{Function: do_nothing calls: $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}

Propchange: cfe/trunk/test/Analysis/debug-CallGraph.cpp
--
svn:eol-style = native

Propchange: 

[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

2018-12-12 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: include/clang/AST/Type.h:3692
   FunctionType::ExceptionType, Expr *, FunctionDecl *,
-  FunctionType::ExtParameterInfo> {
   friend class ASTContext; // ASTContext creates these.

You can use `FunctionType::FunctionTypeExtraBitfields`
to store the qualifiers. It was designed to store extra data.
No need to add yet another trailing object.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54862



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


[PATCH] D55552: [Sema] Better static assert diagnostics for expressions involving temporaries.

2018-12-12 Thread Clement Courbet via Phabricator via cfe-commits
courbet planned changes to this revision.
courbet marked an inline comment as done.
courbet added inline comments.



Comment at: test/SemaCXX/static-assert.cpp:136
+static_assert(std::is_const::value, "message");
+// expected-error@-1{{static_assert failed due to requirement 
'std::is_const::value' "message"}}
 

Quuxplusone wrote:
> Conspicuously missing any test for lines 3081–3106 above. IIUC, those lines 
> would trigger on things like
> 
> ```
> template struct X { int i=0, j=0; constexpr operator bool() const { 
> return false; } };
> template void test() {
> static_assert(X{});
> static_assert(X{1,2});
> static_assert(T{0});
> static_assert(T(0));
> }
> template void test();
> ```
> 
> But I guess I don't see why extra code is needed to handle those; shouldn't 
> the pretty-printer handle them already? What do the current diagnostics look 
> like for my example?
Note: Your examples are `CXXFunctionalCastExpr`, and 
`CXXUnresolvedConstructExpr` respectively, not `CXXTemporaryObjectExpr`, so 
they are not handled by this change.

They are correctly printed before this change with `T==int`.

The issue comes when adding an extra layer of indirection:

```
struct ExampleTypes {
  explicit ExampleTypes(int);
  using T = int;
  using U = float;
};

template struct X {
  int i=0;
  int j=0;
  constexpr operator bool() const { return false; }
};

template void foo6() {
static_assert(X());
static_assert(X{});
static_assert(X{1,2});
static_assert(X({1,2}));
static_assert(typename T::T{0});
static_assert(typename T::T(0));
}
template void foo6();
```

The errors before the change are:
```
File 
/usr/local/google/home/courbet/llvm/llvm/tools/clang/test/SemaCXX/static-assert-cxx17.cpp
 Line 71: static_assert failed due to requirement 'X()'
  File 
/usr/local/google/home/courbet/llvm/llvm/tools/clang/test/SemaCXX/static-assert-cxx17.cpp
 Line 72: static_assert failed due to requirement 'X{}'
  File 
/usr/local/google/home/courbet/llvm/llvm/tools/clang/test/SemaCXX/static-assert-cxx17.cpp
 Line 73: static_assert failed due to requirement 'X{1, 2}'
  File 
/usr/local/google/home/courbet/llvm/llvm/tools/clang/test/SemaCXX/static-assert-cxx17.cpp
 Line 74: static_assert failed due to requirement 'X({1, 2})'
  File 
/usr/local/google/home/courbet/llvm/llvm/tools/clang/test/SemaCXX/static-assert-cxx17.cpp
 Line 75: static_assert failed due to requirement 'typename ExampleTypes::T{0}'
  File 
/usr/local/google/home/courbet/llvm/llvm/tools/clang/test/SemaCXX/static-assert-cxx17.cpp
 Line 76: static_assert failed due to requirement 'typename ExampleTypes::T(0)'
```

I must admit that I did not think of handling these, and now I think it would 
actually be better to tap into the pretty printer to avoid code duplication. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D2



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


[PATCH] D55586: Basic: make `int_least64_t` and `int_fast64_t` match on Darwin

2018-12-12 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r348939


Repository:
  rC Clang

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

https://reviews.llvm.org/D55586



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


r348939 - Basic: make `int_least64_t` and `int_fast64_t` match on Darwin

2018-12-12 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Dec 12 09:05:20 2018
New Revision: 348939

URL: http://llvm.org/viewvc/llvm-project?rev=348939=rev
Log:
Basic: make `int_least64_t` and `int_fast64_t` match on Darwin

The Darwin targets use `int64_t` and `uint64_t` to define the `int_least64_t`
and `int_fast64_t` types.  The underlying type is actually a `long long`.  Match
the types to allow the printf specifiers to work properly and have the compiler
vended macros match the implementation on the target.

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=348939=348938=348939=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Wed Dec 12 09:05:20 2018
@@ -133,6 +133,15 @@ public:
   /// is very similar to ELF's "protected";  Darwin requires a "weak"
   /// attribute on declarations that can be dynamically replaced.
   bool hasProtectedVisibility() const override { return false; }
+
+  TargetInfo::IntType getLeastIntTypeByWidth(unsigned BitWidth,
+ bool IsSigned) const final {
+// Darwin uses `long long` for `int_least64_t` and `int_fast64_t`.
+return BitWidth == 64
+   ? (IsSigned ? TargetInfo::SignedLongLong
+   : TargetInfo::UnsignedLongLong)
+   : TargetInfo::getLeastIntTypeByWidth(BitWidth, IsSigned);
+  }
 };
 
 // DragonFlyBSD Target

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=348939=348938=348939=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Dec 12 09:05:20 2018
@@ -1331,10 +1331,10 @@
 // AARCH64-DARWIN: #define __INT_FAST32_FMTi__ "i"
 // AARCH64-DARWIN: #define __INT_FAST32_MAX__ 2147483647
 // AARCH64-DARWIN: #define __INT_FAST32_TYPE__ int
-// AARCH64-DARWIN: #define __INT_FAST64_FMTd__ "ld"
-// AARCH64-DARWIN: #define __INT_FAST64_FMTi__ "li"
-// AARCH64-DARWIN: #define __INT_FAST64_MAX__ 9223372036854775807L
-// AARCH64-DARWIN: #define __INT_FAST64_TYPE__ long int
+// AARCH64-DARWIN: #define __INT_FAST64_FMTd__ "lld"
+// AARCH64-DARWIN: #define __INT_FAST64_FMTi__ "lli"
+// AARCH64-DARWIN: #define __INT_FAST64_MAX__ 9223372036854775807LL
+// AARCH64-DARWIN: #define __INT_FAST64_TYPE__ long long int
 // AARCH64-DARWIN: #define __INT_FAST8_FMTd__ "hhd"
 // AARCH64-DARWIN: #define __INT_FAST8_FMTi__ "hhi"
 // AARCH64-DARWIN: #define __INT_FAST8_MAX__ 127
@@ -1347,10 +1347,10 @@
 // AARCH64-DARWIN: #define __INT_LEAST32_FMTi__ "i"
 // AARCH64-DARWIN: #define __INT_LEAST32_MAX__ 2147483647
 // AARCH64-DARWIN: #define __INT_LEAST32_TYPE__ int
-// AARCH64-DARWIN: #define __INT_LEAST64_FMTd__ "ld"
-// AARCH64-DARWIN: #define __INT_LEAST64_FMTi__ "li"
-// AARCH64-DARWIN: #define __INT_LEAST64_MAX__ 9223372036854775807L
-// AARCH64-DARWIN: #define __INT_LEAST64_TYPE__ long int
+// AARCH64-DARWIN: #define __INT_LEAST64_FMTd__ "lld"
+// AARCH64-DARWIN: #define __INT_LEAST64_FMTi__ "lli"
+// AARCH64-DARWIN: #define __INT_LEAST64_MAX__ 9223372036854775807LL
+// AARCH64-DARWIN: #define __INT_LEAST64_TYPE__ long long int
 // AARCH64-DARWIN: #define __INT_LEAST8_FMTd__ "hhd"
 // AARCH64-DARWIN: #define __INT_LEAST8_FMTi__ "hhi"
 // AARCH64-DARWIN: #define __INT_LEAST8_MAX__ 127
@@ -1418,16 +1418,16 @@
 // AARCH64-DARWIN: #define __UINT_FAST16_TYPE__ unsigned short
 // AARCH64-DARWIN: #define __UINT_FAST32_MAX__ 4294967295U
 // AARCH64-DARWIN: #define __UINT_FAST32_TYPE__ unsigned int
-// AARCH64-DARWIN: #define __UINT_FAST64_MAX__ 18446744073709551615UL
-// AARCH64-DARWIN: #define __UINT_FAST64_TYPE__ long unsigned int
+// AARCH64-DARWIN: #define __UINT_FAST64_MAX__ 18446744073709551615ULL
+// AARCH64-DARWIN: #define __UINT_FAST64_TYPE__ long long unsigned int
 // AARCH64-DARWIN: #define __UINT_FAST8_MAX__ 255
 // AARCH64-DARWIN: #define __UINT_FAST8_TYPE__ unsigned char
 // AARCH64-DARWIN: #define __UINT_LEAST16_MAX__ 65535
 // AARCH64-DARWIN: #define __UINT_LEAST16_TYPE__ unsigned short
 // AARCH64-DARWIN: #define __UINT_LEAST32_MAX__ 4294967295U
 // AARCH64-DARWIN: #define __UINT_LEAST32_TYPE__ unsigned int
-// AARCH64-DARWIN: #define __UINT_LEAST64_MAX__ 18446744073709551615UL
-// AARCH64-DARWIN: #define __UINT_LEAST64_TYPE__ long unsigned int
+// AARCH64-DARWIN: #define __UINT_LEAST64_MAX__ 18446744073709551615ULL
+// AARCH64-DARWIN: #define __UINT_LEAST64_TYPE__ long long unsigned int
 // AARCH64-DARWIN: #define __UINT_LEAST8_MAX__ 255
 // AARCH64-DARWIN: #define __UINT_LEAST8_TYPE__ unsigned char
 // AARCH64-DARWIN: #define __USER_LABEL_PREFIX__ _


___
cfe-commits 

[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check

2018-12-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/abseil-duration-subtraction.cpp:12
+  // CHECK-FIXES: absl::ToDoubleSeconds(d - absl::Seconds(1))
+  x = absl::ToDoubleSeconds(d) - absl::ToDoubleSeconds(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the 
duration domain [abseil-duration-subtraction]

hwright wrote:
> JonasToth wrote:
> > hwright wrote:
> > > JonasToth wrote:
> > > > From this example starting:
> > > > 
> > > > - The RHS should be a nested expression with function calls, as the RHS 
> > > > is transformed to create the adversary example i mean in the 
> > > > transformation function above.
> > > > 
> > > > ```
> > > > absl::ToDoubleSeconds(d) - 
> > > > absl::ToDoubleSeconds(absl::ToDoubleSeconds(d) - 
> > > > absl::ToDoubleSeconds(d1));
> > > > ```
> > > > I think you need the proper conversion function, as the result of the 
> > > > expression is `double` and you need a `Duration`, right?
> > > > 
> > > > But in principle starting from this idea the transformation might break.
> > > I think there may be some confusion here (and that's entirely my fault. 
> > > :) )
> > > 
> > > We should never get this expression as input to the check, since it 
> > > doesn't compile (as you point out):
> > > ```
> > > absl::ToDoubleSeconds(d) - absl::ToDoubleSeconds(absl::ToDoubleSeconds(d) 
> > > - absl::ToDoubleSeconds(d1));
> > > ```
> > > 
> > > Since `absl::ToDoubleSeconds` requires that its argument is an 
> > > `absl::Duration`, but the expression `absl::ToDoubleSeconds(d) - 
> > > absl::ToDoubleSeconds(d1)` results in a `double`, we can't get this as 
> > > input.
> > > 
> > > There may be other expressions which could be input, but in practice they 
> > > don't really happen.  I've added a contrived example to the tests, but at 
> > > some point the tests get too complex and confuse the fix matching 
> > > infrastructure.
> > Your last sentence is the thing ;) Murphies Law will hit this check, too. 
> > In my opinion wrong transformations are very unfortunate and should be 
> > avoided if possible (in this case possible).
> > You can simply require that the expression of type double does not contain 
> > any duration subtraction calls.
> > 
> > This is even possible in the matcher-part of the check.
> I've written a test (which the testing infrastructure fails to handle well, 
> so I haven't included it in the diff), and it produces these results:
> 
> ```
>//
>//
> -  x = absl::ToDoubleSeconds(d) - (absl::ToDoubleSeconds(d1) - 5);
> +  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1) - 
> 5));
>//
>//
> -  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1) - 
> 5));
> +  x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1 - 
> absl::Seconds(5;
> ```
> 
> Those results are correct.  There is a cosmetic issue of round tripping 
> through the `double` conversion in the 
> `absl::Seconds(absl::ToDoubleSeconds(...))` phrase, but untangling that is 1) 
> difficult (because of order of operations issues) and thus; 2) probably the 
> subject of a separate check.
> 
> This is still such a rare case (as in, we've not encountered it in Google's 
> codebase), that I'm not really concerned.  But if it's worth it to explicitly 
> exclude it from the traversal matcher, I can do that.
Can you say what the direct issue is? I would bet its the overlapping?
A note in the documentation would be ok from my side. When the conflicting 
transformations are tried to be applied clang-tidy does not crash but print a 
nice diagnostic and continue its life?


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

https://reviews.llvm.org/D55245



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


[PATCH] D55510: [ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element types

2018-12-12 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hubert.reinterpretcast marked an inline comment as done.
Closed by commit rL348938: [ExprConstant] Improve memchr/memcmp for type 
mismatch and multibyte element… (authored by hubert.reinterpretcast, committed 
by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55510

Files:
  cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/test/SemaCXX/constexpr-string.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
@@ -121,6 +121,8 @@
   "read of non-const variable %0 is not allowed in a constant expression">;
 def note_constexpr_ltor_non_constexpr : Note<
   "read of non-constexpr variable %0 is not allowed in a constant expression">;
+def note_constexpr_ltor_incomplete_type : Note<
+  "read of incomplete type %0 is not allowed in a constant expression">;
 def note_constexpr_access_null : Note<
   "%select{read of|assignment to|increment of|decrement of}0 "
   "dereferenced null pointer is not allowed in a constant expression">;
Index: cfe/trunk/test/SemaCXX/constexpr-string.cpp
===
--- cfe/trunk/test/SemaCXX/constexpr-string.cpp
+++ cfe/trunk/test/SemaCXX/constexpr-string.cpp
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++1z -fsyntax-only -verify -pedantic
-// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++1z -fsyntax-only -verify -pedantic -fno-signed-char
-// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++1z -fsyntax-only -verify -pedantic -fno-wchar -Dwchar_t=__WCHAR_TYPE__
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-signed-char
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-wchar -DNO_PREDEFINED_WCHAR_T
+// RUN: %clang_cc1 %s -triple armebv7-unknown-linux -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension
+// RUN: %clang_cc1 %s -triple armebv7-unknown-linux -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-signed-char
+// RUN: %clang_cc1 %s -triple armebv7-unknown-linux -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-wchar -DNO_PREDEFINED_WCHAR_T
 
-# 6 "/usr/include/string.h" 1 3 4
+# 9 "/usr/include/string.h" 1 3 4
 extern "C" {
   typedef decltype(sizeof(int)) size_t;
 
@@ -18,10 +21,13 @@
   extern void *memcpy(void *d, const void *s, size_t n);
   extern void *memmove(void *d, const void *s, size_t n);
 }
-# 22 "SemaCXX/constexpr-string.cpp" 2
+# 25 "SemaCXX/constexpr-string.cpp" 2
 
-# 24 "/usr/include/wchar.h" 1 3 4
+# 27 "/usr/include/wchar.h" 1 3 4
 extern "C" {
+#if NO_PREDEFINED_WCHAR_T
+  typedef decltype(L'0') wchar_t;
+#endif
   extern size_t wcslen(const wchar_t *p);
 
   extern int wcscmp(const wchar_t *s1, const wchar_t *s2);
@@ -35,7 +41,7 @@
   extern wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n);
 }
 
-# 39 "SemaCXX/constexpr-string.cpp" 2
+# 45 "SemaCXX/constexpr-string.cpp" 2
 namespace Strlen {
   constexpr int n = __builtin_strlen("hello"); // ok
   static_assert(n == 5);
@@ -95,11 +101,142 @@
   static_assert(__builtin_memcmp("abab\0banana", "abab\0canada", 6) == -1);
   static_assert(__builtin_memcmp("abab\0banana", "abab\0canada", 5) == 0);
 
+  extern struct Incomplete incomplete;
+  static_assert(__builtin_memcmp(, "", 0u) == 0);
+  static_assert(__builtin_memcmp("", , 0u) == 0);
+  static_assert(__builtin_memcmp(, "", 1u) == 42); // expected-error {{not an integral constant}} expected-note {{read of incomplete type 'struct Incomplete'}}
+  static_assert(__builtin_memcmp("", , 1u) == 42); // expected-error {{not an integral constant}} expected-note {{read of incomplete type 'struct Incomplete'}}
+
+  constexpr unsigned char ku00fe00[] = {0x00, 0xfe, 0x00};
+  constexpr unsigned char ku00feff[] = {0x00, 0xfe, 0xff};
+  constexpr signed char ks00fe00[] = {0, -2, 0};
+  constexpr signed char ks00feff[] = {0, -2, -1};
+  static_assert(__builtin_memcmp(ku00feff, ks00fe00, 2) == 0);
+  static_assert(__builtin_memcmp(ku00feff, ks00fe00, 99) == 1);
+  static_assert(__builtin_memcmp(ku00fe00, ks00feff, 99) == -1);
+  static_assert(__builtin_memcmp(ks00feff, ku00fe00, 2) == 0);
+  static_assert(__builtin_memcmp(ks00feff, ku00fe00, 99) == 1);
+  static_assert(__builtin_memcmp(ks00fe00, ku00feff, 99) == -1);
+  static_assert(__builtin_memcmp(ks00fe00, ks00feff, 2) == 0);
+  static_assert(__builtin_memcmp(ks00feff, ks00fe00, 99) == 1);
+  

r348938 - [ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element types

2018-12-12 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed Dec 12 08:53:43 2018
New Revision: 348938

URL: http://llvm.org/viewvc/llvm-project?rev=348938=rev
Log:
[ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element 
types

Summary:
`memchr` and `memcmp` operate upon the character units of the object
representation; that is, the `size_t` parameter expresses the number of
character units. The constant folding implementation is updated in this
patch to account for multibyte element types in the arrays passed to
`memchr`/`memcmp` and, in the case of `memcmp`, to account for the
possibility that the arrays may have differing element types (even when
they are byte-sized).

Actual inspection of the object representation is not implemented.
Comparisons are done only between elements with the same object size;
that is, `memchr` will fail when inspecting at least one character unit
of a multibyte element. The integer types are assumed to have two's
complement representation with 0 for `false`, 1 for `true`, and no
padding bits.

`memcmp` on multibyte elements will only be able to fold in cases where
enough elements are equal for the answer to be 0.

Various tests are added to guard against incorrect folding for cases
that miscompile on some system or other prior to this patch. At the same
time, the unsigned 32-bit `wchar_t` testing in
`test/SemaCXX/constexpr-string.cpp` is restored.

Reviewers: rsmith, aaron.ballman, hfinkel

Reviewed By: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constexpr-string.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=348938=348937=348938=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Wed Dec 12 08:53:43 2018
@@ -121,6 +121,8 @@ def note_constexpr_ltor_non_const_int :
   "read of non-const variable %0 is not allowed in a constant expression">;
 def note_constexpr_ltor_non_constexpr : Note<
   "read of non-constexpr variable %0 is not allowed in a constant expression">;
+def note_constexpr_ltor_incomplete_type : Note<
+  "read of incomplete type %0 is not allowed in a constant expression">;
 def note_constexpr_access_null : Note<
   "%select{read of|assignment to|increment of|decrement of}0 "
   "dereferenced null pointer is not allowed in a constant expression">;

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=348938=348937=348938=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Dec 12 08:53:43 2018
@@ -1290,6 +1290,14 @@ void EvalInfo::addCallStack(unsigned Lim
   }
 }
 
+/// Kinds of access we can perform on an object, for diagnostics.
+enum AccessKinds {
+  AK_Read,
+  AK_Assign,
+  AK_Increment,
+  AK_Decrement
+};
+
 namespace {
   struct ComplexValue {
   private:
@@ -1395,21 +1403,36 @@ namespace {
   set(B, true);
 }
 
+  private:
 // Check that this LValue is not based on a null pointer. If it is, produce
 // a diagnostic and mark the designator as invalid.
-bool checkNullPointer(EvalInfo , const Expr *E,
-  CheckSubobjectKind CSK) {
+template 
+bool checkNullPointerDiagnosingWith(const GenDiagType ) {
   if (Designator.Invalid)
 return false;
   if (IsNullPtr) {
-Info.CCEDiag(E, diag::note_constexpr_null_subobject)
-  << CSK;
+GenDiag();
 Designator.setInvalid();
 return false;
   }
   return true;
 }
 
+  public:
+bool checkNullPointer(EvalInfo , const Expr *E,
+  CheckSubobjectKind CSK) {
+  return checkNullPointerDiagnosingWith([, E, CSK] {
+Info.CCEDiag(E, diag::note_constexpr_null_subobject) << CSK;
+  });
+}
+
+bool checkNullPointerForFoldAccess(EvalInfo , const Expr *E,
+   AccessKinds AK) {
+  return checkNullPointerDiagnosingWith([, E, AK] {
+Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
+  });
+}
+
 // Check this LValue refers to an object. If not, set the designator to be
 // invalid and emit a diagnostic.
 bool checkSubobject(EvalInfo , const Expr *E, CheckSubobjectKind CSK) 
{
@@ -2746,14 +2769,6 @@ static bool diagnoseUnreadableFields(Eva
   return false;
 }
 
-/// Kinds of access we can perform on an object, for diagnostics.
-enum AccessKinds {
-  AK_Read,
-  AK_Assign,
-  AK_Increment,
-  AK_Decrement
-};
-
 namespace {
 /// A handle to a complete object (an 

[PATCH] D55410: [clang-tidy] check for flagging using declarations in headers

2018-12-12 Thread Shyan Akmal via Phabricator via cfe-commits
Naysh marked an inline comment as done.
Naysh added inline comments.



Comment at: docs/clang-tidy/checks/abseil-alias-free-headers.rst:13
+The style guide  http://google.github.io/styleguide/cppguide.html#Aliases 
discusses this
+issue in more detail

aaron.ballman wrote:
> Eugene.Zelenko wrote:
> > Naysh wrote:
> > > Eugene.Zelenko wrote:
> > > > Missing link to guidelines,
> > > @Eugene.Zelenko: Sorry, I'm not sure what you mean. Could you clarify 
> > > what guidelines you're referring to? 
> > Please see documentation in other using-related checks.
> I think he's talking about the fact that this is text and not a hyperlink. It 
> should look something more like
> ```
> The `Abseil Style Guide 
> `_ discusses this 
> issue in more detail.
> ```
Ah okay, that makes sense. Thanks for your help!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55410



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


[PATCH] D55482: [clang-tidy] Improve google-objc-function-naming diagnostics 

2018-12-12 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/google/FunctionNamingCheck.cpp:115
   diag(MatchedDecl->getLocation(),
-   "function name %0 not using function naming conventions described by "
-   "Google Objective-C style guide")
-  << MatchedDecl << generateFixItHint(MatchedDecl);
+   "%select{static|global}1 function name %0 must %select{be in|have an "
+   "appropriate prefix followed by}1 Pascal case as required by Google "

stephanemoore wrote:
> aaron.ballman wrote:
> > stephanemoore wrote:
> > > benhamilton wrote:
> > > > I know "global" is the correct name, but I feel like "non-static" might 
> > > > be clearer to folks dealing with these error messages.
> > > > 
> > > > WDYT?
> > > > 
> > > I'm wary of saying "non-static" because namespaced functions in 
> > > Objective-C++ are not subject to the cited rules. The term "non-static" 
> > > seems like it could be interpreted to extend to namespaced functions 
> > > which could potentially mislead someone into adding prefixes to 
> > > namespaced functions in Objective-C++.
> > How about "%select{static function|function in global namespace}1 named 
> > %0..."
> Definitely better.
Yeah, this is better. Thanks.


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

https://reviews.llvm.org/D55482



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


[PATCH] D55270: [Sema] Further improvements to to static_assert diagnostics.

2018-12-12 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

I agree. I'll have a look at it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55270



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


[PATCH] D55595: [clang-tidy] Share the forced linking code between clang-tidy tool and plugin

2018-12-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D55595#1328263 , @steveire wrote:

> Can you say where else it is common in LLVM? I'm curious. Maybe those places 
> could be changed too.


My "is common" is not quantified, I have seen it before :)

From grepping "extern volatile":

- clang-tidy a lot
- clang/lib/Tooling/CompilationDatabase.cpp:398
- clang/lib/Tooling/Execution.cpp:100
- clang/tools/libclang/CIndex.cpp:8681
- clang/tools/libclang/CIndex.cpp:8675

Thats probably all places or is same idiom implementable with something else?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55595



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


[PATCH] D52418: [driver][mips] Enable integrated assembler for MIPS64 except N32 ABI selected

2018-12-12 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan abandoned this revision.
atanasyan added a comment.

Commits rL348934  and rL348935 
 enable using of integrated assembler for 
MIPS targets in all cases.


Repository:
  rC Clang

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

https://reviews.llvm.org/D52418



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


r348935 - [mips] Enable using of integrated assembler in all cases.

2018-12-12 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Wed Dec 12 07:32:25 2018
New Revision: 348935

URL: http://llvm.org/viewvc/llvm-project?rev=348935=rev
Log:
[mips] Enable using of integrated assembler in all cases.

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=348935=348934=348935=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Dec 12 07:32:25 2018
@@ -2472,18 +2472,9 @@ bool Generic_GCC::IsIntegratedAssemblerD
   case llvm::Triple::systemz:
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
-return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-// Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they
-// can precisely identify the ABI in use (Debian) or only use N64 for 
MIPS64
-// (Android). Other targets are unable to distinguish N32 from N64.
-if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
-getTriple().isAndroid() ||
-getTriple().isOSFreeBSD() ||
-getTriple().isOSOpenBSD())
-  return true;
-return false;
+return true;
   default:
 return false;
   }


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


r348932 - Remove TODO leftover from my devleopment branch

2018-12-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Dec 12 07:13:00 2018
New Revision: 348932

URL: http://llvm.org/viewvc/llvm-project?rev=348932=rev
Log:
Remove TODO leftover from my devleopment branch

Accidentially checked in a TODO line from r348899. This removes it.

Change-Id: I74b59c0ecfe147af8a08dd7fd10893a4ca351d6d

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

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=348932=348931=348932=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec 12 07:13:00 2018
@@ -8,7 +8,6 @@ static void DiagnoseRecursiveConstFields
   std::vector RecordTypeList;
   RecordTypeList.push_back(Ty);
   unsigned NextToCheckIndex = 0;
-  // TODO: MAKE THIS NOT RECURSIVE
   // We walk the record hierarchy breadth-first to ensure that we print
   // diagnostics in field nesting order.
   while (RecordTypeList.size() > NextToCheckIndex) {


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


[PATCH] D55527: Normalize GlobalDecls when used with CPUDispatch

2018-12-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 177853.
erichkeane added a comment.

As mentioned, the @rsmith comments that I thought were doable without feedback.


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

https://reviews.llvm.org/D55527

Files:
  include/clang/AST/GlobalDecl.h
  include/clang/Basic/Attr.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/attr-cpuspecific.c

Index: test/CodeGen/attr-cpuspecific.c
===
--- test/CodeGen/attr-cpuspecific.c
+++ test/CodeGen/attr-cpuspecific.c
@@ -29,21 +29,7 @@
 
 ATTR(cpu_dispatch(ivybridge, knl))
 void TwoVersions(void);
-// LINUX: define void ()* @TwoVersions.resolver()
-// LINUX: call void @__cpu_indicator_init
-// LINUX: ret void ()* @TwoVersions.Z
-// LINUX: ret void ()* @TwoVersions.S
-// LINUX: call void @llvm.trap
-// LINUX: unreachable
-
-// WINDOWS: define dso_local void @TwoVersions()
-// WINDOWS: call void @__cpu_indicator_init()
-// WINDOWS: call void @TwoVersions.Z()
-// WINDOWS-NEXT: ret void
-// WINDOWS: call void @TwoVersions.S()
-// WINDOWS-NEXT: ret void
-// WINDOWS: call void @llvm.trap
-// WINDOWS: unreachable
+// Resolvers are emitted at the end, so the check lines are at the bottom.
 
 ATTR(cpu_specific(ivybridge))
 void TwoVersions(void){}
@@ -82,6 +68,59 @@
 // has an extra config to emit!
 ATTR(cpu_dispatch(ivybridge, knl, atom))
 void TwoVersionsSameAttr(void);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_dispatch(atom, ivybridge, knl))
+void ThreeVersionsSameAttr(void){}
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+// No Cpu Specific options.
+ATTR(cpu_dispatch(atom, ivybridge, knl))
+void NoSpecifics(void);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_dispatch(atom, generic, ivybridge, knl))
+void HasGeneric(void);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_dispatch(atom, generic, ivybridge, knl))
+void HasParams(int i, double d);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_dispatch(atom, generic, ivybridge, knl))
+int HasParamsAndReturn(int i, double d);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_dispatch(atom, generic, pentium))
+int GenericAndPentium(int i, double d);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_dispatch(atom, pentium))
+int DispatchFirst(void);
+// Resolvers are emitted at the end, so the check lines are at the bottom.
+
+ATTR(cpu_specific(atom))
+int DispatchFirst(void) {return 0;}
+ATTR(cpu_specific(pentium))
+int DispatchFirst(void) {return 1;}
+// Resolver emit causes these to be emited, so they happen later.
+
+// LINUX: define void ()* @TwoVersions.resolver()
+// LINUX: call void @__cpu_indicator_init
+// LINUX: ret void ()* @TwoVersions.Z
+// LINUX: ret void ()* @TwoVersions.S
+// LINUX: call void @llvm.trap
+// LINUX: unreachable
+
+// WINDOWS: define dso_local void @TwoVersions()
+// WINDOWS: call void @__cpu_indicator_init()
+// WINDOWS: call void @TwoVersions.Z()
+// WINDOWS-NEXT: ret void
+// WINDOWS: call void @TwoVersions.S()
+// WINDOWS-NEXT: ret void
+// WINDOWS: call void @llvm.trap
+// WINDOWS: unreachable
+
 // LINUX: define void ()* @TwoVersionsSameAttr.resolver()
 // LINUX: ret void ()* @TwoVersionsSameAttr.Z
 // LINUX: ret void ()* @TwoVersionsSameAttr.S
@@ -99,8 +138,6 @@
 // WINDOWS: call void @llvm.trap
 // WINDOWS: unreachable
 
-ATTR(cpu_dispatch(atom, ivybridge, knl))
-void ThreeVersionsSameAttr(void){}
 // LINUX: define void ()* @ThreeVersionsSameAttr.resolver()
 // LINUX: call void @__cpu_indicator_init
 // LINUX: ret void ()* @ThreeVersionsSameAttr.Z
@@ -120,9 +157,16 @@
 // WINDOWS: call void @llvm.trap
 // WINDOWS: unreachable
 
-// No Cpu Specific options.
-ATTR(cpu_dispatch(atom, ivybridge, knl))
-void NoSpecifics(void);
+// LINUX: define i32 @DispatchFirst.O
+// LINUX: ret i32 0
+// LINUX: define i32 @DispatchFirst.B
+// LINUX: ret i32 1
+
+// WINDOWS: define dso_local i32 @DispatchFirst.O()
+// WINDOWS: ret i32 0
+// WINDOWS: define dso_local i32 @DispatchFirst.B
+// WINDOWS: ret i32 1
+
 // LINUX: define void ()* @NoSpecifics.resolver()
 // LINUX: call void @__cpu_indicator_init
 // LINUX: ret void ()* @NoSpecifics.Z
@@ -142,8 +186,6 @@
 // WINDOWS: call void @llvm.trap
 // WINDOWS: unreachable
 
-ATTR(cpu_dispatch(atom, generic, ivybridge, knl))
-void HasGeneric(void);
 // LINUX: define void ()* @HasGeneric.resolver()
 // LINUX: call void @__cpu_indicator_init
 // LINUX: ret void ()* @HasGeneric.Z
@@ -164,8 +206,6 @@
 // WINDOWS-NEXT: ret void
 // WINDOWS-NOT: call void @llvm.trap
 
-ATTR(cpu_dispatch(atom, generic, ivybridge, knl))
-void HasParams(int i, double d);
 // LINUX: define void (i32, double)* @HasParams.resolver()
 // LINUX: call void @__cpu_indicator_init
 // 

[PATCH] D55527: Normalize GlobalDecls when used with CPUDispatch

2018-12-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 7 inline comments as done.
erichkeane added a comment.

I got a couple of @rsmith's requests done.  Most importantly I suspect is 
`MultiVersionFuncs`, though `NotForDefinition` vs `ForDefinition` is perhpas 
something you'll find important.




Comment at: lib/CodeGen/CodeGenModule.cpp:910
 Out << ".resolver";
 }
 

erichkeane wrote:
> rsmith wrote:
> > Hmm, it looks like we don't have a unique name for a `GlobalDecl` naming 
> > the `CPUOrdinal == 0` case of an overloaded `cpu_specific` function:
> > ```
> > __attribute__((cpu_specific(atom)))
> > void f() {} // CPUOrdinal 0 GD mangled as _Z1fv.ifunc
> > __attribute__((cpu_specific(haswell)))
> > void f() {} // CPUOrdinal 0 GD also mangled as _Z1fv.ifunc
> > ```
> > Maybe we could append the CPU-specific manglings for all named CPUs before 
> > the `.ifunc`?
> Well shoot, thats true, since you can call the function at different points 
> and have overload resolution 'choose' a different one (since it is just by 
> ordering).
> 
> If we were to give it a different name, we would either have to replace it 
> later, or make sure a call to 'not the ifunc' doesn't happen.  
I thought about it more last night, if the purpose is simply unique-ness, we 
can generate it as a unique name.  The intent is that it should never make it 
into the IR, so I think appending the names and .ifunc is fine, simply so that 
it is unique.



Comment at: lib/CodeGen/CodeGenModule.cpp:2133-2138
+  // If this is a cpu_dispatch multiversion function, designate it for emission
+  // at the end of the Translation Unit.
+  if (Global->hasAttr()) {
+MultiVersionFuncs.push_back(GD);
+return;
+  }

erichkeane wrote:
> rsmith wrote:
> > Instead of adding a special-case list of `MultiVersionFuncs`, could we 
> > instead change `MayBeEmittedEagerly` to return `false` for `CPUDispatch` 
> > functions and use the normal `DeferredDecls` mechanism for this?
> That list already would have to exist for GCC Multiversioning, since there 
> isn't a single declaration that corresponds to the resolver.  I could 
> definitely remove CPUDispatch from this mechanism and return it to a separate 
> one, but I'm not sure what that buys us.
> 
> Unless you think this is something we can do that will fix the GCC 
> Multiversioning as well?  
I tried for a bit, and couldn't come up with a way that this would work for 
`Target` as well.  IMO, since `MultiVersionFuncs` already has to exist, this 
fits better there.

Additionally, I noticed that when I switched Dispatch over to this version that 
I was having to emit more functions during resolver emission, since they were 
in the deferred list.  The deferred list then attempted to emit them, but no 
longer needed to (though no problems were caused by this).  



Comment at: lib/CodeGen/CodeGenModule.cpp:2637
+if (!ImplDecl.getDecl()) {
+  ImplDecl = GD.getWithMultiVersionOrdinal(Ordinal);
 

erichkeane wrote:
> rsmith wrote:
> > I think we should have a comment somewhere explaining the subtle use of the 
> > multiversion ordinal:
> > 
> >  * (Resolver, 0) refers to the resolver itself
> >  * (Resolver, N) refers to an external (outside this module) symbol for the 
> > N'th CPU in Resolver's cpu_dispatch list
> >  * (Specific, 0) is a placeholder used to refer to the set of function 
> > symbols defined by a cpu_specific function declaration; no corresponding 
> > symbol is ever emitted (right?)
> >  * (Specific, N) refers to an internal (within this module) symbol for the 
> > N'th CPU in Specific's cpu_specific list
> (Specific,0) is a placeholder for a not-yet-existing CPU-Dispatch version of 
> the function.  Otherwise, I think documenting that somewhere is a good idea.  
> I'll look for a good spot for it.
I rephrased this slightly and put it in "EmitMultiVersionFunctionDefinition", 
since it seems to fit there best IMO.



Comment at: lib/CodeGen/CodeGenModule.cpp:2639-2644
+  std::string MangledName = getMangledNameImpl(*this, ImplDecl, FD, true) +
+getCPUSpecificMangling(*this, II->getName());
+  Func = cast(GetOrCreateLLVMFunction(
+  MangledName, DeclTy, ImplDecl,
   /*ForVTable=*/false, /*DontDefer=*/true,
+  /*IsThunk=*/false, llvm::AttributeList(), ForDefinition));

erichkeane wrote:
> rsmith wrote:
> > I think the first part of this should now be equivalent to 
> > `getMangledName(...ImplDecl...)`, which should means that these 6 lines can 
> > be replaced by `GetAddrOfFunction(ImplDecl, DeclTy, false, false, 
> > NotForDefinition)`.
> > 
> > (Also I think you should pass `NotForDefinition` here because you just want 
> > to reference the symbol, you don't want to define it yourself.)
> I remember 'DontDefer=true' being set for a good reason, since we need this 
> function emitted.
> 
> At the moment, this doesn't work 

r348931 - Revert "[OpenCL] Add generic AS to 'this' pointer"

2018-12-12 Thread Mikael Nilsson via cfe-commits
Author: mikael
Date: Wed Dec 12 07:06:16 2018
New Revision: 348931

URL: http://llvm.org/viewvc/llvm-project?rev=348931=rev
Log:
Revert "[OpenCL] Add generic AS to 'this' pointer"

Reverting because the patch broke lldb.


Removed:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGValue.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl
cfe/trunk/test/SemaOpenCLCXX/address-space-templates.cl
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=348931=348930=348931=diff
==
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Wed Dec 12 07:06:16 2018
@@ -510,7 +510,7 @@ struct CanProxyAdaptor;

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=348931=348930=348931=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Dec 12 07:06:16 2018
@@ -2182,10 +2182,7 @@ public:
   /// 'this' type.
   QualType getThisType(ASTContext ) const;
 
-  static QualType getThisType(const FunctionProtoType *FPT,
-  const CXXRecordDecl *Decl);
-
-  Qualifiers getTypeQualifiers() const {
+  unsigned getTypeQualifiers() const {
 return getType()->getAs()->getTypeQuals();
   }
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=348931=348930=348931=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Dec 12 07:06:16 2018
@@ -256,24 +256,28 @@ public:
   }
 
   bool hasConst() const { return Mask & Const; }
-  bool hasOnlyConst() const { return Mask == Const; }
+  void setConst(bool flag) {
+Mask = (Mask & ~Const) | (flag ? Const : 0);
+  }
   void removeConst() { Mask &= ~Const; }
   void addConst() { Mask |= Const; }
 
   bool hasVolatile() const { return Mask & Volatile; }
-  bool hasOnlyVolatile() const { return Mask == Volatile; }
+  void setVolatile(bool flag) {
+Mask = (Mask & ~Volatile) | (flag ? Volatile : 0);
+  }
   void removeVolatile() { Mask &= ~Volatile; }
   void addVolatile() { Mask |= Volatile; }
 
   bool hasRestrict() const { return Mask & Restrict; }
-  bool hasOnlyRestrict() const { return Mask == Restrict; }
+  void setRestrict(bool flag) {
+Mask = (Mask & ~Restrict) | (flag ? Restrict : 0);
+  }
   void removeRestrict() { Mask &= ~Restrict; }
   void addRestrict() { Mask |= Restrict; }
 
   bool hasCVRQualifiers() const { return getCVRQualifiers(); }
   unsigned getCVRQualifiers() const { return Mask & CVRMask; }
-  unsigned getCVRUQualifiers() const { return Mask & (CVRMask | UMask); }
-
   void setCVRQualifiers(unsigned mask) {
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask = (Mask & ~CVRMask) | mask;
@@ -1522,9 +1526,7 @@ protected:
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned FastTypeQuals : Qualifiers::FastWidth;
-/// Whether this function has extended Qualifiers.
-unsigned HasExtQuals : 1;

[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

2018-12-12 Thread Mikael Nilsson via Phabricator via cfe-commits
mikael added a comment.

Seems like my this commit broke: 
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-buildserver/builds/33176

But since I don't really know what anything about lldb, I probably won't be 
able to fix it fast enough.

  
/lldb-buildbot/buildServerSlave/lldb-android-buildserver/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp:2208:24:
 error: no viable overloaded '='
proto_info.TypeQuals = type_quals;
 ^ ~~
  
/lldb-buildbot/buildServerSlave/lldb-android-buildserver/llvm/tools/clang/include/clang/AST/Type.h:141:7:
 note: candidate function (the implicit copy assignment operator) not viable: 
no known conversion from 'unsigned int' to 'const clang::Qualifiers' for 1st 
argument
  class Qualifiers {
^
  
/lldb-buildbot/buildServerSlave/lldb-android-buildserver/llvm/tools/clang/include/clang/AST/Type.h:141:7:
 note: candidate function (the implicit move assignment operator) not viable: 
no known conversion from 'unsigned int' to 'clang::Qualifiers' for 1st argument
  1 error generated.

I think it can be easily solved by Qualifiers::fromFastMask(type_quals); also 
updating the variable name since it changed.

But I know nothing about lldb, so I better revert this patch for now.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54862



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


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-12 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348930: [CUDA][OPENMP][NVPTX]Improve logic of the debug info 
support. (authored by ABataev, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D51554

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Driver/ToolChains/Cuda.h
  cfe/trunk/test/Driver/cuda-dwarf-2.cu
  cfe/trunk/test/Driver/openmp-offload-gpu.c

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H
 
+#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/DebugInfoOptions.h"
@@ -435,6 +436,10 @@
 return true;
   }
 
+  /// Adjust debug information kind considering all passed options.
+  virtual void adjustDebugInfoKind(codegenoptions::DebugInfoKind ,
+   const llvm::opt::ArgList ) const {}
+
   /// GetExceptionModel - Return the tool chain exception model.
   virtual llvm::ExceptionHandling
   GetExceptionModel(const llvm::opt::ArgList ) const;
Index: cfe/trunk/test/Driver/cuda-dwarf-2.cu
===
--- cfe/trunk/test/Driver/cuda-dwarf-2.cu
+++ cfe/trunk/test/Driver/cuda-dwarf-2.cu
@@ -1,25 +1,28 @@
 // REQUIRES: clang-driver
 //
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 | \
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O3 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g0 2>&1 | \
 // RUN:   FileCheck %s -check-prefix NO_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix NO_DEBUG
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb1 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG -check-prefix LINE_TABLE
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-tables-only -O2 --cuda-noopt-device-debug 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG -check-prefix LINE_TABLE
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-directives-only -O2 --cuda-noopt-device-debug 2>&1 | \
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 
 // NO_DEBUG-NOT: warning: debug
-// LINE_TABLE-NOT: warning: debug
+// DEBUG_DIRECTIVES-NOT: warning: debug
+// NO_DEBUG: "-fcuda-is-device"
+// NO_DEBUG-NOT: "-debug-info-kind=
 // NO_DEBUG: ptxas
 // NO_DEBUG-NOT: "-g"
-// LINE_TABLE: "-lineinfo"
+// DEBUG_DIRECTIVES: "-fcuda-is-device"
+// DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
+// DEBUG_DIRECTIVES: ptxas
+// DEBUG_DIRECTIVES-SAME: "-lineinfo"
 // NO_DEBUG: fatbinary
 // NO_DEBUG-NOT: "-g"
 
@@ -27,6 +30,8 @@
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O0 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 | \
+// RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O3 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g2 2>&1 | \
@@ -37,9 +42,14 @@
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb3 -O3 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb1 2>&1 | \
+// RUN:   FileCheck %s -check-prefix HAS_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-tables-only -O2 --cuda-noopt-device-debug 2>&1 | \
+// 

r348930 - [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-12 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Dec 12 06:52:27 2018
New Revision: 348930

URL: http://llvm.org/viewvc/llvm-project?rev=348930=rev
Log:
[CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

Summary:
Added support for the -gline-directives-only option + fixed logic of the
debug info for CUDA devices. If optimization level is O0, then options
--[no-]cuda-noopt-device-debug do not affect the debug info level. If
the optimization level is >O0, debug info options are used +
--no-cuda-noopt-device-debug is used or no --cuda-noopt-device-debug is
used, the optimization level for the device code is kept and the
emission of the debug directives is used.
If the opt level is > O0, debug info is requested +
--cuda-noopt-device-debug option is used, the optimization is disabled
for the device code + required debug info is emitted.

Reviewers: tra, echristo

Subscribers: aprantl, guansong, JDevlieghere, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.h
cfe/trunk/test/Driver/cuda-dwarf-2.cu
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=348930=348929=348930=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Dec 12 06:52:27 2018
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H
 
+#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/DebugInfoOptions.h"
@@ -435,6 +436,10 @@ public:
 return true;
   }
 
+  /// Adjust debug information kind considering all passed options.
+  virtual void adjustDebugInfoKind(codegenoptions::DebugInfoKind 
,
+   const llvm::opt::ArgList ) const {}
+
   /// GetExceptionModel - Return the tool chain exception model.
   virtual llvm::ExceptionHandling
   GetExceptionModel(const llvm::opt::ArgList ) const;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=348930=348929=348930=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Dec 12 06:52:27 2018
@@ -3233,6 +3233,9 @@ static void RenderDebugOptions(const Too
 }
   }
 
+  // Adjust the debug info kind for the given toolchain.
+  TC.adjustDebugInfoKind(DebugInfoKind, Args);
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=348930=348929=348930=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Wed Dec 12 06:52:27 2018
@@ -278,32 +278,44 @@ void CudaInstallationDetector::print(raw
 }
 
 namespace {
-  /// Debug info kind.
-enum DebugInfoKind {
-  NoDebug,   /// No debug info.
-  LineTableOnly, /// Line tables only.
-  FullDebug  /// Full debug info.
+/// Debug info level for the NVPTX devices. We may need to emit different debug
+/// info level for the host and for the device itselfi. This type controls
+/// emission of the debug info for the devices. It either prohibits disable 
info
+/// emission completely, or emits debug directives only, or emits same debug
+/// info as for the host.
+enum DeviceDebugInfoLevel {
+  DisableDebugInfo,/// Do not emit debug info for the devices.
+  DebugDirectivesOnly, /// Emit only debug directives.
+  EmitSameDebugInfoAsHost, /// Use the same debug info level just like for the
+   /// host.
 };
 } // anonymous namespace
 
-static DebugInfoKind mustEmitDebugInfo(const ArgList ) {
-  Arg *A = Args.getLastArg(options::OPT_O_Group);
-  if (Args.hasFlag(options::OPT_cuda_noopt_device_debug,
-   options::OPT_no_cuda_noopt_device_debug,
-   !A || A->getOption().matches(options::OPT_O0))) {
-if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) {
-  const Option  = A->getOption();
-  if (Opt.matches(options::OPT_gN_Group)) {
-if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0))
-  return NoDebug;
-if (Opt.matches(options::OPT_gline_tables_only) ||
-Opt.matches(options::OPT_ggdb1))
-  return LineTableOnly;
-  }
-  return FullDebug;
+/// Define debug 

[PATCH] D55546: [clang] Add AST matcher for block expressions 

2018-12-12 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!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55546



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


[PATCH] D55413: [ExprConstant] Handle compound assignment when LHS has integral type and RHS has floating point type

2018-12-12 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner marked an inline comment as done.
cpplearner added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:3441
+  Value);
+}
 APSInt LHS = HandleIntToIntCast(Info, E, PromotedLHSType,

rjmccall wrote:
> Can we more fundamentally restructure this entire handler so that, if the 
> compound assignment's computation result type is an arithmetic type, we just 
> promote both operands to that type, do the arithmetic there, and then coerce 
> back down?  This is C++, so the LHS type imposes almost no restrictions on 
> the RHS type; also, this is Clang, where we support way too many arithmetic 
> types for our own good.
It seems the conditional statement is unavoidable, because `APSInt` and 
`APFloat` can't be handled at the same time (i.e. you need to choose among 
`Handle{Int,Float}To{Int,Float}Cast`, and between 
`handleIntIntBinOp`/`handleFloatFloatBinOp`). Maybe it's possible to add a 
layer that can accept both `APSInt` and `APFloat`, but it seems like an 
overkill if it's only used in the compound assignment case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55413



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


Re: r348915 - Add explicit dependency on clangSerialization for a bunch of components to fix -DBUILD_SHARED_LIBS=on build

2018-12-12 Thread Alex Bradbury via cfe-commits
On Wed, 12 Dec 2018 at 08:05, Fangrui Song via cfe-commits
 wrote:
>
> Author: maskray
> Date: Wed Dec 12 00:02:18 2018
> New Revision: 348915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348915=rev
> Log:
> Add explicit dependency on clangSerialization for a bunch of components to 
> fix -DBUILD_SHARED_LIBS=on build
>
> This is a more thorough fix of rC348911.
> The story about -DBUILD_SHARED_LIBS=on build after rC348907 (Move 
> PCHContainerOperations from Frontend to Serialization) is:
>
> 1. libclangSerialization.so defines PCHContainerReader dtor, ...
> 2. clangFrontend and clangTooling define classes inheriting from 
> PCHContainerReader, thus their DSOs have undefined references on 
> PCHContainerReader dtor
> 3. Components depending on either clangFrontend or clangTooling cannot be 
> linked unless they have explicit dependency on clangSerialization due to the 
> default linker option -z defs. The explicit dependency could be avoided if 
> libclang{Frontend,Tooling}.so had these undefined references.
>
> This patch adds the explicit dependency on clangSerialization to make them 
> build.

Hi Fangrui. My shared library build ran into issues when linking
libclangHandleCXX.so. I committed rC348929 to fix that.

Best,

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


r348929 - [clang-fuzzer] Add explicit dependency on clangSerialization for clangHandleCXX after rC348907

2018-12-12 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Wed Dec 12 06:33:24 2018
New Revision: 348929

URL: http://llvm.org/viewvc/llvm-project?rev=348929=rev
Log:
[clang-fuzzer] Add explicit dependency on clangSerialization for clangHandleCXX 
after rC348907

This library was breaking my -DBUILD_SHARED_LIBS=1 build. rC348915 seemed to 
miss this case.

As this seems an "obvious" fix, I am committing without pre-commit review as
per the LLVM developer policy.


Modified:
cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt?rev=348929=348928=348929=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt Wed Dec 12 06:33:24 
2018
@@ -8,5 +8,6 @@ add_clang_library(clangHandleCXX
   clangCodeGen
   clangFrontend
   clangLex
+  clangSerialization
   clangTooling
   )


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


[PATCH] D55595: [clang-tidy] Share the forced linking code between clang-tidy tool and plugin

2018-12-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Can you say where else it is common in LLVM? I'm curious. Maybe those places 
could be changed too.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55595



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


r348927 - [OpenCL] Add generic AS to 'this' pointer

2018-12-12 Thread Mikael Nilsson via cfe-commits
Author: mikael
Date: Wed Dec 12 06:11:59 2018
New Revision: 348927

URL: http://llvm.org/viewvc/llvm-project?rev=348927=rev
Log:
[OpenCL] Add generic AS to 'this' pointer

Address spaces are cast into generic before invoking the constructor.

Added support for a trailing Qualifiers object in FunctionProtoType.

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

Added:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGValue.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl
cfe/trunk/test/SemaOpenCLCXX/address-space-templates.cl
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=348927=348926=348927=diff
==
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Wed Dec 12 06:11:59 2018
@@ -510,7 +510,7 @@ struct CanProxyAdaptor;

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=348927=348926=348927=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Dec 12 06:11:59 2018
@@ -2182,7 +2182,10 @@ public:
   /// 'this' type.
   QualType getThisType(ASTContext ) const;
 
-  unsigned getTypeQualifiers() const {
+  static QualType getThisType(const FunctionProtoType *FPT,
+  const CXXRecordDecl *Decl);
+
+  Qualifiers getTypeQualifiers() const {
 return getType()->getAs()->getTypeQuals();
   }
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=348927=348926=348927=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Dec 12 06:11:59 2018
@@ -256,28 +256,24 @@ public:
   }
 
   bool hasConst() const { return Mask & Const; }
-  void setConst(bool flag) {
-Mask = (Mask & ~Const) | (flag ? Const : 0);
-  }
+  bool hasOnlyConst() const { return Mask == Const; }
   void removeConst() { Mask &= ~Const; }
   void addConst() { Mask |= Const; }
 
   bool hasVolatile() const { return Mask & Volatile; }
-  void setVolatile(bool flag) {
-Mask = (Mask & ~Volatile) | (flag ? Volatile : 0);
-  }
+  bool hasOnlyVolatile() const { return Mask == Volatile; }
   void removeVolatile() { Mask &= ~Volatile; }
   void addVolatile() { Mask |= Volatile; }
 
   bool hasRestrict() const { return Mask & Restrict; }
-  void setRestrict(bool flag) {
-Mask = (Mask & ~Restrict) | (flag ? Restrict : 0);
-  }
+  bool hasOnlyRestrict() const { return Mask == Restrict; }
   void removeRestrict() { Mask &= ~Restrict; }
   void addRestrict() { Mask |= Restrict; }
 
   bool hasCVRQualifiers() const { return getCVRQualifiers(); }
   unsigned getCVRQualifiers() const { return Mask & CVRMask; }
+  unsigned getCVRUQualifiers() const { return Mask & (CVRMask | UMask); }
+
   void setCVRQualifiers(unsigned mask) {
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask = (Mask & ~CVRMask) | mask;
@@ -1526,7 +1522,9 @@ protected:
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function 

[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

2018-12-12 Thread Mikael Nilsson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348927: [OpenCL] Add generic AS to this pointer 
(authored by mikael, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54862?vs=177477=177846#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54862

Files:
  include/clang/AST/CanonicalType.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGValue.h
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/CodeGenOpenCLCXX/template-address-spaces.cl
  test/SemaOpenCLCXX/address-space-templates.cl
  tools/libclang/CIndex.cpp

Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -270,7 +270,8 @@
   if (const CXXMethodDecl *MD = dyn_cast(D)) {
 if (MD->isStatic())
   Out << 'S';
-if (unsigned quals = MD->getTypeQualifiers())
+// FIXME: OpenCL: Need to consider address spaces
+if (unsigned quals = MD->getTypeQualifiers().getCVRUQualifiers())
   Out << (char)('0' + quals);
 switch (MD->getRefQualifier()) {
 case RQ_None: break;
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -16,6 +16,7 @@
 #include "CGDebugInfo.h"
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
+#include "TargetInfo.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -2012,8 +2013,19 @@
  bool NewPointerIsChecked) {
   CallArgList Args;
 
+  LangAS SlotAS = E->getType().getAddressSpace();
+  QualType ThisType = D->getThisType(getContext());
+  LangAS ThisAS = ThisType.getTypePtr()->getPointeeType().getAddressSpace();
+  llvm::Value *ThisPtr = This.getPointer();
+  if (SlotAS != ThisAS) {
+unsigned TargetThisAS = getContext().getTargetAddressSpace(ThisAS);
+llvm::Type *NewType =
+ThisPtr->getType()->getPointerElementType()->getPointerTo(TargetThisAS);
+ThisPtr = getTargetHooks().performAddrSpaceCast(*this, This.getPointer(),
+ThisAS, SlotAS, NewType);
+  }
   // Push the this ptr.
-  Args.add(RValue::get(This.getPointer()), D->getThisType(getContext()));
+  Args.add(RValue::get(ThisPtr), D->getThisType(getContext()));
 
   // If this is a trivial constructor, emit a memcpy now before we lose
   // the alignment information on the argument.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2617,9 +2617,9 @@
   const FunctionProtoType *FPT =
   Ty->getPointeeType()->getAs();
   return DBuilder.createMemberPointerType(
-  getOrCreateInstanceMethodType(CGM.getContext().getPointerType(QualType(
-Ty->getClass(), FPT->getTypeQuals())),
-FPT, U),
+  getOrCreateInstanceMethodType(
+  CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()),
+  FPT, U),
   ClassType, Size, /*Align=*/0, Flags);
 }
 
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -26,7 +26,10 @@
 
 static void EmitDeclInit(CodeGenFunction , const VarDecl ,
  ConstantAddress DeclPtr) {
-  assert(D.hasGlobalStorage() && "VarDecl must have global storage!");
+  assert(
+  (D.hasGlobalStorage() ||
+   (D.hasLocalStorage() && CGF.getContext().getLangOpts().OpenCLCPlusPlus)) &&
+  "VarDecl must have global or local (in the case of OpenCL) storage!");
   assert(!D.getType()->isReferenceType() &&
  "Should not call EmitDeclInit on a reference!");
 
Index: lib/CodeGen/CGValue.h

Re: r348276 - [AST][NFC] Make ArrayTypeTraitExpr non polymorphic

2018-12-12 Thread Bruno Ricci via cfe-commits


On 12/12/2018 13:25, Mikael Holmén wrote:
> 
> 
> On 12/12/18 2:17 PM, Bruno Ricci wrote:
>>
>>
>> On 12/12/2018 07:27, Mikael Holmén wrote:
>>> Hi,
>>>
>>> On 12/11/18 5:49 PM, Bruno Ricci wrote:
 Hi Mikael,

 I can indeed reproduce this with gcc 5.5.0 when doing a Release
 build with assertions. I cannot reproduce this with gcc 6.5.0
 (also with a Release build with assertions), nor can I reproduce
 this with clang 7 (also with a Release build with assertions).

 I tried to instrument StringRefCheckerVisitor::VisitChildren but this
 just causes the stack overflow to move to CGBuilder.

 What is stranger is that the reproducer do not even causes
 an ArrayTypeTraitExpr node to be created.

 Increasing the maximum stack size with ulimit by a small amount fixes
 the problem, so I don't think this is a mis-compilation either.
>>>
>>> Oh, I didn't realize it actually passed with a larger stack, I thought
>>> it recursed forever.
>>>
>>> I see now that before the change clang-tidy compiled with gcc 5.4 passed
>>> with stacksize limited to 2288k and after it needs 9372k.
>>>
>>> If I use clang 3.6 to compile I needed 1747k before the change and 1750k
>>> after.
>>
>> Huh ? This is a huge increase.
>>
> 
> Yes, well compared to the insane increase for gcc 5.4 it's nothing :)
> 
> But perhaps the increase with clang is interesting as well, I don't know.

I was talking about the increase with gcc :)

> 
>>>

 I think that this change is correct since no one is using the polymorphism
 of ArrayTypeTraitExpr. Indeed taking the blunt step of making it final do
 not causes any failure.

 The only possible explaination I can think of is that for one reason
 or another, with this particular compiler + build settings, this change
 causes an increase of stack usage which exceeed the default limit ?

>>>
>>> Yes perhaps it's just some deficiency in old gcc versions that is
>>> exposed by this then.
>>>
>>> Thanks,
>>> Mikael
>>
>> Perhaps it is just indeed a deficiency in gcc 5.4, but this is strange.
>>
> 
> Yes. I'm not sure what to do with this, apart from that we will speed up 
> our team's transition from gcc 5.4 to something newer. That would be 
> needed anyway due to the fact that llvm wants to start using C++17, but 
> we'll try to do that sooner rather than later now.
> 
> Regards,
> Mikael

Well there is always the possibility to revert it if this a blocking issue.
I can try to investigate this problem this week-end if I have some time.

Regards,
Bruno

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


Re: r348276 - [AST][NFC] Make ArrayTypeTraitExpr non polymorphic

2018-12-12 Thread Mikael Holmén via cfe-commits


On 12/12/18 2:17 PM, Bruno Ricci wrote:
> 
> 
> On 12/12/2018 07:27, Mikael Holmén wrote:
>> Hi,
>>
>> On 12/11/18 5:49 PM, Bruno Ricci wrote:
>>> Hi Mikael,
>>>
>>> I can indeed reproduce this with gcc 5.5.0 when doing a Release
>>> build with assertions. I cannot reproduce this with gcc 6.5.0
>>> (also with a Release build with assertions), nor can I reproduce
>>> this with clang 7 (also with a Release build with assertions).
>>>
>>> I tried to instrument StringRefCheckerVisitor::VisitChildren but this
>>> just causes the stack overflow to move to CGBuilder.
>>>
>>> What is stranger is that the reproducer do not even causes
>>> an ArrayTypeTraitExpr node to be created.
>>>
>>> Increasing the maximum stack size with ulimit by a small amount fixes
>>> the problem, so I don't think this is a mis-compilation either.
>>
>> Oh, I didn't realize it actually passed with a larger stack, I thought
>> it recursed forever.
>>
>> I see now that before the change clang-tidy compiled with gcc 5.4 passed
>> with stacksize limited to 2288k and after it needs 9372k.
>>
>> If I use clang 3.6 to compile I needed 1747k before the change and 1750k
>> after.
> 
> Huh ? This is a huge increase.
> 

Yes, well compared to the insane increase for gcc 5.4 it's nothing :)

But perhaps the increase with clang is interesting as well, I don't know.

>>
>>>
>>> I think that this change is correct since no one is using the polymorphism
>>> of ArrayTypeTraitExpr. Indeed taking the blunt step of making it final do
>>> not causes any failure.
>>>
>>> The only possible explaination I can think of is that for one reason
>>> or another, with this particular compiler + build settings, this change
>>> causes an increase of stack usage which exceeed the default limit ?
>>>
>>
>> Yes perhaps it's just some deficiency in old gcc versions that is
>> exposed by this then.
>>
>> Thanks,
>> Mikael
> 
> Perhaps it is just indeed a deficiency in gcc 5.4, but this is strange.
> 

Yes. I'm not sure what to do with this, apart from that we will speed up 
our team's transition from gcc 5.4 to something newer. That would be 
needed anyway due to the fact that llvm wants to start using C++17, but 
we'll try to do that sooner rather than later now.

Regards,
Mikael

> Bruno
>>
>>
>>> Regards,
>>> Bruno

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


Re: r348276 - [AST][NFC] Make ArrayTypeTraitExpr non polymorphic

2018-12-12 Thread Bruno Ricci via cfe-commits


On 12/12/2018 07:27, Mikael Holmén wrote:
> Hi,
> 
> On 12/11/18 5:49 PM, Bruno Ricci wrote:
>> Hi Mikael,
>>
>> I can indeed reproduce this with gcc 5.5.0 when doing a Release
>> build with assertions. I cannot reproduce this with gcc 6.5.0
>> (also with a Release build with assertions), nor can I reproduce
>> this with clang 7 (also with a Release build with assertions).
>>
>> I tried to instrument StringRefCheckerVisitor::VisitChildren but this
>> just causes the stack overflow to move to CGBuilder.
>>
>> What is stranger is that the reproducer do not even causes
>> an ArrayTypeTraitExpr node to be created.
>>
>> Increasing the maximum stack size with ulimit by a small amount fixes
>> the problem, so I don't think this is a mis-compilation either.
> 
> Oh, I didn't realize it actually passed with a larger stack, I thought 
> it recursed forever.
> 
> I see now that before the change clang-tidy compiled with gcc 5.4 passed 
> with stacksize limited to 2288k and after it needs 9372k.
> 
> If I use clang 3.6 to compile I needed 1747k before the change and 1750k 
> after.

Huh ? This is a huge increase.

> 
>>
>> I think that this change is correct since no one is using the polymorphism
>> of ArrayTypeTraitExpr. Indeed taking the blunt step of making it final do
>> not causes any failure.
>>
>> The only possible explaination I can think of is that for one reason
>> or another, with this particular compiler + build settings, this change
>> causes an increase of stack usage which exceeed the default limit ?
>>
> 
> Yes perhaps it's just some deficiency in old gcc versions that is 
> exposed by this then.
> 
> Thanks,
> Mikael

Perhaps it is just indeed a deficiency in gcc 5.4, but this is strange.

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


[PATCH] D55447: [Sema] Fix Modified Type in address_space AttributedType

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



Comment at: clang/tools/libclang/CXType.cpp:132
+  if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes) &&
+  ATT->getAttrKind() != attr::AddressSpace) {
 return MakeCXType(ATT->getModifiedType(), TU);

leonardchan wrote:
> aaron.ballman wrote:
> > leonardchan wrote:
> > > aaron.ballman wrote:
> > > > leonardchan wrote:
> > > > > aaron.ballman wrote:
> > > > > > This change seems surprising -- if the parsing options say the 
> > > > > > caller does not want attributed types, why are we returning one 
> > > > > > anyway for address space?
> > > > > This has to do with ensuring `clang_getAddressSpace` still returns 
> > > > > the proper address_space. It does this by essentially checking the 
> > > > > qualifiers of the type, which we now attach to the `AttributedType` 
> > > > > whereas before it was attached to the modified type.
> > > > > 
> > > > > This extra condition is necessary for ensuring that calling 
> > > > > `clang_getAddressSpace` points to the qualified AttributedType 
> > > > > instead of the unqualified modified type.
> > > > My fear is that this will be breaking assumptions in third-party code. 
> > > > If someone disables `CXTranslationUnit_IncludeAttributedTypes`, they 
> > > > are unlikely to expect to receive an `AttributedType` and may react 
> > > > poorly to it.
> > > Instead check if the type is address_space attributed and apply the 
> > > qualifiers the modified type.
> > Sure, they can always modify their code to handle it gracefully, but it's a 
> > silent, breaking change to a somewhat stable API which is why I was 
> > prodding about it.
> > 
> > After talking with @rsmith, we're thinking the correct change here is to 
> > return the attributed type when the user asks for it, but return the 
> > equivalent type rather than the modified type if the user doesn't want 
> > attribute sugar (for all attributes, not just address spaces). This way, 
> > when a user asks for CXType for one of these, they always get a correct 
> > type but sometimes it has attribute type sugar and sometimes it doesn't, 
> > depending on the parsing options.
> > 
> > This is still a silent, breaking change in behavior, which is unfortunate. 
> > It should probably come with a mention in the release notes about the 
> > change to the API and some unit tests as well.
> Ok. In the case of qualifiers then, should the equivalent type still contain 
> the address_space qualifiers when creating the AttributedType?
I believe so, yes -- that would ensure it's the minimally desugared type which 
the type is canonically equivalent to.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55447



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


[PATCH] D54309: [AST] Allow limiting the scope of common AST traversals (getParents, RAV).

2018-12-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

> Sounds like we might not correctly set the parent map for CXXConstructorDecl 
> then?

I unfortunatly don't know where to start to look for. Could you give me a hint 
what to inspect to figure that out?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54309



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


[PATCH] D55595: [clang-tidy] Share the forced linking code between clang-tidy tool and plugin

2018-12-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D55595#1328154 , @steveire wrote:

> FYI, CMake target property `INTERFACE_SOURCES` is designed to make this easy.
>
> For each module you would generate a file containing
>
>   extern volatile int ${MODULE_NAME}ModuleAnchorSource;
>   static int LLVM_ATTRIBUTE_UNUSED ${MODULE_NAME}ModuleAnchorDestination =
>   ${MODULE_NAME}ModuleAnchorSource;
>
>
> and then put that generated file in the `INTERFACE_SOURCES` of each module.
>
>   target_sources(${MODULE_NAME} INTERFACE ${THE_GENERATED_FILE}.cpp)
>
>
> Then, you don't need to maintain it in C++ like this. It is DRY because the 
> `target_link_libraries` entry for the library is what causes the symbol to be 
> used.


That sounds like a better solution, but i think the current pattern is common 
in LLVM, maybe @aaron.ballman or @alexfh could share their opinion on this one?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55595



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


[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-12-12 Thread Gabor Marton via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348923: [ASTImporter] Remove import of definition from 
GetAlreadyImportedOrNull (authored by martong, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53755?vs=175639=177834#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D53755

Files:
  cfe/trunk/include/clang/AST/ASTImporter.h
  cfe/trunk/lib/AST/ASTImporter.cpp


Index: cfe/trunk/include/clang/AST/ASTImporter.h
===
--- cfe/trunk/include/clang/AST/ASTImporter.h
+++ cfe/trunk/include/clang/AST/ASTImporter.h
@@ -209,7 +209,7 @@
 /// Return the copy of the given declaration in the "to" context if
 /// it has already been imported from the "from" context.  Otherwise return
 /// NULL.
-Decl *GetAlreadyImportedOrNull(Decl *FromD);
+Decl *GetAlreadyImportedOrNull(const Decl *FromD) const;
 
 /// Import the given declaration context from the "from"
 /// AST context into the "to" AST context.
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1580,6 +1580,9 @@
 return Err;
 
   ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
 
   return Error::success();
 }
@@ -7745,17 +7748,12 @@
   return ToAttr;
 }
 
-Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
-  llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
-  if (Pos != ImportedDecls.end()) {
-Decl *ToD = Pos->second;
-// FIXME: move this call to ImportDeclParts().
-if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, 
ToD))
-  llvm::consumeError(std::move(Err));
-return ToD;
-  } else {
+Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
+  auto Pos = ImportedDecls.find(FromD);
+  if (Pos != ImportedDecls.end())
+return Pos->second;
+  else
 return nullptr;
-  }
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {


Index: cfe/trunk/include/clang/AST/ASTImporter.h
===
--- cfe/trunk/include/clang/AST/ASTImporter.h
+++ cfe/trunk/include/clang/AST/ASTImporter.h
@@ -209,7 +209,7 @@
 /// Return the copy of the given declaration in the "to" context if
 /// it has already been imported from the "from" context.  Otherwise return
 /// NULL.
-Decl *GetAlreadyImportedOrNull(Decl *FromD);
+Decl *GetAlreadyImportedOrNull(const Decl *FromD) const;
 
 /// Import the given declaration context from the "from"
 /// AST context into the "to" AST context.
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1580,6 +1580,9 @@
 return Err;
 
   ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
 
   return Error::success();
 }
@@ -7745,17 +7748,12 @@
   return ToAttr;
 }
 
-Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
-  llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
-  if (Pos != ImportedDecls.end()) {
-Decl *ToD = Pos->second;
-// FIXME: move this call to ImportDeclParts().
-if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, ToD))
-  llvm::consumeError(std::move(Err));
-return ToD;
-  } else {
+Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
+  auto Pos = ImportedDecls.find(FromD);
+  if (Pos != ImportedDecls.end())
+return Pos->second;
+  else
 return nullptr;
-  }
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348923 - [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-12-12 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Dec 12 03:22:55 2018
New Revision: 348923

URL: http://llvm.org/viewvc/llvm-project?rev=348923=rev
Log:
[ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

Summary: a_sidorin

Reviewers: a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=348923=348922=348923=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Wed Dec 12 03:22:55 2018
@@ -209,7 +209,7 @@ class Attr;
 /// Return the copy of the given declaration in the "to" context if
 /// it has already been imported from the "from" context.  Otherwise return
 /// NULL.
-Decl *GetAlreadyImportedOrNull(Decl *FromD);
+Decl *GetAlreadyImportedOrNull(const Decl *FromD) const;
 
 /// Import the given declaration context from the "from"
 /// AST context into the "to" AST context.

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=348923=348922=348923=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Dec 12 03:22:55 2018
@@ -1580,6 +1580,9 @@ Error ASTNodeImporter::ImportDeclParts(
 return Err;
 
   ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
 
   return Error::success();
 }
@@ -7745,17 +7748,12 @@ Attr *ASTImporter::Import(const Attr *Fr
   return ToAttr;
 }
 
-Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
-  llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
-  if (Pos != ImportedDecls.end()) {
-Decl *ToD = Pos->second;
-// FIXME: move this call to ImportDeclParts().
-if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, 
ToD))
-  llvm::consumeError(std::move(Err));
-return ToD;
-  } else {
+Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
+  auto Pos = ImportedDecls.find(FromD);
+  if (Pos != ImportedDecls.end())
+return Pos->second;
+  else
 return nullptr;
-  }
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {


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


[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-12-12 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@shafik

> We need to make sure we are running the lldb test suite before committing and 
> watching the bots to make sure the commit does not break them.

I just have tested this patch on macOS  and there seems to be no regression. 
Linux also seems to be without any regression. Very soon I am going to commit 
and I am going to monitor green.lab.llvm.org/green/view/LLDB/ for sign of any 
failure. I will revert in case of any failure asap.

Thanks for the review!


Repository:
  rC Clang

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

https://reviews.llvm.org/D53755



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


[PATCH] D55595: Share the forced linking code between clang-tidy tool and plugin

2018-12-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

FYI, CMake target property `INTERFACE_SOURCES` is designed to make this easy.

For each module you would generate a file containing

  extern volatile int ${MODULE_NAME}ModuleAnchorSource;
  static int LLVM_ATTRIBUTE_UNUSED ${MODULE_NAME}ModuleAnchorDestination =
  ${MODULE_NAME}ModuleAnchorSource;

and then put that generated file in the `INTERFACE_SOURCES` of each module.

  target_sources(${MODULE_NAME} INTERFACE ${THE_GENERATED_FILE}.cpp)

Then, you don't need to maintain it in C++ like this. It is DRY because the 
`target_link_libraries` entry for the library is what causes the symbol to be 
used.


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

https://reviews.llvm.org/D55595



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


[PATCH] D55595: Share the forced linking code between clang-tidy tool and plugin

2018-12-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Thanks, LG.
You probably may want to wait a bit (a day?) in case others want to comment.


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

https://reviews.llvm.org/D55595



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


[PATCH] D55595: Share the forced linking code between clang-tidy tool and plugin

2018-12-12 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 177832.
yvvan marked an inline comment as done.
yvvan added a comment.

Add standard prologue to the new header


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

https://reviews.llvm.org/D55595

Files:
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/plugin/ClangTidyPlugin.cpp
  clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tidy/ClangTidyForceLinker.h
===
--- clang-tidy/ClangTidyForceLinker.h
+++ clang-tidy/ClangTidyForceLinker.h
@@ -0,0 +1,108 @@
+//===- ClangTidyForceLinker.h - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace tidy {
+
+// This anchor is used to force the linker to link the CERTModule.
+extern volatile int CERTModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
+CERTModuleAnchorSource;
+
+// This anchor is used to force the linker to link the AbseilModule.
+extern volatile int AbseilModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
+AbseilModuleAnchorSource;
+
+// This anchor is used to force the linker to link the BoostModule.
+extern volatile int BoostModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
+BoostModuleAnchorSource;
+
+// This anchor is used to force the linker to link the BugproneModule.
+extern volatile int BugproneModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BugproneModuleAnchorDestination =
+BugproneModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
+LLVMModuleAnchorSource;
+
+// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
+extern volatile int CppCoreGuidelinesModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
+CppCoreGuidelinesModuleAnchorSource;
+
+// This anchor is used to force the linker to link the FuchsiaModule.
+extern volatile int FuchsiaModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
+FuchsiaModuleAnchorSource;
+
+// This anchor is used to force the linker to link the GoogleModule.
+extern volatile int GoogleModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
+GoogleModuleAnchorSource;
+
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
+// This anchor is used to force the linker to link the MiscModule.
+extern volatile int MiscModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
+MiscModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ModernizeModule.
+extern volatile int ModernizeModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
+ModernizeModuleAnchorSource;
+
+#if CLANG_ENABLE_STATIC_ANALYZER
+// This anchor is used to force the linker to link the MPIModule.
+extern volatile int MPIModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
+MPIModuleAnchorSource;
+#endif
+
+// This anchor is used to force the linker to link the PerformanceModule.
+extern volatile int PerformanceModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
+PerformanceModuleAnchorSource;
+
+// This anchor is used to force the linker to link the PortabilityModule.
+extern volatile int PortabilityModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED PortabilityModuleAnchorDestination =
+PortabilityModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ReadabilityModule.
+extern volatile int ReadabilityModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
+ReadabilityModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ObjCModule.
+extern volatile int ObjCModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
+ObjCModuleAnchorSource;
+
+// This anchor is used to force the linker to link the HICPPModule.
+extern volatile int HICPPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
+HICPPModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ZirconModule.
+extern volatile int ZirconModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
+

  1   2   >