Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66434.

https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/CMakeLists.txt
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -20,15 +20,15 @@
 project. If you have any ideas or suggestions, you might want to put a feature
 request there.
 
-Using clang-rename
+Using Clang-Rename
 ==
 
 :program:`clang-rename` is a `LibTooling
 `_-based tool, and it's easier to
 work with if you set up a compile command database for your project (for an
 example of how to do this see `How To Setup Tooling For LLVM
 `_). You can also
-specify compilation options on the command line after ``--``:
+specify compilation options on the command line after `--`:
 
 .. code-block:: console
 
@@ -47,7 +47,7 @@
 renaming actions in the future.
 
 :program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim, and improve the workflow of users.
+editors, such as Vim and Emacs, and improve the workflow of users.
 
 Although a command line interface exists, it is highly recommended to use the
 text editor interface instead for better experience.
@@ -84,8 +84,8 @@
 -version   - Display the version of this program
 
 
-clang-rename Vim integration
-
+Vim Integration
+===
 
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
@@ -96,7 +96,21 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
 is a reference to a specific key defined by the mapleader variable and is bound
 to backslash by default.
+
+Emacs Integration
+=
+
+You can also use :program:`clang-rename` while using Emacs! To set up
+:program:`clang-rename` integration for Emacs see
+`clang-rename/tool/clang-rename.el
+`_.
+
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, type `clang-rename` and new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.
Index: clang-rename/tool/clang-rename.el
===
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; Keywords: tools, c
+
+;;; Commentary:
+
+;; To install clang-rename.el make sure the directory of this file is in your
+;; 'load-path' and add
+;;
+;;   (require 'clang-rename)
+;;
+;; to your .emacs configuration.
+
+;;; Code:
+
+(defcustom clang-rename-binary "clang-rename"
+  "Path to clang-rename executable."
+  :type 'hook
+  :options '(turn-on-auto-fill flyspell-mode)
+  :group 'wp)
+
+(defun clang-rename (new-name)
+  "Rename all instances of the symbol at the point using clang-rename"
+  (interactive "sEnter a new name: ")
+  (let (;; Emacs offset is 1-based.
+(offset (- (point) 1))
+(orig-buf (current-buffer))
+(file-name (buffer-file-name)))
+
+(let ((rename-command
+  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+   clang-rename-binary offset new-name file-name)))
+  (message (format "Running clang-rename command %s" rename-command))
+  ;; Run clang-rename via bash.
+  (shell-command rename-command)
+  ;; Reload buffer.
+  (interactive)
+  (revert-buffer t t)
+)
+  )
+)
+
+(provide 'clang-rename)
+
+;;; clang-rename.el ends here
Index: clang-rename/tool/CMakeLists.txt
===
--- clang-rename/tool/CMakeLists.txt
+++ clang-rename/tool/CMakeLists.txt
@@ -10,3 +10,7 @@
   )
 
 install(TARGETS clang-rename RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang
+  COMPONENT clang-rename)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

In https://reviews.llvm.org/D23006#502814, @Eugene.Zelenko wrote:

> Please add install rule for clang-rename.el. See clang-format CMakeLists.txt 
> as example.


Good point! Thank you!

Done.


https://reviews.llvm.org/D23006



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


Re: [PATCH] D23045: [Include-fixer] Install executables and support scripts

2016-08-02 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



Comment at: include-fixer/find-all-symbols/tool/CMakeLists.txt:22
@@ +21,2 @@
+  DESTINATION share/clang
+  COMPONENT find-all-symbols)

I think we can put it in `clang-include-fixer` as find-all-symbols is a 
sub-tool of include-fixer.


Repository:
  rL LLVM

https://reviews.llvm.org/D23045



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


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

lgtm with two nits.



Comment at: clang-rename/tool/CMakeLists.txt:14
@@ +13,3 @@
+
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang

Also include the vim integration clang-rename.py?


Comment at: docs/clang-rename.rst:99
@@ -98,3 +98,3 @@
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` 
key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)

s/print/type


https://reviews.llvm.org/D23006



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


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66437.
omtcyfz added a comment.

- s/print/type
- Add `clang-rename.py` to the `CMakeLists.txt` installation instructions.


https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/CMakeLists.txt
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -20,15 +20,15 @@
 project. If you have any ideas or suggestions, you might want to put a feature
 request there.
 
-Using clang-rename
+Using Clang-Rename
 ==
 
 :program:`clang-rename` is a `LibTooling
 `_-based tool, and it's easier to
 work with if you set up a compile command database for your project (for an
 example of how to do this see `How To Setup Tooling For LLVM
 `_). You can also
-specify compilation options on the command line after ``--``:
+specify compilation options on the command line after `--`:
 
 .. code-block:: console
 
@@ -47,7 +47,7 @@
 renaming actions in the future.
 
 :program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim, and improve the workflow of users.
+editors, such as Vim and Emacs, and improve the workflow of users.
 
 Although a command line interface exists, it is highly recommended to use the
 text editor interface instead for better experience.
@@ -84,8 +84,8 @@
 -version   - Display the version of this program
 
 
-clang-rename Vim integration
-
+Vim Integration
+===
 
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
@@ -96,7 +96,21 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and type new desired name. The [` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
 is a reference to a specific key defined by the mapleader variable and is bound
 to backslash by default.
+
+Emacs Integration
+=
+
+You can also use :program:`clang-rename` while using Emacs! To set up
+:program:`clang-rename` integration for Emacs see
+`clang-rename/tool/clang-rename.el
+`_.
+
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, type `clang-rename` and new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.
Index: clang-rename/tool/clang-rename.el
===
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; Keywords: tools, c
+
+;;; Commentary:
+
+;; To install clang-rename.el make sure the directory of this file is in your
+;; 'load-path' and add
+;;
+;;   (require 'clang-rename)
+;;
+;; to your .emacs configuration.
+
+;;; Code:
+
+(defcustom clang-rename-binary "clang-rename"
+  "Path to clang-rename executable."
+  :type 'hook
+  :options '(turn-on-auto-fill flyspell-mode)
+  :group 'wp)
+
+(defun clang-rename (new-name)
+  "Rename all instances of the symbol at the point using clang-rename"
+  (interactive "sEnter a new name: ")
+  (let (;; Emacs offset is 1-based.
+(offset (- (point) 1))
+(orig-buf (current-buffer))
+(file-name (buffer-file-name)))
+
+(let ((rename-command
+  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+   clang-rename-binary offset new-name file-name)))
+  (message (format "Running clang-rename command %s" rename-command))
+  ;; Run clang-rename via bash.
+  (shell-command rename-command)
+  ;; Reload buffer.
+  (interactive)
+  (revert-buffer t t)
+)
+  )
+)
+
+(provide 'clang-rename)
+
+;;; clang-rename.el ends here
Index: clang-rename/tool/CMakeLists.txt
===
--- clang-rename/tool/CMakeLists.txt
+++ clang-rename/tool/CMakeLists.txt
@@ -10,3 +10,10 @@
   )
 
 install(TARGETS clang-rename RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-rename.py
+  DESTINATION share/clang
+  COMPONENT clang-rename)
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang
+  COMPONENT clang-rename)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked 2 inline comments as done.
omtcyfz added a comment.

Thanks! Fixed.

Waiting few more hours just in case anyone will jump in and write few comments.


https://reviews.llvm.org/D23006



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


[PATCH] D23054: [clang-cl] Fix 2 pch tests to use x86_64 as target

2016-08-02 Thread Diana Picus via cfe-commits
rovka created this revision.
rovka added a reviewer: thakis.
rovka added subscribers: cfe-commits, hans.
Herald added a subscriber: aemerson.

These tests require x86-registered-target, but they don't force the target as
x86 on the command line, which means they will be run and they might fail when
building the x86 backend on another platform (such as AArch64).

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


https://reviews.llvm.org/D23054

Files:
  test/Driver/cl-pch-search.cpp
  test/Driver/cl-pch-showincludes.cpp

Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,39 +8,39 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
 // CHECK-YC: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YC: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
 // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
 // CHECK-YU: Note: including file: {{[^ ]*header3.h}}
 
 // When not using pch at all, all the /FI files are printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /FIheader2.h /c /Fo%t -- 
%s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/FIheader2.h /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-FI %s
 // CHECK-FI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-FI: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-FI: Note: including file: {{[^ ]*header3.h}}
 
 // Also check that /FI arguments before the /Yc / /Yu flags are printed right.
 
 // /FI flags before the /Yc arg should be printed, /FI flags after it 
shouldn't.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YCFI %s
 // CHECK-YCFI: Note: including file: {{[^ ]*header0.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YCFI: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header4.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header3.h}}
 
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YUFI %s
 // CHECK-YUFI-NOT: Note: including file: {{.*pch}}
 // CHECK-YUFI-NOT: Note: including file: {{.*header0.h}}
Index: test/Driver/cl-pch-search.cpp
===
--- test/Driver/cl-pch-search.cpp
+++ test/Driver/cl-pch-search.cpp
@@ -3,4 +3,4 @@
 
 // REQUIRES: x86-registered-target
 // Check that pchfile.h next to to pchfile.cc is found correctly.
-// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- 
%S/Inputs/pchfile.cpp 
+// RUN: %clang_cl -Werror --target=x86_64 /Ycpchfile.h /FIpchfile.h /c 
/Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp 


Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,39 +8,39 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
 // CHECK-YC: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YC: Note: including file:  {{[^ ]*header1.

Re: [PATCH] D23054: [clang-cl] Fix 2 pch tests to use x86_64 as target

2016-08-02 Thread Diana Picus via cfe-commits
rovka added a comment.

This seems to be the case for other similar tests as well (e.g. 
cl-pch-errorhandling.cpp requires x86-registered-target, but doesn't force it 
on the command line), but they're not currently crashing. I can update those as 
well if people think it's the right thing to do.


https://reviews.llvm.org/D23054



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


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


https://reviews.llvm.org/D23006



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


Re: [PATCH] D23023: [include-fixer] Correct nested class search for identifiers with scoped information

2016-08-02 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
This revision is now accepted and ready to land.


Comment at: include-fixer/SymbolIndexManager.h:32
@@ +31,3 @@
+  /// \param IsNestedSearch Whether searching nested classes. If true, the
+  ///method tries to stripping identifier name parts from the end until
+  ///it finds the corresponding candidates in database (e.g for

"tries to strip"


Comment at: include-fixer/SymbolIndexManager.h:35
@@ +34,3 @@
+  ///identifier "b::foo", the method will try to find "b" if it fails 
on
+  ///finding "b::foo").
+  ///

"fails to find"


https://reviews.llvm.org/D23023



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


[clang-tools-extra] r277433 - [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Tue Aug  2 03:51:26 2016
New Revision: 277433

URL: http://llvm.org/viewvc/llvm-project?rev=277433&view=rev
Log:
[clang-rename] add basic Emacs integration

This patch aims to add very basic Emacs integration.

Reviewers: hokein, alexfh

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


Added:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
Modified:
clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
clang-tools-extra/trunk/docs/clang-rename.rst

Modified: clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt?rev=277433&r1=277432&r2=277433&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt Tue Aug  2 
03:51:26 2016
@@ -10,3 +10,10 @@ target_link_libraries(clang-rename
   )
 
 install(TARGETS clang-rename RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-rename.py
+  DESTINATION share/clang
+  COMPONENT clang-rename)
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang
+  COMPONENT clang-rename)

Added: clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.el?rev=277433&view=auto
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el (added)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el Tue Aug  2 
03:51:26 2016
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; Keywords: tools, c
+
+;;; Commentary:
+
+;; To install clang-rename.el make sure the directory of this file is in your
+;; 'load-path' and add
+;;
+;;   (require 'clang-rename)
+;;
+;; to your .emacs configuration.
+
+;;; Code:
+
+(defcustom clang-rename-binary "clang-rename"
+  "Path to clang-rename executable."
+  :type 'hook
+  :options '(turn-on-auto-fill flyspell-mode)
+  :group 'wp)
+
+(defun clang-rename (new-name)
+  "Rename all instances of the symbol at the point using clang-rename"
+  (interactive "sEnter a new name: ")
+  (let (;; Emacs offset is 1-based.
+(offset (- (point) 1))
+(orig-buf (current-buffer))
+(file-name (buffer-file-name)))
+
+(let ((rename-command
+  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+   clang-rename-binary offset new-name file-name)))
+  (message (format "Running clang-rename command %s" rename-command))
+  ;; Run clang-rename via bash.
+  (shell-command rename-command)
+  ;; Reload buffer.
+  (interactive)
+  (revert-buffer t t)
+)
+  )
+)
+
+(provide 'clang-rename)
+
+;;; clang-rename.el ends here

Modified: clang-tools-extra/trunk/docs/clang-rename.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=277433&r1=277432&r2=277433&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Tue Aug  2 03:51:26 2016
@@ -20,7 +20,7 @@ to `the LLVM bugtracker `_). You can also
-specify compilation options on the command line after ``--``:
+specify compilation options on the command line after `--`:
 
 .. code-block:: console
 
@@ -47,7 +47,7 @@ only. It is planned to extend the tool's
 renaming actions in the future.
 
 :program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim, and improve the workflow of users.
+editors, such as Vim and Emacs, and improve the workflow of users.
 
 Although a command line interface exists, it is highly recommended to use the
 text editor interface instead for better experience.
@@ -84,8 +84,8 @@ text editor interface instead for better
 -version   - Display the version of this program
 
 
-clang-rename Vim integration
-
+Vim Integration
+===
 
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
@@ -96,7 +96,21 @@ Please note that **you have to save all
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desire

Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277433: [clang-rename] add basic Emacs integration (authored 
by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D23006?vs=66437&id=66442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23006

Files:
  clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
  clang-tools-extra/trunk/docs/clang-rename.rst

Index: clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
@@ -10,3 +10,10 @@
   )
 
 install(TARGETS clang-rename RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-rename.py
+  DESTINATION share/clang
+  COMPONENT clang-rename)
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang
+  COMPONENT clang-rename)
Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; Keywords: tools, c
+
+;;; Commentary:
+
+;; To install clang-rename.el make sure the directory of this file is in your
+;; 'load-path' and add
+;;
+;;   (require 'clang-rename)
+;;
+;; to your .emacs configuration.
+
+;;; Code:
+
+(defcustom clang-rename-binary "clang-rename"
+  "Path to clang-rename executable."
+  :type 'hook
+  :options '(turn-on-auto-fill flyspell-mode)
+  :group 'wp)
+
+(defun clang-rename (new-name)
+  "Rename all instances of the symbol at the point using clang-rename"
+  (interactive "sEnter a new name: ")
+  (let (;; Emacs offset is 1-based.
+(offset (- (point) 1))
+(orig-buf (current-buffer))
+(file-name (buffer-file-name)))
+
+(let ((rename-command
+  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+   clang-rename-binary offset new-name file-name)))
+  (message (format "Running clang-rename command %s" rename-command))
+  ;; Run clang-rename via bash.
+  (shell-command rename-command)
+  ;; Reload buffer.
+  (interactive)
+  (revert-buffer t t)
+)
+  )
+)
+
+(provide 'clang-rename)
+
+;;; clang-rename.el ends here
Index: clang-tools-extra/trunk/docs/clang-rename.rst
===
--- clang-tools-extra/trunk/docs/clang-rename.rst
+++ clang-tools-extra/trunk/docs/clang-rename.rst
@@ -20,15 +20,15 @@
 project. If you have any ideas or suggestions, you might want to put a feature
 request there.
 
-Using clang-rename
+Using Clang-Rename
 ==
 
 :program:`clang-rename` is a `LibTooling
 `_-based tool, and it's easier to
 work with if you set up a compile command database for your project (for an
 example of how to do this see `How To Setup Tooling For LLVM
 `_). You can also
-specify compilation options on the command line after ``--``:
+specify compilation options on the command line after `--`:
 
 .. code-block:: console
 
@@ -47,7 +47,7 @@
 renaming actions in the future.
 
 :program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim, and improve the workflow of users.
+editors, such as Vim and Emacs, and improve the workflow of users.
 
 Although a command line interface exists, it is highly recommended to use the
 text editor interface instead for better experience.
@@ -84,8 +84,8 @@
 -version   - Display the version of this program
 
 
-clang-rename Vim integration
-
+Vim Integration
+===
 
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
@@ -96,7 +96,21 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and type new desired name. The [` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
 is a reference to a specific key defined by the mapleader variable and is bound
 to backslash by default.
+
+Emacs Integration
+=
+
+You can also use :program:`clang-rename` while using Emacs! To set up
+:program:`clang-rename` integration for Emacs see
+`clang-rename/tool/clang-rename.el
+`_.
+
+Once installed, you can point your cursor to symbols you want to rename, 

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-02 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D21814



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


Re: [libcxx] r277357 - Improve shared_ptr dtor performance

2016-08-02 Thread Asiri Rathnayake via cfe-commits
Hi Ben,

Looks like there's a typo in this patch that is causing a buildbot failure:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-singlethreaded-x86_64-linux-debian/builds/1128/steps/build.libcxx/logs/stdio

Also seen in our local builders. I will fix it if I get around to it before
you :)

Cheers,

/ Asiri



On Mon, Aug 1, 2016 at 6:51 PM, Ben Craig via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bcraig
> Date: Mon Aug  1 12:51:26 2016
> New Revision: 277357
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277357&view=rev
> Log:
> Improve shared_ptr dtor performance
>
> If the last destruction is uncontended, skip the atomic store on
> __shared_weak_owners_. This shifts some costs from normal
> shared_ptr usage to weak_ptr uses.
>
> https://reviews.llvm.org/D22470
>
> Modified:
> libcxx/trunk/src/memory.cpp
>
> Modified: libcxx/trunk/src/memory.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=277357&r1=277356&r2=277357&view=diff
>
> ==
> --- libcxx/trunk/src/memory.cpp (original)
> +++ libcxx/trunk/src/memory.cpp Mon Aug  1 12:51:26 2016
> @@ -96,7 +96,35 @@ __shared_weak_count::__release_shared()
>  void
>  __shared_weak_count::__release_weak() _NOEXCEPT
>  {
> -if (decrement(__shared_weak_owners_) == -1)
> +// NOTE: The acquire load here is an optimization of the very
> +// common case where a shared pointer is being destructed while
> +// having no other contended references.
> +//
> +// BENEFIT: We avoid expensive atomic stores like XADD and STREX
> +// in a common case.  Those instructions are slow and do nasty
> +// things to caches.
> +//
> +// IS THIS SAFE?  Yes.  During weak destruction, if we see that we
> +// are the last reference, we know that no-one else is accessing
> +// us. If someone were accessing us, then they would be doing so
> +// while the last shared / weak_ptr was being destructed, and
> +// that's undefined anyway.
> +//
> +// If we see anything other than a 0, then we have possible
> +// contention, and need to use an atomicrmw primitive.
> +// The same arguments don't apply for increment, where it is legal
> +// (though inadvisable) to share shared_ptr references between
> +// threads, and have them all get copied at once.  The argument
> +// also doesn't apply for __release_shared, because an outstanding
> +// weak_ptr::lock() could read / modify the shared count.
> +if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Aquire) == 0)
> +{
> +// no need to do this store, because we are about
> +// to destroy everything.
> +//__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
> +__on_zero_shared_weak();
> +}
> +else if (decrement(__shared_weak_owners_) == -1)
>  __on_zero_shared_weak();
>  }
>
>
>
> ___
> 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


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

//Make sure to rebase once more; documentation was updated in the last 
revision.//


https://reviews.llvm.org/D21814



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


Re: [PATCH] D22853: [clang-rename] add support for template parameter renaming

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG



Comment at: clang-rename/USRFinder.cpp:80
@@ -79,1 +79,3 @@
 TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+if (const auto *TemplateTypeParm =
+dyn_cast(Loc.getType())) {

I'm not saying it's prohibited by the LLVM coding guidelines, I'm saying that 
the other convention seems to be substantially more popular across the LLVM 
project. The difference in how readable the two styles are is not large, 
however, mixing the styles may actually hurt readability.

It looks like the use of braces for single-line if/for/... bodies is more 
common in the files being changed in this patch, so being locally consistent 
wrt. brace usage here is probably more valuable than pursuing consistency with 
LLVM code in general.

However, please be careful when changing code that prevalently uses the other 
style (no braces for single-line if/... bodies). Introducing inconsistencies is 
not good in terms of readability.


https://reviews.llvm.org/D22853



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


Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Jonathan B Coe via cfe-commits
jbcoe removed rL LLVM as the repository for this revision.
jbcoe updated this revision to Diff 66444.
jbcoe added a comment.

Add test that triggers segfault without fix in place.


https://reviews.llvm.org/D23008

Files:
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  test/clang-tidy/cppcoreguidelines-special-member-functions.cpp

Index: test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
===
--- test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
+++ test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
@@ -50,3 +50,18 @@
   DeletesCopyDefaultsMove &operator=(DeletesCopyDefaultsMove &&) = default;
   ~DeletesCopyDefaultsMove() = default;
 };
+
+template 
+struct TemplateClass {
+  TemplateClass() = default;
+  TemplateClass(const TemplateClass &);
+  TemplateClass &operator=(const TemplateClass &);
+  TemplateClass(TemplateClass &&);
+  TemplateClass &operator=(TemplateClass &&);
+  ~TemplateClass();
+};
+
+// Multiple instantiations of a class template will trigger multiple matches for defined special members.
+// This should not cause problems.
+TemplateClass InstantiationWithInt;
+TemplateClass InstantiationWithDouble;
Index: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
===
--- clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -1,4 +1,4 @@
-//===--- SpecialMemberFunctionsCheck.h - clang-tidy---*- C++ -*-===//
+//===--- SpecialMemberFunctionsCheck.h - clang-tidy--*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -41,15 +41,11 @@
 
   using ClassDefId = std::pair;
 
-  using ClassDefiningSpecialMembersMap = llvm::DenseMap>;
+  using ClassDefiningSpecialMembersMap =
+  llvm::DenseMap>;
 
 private:
-
-  static llvm::StringRef toString(SpecialMemberFunctionKind K);
-
-  static std::string join(llvm::ArrayRef SMFS,
-  llvm::StringRef AndOr);
-
   ClassDefiningSpecialMembersMap ClassWithSpecialMembers;
 };
 
@@ -65,7 +61,7 @@
 struct DenseMapInfo<
 clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId> {
   using ClassDefId =
-clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
+  clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
 
   static inline ClassDefId getEmptyKey() {
 return ClassDefId(
Index: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
===
--- clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -43,25 +43,25 @@
   this);
 }
 
-llvm::StringRef SpecialMemberFunctionsCheck::toString(
-SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
+static llvm::StringRef
+toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
   switch (K) {
-  case SpecialMemberFunctionKind::Destructor:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::Destructor:
 return "a destructor";
-  case SpecialMemberFunctionKind::CopyConstructor:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::CopyConstructor:
 return "a copy constructor";
-  case SpecialMemberFunctionKind::CopyAssignment:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::CopyAssignment:
 return "a copy assignment operator";
-  case SpecialMemberFunctionKind::MoveConstructor:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::MoveConstructor:
 return "a move constructor";
-  case SpecialMemberFunctionKind::MoveAssignment:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::MoveAssignment:
 return "a move assignment operator";
   }
   llvm_unreachable("Unhandled SpecialMemberFunctionKind");
 }
 
-std::string SpecialMemberFunctionsCheck::join(
-llvm::ArrayRef SMFS, llvm::StringRef AndOr) {
+template 
+static std::string join(const R &SMFS, llvm::StringRef AndOr) {
 
   assert(!SMFS.empty() &&
  "List of defined or undefined members should never be empty.");
@@ -97,7 +97,7 @@
 
   for (const auto &KV : Matchers)
 if (Result.Nodes.getNodeAs(KV.first))
-  ClassWithSpecialMembers[ID].push_back(KV.second);
+  ClassWithSpecialMembers[ID].insert(KV.second);
 }
 
 void SpecialMemberFunctionsCheck::onEndOfTranslationUnit() {
@@ -112,7 +112,7 @@
   }
 
   for (const auto &C : ClassWithSpecialMembers) {
-ArrayRef DefinedSpecialMembers = C.second;
+const auto &DefinedSpecialMembers = C.second;
 
 if (DefinedSpecialMembers.size() == AllSpecialMembers.size())
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org

[clang-tools-extra] r277437 - [clang-rename] add support for template parameter renaming

2016-08-02 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Tue Aug  2 04:38:38 2016
New Revision: 277437

URL: http://llvm.org/viewvc/llvm-project?rev=277437&view=rev
Log:
[clang-rename] add support for template parameter renaming

Few simple tweaks allow template parameters to be renamed. See
TemplateTypenameFindBy{TemplateParam|TypeInside}.cpp

Reviewers: alexfh

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


Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp

clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=277437&r1=277436&r2=277437&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Tue Aug  2 04:38:38 2016
@@ -77,6 +77,10 @@ public:
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
 TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+if (const auto *TemplateTypeParm =
+dyn_cast(Loc.getType())) {
+  return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
+}
 return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
  TypeEndLoc);
   }

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=277437&r1=277436&r2=277437&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Tue Aug  2 04:38:38 
2016
@@ -104,6 +104,13 @@ public:
 USRSet.end()) {
   checkAndAddLocation(Loc.getBeginLoc());
 }
+if (const auto *TemplateTypeParm =
+dyn_cast(Loc.getType())) {
+  if (USRSet.find(getUSRForDecl(TemplateTypeParm->getDecl())) !=
+  USRSet.end()) {
+checkAndAddLocation(Loc.getBeginLoc());
+  }
+}
 return true;
   }
 

Modified: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp?rev=277437&r1=277436&r2=277437&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
 Tue Aug  2 04:38:38 2016
@@ -1,11 +1,7 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=270 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=147 -new-name=U %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {

Modified: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp?rev=277437&r1=277436&r2=277437&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp 
Tue Aug  2 04:38:38 2016
@@ -1,11 +1,7 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=350 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=227 -new-name=U %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {


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


Re: [PATCH] D22853: [clang-rename] add support for template parameter renaming

2016-08-02 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277437: [clang-rename] add support for template parameter 
renaming (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D22853?vs=66373&id=66446#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22853

Files:
  clang-tools-extra/trunk/clang-rename/USRFinder.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
  clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp

Index: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
===
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
@@ -1,11 +1,7 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=350 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=227 -new-name=U %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
Index: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
===
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
@@ -1,11 +1,7 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=270 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=147 -new-name=U %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
Index: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp
@@ -77,6 +77,10 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
 TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+if (const auto *TemplateTypeParm =
+dyn_cast(Loc.getType())) {
+  return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
+}
 return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
  TypeEndLoc);
   }
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -104,6 +104,13 @@
 USRSet.end()) {
   checkAndAddLocation(Loc.getBeginLoc());
 }
+if (const auto *TemplateTypeParm =
+dyn_cast(Loc.getType())) {
+  if (USRSet.find(getUSRForDecl(TemplateTypeParm->getDecl())) !=
+  USRSet.end()) {
+checkAndAddLocation(Loc.getBeginLoc());
+  }
+}
 return true;
   }
 


Index: clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
+++ clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
@@ -1,11 +1,7 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=350 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=227 -new-name=U %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
Index: clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
+++ clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
@@ -1,11 +1,7 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=270 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=147 -new-name=U %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
-
 template  

Re: [PATCH] D22208: [clang-tidy] Fixes to modernize-use-emplace

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please add revision number (this can be automated, if include differential 
revision URL in your commit message as described in 
http://llvm.org/docs/Phabricator.html#committing-a-change).


https://reviews.llvm.org/D22208



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


[clang-tools-extra] r277438 - clang-rename: split existing options into two new subcommands

2016-08-02 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Aug  2 04:51:31 2016
New Revision: 277438

URL: http://llvm.org/viewvc/llvm-project?rev=277438&view=rev
Log:
clang-rename: split existing options into two new subcommands

- rename-at is meant to be integrated with editors and works mainly off
  of a location in a file, and this is the default
- rename-all is optimized for one or more oldname->newname renames, and
  works with clang-apply-replacements

Reviewers: bkramer, klimek

Subscribers: omtcyfz

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

Added:
clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/RenamingAction.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=277438&r1=277437&r2=277438&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Tue Aug  2 04:51:31 
2016
@@ -35,14 +35,23 @@ namespace rename {
 class RenamingASTConsumer : public ASTConsumer {
 public:
   RenamingASTConsumer(
-  const std::string &NewName, const std::string &PrevName,
-  const std::vector &USRs,
+  const std::vector &NewNames,
+  const std::vector &PrevNames,
+  const std::vector> &USRList,
   std::map &FileToReplaces,
   bool PrintLocations)
-  : NewName(NewName), PrevName(PrevName), USRs(USRs),
+  : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
+for (unsigned I = 0; I < NewNames.size(); ++I) {
+  HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]);
+}
+  }
+
+  void HandleOneRename(ASTContext &Context, const std::string &NewName,
+   const std::string &PrevName,
+   const std::vector &USRs) {
 const auto &SourceMgr = Context.getSourceManager();
 std::vector RenamingCandidates;
 std::vector NewCandidates;
@@ -70,14 +79,14 @@ public:
   }
 
 private:
-  const std::string &NewName, &PrevName;
-  const std::vector &USRs;
+  const std::vector &NewNames, &PrevNames;
+  const std::vector> &USRList;
   std::map &FileToReplaces;
   bool PrintLocations;
 };
 
 std::unique_ptr RenamingAction::newASTConsumer() {
-  return llvm::make_unique(NewName, PrevName, USRs,
+  return llvm::make_unique(NewNames, PrevNames, USRList,
 FileToReplaces, 
PrintLocations);
 }
 

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.h?rev=277438&r1=277437&r2=277438&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.h (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.h Tue Aug  2 04:51:31 
2016
@@ -25,18 +25,19 @@ namespace rename {
 
 class RenamingAction {
 public:
-  RenamingAction(const std::string &NewName, const std::string &PrevName,
- const std::vector &USRs,
+  RenamingAction(const std::vector &NewNames,
+ const std::vector &PrevNames,
+ const std::vector> &USRList,
  std::map &FileToReplaces,
  bool PrintLocations = false)
-  : NewName(NewName), PrevName(PrevName), USRs(USRs),
+  : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   std::unique_ptr newASTConsumer();
 
 private:
-  const std::string &NewName, &PrevName;
-  const std::vector &USRs;
+  const std::vector &NewNames, &PrevNames;
+  const std::vector> &USRList;
   std::map &FileToReplaces;
   bool PrintLocations;
 };

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=277438&r1=277437&r2=277438&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Tue Aug  2 
04:51:31 2016
@@ -39,94 +39,146 @@
 
 using namespace llvm;
 
-cl::OptionCategory

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-02 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277438: clang-rename: split existing options into two new 
subcommands (authored by vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D21814?vs=66362&id=66448#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21814

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/RenamingAction.h
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/docs/clang-rename.rst
  clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
  clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
  clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp

Index: clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar
Index: clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -offset=174 -new-name=Bar1 -offset=212 -new-name=Bar2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 void foo() {
Index: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
@@ -35,14 +35,23 @@
 class RenamingASTConsumer : public ASTConsumer {
 public:
   RenamingASTConsumer(
-  const std::string &NewName, const std::string &PrevName,
-  const std::vector &USRs,
+  const std::vector &NewNames,
+  const std::vector &PrevNames,
+  const std::vector> &USRList,
   std::map &FileToReplaces,
   bool PrintLocations)
-  : NewName(NewName), PrevName(PrevName), USRs(USRs),
+  : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
+for (unsigned I = 0; I < NewNames.size(); ++I) {
+  HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]);
+}
+  }
+
+  void HandleOneRename(ASTContext &Context, const std::string &NewName,
+   const std::string &PrevName,
+   const std::vector &USRs) {
 const auto &SourceMgr = Context.getSourceManager();
 std::vector RenamingCandidates;
 std::vector NewCandidates;
@@ -70,14 +79,14 @@
   }
 
 private:
-  const std::string &NewName, &PrevName;
-  cons

Re: [PATCH] D22208: [clang-tidy] Fixes to modernize-use-emplace

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:115
@@ -95,1 +114,3 @@
+  auto CtorCallSourceRange = CharSourceRange::getTokenRange(
+  InnerCtorCall->getExprLoc(), CallParensRange.getBegin());
 

Prazek wrote:
> alexfh wrote:
> > Prazek wrote:
> > > alexfh wrote:
> > > > This doesn't seem to be an issue, since expression 
> > > > `v.push_back(obj.member())` won't trigger this check: it expects that 
> > > > the argument of the `push_back` call is a `cxxConstructExpr` or a 
> > > > `cxxFunctionalCastExpr`.
> > > what about the implicit conversion? What if obj.member would return 
> > > object that is different from the one that v stores, but it is 
> > > convertible to it?
> > Sounds almost like a recipe for a test case ;) Have you tried to construct 
> > it this way?
> Yes, I think I emulated this case in line 190. I tried to hit this problem 
> but could not find the test case.
>> if The Call->getArg(0) will be a memberExpr (call to member function)
> what about the implicit conversion?

I think, I know what happens in this case. When an implicit conversion happens 
in `v.push_back(obj.member())`, then `Call->getArg(0)` is an implicit 
`CXXConstructExpr`, not a `MemberExpr` (`MemberExpr` will be its indirect 
child). The case should be handled correctly.


https://reviews.llvm.org/D22208



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


Re: [PATCH] D23023: [include-fixer] Correct nested class search for identifiers with scoped information

2016-08-02 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 66452.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D23023

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.cpp
  include-fixer/SymbolIndexManager.cpp
  include-fixer/SymbolIndexManager.h
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -77,6 +77,12 @@
   SymbolInfo("Vector", SymbolInfo::SymbolKind::Class, "\"Vector.h\"", 2,
  {{SymbolInfo::ContextType::Namespace, "a"}},
  /*num_occurrences=*/1),
+  SymbolInfo("StrCat", SymbolInfo::SymbolKind::Class, "\"strcat.h\"",
+ 1, {{SymbolInfo::ContextType::Namespace, "str"}}),
+  SymbolInfo("str", SymbolInfo::SymbolKind::Class, "\"str.h\"",
+ 1, {}),
+  SymbolInfo("foo2", SymbolInfo::SymbolKind::Class, "\"foo2.h\"",
+ 1, {}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -189,6 +195,16 @@
   // full match.
   EXPECT_EQ("#include \"bar.h\"\nnamespace A {\na::b::bar b;\n}",
 runIncludeFixer("namespace A {\nb::bar b;\n}"));
+
+  // Finds candidates for "str::StrCat".
+  EXPECT_EQ("#include \"strcat.h\"\nnamespace foo2 {\nstr::StrCat b;\n}",
+runIncludeFixer("namespace foo2 {\nstr::StrCat b;\n}"));
+  // str::StrCat2 doesn't exist.
+  // In these two cases, StrCat2 is a nested class of class str.
+  EXPECT_EQ("#include \"str.h\"\nnamespace foo2 {\nstr::StrCat2 b;\n}",
+runIncludeFixer("namespace foo2 {\nstr::StrCat2 b;\n}"));
+  EXPECT_EQ("#include \"str.h\"\nnamespace ns {\nstr::StrCat2 b;\n}",
+runIncludeFixer("namespace ns {\nstr::StrCat2 b;\n}"));
 }
 
 TEST(IncludeFixer, EnumConstantSymbols) {
@@ -253,7 +269,7 @@
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
-  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: include-fixer/SymbolIndexManager.h
===
--- include-fixer/SymbolIndexManager.h
+++ include-fixer/SymbolIndexManager.h
@@ -28,12 +28,15 @@
   /// Search for header files to be included for an identifier.
   /// \param Identifier The identifier being searched for. May or may not be
   ///   fully qualified.
-  /// \returns A list of inclusion candidates, in a format ready for being
-  ///  pasted after an #include token.
-  // FIXME: Move mapping from SymbolInfo to headers out of
-  // SymbolIndexManager::search and return SymbolInfos instead of header paths.
+  /// \param IsNestedSearch Whether searching nested classes. If true, the
+  ///method tries to strip identifier name parts from the end until it
+  ///finds the corresponding candidates in database (e.g for identifier
+  ///"b::foo", the method will try to find "b" if it fails to find
+  ///"b::foo").
+  ///
+  /// \returns A list of symbol candidates.
   std::vector
-  search(llvm::StringRef Identifier) const;
+  search(llvm::StringRef Identifier, bool IsNestedSearch = true) const;
 
 private:
   std::vector> SymbolIndices;
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -42,7 +42,8 @@
 }
 
 std::vector
-SymbolIndexManager::search(llvm::StringRef Identifier) const {
+SymbolIndexManager::search(llvm::StringRef Identifier,
+   bool IsNestedSearch) const {
   // The identifier may be fully qualified, so split it and get all the context
   // names.
   llvm::SmallVector Names;
@@ -60,7 +61,7 @@
   // either) and can report that result.
   bool TookPrefix = false;
   std::vector MatchedSymbols;
-  while (MatchedSymbols.empty() && !Names.empty()) {
+  do {
 std::vector Symbols;
 for (const auto &DB : SymbolIndices) {
   auto Res = DB->search(Names.back().str());
@@ -116,7 +117,7 @@
 }
 Names.pop_back();
 TookPrefix = true;
-  }
+  } while (MatchedSymbols.empty() && !Names.empty() && IsNestedSearch);
 
   rankByPopularity(MatchedSymbols);
   return MatchedSymbols;
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -44,7 +44,8 @@
   std::string Stripped

Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Sorry for the delay. I almost missed that there was an update to the patch. 
Please mark addressed comments as "Done". This way it's easier for me to track 
changes and it's easier for you not to miss review comments.

One more thing that this check lacks is fix-it hints, however, this can be 
added later.



Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.h:26
@@ +25,3 @@
+ public:
+  InefficientStringConcatenationCheck(StringRef Name, ClangTidyContext 
*Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;

The formatting is still off (specifically, indentation of `public:` and 
`private:` and the lack of an empty line before `private:`).


https://reviews.llvm.org/D20196



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


[clang-tools-extra] r277442 - [include-fixer] Correct nested class search for identifiers with scoped information

2016-08-02 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Aug  2 05:43:10 2016
New Revision: 277442

URL: http://llvm.org/viewvc/llvm-project?rev=277442&view=rev
Log:
[include-fixer] Correct nested class search for identifiers with scoped 
information

Summary:
include-fixer will firstly try to use scoped namespace context information to
search identifier. However, in some cases, it's unsafe to do nested class
search, because it might treat the identifier as a nested class of scoped
namespace.

Given the following code, and the symbol database only has two classes: "foo" 
and
"b::Bar".

namespace foo { Bar t; }

Before getting fixing, include-fixer will never search "Bar" symbol.
Because it firstly tries to search "foo::Bar", there is no "Bar" in foo 
namespace,
then it finds "foo" in database finally. So it treats "Bar" is a nested class
of "foo".

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=277442&r1=277441&r2=277442&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue Aug  2 05:43:10 
2016
@@ -275,8 +275,11 @@ private:
 // 1. lookup a::b::foo.
 // 2. lookup b::foo.
 std::string QueryString = ScopedQualifiers.str() + Query.str();
-MatchedSymbols = SymbolIndexMgr.search(QueryString);
-if (MatchedSymbols.empty() && !ScopedQualifiers.empty())
+// It's unsafe to do nested search for the identifier with scoped namespace
+// context, it might treat the identifier as a nested class of the scoped
+// namespace.
+MatchedSymbols = SymbolIndexMgr.search(QueryString, 
/*IsNestedSearch=*/false);
+if (MatchedSymbols.empty())
   MatchedSymbols = SymbolIndexMgr.search(Query);
 DEBUG(llvm::dbgs() << "Having found " << MatchedSymbols.size()
<< " symbols\n");

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp?rev=277442&r1=277441&r2=277442&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp Tue Aug  2 
05:43:10 2016
@@ -44,7 +44,8 @@ std::string createQualifiedNameForReplac
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
  !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
-StrippedQualifiers = "::" + SymbolQualifiers.back().str();
+StrippedQualifiers =
+"::" + SymbolQualifiers.back().str() + StrippedQualifiers;
 SymbolQualifiers.pop_back();
   }
   // Append the missing stripped qualifiers.

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=277442&r1=277441&r2=277442&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Tue Aug  2 
05:43:10 2016
@@ -42,7 +42,8 @@ static void rankByPopularity(std::vector
 }
 
 std::vector
-SymbolIndexManager::search(llvm::StringRef Identifier) const {
+SymbolIndexManager::search(llvm::StringRef Identifier,
+   bool IsNestedSearch) const {
   // The identifier may be fully qualified, so split it and get all the context
   // names.
   llvm::SmallVector Names;
@@ -60,7 +61,7 @@ SymbolIndexManager::search(llvm::StringR
   // either) and can report that result.
   bool TookPrefix = false;
   std::vector MatchedSymbols;
-  while (MatchedSymbols.empty() && !Names.empty()) {
+  do {
 std::vector Symbols;
 for (const auto &DB : SymbolIndices) {
   auto Res = DB->search(Names.back().str());
@@ -116,7 +117,7 @@ SymbolIndexManager::search(llvm::StringR
 }
 Names.pop_back();
 TookPrefix = true;
-  }
+  } while (MatchedSymbols.empty() && !Names.empty() && IsNestedSearch);
 
   rankByPopularity(MatchedSymbols);
   return MatchedSymbols;

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?rev=277442&r1=277441&r2=2

Re: [PATCH] D23023: [include-fixer] Correct nested class search for identifiers with scoped information

2016-08-02 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277442: [include-fixer] Correct nested class search for 
identifiers with scoped… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D23023?vs=66452&id=66454#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23023

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -77,6 +77,12 @@
   SymbolInfo("Vector", SymbolInfo::SymbolKind::Class, "\"Vector.h\"", 2,
  {{SymbolInfo::ContextType::Namespace, "a"}},
  /*num_occurrences=*/1),
+  SymbolInfo("StrCat", SymbolInfo::SymbolKind::Class, "\"strcat.h\"",
+ 1, {{SymbolInfo::ContextType::Namespace, "str"}}),
+  SymbolInfo("str", SymbolInfo::SymbolKind::Class, "\"str.h\"",
+ 1, {}),
+  SymbolInfo("foo2", SymbolInfo::SymbolKind::Class, "\"foo2.h\"",
+ 1, {}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -189,6 +195,16 @@
   // full match.
   EXPECT_EQ("#include \"bar.h\"\nnamespace A {\na::b::bar b;\n}",
 runIncludeFixer("namespace A {\nb::bar b;\n}"));
+
+  // Finds candidates for "str::StrCat".
+  EXPECT_EQ("#include \"strcat.h\"\nnamespace foo2 {\nstr::StrCat b;\n}",
+runIncludeFixer("namespace foo2 {\nstr::StrCat b;\n}"));
+  // str::StrCat2 doesn't exist.
+  // In these two cases, StrCat2 is a nested class of class str.
+  EXPECT_EQ("#include \"str.h\"\nnamespace foo2 {\nstr::StrCat2 b;\n}",
+runIncludeFixer("namespace foo2 {\nstr::StrCat2 b;\n}"));
+  EXPECT_EQ("#include \"str.h\"\nnamespace ns {\nstr::StrCat2 b;\n}",
+runIncludeFixer("namespace ns {\nstr::StrCat2 b;\n}"));
 }
 
 TEST(IncludeFixer, EnumConstantSymbols) {
@@ -253,7 +269,7 @@
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
-  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
@@ -28,12 +28,15 @@
   /// Search for header files to be included for an identifier.
   /// \param Identifier The identifier being searched for. May or may not be
   ///   fully qualified.
-  /// \returns A list of inclusion candidates, in a format ready for being
-  ///  pasted after an #include token.
-  // FIXME: Move mapping from SymbolInfo to headers out of
-  // SymbolIndexManager::search and return SymbolInfos instead of header paths.
+  /// \param IsNestedSearch Whether searching nested classes. If true, the
+  ///method tries to strip identifier name parts from the end until it
+  ///finds the corresponding candidates in database (e.g for identifier
+  ///"b::foo", the method will try to find "b" if it fails to find
+  ///"b::foo").
+  ///
+  /// \returns A list of symbol candidates.
   std::vector
-  search(llvm::StringRef Identifier) const;
+  search(llvm::StringRef Identifier, bool IsNestedSearch = true) const;
 
 private:
   std::vector> SymbolIndices;
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -42,7 +42,8 @@
 }
 
 std::vector
-SymbolIndexManager::search(llvm::StringRef Identifier) const {
+SymbolIndexManager::search(llvm::StringRef Identifier,
+   bool IsNestedSearch) const {
   // The identifier may be fully qualified, so split it and get all the context
   // names.
   llvm::SmallVector Names;
@@ -60,7 +61,7 @@
   // either) and can report that result.
   bool TookPrefix = false;
   std::vector MatchedSymbols;
-  while (MatchedSymbols.empty() && !Names.empty()) {
+  do {
 std::vector Symbols;
 f

Re: [PATCH] D23054: [clang-cl] Fix 2 pch tests to use x86_64 as target

2016-08-02 Thread Renato Golin via cfe-commits
rengolin added a subscriber: rengolin.
rengolin added a comment.

All tests should have the target explicit, so I'd advocate for all of them to 
be changed.

Also, we need to make sure --target=x86_64 is enough on Windows. I remember 
some -target=arm not being enough (arm-eabi was enough, for some reason).


https://reviews.llvm.org/D23054



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


[clang-tools-extra] r277444 - [clang-tidy] Fix an unused-using-decl false positive about template arguments in

2016-08-02 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Aug  2 06:26:35 2016
New Revision: 277444

URL: http://llvm.org/viewvc/llvm-project?rev=277444&view=rev
Log:
[clang-tidy] Fix an unused-using-decl false positive about template arguments in
function call expression.

Summary:
The check doesn't mark the template argument as used when the template
argument is a template.

Reviewers: djasper, alexfh

Subscribers: klimek, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=277444&r1=277443&r2=277444&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Tue Aug  
2 06:26:35 2016
@@ -37,6 +37,11 @@ void UnusedUsingDeclsCheck::registerMatc
   Finder->addMatcher(declRefExpr().bind("used"), this);
   Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
  this);
+  Finder->addMatcher(
+  callExpr(hasDeclaration(functionDecl(hasAnyTemplateArgument(
+  anyOf(refersToTemplate(templateName().bind("used")),
+refersToDeclaration(functionDecl().bind("used"))),
+  this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -71,20 +76,27 @@ void UnusedUsingDeclsCheck::check(const
   Contexts.push_back(Context);
 return;
   }
-
   // Mark using declarations as used by setting FoundDecls' value to zero. As
   // the AST is walked in order, usages are only marked after a the
   // corresponding using declaration has been found.
   // FIXME: This currently doesn't look at whether the type reference is
   // actually found with the help of the using declaration.
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-if (const auto *Specialization =
-dyn_cast(Used))
+if (const auto *FD = dyn_cast(Used)) {
+  removeFromFoundDecls(FD->getPrimaryTemplate());
+} else if (const auto *Specialization =
+   dyn_cast(Used)) {
   Used = Specialization->getSpecializedTemplate();
+}
 removeFromFoundDecls(Used);
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+removeFromFoundDecls(Used->getAsTemplateDecl());
+return;
+  }
+
   if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
 if (const auto *FD = dyn_cast(DRE->getDecl())) {
   if (const auto *FDT = FD->getPrimaryTemplate())
@@ -109,6 +121,8 @@ void UnusedUsingDeclsCheck::check(const
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  if (!D)
+return;
   // FIXME: Currently, we don't handle the using-decls being used in different
   // scopes (such as different namespaces, different functions). Instead of
   // giving an incorrect message, we mark all of them as used.

Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h?rev=277444&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h Tue Aug 
 2 06:26:35 2016
@@ -0,0 +1,11 @@
+class MyClass {
+public:
+  template  class S, typename T>
+  S *func1(T *a) {
+return new S();
+  }
+  template 
+  void func2(T a) {
+S();
+  }
+};

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=277444&r1=277443&r2=277444&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Tue Aug 
 2 06:26:35 2016
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- 
-fno-delayed-template-parsing -isystem %S/Inputs/
+
 
 // - Definitions -
 template  class vector {};
@@ -54,6 +55,16 @@ enum Color4 { Blue };
 
 }  // namespace n
 
+#include "unused-using-decls.h"
+namespace ns {
+template 
+class AA {
+  T t;
+};
+template 
+T ff() { T t; return t; }
+} // namespace ns
+
 // - Using declarations -
 // eol-comments aren't removed (yet)
 using n::A; // A
@@ -1

Re: [PATCH] D22803: [clang-tidy] Fix an unused-using-decl false positive about template arguments infunction call expression.

2016-08-02 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL277444: [clang-tidy] Fix an unused-using-decl false positive 
about template arguments in (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D22803?vs=66131&id=66457#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22803

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -37,6 +37,11 @@
   Finder->addMatcher(declRefExpr().bind("used"), this);
   Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
  this);
+  Finder->addMatcher(
+  callExpr(hasDeclaration(functionDecl(hasAnyTemplateArgument(
+  anyOf(refersToTemplate(templateName().bind("used")),
+refersToDeclaration(functionDecl().bind("used"))),
+  this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -71,20 +76,27 @@
   Contexts.push_back(Context);
 return;
   }
-
   // Mark using declarations as used by setting FoundDecls' value to zero. As
   // the AST is walked in order, usages are only marked after a the
   // corresponding using declaration has been found.
   // FIXME: This currently doesn't look at whether the type reference is
   // actually found with the help of the using declaration.
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-if (const auto *Specialization =
-dyn_cast(Used))
+if (const auto *FD = dyn_cast(Used)) {
+  removeFromFoundDecls(FD->getPrimaryTemplate());
+} else if (const auto *Specialization =
+   dyn_cast(Used)) {
   Used = Specialization->getSpecializedTemplate();
+}
 removeFromFoundDecls(Used);
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+removeFromFoundDecls(Used->getAsTemplateDecl());
+return;
+  }
+
   if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
 if (const auto *FD = dyn_cast(DRE->getDecl())) {
   if (const auto *FDT = FD->getPrimaryTemplate())
@@ -109,6 +121,8 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  if (!D)
+return;
   // FIXME: Currently, we don't handle the using-decls being used in different
   // scopes (such as different namespaces, different functions). Instead of
   // giving an incorrect message, we mark all of them as used.
Index: clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h
===
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/unused-using-decls.h
@@ -0,0 +1,11 @@
+class MyClass {
+public:
+  template  class S, typename T>
+  S *func1(T *a) {
+return new S();
+  }
+  template 
+  void func2(T a) {
+S();
+  }
+};
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- -fno-delayed-template-parsing -isystem %S/Inputs/
+
 
 // - Definitions -
 template  class vector {};
@@ -54,6 +55,16 @@
 
 }  // namespace n
 
+#include "unused-using-decls.h"
+namespace ns {
+template 
+class AA {
+  T t;
+};
+template 
+T ff() { T t; return t; }
+} // namespace ns
+
 // - Using declarations -
 // eol-comments aren't removed (yet)
 using n::A; // A
@@ -136,6 +147,9 @@
 using n::Color3;
 using n::Blue;
 
+using ns::AA;
+using ns::ff;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -151,4 +165,9 @@
   Color2 color2;
   int t1 = Color3::Yellow;
   int t2 = Blue;
+
+  MyClass a;
+  int t3 = 0;
+  a.func1(&t3);
+  a.func2(t3);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-08-02 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/FormatTokenLexer.cpp:254
@@ +253,3 @@
+  for (; Offset != Lex->getBuffer().end(); ++Offset) {
+if (*Offset == '`') {
+  StateStack.pop();

I'd use Offset[0]


Comment at: lib/Format/FormatTokenLexer.h:85
@@ -68,2 +84,3 @@
   bool GreaterStashed, LessStashed;
+  std::stack StateStack;
   unsigned Column;

Should we also use this for GreaterStashed and LessStashed?


https://reviews.llvm.org/D22431



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


Re: [PATCH] D22834: Added 'inline' attribute to basic_string's destructor

2016-08-02 Thread Marshall Clow via cfe-commits
On Sat, Jul 30, 2016 at 12:47 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Jul 26, 2016 at 10:30:22PM +, Laxman Sole via cfe-commits
> wrote:
> > Currently basic_string's destructor is not getting inlined. So adding
> 'inline' attribute to ~basic_string().
>
> Does this change the ABI?
>
>
That would be a concern for me.
Not an AbI change, really but existing programs expect the dtor to exist in
the dylib.

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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Perhaps call it AccessModifierIntroducesScope or something?

Side-track: I find it highly confusing that in

  class C {
int v1;
private:
  int v2;
  }

v1 & v2 have different indent, although they are in the same scope.


https://reviews.llvm.org/D22505



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


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-08-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277449: [analyzer] Respect statement-specific data in 
CloneDetection. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D22514?vs=66309&id=66460#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22514

Files:
  cfe/trunk/include/clang/Analysis/CloneDetection.h
  cfe/trunk/lib/Analysis/CloneDetection.cpp
  cfe/trunk/test/Analysis/copypaste/asm.cpp
  cfe/trunk/test/Analysis/copypaste/attributes.cpp
  cfe/trunk/test/Analysis/copypaste/call.cpp
  cfe/trunk/test/Analysis/copypaste/catch.cpp
  cfe/trunk/test/Analysis/copypaste/delete.cpp
  cfe/trunk/test/Analysis/copypaste/dependent-exist.cpp
  cfe/trunk/test/Analysis/copypaste/expr-types.cpp
  cfe/trunk/test/Analysis/copypaste/false-positives.cpp
  cfe/trunk/test/Analysis/copypaste/fold.cpp
  cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
  cfe/trunk/test/Analysis/copypaste/functions.cpp
  cfe/trunk/test/Analysis/copypaste/generic.c
  cfe/trunk/test/Analysis/copypaste/labels.cpp
  cfe/trunk/test/Analysis/copypaste/lambda.cpp

Index: cfe/trunk/include/clang/Analysis/CloneDetection.h
===
--- cfe/trunk/include/clang/Analysis/CloneDetection.h
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h
@@ -157,14 +157,16 @@
 /// are not supported.
 class CloneDetector {
 public:
+  typedef unsigned DataPiece;
+
   /// Holds the data about a StmtSequence that is needed during the search for
   /// code clones.
   struct CloneSignature {
 /// \brief Holds all relevant data of a StmtSequence.
 ///
 /// If this variable is equal for two different StmtSequences, then they can
 /// be considered clones of each other.
-std::vector Data;
+std::vector Data;
 
 /// \brief The complexity of the StmtSequence.
 ///
Index: cfe/trunk/test/Analysis/copypaste/labels.cpp
===
--- cfe/trunk/test/Analysis/copypaste/labels.cpp
+++ cfe/trunk/test/Analysis/copypaste/labels.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+
+bool foo1(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Targeting a different label with the address-of-label operator.
+bool foo2(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&end;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Different target label in goto
+bool foo3(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto end;
+  }
+  end:
+  return false;
+}
+
+// FIXME: Can't detect same algorithm as in foo1 but with different label names.
+bool foo4(int x) {
+  foo:
+  if (x != 3) {
+++x;
+void *ptr = &&foo;
+goto foo;
+  }
+  end:
+  return false;
+}
Index: cfe/trunk/test/Analysis/copypaste/delete.cpp
===
--- cfe/trunk/test/Analysis/copypaste/delete.cpp
+++ cfe/trunk/test/Analysis/copypaste/delete.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+bool foo1(int x, int* a) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+delete a;
+  return true;
+}
+
+// Explicit global delete
+bool foo2(int x, int* a) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+::delete a;
+  return true;
+}
+
+// Array delete
+bool foo3(int x, int* a) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+delete[] a;
+  return true;
+}
Index: cfe/trunk/test/Analysis/copypaste/dependent-exist.cpp
===
--- cfe/trunk/test/Analysis/copypaste/dependent-exist.cpp
+++ cfe/trunk/test/Analysis/copypaste/dependent-exist.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -analyze -fms-extensions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+bool foo1(int x) {
+  if (x < 0) {
+__if_exists(x) { return false; }
+  }
+  return true;
+}
+
+// Same as above, but __if_not_exists
+bool foo2(int x) {
+  if (x < 0) {
+__if_not_exists(x) { return false; }
+  }
+  return true;
+}
Index: cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
===
--- cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
+++ cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if function try blocks are correctly handled.
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x

r277449 - [analyzer] Respect statement-specific data in CloneDetection.

2016-08-02 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug  2 07:21:09 2016
New Revision: 277449

URL: http://llvm.org/viewvc/llvm-project?rev=277449&view=rev
Log:
[analyzer] Respect statement-specific data in CloneDetection.

So far the CloneDetector only respected the kind of each statement when
searching for clones. This patch refines the way the CloneDetector collects data
from each statement by providing methods for each statement kind,
that will read the kind-specific attributes.

For example, statements 'a < b' and 'a > b' are no longer considered to be
clones, because they are different in operation code, which is an attribute
specific to the BinaryOperator statement kind.

Patch by Raphael Isemann!

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

Added:
cfe/trunk/test/Analysis/copypaste/asm.cpp
cfe/trunk/test/Analysis/copypaste/attributes.cpp
cfe/trunk/test/Analysis/copypaste/call.cpp
cfe/trunk/test/Analysis/copypaste/catch.cpp
cfe/trunk/test/Analysis/copypaste/delete.cpp
cfe/trunk/test/Analysis/copypaste/dependent-exist.cpp
cfe/trunk/test/Analysis/copypaste/expr-types.cpp
cfe/trunk/test/Analysis/copypaste/fold.cpp
cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
cfe/trunk/test/Analysis/copypaste/generic.c
cfe/trunk/test/Analysis/copypaste/labels.cpp
cfe/trunk/test/Analysis/copypaste/lambda.cpp
Modified:
cfe/trunk/include/clang/Analysis/CloneDetection.h
cfe/trunk/lib/Analysis/CloneDetection.cpp
cfe/trunk/test/Analysis/copypaste/false-positives.cpp
cfe/trunk/test/Analysis/copypaste/functions.cpp

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=277449&r1=277448&r2=277449&view=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Tue Aug  2 07:21:09 2016
@@ -157,6 +157,8 @@ public:
 /// are not supported.
 class CloneDetector {
 public:
+  typedef unsigned DataPiece;
+
   /// Holds the data about a StmtSequence that is needed during the search for
   /// code clones.
   struct CloneSignature {
@@ -164,7 +166,7 @@ public:
 ///
 /// If this variable is equal for two different StmtSequences, then they 
can
 /// be considered clones of each other.
-std::vector Data;
+std::vector Data;
 
 /// \brief The complexity of the StmtSequence.
 ///

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=277449&r1=277448&r2=277449&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Tue Aug  2 07:21:09 2016
@@ -16,6 +16,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
+#include "clang/AST/StmtVisitor.h"
 #include "llvm/ADT/StringRef.h"
 
 using namespace clang;
@@ -79,6 +80,168 @@ SourceLocation StmtSequence::getStartLoc
 SourceLocation StmtSequence::getEndLoc() const { return back()->getLocEnd(); }
 
 namespace {
+/// \brief Collects the data of a single Stmt.
+///
+/// This class defines what a code clone is: If it collects for two statements
+/// the same data, then those two statements are considered to be clones of 
each
+/// other.
+class StmtDataCollector : public ConstStmtVisitor {
+
+  ASTContext &Context;
+  std::vector &CollectedData;
+
+public:
+  /// \brief Collects data of the given Stmt.
+  /// \param S The given statement.
+  /// \param Context The ASTContext of S.
+  /// \param D The given data vector to which all collected data is appended.
+  StmtDataCollector(const Stmt *S, ASTContext &Context,
+std::vector &D)
+  : Context(Context), CollectedData(D) {
+Visit(S);
+  }
+
+  // Below are utility methods for appending different data to the vector.
+
+  void addData(CloneDetector::DataPiece Integer) {
+CollectedData.push_back(Integer);
+  }
+
+  // FIXME: The functions below add long strings to the data vector which are
+  // probably not good for performance. Replace the strings with pointer values
+  // or a some other unique integer.
+
+  void addData(llvm::StringRef Str) {
+if (Str.empty())
+  return;
+
+const size_t OldSize = CollectedData.size();
+
+const size_t PieceSize = sizeof(CloneDetector::DataPiece);
+// Calculate how many vector units we need to accomodate all string bytes.
+size_t RoundedUpPieceNumber = (Str.size() + PieceSize - 1) / PieceSize;
+// Allocate space for the string in the data vector.
+CollectedData.resize(CollectedData.size() + RoundedUpPieceNumber);
+
+// Copy the string to the allocated space at the end of the vector.
+std::memcpy(CollectedData.data() + OldSize, Str.data(), Str.size()

Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Daniel Jasper via cfe-commits
djasper added a comment.

So you'd be for #1 of the three choices from my previous comment?


https://reviews.llvm.org/D22505



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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Manuel Klimek via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D22505#503278, @djasper wrote:

> So you'd be for #1 of the three choices from my previous comment?


Yes, because I think ultimately introducing scopes is different from simple 
outdents/indents.


https://reviews.llvm.org/D22505



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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Manuel Klimek via cfe-commits
klimek added a comment.

(full disclosure: I'm also generally opposed to this change, but if there are 
really enough users using this it's probably a lost cause)


https://reviews.llvm.org/D22505



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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I generally agree. Note, however, that the mentioned style guide doesn't 
actually specify this. All it says is "The public, protected, and private 
keywords should be indented inside the class with the function declarations 
indented as well."

So I guess,

  class C {
  int v1;
private:
  int v2;
  };

Would actually also be valid according to the style guide.


https://reviews.llvm.org/D22505



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


[PATCH] D23058: [clang-rename] add support for template instantiations

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: alexfh, klimek.
omtcyfz added a subscriber: cfe-commits.

This patch introduces basic capabilities of renaming templated class and its 
specializations.

https://reviews.llvm.org/D23058

Files:
  clang-rename/USRFinder.cpp
  clang-rename/USRFindingAction.cpp
  test/clang-rename/TemplateClassInstantiationFindByDeclaration.cpp
  test/clang-rename/TemplateClassInstantiationFindByTypeUse.cpp
  test/clang-rename/TemplateClassInstantiationFindByUninstantiatedType.cpp

Index: test/clang-rename/TemplateClassInstantiationFindByUninstantiatedType.cpp
===
--- /dev/null
+++ test/clang-rename/TemplateClassInstantiationFindByUninstantiatedType.cpp
@@ -0,0 +1,39 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=440 -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+template 
+class Foo {   // CHECK: class Bar {
+public:
+  T foo(T arg, T& ref, T* ptr) {
+T value;
+int number = 42;
+value = (T)number;
+value = static_cast(number);
+return value;
+  }
+  static void foo(T value) {}
+  T member;
+};
+
+template 
+void func() {
+  Foo obj; // CHECK: Bar obj;
+  obj.member = T();
+  Foo::foo();  // CHECK: Bar::foo();
+}
+
+int main() {
+  Foo i; // CHECK: Bar i;
+  i.member = 0;
+  Foo::foo(0);   // CHECK: Bar::foo(0);
+
+  Foo b;// CHECK: Bar b;
+  b.member = false;
+  Foo::foo(false);  // CHECK: Bar::foo(false);
+
+  return 0;
+}
+
+// Use grep -FUbo 'Foo'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/TemplateClassInstantiationFindByTypeUse.cpp
===
--- test/clang-rename/TemplateClassInstantiationFindByTypeUse.cpp
+++ test/clang-rename/TemplateClassInstantiationFindByTypeUse.cpp
@@ -1,14 +1,9 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=703 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename -offset=575 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename classes with templates
-// correctly.
-// XFAIL: *
-
 template 
-class Foo {   // CHECK: class Bar;
+class Foo {   // CHECK: class Bar {
 public:
   T foo(T arg, T& ref, T* ptr) {
 T value;
Index: test/clang-rename/TemplateClassInstantiationFindByDeclaration.cpp
===
--- test/clang-rename/TemplateClassInstantiationFindByDeclaration.cpp
+++ test/clang-rename/TemplateClassInstantiationFindByDeclaration.cpp
@@ -1,14 +1,9 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=287 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename -offset=159 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename classes with templates
-// correctly.
-// XFAIL: *
-
 template 
-class Foo {   // CHECK: class Bar;
+class Foo {   // CHECK: class Bar {
 public:
   T foo(T arg, T& ref, T* ptr) {
 T value;
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -53,12 +53,14 @@
 : FoundDecl(FoundDecl), Context(Context), USRs(USRs), USRSet(), Finder() {}
 
   void Find() {
-USRSet.insert(getUSRForDecl(FoundDecl));
 if (const auto *MethodDecl = dyn_cast(FoundDecl)) {
   addUSRsFromOverrideSets(MethodDecl);
-}
-if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
-  addUSRsOfCtorDtors(RecordDecl);
+} else if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
+  handleCXXRecordDecl(RecordDecl);
+} else if (const auto *TemplateDecl = dyn_cast(FoundDecl)) {
+  handleClassTemplateDecl(TemplateDecl);
+} else {
+  USRSet.insert(getUSRForDecl(FoundDecl));
 }
 addMatchers();
 Finder.matchAST(Context);
@@ -87,12 +89,29 @@
 }
   }
 
+  void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
+RecordDecl = RecordDecl->getDefinition();
+if (const auto *ClassTemplateSpecDecl
+= dyn_cast(RecordDecl)) {
+  handleClassTemplateDecl(ClassTemplateSpecDecl->getSpecializedTemplate());
+}
+addUSRsOfCtorDtors(RecordDecl);
+  }
+
+  void handleClassTemplateDecl(const ClassTemplateDecl *TemplateDecl) {
+for (const auto *Specialization : TemplateDecl->specializations()) {
+  addUSRsOfCtorDtors(Specialization);
+}
+addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
+  }
+
   void addUSRsOfCtorDtors(const CXXRecordDecl *RecordDecl) {
 RecordDecl = RecordDecl->getDefinition();
 for (const auto *CtorDecl : RecordDecl->ctors()) {
   USRSet.insert(getUSRForDecl(CtorDecl));
 }
 USRSet.insert(getUSRForDecl(Record

Re: [PATCH] D23054: [clang-cl] Fix 2 pch tests to use x86_64 as target

2016-08-02 Thread Diana Picus via cfe-commits
rovka added a comment.

In https://reviews.llvm.org/D23054#503246, @rengolin wrote:

> All tests should have the target explicit, so I'd advocate for all of them to 
> be changed.


Coming right up...

> Also, we need to make sure --target=x86_64 is enough on Windows. I remember 
> some -target=arm not being enough (arm-eabi was enough, for some reason).


It's enough, I've seen it used in other clang-cl tests.


https://reviews.llvm.org/D23054



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


[clang-tools-extra] r277452 - clang-tools-extra/test/clang-rename/TemplateTypenameFindBy*.cpp: Appease targeting ms mode.

2016-08-02 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Aug  2 08:17:40 2016
New Revision: 277452

URL: http://llvm.org/viewvc/llvm-project?rev=277452&view=rev
Log:
clang-tools-extra/test/clang-rename/TemplateTypenameFindBy*.cpp: Appease 
targeting ms mode.

Modified:

clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp

clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp

Modified: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp?rev=277452&r1=277451&r2=277452&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
 Tue Aug  2 08:17:40 2016
@@ -14,5 +14,5 @@ T member; // CHE
 };
 
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=19 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=19 -new-name=U %t.cpp -i -- 
-fno-delayed-template-parsing
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s

Modified: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp?rev=277452&r1=277451&r2=277452&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp 
Tue Aug  2 08:17:40 2016
@@ -14,5 +14,5 @@ T member; // CHE
 };
 
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=99 -new-name=U %t.cpp -i --
+// RUN: clang-rename -offset=99 -new-name=U %t.cpp -i -- 
-fno-delayed-template-parsing
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s


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


[clang-tools-extra] r277451 - clang-tools-extra/test/clang-rename/TemplateTypenameFindBy*.cpp: Move RUN: lines below not to be affected by tweaks of parameters.

2016-08-02 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Aug  2 08:17:36 2016
New Revision: 277451

URL: http://llvm.org/viewvc/llvm-project?rev=277451&view=rev
Log:
clang-tools-extra/test/clang-rename/TemplateTypenameFindBy*.cpp: Move RUN: 
lines below not to be affected by tweaks of parameters.

Modified:

clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp

clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp

Modified: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp?rev=277451&r1=277450&r2=277451&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
 Tue Aug  2 08:17:36 2016
@@ -1,7 +1,3 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=147 -new-name=U %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
@@ -16,3 +12,7 @@ static void foo(T value) {}   // CHE
 
 T member; // CHECK: U member;
 };
+
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=19 -new-name=U %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s

Modified: 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp?rev=277451&r1=277450&r2=277451&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-rename/TemplateTypenameFindByTypeInside.cpp 
Tue Aug  2 08:17:36 2016
@@ -1,7 +1,3 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=227 -new-name=U %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
 template  // CHECK: template 
 class Foo {
 T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
@@ -16,3 +12,7 @@ static void foo(T value) {}   // CHE
 
 T member; // CHECK: U member;
 };
+
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=99 -new-name=U %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s


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


Re: [PATCH] D23014: [analyzer] Model base to derived casts more precisely.

2016-08-02 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:423
@@ +422,3 @@
+
+if (!val.isZeroConstant()) {
+  val = getStoreManager().evalDynamicCast(val, T, Failed);

I guess if `val` is a //non-zero// constant, it wouldn't make much difference.


https://reviews.llvm.org/D23014



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


Re: [PATCH] D23014: [analyzer] Model base to derived casts more precisely.

2016-08-02 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:423
@@ +422,3 @@
+
+if (!val.isZeroConstant()) {
+  val = getStoreManager().evalDynamicCast(val, T, Failed);

NoQ wrote:
> I guess if `val` is a //non-zero// constant, it wouldn't make much difference.
I might be wrong, but isn't the only valid constant value for a pointer the 
zero constant?


https://reviews.llvm.org/D23014



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


Re: [PATCH] D22853: [clang-rename] add support for template parameter renaming

2016-08-02 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.
chapuni added a comment.

Seems a couple of tests would be incompatible to -fdelayed-template-parsing. 
Appeased in r277452.


Repository:
  rL LLVM

https://reviews.llvm.org/D22853



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


Re: [PATCH] D23054: [clang-cl] Fix PCH tests to use x86_64 as target

2016-08-02 Thread Diana Picus via cfe-commits
rovka retitled this revision from "[clang-cl] Fix 2 pch tests to use x86_64 as 
target" to "[clang-cl] Fix PCH tests to use x86_64 as target".
rovka updated this revision to Diff 66467.
rovka added a comment.

Added cl-pch-errorhandling.cpp


https://reviews.llvm.org/D23054

Files:
  test/Driver/cl-pch-errorhandling.cpp
  test/Driver/cl-pch-search.cpp
  test/Driver/cl-pch-showincludes.cpp

Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,39 +8,39 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
 // CHECK-YC: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YC: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
 // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
 // CHECK-YU: Note: including file: {{[^ ]*header3.h}}
 
 // When not using pch at all, all the /FI files are printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /FIheader2.h /c /Fo%t -- 
%s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/FIheader2.h /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-FI %s
 // CHECK-FI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-FI: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-FI: Note: including file: {{[^ ]*header3.h}}
 
 // Also check that /FI arguments before the /Yc / /Yu flags are printed right.
 
 // /FI flags before the /Yc arg should be printed, /FI flags after it 
shouldn't.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YCFI %s
 // CHECK-YCFI: Note: including file: {{[^ ]*header0.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YCFI: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header4.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header3.h}}
 
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YUFI %s
 // CHECK-YUFI-NOT: Note: including file: {{.*pch}}
 // CHECK-YUFI-NOT: Note: including file: {{.*header0.h}}
Index: test/Driver/cl-pch-search.cpp
===
--- test/Driver/cl-pch-search.cpp
+++ test/Driver/cl-pch-search.cpp
@@ -3,4 +3,4 @@
 
 // REQUIRES: x86-registered-target
 // Check that pchfile.h next to to pchfile.cc is found correctly.
-// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- 
%S/Inputs/pchfile.cpp 
+// RUN: %clang_cl -Werror --target=x86_64 /Ycpchfile.h /FIpchfile.h /c 
/Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp
Index: test/Driver/cl-pch-errorhandling.cpp
===
--- test/Driver/cl-pch-errorhandling.cpp
+++ test/Driver/cl-pch-errorhandling.cpp
@@ -6,7 +6,7 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: not %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h 
/Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
+// RUN: not %clang_cl -Werror --target=x86_64 /Yc%S/Inputs/pchfile.h 
/FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1


Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,39 +8,39 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) an

[libcxx] r277456 - Fixing 'Aquire' typo and libcxx build.

2016-08-02 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Aug  2 08:43:48 2016
New Revision: 277456

URL: http://llvm.org/viewvc/llvm-project?rev=277456&view=rev
Log:
Fixing 'Aquire' typo and libcxx build.

Modified:
libcxx/trunk/src/include/atomic_support.h
libcxx/trunk/src/memory.cpp

Modified: libcxx/trunk/src/include/atomic_support.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/atomic_support.h?rev=277456&r1=277455&r2=277456&view=diff
==
--- libcxx/trunk/src/include/atomic_support.h (original)
+++ libcxx/trunk/src/include/atomic_support.h Tue Aug  2 08:43:48 2016
@@ -45,7 +45,7 @@ namespace {
 enum __libcpp_atomic_order {
 _AO_Relaxed = __ATOMIC_RELAXED,
 _AO_Consume = __ATOMIC_CONSUME,
-_AO_Aquire  = __ATOMIC_ACQUIRE,
+_AO_Acquire = __ATOMIC_ACQUIRE,
 _AO_Release = __ATOMIC_RELEASE,
 _AO_Acq_Rel = __ATOMIC_ACQ_REL,
 _AO_Seq = __ATOMIC_SEQ_CST

Modified: libcxx/trunk/src/memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=277456&r1=277455&r2=277456&view=diff
==
--- libcxx/trunk/src/memory.cpp (original)
+++ libcxx/trunk/src/memory.cpp Tue Aug  2 08:43:48 2016
@@ -117,7 +117,7 @@ __shared_weak_count::__release_weak() _N
 // threads, and have them all get copied at once.  The argument
 // also doesn't apply for __release_shared, because an outstanding
 // weak_ptr::lock() could read / modify the shared count.
-if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Aquire) == 0)
+if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Acquire) == 0)
 {
 // no need to do this store, because we are about
 // to destroy everything.


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


Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-08-02 Thread Tavian Barnes via cfe-commits
tavianator added a comment.

Anything else I need to do for this patch?


https://reviews.llvm.org/D21803



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


r277457 - [clang-cl] Fix PCH tests to use x86_64 as target

2016-08-02 Thread Diana Picus via cfe-commits
Author: rovka
Date: Tue Aug  2 08:53:00 2016
New Revision: 277457

URL: http://llvm.org/viewvc/llvm-project?rev=277457&view=rev
Log:
[clang-cl] Fix PCH tests to use x86_64 as target

These tests require x86-registered-target, but they don't force the target as
x86 on the command line, which means they will be run and they might fail when
building the x86 backend on another platform (such as AArch64).

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

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

Modified:
cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
cfe/trunk/test/Driver/cl-pch-search.cpp
cfe/trunk/test/Driver/cl-pch-showincludes.cpp

Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=277457&r1=277456&r2=277457&view=diff
==
--- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Tue Aug  2 08:53:00 2016
@@ -6,7 +6,7 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: not %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h 
/Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
+// RUN: not %clang_cl -Werror --target=x86_64 /Yc%S/Inputs/pchfile.h 
/FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1

Modified: cfe/trunk/test/Driver/cl-pch-search.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-search.cpp?rev=277457&r1=277456&r2=277457&view=diff
==
--- cfe/trunk/test/Driver/cl-pch-search.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-search.cpp Tue Aug  2 08:53:00 2016
@@ -3,4 +3,4 @@
 
 // REQUIRES: x86-registered-target
 // Check that pchfile.h next to to pchfile.cc is found correctly.
-// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- 
%S/Inputs/pchfile.cpp 
+// RUN: %clang_cl -Werror --target=x86_64 /Ycpchfile.h /FIpchfile.h /c 
/Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp

Modified: cfe/trunk/test/Driver/cl-pch-showincludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-showincludes.cpp?rev=277457&r1=277456&r2=277457&view=diff
==
--- cfe/trunk/test/Driver/cl-pch-showincludes.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-showincludes.cpp Tue Aug  2 08:53:00 2016
@@ -8,14 +8,14 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
 // CHECK-YC: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YC: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
@@ -23,7 +23,7 @@
 // CHECK-YU: Note: including file: {{[^ ]*header3.h}}
 
 // When not using pch at all, all the /FI files are printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /FIheader2.h /c /Fo%t -- 
%s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/FIheader2.h /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-FI %s
 // CHECK-FI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-FI: Note: including file:  {{[^ ]*header1.h}}
@@ -32,7 +32,7 @@
 // Also check that /FI arguments before the /Yc / /Yu flags are printed right.
 
 // /FI flags before the /Yc arg should be printed, /FI flags after it 
shouldn't.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YCFI %s
 // CHECK-YCFI: Note: including file: {{[^ ]*header0.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header2.h}}
@@ -40,7 +40,7 @@
 // CHECK-YCFI: Note: including file: {{[^ ]*header4.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header3.h

Re: [PATCH] D23054: [clang-cl] Fix PCH tests to use x86_64 as target

2016-08-02 Thread Diana Picus via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277457: [clang-cl] Fix PCH tests to use x86_64 as target 
(authored by rovka).

Changed prior to commit:
  https://reviews.llvm.org/D23054?vs=66467&id=66468#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23054

Files:
  cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
  cfe/trunk/test/Driver/cl-pch-search.cpp
  cfe/trunk/test/Driver/cl-pch-showincludes.cpp

Index: cfe/trunk/test/Driver/cl-pch-search.cpp
===
--- cfe/trunk/test/Driver/cl-pch-search.cpp
+++ cfe/trunk/test/Driver/cl-pch-search.cpp
@@ -3,4 +3,4 @@
 
 // REQUIRES: x86-registered-target
 // Check that pchfile.h next to to pchfile.cc is found correctly.
-// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- 
%S/Inputs/pchfile.cpp 
+// RUN: %clang_cl -Werror --target=x86_64 /Ycpchfile.h /FIpchfile.h /c 
/Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp
Index: cfe/trunk/test/Driver/cl-pch-showincludes.cpp
===
--- cfe/trunk/test/Driver/cl-pch-showincludes.cpp
+++ cfe/trunk/test/Driver/cl-pch-showincludes.cpp
@@ -8,39 +8,39 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
 // CHECK-YC: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YC: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h 
/Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
 // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
 // CHECK-YU: Note: including file: {{[^ ]*header3.h}}
 
 // When not using pch at all, all the /FI files are printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /FIheader2.h /c /Fo%t -- 
%s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/FIheader2.h /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-FI %s
 // CHECK-FI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-FI: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-FI: Note: including file: {{[^ ]*header3.h}}
 
 // Also check that /FI arguments before the /Yc / /Yu flags are printed right.
 
 // /FI flags before the /Yc arg should be printed, /FI flags after it 
shouldn't.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Ycheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YCFI %s
 // CHECK-YCFI: Note: including file: {{[^ ]*header0.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header2.h}}
 // CHECK-YCFI: Note: including file:  {{[^ ]*header1.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header4.h}}
 // CHECK-YCFI: Note: including file: {{[^ ]*header3.h}}
 
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader0.h 
/FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: %clang_cl -Werror --target=x86_64 /showIncludes /I%S/Inputs 
/Yuheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
 // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YUFI %s
 // CHECK-YUFI-NOT: Note: including file: {{.*pch}}
 // CHECK-YUFI-NOT: Note: including file: {{.*header0.h}}
Index: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
===
--- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
+++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
@@ -6,7 +6,7 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: not %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h 
/Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
+// RUN: not %clang_cl -Werror --target=x86_64 /Yc%S/Inputs/pchfile.h 
/FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1


Index: cfe/trunk/test/Driver/cl-pch-search.cpp
===
--- cfe/trunk/test/Driver/cl-pch-search.cp

Re: [PATCH] D23014: [analyzer] Model base to derived casts more precisely.

2016-08-02 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:423
@@ +422,3 @@
+
+if (!val.isZeroConstant()) {
+  val = getStoreManager().evalDynamicCast(val, T, Failed);

xazax.hun wrote:
> NoQ wrote:
> > I guess if `val` is a //non-zero// constant, it wouldn't make much 
> > difference.
> I might be wrong, but isn't the only valid constant value for a pointer the 
> zero constant?
Even if forbidden by the Standard in well-formed programs, we'd have to expect 
it here - after all, it's great if we analyze a program that has a bug :)

We also have this `FixedAddressChecker` thing, so even in our simplified model, 
there actually do exist non-zero constant pointers. That said, there's some bug 
i stepped into in explain-svals.cpp, which produces more zero constant pointers 
that one would expect, didn't have time to investigate yet...


https://reviews.llvm.org/D23014



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


[PATCH] D23060: [analyzer] Show enabled checker list

2016-08-02 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, NoQ.
xazax.hun added a subscriber: cfe-commits.

This patch adds a command line option to list the checkers that were enabled by 
analyzer-checker and not disabled by -analyzer-disable-checker.

It can be very useful to debug long command lines when it is not immediately 
apparent which checkers are turned on and which checkers are turned off.

Clang tidy already has a similar feature. 

https://reviews.llvm.org/D23060

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/CheckerRegistry.h
  include/clang/StaticAnalyzer/Frontend/FrontendActions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Core/CheckerRegistry.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
  test/Analysis/analyzer-enabled-checkers.c

Index: test/Analysis/analyzer-enabled-checkers.c
===
--- /dev/null
+++ test/Analysis/analyzer-enabled-checkers.c
@@ -0,0 +1,29 @@
+// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=core -Xclang -analyzer-checker-list-enabled > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+void bar() {}
+void foo() {
+  // Call bar 33 times so max-times-inline-large is met and
+  // min-blocks-for-inline-large is checked
+  for (int i = 0; i < 34; ++i) {
+bar();
+  }
+}
+
+// CHECK: OVERVIEW: Clang Static Analyzer Enabled Checkers List
+// CHECK: core.CallAndMessage
+// CHECK: core.DivideZero
+// CHECK: core.DynamicTypePropagation
+// CHECK: core.NonNullParamChecker
+// CHECK: core.NullDereference
+// CHECK: core.StackAddressEscape
+// CHECK: core.UndefinedBinaryOperatorResult
+// CHECK: core.VLASize
+// CHECK: core.builtin.BuiltinFunctions
+// CHECK: core.builtin.NoReturnFunctions
+// CHECK: core.uninitialized.ArraySubscript
+// CHECK: core.uninitialized.Assign
+// CHECK: core.uninitialized.Branch
+// CHECK: core.uninitialized.CapturedBlockVariable
+// CHECK: core.uninitialized.UndefReturn
+
Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -101,18 +101,24 @@
   << pluginAPIVersion;
 }
 
+static SmallVector
+getCheckerOptList(const AnalyzerOptions &opts) {
+  SmallVector checkerOpts;
+  for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) {
+const std::pair &opt = opts.CheckersControlList[i];
+checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second));
+  }
+  return checkerOpts;
+}
+
 std::unique_ptr
 ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts,
ArrayRef plugins,
DiagnosticsEngine &diags) {
   std::unique_ptr checkerMgr(
   new CheckerManager(langOpts, &opts));
 
-  SmallVector checkerOpts;
-  for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) {
-const std::pair &opt = opts.CheckersControlList[i];
-checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second));
-  }
+  SmallVector checkerOpts = getCheckerOptList(opts);
 
   ClangCheckerRegistry allCheckers(plugins, &diags);
   allCheckers.initializeManager(*checkerMgr, checkerOpts);
@@ -137,3 +143,12 @@
 
   ClangCheckerRegistry(plugins).printHelp(out);
 }
+
+void ento::printEnabledCheckerList(raw_ostream &out,
+   ArrayRef plugins,
+   const AnalyzerOptions &opts) {
+  out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n";
+
+  SmallVector checkerOpts = getCheckerOptList(opts);
+  ClangCheckerRegistry(plugins).printList(out, checkerOpts);
+}
Index: lib/StaticAnalyzer/Core/CheckerRegistry.cpp
===
--- lib/StaticAnalyzer/Core/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Core/CheckerRegistry.cpp
@@ -175,3 +175,22 @@
 out << '\n';
   }
 }
+
+void CheckerRegistry::printList(
+raw_ostream &out, SmallVectorImpl &opts) const {
+  std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
+
+  // Collect checkers enabled by the options.
+  CheckerInfoSet enabledCheckers;
+  for (SmallVectorImpl::iterator i = opts.begin(),
+   e = opts.end();
+   i != e; ++i) {
+collectCheckers(Checkers, Packages, *i, enabledCheckers);
+  }
+
+  for (CheckerInfoSet::const_iterator i = enabledCheckers.begin(),
+  e = enabledCheckers.end();
+   i != e; ++i) {
+out << (*i)->FullName << '\n';
+  }
+}
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerI

RE: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel attributes

2016-08-02 Thread Liu, Yaxun (Sam) via cfe-commits
The LLVM IR generated by Clang trunk for spir target is not conformant to SPIR 
spec 1.2 or 2.0 even without my change. For example, it differs from SPIR spec 
about LLVM version, image type name, sampler type representation, blocks 
representation, etc. It is the result of evolution of the original SPIR for a 
better solution of many issues of SPIR.

If we look back at the RFC about the new kernel argument metadata, there was 
agreement that the original kernel argument metadata is difficult to work with, 
therefore the proposal to use function metadata was accepted to alleviate this 
issue. The new function metadata was more concise and easier to work with.

For SPIR consumer, the new format conveys equivalent information as the old 
format. There is no reason they cannot consume this new format.

If users want to generate SPIR conformant LLVM IR, they should use khronos SPIR 
producer instead of clang trunk.

Sam

-Original Message-
From: Pan Xiuli [mailto:xiuli...@outlook.com] 
Sent: Monday, August 1, 2016 10:40 PM
To: 'Anastasia Stulova' ; 
reviews+d20979+public+e2872c9c869f1...@reviews.llvm.org; 
alexey.ba...@intel.com; Liu, Yaxun (Sam) 
Cc: Stellard, Thomas ; cfe-commits@lists.llvm.org; 'nd' 

Subject: RE: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel 
attributes

Hi,

What I mean is the spec of spir 1.2/2.0 has very clear example about how the 
metadata should organized. But now with this patch, the result of spir is 
changed and not like it before. So what I want to know is why we change the old 
spir example style code, but not add something alongside.
Now we have metadata after each function but spir shows a opencl.kernels 
metadata is need for all modules:
"Each SPIR module has a opencl.kernels named metadata node containing a list of 
metadata objects."

I think this patch maybe useful for some other target, but we should not break 
the old spir as now we have not had a substitute one.

Thanks
Xiuli

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com] 
Sent: Tuesday, August 2, 2016 2:14 AM
To: Pan Xiuli ; 
reviews+d20979+public+e2872c9c869f1...@reviews.llvm.org; 
alexey.ba...@intel.com; Liu, Yaxun (Sam) (yaxun@amd.com) 
Cc: thomas.stell...@amd.com; cfe-commits@lists.llvm.org; nd 
Subject: RE: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel 
attributes

Hi Xiuli,

Could you please elaborate what do you think it broken exactly?

Because we haven't actually removed opencl.kernels metadata but just changed 
the format of it. 

Basically, we are using function metadata instead of generic metadata as it was 
before.

Thanks,
Anastasia

-Original Message-
From: Pan Xiuli [mailto:xiuli...@outlook.com] 
Sent: 01 August 2016 05:54
To: reviews+d20979+public+e2872c9c869f1...@reviews.llvm.org; Anastasia Stulova; 
alexey.ba...@intel.com
Cc: thomas.stell...@amd.com; cfe-commits@lists.llvm.org
Subject: RE: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel 
attributes

Hi Sam,

I am now using llvm39 to enable our opencl driver, but I found this patch broke 
the spir target as well.
The opencl.kernels metadata is required by spir spec. I think we should keep 
the old code for spir target.

Thanks
Xiuli

-Original Message-
From: Yaxun Liu [mailto:yaxun@amd.com] 
Sent: Wednesday, June 22, 2016 11:04 PM
To: yaxun@amd.com; xiuli...@outlook.com; anastasia.stul...@arm.com; 
alexey.ba...@intel.com
Cc: thomas.stell...@amd.com; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D20979: [OpenCL] Use function metadata to represent kernel 
attributes

This revision was automatically updated to reflect the committed changes.
Closed by commit rL273425: [OpenCL] Use function metadata to represent kernel 
attributes (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D20979?vs=60545&id=61555#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20979

Files:
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
  cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
  cfe/trunk/test/CodeGenOpenCL/kernel-metadata.cl

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


Re: r277449 - [analyzer] Respect statement-specific data in CloneDetection.

2016-08-02 Thread Renato Golin via cfe-commits
On 2 August 2016 at 13:21, Artem Dergachev via cfe-commits
 wrote:
> Author: dergachev
> Date: Tue Aug  2 07:21:09 2016
> New Revision: 277449
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277449&view=rev
> Log:
> [analyzer] Respect statement-specific data in CloneDetection.

Hi Artem,

Just to make sure you're aware of:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/10182

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


Re: r277449 - [analyzer] Respect statement-specific data in CloneDetection.

2016-08-02 Thread Artem Dergachev via cfe-commits

Wow, i haven't noticed it's mine!

Will have a look, sorry.


On 8/2/16 5:51 PM, Renato Golin via cfe-commits wrote:

On 2 August 2016 at 13:21, Artem Dergachev via cfe-commits
 wrote:

Author: dergachev
Date: Tue Aug  2 07:21:09 2016
New Revision: 277449

URL: http://llvm.org/viewvc/llvm-project?rev=277449&view=rev
Log:
[analyzer] Respect statement-specific data in CloneDetection.

Hi Artem,

Just to make sure you're aware of:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/10182

cheers,
--renato
___
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


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-02 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Yes, I did that -- but I got no conflicts there. ;-)


Repository:
  rL LLVM

https://reviews.llvm.org/D21814



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


[clang-tools-extra] r277469 - [clang-rename] fix Emacs script build failure

2016-08-02 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Tue Aug  2 10:10:17 2016
New Revision: 277469

URL: http://llvm.org/viewvc/llvm-project?rev=277469&view=rev
Log:
[clang-rename] fix Emacs script build failure

Clang-rename Emacs integration script sometimes doesn't work correctly.


Modified:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.el

Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.el?rev=277469&r1=277468&r2=277469&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el Tue Aug  2 
10:10:17 2016
@@ -34,8 +34,9 @@
   ;; Run clang-rename via bash.
   (shell-command rename-command)
   ;; Reload buffer.
-  (interactive)
-  (revert-buffer t t)
+  (lambda ()
+(interactive)
+(revert-buffer t t))
 )
   )
 )


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


r277473 - [analyzer] Hotfix for buildbot failure due to unspecified triple in r277449

2016-08-02 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug  2 10:16:06 2016
New Revision: 277473

URL: http://llvm.org/viewvc/llvm-project?rev=277473&view=rev
Log:
[analyzer] Hotfix for buildbot failure due to unspecified triple in r277449

If a target triple is not specified, the default host triple is used,
which is not good for compiling inline assembler code.

Patch by Raphael Isemann!

Modified:
cfe/trunk/test/Analysis/copypaste/asm.cpp

Modified: cfe/trunk/test/Analysis/copypaste/asm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/copypaste/asm.cpp?rev=277473&r1=277472&r2=277473&view=diff
==
--- cfe/trunk/test/Analysis/copypaste/asm.cpp (original)
+++ cfe/trunk/test/Analysis/copypaste/asm.cpp Tue Aug  2 10:16:06 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -std=c++11 
-analyzer-checker=alpha.clone.CloneChecker -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze 
-analyzer-checker=alpha.clone.CloneChecker -verify %s
 
 // expected-no-diagnostics
 


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


Re: [PATCH] D23014: [analyzer] Model base to derived casts more precisely.

2016-08-02 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Other than a naming/documentation suggestion, looks good to me. Thanks Gábor!



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:424
@@ +423,3 @@
+if (!val.isZeroConstant()) {
+  val = getStoreManager().evalDynamicCast(val, T, Failed);
+}

It seems a bit weird to call a method named "evalDynamicCast" when handling a 
static cast. What do you think about renaming evalDynamicCast() to to 
attemptDowncast() and updating its documentation to reflect its now-dual use?


https://reviews.llvm.org/D23014



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


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-08-02 Thread Cameron via cfe-commits
cameron314 added a comment.

Anyone have time to check this out this week?
It's a one-line fix, includes a test, and is for a fairly important bug :-)


https://reviews.llvm.org/D20338



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


Re: [PATCH] D22698: [libcxx] Missing member types 'traits_type' and 'string_type' in class basic_regex

2016-08-02 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D22698



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


[libclc] r277481 - Creating release_38 off revision 260304

2016-08-02 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue Aug  2 11:29:52 2016
New Revision: 277481

URL: http://llvm.org/viewvc/llvm-project?rev=277481&view=rev
Log:
Creating release_38 off revision 260304

Added:
libclc/branches/release_38/
  - copied from r260304, libclc/trunk/

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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Loki Astari via cfe-commits
LokiAstari added a comment.

I don't have a problem changing it so the default behaviour is:

  class C {
  int v1;
private:
  int v2;
  };

But I would like to retain the functionality that if there is no explicit 
public/private/protected that it follows the original.
But if there is huge objection to that I am not going to fight over this one (I 
can live with the indention above).

Loki.


https://reviews.llvm.org/D22505



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


Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-08-02 Thread Bittner Barni via cfe-commits
bittnerbarni updated this revision to Diff 66492.

https://reviews.llvm.org/D20196

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientStringConcatenationCheck.cpp
  clang-tidy/performance/InefficientStringConcatenationCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
  test/clang-tidy/performance-inefficient-string-concatenation.cpp

Index: test/clang-tidy/performance-inefficient-string-concatenation.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-string-concatenation.cpp
@@ -0,0 +1,44 @@
+// RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t
+
+namespace std {
+template 
+class basic_string {
+public:
+  basic_string() {}
+  ~basic_string() {}
+  basic_string *operator+=(const basic_string &) {}
+  friend basic_string operator+(const basic_string &, const basic_string &) {}
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f(std::string) {}
+std::string g(std::string) {}
+
+int main() {
+  std::string mystr1, mystr2;
+  std::wstring mywstr1, mywstr2;
+
+  for (int i = 0; i < 10; ++i) {
+f(mystr1 + mystr2 + mystr1);
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead
+mystr1 = mystr1 + mystr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+mystr1 = mystr2 + mystr2 + mystr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: string concatenation
+mystr1 = mystr2 + mystr1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+mywstr1 = mywstr2 + mywstr1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+mywstr1 = mywstr2 + mywstr2 + mywstr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: string concatenation
+
+mywstr1 = mywstr2 + mywstr2;
+mystr1 = mystr2 + mystr2;
+mystr1 += mystr2;
+f(mystr2 + mystr1);
+mystr1 = g(mystr1);
+  }
+  return 0;
+}
Index: docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
@@ -0,0 +1,49 @@
+.. title:: clang-tidy - performance-inefficient-string-concatenation
+
+performance-inefficient-string-concatenation
+
+
+This check warns about the performance overhead arising from concatenating strings using the ``operator+``, for instance:
+
+.. code:: c++
+
+std::string a("Foo"), b("Bar");
+a = a + b;
+
+Instead of this structure you should use ``operator+=`` or ``std::string``'s (``std::basic_string``) class member function ``append()``. For instance:
+   
+.. code:: c++
+
+   std::string a("Foo"), b("Baz");
+   for (int i = 0; i < 2; ++i) {
+   a = a + "Bar" + b;
+   }
+
+Could be rewritten in a greatly more efficient way like:
+
+.. code:: c++
+
+   std::string a("Foo"), b("Baz");
+   for (int i = 0; i < 2; ++i) {
+   a.append("Bar").append(b);
+   } 
+
+And this can be rewritten too:
+
+.. code:: c++
+
+   void f(const std::string&) {}
+   std::string a("Foo"), b("Baz");
+   void g() {
+   f(a + "Bar" + b);
+   }
+
+In a slightly more efficient way like:
+
+.. code:: c++
+
+   void f(const std::string&) {}
+   std::string a("Foo"), b("Baz");
+   void g() {
+   f(std::string(a).append("Bar").append(b));
+   }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -102,6 +102,7 @@
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
+   performance-inefficient-string-concatenation
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
readability-avoid-const-params-in-decls
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -184,6 +184,12 @@
   Warns about range-based loop with a loop variable of const ref type where the
   type of the variable does not match the one returned by the iterator.
 
+- New `performance-inefficient-string-concatenation
+  `_ check
+
+  This check is to warn about the performance overhead arising from concatenating 
+  strings, using the ``operator+``, instead of ``operator+=``.
+  
 - New `performance-unnecessary-value-param
   `_ check
 
Index: clang-tidy/performance/Performa

Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-08-02 Thread Bittner Barni via cfe-commits
bittnerbarni marked 14 inline comments as done.
bittnerbarni added a comment.

https://reviews.llvm.org/D20196



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


Re: [PATCH] D23045: [Include-fixer] Install executables and support scripts

2016-08-02 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: include-fixer/find-all-symbols/tool/CMakeLists.txt:22
@@ +21,2 @@
+  DESTINATION share/clang
+  COMPONENT find-all-symbols)

hokein wrote:
> I think we can put it in `clang-include-fixer` as find-all-symbols is a 
> sub-tool of include-fixer.
In other make files executable name and COMPONENT for scripts are same. Should 
I add COMPONENT to find-all-symbols executable too?


Repository:
  rL LLVM

https://reviews.llvm.org/D23045



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


Re: [PATCH] D22419: [CFG] Fix crash in thread sanitizer.

2016-08-02 Thread Nandor Licker via cfe-commits
nandor added a comment.

ping


https://reviews.llvm.org/D22419



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


Re: [PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

2016-08-02 Thread Erik Pilkington via cfe-commits
erik.pilkington updated this revision to Diff 66501.
erik.pilkington added a comment.

This new patch removes the warning `diag::warn_available_using_star_case`, as 
per Devin's suggestion.


https://reviews.llvm.org/D23003

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Stmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/ScopeInfo.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  test/Parser/objc-available.m
  test/Sema/attr-availability.c
  test/SemaObjC/attr-availability.m
  test/SemaObjC/property-deprecated-warning.m
  test/SemaObjC/unguarded-availability.m

Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.9 -Wunguarded-availability -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -DOBJCPP -triple x86_64-apple-macosx-10.9 -Wunguarded-availability -fsyntax-only -verify %s
+
+#define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
+#define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
+
+int func_10_11() AVAILABLE_10_11; // expected-note 3 {{'func_10_11' has been explicitly marked partial here}}
+
+int func_10_12() AVAILABLE_10_12; // expected-note 2 {{'func_10_12' has been explicitly marked partial here}}
+
+void use_func() {
+  func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
+
+  if (@available(macos 10.11, *))
+func_10_11();
+  else
+func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
+}
+
+void defn_10_11() AVAILABLE_10_11;
+
+void defn_10_11() {
+  func_10_11();
+}
+
+void nested_ifs() {
+  if (@available(macos 10.12, *)) {
+if (@available(macos 10.10, *)) {
+  func_10_12();
+} else {
+  func_10_12();
+}
+  } else {
+func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{enclose 'func_10_12' in an @available check to silence this warning}}
+  }
+}
+
+void star_case() {
+  if (@available(ios 9, *))
+func_10_11();
+  else
+func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
+}
+
+typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been explicitly marked partial here}}
+typedef int int_10_12 AVAILABLE_10_12; // expected-note {{'int_10_12' has been explicitly marked partial here}}
+
+void use_typedef() {
+  int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}}
+}
+
+__attribute__((objc_root_class))
+AVAILABLE_10_11 @interface Class_10_11 {
+  int_10_11 foo;
+  int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
+}
+- (void)method1;
+- (void)method2;
+@end
+
+@implementation Class_10_11
+- (void) method1 {
+  func_10_11();
+  func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{enclose 'func_10_12' in an @available check to silence this warning}}
+}
+
+- (void)method2 AVAILABLE_10_12 {
+  func_10_12();
+}
+
+@end
+
+int protected_scope() {
+  if (@available(macos 10.20, *)) { // expected-note 2 {{jump enters controlled statement of if available}}
+  label1:
+return 0;
+  } else {
+  label2:
+goto label1; // expected-error{{cannot jump from this goto statement to its label}}
+  }
+
+  goto label2; // expected-error{{cannot jump from this goto statement to its label}}
+}
+
+#ifdef OBJCPP
+
+int f(char) __attribute__((availability(macos, introduced=10.12))); // expected-note {{'f' has been explicitly marked partial here}}
+int f(int);
+
+template  int use_f() {
+  return f(T()); // expected-warning{{'f' is only available on macOS 10.12 or newer}} expected-note{{enclose}}
+}
+
+int a = use_f();
+int b = use_f(); // expected-note{{in instantiation}}
+
+#endif
Index: test/SemaObjC/property-deprecated-warning.m
===
--- test/SemaObjC/property-deprecated-warning.m
+++ test/SemaObjC/property-deprecated-warning.m
@@ -9,7 +9,7 @@
 @property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'ptarget' is declared deprecated here}} expected-note {{'ptarget' has been explicitly marked de

r277487 - [Order Files] Remove dtrace predicate

2016-08-02 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Aug  2 12:50:53 2016
New Revision: 277487

URL: http://llvm.org/viewvc/llvm-project?rev=277487&view=rev
Log:
[Order Files] Remove dtrace predicate

Having the dtrace predicate setup to only show probes in clang filters out 
static initializers executed by dyld, which we do want included in the order 
files.

Modified:
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=277487&r1=277486&r2=277487&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Aug  2 12:50:53 2016
@@ -75,13 +75,12 @@ def dtrace(args):
   target = "oneshot$target:::entry"
   else:
   target = "pid$target:::entry"
-  predicate = '%s/probemod=="%s"/' % (target, os.path.basename(cmd[0]))
   log_timestamp = 'printf("dtrace-TS: %d\\n", timestamp)'
   if opts.use_ustack:
   action = 'ustack(1);'
   else:
   action = 'printf("dtrace-Symbol: %s\\n", probefunc);'
-  dtrace_script = "%s { %s; %s }" % (predicate, log_timestamp, action)
+  dtrace_script = "%s { %s; %s }" % (target, log_timestamp, action)
 
   dtrace_args = []
   if not os.geteuid() == 0:


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


r277488 - Updated documentation

2016-08-02 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Aug  2 12:51:48 2016
New Revision: 277488

URL: http://llvm.org/viewvc/llvm-project?rev=277488&view=rev
Log:
Updated documentation

Reviewers: kcc, eugenis

Subscribers: llvm-commits

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

Modified:
cfe/trunk/docs/AddressSanitizer.rst

Modified: cfe/trunk/docs/AddressSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AddressSanitizer.rst?rev=277488&r1=277487&r2=277488&view=diff
==
--- cfe/trunk/docs/AddressSanitizer.rst (original)
+++ cfe/trunk/docs/AddressSanitizer.rst Tue Aug  2 12:51:48 2016
@@ -14,7 +14,8 @@ following types of bugs:
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (to some extent)
+* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
 * Double-free, invalid free
 * Memory leaks (experimental)
 


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


Re: [PATCH] D23042: [CUDA] Do not allow using NVPTX target for host compilation.

2016-08-02 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 66505.
tra added a comment.
Herald added a subscriber: klimek.

Abort pipeline constructions early if we detect that NVPTX is used for host 
compilation.
Restore assertions for presence of -march flag.


https://reviews.llvm.org/D23042

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/Driver.cpp
  test/Driver/cuda-bad-arch.cu
  test/Preprocessor/cuda-types.cu
  unittests/ASTMatchers/ASTMatchersTest.h

Index: unittests/ASTMatchers/ASTMatchersTest.h
===
--- unittests/ASTMatchers/ASTMatchersTest.h
+++ unittests/ASTMatchers/ASTMatchersTest.h
@@ -189,7 +189,7 @@
   // avoid constructing a full system triple.
   std::vector Args = {
   "-xcuda",  "-fno-ms-extensions",  "--cuda-host-only", "-nocudainc",
-  "-target", "nvptx64-unknown-unknown", CompileArg};
+  "-target", "x86_64-unknown-unknown", CompileArg};
   if (!runToolOnCodeWithArgs(Factory->create(),
  CudaHeader + Code, Args)) {
 return testing::AssertionFailure() << "Parsing error in \"" << Code << 
"\"";
Index: test/Preprocessor/cuda-types.cu
===
--- test/Preprocessor/cuda-types.cu
+++ test/Preprocessor/cuda-types.cu
@@ -19,9 +19,3 @@
 // RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/powerpc64-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-host-defines-filtered
 // RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/powerpc64-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-device-defines-filtered
 // RUN: diff %T/powerpc64-host-defines-filtered 
%T/powerpc64-device-defines-filtered
-
-// RUN: %clang --cuda-host-only -nocudainc -target nvptx-nvidia-cuda -x cuda 
-E -dM -o - /dev/null > %T/nvptx-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -target nvptx-nvidia-cuda -x cuda 
-E -dM -o - /dev/null > %T/nvptx-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/nvptx-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/nvptx-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/nvptx-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/nvptx-device-defines-filtered
-// RUN: diff %T/nvptx-host-defines-filtered %T/nvptx-device-defines-filtered
Index: test/Driver/cuda-bad-arch.cu
===
--- test/Driver/cuda-bad-arch.cu
+++ test/Driver/cuda-bad-arch.cu
@@ -19,4 +19,9 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 
+// We don't allow using NVPTX for host compilation.
+// RUN: %clang -### --cuda-host-only -target nvptx-nvidia-cuda -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix HOST_NVPTX %s
+
 // OK-NOT: error: Unsupported CUDA gpu architecture
+// HOST_NVPTX: error: unsupported use of NVPTX for host compilation.
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1407,11 +1407,16 @@
   bool CompileDeviceOnly =
   PartialCompilationArg &&
   
PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only);
+  const ToolChain *HostTC = C.getSingleOffloadToolChain();
+  assert(HostTC && "No toolchain for host compilation.");
+  if (HostTC->getTriple().isNVPTX()) {
+C.getDriver().Diag(diag::err_drv_cuda_nvptx_host);
+return nullptr;
+  }
 
   if (CompileHostOnly) {
-OffloadAction::HostDependence HDep(
-*HostAction, *C.getSingleOffloadToolChain(),
-/*BoundArch=*/nullptr, Action::OFK_Cuda);
+OffloadAction::HostDependence HDep(*HostAction, *HostTC,
+   /*BoundArch=*/nullptr, 
Action::OFK_Cuda);
 return C.MakeAction(HDep);
   }
 
@@ -1507,9 +1512,8 @@
 
   // Return a new host action that incorporates original host action and all
   // device actions.
-  OffloadAction::HostDependence HDep(
-  *HostAction, *C.getSingleOffloadToolChain(),
-  /*BoundArch=*/nullptr, Action::OFK_Cuda);
+  OffloadAction::HostDependence HDep(*HostAction, *HostTC,
+ /*BoundArch=*/nullptr, Action::OFK_Cuda);
   OffloadAction::DeviceDependences DDep;
   DDep.add(*FatbinAction, *CudaTC, /*BoundArch=*/nullptr, Action::OFK_Cuda);
   return C.MakeAction(HDep, DDep);
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -30,6 +30,7 @@
   "GPU arch %1 requires CUDA version at least %3, but installation at %0 is 
%2. "
   "Use --cuda-path to specify a different CUDA install, or pass "
   "--no-cuda-version-check.">;
+def err_drv_cuda_nvptx_host : Error<"unsupported use of NVPTX for host 
compilation.">;
 def err_drv_invalid_thread_model_for_target 

Re: r277095 - [Parser] Fix bug where delayed typo in conditional expression was corrected twice

2016-08-02 Thread Hans Wennborg via cfe-commits
Should we merge this to 3.9?

Thanks,
Hans

On Thu, Jul 28, 2016 at 5:55 PM, Erik Pilkington via cfe-commits
 wrote:
> Author: epilk
> Date: Thu Jul 28 19:55:40 2016
> New Revision: 277095
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277095&view=rev
> Log:
> [Parser] Fix bug where delayed typo in conditional expression was corrected 
> twice
>
> Patch by David Tarditi!
>
> Differential revision: https://reviews.llvm.org/D22930
>
> Modified:
> cfe/trunk/lib/Parse/ParseExpr.cpp
> cfe/trunk/test/Sema/typo-correction.c
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=277095&r1=277094&r2=277095&view=diff
> ==
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Jul 28 19:55:40 2016
> @@ -446,14 +446,15 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>  LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
>   OpToken.getKind(), LHS.get(), RHS.get());
>
> -// In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr 
> check.
> -if (!getLangOpts().CPlusPlus)
> -  continue;
>} else {
>  LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
>   LHS.get(), TernaryMiddle.get(),
>   RHS.get());
>}
> +  // In this case, ActOnBinOp or ActOnConditionalOp performed the
> +  // CorrectDelayedTyposInExpr check.
> +  if (!getLangOpts().CPlusPlus)
> +continue;
>  }
>  // Ensure potential typos aren't left undiagnosed.
>  if (LHS.isInvalid()) {
>
> Modified: cfe/trunk/test/Sema/typo-correction.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=277095&r1=277094&r2=277095&view=diff
> ==
> --- cfe/trunk/test/Sema/typo-correction.c (original)
> +++ cfe/trunk/test/Sema/typo-correction.c Thu Jul 28 19:55:40 2016
> @@ -65,3 +65,18 @@ int fn_with_rs(int r) { r = TYPO + r * T
>  void fn_with_unknown(int a, int b) {
>fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of 
> undeclared identifier}}
>  }
> +
> +// Two typos in a parenthesized expression or argument list with a 
> conditional
> +// expression caused a crash in C mode.
> +//
> +// r272587 fixed a similar bug for binary operations. The same fix was 
> needed for
> +// conditional expressions.
> +
> +int g(int x, int y) {
> +  return x + y;
> +}
> +
> +int h() {
> +  g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
> +  (x, 5 ? z : 0);  // expected-error 2 {{use of undeclared identifier}}
> +}
>
>
> ___
> 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


Re: [PATCH] D22208: [clang-tidy] Fixes to modernize-use-emplace

2016-08-02 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D22208#503194, @alexfh wrote:

> Please add revision number (this can be automated, if include differential 
> revision URL in your commit message as described in 
> http://llvm.org/docs/Phabricator.html#committing-a-change).


I normally use arc, but I was working in half from my laptop and in half from 
workstation, and I am not sure if arc would handle this.

I added the url in the patch, but I didn't know that "Differential Revision:" 
is required. I will keep it in mind next time.


https://reviews.llvm.org/D22208



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


Re: [PATCH] D22208: [clang-tidy] Fixes to modernize-use-emplace

2016-08-02 Thread Piotr Padlewski via cfe-commits
Prazek marked 5 inline comments as done.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:115
@@ -95,1 +114,3 @@
+  auto CtorCallSourceRange = CharSourceRange::getTokenRange(
+  InnerCtorCall->getExprLoc(), CallParensRange.getBegin());
 

alexfh wrote:
> Prazek wrote:
> > alexfh wrote:
> > > Prazek wrote:
> > > > alexfh wrote:
> > > > > This doesn't seem to be an issue, since expression 
> > > > > `v.push_back(obj.member())` won't trigger this check: it expects that 
> > > > > the argument of the `push_back` call is a `cxxConstructExpr` or a 
> > > > > `cxxFunctionalCastExpr`.
> > > > what about the implicit conversion? What if obj.member would return 
> > > > object that is different from the one that v stores, but it is 
> > > > convertible to it?
> > > Sounds almost like a recipe for a test case ;) Have you tried to 
> > > construct it this way?
> > Yes, I think I emulated this case in line 190. I tried to hit this problem 
> > but could not find the test case.
> >> if The Call->getArg(0) will be a memberExpr (call to member function)
> > what about the implicit conversion?
> 
> I think, I know what happens in this case. When an implicit conversion 
> happens in `v.push_back(obj.member())`, then `Call->getArg(0)` is an implicit 
> `CXXConstructExpr`, not a `MemberExpr` (`MemberExpr` will be its indirect 
> child). The case should be handled correctly.
That might be it. I remember that in some early version I was biding to 
MemberExpr somewhere, which might cause it.


https://reviews.llvm.org/D22208



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


r277490 - Update Clang Parser test error message to match new parser errors

2016-08-02 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Tue Aug  2 12:58:14 2016
New Revision: 277490

URL: http://llvm.org/viewvc/llvm-project?rev=277490&view=rev
Log:
Update Clang Parser test error message to match new parser errors

Update clang tests in light of r277489.

Modified:
cfe/trunk/test/Parser/ms-inline-asm.c

Modified: cfe/trunk/test/Parser/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=277490&r1=277489&r2=277490&view=diff
==
--- cfe/trunk/test/Parser/ms-inline-asm.c (original)
+++ cfe/trunk/test/Parser/ms-inline-asm.c Tue Aug  2 12:58:14 2016
@@ -54,7 +54,7 @@ void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
 void t13() {
-  __asm m{o}v eax, ebx // expected-error {{expected identifier}} 
expected-error {{use of undeclared label '{o}v eax, ebx'}}
+  __asm m{o}v eax, ebx // expected-error {{unknown token in expression}}
 }
 
 int t_fail() { // expected-note {{to match this}}


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


[PATCH] D23071: [OpenCL] Remove extra native_ functions from opencl-c.h

2016-08-02 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: Anastasia, yaxunl, nhaustov.
ashi1 added a subscriber: cfe-commits.
ashi1 set the repository for this revision to rL LLVM.

There should be no native_ builtin functions with double type arguments.

Repository:
  rL LLVM

https://reviews.llvm.org/D23071

Files:
  lib/Headers/opencl-c.h

Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -9810,14 +9810,6 @@
 float4 __ovld __cnfn native_cos(float4 x);
 float8 __ovld __cnfn native_cos(float8 x);
 float16 __ovld __cnfn native_cos(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_cos(double x);
-double2 __ovld __cnfn native_cos(double2 x);
-double3 __ovld __cnfn native_cos(double3 x);
-double4 __ovld __cnfn native_cos(double4 x);
-double8 __ovld __cnfn native_cos(double8 x);
-double16 __ovld __cnfn native_cos(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute x / y over an implementation-defined range.
@@ -9829,14 +9821,6 @@
 float4 __ovld __cnfn native_divide(float4 x, float4 y);
 float8 __ovld __cnfn native_divide(float8 x, float8 y);
 float16 __ovld __cnfn native_divide(float16 x, float16 y);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_divide(double x, double y);
-double2 __ovld __cnfn native_divide(double2 x, double2 y);
-double3 __ovld __cnfn native_divide(double3 x, double3 y);
-double4 __ovld __cnfn native_divide(double4 x, double4 y);
-double8 __ovld __cnfn native_divide(double8 x, double8 y);
-double16 __ovld __cnfn native_divide(double16 x, double16 y);
-#endif //cl_khr_fp64
 
 /**
  * Compute the base- e exponential of x over an
@@ -9849,14 +9833,6 @@
 float4 __ovld __cnfn native_exp(float4 x);
 float8 __ovld __cnfn native_exp(float8 x);
 float16 __ovld __cnfn native_exp(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_exp(double x);
-double2 __ovld __cnfn native_exp(double2 x);
-double3 __ovld __cnfn native_exp(double3 x);
-double4 __ovld __cnfn native_exp(double4 x);
-double8 __ovld __cnfn native_exp(double8 x);
-double16 __ovld __cnfn native_exp(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute the base- 2 exponential of x over an
@@ -9869,14 +9845,6 @@
 float4 __ovld __cnfn native_exp2(float4 x);
 float8 __ovld __cnfn native_exp2(float8 x);
 float16 __ovld __cnfn native_exp2(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_exp2(double x);
-double2 __ovld __cnfn native_exp2(double2 x);
-double3 __ovld __cnfn native_exp2(double3 x);
-double4 __ovld __cnfn native_exp2(double4 x);
-double8 __ovld __cnfn native_exp2(double8 x);
-double16 __ovld __cnfn native_exp2(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute the base- 10 exponential of x over an
@@ -9889,14 +9857,6 @@
 float4 __ovld __cnfn native_exp10(float4 x);
 float8 __ovld __cnfn native_exp10(float8 x);
 float16 __ovld __cnfn native_exp10(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_exp10(double x);
-double2 __ovld __cnfn native_exp10(double2 x);
-double3 __ovld __cnfn native_exp10(double3 x);
-double4 __ovld __cnfn native_exp10(double4 x);
-double8 __ovld __cnfn native_exp10(double8 x);
-double16 __ovld __cnfn native_exp10(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute natural logarithm over an implementationdefined
@@ -9909,14 +9869,6 @@
 float4 __ovld __cnfn native_log(float4 x);
 float8 __ovld __cnfn native_log(float8 x);
 float16 __ovld __cnfn native_log(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_log(double x);
-double2 __ovld __cnfn native_log(double2 x);
-double3 __ovld __cnfn native_log(double3 x);
-double4 __ovld __cnfn native_log(double4 x);
-double8 __ovld __cnfn native_log(double8 x);
-double16 __ovld __cnfn native_log(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute a base 2 logarithm over an implementationdefined
@@ -9928,14 +9880,6 @@
 float4 __ovld __cnfn native_log2(float4 x);
 float8 __ovld __cnfn native_log2(float8 x);
 float16 __ovld __cnfn native_log2(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_log2(double x);
-double2 __ovld __cnfn native_log2(double2 x);
-double3 __ovld __cnfn native_log2(double3 x);
-double4 __ovld __cnfn native_log2(double4 x);
-double8 __ovld __cnfn native_log2(double8 x);
-double16 __ovld __cnfn native_log2(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute a base 10 logarithm over an implementationdefined
@@ -9947,14 +9891,6 @@
 float4 __ovld __cnfn native_log10(float4 x);
 float8 __ovld __cnfn native_log10(float8 x);
 float16 __ovld __cnfn native_log10(float16 x);
-#ifdef cl_khr_fp64
-double __ovld __cnfn native_log10(double x);
-double2 __ovld __cnfn native_log10(double2 x);
-double3 __ovld __cnfn native_log10(double3 x);
-double4 __ovld __cnfn native_log10(double4 x);
-double8 __ovld __cnfn native_log10(double8 x);
-double16 __ovld __cnfn native_log10(double16 x);
-#endif //cl_khr_fp64
 
 /**
  * Compute x to the power y, where x is >= 0. The range of
@@ -9967,14 +9903,6 @@
 flo

[clang-tools-extra] r277491 - [clang-rename] fix Emacs integration script

2016-08-02 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Tue Aug  2 13:23:08 2016
New Revision: 277491

URL: http://llvm.org/viewvc/llvm-project?rev=277491&view=rev
Log:
[clang-rename] fix Emacs integration script

Modified:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.el

Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.el?rev=277491&r1=277490&r2=277491&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el Tue Aug  2 
13:23:08 2016
@@ -34,9 +34,7 @@
   ;; Run clang-rename via bash.
   (shell-command rename-command)
   ;; Reload buffer.
-  (lambda ()
-(interactive)
-(revert-buffer t t))
+  (revert-buffer t t)
 )
   )
 )


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


r277492 - Revert "[Order Files] Remove dtrace predicate"

2016-08-02 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Aug  2 13:23:56 2016
New Revision: 277492

URL: http://llvm.org/viewvc/llvm-project?rev=277492&view=rev
Log:
Revert "[Order Files] Remove dtrace predicate"

This reverts commit r277487.

Removing the probe predicate was a red herring. It results in more symbols 
being placed in the final order file, but they are symbols from outside the 
clang image.

Modified:
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=277492&r1=277491&r2=277492&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Aug  2 13:23:56 2016
@@ -75,12 +75,13 @@ def dtrace(args):
   target = "oneshot$target:::entry"
   else:
   target = "pid$target:::entry"
+  predicate = '%s/probemod=="%s"/' % (target, os.path.basename(cmd[0]))
   log_timestamp = 'printf("dtrace-TS: %d\\n", timestamp)'
   if opts.use_ustack:
   action = 'ustack(1);'
   else:
   action = 'printf("dtrace-Symbol: %s\\n", probefunc);'
-  dtrace_script = "%s { %s; %s }" % (target, log_timestamp, action)
+  dtrace_script = "%s { %s; %s }" % (predicate, log_timestamp, action)
 
   dtrace_args = []
   if not os.geteuid() == 0:


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


Re: [PATCH] D23004: [ASTMatchers] Add matchers canReferToDecl() and hasUnderlyingDecl()

2016-08-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:2809
@@ +2808,3 @@
+///   matches \c foo in \c foo(t);
+AST_MATCHER_P(OverloadExpr, canReferToDecl, internal::Matcher,
+  InnerMatcher) {

I find the name of this matcher a little bit confusing. The documentation 
doesn't describe what the matcher does (can you please clarify the docs?). The 
implementation suggests that this is looking to see if the given decl exists in 
the overload expression set, which makes me wonder why this isn't implemented 
on the `hasDeclaration()` traversal matcher rather than adding a new matcher 
name?


https://reviews.llvm.org/D23004



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


Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:63-64
@@ -62,4 +62,4 @@
 
-std::string SpecialMemberFunctionsCheck::join(
-llvm::ArrayRef SMFS, llvm::StringRef AndOr) {
+template 
+static std::string join(const R &SMFS, llvm::StringRef AndOr) {
 

I hadn't noticed this before -- why has this been converted to an unrestricted 
template? If generality is what you were going for, it should have accepted a 
range (or a pair of iterators) instead?


https://reviews.llvm.org/D23008



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


Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.
Prazek accepted this revision.
Prazek added a reviewer: Prazek.
Prazek added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D23008



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


Re: [PATCH] D23071: [OpenCL] Remove extra native_ functions from opencl-c.h

2016-08-02 Thread Nikolay Haustov via cfe-commits
nhaustov accepted this revision.
nhaustov added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.

Could you also note in commit message that online HTML docs are not very clear, 
but pdf of OpenCL specification has it right.


Repository:
  rL LLVM

https://reviews.llvm.org/D23071



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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Manuel Klimek via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D22505#503472, @LokiAstari wrote:

> I don't have a problem changing it so the default behaviour is:
>
>   class C {
>   int v1;
> private:
>   int v2;
>   };
>   
>
> But I would like to retain the functionality that if there is no explicit 
> public/private/protected that it follows the original.
>  But if there is huge objection to that I am not going to fight over this one 
> (I can live with the indention above).


That should already be doable with a negative offset today, right?


https://reviews.llvm.org/D22505



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


Re: [PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

2016-08-02 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:6611
@@ +6610,3 @@
+  if (auto *E = dyn_cast(If->getCond())) {
+// If we're using the '*' case here, then we cannot emit any warnings for
+// the 'then' branch.

Do you still want to suppress warnings in the 'then' branch for '*'? I think 
there is potential value in pointing out uses of APIs that are not available on 
the minimum deployment target for the '*' case.


https://reviews.llvm.org/D23003



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


[PATCH] D23078: ObjC: Use a new type for ObjC type parameter (Patch 1 out of 3)

2016-08-02 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: dexonsmith, doug.gregor.
manmanren added a subscriber: cfe-commits.

For ObjC type parameter, we used to have TypedefType that is canonicalized to
id or the bound type. We can't represent "T " and thus will lose
the type information in the following example:
@interface MyMutableDictionary : NSObject
- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType )key;
@end
MyMutableDictionary *stringsByString;
NSNumber *n1, *n2;
stringsByString[n1] = n2;
--> no warning on type mismatch of the key.

To fix the problem, we introduce a new type ObjCTypeParamType that supports
a list of protocol qualifiers.

This is the first patch:
[NFC] Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.
This will be shared between ObjCObjectType and ObjCTypeParamType.

https://reviews.llvm.org/D23078

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -546,15 +546,9 @@
   ObjCObjectTypeBits.NumTypeArgs = typeArgs.size();
   assert(getTypeArgsAsWritten().size() == typeArgs.size() &&
  "bitfield overflow in type argument count");
-  ObjCObjectTypeBits.NumProtocols = protocols.size();
-  assert(getNumProtocols() == protocols.size() &&
- "bitfield overflow in protocol count");
   if (!typeArgs.empty())
 memcpy(getTypeArgStorage(), typeArgs.data(),
typeArgs.size() * sizeof(QualType));
-  if (!protocols.empty())
-memcpy(getProtocolStorage(), protocols.data(),
-   protocols.size() * sizeof(ObjCProtocolDecl*));
 
   for (auto typeArg : typeArgs) {
 if (typeArg->isDependentType())
@@ -565,6 +559,9 @@
 if (typeArg->containsUnexpandedParameterPack())
   setContainsUnexpandedParameterPack();
   }
+  // Initialize the protocol qualifiers. The protocol storage is known
+  // after we set number of type arguments.
+  initialize(protocols);
 }
 
 bool ObjCObjectType::isSpecialized() const { 
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -4699,6 +4699,60 @@
   }
 };
 
+/// This class wraps the list of protocol qualifiers. For types that can
+/// take ObjC protocol qualifers, they can subclass this class. This class
+/// saves the number of protocols
+template 
+class ObjCProtocolQualifiers {
+protected:
+  ObjCProtocolQualifiers() {}
+  ObjCProtocolDecl * const *getProtocolStorage() const {
+return const_cast(this)->getProtocolStorage();
+  }
+
+  ObjCProtocolDecl **getProtocolStorage() {
+return static_cast(this)->getProtocolStorageImpl();
+  }
+  void setNumProtocols(unsigned N) {
+static_cast(this)->setNumProtocolsImpl(N);
+  }
+  void initialize(ArrayRef protocols) {
+setNumProtocols(protocols.size());
+assert(getNumProtocols() == protocols.size() &&
+   "bitfield overflow in protocol count");
+if (!protocols.empty())
+  memcpy(getProtocolStorage(), protocols.data(),
+ protocols.size() * sizeof(ObjCProtocolDecl*));
+  }
+
+public:
+  typedef ObjCProtocolDecl * const *qual_iterator;
+  typedef llvm::iterator_range qual_range;
+
+  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
+  qual_iterator qual_begin() const { return getProtocolStorage(); }
+  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
+
+  bool qual_empty() const { return getNumProtocols() == 0; }
+
+  /// Return the number of qualifying protocols in this type, or 0 if
+  /// there are none.
+  unsigned getNumProtocols() const {
+return static_cast(this)->getNumProtocolsImpl();
+  }
+
+  /// Fetch a protocol by index.
+  ObjCProtocolDecl *getProtocol(unsigned I) const {
+assert(I < getNumProtocols() && "Out-of-range protocol access");
+return qual_begin()[I];
+  }
+
+  /// Retrieve all of the protocol qualifiers.
+  ArrayRef getProtocols() const {
+return ArrayRef(qual_begin(), getNumProtocols());
+  }
+};
+
 /// Represents a class type in Objective C.
 ///
 /// Every Objective C type is a combination of a base type, a set of
@@ -4727,7 +4781,9 @@
 /// 'id' is an ObjCObjectPointerType whose pointee is an ObjCObjectType
 /// with base BuiltinType::ObjCIdType and protocol list [P].  Eventually
 /// this should get its own sugar class to better represent the source.
-class ObjCObjectType : public Type {
+class ObjCObjectType : public Type,
+   public ObjCProtocolQualifiers {
+  friend class ObjCProtocolQualifiers;
   // ObjCObjectType.NumTypeArgs - the number of type arguments stored
   // after the ObjCObjectPointerType node.
   // ObjCObjectType.NumProtocols - the number of protocols stored
@@ -4747,16 +4803,20 @@
   mutable llvm::PointerIntPair
 CachedSuperClassType;
 
-  ObjCProtocolDecl * const *getProtocolStorage() const {
-return const_cast(this)->g

Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-08-02 Thread Loki Astari via cfe-commits
LokiAstari added a comment.

> That should already be doable with a negative offset today, right?


Yes. So I don't need to add any changes. right?


https://reviews.llvm.org/D22505



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


[PATCH] D23079: ObjC: Use a new type for ObjC type parameter (patch 2 out of 3)

2016-08-02 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: doug.gregor.
manmanren added a subscriber: cfe-commits.

This depends on https://reviews.llvm.org/D23078

ObjC generics: Add ObjCTypeParamType in the type system.

We also need to add ObjCTypeParamTypeLoc. ObjCTypeParamType supports the
representation of "T " where T is a type parameter. Before this,
we use TypedefType to represent the type parameter for ObjC.

ObjCTypeParamType has "ObjCTypeParamDecl *OTPDecl" and it extends from
ObjCProtocolQualifiers.

The last patch (patch #3) will start using this new type.

https://reviews.llvm.org/D23079

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/AST/TypeNodes.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1534,6 +1534,18 @@
   return Visit(MakeCursorObjCClassRef(TL.getIFaceDecl(), TL.getNameLoc(), TU));
 }
 
+bool CursorVisitor::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (Visit(MakeCursorTypeRef(TL.getDecl(), TL.getLocStart(), TU)))
+return true;
+  for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
+if (Visit(MakeCursorObjCProtocolRef(TL.getProtocol(I), TL.getProtocolLoc(I),
+TU)))
+  return true;
+  }
+
+  return false;
+}
+
 bool CursorVisitor::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
   if (TL.hasBaseTypeAsWritten() && Visit(TL.getBaseLoc()))
 return true;
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -450,6 +450,14 @@
   Code = TYPE_OBJC_INTERFACE;
 }
 
+void ASTTypeWriter::VisitObjCTypeParamType(const ObjCTypeParamType *T) {
+  Record.AddDeclRef(T->getDecl());
+  Record.push_back(T->getNumProtocols());
+  for (const auto *I : T->quals())
+Record.AddDeclRef(I);
+  Code = TYPE_OBJC_TYPE_PARAM;
+}
+
 void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
   Record.AddTypeRef(T->getBaseType());
   Record.push_back(T->getTypeArgsAsWritten().size());
@@ -587,6 +595,12 @@
 void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   Record.AddSourceLocation(TL.getNameLoc());
 }
+void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  Record.AddSourceLocation(TL.getProtocolLAngleLoc());
+  Record.AddSourceLocation(TL.getProtocolRAngleLoc());
+  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+Record.AddSourceLocation(TL.getProtocolLoc(i));
+}
 void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   Record.AddSourceLocation(TL.getTypeofLoc());
   Record.AddSourceLocation(TL.getLParenLoc());
@@ -1066,6 +1080,7 @@
   RECORD(TYPE_ATOMIC);
   RECORD(TYPE_DECAYED);
   RECORD(TYPE_ADJUSTED);
+  RECORD(TYPE_OBJC_TYPE_PARAM);
   RECORD(LOCAL_REDECLARATIONS);
   RECORD(DECL_TYPEDEF);
   RECORD(DECL_TYPEALIAS);
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5542,6 +5542,16 @@
 return Context.getObjCInterfaceType(ItfD->getCanonicalDecl());
   }
 
+  case TYPE_OBJC_TYPE_PARAM: {
+unsigned Idx = 0;
+ObjCTypeParamDecl *Decl
+  = ReadDeclAs(*Loc.F, Record, Idx);
+unsigned NumProtos = Record[Idx++];
+SmallVector Protos;
+for (unsigned I = 0; I != NumProtos; ++I)
+  Protos.push_back(ReadDeclAs(*Loc.F, Record, Idx));
+return Context.getObjCTypeParamType(Decl, Protos);
+  }
   case TYPE_OBJC_OBJECT: {
 unsigned Idx = 0;
 QualType Base = readType(*Loc.F, Record, Idx);
@@ -5940,6 +5950,13 @@
 void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation(Record, Idx));
 }
+void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  TL.setProtocolLAngleLoc(ReadSourceLocation(Record, Idx));
+  TL.setProtocolRAngleLoc(ReadSourceLocation(Record, Idx));
+  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+TL.setProtocolLoc(i, ReadSourceLocation(Record, Idx));
+}
+
 void TypeLocReader

[PATCH] D23080: ObjC: Use a new type for ObjC type parameter (patch 3 out of 3)

2016-08-02 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: doug.gregor.
manmanren added a subscriber: cfe-commits.


Depends on https://reviews.llvm.org/D23078 and https://reviews.llvm.org/D23079

We say ObjCTypeParamType is ObjCObjectPointerType, but we assert
fail when trying to call Type::getPointeeType.

We compare the types between declaration and definition for ObjCMethods that
use the type parameter, by using simpleTransform that transforms the
ObjCTypeParamType to the underlying type of the ObjCTypeParamDecl. This matches
our previous behavior.

rdar://24619481
rdar://25060179


https://reviews.llvm.org/D23080

Files:
  include/clang/AST/Type.h
  lib/AST/DeclObjC.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaType.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/SemaObjC/kindof.m
  test/SemaObjC/parameterized_classes.m
  test/SemaObjC/parameterized_classes_subst.m

Index: test/SemaObjC/parameterized_classes_subst.m
===
--- test/SemaObjC/parameterized_classes_subst.m
+++ test/SemaObjC/parameterized_classes_subst.m
@@ -426,3 +426,36 @@
 // warning about likely protocol/class name typos.
 // --
 typedef NSArray ArrayOfNSObjectWarning; // expected-warning{{parameterized class 'NSArray' already conforms to the protocols listed; did you forget a '*'?}}
+
+// rdar://25060179
+@interface MyMutableDictionary : NSObject
+- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType )key; // expected-note{{passing argument to parameter 'obj' here}} \
+// expected-note{{passing argument to parameter 'key' here}}
+@end
+
+void bar(MyMutableDictionary *stringsByString,
+ NSNumber *n1, NSNumber *n2) {
+  // We warn here when the key types do not match.
+  stringsByString[n1] = n2; // expected-warning{{incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'}} \
+// expected-warning{{incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'}}
+}
+
+@interface MyTest : NSObject 
+- (V)test:(K)key;
+- (V)test2:(K)key; // expected-note{{previous definition is here}}
+- (void)mapUsingBlock:(id (^)(V))block;
+- (void)mapUsingBlock2:(id (^)(V))block; // expected-note{{previous definition is here}}
+@end
+
+@implementation MyTest
+- (id)test:(id)key {
+  return key;
+}
+- (int)test2:(id)key{ // expected-warning{{conflicting return type in implementation}}
+  return 0;
+}
+- (void)mapUsingBlock:(id (^)(id))block {
+}
+- (void)mapUsingBlock2:(id)block { // expected-warning{{conflicting parameter types in implementation}}
+}
+@end
Index: test/SemaObjC/parameterized_classes.m
===
--- test/SemaObjC/parameterized_classes.m
+++ test/SemaObjC/parameterized_classes.m
@@ -320,7 +320,7 @@
 @interface PC23 : PC1 // expected-error{{unknown type name 'U'}}
 @end
 
-@interface PC24 : PC1 // expected-error{{type argument 'T' (aka 'id') does not satisfy the bound ('NSObject *') of type parameter 'U'}}
+@interface PC24 : PC1 // expected-error{{type argument 'T' does not satisfy the bound ('NSObject *') of type parameter 'U'}}
 @end
 
 @interface NSFoo : PC1 // okay
Index: test/SemaObjC/kindof.m
===
--- test/SemaObjC/kindof.m
+++ test/SemaObjC/kindof.m
@@ -385,7 +385,7 @@
 @end
 
 @interface NSGeneric : NSObject
-- (void)test:(__kindof ObjectType)T;
+- (void)test:(__kindof ObjectType)T; // expected-note{{passing argument to parameter 'T' here}}
 - (void)mapUsingBlock:(id (^)(__kindof ObjectType))block;
 @end
 @implementation NSGeneric
@@ -395,6 +395,14 @@
 }
 @end
 
+void testGeneric(NSGeneric *generic) {
+  NSObject *NSObject_obj;
+  // Assign from NSObject_obj to __kindof NSString*.
+  [generic test:NSObject_obj]; // expected-warning{{incompatible pointer types sending 'NSObject *' to parameter of type '__kindof NSString *'}}
+  NSString *NSString_str;
+  [generic test:NSString_str];
+}
+
 // Check that clang doesn't crash when a type parameter is illegal.
 @interface Array1 : NSObject
 @end
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -60,7 +60,8 @@
   // Check if a callback is passed inside a struct (for both, struct passed by
   // reference and by value). Dig just one level into the struct for now.
 
-  if (T->isAnyPointerType() || T->isReferenceType())
+  if ((T->isAnyPointerType() && !isa(T)) ||
+  T->isReferenceType())
 T = T->getPointeeType();
 
   if (const RecordType *RT = T->getAsStructureType()) {
@@ -129,6 +130,8 @@
 /// \brief Returns true if a type is a pointer-to-const or reference-to-const
 /// with no further ind

Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:63-64
@@ -62,4 +62,4 @@
 
-std::string SpecialMemberFunctionsCheck::join(
-llvm::ArrayRef SMFS, llvm::StringRef AndOr) {
+template 
+static std::string join(const R &SMFS, llvm::StringRef AndOr) {
 

aaron.ballman wrote:
> I hadn't noticed this before -- why has this been converted to an 
> unrestricted template? If generality is what you were going for, it should 
> have accepted a range (or a pair of iterators) instead?
It needs to handle SmallSetVector which I can't convert to an ArrayRef.

How do I specify a range?


https://reviews.llvm.org/D23008



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


Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:63-64
@@ -62,4 +62,4 @@
 
-std::string SpecialMemberFunctionsCheck::join(
-llvm::ArrayRef SMFS, llvm::StringRef AndOr) {
+template 
+static std::string join(const R &SMFS, llvm::StringRef AndOr) {
 

jbcoe wrote:
> aaron.ballman wrote:
> > I hadn't noticed this before -- why has this been converted to an 
> > unrestricted template? If generality is what you were going for, it should 
> > have accepted a range (or a pair of iterators) instead?
> It needs to handle SmallSetVector which I can't convert to an ArrayRef.
> 
> How do I specify a range?
```
template 
static std::string join(llvm::iterator_range R, llvm::StringRef AndOr);
```
Untested, but you get the idea.


https://reviews.llvm.org/D23008



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


Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Running tests, will submit shortly.



Comment at: docs/clang-tidy/checks/mpi-type-mismatch.rst:13
@@ +12,3 @@
+.. code:: c++
+  // In this case, the buffer type matches MPI datatype.
+  char buf;

This doesn't parse - an extra newline is needed. I'll fix this myself.


https://reviews.llvm.org/D21962



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


Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 66541.
jbcoe added a comment.

static `join` function is no longer a function template.


https://reviews.llvm.org/D23008

Files:
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  test/clang-tidy/cppcoreguidelines-special-member-functions.cpp

Index: test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
===
--- test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
+++ test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
@@ -50,3 +50,18 @@
   DeletesCopyDefaultsMove &operator=(DeletesCopyDefaultsMove &&) = default;
   ~DeletesCopyDefaultsMove() = default;
 };
+
+template 
+struct TemplateClass {
+  TemplateClass() = default;
+  TemplateClass(const TemplateClass &);
+  TemplateClass &operator=(const TemplateClass &);
+  TemplateClass(TemplateClass &&);
+  TemplateClass &operator=(TemplateClass &&);
+  ~TemplateClass();
+};
+
+// Multiple instantiations of a class template will trigger multiple matches for defined special members.
+// This should not cause problems.
+TemplateClass InstantiationWithInt;
+TemplateClass InstantiationWithDouble;
Index: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
===
--- clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -1,4 +1,4 @@
-//===--- SpecialMemberFunctionsCheck.h - clang-tidy---*- C++ -*-===//
+//===--- SpecialMemberFunctionsCheck.h - clang-tidy--*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -41,15 +41,11 @@
 
   using ClassDefId = std::pair;
 
-  using ClassDefiningSpecialMembersMap = llvm::DenseMap>;
+  using ClassDefiningSpecialMembersMap =
+  llvm::DenseMap>;
 
 private:
-
-  static llvm::StringRef toString(SpecialMemberFunctionKind K);
-
-  static std::string join(llvm::ArrayRef SMFS,
-  llvm::StringRef AndOr);
-
   ClassDefiningSpecialMembersMap ClassWithSpecialMembers;
 };
 
@@ -65,7 +61,7 @@
 struct DenseMapInfo<
 clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId> {
   using ClassDefId =
-clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
+  clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
 
   static inline ClassDefId getEmptyKey() {
 return ClassDefId(
Index: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
===
--- clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -43,25 +43,26 @@
   this);
 }
 
-llvm::StringRef SpecialMemberFunctionsCheck::toString(
-SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
+static llvm::StringRef
+toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
   switch (K) {
-  case SpecialMemberFunctionKind::Destructor:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::Destructor:
 return "a destructor";
-  case SpecialMemberFunctionKind::CopyConstructor:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::CopyConstructor:
 return "a copy constructor";
-  case SpecialMemberFunctionKind::CopyAssignment:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::CopyAssignment:
 return "a copy assignment operator";
-  case SpecialMemberFunctionKind::MoveConstructor:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::MoveConstructor:
 return "a move constructor";
-  case SpecialMemberFunctionKind::MoveAssignment:
+  case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::MoveAssignment:
 return "a move assignment operator";
   }
   llvm_unreachable("Unhandled SpecialMemberFunctionKind");
 }
 
-std::string SpecialMemberFunctionsCheck::join(
-llvm::ArrayRef SMFS, llvm::StringRef AndOr) {
+static std::string
+join(ArrayRef SMFS,
+ llvm::StringRef AndOr) {
 
   assert(!SMFS.empty() &&
  "List of defined or undefined members should never be empty.");
@@ -97,7 +98,7 @@
 
   for (const auto &KV : Matchers)
 if (Result.Nodes.getNodeAs(KV.first))
-  ClassWithSpecialMembers[ID].push_back(KV.second);
+  ClassWithSpecialMembers[ID].insert(KV.second);
 }
 
 void SpecialMemberFunctionsCheck::onEndOfTranslationUnit() {
@@ -112,7 +113,7 @@
   }
 
   for (const auto &C : ClassWithSpecialMembers) {
-ArrayRef DefinedSpecialMembers = C.second;
+const auto &DefinedSpecialMembers = C.second;
 
 if (DefinedSpecialMembers.size() == AllSpecialMembers.size())
   continue;
@@ -124,7 +125,7 @@
 std::back_inserter(UndefinedSpecialMembers));
 
 diag(C.first.first, "class '%0' defines %1 but does not define %2")
-<< C.f

Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Jonathan B Coe via cfe-commits
jbcoe marked an inline comment as done.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:63-64
@@ -62,3 +62,4 @@
 
-std::string SpecialMemberFunctionsCheck::join(
-llvm::ArrayRef SMFS, llvm::StringRef AndOr) {
+static std::string
+join(ArrayRef SMFS,
+ llvm::StringRef AndOr) {

iterator_range loses me size, empty and index access. There's a function that 
gets and ArrayRef from a SmallSetVector (I wonder why there's no implicit 
conversion defined) so I can change the signature to take ArrayRef.


https://reviews.llvm.org/D23008



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


[libcxx] r277512 - Pass compilers when configuring Google Benchmark.

2016-08-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug  2 15:21:07 2016
New Revision: 277512

URL: http://llvm.org/viewvc/llvm-project?rev=277512&view=rev
Log:
Pass compilers when configuring  Google Benchmark.

Modified:
libcxx/trunk/benchmarks/CMakeLists.txt

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=277512&r1=277511&r2=277512&view=diff
==
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Tue Aug  2 15:21:07 2016
@@ -26,7 +26,9 @@ ExternalProject_Add(google-benchmark-lib
 PREFIX benchmark-libcxx
 SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark
 INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx
-CMAKE_CACHE_DEFAULT_ARGS
+CMAKE_CACHE_ARGS
+  -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
+  -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
   -DCMAKE_BUILD_TYPE:STRING=RELEASE
   -DCMAKE_INSTALL_PREFIX:PATH=
   -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBCXX_COMPILE_FLAGS}
@@ -45,7 +47,9 @@ if (LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB
 INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native
 CMAKE_CACHE_ARGS
   -DBENCHMARK_ENABLE_TESTING:BOOL=OFF
-CMAKE_CACHE_DEFAULT_ARGS
+CMAKE_CACHE_ARGS
+  -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
+  -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
   -DCMAKE_BUILD_TYPE:STRING=RELEASE
   -DCMAKE_INSTALL_PREFIX:PATH=)
 endif()
@@ -63,6 +67,7 @@ set(BENCHMARK_TEST_COMPILE_FLAGS
 )
 set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
 -nostdinc++
+-cxx-isystem ${LIBCXX_SOURCE_DIR}/include
 ${BENCHMARK_TEST_COMPILE_FLAGS}
 -Wno-user-defined-literals
 )


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


Re: [PATCH] D23008: [clang-tidy] fix segfault in cppcore-guidelines-special-member-functions check

2016-08-02 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM now, thank you for switching back! I was mostly worried about an 
unrestricted template argument in this case, not the particular form of the 
change. :-)


https://reviews.llvm.org/D23008



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


Re: [PATCH] D23058: [clang-rename] add support for template instantiations

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: test/clang-rename/TemplateClassInstantiationFindByDeclaration.cpp:2
@@ -1,3 +1,3 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=287 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename -offset=159 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s

It makes sense to move RUN lines to the end of the file (and add 
-fno-delayed-template-parsing, if windows buildbots start complaining).


Comment at: 
test/clang-rename/TemplateClassInstantiationFindByUninstantiatedType.cpp:2
@@ +1,3 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=440 -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s

This test looks exactly as the one above except for the offset. Instead of 
duplicating tests, we can run clang-rename multiple times and use different 
-check-prefix with FileCheck. In this case moving the RUN lines to the bottom 
makes even more sense.

Also, instructions for updating -offset are incorrect, if you have multiple 
different offsets.


https://reviews.llvm.org/D23058



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


Re: [PATCH] D23042: [CUDA] Do not allow using NVPTX target for host compilation.

2016-08-02 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

> Restore assertions for presence of -march flag.


We don't need an explicit assertion in TranslateArgs?



Comment at: lib/Driver/Driver.cpp:1412
@@ +1411,3 @@
+  assert(HostTC && "No toolchain for host compilation.");
+  if (HostTC->getTriple().isNVPTX()) {
+C.getDriver().Diag(diag::err_drv_cuda_nvptx_host);

This is probably worth a comment?


https://reviews.llvm.org/D23042



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


Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-08-02 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277516: [clang-tidy] MPITypeMismatchCheck (authored by 
alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D21962?vs=65404&id=66544#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21962

Files:
  clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/mpi/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/mpi/MPITidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp
  clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.h
  clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/mpi-type-mismatch.rst
  clang-tools-extra/trunk/test/clang-tidy/Inputs/mpi-type-mismatch/mpimock.h
  clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp

Index: clang-tools-extra/trunk/docs/clang-tidy/checks/mpi-type-mismatch.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/mpi-type-mismatch.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/mpi-type-mismatch.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - mpi-type-mismatch
+
+mpi-type-mismatch
+=
+
+This check verifies if buffer type and MPI (Message Passing Interface) datatype
+pairs match for used MPI functions. All MPI datatypes defined by the MPI
+standard (3.1) are verified by this check. User defined typedefs, custom MPI
+datatypes and null pointer constants are skipped, in the course of verification.
+
+Example:
+.. code:: c++
+
+  // In this case, the buffer type matches MPI datatype.
+  char buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+
+  // In the following case, the buffer type does not match MPI datatype.
+  int buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
@@ -110,6 +110,7 @@
modernize-use-nullptr
modernize-use-override
modernize-use-using
+   mpi-type-mismatch
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
Index: clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp
@@ -0,0 +1,255 @@
+// RUN: %check_clang_tidy %s mpi-type-mismatch %t -- -- -I %S/Inputs/mpi-type-mismatch
+
+#include "mpimock.h"
+
+void charNegativeTest() {
+  int buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int' does not match the MPI datatype 'MPI_CHAR'
+
+  short buf2;
+  MPI_Send(&buf2, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_CHAR'
+
+  long buf3;
+  MPI_Send(&buf3, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not match the MPI datatype 'MPI_CHAR'
+
+  int8_t buf4;
+  MPI_Send(&buf4, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'
+
+  uint16_t buf5;
+  MPI_Send(&buf5, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'
+
+  long double _Complex buf6;
+  MPI_Send(&buf6, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'
+
+  std::complex buf7;
+  MPI_Send(&buf7, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex' does not match the MPI datatype 'MPI_CHAR'
+}
+
+void intNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'
+
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'
+
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_INT'
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' d

[clang-tools-extra] r277517 - [docs] Fix links format.

2016-08-02 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Aug  2 15:29:47 2016
New Revision: 277517

URL: http://llvm.org/viewvc/llvm-project?rev=277517&view=rev
Log:
[docs] Fix links format.

Modified:
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/docs/include-fixer.rst

Modified: clang-tools-extra/trunk/docs/clang-rename.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=277517&r1=277516&r2=277517&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Tue Aug  2 15:29:47 2016
@@ -143,8 +143,8 @@ Please note that **you have to save all
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-`cr` and type new desired name. The [` key`]
-(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and type new desired name. The ` key
+`_
 is a reference to a specific key defined by the mapleader variable and is bound
 to backslash by default.
 

Modified: clang-tools-extra/trunk/docs/include-fixer.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/include-fixer.rst?rev=277517&r1=277516&r2=277517&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Tue Aug  2 15:29:47 2016
@@ -67,9 +67,9 @@ following key binding to your ``.vimrc``
   noremap cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
 
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change
-``cf`` to another binding if you need clang-include-fixer on a 
different
-key. The
-[`` 
key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cf` to another binding if you need clang-include-fixer on a different
+key. The ` key
+`_
 is a reference to a specific key defined by the mapleader variable and is bound
 to backslash by default.
 


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


  1   2   >