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

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65672.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ 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: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -32,7 +32,7 @@
 
 .. code-block:: console
 
-  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+  $ clang-rename rename-at -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
 
 
 To get an offset of a symbol in a file run
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file.
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/clang-rename rename-all -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol named .
+
+  USAGE: clang-rename r

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

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276836 and resolved conflicts.


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] D22663: Support setting default value for -rtlib at build time

2016-07-27 Thread Lei Zhang via cfe-commits
zlei added a comment.

@Hahnfeld Could you please commit it? I don't have the access.

Thanks :)


https://reviews.llvm.org/D22663



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


Re: [PATCH] D22805: [clang-include-fixer] Added Emacs integration for clang-include-fixer.

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

It looks good to me now, a few comments.  Let's wait to see whether @bkramer 
has any further comments.



Comment at: docs/include-fixer.rst:81
@@ +80,3 @@
+To run `clang-include-fixer` on a potentially unsaved buffer in Emacs. 
+Ensure that Emacs finds ``clang-include-fixer.el`` by adding the diretory 
containing the file to the ``load-path``
+and requiring the `clang-include-fixer` in your ```.emacs``:

s/diretory/directory


Comment at: include-fixer/tool/clang-include-fixer.el:23
@@ +22,3 @@
+  "clang-include-fixer"
+  "Location of the `clang-include-fixer' executable.
+

I might be wrong, I think it is missing a `"` at the end?


Comment at: include-fixer/tool/clang-include-fixer.el:51
@@ +50,3 @@
+  "Calls clang-include-fixer with parameters INCLUDE-FIXER-PARAMETER-[ABC].
+If the call was successful the returned result is stored in a temp buffer
+and the function CALLEE is called on this temp buffer."

code indentation.


https://reviews.llvm.org/D22805



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


Re: [PATCH] D22663: Support setting default value for -rtlib at build time

2016-07-27 Thread Jonas Hahnfeld via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276848: Support setting default value for -rtlib at build 
time (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D22663?vs=65643&id=65678#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22663

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/include/clang/Config/config.h.cmake
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/test/Driver/linux-ld.c
  cfe/trunk/test/Driver/miamcu-opt.c
  cfe/trunk/test/Driver/miamcu-opt.cpp
  cfe/trunk/test/Driver/mingw-libgcc.c
  cfe/trunk/test/Driver/mingw.cpp
  cfe/trunk/test/Driver/mips-mti-linux.c
  cfe/trunk/test/Driver/sanitizer-ld.c
  cfe/trunk/test/Driver/windows-cross.c
  cfe/trunk/test/OpenMP/linking.c

Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -193,12 +193,23 @@
 "enable x86 relax relocations by default")
 
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
-  "Default C++ stdlib to use (empty for platform default, \"libstdc++\" or \"libc++\"")
+  "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
 CLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR
 CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++"))
   message(WARNING "Resetting default C++ stdlib to use platform default")
-  set(CLANG_DEFAULT_CXX_STDLIB "")
+  set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
+"Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default" FORCE)
+endif()
+
+set(CLANG_DEFAULT_RTLIB "" CACHE STRING
+  "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)")
+if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
+CLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR
+CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt"))
+  message(WARNING "Resetting default rtlib to use platform default")
+  set(CLANG_DEFAULT_RTLIB "" CACHE STRING
+"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -534,15 +534,19 @@
 
 ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
 const ArgList &Args) const {
-  if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
-StringRef Value = A->getValue();
-if (Value == "compiler-rt")
-  return ToolChain::RLT_CompilerRT;
-if (Value == "libgcc")
-  return ToolChain::RLT_Libgcc;
-getDriver().Diag(diag::err_drv_invalid_rtlib_name)
-  << A->getAsString(Args);
-  }
+  const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
+  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
+
+  // "platform" is only used in tests to override CLANG_DEFAULT_RTLIB
+  if (LibName == "compiler-rt")
+return ToolChain::RLT_CompilerRT;
+  else if (LibName == "libgcc")
+return ToolChain::RLT_Libgcc;
+  else if (LibName == "platform")
+return GetDefaultRuntimeLibType();
+
+  if (A)
+getDriver().Diag(diag::err_drv_invalid_rtlib_name) << A->getAsString(Args);
 
   return GetDefaultRuntimeLibType();
 }
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -575,6 +575,8 @@
   /// @name Apple ToolChain Implementation
   /// {
 
+  RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
+
   void AddLinkRuntimeLibArgs(const llvm::Triple &EffectiveTriple,
  const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const override;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -403,18 +403,23 @@
   /*AddRPath*/ true);
 }
 
+ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(
+const ArgList &Args) const {
+  if (Arg* A = Args.getLastArg(options::OPT_rtlib_EQ)) {
+StringRef Value = A->getValue();
+if (Value != "compiler-rt")
+  getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
+  << Value << "darwin";
+  }
+
+  return ToolChain::RLT_CompilerRT;
+}
+
 void DarwinClang::AddLinkRuntimeLibArgs(const llvm::Triple &EffectiveTriple,
 const ArgList &Args,
 ArgStringList &CmdArgs) const {
-  // Darwin only supports the compiler-rt based runtime libraries.
-  switch (GetRuntimeLibType(Args)) {
-  case ToolChain::RLT_

r276848 - Support setting default value for -rtlib at build time

2016-07-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Jul 27 03:15:54 2016
New Revision: 276848

URL: http://llvm.org/viewvc/llvm-project?rev=276848&view=rev
Log:
Support setting default value for -rtlib at build time

This patch introduces a new cmake variable: CLANG_DEFAULT_RTLIB, thru
which we can specify a default value for -rtlib (libgcc or
compiler-rt) at build time, just like how we set the default C++
stdlib thru CLANG_DEFAULT_CXX_STDLIB.

With these two options, we can configure clang to build binaries on
Linux that have no runtime dependence on any gcc libs (libstdc++ or
libgcc_s).

Patch by Lei Zhang!

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/linux-ld.c
cfe/trunk/test/Driver/miamcu-opt.c
cfe/trunk/test/Driver/miamcu-opt.cpp
cfe/trunk/test/Driver/mingw-libgcc.c
cfe/trunk/test/Driver/mingw.cpp
cfe/trunk/test/Driver/mips-mti-linux.c
cfe/trunk/test/Driver/sanitizer-ld.c
cfe/trunk/test/Driver/windows-cross.c
cfe/trunk/test/OpenMP/linking.c

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=276848&r1=276847&r2=276848&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Jul 27 03:15:54 2016
@@ -193,12 +193,23 @@ set(ENABLE_X86_RELAX_RELOCATIONS OFF CAC
 "enable x86 relax relocations by default")
 
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
-  "Default C++ stdlib to use (empty for platform default, \"libstdc++\" or 
\"libc++\"")
+  "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform 
default")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
 CLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR
 CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++"))
   message(WARNING "Resetting default C++ stdlib to use platform default")
-  set(CLANG_DEFAULT_CXX_STDLIB "")
+  set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
+"Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for 
platform default" FORCE)
+endif()
+
+set(CLANG_DEFAULT_RTLIB "" CACHE STRING
+  "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for 
platform default)")
+if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
+CLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR
+CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt"))
+  message(WARNING "Resetting default rtlib to use platform default")
+  set(CLANG_DEFAULT_RTLIB "" CACHE STRING
+"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for 
platform default)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING

Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=276848&r1=276847&r2=276848&view=diff
==
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Wed Jul 27 03:15:54 2016
@@ -11,6 +11,9 @@
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
+/* Default runtime library to use. */
+#define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
+
 /* Default OpenMP runtime used by -fopenmp. */
 #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}"
 

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=276848&r1=276847&r2=276848&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Jul 27 03:15:54 2016
@@ -534,15 +534,19 @@ void ToolChain::addProfileRTLibs(const l
 
 ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
 const ArgList &Args) const {
-  if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
-StringRef Value = A->getValue();
-if (Value == "compiler-rt")
-  return ToolChain::RLT_CompilerRT;
-if (Value == "libgcc")
-  return ToolChain::RLT_Libgcc;
-getDriver().Diag(diag::err_drv_invalid_rtlib_name)
-  << A->getAsString(Args);
-  }
+  const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
+  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
+
+  // "platform" is only used in tests to override CLANG_DEFAULT_RTLIB
+  if (LibName == "compiler-rt")
+return ToolChain::RLT_CompilerRT;
+  else if (LibName == "libgcc")
+return ToolChain::RLT_Libgcc;
+  else if (LibName == "platform")
+return GetDefaultRuntimeLibType();
+
+  if (A)
+getDriver().Diag(diag::err_drv_invalid_rtlib_name) << A->getAsString(Args);
 
   return GetDefaultRuntimeLibType();
 }

Modif

Re: [PATCH] D22805: [clang-include-fixer] Added Emacs integration for clang-include-fixer.

2016-07-27 Thread Jens Massberg via cfe-commits
massberg updated this revision to Diff 65679.
massberg marked an inline comment as done.
massberg added a comment.

Updating https://reviews.llvm.org/D22805: [clang-include-fixer] Added Emacs 
integration for clang-include-fixer.

- Corrected typos and code indentation.


https://reviews.llvm.org/D22805

Files:
  docs/include-fixer.rst
  include-fixer/tool/clang-include-fixer.el

Index: include-fixer/tool/clang-include-fixer.el
===
--- /dev/null
+++ include-fixer/tool/clang-include-fixer.el
@@ -0,0 +1,207 @@
+;;; clang-include-fxier.el --- Emacs integration of the clang include fixer
+
+;; Keywords: tools, c
+;; Package-Requires: ((json "1.2"))
+
+;;; Commentary:
+
+;; This package allows to invoke the 'clang-include-fixer' within Emacs.
+;; 'clang-include-fixer' provides an automated way of adding #include
+;; directives for missing symbols in one translation unit, see
+;; .
+
+;;; Code:
+
+(require 'json)
+
+(defgroup clang-include-fixer nil
+  "Include fixer."
+  :group 'tools)
+
+(defcustom clang-include-fixer-executable
+  "clang-include-fixer"
+  "Location of the `clang-include-fixer' executable.
+
+   A string containing the name or the full path of the executable."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+(defcustom clang-include-fixer-input-format
+  "yaml"
+  "clang-include-fixer input format."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+(defcustom clang-include-fixer-init-string
+  ""
+  "clang-include-fixer input format."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+
+(defun clang-include-fixer-call-executable (callee
+include-fixer-parameter-a
+&optional include-fixer-parameter-b
+&optional include-fixer-parameter-c
+)
+  "Calls clang-include-fixer with parameters INCLUDE-FIXER-PARAMETER-[ABC].
+   If the call was successful the returned result is stored in a temp buffer
+   and the function CALLEE is called on this temp buffer."
+
+(let ((temp-buffer (generate-new-buffer " *clang-include-fixer-temp*"))
+  (temp-file (make-temp-file "clang-include-fixer")))
+  (unwind-protect
+  (let (status stderr operations)
+(if (eq include-fixer-parameter-c nil)
+(setq status
+  (call-process-region
+   (point-min) (point-max) clang-include-fixer-executable
+   nil `(,temp-buffer ,temp-file) nil
+
+   "-stdin"
+   include-fixer-parameter-a
+   (buffer-file-name)
+   ))
+  (setq status
+(call-process-region
+ (point-min) (point-max) clang-include-fixer-executable
+ nil `(,temp-buffer ,temp-file) nil
+
+ "-stdin"
+ include-fixer-parameter-a
+ include-fixer-parameter-b
+ include-fixer-parameter-c
+ (buffer-file-name)
+ )))
+
+(setq stderr
+  (with-temp-buffer
+(insert-file-contents temp-file)
+(when (> (point-max) (point-min))
+  (insert ": "))
+(buffer-substring-no-properties
+ (point-min) (line-end-position
+
+(cond
+ ((stringp status)
+  (error "(clang-include-fixer killed by signal %s%s)" status
+ stderr))
+ ((not (equal 0 status))
+  (error "(clang-include-fixer failed with code %d%s)" status
+ stderr)))
+(funcall callee temp-buffer))
+(delete-file temp-file)
+(when (buffer-name temp-buffer) (kill-buffer temp-buffer)
+
+
+(defun clang-include-fixer-replace_buffer (temp-buffer)
+  "Replace current buffer by content of TEMP-BUFFER"
+
+  (with-current-buffer temp-buffer
+(setq temp-start (point-min))
+(setq temp-end (point-max))
+)
+  (barf-if-buffer-read-only)
+  (erase-buffer)
+  (save-excursion
+(insert-buffer-substring temp-buffer temp-start temp-end)))
+
+
+(defun clang-include-fixer-add-header (temp-buffer)
+  "Analyse the result of include-fixer stored in TEMP_BUFFER and add a
+   missing header if there is any. If there are multiple possible headers
+   the user can select one of them to be included."
+
+  (with-current-buffer temp-buffer
+(setq result (buffer-substring (point-min) (point-max)))
+(setq include-fixer-context
+  (let ((json-object-type 'plist))
+(json-read-from-string result
+
+  ;; The header-infos is already sorted by include-fixer.
+  (setq header-infos (p

Re: [PATCH] D22805: [clang-include-fixer] Added Emacs integration for clang-include-fixer.

2016-07-27 Thread Jens Massberg via cfe-commits
massberg marked 2 inline comments as done.
massberg added a comment.

Thanks for the comments!



Comment at: include-fixer/tool/clang-include-fixer.el:24
@@ +23,3 @@
+  "Location of the `clang-include-fixer' executable.
+
+   A string containing the name or the full path of the executable."

The ending  " is two lines below.


https://reviews.llvm.org/D22805



___
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-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Apart from my high level concerns, which of course I still have...



Comment at: clang-rename/tool/clang-rename.py:43
@@ -42,2 +42,3 @@
 command = [binary,
+   "rename-at",
filename,

`rename-at` isn't necessary here anymore since it's going to be default 
behavior IIUC


Comment at: docs/clang-rename.rst:35
@@ -34,3 +34,3 @@
 
-  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include 
-DMY_DEFINES ...
+  $ clang-rename rename-at -offset=42 -new-name=foo test.cpp -- 
-Imy_project/include -DMY_DEFINES ...
 

docs should be fixed correspondingly; i.e. prefer to write `clang-rename 
-offset=42` over `clang-rename -rename-at`


Comment at: docs/clang-rename.rst:50
@@ +49,3 @@
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+

here and later, too


https://reviews.llvm.org/D21814



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


r276851 - [ARM] Pass -mimplcit-it= to integrated assembler

2016-07-27 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Wed Jul 27 03:54:13 2016
New Revision: 276851

URL: http://llvm.org/viewvc/llvm-project?rev=276851&view=rev
Log:
[ARM] Pass -mimplcit-it= to integrated assembler

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


Added:
cfe/trunk/test/Driver/arm-implicit-it.s
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276851&r1=276850&r2=276851&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 03:54:13 2016
@@ -1377,6 +1377,7 @@ def mwatchsimulator_version_min_EQ : Joi
 def march_EQ : Joined<["-"], "march=">, Group;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
+def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, 
Group;
 def mconsole : Joined<["-"], "mconsole">, Group, 
Flags<[DriverOption]>;
 def mwindows : Joined<["-"], "mwindows">, Group, 
Flags<[DriverOption]>;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276851&r1=276850&r2=276851&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 03:54:13 2016
@@ -2882,6 +2882,27 @@ static void CollectArgsForIntegratedAsse
DefaultIncrementalLinkerCompatible))
 CmdArgs.push_back("-mincremental-linker-compatible");
 
+  switch (C.getDefaultToolChain().getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) {
+  StringRef Value = A->getValue();
+  if (Value == "always" || Value == "never" || Value == "arm" ||
+  Value == "thumb") {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value));
+  } else {
+D.Diag(diag::err_drv_unsupported_option_argument)
+<< A->getOption().getName() << Value;
+  }
+}
+break;
+  default:
+break;
+  }
+
   // When passing -I arguments to the assembler we sometimes need to
   // unconditionally take the next argument.  For example, when parsing
   // '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the

Added: cfe/trunk/test/Driver/arm-implicit-it.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-implicit-it.s?rev=276851&view=auto
==
--- cfe/trunk/test/Driver/arm-implicit-it.s (added)
+++ cfe/trunk/test/Driver/arm-implicit-it.s Wed Jul 27 03:54:13 2016
@@ -0,0 +1,24 @@
+// RUN: %clang -target armv7--none-eabi -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=arm -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ARM
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=thumb -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-THUMB
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=never -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NEVER
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=always -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ALWAYS
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=thisisnotavalidoption 
-### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-INVALID
+
+// CHECK-DEFAULT-NOT: "-arm-implicit-it
+// CHECK-ARM: "-arm-implicit-it=arm"
+// CHECK-THUMB: "-arm-implicit-it=thumb"
+// CHECK-NEVER: "-arm-implicit-it=never"
+// CHECK-ALWAYS: "-arm-implicit-it=always"
+// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to 
option 'mimplicit-it='


___
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-07-27 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65684.

https://reviews.llvm.org/D21814

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

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ 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: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/clang-rename rename-all -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol named .
+
+  USAGE: clang-rename rename-all [subcommand] [options]  [... ]
+
+  OPTIONS:
+
   Generic Options:
 
 -help  - Display available options (-help-hidden for more)
 -help-list - Display list of available options (-help-list-hidden for more)
 -version   - Display th

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

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos marked 2 inline comments as done.
vmiklos added a comment.

> rename-at isn't necessary here anymore since it's going to be default 
> behavior IIUC


Indeed, it can be changed back now, done.

> docs should be fixed correspondingly; i.e. prefer to write clang-rename 
> -offset=42 over clang-rename -rename-at


Done.

> here and later, too


`clang-rename rename-at` is now only mentioned by the document when it comes to
`clang-rename rename-at -help`, which is still necessary, as `clang-rename
-help` talks about the subcommands only. I've updated `clang-rename -help` so
that it points out that `rename-at` is the default, though.


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] D21749: Changes related to new implementation of tooling::Replacements as class.

2016-07-27 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 65685.
ioeric added a comment.

- Merged with origin/master.


https://reviews.llvm.org/D21749

Files:
  
clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  include-fixer/IncludeFixer.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  tool-template/ToolTemplate.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -119,7 +119,14 @@
   DiagConsumer.finish();
   tooling::Replacements Fixes;
   for (const ClangTidyError &Error : Context.getErrors())
-Fixes.insert(Error.Fix.begin(), Error.Fix.end());
+for (const auto &Fix : Error.Fix) {
+  auto Err = Fixes.add(Fix);
+  // FIXME: better error handling.
+  if (Err) {
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+return "";
+  }
+}
   if (Errors)
 *Errors = Context.getErrors();
   auto Result = tooling::applyAllReplacements(Code, Fixes);
Index: tool-template/ToolTemplate.cpp
===
--- tool-template/ToolTemplate.cpp
+++ tool-template/ToolTemplate.cpp
@@ -53,18 +53,20 @@
 
 namespace {
 class ToolTemplateCallback : public MatchFinder::MatchCallback {
- public:
-  ToolTemplateCallback(Replacements *Replace) : Replace(Replace) {}
+public:
+  ToolTemplateCallback(std::map *Replace)
+  : Replace(Replace) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-// TODO: This routine will get called for each thing that the matchers find.
+// TODO: This routine will get called for each thing that the matchers
+// find.
 // At this point, you can examine the match, and do whatever you want,
 // including replacing the matched text with other text
 (void)Replace; // This to prevent an "unused member variable" warning;
   }
 
- private:
-  Replacements *Replace;
+private:
+  std::map *Replace;
 };
 } // end anonymous namespace
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -350,8 +350,7 @@
   }
 
   if (!Quiet)
-errs() << "Added #include " << Context.getHeaderInfos().front().Header
-   << '\n';
+llvm::errs() << "Added #include" << Context.getHeaderInfos().front().Header;
 
   // Set up a new source manager for applying the resulting replacements.
   IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions);
Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -352,23 +352,36 @@
   std::string IncludeName =
   "#include " + Context.getHeaderInfos().front().Header + "\n";
   // Create replacements for the new header.
-  clang::tooling::Replacements Insertions = {
-  tooling::Replacement(FilePath, UINT_MAX, 0, IncludeName)};
+  clang::tooling::Replacements Insertions;
+  // FIXME: remove this error comsuption when createInsertHeaderReplacements
+  // returns Error.
+  llvm::consumeError(
+  Insertions.add(tooling::Replacement(FilePath, UINT_MAX, 0, IncludeName)));
 
   auto CleanReplaces = cleanupAroundReplacements(Code, Insertions, Style);
   if (!CleanReplaces)
 return CleanReplaces;
 
+  auto Replaces = std::move(*CleanReplaces);
   if (AddQualifiers) {
 for (const auto &Info : Context.getQuerySymbolInfos()) {
   // Ignore the empty range.
-  if (Info.Range.getLength() > 0)
-CleanReplaces->insert({FilePath, Info.Range.getOffset(),
-   Info.Range.getLength(),
-   Context.getHeaderInfos().front().QualifiedName});
+  if (Info.Range.getLength() > 0) {
+auto R = tooling::Replacement(
+{FilePath, Info.Range.getOffset(), Info.Range.getLength(),
+ Context.getHeaderInfos().front().QualifiedName});
+auto Err = Replaces.add(R);
+if (Err) {
+  llvm::consumeError(std::move(Err));
+  R = tooling::Replacement(
+  R.getFilePath(), Replaces.getShiftedCodePosition(R.getOffset()),
+  R.getLength(), R.getReplacementText());
+  Replaces = Replaces.merge(tooling::Replacements(R));
+}
+  }
 }
   }
-  return formatReplacements(Code, *CleanReplaces, Style);
+  return formatReplacements(Code, Replaces, Style);
 }
 
 } // namespace include_fixer
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===

Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-27 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 65686.
ioeric added a comment.

- Moved ReplacementTest and toReplacements to ReplacementTest.h
- Merge branch 'master' of http://llvm.org/git/clang into replace


https://reviews.llvm.org/D21748

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/TokenAnalyzer.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  lib/Tooling/RefactoringCallbacks.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp
  unittests/Tooling/ReplacementTest.h
  unittests/Tooling/RewriterTest.cpp

Index: unittests/Tooling/RewriterTest.cpp
===
--- unittests/Tooling/RewriterTest.cpp
+++ unittests/Tooling/RewriterTest.cpp
@@ -39,8 +39,11 @@
 
 TEST(Rewriter, AdjacentInsertAndDelete) {
   Replacements Replaces;
-  Replaces.insert(Replacement("", 6, 6, ""));
-  Replaces.insert(Replacement("", 6, 0, "replaced\n"));
+  auto Err = Replaces.add(Replacement("", 6, 6, ""));
+  EXPECT_TRUE(!Err);
+  Replaces =
+  Replaces.merge(Replacements(Replacement("", 6, 0, "replaced\n")));
+
   auto Rewritten = applyAllReplacements("line1\nline2\nline3\nline4", Replaces);
   EXPECT_TRUE(static_cast(Rewritten));
   EXPECT_EQ("line1\nreplaced\nline3\nline4", *Rewritten);
Index: unittests/Tooling/ReplacementTest.h
===
--- /dev/null
+++ unittests/Tooling/ReplacementTest.h
@@ -0,0 +1,53 @@
+//===- unittest/Tooling/ReplacementTest.h - Replacements related test--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines a utility class for Replacement related tests.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
+#define LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
+
+#include "RewriterTestContext.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+
+static tooling::Replacements
+toReplacements(const std::set &Replaces) {
+  tooling::Replacements Result;
+  for (const auto &R : Replaces) {
+auto Err = Result.add(R);
+EXPECT_TRUE(!Err);
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return tooling::Replacements();
+}
+  }
+  return Result;
+}
+
+class ReplacementTest : public ::testing::Test {
+public:
+protected:
+  tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
+ llvm::StringRef ReplacementText) {
+return tooling::Replacement(Context.Sources, Start, Length,
+ReplacementText);
+  }
+
+  RewriterTestContext Context;
+};
+
+} // namespace tooling
+} // namespace clang
+
+#endif // LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "ReplacementTest.h"
 #include "RewriterTestContext.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
@@ -31,16 +32,6 @@
 namespace clang {
 namespace tooling {
 
-class ReplacementTest : public ::testing::Test {
- protected:
-  Replacement createReplacement(SourceLocation Start, unsigned Length,
-llvm::StringRef ReplacementText) {
-return Replacement(Context.Sources, Start, Length, ReplacementText);
-  }
-
-  RewriterTestContext Context;
-};
-
 TEST_F(ReplacementTest, CanDeleteAllText) {
   FileID ID = Context.createInMemoryFile("input.cpp", "text");
   SourceLocation Location = Context.getLocation(ID, 1, 1);
@@ -108,62 +99,59 @@
   EXPECT_TRUE(Replace2.getFilePath().empty());
 }
 
-TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.createInMemoryFile("input.cpp",
- "line1\nline2\nline3\nline4");
+TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 1),
-  5, "other"));
-  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("line1\nreplaced\nother\nline4", Co

Re: [PATCH] D22805: [clang-include-fixer] Added Emacs integration for clang-include-fixer.

2016-07-27 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

Looks good from my side.


https://reviews.llvm.org/D22805



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


Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-27 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 65687.
ioeric added a comment.

- Clean up ReplacemenTest.h header a bit.


https://reviews.llvm.org/D21748

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/TokenAnalyzer.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  lib/Tooling/RefactoringCallbacks.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp
  unittests/Tooling/ReplacementTest.h
  unittests/Tooling/RewriterTest.cpp

Index: unittests/Tooling/RewriterTest.cpp
===
--- unittests/Tooling/RewriterTest.cpp
+++ unittests/Tooling/RewriterTest.cpp
@@ -39,8 +39,11 @@
 
 TEST(Rewriter, AdjacentInsertAndDelete) {
   Replacements Replaces;
-  Replaces.insert(Replacement("", 6, 6, ""));
-  Replaces.insert(Replacement("", 6, 0, "replaced\n"));
+  auto Err = Replaces.add(Replacement("", 6, 6, ""));
+  EXPECT_TRUE(!Err);
+  Replaces =
+  Replaces.merge(Replacements(Replacement("", 6, 0, "replaced\n")));
+
   auto Rewritten = applyAllReplacements("line1\nline2\nline3\nline4", Replaces);
   EXPECT_TRUE(static_cast(Rewritten));
   EXPECT_EQ("line1\nreplaced\nline3\nline4", *Rewritten);
Index: unittests/Tooling/ReplacementTest.h
===
--- /dev/null
+++ unittests/Tooling/ReplacementTest.h
@@ -0,0 +1,56 @@
+//===- unittest/Tooling/ReplacementTest.h - Replacements related test--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines utility class and function for Replacement related tests.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
+#define LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
+
+#include "RewriterTestContext.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+
+/// \brief Converts a set of replacements to Replacements class.
+/// \return A Replacements class containing \p Replaces on success; otherwise,
+/// an empty Replacements is returned.
+static tooling::Replacements
+toReplacements(const std::set &Replaces) {
+  tooling::Replacements Result;
+  for (const auto &R : Replaces) {
+auto Err = Result.add(R);
+EXPECT_TRUE(!Err);
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return tooling::Replacements();
+}
+  }
+  return Result;
+}
+
+/// \brief A utility class for replacement related tests.
+class ReplacementTest : public ::testing::Test {
+protected:
+  tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
+ llvm::StringRef ReplacementText) {
+return tooling::Replacement(Context.Sources, Start, Length,
+ReplacementText);
+  }
+
+  RewriterTestContext Context;
+};
+
+} // namespace tooling
+} // namespace clang
+
+#endif // LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "ReplacementTest.h"
 #include "RewriterTestContext.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
@@ -31,16 +32,6 @@
 namespace clang {
 namespace tooling {
 
-class ReplacementTest : public ::testing::Test {
- protected:
-  Replacement createReplacement(SourceLocation Start, unsigned Length,
-llvm::StringRef ReplacementText) {
-return Replacement(Context.Sources, Start, Length, ReplacementText);
-  }
-
-  RewriterTestContext Context;
-};
-
 TEST_F(ReplacementTest, CanDeleteAllText) {
   FileID ID = Context.createInMemoryFile("input.cpp", "text");
   SourceLocation Location = Context.getLocation(ID, 1, 1);
@@ -108,62 +99,59 @@
   EXPECT_TRUE(Replace2.getFilePath().empty());
 }
 
-TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.createInMemoryFile("input.cpp",
- "line1\nline2\nline3\nline4");
+TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 1),

Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-27 Thread Eric Liu via cfe-commits
ioeric marked an inline comment as done.


Comment at: unittests/Tooling/RefactoringTest.cpp:112
@@ -111,4 +111,3 @@
 
-TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.createInMemoryFile("input.cpp",
- "line1\nline2\nline3\nline4");
+static Replacements toReplacements(const std::set &Replaces) {
+  Replacements Result;

klimek wrote:
> Looks like we should put this function into some header, so we don't need to 
> re-implement it in every test?
Done. 

Added unittests/Tooling/ReplacementTest.h that contains `ReplacementTest` class 
and `toReplacements`, both of which are used in multiple test files.


https://reviews.llvm.org/D21748



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


[clang-tools-extra] r276853 - [clang-include-fixer] Added Emacs integration for clang-include-fixer.

2016-07-27 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jul 27 05:11:06 2016
New Revision: 276853

URL: http://llvm.org/viewvc/llvm-project?rev=276853&view=rev
Log:
[clang-include-fixer] Added Emacs integration for clang-include-fixer.

Patch by Jens Massberg! Thanks a lot.

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

Added:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
Modified:
clang-tools-extra/trunk/docs/include-fixer.rst

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=276853&r1=276852&r2=276853&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Wed Jul 27 05:11:06 2016
@@ -75,6 +75,25 @@ You can customize the number of headers
 
 See ``clang-include-fixer.py`` for more details.
 
+Integrate with Emacs
+
+To run `clang-include-fixer` on a potentially unsaved buffer in Emacs.
+Ensure that Emacs finds ``clang-include-fixer.el`` by adding the directory 
containing the file to the ``load-path``
+and requiring the `clang-include-fixer` in your ```.emacs``:
+
+.. code-block:: console
+
+ (add-to-list 'load-path 
"path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/"
+ (require 'clang-include-fixer)
+
+Within Emacs the tool can be invoked with the command ``M-x 
clang-include-fixer``.
+
+Make sure Emacs can find :program:`clang-include-fixer`:
+
+- Add the path to :program:`clang-include-fixer` to the PATH environment 
variable.
+
+See ``clang-include-fixer.el`` for more details.
+
 How it Works
 
 

Added: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=276853&view=auto
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (added)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Wed Jul 
27 05:11:06 2016
@@ -0,0 +1,207 @@
+;;; clang-include-fxier.el --- Emacs integration of the clang include fixer
+
+;; Keywords: tools, c
+;; Package-Requires: ((json "1.2"))
+
+;;; Commentary:
+
+;; This package allows to invoke the 'clang-include-fixer' within Emacs.
+;; 'clang-include-fixer' provides an automated way of adding #include
+;; directives for missing symbols in one translation unit, see
+;; .
+
+;;; Code:
+
+(require 'json)
+
+(defgroup clang-include-fixer nil
+  "Include fixer."
+  :group 'tools)
+
+(defcustom clang-include-fixer-executable
+  "clang-include-fixer"
+  "Location of the `clang-include-fixer' executable.
+
+   A string containing the name or the full path of the executable."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+(defcustom clang-include-fixer-input-format
+  "yaml"
+  "clang-include-fixer input format."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+(defcustom clang-include-fixer-init-string
+  ""
+  "clang-include-fixer input format."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+
+(defun clang-include-fixer-call-executable (callee
+include-fixer-parameter-a
+&optional include-fixer-parameter-b
+&optional include-fixer-parameter-c
+)
+  "Calls clang-include-fixer with parameters INCLUDE-FIXER-PARAMETER-[ABC].
+   If the call was successful the returned result is stored in a temp buffer
+   and the function CALLEE is called on this temp buffer."
+
+(let ((temp-buffer (generate-new-buffer " *clang-include-fixer-temp*"))
+  (temp-file (make-temp-file "clang-include-fixer")))
+  (unwind-protect
+  (let (status stderr operations)
+(if (eq include-fixer-parameter-c nil)
+(setq status
+  (call-process-region
+   (point-min) (point-max) clang-include-fixer-executable
+   nil `(,temp-buffer ,temp-file) nil
+
+   "-stdin"
+   include-fixer-parameter-a
+   (buffer-file-name)
+   ))
+  (setq status
+(call-process-region
+ (point-min) (point-max) clang-include-fixer-executable
+ nil `(,temp-buffer ,temp-file) nil
+
+ "-stdin"
+ include-fixer-parameter-a
+ include-fixer-parameter-b
+ include-fixer-parameter-c
+ (buffer-file-name)
+ )))
+
+(setq stderr
+  (with-temp-buffer
+  

Re: [PATCH] D22805: [clang-include-fixer] Added Emacs integration for clang-include-fixer.

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276853: [clang-include-fixer] Added Emacs integration for 
clang-include-fixer. (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D22805?vs=65679&id=65689#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22805

Files:
  clang-tools-extra/trunk/docs/include-fixer.rst
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el

Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
@@ -0,0 +1,207 @@
+;;; clang-include-fxier.el --- Emacs integration of the clang include fixer
+
+;; Keywords: tools, c
+;; Package-Requires: ((json "1.2"))
+
+;;; Commentary:
+
+;; This package allows to invoke the 'clang-include-fixer' within Emacs.
+;; 'clang-include-fixer' provides an automated way of adding #include
+;; directives for missing symbols in one translation unit, see
+;; .
+
+;;; Code:
+
+(require 'json)
+
+(defgroup clang-include-fixer nil
+  "Include fixer."
+  :group 'tools)
+
+(defcustom clang-include-fixer-executable
+  "clang-include-fixer"
+  "Location of the `clang-include-fixer' executable.
+
+   A string containing the name or the full path of the executable."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+(defcustom clang-include-fixer-input-format
+  "yaml"
+  "clang-include-fixer input format."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+(defcustom clang-include-fixer-init-string
+  ""
+  "clang-include-fixer input format."
+  :group 'clang-include-fixer
+  :type 'string
+  :risky t)
+
+
+(defun clang-include-fixer-call-executable (callee
+include-fixer-parameter-a
+&optional include-fixer-parameter-b
+&optional include-fixer-parameter-c
+)
+  "Calls clang-include-fixer with parameters INCLUDE-FIXER-PARAMETER-[ABC].
+   If the call was successful the returned result is stored in a temp buffer
+   and the function CALLEE is called on this temp buffer."
+
+(let ((temp-buffer (generate-new-buffer " *clang-include-fixer-temp*"))
+  (temp-file (make-temp-file "clang-include-fixer")))
+  (unwind-protect
+  (let (status stderr operations)
+(if (eq include-fixer-parameter-c nil)
+(setq status
+  (call-process-region
+   (point-min) (point-max) clang-include-fixer-executable
+   nil `(,temp-buffer ,temp-file) nil
+
+   "-stdin"
+   include-fixer-parameter-a
+   (buffer-file-name)
+   ))
+  (setq status
+(call-process-region
+ (point-min) (point-max) clang-include-fixer-executable
+ nil `(,temp-buffer ,temp-file) nil
+
+ "-stdin"
+ include-fixer-parameter-a
+ include-fixer-parameter-b
+ include-fixer-parameter-c
+ (buffer-file-name)
+ )))
+
+(setq stderr
+  (with-temp-buffer
+(insert-file-contents temp-file)
+(when (> (point-max) (point-min))
+  (insert ": "))
+(buffer-substring-no-properties
+ (point-min) (line-end-position
+
+(cond
+ ((stringp status)
+  (error "(clang-include-fixer killed by signal %s%s)" status
+ stderr))
+ ((not (equal 0 status))
+  (error "(clang-include-fixer failed with code %d%s)" status
+ stderr)))
+(funcall callee temp-buffer))
+(delete-file temp-file)
+(when (buffer-name temp-buffer) (kill-buffer temp-buffer)
+
+
+(defun clang-include-fixer-replace_buffer (temp-buffer)
+  "Replace current buffer by content of TEMP-BUFFER"
+
+  (with-current-buffer temp-buffer
+(setq temp-start (point-min))
+(setq temp-end (point-max))
+)
+  (barf-if-buffer-read-only)
+  (erase-buffer)
+  (save-excursion
+(insert-buffer-substring temp-buffer temp-start temp-end)))
+
+
+(defun clang-include-fixer-add-header (temp-buffer)
+  "Analyse the result of include-fixer stored in TEMP_BUFFER and add a
+   missing header if there is any. If there are multiple possible headers
+   the user can select one of them to be included."
+
+  (with-current-buffer temp-buffer
+(setq result (buffer-substring (point-min) (point-max)))
+(setq include-fixer-context

r276854 - clang-format: Fix incorrect detection of QT-signals access specifier.

2016-07-27 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Jul 27 05:13:24 2016
New Revision: 276854

URL: http://llvm.org/viewvc/llvm-project?rev=276854&view=rev
Log:
clang-format: Fix incorrect detection of QT-signals access specifier.

Before:
  void f() {
  label:
signals
.baz();
  }

After:
  void f() {
  label:
signals.baz();
  }

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=276854&r1=276853&r2=276854&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Jul 27 05:13:24 2016
@@ -906,8 +906,8 @@ void UnwrappedLineParser::parseStructura
   if (FormatTok->is(tok::colon)) {
 nextToken();
 addUnwrappedLine();
+return;
   }
-  return;
 }
 // In all other cases, parse the declaration.
 break;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=276854&r1=276853&r2=276854&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jul 27 05:13:24 2016
@@ -1934,6 +1934,10 @@ TEST_F(FormatTest, UnderstandsAccessSpec
   verifyFormat("{\n"
"  signals.set(); // This needs indentation.\n"
"}");
+  verifyFormat("void f() {\n"
+   "label:\n"
+   "  signals.baz();\n"
+   "}");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {


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


Re: [llvm-dev] [PATCH] Add support for the 'unless' matcher in the dynamic layer.

2016-07-27 Thread Manuel Klimek via cfe-commits
On Wed, Jul 27, 2016 at 1:06 AM Piotr Padlewski via llvm-dev <
llvm-...@lists.llvm.org> wrote:

> We could also just add nothing() matcher, so debugging would be much
> easier, just add anything() or nothing() matcher as extra argument.
>
> The other pros of it is that new developers won't send the patches that
> uses those variadic matchers with only one argument.
>

We already have anything() and unless(anything()).


>
> 2016-07-26 16:02 GMT-07:00 Zac Hansen via llvm-dev <
> llvm-...@lists.llvm.org>:
>
>> Even if it still did add overhead, it seems perfectly reasonable, from a
>> user's perspective (namely mine), that if I introduce unnecessary narrowing
>> matchers to my chain that there may be a performance penalty.
>>
>> The ability to do the following easily outweighs any performance issues
>> for me:
>>
>>
>> anyOf (
>> /*hasName("..."), */
>> hasName("...")
>>
>> )
>>
>> though C++ not allowing trailing commas makes this not quite as great.
>>
>>
>> *However, without help, I would not be able to put forward a patch with
>> anything more than simply removing the minimums.*
>>
>> Would this be acceptable or would someone be able to point me at what it
>> would take to do it the "smart way" in less time than it would take them to
>> make the change themselves?
>>
>> On Tue, Jul 26, 2016 at 3:29 PM, Samuel Benzaquen 
>> wrote:
>>
>>> One of the reasons we added the minimum was because these nodes added
>>> overhead to the matching that was not unnecessary when they only had a
>>> single node.
>>> On the current implementation we could actually get rid of the node
>>> completely for the one argument calls.
>>> I would be ok with removing the lower bound.
>>>
>>>
>>> On Tue, Jul 26, 2016 at 6:20 PM, Zac Hansen  wrote:
>>>
 I was wondering if there is any objection to removing the 2-element
 minimum on the eachOf, anyOf and allOf matchers.

 It is frustrating when playing with matchers to have to edit
 significant amounts of code to be able to temporarily go from 2 to 1
 matcher inside an any- or allOf matcher.

 And overall it feels very "un-set-theory"-like.

 The change was made here:
 https://github.com/llvm-mirror/clang/commit/674e54c167eab0be7a54bca7082c07d2f1d0c8cc


 Thank you and apologies if I sent this to the wrong lists/people.

 --Zac

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


Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-27 Thread John Brawn via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276856: Adjust Registry interface to not require plugins to 
export a registry (authored by john.brawn).

Repository:
  rL LLVM

https://reviews.llvm.org/D21385

Files:
  cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
  cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
  cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
  cfe/trunk/include/clang/Lex/Preprocessor.h
  cfe/trunk/lib/Frontend/FrontendAction.cpp
  cfe/trunk/lib/Lex/Preprocessor.cpp
  cfe/trunk/lib/Tooling/CompilationDatabase.cpp
  llvm/trunk/include/llvm/Support/Registry.h
  llvm/trunk/lib/CodeGen/GCMetadataPrinter.cpp
  llvm/trunk/lib/CodeGen/GCStrategy.cpp

Index: llvm/trunk/include/llvm/Support/Registry.h
===
--- llvm/trunk/include/llvm/Support/Registry.h
+++ llvm/trunk/include/llvm/Support/Registry.h
@@ -69,13 +69,14 @@
   node(const entry &V) : Next(nullptr), Val(V) {}
 };
 
-static void add_node(node *N) {
-  if (Tail)
-Tail->Next = N;
-  else
-Head = N;
-  Tail = N;
-}
+/// Add a node to the Registry: this is the interface between the plugin and
+/// the executable.
+///
+/// This function is exported by the executable and called by the plugin to
+/// add a node to the executable's registry. Therefore it's not defined here
+/// to avoid it being instantiated in the plugin and is instead defined in
+/// the executable (see LLVM_INSTANTIATE_REGISTRY below).
+static void add_node(node *N);
 
 /// Iterators for registry entries.
 ///
@@ -120,61 +121,23 @@
 add_node(&Node);
   }
 };
-
-/// A dynamic import facility.  This is used on Windows to
-/// import the entries added in the plugin.
-static void import(sys::DynamicLibrary &DL, const char *RegistryName) {
-  typedef void *(*GetRegistry)();
-  std::string Name("LLVMGetRegistry_");
-  Name.append(RegistryName);
-  GetRegistry Getter =
-  (GetRegistry)(intptr_t)DL.getAddressOfSymbol(Name.c_str());
-  if (Getter) {
-// Call the getter function in order to get the full copy of the
-// registry defined in the plugin DLL, and copy them over to the
-// current Registry.
-typedef std::pair Info;
-Info *I = static_cast(Getter());
-iterator begin(I->first);
-iterator end(I->second);
-for (++end; begin != end; ++begin) {
-  // This Node object needs to remain alive for the
-  // duration of the program.
-  add_node(new node(*begin));
-}
-  }
-}
-
-/// Retrieve the data to be passed across DLL boundaries when
-/// importing registries from another DLL on Windows.
-static void *exportRegistry() {
-  static std::pair Info(Head, Tail);
-  return &Info;
-}
   };
-
-  
-  // Since these are defined in a header file, plugins must be sure to export
-  // these symbols.
-  template 
-  typename Registry::node *Registry::Head;
-
-  template 
-  typename Registry::node *Registry::Tail;
 } // end namespace llvm
 
-#ifdef LLVM_ON_WIN32
-#define LLVM_EXPORT_REGISTRY(REGISTRY_CLASS)   \
-  extern "C" { \
-  __declspec(dllexport) void *__cdecl LLVMGetRegistry_##REGISTRY_CLASS() { \
-return REGISTRY_CLASS::exportRegistry();   \
-  }\
+/// Instantiate a registry class.
+///
+/// This instantiates add_node and the Head and Tail pointers.
+#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS) \
+  namespace llvm { \
+  template<> void REGISTRY_CLASS::add_node(REGISTRY_CLASS::node *N) { \
+if (Tail) \
+ Tail->Next = N; \
+else \
+  Head = N; \
+Tail = N; \
+  } \
+  template<> typename REGISTRY_CLASS::node *REGISTRY_CLASS::Head = nullptr; \
+  template<> typename REGISTRY_CLASS::node *REGISTRY_CLASS::Tail = nullptr; \
   }
-#define LLVM_IMPORT_REGISTRY(REGISTRY_CLASS, DL)   \
-  REGISTRY_CLASS::import(DL, #REGISTRY_CLASS)
-#else
-#define LLVM_EXPORT_REGISTRY(REGISTRY_CLASS)
-#define LLVM_IMPORT_REGISTRY(REGISTRY_CLASS, DL)
-#endif
 
 #endif // LLVM_SUPPORT_REGISTRY_H
Index: llvm/trunk/lib/CodeGen/GCStrategy.cpp
===
--- llvm/trunk/lib/CodeGen/GCStrategy.cpp
+++ llvm/trunk/lib/CodeGen/GCStrategy.cpp
@@ -16,6 +16,8 @@
 
 using namespace llvm;
 
+LLVM_INSTANTIATE_REGISTRY(GCRegistry)
+
 GCStrategy::GCStrategy()
 : UseStatepoints(false), NeededSafePoints(0), CustomReadBarriers(false),
   CustomWriteBarriers(false), CustomRoots(false), InitRoots(true),
Index: llvm/trunk/lib/CodeGen/GCMetadataPrinter.cpp
===
--

r276856 - Adjust Registry interface to not require plugins to export a registry

2016-07-27 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Wed Jul 27 06:18:38 2016
New Revision: 276856

URL: http://llvm.org/viewvc/llvm-project?rev=276856&view=rev
Log:
Adjust Registry interface to not require plugins to export a registry

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

Differential Revision: http://reviews.llvm.org/D21385

Modified:
cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt?rev=276856&r1=276855&r2=276856&view=diff
==
--- cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt (original)
+++ cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt Wed Jul 27 06:18:38 2016
@@ -1,4 +1,4 @@
-add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
+add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL 
clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(AnnotateFunctions PRIVATE

Modified: cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt?rev=276856&r1=276855&r2=276856&view=diff
==
--- cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt (original)
+++ cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt Wed Jul 27 06:18:38 
2016
@@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols di
   endif()
 endif()
 
-add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
+add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL 
clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(PrintFunctionNames PRIVATE

Modified: cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h?rev=276856&r1=276855&r2=276856&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h Wed Jul 27 
06:18:38 2016
@@ -13,9 +13,6 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/Support/Registry.h"
 
-// Instantiated in FrontendAction.cpp.
-extern template class llvm::Registry;
-
 namespace clang {
 
 /// The frontend plugin registry.

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=276856&r1=276855&r2=276856&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 27 06:18:38 2016
@@ -1956,6 +1956,4 @@ typedef llvm::Registry Pr
 
 }  // end namespace clang
 
-extern template class llvm::Registry;
-
 #endif

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=276856&r1=276855&r2=276856&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed Jul 27 06:18:38 2016
@@ -33,7 +33,7 @@
 #include 
 using namespace clang;
 
-template class llvm::Registry;
+LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
 
 namespace {
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=276856&r1=276855&r2=276856&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
++

r276857 - Revert r276856 "Adjust Registry interface to not require plugins to export a registry"

2016-07-27 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Wed Jul 27 06:41:18 2016
New Revision: 276857

URL: http://llvm.org/viewvc/llvm-project?rev=276857&view=rev
Log:
Revert r276856 "Adjust Registry interface to not require plugins to export a 
registry"

This is causing a huge pile of buildbot failures.

Modified:
cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt (original)
+++ cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt Wed Jul 27 06:41:18 2016
@@ -1,4 +1,4 @@
-add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL 
clang)
+add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(AnnotateFunctions PRIVATE

Modified: cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt (original)
+++ cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt Wed Jul 27 06:41:18 
2016
@@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols di
   endif()
 endif()
 
-add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL 
clang)
+add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(PrintFunctionNames PRIVATE

Modified: cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h Wed Jul 27 
06:41:18 2016
@@ -13,6 +13,9 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/Support/Registry.h"
 
+// Instantiated in FrontendAction.cpp.
+extern template class llvm::Registry;
+
 namespace clang {
 
 /// The frontend plugin registry.

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 27 06:41:18 2016
@@ -1956,4 +1956,6 @@ typedef llvm::Registry Pr
 
 }  // end namespace clang
 
+extern template class llvm::Registry;
+
 #endif

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed Jul 27 06:41:18 2016
@@ -33,7 +33,7 @@
 #include 
 using namespace clang;
 
-LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
+template class llvm::Registry;
 
 namespace {
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Jul 27 06:41:18 2016
@@ -54,7 +54,7 @@
 #include 
 using namespace clang;
 
-LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
+template class llvm::Registry;
 
 
//===--===//
 ExternalPreprocessorSource::~ExternalPreprocessorSource() { }

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=276857&r1=276856&r2=276857&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed Jul 27 06:41:18 2016
@@ -32,8 +32,6 @@
 using namespace clang;
 using namespace tooling;
 
-LLVM_INSTANTIATE_REGISTRY(Compilati

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

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

Few simple tweaks allow template parameters to be renamed. See 
TemplateTypenameFindBy{TemplateParam|TypeInside}.cpp for example how it works.

https://reviews.llvm.org/D22853

Files:
  clang-rename/USRFinder.cpp
  clang-rename/USRLocFinder.cpp
  test/clang-rename/TemplateTypename.cpp
  test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
  test/clang-rename/TemplateTypenameFindByTypeInside.cpp

Index: test/clang-rename/TemplateTypenameFindByTypeInside.cpp
===
--- test/clang-rename/TemplateTypenameFindByTypeInside.cpp
+++ 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=205 -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: test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
===
--- test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
+++ 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: test/clang-rename/TemplateTypename.cpp
===
--- test/clang-rename/TemplateTypename.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// Currently unsupported test.
-// RUN: cat %s > %t.cpp
-// FIXME: clang-rename should be able to rename template parameters correctly.
-
-template 
-T foo(T arg, T& ref, T* ptr) {
-  T value;
-  int number = 42;
-  value = (T)number;
-  value = static_cast(number);
-  return value;
-}
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -117,6 +117,11 @@
 if (getUSRForDecl(Loc.getType()->getAsCXXRecordDecl()) == USR) {
   checkAndAddLocation(Loc.getBeginLoc());
 }
+if (const auto *TTPT = dyn_cast(Loc.getType())) {
+  if (getUSRForDecl(TTPT->getDecl()) == USR) {
+checkAndAddLocation(Loc.getBeginLoc());
+  }
+}
 return true;
   }
 
@@ -161,8 +166,7 @@
   void checkAndAddLocation(SourceLocation Loc) {
 const auto BeginLoc = Loc;
 const auto EndLoc = Lexer::getLocForEndOfToken(
-   BeginLoc, 0, Context.getSourceManager(),
-   Context.getLangOpts());
+BeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
 StringRef TokenName =
 Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc),
  Context.getSourceManager(), 
Context.getLangOpts());
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -75,7 +75,10 @@
   bool VisitTypeLoc(const TypeLoc Loc) {
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-   TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
+TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
+if (const auto *TTPT = dyn_cast(Loc.getType())) {
+  return setResult(TTPT->getDecl(), TypeBeginLoc, TypeEndLoc);
+}
 return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
  TypeEndLoc);
   }


Index: test/clang-rename/TemplateTypenameFindByTypeInside.cpp
===
--- test/clang-rename/TemplateTypenameFindByTypeInside.cpp
+++ 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=205 -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: test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
===

[PATCH] D22854: change Vim key binding for include-fixer and clang-rename

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

Change Vim key binding for include-fixer (`,cf` -> `cf`) and 
clang-rename (`,cr` -> `cr`) to use `` instead of `,` like cool 
Vim people (tm) do.

https://reviews.llvm.org/D22854

Files:
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  docs/include-fixer.rst
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see 
http://clang.llvm.org/extra/include-fixer.html
 #
Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -60,10 +60,11 @@
 
 .. code-block:: console
 
-  map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+  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.
+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.
 
 Make sure vim can find :program:`clang-include-fixer`:
 
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -93,7 +93,7 @@
 
`_.
 
 Once installed, you can point your cursor to the symbols you want to rename,
-press `,cr` and print new desired name.
+press `cr` and print 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.py
===
--- clang-rename/tool/clang-rename.py
+++ clang-rename/tool/clang-rename.py
@@ -9,13 +9,13 @@
 
 To install, simply put this into your ~/.vimrc
 
-map ,cr :pyf /clang-rename.py
+noremap cr :pyf /clang-rename.py
 
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be prompted for a new name 
if
-the cursor points to a valid symbol.
+you would like to rename and press 'cr'. You will be prompted for a new
+name if the cursor points to a valid symbol.
 '''
 
 import vim


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
 #
Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -60,10 +60,11 @@
 
 .. code-block:: console
 
-  map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+  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.
+This enables `clang-include-fixer` for NORMAL

Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-27 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/D21748



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


[PATCH] D22855: [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo created this revision.
mstorsjo added a subscriber: cfe-commits.
Herald added subscribers: samparker, rengolin, aemerson.

This makes sure that the thumb section flag gets set by the assembler.

This is an alternative fix to D22776.

https://reviews.llvm.org/D22855

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/thumb-attributes.s

Index: test/Driver/thumb-attributes.s
===
--- /dev/null
+++ test/Driver/thumb-attributes.s
@@ -0,0 +1,22 @@
+@ RUN: %clang -target armv7-windows-itanium -c -o - %s \
+@ RUN:   | llvm-readobj -s - | FileCheck %s
+
+   .syntax unified
+   .thumb
+
+   .text
+
+   .global function
+   .thumb_func
+function:
+   bx lr
+
+@ CHECK: Sections [
+@ CHECK:   Section {
+@ CHECK: Name: .text
+@ CHECK: Characteristics [
+@ CHECK-DAG:   IMAGE_SCN_CNT_CODE
+@ CHECK-DAG:   IMAGE_SCN_MEM_16BIT
+@ CHECK: ]
+@ CHECK:   }
+@ CHECK: ]
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -493,8 +493,10 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
+// Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
+ getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else


Index: test/Driver/thumb-attributes.s
===
--- /dev/null
+++ test/Driver/thumb-attributes.s
@@ -0,0 +1,22 @@
+@ RUN: %clang -target armv7-windows-itanium -c -o - %s \
+@ RUN:   | llvm-readobj -s - | FileCheck %s
+
+	.syntax unified
+	.thumb
+
+	.text
+
+	.global function
+	.thumb_func
+function:
+	bx lr
+
+@ CHECK: Sections [
+@ CHECK:   Section {
+@ CHECK: Name: .text
+@ CHECK: Characteristics [
+@ CHECK-DAG:   IMAGE_SCN_CNT_CODE
+@ CHECK-DAG:   IMAGE_SCN_MEM_16BIT
+@ CHECK: ]
+@ CHECK:   }
+@ CHECK: ]
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -493,8 +493,10 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
+// Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
+ getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Eric Liu via cfe-commits
ioeric added a comment.

Could you briefly explain what  is and how to lookup/set it in the doc, 
or at least provide reference?


https://reviews.llvm.org/D22854



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


Re: [PATCH] D22798: Fix for compiling with clang <= 3.7 and g++6 headers.

2016-07-27 Thread Frederich Munch via cfe-commits
marsupial added a comment.

Would be nice...I have no commit access.


Repository:
  rL LLVM

https://reviews.llvm.org/D22798



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


Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-07-27 Thread Guy Blank via cfe-commits
guyblank updated this revision to Diff 65676.
guyblank marked an inline comment as done.

https://reviews.llvm.org/D21959

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  lib/Headers/xsaveintrin.h
  test/CodeGen/builtins-x86.c
  test/CodeGen/x86_32-xsave.c
  test/CodeGen/x86_64-xsave.c
  test/Headers/ms-intrin.cpp

Index: test/Headers/ms-intrin.cpp
===
--- test/Headers/ms-intrin.cpp
+++ test/Headers/ms-intrin.cpp
@@ -50,7 +50,6 @@
   int info[4];
   __cpuid(info, 0);
   __cpuidex(info, 0, 0);
-  _xgetbv(0);
   __halt();
   __readmsr(0);
 
Index: test/CodeGen/x86_64-xsave.c
===
--- test/CodeGen/x86_64-xsave.c
+++ test/CodeGen/x86_64-xsave.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVE
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVE
 
+// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XGETBV
+// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSETBV
+
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVEOPT
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVEOPT
 
@@ -10,8 +13,14 @@
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVES
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVES
 
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+#include 
+
+
 void test() {
   unsigned long long tmp_ULLi;
+  unsigned int   tmp_Ui;
   void*  tmp_vp;
 
 #ifdef TEST_XSAVE
@@ -46,6 +55,18 @@
 // XSAVE: [[low32_4:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_4]] to i32
 // XSAVE: call void @llvm.x86.xrstor64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])
   (void)__builtin_ia32_xrstor64(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xsave
+  (void)_xsave(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xsave64
+  (void)_xsave64(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xrstor
+  (void)_xrstor(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xrstor64
+  (void)_xrstor64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEOPT
@@ -64,6 +85,12 @@
 // XSAVEOPT: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32
 // XSAVEOPT: call void @llvm.x86.xsaveopt64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])
   (void)__builtin_ia32_xsaveopt64(tmp_vp, tmp_ULLi);
+  
+// XSAVEOPT: call void @llvm.x86.xsaveopt
+  (void)_xsaveopt(tmp_vp, tmp_ULLi);
+  
+// XSAVEOPT: call void @llvm.x86.xsaveopt64
+  (void)_xsaveopt64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEC
@@ -82,6 +109,12 @@
 // XSAVEC: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32
 // XSAVEC: call void @llvm.x86.xsavec64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])
   (void)__builtin_ia32_xsavec64(tmp_vp, tmp_ULLi);
+  
+// XSAVEC: call void @llvm.x86.xsavec 
+  (void)_xsavec(tmp_vp, tmp_ULLi);
+  
+// XSAVEC: call void @llvm.x86.xsavec64
+  (void)_xsavec64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVES
@@ -116,5 +149,39 @@
 // XSAVES: [[low32_4:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_4]] to i32
 // XSAVES: call void @llvm.x86.xrstors64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])
   (void)__builtin_ia32_xrstors64(tmp_vp, tmp_ULLi);
+  
+// XSAVES: call void @llvm.x86.xsaves
+  (void)_xsaves(tmp_vp, tmp_ULLi); 
+  
+// XSAVES: call void @llvm.x86.xsaves64
+  (void)_xsaves64(tmp_vp, tmp_ULLi); 
+
+// XSAVES: call void @llvm.x86.xrstors
+  (void)_xrstors(tmp_vp, tmp_ULLi);
+  
+// XSAVES: call void @llvm.x86.xrstors64
+  (void)_xrstors64(tmp_vp, tmp_ULLi);
+#endif
+
+#ifdef TEST_XGETBV
+// XGETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4
+// XGETBV: call i64 @llvm.x86.xgetbv(i32 [[tmp_Ui]])
+  tmp_ULLi = __builtin_ia32_xgetbv(tmp_Ui);
+  
+// XGETBV: call i64 @llvm.x86.xgetbv
+  tmp_ULLi = _xgetbv(tmp_Ui);
+#endif
+
+#ifdef TEST_XSETBV
+// XSETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4
+// XSETBV: [[tmp_ULLi_3:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSET

[PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added a reviewer: zaks.anna.
NoQ added subscribers: dcoughlin, xazax.hun, a.sidorin, cfe-commits.

The `-analyze-function` option is very useful when debugging test failures, 
especially when printing or viewing exploded graphs - with this option you no 
longer need to delete or comment out other test cases.

But because this option accepts unqualified identifiers, it is hard to use this 
option in C++ tests (in which you often need to test a particular method of a 
particular class, but there's no way to specify the class, eg. D22374).

This patch changes `-analyze-function` to accept qualified names. Because 
`-analyzer-display-progress` has recently been changed to display qualified 
names, you can use `-analyzer-display-progress` to quickly lookup the exact 
name you need to put into `-analyze-function`.

Yeah, i agree it's a good idea to update the debugging tricks doc, just as soon 
as i get to it :)

https://reviews.llvm.org/D22856

Files:
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/analyzeOneFunction.m

Index: test/Analysis/analyzeOneFunction.m
===
--- test/Analysis/analyzeOneFunction.m
+++ test/Analysis/analyzeOneFunction.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyze-function="myMethodWithY:withX:" 
-analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyze-function="Test1::myMethodWithY:withX:" 
-analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -569,14 +569,8 @@
 }
 
 static std::string getFunctionName(const Decl *D) {
-  if (const ObjCMethodDecl *ID = dyn_cast(D)) {
-return ID->getSelector().getAsString();
-  }
-  if (const FunctionDecl *ND = dyn_cast(D)) {
-IdentifierInfo *II = ND->getIdentifier();
-if (II)
-  return II->getName();
-  }
+  if (const NamedDecl *ND = dyn_cast(D))
+return ND->getQualifiedNameAsString();
   return "";
 }
 


Index: test/Analysis/analyzeOneFunction.m
===
--- test/Analysis/analyzeOneFunction.m
+++ test/Analysis/analyzeOneFunction.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyze-function="myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyze-function="Test1::myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -569,14 +569,8 @@
 }
 
 static std::string getFunctionName(const Decl *D) {
-  if (const ObjCMethodDecl *ID = dyn_cast(D)) {
-return ID->getSelector().getAsString();
-  }
-  if (const FunctionDecl *ND = dyn_cast(D)) {
-IdentifierInfo *II = ND->getIdentifier();
-if (II)
-  return II->getName();
-  }
+  if (const NamedDecl *ND = dyn_cast(D))
+return ND->getQualifiedNameAsString();
   return "";
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21749: Changes related to new implementation of tooling::Replacements as class.

2016-07-27 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 65712.
ioeric added a comment.

- Minor cleanup/


https://reviews.llvm.org/D21749

Files:
  
clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  include-fixer/IncludeFixer.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  tool-template/ToolTemplate.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -119,7 +119,14 @@
   DiagConsumer.finish();
   tooling::Replacements Fixes;
   for (const ClangTidyError &Error : Context.getErrors())
-Fixes.insert(Error.Fix.begin(), Error.Fix.end());
+for (const auto &Fix : Error.Fix) {
+  auto Err = Fixes.add(Fix);
+  // FIXME: better error handling. Keep the behavior for now.
+  if (Err) {
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+return "";
+  }
+}
   if (Errors)
 *Errors = Context.getErrors();
   auto Result = tooling::applyAllReplacements(Code, Fixes);
Index: tool-template/ToolTemplate.cpp
===
--- tool-template/ToolTemplate.cpp
+++ tool-template/ToolTemplate.cpp
@@ -53,18 +53,20 @@
 
 namespace {
 class ToolTemplateCallback : public MatchFinder::MatchCallback {
- public:
-  ToolTemplateCallback(Replacements *Replace) : Replace(Replace) {}
+public:
+  ToolTemplateCallback(std::map *Replace)
+  : Replace(Replace) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-// TODO: This routine will get called for each thing that the matchers find.
+// TODO: This routine will get called for each thing that the matchers
+// find.
 // At this point, you can examine the match, and do whatever you want,
 // including replacing the matched text with other text
 (void)Replace; // This to prevent an "unused member variable" warning;
   }
 
- private:
-  Replacements *Replace;
+private:
+  std::map *Replace;
 };
 } // end anonymous namespace
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -350,8 +350,8 @@
   }
 
   if (!Quiet)
-errs() << "Added #include " << Context.getHeaderInfos().front().Header
-   << '\n';
+llvm::errs() << "Added #include " << Context.getHeaderInfos().front().Header
+ << "\n";
 
   // Set up a new source manager for applying the resulting replacements.
   IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions);
Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -352,23 +352,36 @@
   std::string IncludeName =
   "#include " + Context.getHeaderInfos().front().Header + "\n";
   // Create replacements for the new header.
-  clang::tooling::Replacements Insertions = {
-  tooling::Replacement(FilePath, UINT_MAX, 0, IncludeName)};
+  clang::tooling::Replacements Insertions;
+  auto Err =
+  Insertions.add(tooling::Replacement(FilePath, UINT_MAX, 0, IncludeName));
+  if (Err)
+return std::move(Err);
 
   auto CleanReplaces = cleanupAroundReplacements(Code, Insertions, Style);
   if (!CleanReplaces)
 return CleanReplaces;
 
+  auto Replaces = std::move(*CleanReplaces);
   if (AddQualifiers) {
 for (const auto &Info : Context.getQuerySymbolInfos()) {
   // Ignore the empty range.
-  if (Info.Range.getLength() > 0)
-CleanReplaces->insert({FilePath, Info.Range.getOffset(),
-   Info.Range.getLength(),
-   Context.getHeaderInfos().front().QualifiedName});
+  if (Info.Range.getLength() > 0) {
+auto R = tooling::Replacement(
+{FilePath, Info.Range.getOffset(), Info.Range.getLength(),
+ Context.getHeaderInfos().front().QualifiedName});
+auto Err = Replaces.add(R);
+if (Err) {
+  llvm::consumeError(std::move(Err));
+  R = tooling::Replacement(
+  R.getFilePath(), Replaces.getShiftedCodePosition(R.getOffset()),
+  R.getLength(), R.getReplacementText());
+  Replaces = Replaces.merge(tooling::Replacements(R));
+}
+  }
 }
   }
-  return formatReplacements(Code, *CleanReplaces, Style);
+  return formatReplacements(Code, Replaces, Style);
 }
 
 } // namespace include_fixer
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
==

Re: [PATCH] D21749: Changes related to new implementation of tooling::Replacements as class.

2016-07-27 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/D21749



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: vmiklos.
vmiklos added a comment.

`:help leader` explains it. Or see this link: 
http://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader. The 
later describes 3 arguments for using `` instead of `,` directly.


https://reviews.llvm.org/D22854



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 65714.
omtcyfz added a comment.

add refernce to what `` is


https://reviews.llvm.org/D22854

Files:
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  docs/include-fixer.rst
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see 
http://clang.llvm.org/extra/include-fixer.html
 #
Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -60,10 +60,14 @@
 
 .. code-block:: console
 
-  map ,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.
+  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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
 
 Make sure vim can find :program:`clang-include-fixer`:
 
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -92,8 +92,11 @@
 `clang-rename/tool/clang-rename.py
 
`_.
 
-Once installed, you can point your cursor to the symbols you want to rename,
-press `,cr` and print new desired name.
-
 Please note that **you have to save all buffers, in which the replacement will
 happen before running the tool**.
+
+Once installed, you can point your cursor to the 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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
Index: clang-rename/tool/clang-rename.py
===
--- clang-rename/tool/clang-rename.py
+++ clang-rename/tool/clang-rename.py
@@ -9,13 +9,13 @@
 
 To install, simply put this into your ~/.vimrc
 
-map ,cr :pyf /clang-rename.py
+noremap cr :pyf /clang-rename.py
 
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be prompted for a new name 
if
-the cursor points to a valid symbol.
+you would like to rename and press 'cr'. You will be prompted for a new
+name if the cursor points to a valid symbol.
 '''
 
 import vim


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
 #
Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -60,10 +60,14 @@
 
 .. code-block:: console
 
-  map ,cf :pyf path/to/llvm/source/tools/clang

Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

In https://reviews.llvm.org/D22854#497496, @vmiklos wrote:

> `:help leader` explains it. Or see this link: 
> http://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader. The 
> later describes 3 arguments for using `` instead of `,` directly.


I think the point was to put that into documentation :)


https://reviews.llvm.org/D22854



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


[PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo created this revision.
mstorsjo added a subscriber: cfe-commits.
Herald added subscribers: samparker, rengolin, aemerson.

This test uses an immediate constant, which was previously broken in inline 
assembly, prior to LLVM r276859.


https://reviews.llvm.org/D22857

Files:
  test/CodeGen/arm-inline-asm-windows.c

Index: test/CodeGen/arm-inline-asm-windows.c
===
--- /dev/null
+++ test/CodeGen/arm-inline-asm-windows.c
@@ -0,0 +1,8 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target armv7-windows -c -o - %s
+
+int t1 (void) {
+  int var;
+  asm("mov %0, #42" : "=r"(var));
+  return var;
+}


Index: test/CodeGen/arm-inline-asm-windows.c
===
--- /dev/null
+++ test/CodeGen/arm-inline-asm-windows.c
@@ -0,0 +1,8 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target armv7-windows -c -o - %s
+
+int t1 (void) {
+  int var;
+  asm("mov %0, #42" : "=r"(var));
+  return var;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22855: [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a reviewer: rengolin.
rengolin added a comment.
This revision is now accepted and ready to land.

LGTM. I'll add the test to LLVM as a separate commit.



Comment at: lib/Driver/ToolChain.cpp:499
@@ -498,1 +498,3 @@
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
+ getTriple().isOSWindows()) {
   if (IsBigEndian)

This makes sense to me.


Comment at: test/Driver/thumb-attributes.s:1
@@ +1,2 @@
+@ RUN: %clang -target armv7-windows-itanium -c -o - %s \
+@ RUN:   | llvm-readobj -s - | FileCheck %s

But we don't usually do asm tests in Clang. I can add this test to LLVM's MC 
dir.


https://reviews.llvm.org/D22855



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


Re: [PATCH] D22374: [analyzer] Copy and move constructors - ExprEngine extended for "almost trivial" copy and move constructors

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

I see what's going on.

`performTrivialCopy()` already calls `evalBind()`, which in turn calls 
`runCheckersForBind()`, so no effort is needed there.

However, the bind event itself is now different - instead of a separate event 
for every bind, you're having only one event for binding the 
`nonloc::LazyCompoundVal`.

For example, in testNonPODWrapper (which calls the test on line 177), you used 
to have one bind of an `UndefinedVal` into `w2.p.x` (which produced the 
warning) and one bind of `1 S32b` into `w2.p.y`, which didn't produce the 
warning. But now you're having just one bind event of 
`lazyCompoundVal{0x7fb5b80ef3b8,w}` into `w2`. By unpacking the compound 
value's store, you could see that `w.p.y` in it contains an undefined value 
(though you wouldn't see it in the store's dump directly, the `StoreManager` 
would produce one for you when you ask for it).

At a glance, this might be worth fixing on the checker's side. Essentially, 
that might still be a problem when truly-trivial (as opposed to almost-trivial) 
copies are performed, so i guess the checker might need fixing regardless.

Dropping such warnings is also a viable option. We can think of this warning as 
false, because perhaps the purpose of this code was to ensure that at least 
`w2.p.y` is initialized.

But if `w` was completely unitialized (that is, LCV contained only 
uninitialized values in its store in the cluster defined by its parent region), 
then the warning should be useful. So i'm also having this feature request for 
all Undefined* checkers - perhaps not only consider straightforward undefined 
values, but also passing uninitialized structures by value or by const 
pointer/reference?


https://reviews.llvm.org/D22374



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


Re: [PATCH] D22855: [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo added inline comments.


Comment at: test/Driver/thumb-attributes.s:1
@@ +1,2 @@
+@ RUN: %clang -target armv7-windows-itanium -c -o - %s \
+@ RUN:   | llvm-readobj -s - | FileCheck %s

rengolin wrote:
> But we don't usually do asm tests in Clang. I can add this test to LLVM's MC 
> dir.
Do tests there also use the clang frontend driver? If you change it to test 
with llvm-mc with a thumb triplet, you won't actually test anything of this.

(Also, as long as this test uses clang, should it perhaps need a "// REQUIRES: 
arm-registered-target" at the start? I had that included in the other clang 
test, which was based on other old tests, while this one was changed from 
llvm-mc to clang.)


https://reviews.llvm.org/D22855



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


Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-07-27 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

It likely is sufficient.  The code in Targets.cpp adds checking for 
"long-calls" feature in hasFeature, but it's not explicitly used anywhere.  The 
rest of the changes are mostly to clean up the handling of feature strings.


Repository:
  rL LLVM

https://reviews.llvm.org/D22766



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


[clang-tools-extra] r276861 - [clang-tidy] Add cppcoreguidelines-slicing entry to list.rst.

2016-07-27 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jul 27 08:11:50 2016
New Revision: 276861

URL: http://llvm.org/viewvc/llvm-project?rev=276861&view=rev
Log:
[clang-tidy] Add cppcoreguidelines-slicing entry to list.rst.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=276861&r1=276860&r2=276861&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Wed Jul 27 08:11:50 
2016
@@ -29,6 +29,7 @@ Clang-Tidy Checks
cppcoreguidelines-pro-type-static-cast-downcast
cppcoreguidelines-pro-type-union-access
cppcoreguidelines-pro-type-vararg
+   cppcoreguidelines-slicing
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace


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


Re: [PATCH] D22855: [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: test/Driver/thumb-attributes.s:1
@@ +1,2 @@
+@ RUN: %clang -target armv7-windows-itanium -c -o - %s \
+@ RUN:   | llvm-readobj -s - | FileCheck %s

mstorsjo wrote:
> rengolin wrote:
> > But we don't usually do asm tests in Clang. I can add this test to LLVM's 
> > MC dir.
> Do tests there also use the clang frontend driver? If you change it to test 
> with llvm-mc with a thumb triplet, you won't actually test anything of this.
> 
> (Also, as long as this test uses clang, should it perhaps need a "// 
> REQUIRES: arm-registered-target" at the start? I had that included in the 
> other clang test, which was based on other old tests, while this one was 
> changed from llvm-mc to clang.)
> If you change it to test with llvm-mc with a thumb triplet, you won't 
> actually test anything of this.

That's a good point, actually. A better test for this one thing would be to 
make sure that whatever C file would generate an IR with a triple that is 
actually "thumb".


https://reviews.llvm.org/D22855



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


[clang-tools-extra] r276862 - [include-fixer] Update document.

2016-07-27 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jul 27 08:17:16 2016
New Revision: 276862

URL: http://llvm.org/viewvc/llvm-project?rev=276862&view=rev
Log:
[include-fixer] Update document.

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

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=276862&r1=276861&r2=276862&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Wed Jul 27 08:17:16 2016
@@ -10,6 +10,10 @@ management of ``#include`` directives in
 an automated way of adding ``#include`` directives for missing symbols in one
 translation unit.
 
+While inserting missing ``#include``, :program:`clang-include-fixer` adds
+missing namespace qualifiers to all instances of an unidentified symbol if
+the symbol is missing some prefix namespace qualifiers.
+
 Setup
 =
 
@@ -31,7 +35,7 @@ so only implementation files can be hand
 .. _How To Setup Tooling For LLVM: 
http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
 Creating a Symbol Index From a Compilation Database
---
+---
 
 The include fixer contains :program:`find-all-symbols`, a tool to create a
 symbol database in YAML format from a compilation database by parsing all
@@ -54,7 +58,7 @@ database for LLVM, any project built by
 Added #include "foo.h"
 
 Integrate with Vim

+--
 To run `clang-include-fixer` on a potentially unsaved buffer in Vim. Add the
 following key binding to your ``.vimrc``:
 


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


Re: [PATCH] D22855: [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo updated this revision to Diff 65725.
mstorsjo added a comment.

Updated the test to only check what triplet is passed to the assembler


https://reviews.llvm.org/D22855

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/windows-thumb.s

Index: test/Driver/windows-thumb.s
===
--- /dev/null
+++ test/Driver/windows-thumb.s
@@ -0,0 +1,2 @@
+; RUN: %clang -target armv7-windows -c -### %s 2>&1 | FileCheck %s
+; CHECK: "-triple" "thumbv7-
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -493,8 +493,10 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
+// Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
+ getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else


Index: test/Driver/windows-thumb.s
===
--- /dev/null
+++ test/Driver/windows-thumb.s
@@ -0,0 +1,2 @@
+; RUN: %clang -target armv7-windows -c -### %s 2>&1 | FileCheck %s
+; CHECK: "-triple" "thumbv7-
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -493,8 +493,10 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
+// Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
+ getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Answering myself: Hmm, so the only reason why MPI checker class appears in 
doxygen 
(http://clang.llvm.org/doxygen/classclang_1_1ento_1_1mpi_1_1MPIChecker.html) is 
because this class is not in anonymous namespace (as far as i understand, they 
needed to be multi-file for some reason). CheckerDocumentation says that every 
checker must be wrapped in anonymous namespace, except 
CheckerDocumentationChecker :)

I don’t really see a good reason for the library functions checker to be moved 
out of anonymous namespace or deserve a doxygen page - after all, it’s all in 
one file, and the docs are right in front of the reader’s eyes anyway. But 
maybe if this checker expands enough, we could expose its data structures into 
public use, and then they'd be worth documenting :)


https://reviews.llvm.org/D20811



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


[clang-tools-extra] r276866 - [clang-rename] skip CXXConversionDecl while searching for NamedDecl

2016-07-27 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Wed Jul 27 08:37:22 2016
New Revision: 276866

URL: http://llvm.org/viewvc/llvm-project?rev=276866&view=rev
Log:
[clang-rename] skip CXXConversionDecl while searching for NamedDecl

Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.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=276866&r1=276865&r2=276866&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Wed Jul 27 08:37:22 2016
@@ -52,8 +52,8 @@ public:
   // checking if the point lies within the length of the name of the 
declaration
   // and the start location is sufficient.
   bool VisitNamedDecl(const NamedDecl *Decl) {
-return setResult(Decl, Decl->getLocation(),
- Decl->getNameAsString().length());
+return dyn_cast(Decl) ? true :
+setResult(Decl, Decl->getLocation(), Decl->getNameAsString().length());
   }
 
   // Expression visitors:

Modified: clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp?rev=276866&r1=276865&r2=276866&view=diff
==
--- clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp Wed Jul 
27 08:37:22 2016
@@ -1,12 +1,10 @@
-// Currently unsupported test.
-// RUN: cat %s > %t.cpp
-// FIXME: clang-rename should handle conversions from a class type to another
-// type.
+// RUN: clang-rename -offset=143 -new-name=Bar %s -- | FileCheck %s
 
 class Foo {}; // CHECK: class Bar {};
 
-class Baz {   // CHECK: class Bar {
+class Baz {
   operator Foo() const {  // CHECK: operator Bar() const {
+// offset  ^
 Foo foo;  // CHECK: Bar foo;
 return foo;
   }


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


[PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-07-27 Thread Anton Yartsev via cfe-commits
ayartsev created this revision.
ayartsev added reviewers: zaks.anna, krememek.
ayartsev added a subscriber: cfe-commits.

The attached patch eliminates unneeded checker data propagation from one of the 
operands of a logical operation to the operation result. The result of a 
logical operation is calculated from the logical values of its operands and is 
independent from operands nature.

One of the test changed its result (misc-ps-region-store.m, rdar_7275774). I 
did not manage to understand the test, something is definitely wrong with it - 
at least the comment inside the test do not correspond to reality and an old 
test result seem to be wrong.

The patch fixes https://llvm.org/bugs/show_bug.cgi?id=15623.

Please review!

https://reviews.llvm.org/D22862

Files:
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Analysis/misc-ps-region-store.m
  test/Analysis/unwanted-programstate-data-propagation.c

Index: test/Analysis/unwanted-programstate-data-propagation.c
===
--- test/Analysis/unwanted-programstate-data-propagation.c
+++ test/Analysis/unwanted-programstate-data-propagation.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s
+// expected-no-diagnostics
+
+// test for PR15623
+#include "Inputs/system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+_Bool test1(void) {
+   char *param = malloc(10);
+   char *value = malloc(10);
+   _Bool ok = (param && value);
+   free(param);
+   free(value);
+   // Previously we ended up with 'Use of memory after it is freed' on return.
+   // This happened due to incorrect processing of logical AND at line
+   // '_Bool ok = (param && value);'. The ProgramState data attached to the
+   // pointers memory region by the unix.Malloc checker was propogated to the
+   // 'ok' variable by mistake.
+   return ok; // no warning
+}
Index: test/Analysis/misc-ps-region-store.m
===
--- test/Analysis/misc-ps-region-store.m
+++ test/Analysis/misc-ps-region-store.m
@@ -323,14 +323,15 @@
 void rdar_7275774(void *data, unsigned n) {
   if (!(data || n == 0))
 return;
-  
+
+  // 'data' == null, n > 0
   unsigned short *p = (unsigned short*) data;
   unsigned short *q = p + (n / 2);
 
   if (p < q) {
 // If we reach here, 'p' cannot be null.  If 'p' is null, then 'n' must
 // be '0', meaning that this branch is not feasible.
-*p = *q; // no-warning
+*p = *q; // expected-warning{{Dereference of null pointer (loaded from 
variable 'p')}}
   }
 }
 
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -602,8 +602,7 @@
   if (StTrue) {
 if (StFalse) {
   // We can't constrain the value to 0 or 1.
-  // The best we can do is a cast.
-  X = getSValBuilder().evalCast(RHSVal, B->getType(), RHS->getType());
+  X = UnknownVal();
 } else {
   // The value is known to be true.
   X = getSValBuilder().makeIntVal(1, B->getType());


Index: test/Analysis/unwanted-programstate-data-propagation.c
===
--- test/Analysis/unwanted-programstate-data-propagation.c
+++ test/Analysis/unwanted-programstate-data-propagation.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s
+// expected-no-diagnostics
+
+// test for PR15623
+#include "Inputs/system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+_Bool test1(void) {
+   char *param = malloc(10);
+   char *value = malloc(10);
+   _Bool ok = (param && value);
+   free(param);
+   free(value);
+   // Previously we ended up with 'Use of memory after it is freed' on return.
+   // This happened due to incorrect processing of logical AND at line
+   // '_Bool ok = (param && value);'. The ProgramState data attached to the
+   // pointers memory region by the unix.Malloc checker was propogated to the
+   // 'ok' variable by mistake.
+   return ok; // no warning
+}
Index: test/Analysis/misc-ps-region-store.m
===
--- test/Analysis/misc-ps-region-store.m
+++ test/Analysis/misc-ps-region-store.m
@@ -323,14 +323,15 @@
 void rdar_7275774(void *data, unsigned n) {
   if (!(data || n == 0))
 return;
-  
+
+  // 'data' == null, n > 0
   unsigned short *p = (unsigned short*) data;
   unsigned short *q = p + (n / 2);
 
   if (p < q) {
 // If we reach here, 'p' cannot be null.  If 'p' is null, then 'n' must
 // be '0', meaning that this branch is not feasible.
-*p = *q; // no-warning
+*p = *q; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
   }

Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Any other comments?


https://reviews.llvm.org/D22854



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: docs/clang-rename.rst:98
@@ +97,3 @@
+
+Once installed, you can point your cursor to the symbols you want to rename,
+press ``cr`` and print new desired name. The

s/the symbols/symbols/


Comment at: docs/clang-rename.rst:101
@@ +100,3 @@
+[`` 
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 
binded
+to backslash by default.

s/a reference to //

sounds redundant..


Comment at: docs/include-fixer.rst:69
@@ +68,3 @@
+[`` 
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 
binded
+to backslash by default.

s/a reference to //


https://reviews.llvm.org/D22854



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: docs/clang-rename.rst:101
@@ +100,3 @@
+[`` 
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 
binded
+to backslash by default.

ioeric wrote:
> s/a reference to //
> 
> sounds redundant..
Why does it?

Key is a key; key can't be assigned to anything. Reference can be changed to 
any other key.


https://reviews.llvm.org/D22854



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 65739.
omtcyfz marked an inline comment as done.

https://reviews.llvm.org/D22854

Files:
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  docs/include-fixer.rst
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see 
http://clang.llvm.org/extra/include-fixer.html
 #
Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -64,10 +64,14 @@
 
 .. code-block:: console
 
-  map ,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.
+  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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
 
 Make sure vim can find :program:`clang-include-fixer`:
 
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -92,8 +92,11 @@
 `clang-rename/tool/clang-rename.py
 
`_.
 
-Once installed, you can point your cursor to the symbols you want to rename,
-press `,cr` and print new desired name.
-
 Please note that **you have to save all buffers, in which the replacement will
 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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
Index: clang-rename/tool/clang-rename.py
===
--- clang-rename/tool/clang-rename.py
+++ clang-rename/tool/clang-rename.py
@@ -9,13 +9,13 @@
 
 To install, simply put this into your ~/.vimrc
 
-map ,cr :pyf /clang-rename.py
+noremap cr :pyf /clang-rename.py
 
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be prompted for a new name 
if
-the cursor points to a valid symbol.
+you would like to rename and press 'cr'. You will be prompted for a new
+name if the cursor points to a valid symbol.
 '''
 
 import vim


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
 #
Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -64,10 +64,14 @@
 
 .. code-block:: console
 
-  map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/inc

r276869 - [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Wed Jul 27 09:12:20 2016
New Revision: 276869

URL: http://llvm.org/viewvc/llvm-project?rev=276869&view=rev
Log:
[ARM] Pass thumb as architecture to the underlying tools, when targeting windows

This makes sure that the thumb section flag gets set by the assembler.

Patch by Martin Storsjö.

Added:
cfe/trunk/test/Driver/windows-thumb.s
Modified:
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=276869&r1=276868&r2=276869&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Jul 27 09:12:20 2016
@@ -493,8 +493,10 @@ std::string ToolChain::ComputeLLVMTriple
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
+// Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
+ getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else

Added: cfe/trunk/test/Driver/windows-thumb.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-thumb.s?rev=276869&view=auto
==
--- cfe/trunk/test/Driver/windows-thumb.s (added)
+++ cfe/trunk/test/Driver/windows-thumb.s Wed Jul 27 09:12:20 2016
@@ -0,0 +1,2 @@
+; RUN: %clang -target armv7-windows -c -### %s 2>&1 | FileCheck %s
+; CHECK: "-triple" "thumbv7-


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


Re: [PATCH] D22855: [ARM] Pass thumb as architecture to the underlying tools, when targeting windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin closed this revision.
rengolin added a comment.

Committed as r276869.


https://reviews.llvm.org/D22855



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm



Comment at: docs/clang-rename.rst:101
@@ +100,3 @@
+[`` 
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 
binded
+to backslash by default.

Didn't see it was " key"... thought it was just "". 

nvm, not important :)


https://reviews.llvm.org/D22854



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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/include-fixer.rst:73
@@ +72,3 @@
+[`` 
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 
binded
+to backslash by default.

s/binded/bound/
Same elsewhere.


https://reviews.llvm.org/D22854



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


[clang-tools-extra] r276870 - change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Wed Jul 27 09:23:47 2016
New Revision: 276870

URL: http://llvm.org/viewvc/llvm-project?rev=276870&view=rev
Log:
change Vim key binding for include-fixer and clang-rename

Change Vim key binding for include-fixer (`,cf` -> `cf`) and
clang-rename (`,cr` -> `cr`) to use `` instead of `,` like
cool Vim people (tm) do.

Reviewers: ioeric

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


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

Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.py?rev=276870&r1=276869&r2=276870&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py Wed Jul 27 
09:23:47 2016
@@ -9,13 +9,13 @@ Before installing make sure one of the f
 
 To install, simply put this into your ~/.vimrc
 
-map ,cr :pyf /clang-rename.py
+noremap cr :pyf /clang-rename.py
 
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be prompted for a new name 
if
-the cursor points to a valid symbol.
+you would like to rename and press 'cr'. You will be prompted for a new
+name if the cursor points to a valid symbol.
 '''
 
 import vim

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=276870&r1=276869&r2=276870&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Wed Jul 27 09:23:47 2016
@@ -92,8 +92,11 @@ You can call :program:`clang-rename` dir
 `clang-rename/tool/clang-rename.py
 
`_.
 
-Once installed, you can point your cursor to the symbols you want to rename,
-press `,cr` and print new desired name.
-
 Please note that **you have to save all buffers, in which the replacement will
 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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+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=276870&r1=276869&r2=276870&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Wed Jul 27 09:23:47 2016
@@ -64,10 +64,14 @@ following key binding to your ``.vimrc``
 
 .. code-block:: console
 
-  map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+  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.
+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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
 
 Make sure vim can find :program:`clang-include-fixer`:
 

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py?rev=276870&r1=276869&r2=276870&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py Wed Jul 
27 09:23:47 2016
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   noremap cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
 #
-# This enables clang-include-fi

Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: docs/clang-rename.rst:101
@@ +100,3 @@
+[`` 
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 
binded
+to backslash by default.

ioeric wrote:
> Didn't see it was " key"... thought it was just "". 
> 
> nvm, not important :)
Okay, thank you :)


https://reviews.llvm.org/D22854



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


[clang-tools-extra] r276871 - fix typo in clang-rename and clang-tidy docs

2016-07-27 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Wed Jul 27 09:26:03 2016
New Revision: 276871

URL: http://llvm.org/viewvc/llvm-project?rev=276871&view=rev
Log:
fix typo in clang-rename and clang-tidy docs

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=276871&r1=276870&r2=276871&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Wed Jul 27 09:26:03 2016
@@ -98,5 +98,5 @@ 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)
-is a reference to a specific key defined by the mapleader variable and is 
binded
+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=276871&r1=276870&r2=276871&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Wed Jul 27 09:26:03 2016
@@ -70,7 +70,7 @@ This enables `clang-include-fixer` for N
 ``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)
-is a reference to a specific key defined by the mapleader variable and is 
binded
+is a reference to a specific key defined by the mapleader variable and is bound
 to backslash by default.
 
 Make sure vim can find :program:`clang-include-fixer`:


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


Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276870: change Vim key binding for include-fixer and 
clang-rename (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D22854?vs=65739&id=65741#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22854

Files:
  clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
  clang-tools-extra/trunk/docs/clang-rename.rst
  clang-tools-extra/trunk/docs/include-fixer.rst
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py

Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
@@ -9,13 +9,13 @@
 
 To install, simply put this into your ~/.vimrc
 
-map ,cr :pyf /clang-rename.py
+noremap cr :pyf /clang-rename.py
 
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be prompted for a new name 
if
-the cursor points to a valid symbol.
+you would like to rename and press 'cr'. You will be prompted for a new
+name if the cursor points to a valid symbol.
 '''
 
 import vim
Index: clang-tools-extra/trunk/docs/include-fixer.rst
===
--- clang-tools-extra/trunk/docs/include-fixer.rst
+++ clang-tools-extra/trunk/docs/include-fixer.rst
@@ -64,10 +64,14 @@
 
 .. code-block:: console
 
-  map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+  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.
+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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
 
 Make sure vim can find :program:`clang-include-fixer`:
 
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
@@ -92,8 +92,11 @@
 `clang-rename/tool/clang-rename.py
 
`_.
 
-Once installed, you can point your cursor to the symbols you want to rename,
-press `,cr` and print new desired name.
-
 Please note that **you have to save all buffers, in which the replacement will
 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)
+is a reference to a specific key defined by the mapleader variable and is 
binded
+to backslash by default.
Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
@@ -2,10 +2,10 @@
 # - Change 'binary' if clang-include-fixer is not on the path (see below).
 # - Add to your .vimrc:
 #
-#   map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#   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.
+# 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.
 #
 # To set up clang-include-fixer, see 
http://clang.llvm.org/extra/include-fixer.html
 #


Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
@@ -9,13 +9,13 @@
 
 To install, simply put this into your ~/.vimrc
 
-map ,cr :pyf /clang-rename.py
+noremap cr :pyf /clang-rename.py
 
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be prompte

Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
On Wed, Jul 27, 2016 at 5:53 AM, Martin Storsjö 
wrote:

> mstorsjo created this revision.
> mstorsjo added a subscriber: cfe-commits.
> Herald added subscribers: samparker, rengolin, aemerson.
>
> This test uses an immediate constant, which was previously broken in
> inline assembly, prior to LLVM r276859.
>
>
> https://reviews.llvm.org/D22857
>
> Files:
>   test/CodeGen/arm-inline-asm-windows.c
>
> Index: test/CodeGen/arm-inline-asm-windows.c
> ===
> --- /dev/null
> +++ test/CodeGen/arm-inline-asm-windows.c
> @@ -0,0 +1,8 @@
> +// REQUIRES: arm-registered-target
> +// RUN: %clang -target armv7-windows -c -o - %s
> +
> +int t1 (void) {
> +  int var;
> +  asm("mov %0, #42" : "=r"(var));
>

Please use the portable spelling `__asm__`.


> +  return var;
> +}
>
>
How about a test for MS asm blocks?


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


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a subscriber: compnerd.
rengolin added a comment.

I'll just echo @compnerd comments, since Phab didn't get it.

- Change the syntax to __asm__, to be more portable
- Add Microsoft asm block syntax

cheers,
--renato


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin requested changes to this revision.
This revision now requires changes to proceed.


Comment at: test/CodeGen/arm-inline-asm-windows.c:2
@@ +1,3 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target armv7-windows -c -o - %s
+

Also, I just noticed, this outputs the binary to stdout. Maybe better 

-o /dev/null

or whatever is the practice on Windows that also work on Linux. :)


https://reviews.llvm.org/D22857



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


Re: [llvm-dev] [PATCH] Add support for the 'unless' matcher in the dynamic layer.

2016-07-27 Thread Piotr Padlewski via cfe-commits
Is, but it is still a lot of typing and we are talking about debuging.

2016-07-27 3:40 GMT-07:00 Manuel Klimek :

> On Wed, Jul 27, 2016 at 1:06 AM Piotr Padlewski via llvm-dev <
> llvm-...@lists.llvm.org> wrote:
>
>> We could also just add nothing() matcher, so debugging would be much
>> easier, just add anything() or nothing() matcher as extra argument.
>>
>> The other pros of it is that new developers won't send the patches that
>> uses those variadic matchers with only one argument.
>>
>
> We already have anything() and unless(anything()).
>
>
>>
>> 2016-07-26 16:02 GMT-07:00 Zac Hansen via llvm-dev <
>> llvm-...@lists.llvm.org>:
>>
>>> Even if it still did add overhead, it seems perfectly reasonable, from a
>>> user's perspective (namely mine), that if I introduce unnecessary narrowing
>>> matchers to my chain that there may be a performance penalty.
>>>
>>> The ability to do the following easily outweighs any performance issues
>>> for me:
>>>
>>>
>>> anyOf (
>>> /*hasName("..."), */
>>> hasName("...")
>>>
>>> )
>>>
>>> though C++ not allowing trailing commas makes this not quite as great.
>>>
>>>
>>> *However, without help, I would not be able to put forward a patch with
>>> anything more than simply removing the minimums.*
>>>
>>> Would this be acceptable or would someone be able to point me at what it
>>> would take to do it the "smart way" in less time than it would take them to
>>> make the change themselves?
>>>
>>> On Tue, Jul 26, 2016 at 3:29 PM, Samuel Benzaquen 
>>> wrote:
>>>
 One of the reasons we added the minimum was because these nodes added
 overhead to the matching that was not unnecessary when they only had a
 single node.
 On the current implementation we could actually get rid of the node
 completely for the one argument calls.
 I would be ok with removing the lower bound.


 On Tue, Jul 26, 2016 at 6:20 PM, Zac Hansen  wrote:

> I was wondering if there is any objection to removing the 2-element
> minimum on the eachOf, anyOf and allOf matchers.
>
> It is frustrating when playing with matchers to have to edit
> significant amounts of code to be able to temporarily go from 2 to 1
> matcher inside an any- or allOf matcher.
>
> And overall it feels very "un-set-theory"-like.
>
> The change was made here:
> https://github.com/llvm-mirror/clang/commit/674e54c167eab0be7a54bca7082c07d2f1d0c8cc
>
>
> Thank you and apologies if I sent this to the wrong lists/people.
>
> --Zac
>


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


r276878 - Implement filtering for code completion of identifiers.

2016-07-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Jul 27 09:56:59 2016
New Revision: 276878

URL: http://llvm.org/viewvc/llvm-project?rev=276878&view=rev
Log:
Implement filtering for code completion of identifiers.

Patch by Cristina Cristescu and Axel Naumann!

Agreed on post commit review (D17820).

Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/test/CodeCompletion/objc-message.mm
cfe/trunk/test/Index/complete-method-decls.m
cfe/trunk/test/Index/complete-objc-message-id.m
cfe/trunk/test/Index/complete-objc-message.m
cfe/trunk/test/Index/complete-recovery.m
cfe/trunk/test/Index/complete-super.m

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=276878&r1=276877&r2=276878&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 27 09:56:59 2016
@@ -265,6 +265,10 @@ class Preprocessor : public RefCountedBa
   /// \brief True if we hit the code-completion point.
   bool CodeCompletionReached;
 
+  /// \brief The code completion token containing the information
+  /// on the stem that is to be code completed.
+  IdentifierInfo *CodeCompletionII;
+
   /// \brief The directory that the main file should be considered to occupy,
   /// if it does not correspond to a real file (as happens when building a
   /// module).
@@ -984,6 +988,18 @@ public:
   /// completion point.
   void CodeCompleteNaturalLanguage();
 
+  /// \brief Set the code completion token for filtering purposes.
+  void setCodeCompletionIdentifierInfo(IdentifierInfo *Filter) {
+CodeCompletionII = Filter;
+  }
+
+  /// \brief Get the code completion token for filtering purposes.
+  StringRef getCodeCompletionFilter() {
+if (CodeCompletionII)
+  return CodeCompletionII->getName();
+return {};
+  }
+
   /// \brief Retrieve the preprocessing record, or NULL if there is no
   /// preprocessing record.
   PreprocessingRecord *getPreprocessingRecord() const { return Record; }

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=276878&r1=276877&r2=276878&view=diff
==
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Wed Jul 27 09:56:59 2016
@@ -913,6 +913,13 @@ public:
   /// \brief Deregisters and destroys this code-completion consumer.
   virtual ~CodeCompleteConsumer();
 
+  /// \name Code-completion filtering
+  /// \brief Check if the result should be filtered out.
+  virtual bool isResultFilteredOut(StringRef Filter,
+   CodeCompletionResult Results) {
+return false;
+  }
+
   /// \name Code-completion callbacks
   //@{
   /// \brief Process the finalized code-completion results.
@@ -966,6 +973,8 @@ public:
  OverloadCandidate *Candidates,
  unsigned NumCandidates) override;
 
+  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) 
override;
+
   CodeCompletionAllocator &getAllocator() override {
 return CCTUInfo.getAllocator();
   }

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=276878&r1=276877&r2=276878&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Jul 27 09:56:59 2016
@@ -1533,7 +1533,15 @@ FinishIdentifier:
 // preprocessor, which may macro expand it or something.
 if (II->isHandleIdentifierCase())
   return PP->HandleIdentifier(Result);
-
+
+if (II->getTokenID() == tok::identifier && isCodeCompletionPoint(CurPtr)
+&& II->getPPKeywordID() == tok::pp_not_keyword
+&& II->getObjCKeywordID() == tok::objc_not_keyword) {
+  // Return the code-completion token.
+  Result.setKind(tok::code_completion);
+  cutOffLexing();
+  return true;
+}
 return true;
   }
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=276878&r1=276877&r2=276878&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Jul 27 09:56:59 2016
@@ -74,7 +74,7 @@ Preprocessor::Preprocessor(IntrusiveRefC
   IncrementalProcessing(false), TUKind(TUKind), CodeComplete(nullptr),
   CodeCompletionFile(nullptr), CodeCompletio

Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r276878.


Repository:
  rL LLVM

https://reviews.llvm.org/D17820



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


RE: r276361 - Reverting r275115 which caused PR28634.

2016-07-27 Thread Daniel Sanders via cfe-commits
Thanks for reverting this, our internal buildbots have gone green again.

> Can you add a non-regression test case?
> (It seems the test-suite didn’t catch this bug right?)

Do we have any upstream buildbots using -O0? I haven't investigated very far* 
but -O0 seems to be the common factor between our internal builders that 
failed. Also, adding -O1 to the failing command causes the compilation failure 
to disappear on MultiSource/Applications/JM/ldecod/loopFilter.c. I haven't 
tested the other failing tests yet but they were:
MultiSource/Applications/SPASS/SPASS
MultiSource/Benchmarks/Olden/bh/bh
MultiSource/Applications/viterbi/viterbi
MultiSource/Applications/sqlite3/sqlite3
MultiSource/Applications/JM/lencod/lencod
MultiSource/Applications/hbd/hbd
MultiSource/Benchmarks/MallocBench/gs/gs
MultiSource/Benchmarks/ASC_Sequoia/AMGmk/AMGmk
MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset

* We've had higher priority buildbot issues over the last couple weeks and I'm 
still tracking down a particularly unpleasant one where failing 'ninja 
check-all' somehow manages to kill all _future_ python processes as they're 
being created. I'm having to reboot the machine after each attempt at bisecting 
it.

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Mehdi Amini via cfe-commits
> Sent: 22 July 2016 01:31
> To: Wolfgang Pieb
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: r276361 - Reverting r275115 which caused PR28634.
> 
> 
> > On Jul 21, 2016, at 4:28 PM, Wolfgang Pieb via cfe-commits  comm...@lists.llvm.org> wrote:
> >
> > Author: wolfgangp
> > Date: Thu Jul 21 18:28:18 2016
> > New Revision: 276361
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276361&view=rev
> > Log:
> > Reverting r275115 which caused PR28634.
> > When empty (forwarding) basic blocks that are referenced by user labels
> > are removed, incorrect code may be generated.
> 
> Can you add a non-regression test case?
> (It seems the test-suite didn’t catch this bug right?)
> 
> Thanks,
> 
> —
> Mehdi
> 
> 
> >
> >
> > Removed:
> >cfe/trunk/test/CodeGen/forwarding-blocks-if.c
> > Modified:
> >cfe/trunk/lib/CodeGen/CGStmt.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
> > URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276361&r1=276360&r2=27
> 6361&view=diff
> >
> ==
> 
> > --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 18:28:18 2016
> > @@ -623,14 +623,7 @@ void CodeGenFunction::EmitIfStmt(const I
> > RunCleanupsScope ThenScope(*this);
> > EmitStmt(S.getThen());
> >   }
> > -  {
> > -auto CurBlock = Builder.GetInsertBlock();
> > -EmitBranch(ContBlock);
> > -// Eliminate any empty blocks that may have been created by nested
> > -// control flow statements in the 'then' clause.
> > -if (CurBlock)
> > -  SimplifyForwardingBlocks(CurBlock);
> > -  }
> > +  EmitBranch(ContBlock);
> >
> >   // Emit the 'else' code if present.
> >   if (const Stmt *Else = S.getElse()) {
> > @@ -646,12 +639,7 @@ void CodeGenFunction::EmitIfStmt(const I
> > {
> >   // There is no need to emit line number for an unconditional branch.
> >   auto NL = ApplyDebugLocation::CreateEmpty(*this);
> > -  auto CurBlock = Builder.GetInsertBlock();
> >   EmitBranch(ContBlock);
> > -  // Eliminate any empty blocks that may have been created by nested
> > -  // control flow statements emitted in the 'else' clause.
> > -  if (CurBlock)
> > -SimplifyForwardingBlocks(CurBlock);
> > }
> >   }
> >
> >
> > Removed: cfe/trunk/test/CodeGen/forwarding-blocks-if.c
> > URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/CodeGen/forwarding-blocks-
> if.c?rev=276360&view=auto
> >
> ==
> 
> > --- cfe/trunk/test/CodeGen/forwarding-blocks-if.c (original)
> > +++ cfe/trunk/test/CodeGen/forwarding-blocks-if.c (removed)
> > @@ -1,36 +0,0 @@
> > -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
> > -// Check that no empty blocks are generated for nested ifs.
> > -
> > -extern void func();
> > -
> > -int f0(int val) {
> > -  if (val == 0) {
> > -func();
> > -  } else if (val == 1) {
> > -func();
> > -  }
> > -  return 0;
> > -}
> > -
> > -// CHECK-LABEL: define {{.*}}i32 @f0
> > -// CHECK: call void {{.*}} @func
> > -// CHECK: call void {{.*}} @func
> > -// CHECK: br label %[[RETBLOCK1:[^ ]*]]
> > -// CHECK: [[RETBLOCK1]]:
> > -// CHECK-NOT: br label
> > -// CHECK: ret i32
> > -
> > -int f1(int val, int g) {
> > -  if (val == 0)
> > -if (g == 1) {
> > -  func();
> > -}
> > -  return 0;
> > -}
> > -
> > -// CHECK-LABEL: define {{.*}}i32 @f1
> > -// CHECK: call void {{.*}} @func
> > -// CHECK: br label %[

Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65747.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Remove of use of SmallVector and include CUDA args only for the regular 
toolchain.


https://reviews.llvm.org/D22518

Files:
  lib/Driver/Tools.cpp
  test/Driver/cuda-version-check.cu

Index: test/Driver/cuda-version-check.cu
===
--- test/Driver/cuda-version-check.cu
+++ test/Driver/cuda-version-check.cu
@@ -39,6 +39,15 @@
 // RUN:--no-cuda-version-check %s | \
 // RUN:FileCheck %s --check-prefix=OK
 
+// We need to make sure the version check is done only for the device toolchain,
+// therefore we should not get an error in host-only mode. We use the -S here
+// to avoid the error being produced in case by the assembler tool, which does
+// the same check.
+// RUN: %clang -v -### --cuda-gpu-arch=sm_60 --cuda-host-only --sysroot=%S/Inputs/CUDA -S 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=OK
+// RUN: %clang -v -### --cuda-gpu-arch=sm_60 --cuda-device-only --sysroot=%S/Inputs/CUDA -S 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=ERR_SM60
+
 // OK-NOT: error: GPU arch
 
 // OK_SM35-NOT: error: GPU arch sm_35
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -296,56 +296,25 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
-/// Add the C++ include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadCXXStdlibIncludeArgs(Compilation &C,
-const JobAction &JA,
-const ArgList &Args,
-ArgStringList &CmdArgs) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the C include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadClangSystemIncludeArgs(Compilation &C,
-  const JobAction &JA,
-  const ArgList &Args,
-  ArgStringList &CmdArgs) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the include args that are specific of each offloading programming model.
-static void addExtraOffloadSpecificIncludeArgs(Compilation &C,
-   const JobAction &JA,
-   const ArgList &Args,
-   ArgStringList &CmdArgs) {
-
+/// Apply \a Work on the current tool chain \a RegularToolChain and any other
+/// offloading tool chain that is associated with the current action \a JA.
+static void
+forAllAssociatedToolChains(Compilation &C, const JobAction &JA,
+   const ToolChain &RegularToolChain,
+   llvm::function_ref Work) {
+  // Apply Work on the current/regular tool chain.
+  Work(RegularToolChain);
+
+  // Apply Work on all the offloading tool chains associated with the current
+  // action.
   if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
 
-  // TODO: Add support for other programming models here.
+  //
+  // TODO: Add support for other offloading programming models here.
+  //
 }
 
 void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
@@ -622,22 +591,26 @@
   // of an offloading programming model.
 
   // Add C++ include arguments, if needed.
-  if (types::isCXX(Inputs[0].getType())) {
-getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-addExtraOffloadCXXStdlibIncludeArgs(C, JA, Args, CmdArgs);
-  }
+  if (types::isCXX(Inputs[0].getType()))
+forAllAssociatedToolChains(C, JA, getToolChain(),
+   [&Args, &CmdAr

Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Art, Richard,

Thanks for looking at this patch. I tried to address Richard concerns in the 
last diff.

Let me know your thoughts,

Thanks again,
Samuel



Comment at: lib/Driver/Tools.cpp:308-335
@@ -349,1 +307,30 @@
+Action::OffloadKind ActiveOffloadingKind = Action::OFK_None) {
+  SmallVector RelevantToolChains;
+  // Add the current tool chain to the relevant tool chain list if it is
+  // defined.
+  if (RegularToolChain)
+RelevantToolChains.push_back(RegularToolChain);
+
+  // Add all the offloading tool chains associated with the current action to
+  // the relevant tool chain list. If we don't have a specific active offload
+  // kind, consider all available, otherwise consider only the active kind.
+  if (ActiveOffloadingKind == Action::OFK_None ||
+  ActiveOffloadingKind == Action::OFK_Cuda) {
+if (JA.isHostOffloading(Action::OFK_Cuda))
+  RelevantToolChains.push_back(
+  C.getSingleOffloadToolChain());
+else if (JA.isDeviceOffloading(Action::OFK_Cuda))
+  RelevantToolChains.push_back(
+  C.getSingleOffloadToolChain());
+  }
+
+  //
+  // TODO: Add support for other offloading programming models here.
+  //
+
+  // Apply Work on all the relevant tool chains.
+  for (const auto *TC : RelevantToolChains) {
+assert(TC && "Undefined tool chain??");
+Work(TC);
+  }
 }

rsmith wrote:
> There's no point in building a `SmallVector` here, just directly call `Work` 
> when you find a toolchain that should be used.
Ok, I'm doing as you suggest.


Comment at: lib/Driver/Tools.cpp:317-318
@@ +316,4 @@
+  // kind, consider all available, otherwise consider only the active kind.
+  if (ActiveOffloadingKind == Action::OFK_None ||
+  ActiveOffloadingKind == Action::OFK_Cuda) {
+if (JA.isHostOffloading(Action::OFK_Cuda))

rsmith wrote:
> What is this `ActiveOffloadingKind` parameter for? Both values that we 
> actually pass in here do the exact same thing.
`ActiveOffloadingKind` was meant to signal the offloading model in use. Its 
true right now we only have CUDA kind. We are proposing the OpenMP kind in 
https://reviews.llvm.org/D21843 (one of the depending patches of the patch that 
inserted this modification), so the goal was to pave the way for that.

In any case, I'm removing the `ActiveOffloadingKind` check, as I am calling 
`AddCudaIncludeArgs` directly in the caller of this function. Let me know if 
you'd like to fix this in a different way.


Comment at: lib/Driver/Tools.cpp:341-346
@@ -340,8 @@
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-

rsmith wrote:
> The OFK_Host / OFK_Cuda arguments here are reversed from the other two cases. 
> Is that a bug that's fixed by this change, or a bug that's introduced by this 
> change? :)
> 
> Either way it seems that we're missing test coverage.
As per the implementation before my change, `AddCudaIncludeArgs` should be 
called on the current toolchain. The outcome of using one toolchain or the 
other is similar except that for a CUDA toolchain there is an extra check. So, 
we'd always get the check if producing commands for both toolchains except if 
compiling with host/device-only mode. I fixed the issue here and added 
regression tests for host/device only . 


https://reviews.llvm.org/D22518



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

I think it would be better for fully-qualified Objective-C methods to be 
specified with their Objective-C-style names. For example:  "-[Test1 
myMethodWithY:withX:]". This would also remove the ambiguity when there are 
class and instance methods with the same selector.

Does this approach work for C++ when there are multiple overloads of methods 
with the same name?


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

> I think it would be better for fully-qualified Objective-C methods to be 
> specified with their Objective-C-style names. For example: "-[Test1 
> myMethodWithY:withX:]".


Uhm, need to know more about those. So i just print "`-[`", then 
fully-qualified class name, then selector identifier, then "`]`"?

> Does this approach work for C++ when there are multiple overloads of methods 
> with the same name?


Nope, unfortunately not. I'm open to suggestions on how to make this work. We 
may either dump types of arguments, or do something like "`foo~1`", "`foo~2`", 
etc.


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22690: [OpenMP] Add support for mapping array sections through pointer references.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65751.
sfantao marked an inline comment as done.
sfantao added a comment.

- Use castAs instead of getAs in pointer type.


https://reviews.llvm.org/D22690

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp

Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -60,12 +60,15 @@
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK2 --check-prefix CK2-32
 #ifdef CK2
 
-// CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
-// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i[[sz]]] zeroinitializer
+// Map types: OMP_MAP_IS_PTR = 32
+// CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i32] [i32 32]
 
-// CK2-LABEL: implicit_maps_integer_reference
-void implicit_maps_integer_reference (int a){
+// CK2-LABEL: implicit_maps_reference
+void implicit_maps_reference (int a, int *b){
   int &i = a;
   // CK2-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}})
   // CK2-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
@@ -85,6 +88,25 @@
   {
++i;
   }
+
+  int *&p = b;
+  // CK2-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES2]]{{.+}}, {{.+}}[[TYPES2]]{{.+}})
+  // CK2-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
+  // CK2-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
+  // CK2-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK2-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK2-DAG: store i8* [[VALBP:%.+]], i8** [[BP1]],
+  // CK2-DAG: store i8* [[VALP:%.+]], i8** [[P1]],
+  // CK2-DAG: [[VALBP]] = bitcast i32* [[VAL:%.+]] to i8*
+  // CK2-DAG: [[VALP]] = bitcast i32* [[VAL]] to i8*
+  // CK2-DAG: [[VAL]] = load i32*, i32** [[ADDR:%.+]],
+  // CK2-DAG: [[ADDR]] = load i32**, i32*** [[ADDR2:%.+]],
+
+  // CK2: call void [[KERNEL2:@.+]](i32* [[VAL]])
+  #pragma omp target
+  {
+   ++p;
+  }
 }
 
 // CK2: define internal void [[KERNEL]](i[[sz]] [[ARG:%.+]])
@@ -99,6 +121,14 @@
 // CK2-32: [[RVAL:%.+]] = load i32*, i32** [[REF]],
 // CK2-32: {{.+}} = load i32, i32* [[RVAL]],
 
+// CK2: define internal void [[KERNEL2]](i32* [[ARG:%.+]])
+// CK2: [[ADDR:%.+]] = alloca i32*,
+// CK2: [[REF:%.+]] = alloca i32**,
+// CK2: store i32* [[ARG]], i32** [[ADDR]],
+// CK2: store i32** [[ADDR]], i32*** [[REF]],
+// CK2: [[T:%.+]] = load i32**, i32*** [[REF]],
+// CK2: [[TT:%.+]] = load i32*, i32** [[T]],
+// CK2: getelementptr inbounds i32, i32* [[TT]], i32 1
 #endif
 ///==///
 // RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-64
@@ -4471,4 +4501,67 @@
 // CK27: define {{.+}}[[CALL06]]
 // CK27: define {{.+}}[[CALL07]]
 #endif
+///==///
+// RUN: %clang_cc1 -DCK28 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK28 --check-prefix CK28-64
+// RUN: %clang_cc1 -DCK28 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-64
+// RUN: %clang_cc1 -DCK28 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-32
+// RUN: %clang_cc1 -DCK28 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-32
+#ifdef CK28
+
+// CK28: [[SIZE00:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] [i[[Z:64|32]] {{8|4}}]
+// CK28: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i32] 

Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Akira Hatanaka via cfe-commits
ahatanak added a subscriber: ahatanak.
ahatanak added a comment.

Is r276859 fixing a bug in the assembler?

I'm trying to understand why we have to add a clang test in this particular 
case because I don't think we normally add a test in clang every time we fix a 
bug in the backend or assembler.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a comment.

In https://reviews.llvm.org/D22857#497805, @ahatanak wrote:

> Is r276859 fixing a bug in the assembler?


Sort of. It was just adding a comment character to ; instead of #.

> I'm trying to understand why we have to add a clang test in this particular 
> case because I don't think we normally add a test in clang every time we fix 
> a bug in the backend or assembler.


As I read it, this is just making sure "inline asm" works on Windows, which 
apparently hasn't been working so far. In a way, unrelated to the commit in 
question.

I agree we shouldn't be adding clang tests to assembler bugs.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Jun Bum Lim via cfe-commits
junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: default label 
in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

  default: llvm_unreachable("Unknown code completion result Kind.");
  ^


Repository:
  rL LLVM

https://reviews.llvm.org/D17820



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


[PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi created this revision.
ibadawi added reviewers: majnemer, rjmccall.
ibadawi added a subscriber: cfe-commits.

This is a proposed fix for bug 16154 
(https://llvm.org/bugs/show_bug.cgi?id=16154) -- it was tentatively fixed in 
r183084 but had the fix was backed out in r183575 because the approach taken 
wrongly affected the behavior or other warnings.

https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,10 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
+
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,10 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
+
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Ping.


https://reviews.llvm.org/D22596



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


r276887 - Update cxx_dr_Status after 3.9 branch

2016-07-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 27 11:39:45 2016
New Revision: 276887

URL: http://llvm.org/viewvc/llvm-project?rev=276887&view=rev
Log:
Update cxx_dr_Status after 3.9 branch

Modified:
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=276887&r1=276886&r2=276887&view=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Jul 27 11:39:45 2016
@@ -7315,7 +7315,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1250";>1250
 CD3
 Cv-qualification of incomplete virtual function return types
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1251";>1251
@@ -9253,7 +9253,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1573";>1573
 DRWP
 Inherited constructor characteristics
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1574";>1574
@@ -9289,7 +9289,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579";>1579
 C++14
 Return by converting move constructor
-Unknown
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1580";>1580
@@ -9685,7 +9685,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1645";>1645
 DR
 Identical inheriting constructors via default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1646";>1646
@@ -10105,7 +10105,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1715";>1715
 DR
 Access and inherited constructor templates
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1716";>1716
@@ -10231,7 +10231,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1736";>1736
 DR
 Inheriting constructor templates in a local class
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1737";>1737
@@ -11461,7 +11461,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1941";>1941
 DR
 SFINAE and inherited constructor default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1942";>1942
@@ -11569,7 +11569,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1959";>1959
 DR
 Inadvertently inherited copy constructor
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1960";>1960
@@ -11761,7 +11761,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1991";>1991
 DR
 Inheriting constructors vs default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1992";>1992

Modified: cfe/trunk/www/make_cxx_dr_status
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/make_cxx_dr_status?rev=276887&r1=276886&r2=276887&view=diff
==
--- cfe/trunk/www/make_cxx_dr_status (original)
+++ cfe/trunk/www/make_cxx_dr_status Wed Jul 27 11:39:45 2016
@@ -102,10 +102,10 @@ def availability(issue):
   if status == 'unknown':
 avail = 'Unknown'
 avail_style = ' class="none"'
-  elif status == '3.9':
+  elif status == '4.0':
 avail = 'SVN'
 avail_style = ' class="svn"'
-  elif status.startswith('3.'):
+  elif re.match('^[0-9]+\.', status):
 avail = 'Clang %s' % status
 avail_style = ' class="full"'
   elif status == 'yes':


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


r276889 - Fix unnecessary default switch warning

2016-07-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jul 27 11:41:56 2016
New Revision: 276889

URL: http://llvm.org/viewvc/llvm-project?rev=276889&view=rev
Log:
Fix unnecessary default switch warning

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

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=276889&r1=276888&r2=276889&view=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Jul 27 11:41:56 2016
@@ -445,8 +445,8 @@ bool PrintingCodeCompleteConsumer::isRes
   case CodeCompletionResult::RK_Pattern: {
 return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
   }
-  default: llvm_unreachable("Unknown code completion result Kind.");
   }
+  llvm_unreachable("Unknown code completion result Kind.");
 }
 
 void 


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


Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Artem Belevich via cfe-commits
tra added a comment.

Looks good.


https://reviews.llvm.org/D22518



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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-27 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Misc/amdgcn.languageOptsOpenCL.cl:188
@@ +187,3 @@
+  #endif
+#else
+  #ifdef cl_khr_mipmap_image

Looks good! Could you just remove indentation please as it's not common for C 
macros?

The same for the test below!


Repository:
  rL LLVM

https://reviews.llvm.org/D22637



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


r276891 - UsersManual.rst: update clang-cl option list

2016-07-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 27 11:56:03 2016
New Revision: 276891

URL: http://llvm.org/viewvc/llvm-project?rev=276891&view=rev
Log:
UsersManual.rst: update clang-cl option list

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=276891&r1=276890&r2=276891&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Jul 27 11:56:03 2016
@@ -2118,16 +2118,26 @@ Execute ``clang-cl /?`` to see a list of
   /fp:fast
   /fp:precise
   /fp:strict
+  /Fp  Set pch filename (with /Yc and /Yu)
   /GAAssume thread-local variables are defined in the 
executable
+  /GdSet __cdecl as a default calling convention
   /GF-   Disable string pooling
   /GR-   Disable emission of RTTI data
   /GREnable emission of RTTI data
+  /GrSet __fastcall as a default calling convention
+  /GS-   Disable buffer security check
+  /GSEnable buffer security check
   /Gs Set stack probe size
+  /GvSet __vectorcall as a default calling convention
   /Gw-   Don't put each data item in its own section
   /GwPut each data item in its own section
+  /GX-   Enable exception handling
+  /GXEnable exception handling
   /Gy-   Don't put each function in its own section
   /GyPut each function in its own section
+  /GzSet __stdcall as a default calling convention
   /help  Display available options
+  /imsvcAdd directory to system include search path, as 
if part of %INCLUDE%
   /IAdd directory to include search path
   /J Make char type unsigned
   /LDd   Create debug DLL
@@ -2137,7 +2147,6 @@ Execute ``clang-cl /?`` to see a list of
   /MDUse DLL run-time
   /MTd   Use static debug run-time
   /MTUse static run-time
-  /Ob0   Disable inlining
   /OdDisable optimization
   /Oi-   Disable use of builtin functions
   /OiEnable use of builtin functions
@@ -2149,6 +2158,7 @@ Execute ``clang-cl /?`` to see a list of
   /Qvec- Disable the loop vectorization passes
   /Qvec  Enable the loop vectorization passes
   /showIncludes  Print info about included files to stderr
+  /std:   Language standard to compile for
   /TCTreat all source files as C
   /Tc  Specify a C source file
   /TPTreat all source files as C++
@@ -2171,6 +2181,9 @@ Execute ``clang-cl /?`` to see a list of
   /WX-   Do not treat warnings as errors
   /WXTreat warnings as errors
   /w Disable all warnings
+  /Y-Disable precompiled headers, overrides /Yc and /Yu
+  /Yc  Generate a pch file for all code up to and 
including 
+  /Yu  Load a pch file and use it instead of all code up 
to and including 
   /Z7Enable CodeView debug information in object files
   /Zc:sizedDealloc-  Disable C++14 sized global deallocation functions
   /Zc:sizedDealloc   Enable C++14 sized global deallocation functions
@@ -2179,6 +2192,7 @@ Execute ``clang-cl /?`` to see a list of
   /Zc:threadSafeInit Enable thread-safe initialization of static 
variables
   /Zc:trigraphs- Disable trigraphs (default)
   /Zc:trigraphs  Enable trigraphs
+  /ZdEmit debug line number tables only
   /ZiAlias for /Z7. Does not produce PDBs.
   /ZlDon't mention any default libraries in the object 
file
   /ZpSet the default maximum struct packing alignment 
to 1
@@ -2215,6 +2229,8 @@ Execute ``clang-cl /?`` to see a list of
   -fsanitize=  Turn on runtime checks for various forms of 
undefined or suspicious
   behavior. See user manual for available checks
   -gcodeview  Generate CodeView debug information
+  -gline-tables-only  Emit debug line number tables only
+  -miamcu Use Intel MCU ABI
   -mllvm   Additional arguments to forward to LLVM's option 
processing
   -Qunused-arguments  Don't emit warning for unused driver arguments
   -R  Enable the specified

[PATCH] D22874: [analyzer] Fixes to the checker developer manual.

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added a reviewer: zaks.anna.
NoQ added subscribers: dcoughlin, xazax.hun, a.sidorin, cfe-commits.

1. Fix the explanation of how to run tests after migration from autotools to 
cmake.

2. Expand the "debugging" section with more interesting stuff, as accidentally 
discussed in D22622 and D22856.

Any other things to fix there?

Also, does anybody think it's a good idea to mention my unofficial guide 
(https://github.com/haoNoQ/clang-analyzer-guide/releases) in the "additional 
sources" section?

https://reviews.llvm.org/D22874

Files:
  www/analyzer/checker_dev_manual.html

Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -511,75 +511,143 @@
   live in clang/test/Analysis folder. To run all of the analyzer tests, 
   execute the following from the clang build directory:
 
-$ TESTDIRS=Analysis make test
+$ bin/llvm-lit -sv ../llvm/tools/clang/test/Analysis
 
 
 Useful Commands/Debugging Hints
-
-
-While investigating a checker-related issue, instruct the analyzer to only 
+
+Attaching the debugger
+
+When your command contains the -cc1 flag, you can attach the
+debugger to it directly:
+
+
+$ gdb --args clang -cc1 -analyze -analyzer-checker=core test.c
+$ lldb -- clang -cc1 -analyze -analyzer-checker=core test.c
+
+
+
+Otherwise, if your command line contains --analyze,
+the actual clang instance would be run in a separate process. In
+order to debug it, you'd have to either instruct your debugger to attach
+itself to the child process (for example, in gcc you can
+set follow-fork-mode=child), or use the -###
+flag for obtaining the command line of the child process:
+
+
+
+$ clang --analyze test.c -\#\#\#
+
+
+
+Below we describe a few useful command line arguments, all of which assume that
+you are running clang -cc1.
+
+
+Narrowing down the problem
+
+While investigating a checker-related issue, instruct the analyzer to only
 execute a single checker:
-
-$ clang -cc1 -analyze -analyzer-checker=osx.KeychainAPI test.c
-
-
-
-To dump AST:
-
-$ clang -cc1 -ast-dump test.c
-
-
-
-To view/dump CFG use debug.ViewCFG or debug.DumpCFG checkers:
-
-$ clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.c
- 
-
-
-To see all available debug checkers:
-
-$ clang -cc1 -analyzer-checker-help | grep "debug"
-
-
-
-To see which function is failing while processing a large file use 
--analyzer-display-progress option.
-
-
-While debugging execute clang -cc1 -analyze -analyzer-checker=core 
-instead of clang --analyze, as the later would call the compiler 
-in a separate process.
-
-
-To view ExplodedGraph (the state graph explored by the analyzer) while 
-debugging, goto a frame that has clang::ento::ExprEngine object and 
-execute:
- 
-(gdb) p ViewGraph(0)
-
-
-
-To see the ProgramState while debugging use the following command. 
-
-(gdb) p State->dump()
- 
-
-
-To see clang::Expr while debugging use the following command. If you 
-pass in a SourceManager object, it will also dump the corresponding line in the 
-source code.
-
-(gdb) p E->dump()
- 
-
-
-To dump AST of a method that the current ExplodedNode belongs to:
-
-(gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump()
-(gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump(getContext().getSourceManager())
-
-
-
+
+
+$ clang -cc1 -analyze -analyzer-checker=osx.KeychainAPI test.c
+
+
+If you are experiencing a crash, to see which function is failing while
+processing a large file use the  -analyzer-display-progress
+option.
+
+You can analyze a particular function within the file, which is often useful
+because the problem is always in a certain function:
+
+$ clang -cc1 -analyze -analyzer-checker=core test.c -analyzer-display-progress
+ANALYZE (Syntax): test.c foo
+ANALYZE (Syntax): test.c bar
+ANALYZE (Path,  Inline_Regular): test.c bar
+ANALYZE (Path,  Inline_Regular): test.c foo
+$ clang -cc1 -analyze -analyzer-checker=core test.c -analyzer-display-progress -analyze-function=foo
+ANALYZE (Syntax): test.c foo
+ANALYZE (Path,  Inline_Regular): test.c foo
+
+
+Visualizing the analysis
+
+To dump the AST, which often helps understanding how the program should
+behave:
+
+$ clang -cc1 -ast-dump test.c
+
+
+To view/dump CFG use debug.ViewCFG or debug.DumpCFG
+checkers:
+
+$ clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.c
+
+
+ExplodedGraph (the state graph explored by the analyzer) can be
+visualized with another debug checker:
+
+$ clang -cc1 -analyze -analyzer-checker=debug.ViewExplodedGraph test.c
+
+Or, equivalently, with -analyzer-viz-egraph-graphviz
+option, which does the same thing - dumps the exploded graph in graphviz
+.dot format.
+
+You can convert .dot files into other formats - in
+particular, converting to .svg and viewing in your web
+browser might be more comfortable than using 

Re: [PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi updated this revision to Diff 65763.
ibadawi added a comment.

Remove extra blank line added by accident


https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi updated this revision to Diff 65765.
ibadawi added a comment.

Restore the test lost in patch #2. Really sorry for the noise...


https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: tra, cfe-commits.

Before this patch, we computed the offsets in memory of args passed to
GPU kernel functions by throwing all of the args into an LLVM struct.

clang emits packed llvm structs basically whenever it feels like it, and
packed structs have alignment 1.  So we cannot rely on the llvm type's
alignment matching the C++ type's alignment.

This patch fixes our codegen so we always respect the clang types'
alignments.

https://reviews.llvm.org/D22879

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/kernel-args-alignment.cu

Index: test/CodeGenCUDA/kernel-args-alignment.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction &CGF,
  FunctionArgList &Args) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(

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

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 12:39:47 2016
New Revision: 276896

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

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=276896&r1=276895&r2=276896&view=diff
==
--- cfe/trunk/test/Parser/ms-inline-asm.c (original)
+++ cfe/trunk/test/Parser/ms-inline-asm.c Wed Jul 27 12:39:47 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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-27 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 65773.
ashi1 marked an inline comment as done.
ashi1 added a comment.

Removed indentation as per Anastasia's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D22637

Files:
  include/clang/Basic/OpenCLExtensions.def
  lib/Basic/Targets.cpp
  test/Misc/amdgcn.languageOptsOpenCL.cl
  test/SemaOpenCL/extension-version.cl

Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -222,6 +222,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 
 #if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
+#if (__OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -181,6 +181,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_egl_image' - 
ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
 #ifdef cl_khr_srgb_image_writes
 #error "Incorrect cl_khr_srgb_image_writes define"
 #endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2115,6 +2115,7 @@
   Opts.cl_khr_fp16 = 1;
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
Index: include/clang/Basic/OpenCLExtensions.def
===
--- include/clang/Basic/OpenCLExtensions.def
+++ include/clang/Basic/OpenCLExtensions.def
@@ -67,6 +67,7 @@
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -222,6 +222,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 
 #if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
+#if (__OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -181,6 +181,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_egl_image' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
 #ifdef cl_khr_srgb_image_writes
 #error "Incorrect cl_khr_srgb_image_writes define"
 #endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2115,6 +2115,7 @@
   Opts.cl_khr_fp16 = 1;
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
Index: include/clang/Basic/OpenCLExtensions.def
===
--- include/clang/Basic/OpenCLExtensions.def
+++ include/clang/Basic

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Btw, I am missing tests for generated __translate_sampler_initializer which I 
think we had at some point.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:84
@@ +83,3 @@
+SamplerTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "__opencl_sampler_t"),
+  CGM.getContext().getTargetAddressSpace(

Related to this thread: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050126.html.

I am guessing leaving the old naming scheme should be fine.


Comment at: lib/Sema/SemaInit.cpp:6907
@@ -6905,2 +6906,3 @@
 case SK_OCLSamplerInit: {
-  assert(Step->Type->isSamplerT() && 
+  // Sampler initialzation have 6 cases:
+  //   1. function argument passing

There are 5 cases it seems :)


Comment at: lib/Sema/SemaInit.cpp:6947
@@ +6946,3 @@
+  // Do not diagnose if the file-scope variable does not have 
initializer
+  // since this has already beend diagnosed when parsing the variable
+  // declaration.

beend -> been


Comment at: lib/Sema/SemaInit.cpp:6949
@@ +6948,3 @@
+  // declaration.
+  if (!Var->getInit() || !isa(Var->getInit()))
+break;

Do we accept declaring global sampler_t variable without an initializer?


Comment at: lib/Sema/SemaInit.cpp:6956
@@ +6955,3 @@
+}
+  }
+

Could you use else here instead of adding TakeLiteral variable to avoid going 
to the next compound statement?


Comment at: lib/Sema/SemaInit.cpp:6965
@@ +6964,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Should this generate an error?


Comment at: test/SemaOpenCL/sampler_t.cl:51
@@ -14,1 +50,3 @@
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);

Are these extra calls below adding any extra testing?


Comment at: test/SemaOpenCL/sampler_t.cl:83
@@ -28,2 +82,3 @@
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary 
expression}}
+  foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }

Does this line add extra testing?


https://reviews.llvm.org/D21567



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: test/CodeGenCUDA/kernel-args-alignment.cu:1-2
@@ +1,3 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+

Typically clang doesn't need a registered backend for a target to generate IR 
for that target. It "knows" a whole bunch of stuff about all target calling 
conventions and data layout. Unless CUDA goes out of its way to query LLVM 
backend information, we shouldn't need these REQUIRES lines.

You should probably test this theory, though, by configuring an ARM-only clang 
and running the tests. :)


https://reviews.llvm.org/D22879



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


r276900 - [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

2016-07-27 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Jul 27 13:25:10 2016
New Revision: 276900

URL: http://llvm.org/viewvc/llvm-project?rev=276900&view=rev
Log:
[Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

Fixes PR27994, a crash on valid.

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

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=276900&r1=276899&r2=276900&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 27 13:25:10 2016
@@ -961,32 +961,26 @@ static QualType adjustCVQualifiersForCXX
 QualType Sema::getCurrentThisType() {
   DeclContext *DC = getFunctionLevelDeclContext();
   QualType ThisTy = CXXThisTypeOverride;
+
   if (CXXMethodDecl *method = dyn_cast(DC)) {
 if (method && method->isInstance())
   ThisTy = method->getThisType(Context);
   }
-  if (ThisTy.isNull()) {
-if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
-CurContext->getParent()->getParent()->isRecord()) {
-  // This is a generic lambda call operator that is being instantiated
-  // within a default initializer - so use the enclosing class as 'this'.
-  // There is no enclosing member function to retrieve the 'this' pointer
-  // from.
-
-  // FIXME: This looks wrong. If we're in a lambda within a lambda within a
-  // default member initializer, we need to recurse up more parents to find
-  // the right context. Looks like we should be walking up to the parent of
-  // the closure type, checking whether that is itself a lambda, and if so,
-  // recursing, until we reach a class or a function that isn't a lambda
-  // call operator. And we should accumulate the constness of *this on the
-  // way.
-
-  QualType ClassTy = Context.getTypeDeclType(
-  cast(CurContext->getParent()->getParent()));
-  // There are no cv-qualifiers for 'this' within default initializers, 
-  // per [expr.prim.general]p4.
-  ThisTy = Context.getPointerType(ClassTy);
-}
+
+  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
+  !ActiveTemplateInstantiations.empty()) {
+
+assert(isa(DC) &&
+   "Trying to get 'this' type from static method?");
+
+// This is a lambda call operator that is being instantiated as a default
+// initializer. DC must point to the enclosing class type, so we can 
recover
+// the 'this' type from it.
+
+QualType ClassTy = Context.getTypeDeclType(cast(DC));
+// There are no cv-qualifiers for 'this' within default initializers,
+// per [expr.prim.general]p4.
+ThisTy = Context.getPointerType(ClassTy);
   }
 
   // If we are within a lambda's call operator, the cv-qualifiers of 'this'

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=276900&r1=276899&r2=276900&view=diff
==
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Wed Jul 27 13:25:10 2016
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@ void foo() {
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}


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


Re: [PATCH] D21145: [Sema] Fix crash on valid where instantiation of lambda cannot access type of 'this'

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276900: [Sema] Teach getCurrentThisType to reconize lambda 
in in-class initializer (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D21145?vs=60622&id=65779#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21145

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Index: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
===
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -961,32 +961,26 @@
 QualType Sema::getCurrentThisType() {
   DeclContext *DC = getFunctionLevelDeclContext();
   QualType ThisTy = CXXThisTypeOverride;
+
   if (CXXMethodDecl *method = dyn_cast(DC)) {
 if (method && method->isInstance())
   ThisTy = method->getThisType(Context);
   }
-  if (ThisTy.isNull()) {
-if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
-CurContext->getParent()->getParent()->isRecord()) {
-  // This is a generic lambda call operator that is being instantiated
-  // within a default initializer - so use the enclosing class as 'this'.
-  // There is no enclosing member function to retrieve the 'this' pointer
-  // from.
-
-  // FIXME: This looks wrong. If we're in a lambda within a lambda within a
-  // default member initializer, we need to recurse up more parents to find
-  // the right context. Looks like we should be walking up to the parent of
-  // the closure type, checking whether that is itself a lambda, and if so,
-  // recursing, until we reach a class or a function that isn't a lambda
-  // call operator. And we should accumulate the constness of *this on the
-  // way.
-
-  QualType ClassTy = Context.getTypeDeclType(
-  cast(CurContext->getParent()->getParent()));
-  // There are no cv-qualifiers for 'this' within default initializers, 
-  // per [expr.prim.general]p4.
-  ThisTy = Context.getPointerType(ClassTy);
-}
+
+  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
+  !ActiveTemplateInstantiations.empty()) {
+
+assert(isa(DC) &&
+   "Trying to get 'this' type from static method?");
+
+// This is a lambda call operator that is being instantiated as a default
+// initializer. DC must point to the enclosing class type, so we can 
recover
+// the 'this' type from it.
+
+QualType ClassTy = Context.getTypeDeclType(cast(DC));
+// There are no cv-qualifiers for 'this' within default initializers,
+// per [expr.prim.general]p4.
+ThisTy = Context.getPointerType(ClassTy);
   }
 
   // If we are within a lambda's call operator, the cv-qualifiers of 'this'


Index: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
===
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks %s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks %s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -961,32 +961,26 @@
 QualT

[PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-27 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added reviewers: klimek, omtcyfz.
alexshap added subscribers: compnerd, cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

Properly initialize the field Context in NamedDeclFindingASTVisitor 
constructor: 
it is dereferenced in VisitTypeLoc Context->getLangOpts(). 
Fix passing nullptr to setResult in VisitTypeLoc: 
it is dereferenced in setResult Decl->getQualifiedNameAsString().
Add a test case: 
clang-rename crashes on it without this patch, works correctly with this patch. 
All the other tests are green.

https://reviews.llvm.org/D22881

Files:
  clang-rename/USRFinder.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp

Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -42,8 +42,9 @@
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string &Name,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -76,8 +77,9 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@
 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
  const std::string &Name) {
   const auto &SourceMgr = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, &Context);
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();


Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -42,8 +42,9 @@
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string &Name,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -76,8 +77,9 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@
 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
  const std::string &Name) {
   const auto &SourceMgr = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, &Context);
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.or

r276904 - Adjust coercion of aggregates on RenderScript

2016-07-27 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Wed Jul 27 14:01:51 2016
New Revision: 276904

URL: http://llvm.org/viewvc/llvm-project?rev=276904&view=rev
Log:
Adjust coercion of aggregates on RenderScript

Summary:
In RenderScript, the size of the argument or return value emitted in the
IR is expected to be the same as the size of corresponding qualified
type.  For ARM and AArch64, the coercion performed by Clang can
change the parameter or return value to a type whose size is different
(usually larger) than the original aggregate type.  Specifically, this
can happen in the following cases:
- Aggregate parameters of size <= 64 bytes and return values smaller
  than 4 bytes on ARM
- Aggregate parameters and return values smaller than bytes on
  AArch64

This patch coerces the cases above to an integer array that is the same
size and alignment as the original aggregate.  A new field is added to
TargetInfo to detect a RenderScript target and limit this coercion just
to that case.

Tests added to test/CodeGen/renderscript.c

Reviewers: rsmith

Subscribers: aemerson, srhines, llvm-commits

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/renderscript.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Jul 27 14:01:51 2016
@@ -92,6 +92,8 @@ protected:
 
   unsigned HasBuiltinMSVaList : 1;
 
+  unsigned IsRenderScriptTarget : 1;
+
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple &T);
 
@@ -565,6 +567,9 @@ public:
   /// available on this target.
   bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; }
 
+  /// Returns true for RenderScript.
+  bool isRenderScriptTarget() const { return IsRenderScriptTarget; }
+
   /// \brief Returns whether the passed in string is a valid clobber in an
   /// inline asm statement.
   ///

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Wed Jul 27 14:01:51 2016
@@ -80,6 +80,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   SSERegParmMax = 0;
   HasAlignMac68kSupport = false;
   HasBuiltinMSVaList = false;
+  IsRenderScriptTarget = false;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 27 14:01:51 2016
@@ -8113,6 +8113,7 @@ public:
  Triple.getOSName(),
  Triple.getEnvironmentName()),
 Opts) {
+IsRenderScriptTarget = true;
 LongWidth = LongAlign = 64;
   }
   void getTargetDefines(const LangOptions &Opts,
@@ -8130,7 +8131,9 @@ public:
   : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(),
  Triple.getOSName(),
  Triple.getEnvironmentName()),
-Opts) {}
+Opts) {
+IsRenderScriptTarget = true;
+  }
 
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 27 14:01:51 2016
@@ -31,6 +31,31 @@
 using namespace clang;
 using namespace CodeGen;
 
+// Helper for coercing an aggregate argument or return value into an integer
+// array of the same size (including padding) and alignment.  This alternate
+// coercion happens only for the RenderScript ABI and can be removed after
+// runtimes that rely on it are no longer supported.
+//
+// RenderScript assumes that the size of the argument / return value in the IR
+// is the same as the size of the corresponding qualified type. This helper
+// coerces the aggregate type into an array of the same size (in

Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D22857#497719, @rengolin wrote:

> I'll just echo @compnerd comments, since Phab didn't get it.
>
> - Change the syntax to __asm__, to be more portable
> - Add Microsoft asm block syntax


MSVC doesn't support inline assembly on ARM at all (they only support that on 
32 bit x86), so there's none of their syntax to support or test.

In https://reviews.llvm.org/D22857#497808, @rengolin wrote:

> As I read it, this is just making sure "inline asm" works on Windows, which 
> apparently hasn't been working so far. In a way, unrelated to the commit in 
> question.


No, inline assembly has been working, but only for assembly that didn't contain 
any immediate values.

> I agree we shouldn't be adding clang tests to assembler bugs.


Ok, we can skip this test if you prefer - the assembler test added for llvm-mc 
should be fine and enough as well.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits

Looking into it.
On 27/07/16 18:34, Jun Bum Lim wrote:

junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: default label 
in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

   default: llvm_unreachable("Unknown code completion result Kind.");
   ^


Repository:
   rL LLVM

https://reviews.llvm.org/D17820





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


r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 14:57:40 2016
New Revision: 276907

URL: http://llvm.org/viewvc/llvm-project?rev=276907&view=rev
Log:
Add flags to toggle preservation of assembly comments

Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.

Reviewers: echristo, rnk

Subscribers: mehdi_amini, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/preserve-as-comments.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
@@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
Group;
+def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Do not preserve comments in inline assembly">;
 def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
 def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
 def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27 14:57:40 2016
@@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
 CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
 CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
@@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
   CodeGenOpts.IncrementalLinkerCompatible;
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+  Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
 
   TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
@@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation &C,
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
+options::OPT_fno_preserve_as_comments, true))
+CmdArgs.push_back("-fno-preserve-as-comments");
+
   if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
 CmdArgs.push_back("-mregparm");
 CmdArgs.push_back(A->getValue());

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jul 27 14:57:40 2016
@@ -544,6 +544,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
   Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
+  Opts.PreserveAsmComme

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Yaxun Liu via cfe-commits
yaxunl marked 9 inline comments as done.


Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:84
@@ +83,3 @@
+SamplerTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "__opencl_sampler_t"),
+  CGM.getContext().getTargetAddressSpace(

Anastasia wrote:
> Related to this thread: 
> http://lists.llvm.org/pipermail/cfe-dev/2016-July/050126.html.
> 
> I am guessing leaving the old naming scheme should be fine.
I have some more comments about that. I think we should use 
`struct.__opencl_sampler` as the name of sampler type in LLVM IR.


Comment at: lib/Sema/SemaInit.cpp:6949
@@ +6948,3 @@
+  // declaration.
+  if (!Var->getInit() || !isa(Var->getInit()))
+break;

Anastasia wrote:
> Do we accept declaring global sampler_t variable without an initializer?
no. Since in file scope sampler variable is only allowed in constant addr 
space, it has to be initialized. There is a test for it.


Comment at: lib/Sema/SemaInit.cpp:6956
@@ +6955,3 @@
+}
+  }
+

Anastasia wrote:
> Could you use else here instead of adding TakeLiteral variable to avoid going 
> to the next compound statement?
Good catch. Will do.


Comment at: lib/Sema/SemaInit.cpp:6965
@@ +6964,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Anastasia wrote:
> Should this generate an error?
This has already been diagnosed when parsing the intializer of the variable 
declaration.


Comment at: test/SemaOpenCL/sampler_t.cl:51
@@ -14,1 +50,3 @@
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);

Anastasia wrote:
> Are these extra calls below adding any extra testing?
Add the function calls to test

1. No additional error msgs since the error msgs should be emitted for the 
variable declarations.
2. no crashes when parsing them


Comment at: test/SemaOpenCL/sampler_t.cl:83
@@ -28,2 +82,3 @@
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary 
expression}}
+  foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }

Anastasia wrote:
> Does this line add extra testing?
Test no crashes when an invalid sampler expression is passed as a sampler 
argument.


https://reviews.llvm.org/D21567



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 65796.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments. Added missing codegen test.


https://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,31 +1,85 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+constant sampler_t glb_smp6 = glb_smp; // expected-error{{initializer element is not a compile-time constant}}
+
+int f(void);
+constant sampler_t glb_smp7 = f(); // expected-error{{initializer element is not a compile-time constant}}
+
+constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant sampler_t' with an expression of incompatible type 'float'}}
+
+constant sampler_t glb_smp9 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
 
 void foo(sampler_t);
 
 constant struct sampler_s {
   sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
 } sampler_str = {0};
 
+sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
-  const sampler_t const_smp = 7;
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  const sampler_t const_smp2;
+  const sampler_t const_smp3 = const_smp;
+  const sampler_t const_smp4 = f();
+  const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const sampler_t' with an expression of incompatible type 'float'}}
+  const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
+
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);
+  foo(glb_smp4);
+  foo(glb_smp5);
+  foo(glb_smp6);
+  foo(glb_smp7);
+  foo(glb_smp8);
+  foo(glb_smp9);
+  foo(smp);
+  foo(sampler_str.smp);
   foo(const_smp);
+  foo(const_smp2);
+  foo(const_smp3);
+  foo(const_smp4);
+  foo(const_smp5);
+  foo(const_smp6);
+  foo(argsmp);
   foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
+  foo(sa[0]);
+  foo(bad());
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
 
 void bar() {
-  sampler_t smp1 = 7;
-  sampler_t smp2 = 2;
+  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
   smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
   smp1+1; //expected-error{{invalid operands to binary expression ('s

  1   2   >