[libcxx] r329545 - Revert "[CMake] Use custom command and target to install libc++ headers"

2018-04-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Sun Apr  8 21:36:04 2018
New Revision: 329545

URL: http://llvm.org/viewvc/llvm-project?rev=329545=rev
Log:
Revert "[CMake] Use custom command and target to install libc++ headers"

This reverts commit r329544 which is failing on libcxx standalone bots.

Modified:
libcxx/trunk/NOTES.TXT
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/include/CMakeLists.txt
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/NOTES.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/NOTES.TXT?rev=329545=329544=329545=diff
==
--- libcxx/trunk/NOTES.TXT (original)
+++ libcxx/trunk/NOTES.TXT Sun Apr  8 21:36:04 2018
@@ -26,4 +26,3 @@ to libc++.
 1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`.
 2. Update `test/libcxx/double_include.sh.cpp` to include the new header.
 3. Create a submodule in `include/module.modulemap` for the new header.
-4. Update the include/CMakeLists.txt file to include the new header.

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=329545=329544=329545=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Sun Apr  8 21:36:04 2018
@@ -47,22 +47,12 @@ macro(setup_abi_lib abidefines abilib ab
 set(found TRUE)
 get_filename_component(dstdir ${fpath} PATH)
 get_filename_component(ifile ${fpath} NAME)
-set(src ${incpath}/${fpath})
-
-set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${fpath})
-add_custom_command(OUTPUT ${dst}
-DEPENDS ${src}
-COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
-COMMENT "Copying C++ ABI header ${fpath}...")
-list(APPEND abilib_headers "${dst}")
-
-set(dst "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}/${fpath}")
-add_custom_command(OUTPUT ${dst}
-DEPENDS ${src}
-COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
-COMMENT "Copying C++ ABI header ${fpath}...")
-list(APPEND abilib_headers "${dst}")
-
+file(COPY "${incpath}/${fpath}"
+  DESTINATION "${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}"
+  )
+file(COPY "${incpath}/${fpath}"
+  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}"
+  )
 if (LIBCXX_INSTALL_HEADERS)
   install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
 DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
@@ -70,6 +60,7 @@ macro(setup_abi_lib abidefines abilib ab
 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 )
 endif()
+list(APPEND abilib_headers "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}")
   endif()
 endforeach()
 if (NOT found)
@@ -78,7 +69,6 @@ macro(setup_abi_lib abidefines abilib ab
   endforeach()
 
   include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
-  add_custom_target(cxx-abi-headers ALL DEPENDS ${abilib_headers})
 endmacro()
 
 

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=329545=329544=329545=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Sun Apr  8 21:36:04 2018
@@ -1,183 +1,5 @@
-set(files
-  __bit_reference
-  __bsd_locale_defaults.h
-  __bsd_locale_fallbacks.h
-  __debug
-  __functional_03
-  __functional_base
-  __functional_base_03
-  __hash_table
-  __libcpp_version
-  __locale
-  __mutex_base
-  __nullptr
-  __split_buffer
-  __sso_allocator
-  __std_stream
-  __string
-  __threading_support
-  __tree
-  __tuple
-  __undef_macros
-  algorithm
-  any
-  array
-  atomic
-  bitset
-  cassert
-  ccomplex
-  cctype
-  cerrno
-  cfenv
-  cfloat
-  chrono
-  cinttypes
-  ciso646
-  climits
-  clocale
-  cmath
-  codecvt
-  compare
-  complex
-  complex.h
-  condition_variable
-  csetjmp
-  csignal
-  cstdarg
-  cstdbool
-  cstddef
-  cstdint
-  cstdio
-  cstdlib
-  cstring
-  ctgmath
-  ctime
-  ctype.h
-  cwchar
-  cwctype
-  deque
-  errno.h
-  exception
-  experimental/__config
-  experimental/__memory
-  experimental/algorithm
-  experimental/any
-  experimental/chrono
-  experimental/coroutine
-  experimental/deque
-  experimental/dynarray
-  experimental/filesystem
-  experimental/forward_list
-  experimental/functional
-  experimental/iterator
-  experimental/list
-  experimental/map
-  experimental/memory_resource
-  experimental/numeric
-  experimental/optional
-  experimental/propagate_const
-  experimental/ratio
-  experimental/regex
-  experimental/set
-  experimental/string
-  experimental/string_view
-  

[PATCH] D45237: [RISCV] Fix logic to check if frame pointer should be used

2018-04-08 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 141584.
mgrang retitled this revision from "[RISCV] Fix logic check if frame pointer 
should be used" to "[RISCV] Fix logic to check if frame pointer should be used".
mgrang added a comment.

Added unit tests.


https://reviews.llvm.org/D45237

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/frame-pointer.c


Index: test/Driver/frame-pointer.c
===
--- test/Driver/frame-pointer.c
+++ test/Driver/frame-pointer.c
@@ -45,6 +45,18 @@
 // RUN: %clang -target riscv64-unknown-elf -### -S -O3 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-elf -### -S -Os %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKs-64 %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK0-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK1-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O2 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK2-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK3-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKs-32 %s
+
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK0-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK1-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O2 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK2-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK3-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKs-64 %s
+
 // CHECK0-32: -mdisable-fp-elim
 // CHECK1-32-NOT: -mdisable-fp-elim
 // CHECK2-32-NOT: -mdisable-fp-elim
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -529,6 +529,9 @@
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+return !areOptimizationsEnabled(Args);
   default:
 break;
   }
@@ -552,14 +555,6 @@
 }
   }
 
-  switch (Triple.getArch()) {
-case llvm::Triple::riscv32:
-case llvm::Triple::riscv64:
-  return !areOptimizationsEnabled(Args);
-default:
-  break;
-  }
-
   if (Triple.isOSWindows()) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86:


Index: test/Driver/frame-pointer.c
===
--- test/Driver/frame-pointer.c
+++ test/Driver/frame-pointer.c
@@ -45,6 +45,18 @@
 // RUN: %clang -target riscv64-unknown-elf -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-elf -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-32 %s
+
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
+
 // CHECK0-32: -mdisable-fp-elim
 // CHECK1-32-NOT: -mdisable-fp-elim
 // CHECK2-32-NOT: -mdisable-fp-elim
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -529,6 +529,9 @@
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+return !areOptimizationsEnabled(Args);
   default:
 break;
   }
@@ -552,14 +555,6 

[PATCH] D44773: [CMake] Use custom command and target to install libc++ headers

2018-04-08 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX329544: [CMake] Use custom command and target to install 
libc++ headers (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44773?vs=141580=141583#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44773

Files:
  NOTES.TXT
  cmake/Modules/HandleLibCXXABI.cmake
  include/CMakeLists.txt
  lib/CMakeLists.txt

Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -1,5 +1,183 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+set(files
+  __bit_reference
+  __bsd_locale_defaults.h
+  __bsd_locale_fallbacks.h
+  __debug
+  __functional_03
+  __functional_base
+  __functional_base_03
+  __hash_table
+  __libcpp_version
+  __locale
+  __mutex_base
+  __nullptr
+  __split_buffer
+  __sso_allocator
+  __std_stream
+  __string
+  __threading_support
+  __tree
+  __tuple
+  __undef_macros
+  algorithm
+  any
+  array
+  atomic
+  bitset
+  cassert
+  ccomplex
+  cctype
+  cerrno
+  cfenv
+  cfloat
+  chrono
+  cinttypes
+  ciso646
+  climits
+  clocale
+  cmath
+  codecvt
+  compare
+  complex
+  complex.h
+  condition_variable
+  csetjmp
+  csignal
+  cstdarg
+  cstdbool
+  cstddef
+  cstdint
+  cstdio
+  cstdlib
+  cstring
+  ctgmath
+  ctime
+  ctype.h
+  cwchar
+  cwctype
+  deque
+  errno.h
+  exception
+  experimental/__config
+  experimental/__memory
+  experimental/algorithm
+  experimental/any
+  experimental/chrono
+  experimental/coroutine
+  experimental/deque
+  experimental/dynarray
+  experimental/filesystem
+  experimental/forward_list
+  experimental/functional
+  experimental/iterator
+  experimental/list
+  experimental/map
+  experimental/memory_resource
+  experimental/numeric
+  experimental/optional
+  experimental/propagate_const
+  experimental/ratio
+  experimental/regex
+  experimental/set
+  experimental/string
+  experimental/string_view
+  experimental/system_error
+  experimental/tuple
+  experimental/type_traits
+  experimental/unordered_map
+  experimental/unordered_set
+  experimental/utility
+  experimental/vector
+  ext/__hash
+  ext/hash_map
+  ext/hash_set
+  float.h
+  forward_list
+  fstream
+  functional
+  future
+  initializer_list
+  inttypes.h
+  iomanip
+  ios
+  iosfwd
+  iostream
+  istream
+  iterator
+  limits
+  limits.h
+  list
+  locale
+  locale.h
+  map
+  math.h
+  memory
+  module.modulemap
+  mutex
+  new
+  numeric
+  optional
+  ostream
+  queue
+  random
+  ratio
+  regex
+  scoped_allocator
+  set
+  setjmp.h
+  shared_mutex
+  sstream
+  stack
+  stdbool.h
+  stddef.h
+  stdexcept
+  stdint.h
+  stdio.h
+  stdlib.h
+  streambuf
+  string
+  string.h
+  string_view
+  strstream
+  system_error
+  tgmath.h
+  thread
+  tuple
+  type_traits
+  typeindex
+  typeinfo
+  unordered_map
+  unordered_set
+  utility
+  valarray
+  variant
+  vector
+  version
+  wchar.h
+  wctype.h
+  )
+
+if(LIBCXX_INSTALL_SUPPORT_HEADERS)
+  set(files
+${files}
+support/android/locale_bionic.h
+support/fuchsia/xlocale.h
+support/ibm/limits.h
+support/ibm/locale_mgmt_aix.h
+support/ibm/support.h
+support/ibm/xlocale.h
+support/musl/xlocale.h
+support/newlib/xlocale.h
+support/solaris/floatingpoint.h
+support/solaris/wchar.h
+support/solaris/xlocale.h
+support/win32/limits_msvc_win32.h
+support/win32/locale_win32.h
+support/xlocale/__nop_locale_mgmt.h
+support/xlocale/__posix_l_fallback.h
+support/xlocale/__strtonum_fallback.h
+support/xlocale/xlocale.h
+)
 endif()
 
 if (LIBCXX_NEEDS_SITE_CONFIG)
@@ -14,44 +192,56 @@
 ${LIBCXX_BINARY_DIR}/__config_site
   )
   # Add a target that executes the generation commands.
-  add_custom_target(generate_config_header ALL
+  add_custom_target(cxx-generated-config ALL
 DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
-  set(generated_config_deps generate_config_header)
+  set(generated_config_deps cxx-generated-config)
+else()
+  set(files
+${files}
+__config
+)
 endif()
 
-set(LIBCXX_HEADER_PATTERN
-  PATTERN "*"
-  PATTERN "CMakeLists.txt" EXCLUDE
-  PATTERN ".svn" EXCLUDE
-  PATTERN "__config_site.in" EXCLUDE
-  ${LIBCXX_SUPPORT_HEADER_PATTERN}
-  )
-
 if(NOT LIBCXX_USING_INSTALLED_LLVM AND LLVM_BINARY_DIR)
-  file(COPY .
-DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
-FILES_MATCHING
-${LIBCXX_HEADER_PATTERN}
-)
+  set(output_dir ${LLVM_BINARY_DIR}/include/c++/v1)
+
+  set(out_files)
+  foreach(f ${files})
+set(src ${CMAKE_CURRENT_SOURCE_DIR}/${f})
+set(dst ${output_dir}/${f})
+add_custom_command(OUTPUT ${dst}
+  DEPENDS ${src}
+  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+  COMMENT "Copying libc++'s ${f}...")
+list(APPEND out_files ${dst})
+  endforeach()
 
   if 

[PATCH] D44773: [CMake] Use custom command and target to install libc++ headers

2018-04-08 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329544: [CMake] Use custom command and target to install 
libc++ headers (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44773?vs=141580=141582#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44773

Files:
  libcxx/trunk/NOTES.TXT
  libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/trunk/include/CMakeLists.txt
  libcxx/trunk/lib/CMakeLists.txt

Index: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
===
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
@@ -47,28 +47,38 @@
 set(found TRUE)
 get_filename_component(dstdir ${fpath} PATH)
 get_filename_component(ifile ${fpath} NAME)
-file(COPY "${incpath}/${fpath}"
-  DESTINATION "${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}"
-  )
-file(COPY "${incpath}/${fpath}"
-  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}"
-  )
+set(src ${incpath}/${fpath})
+
+set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${fpath})
+add_custom_command(OUTPUT ${dst}
+DEPENDS ${src}
+COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+COMMENT "Copying C++ ABI header ${fpath}...")
+list(APPEND abilib_headers "${dst}")
+
+set(dst "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}/${fpath}")
+add_custom_command(OUTPUT ${dst}
+DEPENDS ${src}
+COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+COMMENT "Copying C++ ABI header ${fpath}...")
+list(APPEND abilib_headers "${dst}")
+
 if (LIBCXX_INSTALL_HEADERS)
   install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
 DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
 COMPONENT cxx-headers
 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 )
 endif()
-list(APPEND abilib_headers "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}")
   endif()
 endforeach()
 if (NOT found)
   message(WARNING "Failed to find ${fpath}")
 endif()
   endforeach()
 
   include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
+  add_custom_target(cxx-abi-headers ALL DEPENDS ${abilib_headers})
 endmacro()
 
 
Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -283,7 +283,8 @@
 endif()
 
 # Add a meta-target for both libraries.
-add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS} ${generated_config_deps})
+add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS})
+add_dependencies(cxx cxx-headers)
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
Index: libcxx/trunk/NOTES.TXT
===
--- libcxx/trunk/NOTES.TXT
+++ libcxx/trunk/NOTES.TXT
@@ -26,3 +26,4 @@
 1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`.
 2. Update `test/libcxx/double_include.sh.cpp` to include the new header.
 3. Create a submodule in `include/module.modulemap` for the new header.
+4. Update the include/CMakeLists.txt file to include the new header.
Index: libcxx/trunk/include/CMakeLists.txt
===
--- libcxx/trunk/include/CMakeLists.txt
+++ libcxx/trunk/include/CMakeLists.txt
@@ -1,5 +1,183 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+set(files
+  __bit_reference
+  __bsd_locale_defaults.h
+  __bsd_locale_fallbacks.h
+  __debug
+  __functional_03
+  __functional_base
+  __functional_base_03
+  __hash_table
+  __libcpp_version
+  __locale
+  __mutex_base
+  __nullptr
+  __split_buffer
+  __sso_allocator
+  __std_stream
+  __string
+  __threading_support
+  __tree
+  __tuple
+  __undef_macros
+  algorithm
+  any
+  array
+  atomic
+  bitset
+  cassert
+  ccomplex
+  cctype
+  cerrno
+  cfenv
+  cfloat
+  chrono
+  cinttypes
+  ciso646
+  climits
+  clocale
+  cmath
+  codecvt
+  compare
+  complex
+  complex.h
+  condition_variable
+  csetjmp
+  csignal
+  cstdarg
+  cstdbool
+  cstddef
+  cstdint
+  cstdio
+  cstdlib
+  cstring
+  ctgmath
+  ctime
+  ctype.h
+  cwchar
+  cwctype
+  deque
+  errno.h
+  exception
+  experimental/__config
+  experimental/__memory
+  experimental/algorithm
+  experimental/any
+  experimental/chrono
+  experimental/coroutine
+  experimental/deque
+  experimental/dynarray
+  experimental/filesystem
+  experimental/forward_list
+  experimental/functional
+  experimental/iterator
+  experimental/list
+  experimental/map
+  experimental/memory_resource
+  experimental/numeric
+  

[libcxx] r329544 - [CMake] Use custom command and target to install libc++ headers

2018-04-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Sun Apr  8 21:23:04 2018
New Revision: 329544

URL: http://llvm.org/viewvc/llvm-project?rev=329544=rev
Log:
[CMake] Use custom command and target to install libc++ headers

Using file(COPY FILE...) has several downsides. Since the file command
is only executed at configuration time, any changes to headers made
after the initial CMake execution are ignored. This can lead to subtle
errors since the just built Clang will be using stale libc++ headers.
Furthermore, since the headers are copied prior to executing the build
system, this may hide missing dependencies on libc++ from other LLVM
components.

This changes replaces the use of file(COPY FILE...) command with a
custom command and target which addresses all aforementioned issues and
matches the implementation already used by other LLVM components that
also install headers like Clang builtin headers.

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

Modified:
libcxx/trunk/NOTES.TXT
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/include/CMakeLists.txt
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/NOTES.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/NOTES.TXT?rev=329544=329543=329544=diff
==
--- libcxx/trunk/NOTES.TXT (original)
+++ libcxx/trunk/NOTES.TXT Sun Apr  8 21:23:04 2018
@@ -26,3 +26,4 @@ to libc++.
 1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`.
 2. Update `test/libcxx/double_include.sh.cpp` to include the new header.
 3. Create a submodule in `include/module.modulemap` for the new header.
+4. Update the include/CMakeLists.txt file to include the new header.

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=329544=329543=329544=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Sun Apr  8 21:23:04 2018
@@ -47,12 +47,22 @@ macro(setup_abi_lib abidefines abilib ab
 set(found TRUE)
 get_filename_component(dstdir ${fpath} PATH)
 get_filename_component(ifile ${fpath} NAME)
-file(COPY "${incpath}/${fpath}"
-  DESTINATION "${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}"
-  )
-file(COPY "${incpath}/${fpath}"
-  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}"
-  )
+set(src ${incpath}/${fpath})
+
+set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${fpath})
+add_custom_command(OUTPUT ${dst}
+DEPENDS ${src}
+COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+COMMENT "Copying C++ ABI header ${fpath}...")
+list(APPEND abilib_headers "${dst}")
+
+set(dst "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}/${fpath}")
+add_custom_command(OUTPUT ${dst}
+DEPENDS ${src}
+COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+COMMENT "Copying C++ ABI header ${fpath}...")
+list(APPEND abilib_headers "${dst}")
+
 if (LIBCXX_INSTALL_HEADERS)
   install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
 DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
@@ -60,7 +70,6 @@ macro(setup_abi_lib abidefines abilib ab
 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 )
 endif()
-list(APPEND abilib_headers "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}")
   endif()
 endforeach()
 if (NOT found)
@@ -69,6 +78,7 @@ macro(setup_abi_lib abidefines abilib ab
   endforeach()
 
   include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
+  add_custom_target(cxx-abi-headers ALL DEPENDS ${abilib_headers})
 endmacro()
 
 

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=329544=329543=329544=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Sun Apr  8 21:23:04 2018
@@ -1,5 +1,183 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+set(files
+  __bit_reference
+  __bsd_locale_defaults.h
+  __bsd_locale_fallbacks.h
+  __debug
+  __functional_03
+  __functional_base
+  __functional_base_03
+  __hash_table
+  __libcpp_version
+  __locale
+  __mutex_base
+  __nullptr
+  __split_buffer
+  __sso_allocator
+  __std_stream
+  __string
+  __threading_support
+  __tree
+  __tuple
+  __undef_macros
+  algorithm
+  any
+  array
+  atomic
+  bitset
+  cassert
+  ccomplex
+  cctype
+  cerrno
+  cfenv
+  cfloat
+  chrono
+  cinttypes
+  ciso646
+  climits
+  clocale
+  cmath
+  codecvt
+  compare
+  complex
+  complex.h
+  

r329543 - [XRay][llvm+clang] Consolidate attribute list files

2018-04-08 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Sun Apr  8 21:02:09 2018
New Revision: 329543

URL: http://llvm.org/viewvc/llvm-project?rev=329543=rev
Log:
[XRay][llvm+clang] Consolidate attribute list files

Summary:
This change consolidates the always/never lists that may be provided to
clang to externally control which functions should be XRay instrumented
by imbuing attributes. The files follow the same format as defined in
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html for the
sanitizer blacklist.

We also deprecate the existing `-fxray-instrument-always=` and
`-fxray-instrument-never=` flags, in favour of `-fxray-attr-list=`.

This fixes http://llvm.org/PR34721.

Reviewers: echristo, vlad.tsyrklevich, eugenis

Reviewed By: vlad.tsyrklevich

Subscribers: llvm-commits, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/xray-attr-list.cpp
cfe/trunk/test/CodeGen/xray-never-instrument.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Basic/XRayLists.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/XRayLists.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/xray-always-instrument.cpp
cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=329543=329542=329543=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Sun Apr  8 21:02:09 2018
@@ -148,13 +148,20 @@ public:
   /// \brief Paths to the XRay "always instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay
   /// "always instrument" attribute.
+  /// WARNING: This is a deprecated field and will go away in the future.
   std::vector XRayAlwaysInstrumentFiles;
 
   /// \brief Paths to the XRay "never instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay
   /// "never instrument" attribute.
+  /// WARNING: This is a deprecated field and will go away in the future.
   std::vector XRayNeverInstrumentFiles;
 
+  /// \brief Paths to the XRay attribute list files, specifying which objects
+  /// (files, functions, variables) should be imbued with the appropriate XRay
+  /// attribute(s).
+  std::vector XRayAttrListFiles;
+
   clang::ObjCRuntime ObjCRuntime;
 
   std::string ObjCConstantStringClass;

Modified: cfe/trunk/include/clang/Basic/XRayLists.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/XRayLists.h?rev=329543=329542=329543=diff
==
--- cfe/trunk/include/clang/Basic/XRayLists.h (original)
+++ cfe/trunk/include/clang/Basic/XRayLists.h Sun Apr  8 21:02:09 2018
@@ -26,12 +26,13 @@ namespace clang {
 class XRayFunctionFilter {
   std::unique_ptr AlwaysInstrument;
   std::unique_ptr NeverInstrument;
+  std::unique_ptr AttrList;
   SourceManager 
 
 public:
   XRayFunctionFilter(ArrayRef AlwaysInstrumentPaths,
  ArrayRef NeverInstrumentPaths,
- SourceManager );
+ ArrayRef AttrListPaths, SourceManager );
 
   enum class ImbueAttribute {
 NONE,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329543=329542=329543=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sun Apr  8 21:02:09 2018
@@ -1095,11 +1095,15 @@ def fxray_instruction_threshold_ :
 def fxray_always_instrument :
   JoinedOrSeparate<["-"], "fxray-always-instrument=">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Filename defining the whitelist for imbuing the 'always 
instrument' XRay attribute.">;
+  HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 
'always instrument' XRay attribute.">;
 def fxray_never_instrument :
   JoinedOrSeparate<["-"], "fxray-never-instrument=">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Filename defining the whitelist for imbuing the 'never instrument' 
XRay attribute.">;
+  HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'never 
instrument' XRay attribute.">;
+def fxray_attr_list :
+  JoinedOrSeparate<["-"], "fxray-attr-list=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Filename defining the list of functions/types for imbuing XRay 
attributes.">;
 
 def fxray_always_emit_customevents : Flag<["-"], 
"fxray-always-emit-customevents">, Group,
   Flags<[CC1Option]>,

Modified: 

[PATCH] D44773: [CMake] Use custom command and target to install libc++ headers

2018-04-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 141580.

Repository:
  rCXX libc++

https://reviews.llvm.org/D44773

Files:
  libcxx/NOTES.TXT
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/lib/CMakeLists.txt

Index: libcxx/lib/CMakeLists.txt
===
--- libcxx/lib/CMakeLists.txt
+++ libcxx/lib/CMakeLists.txt
@@ -283,7 +283,8 @@
 endif()
 
 # Add a meta-target for both libraries.
-add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS} ${generated_config_deps})
+add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS})
+add_dependencies(cxx cxx-headers)
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
Index: libcxx/include/CMakeLists.txt
===
--- libcxx/include/CMakeLists.txt
+++ libcxx/include/CMakeLists.txt
@@ -1,5 +1,183 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+set(files
+  __bit_reference
+  __bsd_locale_defaults.h
+  __bsd_locale_fallbacks.h
+  __debug
+  __functional_03
+  __functional_base
+  __functional_base_03
+  __hash_table
+  __libcpp_version
+  __locale
+  __mutex_base
+  __nullptr
+  __split_buffer
+  __sso_allocator
+  __std_stream
+  __string
+  __threading_support
+  __tree
+  __tuple
+  __undef_macros
+  algorithm
+  any
+  array
+  atomic
+  bitset
+  cassert
+  ccomplex
+  cctype
+  cerrno
+  cfenv
+  cfloat
+  chrono
+  cinttypes
+  ciso646
+  climits
+  clocale
+  cmath
+  codecvt
+  compare
+  complex
+  complex.h
+  condition_variable
+  csetjmp
+  csignal
+  cstdarg
+  cstdbool
+  cstddef
+  cstdint
+  cstdio
+  cstdlib
+  cstring
+  ctgmath
+  ctime
+  ctype.h
+  cwchar
+  cwctype
+  deque
+  errno.h
+  exception
+  experimental/__config
+  experimental/__memory
+  experimental/algorithm
+  experimental/any
+  experimental/chrono
+  experimental/coroutine
+  experimental/deque
+  experimental/dynarray
+  experimental/filesystem
+  experimental/forward_list
+  experimental/functional
+  experimental/iterator
+  experimental/list
+  experimental/map
+  experimental/memory_resource
+  experimental/numeric
+  experimental/optional
+  experimental/propagate_const
+  experimental/ratio
+  experimental/regex
+  experimental/set
+  experimental/string
+  experimental/string_view
+  experimental/system_error
+  experimental/tuple
+  experimental/type_traits
+  experimental/unordered_map
+  experimental/unordered_set
+  experimental/utility
+  experimental/vector
+  ext/__hash
+  ext/hash_map
+  ext/hash_set
+  float.h
+  forward_list
+  fstream
+  functional
+  future
+  initializer_list
+  inttypes.h
+  iomanip
+  ios
+  iosfwd
+  iostream
+  istream
+  iterator
+  limits
+  limits.h
+  list
+  locale
+  locale.h
+  map
+  math.h
+  memory
+  module.modulemap
+  mutex
+  new
+  numeric
+  optional
+  ostream
+  queue
+  random
+  ratio
+  regex
+  scoped_allocator
+  set
+  setjmp.h
+  shared_mutex
+  sstream
+  stack
+  stdbool.h
+  stddef.h
+  stdexcept
+  stdint.h
+  stdio.h
+  stdlib.h
+  streambuf
+  string
+  string.h
+  string_view
+  strstream
+  system_error
+  tgmath.h
+  thread
+  tuple
+  type_traits
+  typeindex
+  typeinfo
+  unordered_map
+  unordered_set
+  utility
+  valarray
+  variant
+  vector
+  version
+  wchar.h
+  wctype.h
+  )
+
+if(LIBCXX_INSTALL_SUPPORT_HEADERS)
+  set(files
+${files}
+support/android/locale_bionic.h
+support/fuchsia/xlocale.h
+support/ibm/limits.h
+support/ibm/locale_mgmt_aix.h
+support/ibm/support.h
+support/ibm/xlocale.h
+support/musl/xlocale.h
+support/newlib/xlocale.h
+support/solaris/floatingpoint.h
+support/solaris/wchar.h
+support/solaris/xlocale.h
+support/win32/limits_msvc_win32.h
+support/win32/locale_win32.h
+support/xlocale/__nop_locale_mgmt.h
+support/xlocale/__posix_l_fallback.h
+support/xlocale/__strtonum_fallback.h
+support/xlocale/xlocale.h
+)
 endif()
 
 if (LIBCXX_NEEDS_SITE_CONFIG)
@@ -14,44 +192,56 @@
 ${LIBCXX_BINARY_DIR}/__config_site
   )
   # Add a target that executes the generation commands.
-  add_custom_target(generate_config_header ALL
+  add_custom_target(cxx-generated-config ALL
 DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
-  set(generated_config_deps generate_config_header)
+  set(generated_config_deps cxx-generated-config)
+else()
+  set(files
+${files}
+__config
+)
 endif()
 
-set(LIBCXX_HEADER_PATTERN
-  PATTERN "*"
-  PATTERN "CMakeLists.txt" EXCLUDE
-  PATTERN ".svn" EXCLUDE
-  PATTERN "__config_site.in" EXCLUDE
-  ${LIBCXX_SUPPORT_HEADER_PATTERN}
-  )
-
 if(NOT LIBCXX_USING_INSTALLED_LLVM AND LLVM_BINARY_DIR)
-  file(COPY .
-DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
-FILES_MATCHING
-${LIBCXX_HEADER_PATTERN}
-)
+  set(output_dir ${LLVM_BINARY_DIR}/include/c++/v1)
+
+  set(out_files)
+  foreach(f ${files})
+set(src 

[PATCH] D45357: [XRay][llvm+clang] Consolidate attribute list files

2018-04-08 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329543: [XRay][llvm+clang] Consolidate attribute list files 
(authored by dberris, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45357?vs=141578=141581#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45357

Files:
  cfe/trunk/include/clang/Basic/LangOptions.h
  cfe/trunk/include/clang/Basic/XRayLists.h
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/XRayArgs.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Basic/XRayLists.cpp
  cfe/trunk/lib/Driver/XRayArgs.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/xray-always-instrument.cpp
  cfe/trunk/test/CodeGen/xray-attr-list.cpp
  cfe/trunk/test/CodeGen/xray-imbue-arg1.cpp
  cfe/trunk/test/CodeGen/xray-never-instrument.cpp
  llvm/trunk/docs/XRay.rst
  llvm/trunk/docs/XRayExample.rst

Index: cfe/trunk/include/clang/Basic/XRayLists.h
===
--- cfe/trunk/include/clang/Basic/XRayLists.h
+++ cfe/trunk/include/clang/Basic/XRayLists.h
@@ -26,12 +26,13 @@
 class XRayFunctionFilter {
   std::unique_ptr AlwaysInstrument;
   std::unique_ptr NeverInstrument;
+  std::unique_ptr AttrList;
   SourceManager 
 
 public:
   XRayFunctionFilter(ArrayRef AlwaysInstrumentPaths,
  ArrayRef NeverInstrumentPaths,
- SourceManager );
+ ArrayRef AttrListPaths, SourceManager );
 
   enum class ImbueAttribute {
 NONE,
Index: cfe/trunk/include/clang/Basic/LangOptions.h
===
--- cfe/trunk/include/clang/Basic/LangOptions.h
+++ cfe/trunk/include/clang/Basic/LangOptions.h
@@ -148,13 +148,20 @@
   /// \brief Paths to the XRay "always instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay
   /// "always instrument" attribute.
+  /// WARNING: This is a deprecated field and will go away in the future.
   std::vector XRayAlwaysInstrumentFiles;
 
   /// \brief Paths to the XRay "never instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay
   /// "never instrument" attribute.
+  /// WARNING: This is a deprecated field and will go away in the future.
   std::vector XRayNeverInstrumentFiles;
 
+  /// \brief Paths to the XRay attribute list files, specifying which objects
+  /// (files, functions, variables) should be imbued with the appropriate XRay
+  /// attribute(s).
+  std::vector XRayAttrListFiles;
+
   clang::ObjCRuntime ObjCRuntime;
 
   std::string ObjCConstantStringClass;
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1095,11 +1095,15 @@
 def fxray_always_instrument :
   JoinedOrSeparate<["-"], "fxray-always-instrument=">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Filename defining the whitelist for imbuing the 'always instrument' XRay attribute.">;
+  HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'always instrument' XRay attribute.">;
 def fxray_never_instrument :
   JoinedOrSeparate<["-"], "fxray-never-instrument=">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Filename defining the whitelist for imbuing the 'never instrument' XRay attribute.">;
+  HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'never instrument' XRay attribute.">;
+def fxray_attr_list :
+  JoinedOrSeparate<["-"], "fxray-attr-list=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Filename defining the list of functions/types for imbuing XRay attributes.">;
 
 def fxray_always_emit_customevents : Flag<["-"], "fxray-always-emit-customevents">, Group,
   Flags<[CC1Option]>,
Index: cfe/trunk/include/clang/Driver/XRayArgs.h
===
--- cfe/trunk/include/clang/Driver/XRayArgs.h
+++ cfe/trunk/include/clang/Driver/XRayArgs.h
@@ -21,6 +21,7 @@
 class XRayArgs {
   std::vector AlwaysInstrumentFiles;
   std::vector NeverInstrumentFiles;
+  std::vector AttrListFiles;
   std::vector ExtraDeps;
   bool XRayInstrument = false;
   int InstructionThreshold = 200;
Index: cfe/trunk/test/CodeGen/xray-attr-list.cpp
===
--- cfe/trunk/test/CodeGen/xray-attr-list.cpp
+++ cfe/trunk/test/CodeGen/xray-attr-list.cpp
@@ -0,0 +1,19 @@
+// RUN: echo "[always]" > %t.xray-attrlist
+// RUN: echo "fun:*always*" >> %t.xray-attrlist
+// RUN: echo "[never]" >> %t.xray-attrlist
+// RUN: echo "fun:*never*" >> %t.xray-attrlist
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: -fxray-attr-list=%t.xray-attrlist -emit-llvm -o - %s \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+void always() {}
+void never() {}

[PATCH] D45422: [Driver] Allow drivers to add multiple libc++ include paths

2018-04-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: rsmith, dlj, rnk.
Herald added subscribers: cfe-commits, sdardis, dschuff.
Herald added a reviewer: EricWF.

This allows toolchain drivers to add multiple libc++ include paths akin
to libstdc++. This is useful in multiarch setup when some headers might
be in target specific include directory. There should be no functional
change.


Repository:
  rC Clang

https://reviews.llvm.org/D45422

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CloudABI.h
  clang/lib/Driver/ToolChains/Contiki.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Haiku.cpp
  clang/lib/Driver/ToolChains/Haiku.h
  clang/lib/Driver/ToolChains/Lanai.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MipsLinux.cpp
  clang/lib/Driver/ToolChains/MipsLinux.h
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/lib/Driver/ToolChains/Myriad.h
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/NaCl.h
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/NetBSD.h
  clang/lib/Driver/ToolChains/PS4CPU.h

Index: clang/lib/Driver/ToolChains/PS4CPU.h
===
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -61,7 +61,9 @@
  const llvm::opt::ArgList );
 
   // No support for finding a C++ standard library yet.
-  std::string findLibCxxIncludePath() const override { return ""; }
+  void addLibCxxIncludePaths(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override {}
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override {}
Index: clang/lib/Driver/ToolChains/NetBSD.h
===
--- clang/lib/Driver/ToolChains/NetBSD.h
+++ clang/lib/Driver/ToolChains/NetBSD.h
@@ -60,7 +60,9 @@
 
   CXXStdlibType GetDefaultCXXStdlibType() const override;
 
-  std::string findLibCxxIncludePath() const override;
+  void addLibCxxIncludePaths(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
Index: clang/lib/Driver/ToolChains/NetBSD.cpp
===
--- clang/lib/Driver/ToolChains/NetBSD.cpp
+++ clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -406,8 +406,10 @@
   return ToolChain::CST_Libstdcxx;
 }
 
-std::string NetBSD::findLibCxxIncludePath() const {
-  return getDriver().SysRoot + "/usr/include/c++/";
+void NetBSD::addLibCxxIncludePaths(const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList ) const {
+  addSystemInclude(DriverArgs, CC1Args,
+   getDriver().SysRoot + "/usr/include/c++/");
 }
 
 void NetBSD::addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
Index: clang/lib/Driver/ToolChains/NaCl.h
===
--- clang/lib/Driver/ToolChains/NaCl.h
+++ clang/lib/Driver/ToolChains/NaCl.h
@@ -53,7 +53,9 @@
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  std::string findLibCxxIncludePath() const override;
+  void addLibCxxIncludePaths(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
 
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const override;
 
Index: clang/lib/Driver/ToolChains/NaCl.cpp
===
--- clang/lib/Driver/ToolChains/NaCl.cpp
+++ clang/lib/Driver/ToolChains/NaCl.cpp
@@ -309,25 +309,29 @@
   CmdArgs.push_back("-lc++");
 }
 
-std::string NaClToolChain::findLibCxxIncludePath() const {
+void NaClToolChain::addLibCxxIncludePaths(
+const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const {
   const Driver  = getDriver();
 
   SmallString<128> P(D.Dir + "/../");
   switch (getTriple().getArch()) {
   case llvm::Triple::arm:
 llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
-return P.str();
+addSystemInclude(DriverArgs, CC1Args, P.str());
+break;
   case llvm::Triple::x86:
 llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
-return P.str();
+addSystemInclude(DriverArgs, CC1Args, P.str());
+break;
   case llvm::Triple::x86_64:
 llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
-return P.str();
+addSystemInclude(DriverArgs, CC1Args, P.str());
+break;
   case llvm::Triple::mipsel:
 llvm::sys::path::append(P, "mipsel-nacl/include/c++/v1");
-return P.str();
-  default:
-return "";
+addSystemInclude(DriverArgs, CC1Args, 

[PATCH] D45357: [XRay][llvm+clang] Consolidate attribute list files

2018-04-08 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 141578.
dberris added a comment.

- fixup: fix typo


https://reviews.llvm.org/D45357

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/XRayLists.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/XRayLists.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/xray-always-instrument.cpp
  clang/test/CodeGen/xray-attr-list.cpp
  clang/test/CodeGen/xray-imbue-arg1.cpp
  clang/test/CodeGen/xray-never-instrument.cpp
  llvm/docs/XRay.rst
  llvm/docs/XRayExample.rst

Index: llvm/docs/XRayExample.rst
===
--- llvm/docs/XRayExample.rst
+++ llvm/docs/XRayExample.rst
@@ -178,22 +178,22 @@
 To use this feature, you can define one file for the functions to always
 instrument, and another for functions to never instrument. The format of these
 files are exactly the same as the SanitizerLists files that control similar
-things for the sanitizer implementations. For example, we can have two
-different files like below:
+things for the sanitizer implementations. For example:
 
 ::
 
-  # always-instrument.txt
+  # xray-attr-list.txt
   # always instrument functions that match the following filters:
+  [always]
   fun:main
 
-  # never-instrument.txt
   # never instrument functions that match the following filters:
+  [never]
   fun:__cxx_*
 
-Given the above two files we can re-build by providing those two files as
-arguments to clang as ``-fxray-always-instrument=always-instrument.txt`` or
-``-fxray-never-instrument=never-instrument.txt``.
+Given the file above we can re-build by providing it to the
+``-fxray-attr-list=`` flag to clang. You can have multiple files, each defining
+different sets of attribute sets, to be combined into a single list by clang.
 
 The XRay stack tool
 ---
Index: llvm/docs/XRay.rst
===
--- llvm/docs/XRay.rst
+++ llvm/docs/XRay.rst
@@ -117,6 +117,27 @@
   ; ...
 }
 
+Special Case File
+-
+
+Attributes can be imbued through the use of special case files instead of
+adding them to the original source files. You can use this to mark certain
+functions and classes to be never, always, or instrumented with first-argument
+logging from a file. The file's format is described below:
+
+.. code-block:: bash
+
+# Comments are supported
+[always]
+fun:always_instrument
+fun:log_arg1=arg1 # Log the first argument for the function
+
+[never]
+fun:never_instrument
+
+These files can be provided through the ``-fxray-attr-list=`` flag to clang.
+You may have multiple files loaded through multiple instances of the flag.
+
 XRay Runtime Library
 
 
Index: clang/test/CodeGen/xray-never-instrument.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-never-instrument.cpp
@@ -0,0 +1,24 @@
+// RUN: echo "fun:*foo*" > %t.never-instrument
+// RUN: echo "src:*xray-never-instrument.cpp" >> %t.never-instrument
+// RUN: echo "[never]" > %t.xray-attrlist
+// RUN: echo "fun:*foo*" >> %t.xray-attrlist
+// RUN: echo "src:*xray-never-instrument.cpp" >> %t.xray-attrlist
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: -fxray-never-instrument=%t.never-instrument -emit-llvm -o - %s \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: -fxray-attr-list=%t.xray-attrlist -emit-llvm -o - %s \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+void foo() {}
+
+[[clang::xray_always_instrument]] void bar() {}
+
+void baz() {}
+
+// CHECK: define void @_Z3foov() #[[NEVERATTR:[0-9]+]] {
+// CHECK: define void @_Z3barv() #[[ALWAYSATTR:[0-9]+]] {
+// CHECK: define void @_Z3bazv() #[[NEVERATTR:[0-9]+]] {
+// CHECK: attributes #[[NEVERATTR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
+// CHECK: attributes #[[ALWAYSATTR]] = {{.*}} "function-instrument"="xray-always" {{.*}}
+
Index: clang/test/CodeGen/xray-imbue-arg1.cpp
===
--- clang/test/CodeGen/xray-imbue-arg1.cpp
+++ clang/test/CodeGen/xray-imbue-arg1.cpp
@@ -1,5 +1,12 @@
 // RUN: echo "fun:*arg1*=arg1" >> %t.always-instrument
-// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -fxray-always-instrument=%t.always-instrument -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: echo "[always]" > %t.xray-attrlist
+// RUN: echo "fun:*arg1*=arg1" >> %t.xray-attrlist
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: -fxray-always-instrument=%t.always-instrument -emit-llvm -o - %s \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: 

[PATCH] D45421: [X86] Emit native IR for pmuldq/pmuludq builtins.

2018-04-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.
Herald added a subscriber: cfe-commits.

I believe all the pieces are now in place in the backend to make this 
correctly. We can truncate the vXi64 type to vXi32, extend it back up to the 
original width and multiply.

In the backend the truncate+extend will becomes 
sign_extend_inreg/zero_extend_inreg(really an and). Then those will be combined 
with the mul to PMULDQ/PMULUDQ. Then SimplifyDemandedBits will strip the 
sign_extend_inreg/zero_extend_inreg out.

The only question I have is whether its ok to emit the v2i32 intermediate type 
for the 128-bit version. I wasn't sure of any examples where we use an illegal 
type in our intrinsic/builtin handling. At least not a narrower type. I know 
pavg uses a wider type.

I think I could probably do this all in the header file using 
__builtin_convertvector if that's desired.


Repository:
  rC Clang

https://reviews.llvm.org/D45421

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/sse2-builtins.c
  test/CodeGen/sse41-builtins.c

Index: test/CodeGen/sse41-builtins.c
===
--- test/CodeGen/sse41-builtins.c
+++ test/CodeGen/sse41-builtins.c
@@ -312,7 +312,11 @@
 
 __m128i test_mm_mul_epi32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_mul_epi32
-  // CHECK: call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
+  // CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  // CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  // CHECK: sext <2 x i32> %{{.*}} to <2 x i64>
+  // CHECK: sext <2 x i32> %{{.*}} to <2 x i64>
+  // CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   return _mm_mul_epi32(x, y);
 }
 
Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -816,7 +816,11 @@
 
 __m128i test_mm_mul_epu32(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_mul_epu32
-  // CHECK: call <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
+  // CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  // CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  // CHECK: zext <2 x i32> %{{.*}} to <2 x i64>
+  // CHECK: zext <2 x i32> %{{.*}} to <2 x i64>
+  // CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   return _mm_mul_epu32(A, B);
 }
 
Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -727,60 +727,92 @@
 __m256i test_mm256_mask_mul_epi32 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y) {
   //CHECK-LABEL: @test_mm256_mask_mul_epi32
-  //CHECK: @llvm.x86.avx2.pmul.dq
+  //CHECK: trunc <4 x i64> %{{.*}} to <4 x i32>
+  //CHECK: trunc <4 x i64> %{{.*}} to <4 x i32>
+  //CHECK: sext <4 x i32> %{{.*}} to <4 x i64>
+  //CHECK: sext <4 x i32> %{{.*}} to <4 x i64>
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_mul_epi32(__W, __M, __X, __Y);
 }
 
 __m256i test_mm256_maskz_mul_epi32 (__mmask8 __M, __m256i __X, __m256i __Y) {
   //CHECK-LABEL: @test_mm256_maskz_mul_epi32
-  //CHECK: @llvm.x86.avx2.pmul.dq
+  //CHECK: trunc <4 x i64> %{{.*}} to <4 x i32>
+  //CHECK: trunc <4 x i64> %{{.*}} to <4 x i32>
+  //CHECK: sext <4 x i32> %{{.*}} to <4 x i64>
+  //CHECK: sext <4 x i32> %{{.*}} to <4 x i64>
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_maskz_mul_epi32(__M, __X, __Y);
 }
 
 
 __m128i test_mm_mask_mul_epi32 (__m128i __W, __mmask8 __M, __m128i __X,
 __m128i __Y) {
   //CHECK-LABEL: @test_mm_mask_mul_epi32
-  //CHECK: @llvm.x86.sse41.pmuldq
+  //CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  //CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  //CHECK: sext <2 x i32> %{{.*}} to <2 x i64>
+  //CHECK: sext <2 x i32> %{{.*}} to <2 x i64>
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_mul_epi32(__W, __M, __X, __Y);
 }
 
 __m128i test_mm_maskz_mul_epi32 (__mmask8 __M, __m128i __X, __m128i __Y) {
   //CHECK-LABEL: @test_mm_maskz_mul_epi32
-  //CHECK: @llvm.x86.sse41.pmuldq
+  //CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  //CHECK: trunc <2 x i64> %{{.*}} to <2 x i32>
+  //CHECK: sext <2 x i32> %{{.*}} to <2 x i64>
+  //CHECK: sext <2 x i32> %{{.*}} to <2 x i64>
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_mul_epi32(__M, __X, __Y);
 }
 
 __m256i test_mm256_mask_mul_epu32 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y) {
   //CHECK-LABEL: @test_mm256_mask_mul_epu32
-  //CHECK: @llvm.x86.avx2.pmulu.dq

[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-08 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 141574.
Wizard added a comment.

reorder release note for alphabetical order


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392

Files:
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/IvarDeclarationCheck.cpp
  clang-tidy/objc/IvarDeclarationCheck.h
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-ivar-declaration.rst
  test/clang-tidy/objc-ivar-declaration.m

Index: test/clang-tidy/objc-ivar-declaration.m
===
--- /dev/null
+++ test/clang-tidy/objc-ivar-declaration.m
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s objc-ivar-declaration %t
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: instance variable 'barWithoutPrefix' not using '_' as prefix [objc-ivar-declaration]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: docs/clang-tidy/checks/objc-ivar-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-ivar-declaration.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - objc-ivar-declaration
+
+objc-ivar-declaration
+=
+
+Finds Objective-C ivars that do not have a '_' prefix.
+According to Apple's programming guide, the ivar names should be 
+prefixed with '_'.
+
+For code of ivar declaration:
+
+.. code-block:: objc
+
+   int barWithoutPrefix;
+
+The fix will be:
+
+.. code-block:: objc
+
+   int _barWithoutPrefix;
+
+The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -187,6 +187,7 @@
objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
+   objc-ivar-declaration
objc-property-declaration
performance-faster-string-find
performance-for-range-copy
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -124,6 +124,11 @@
   Finds and replaces deprecated uses of ``std::uncaught_exception`` to
   ``std::uncaught_exceptions``.
 
+- New :doc:`objc-ivar-declaration
+  ` check
+
+  Finds Objective-C ivars that do not have a '_' prefix.
+
 - New :doc:`portability-simd-intrinsics
   ` check
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
+#include "IvarDeclarationCheck.h"
 #include "PropertyDeclarationCheck.h"
 
 using namespace clang::ast_matchers;
@@ -30,6 +31,8 @@
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
 "objc-forbidden-subclassing");
+CheckFactories.registerCheck(
+"objc-ivar-declaration");
 CheckFactories.registerCheck(
 "objc-property-declaration");
   }
Index: clang-tidy/objc/IvarDeclarationCheck.h
===
--- /dev/null
+++ clang-tidy/objc/IvarDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- IvarDeclarationCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds Objective-C ivars which do not have '_' prefix.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-ivar-declaration.html
+class IvarDeclarationCheck : public ClangTidyCheck {
+public:
+  IvarDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace objc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
Index: clang-tidy/objc/IvarDeclarationCheck.cpp
===
--- /dev/null
+++ clang-tidy/objc/IvarDeclarationCheck.cpp
@@ -0,0 +1,52 @@
+//===--- 

[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D45392#1061064, @Wizard wrote:

> In https://reviews.llvm.org/D45392#1060971, @Eugene.Zelenko wrote:
>
> > In https://reviews.llvm.org/D45392#1060912, @Wizard wrote:
> >
> > > In https://reviews.llvm.org/D45392#1060854, @Eugene.Zelenko wrote:
> > >
> > > > In https://reviews.llvm.org/D45392#1060845, @Wizard wrote:
> > > >
> > > > > In https://reviews.llvm.org/D45392#1060485, @Eugene.Zelenko wrote:
> > > > >
> > > > > > If this is Apple guideline, check name should reflect this. I think 
> > > > > > will be good idea to have general check for Apple naming 
> > > > > > conventions instead of separate checks for specific situations like 
> > > > > > //objc-ivar-declaration// and //objc-property-declaration//.
> > > > >
> > > > >
> > > > > Thanks for the suggestion. I understand your point that they are both 
> > > > > naming convention, however, they are about different components and 
> > > > > using totally different naming rules. PropertyDeclarationCheck is 
> > > > > already a very complicated check (the most complicated one for ObjC), 
> > > > > I would rather not make it more heavy and try my best to split 
> > > > > independent logic to different checks.
> > > >
> > > >
> > > > See readability-identifier-naming 
> > > > 
> > > >  as example of multiple rules in one check.
> > >
> > >
> > > I took a look at IdentifierNamingCheck. Here's my thought:
> > >
> > > 1. IdentifierNamingCheck is trying to apply configurable naming 
> > > convention to C++ identifiers, and all the identifiers will share the 
> > > same style set. That is not the case of ObjC, where we follow Apple's 
> > > programming guide, and different types of identifiers are using different 
> > > style.
> > > 2. Such pattern can handle complicated requirements but to me it is not 
> > > simple enough to read and maintain. I would rather keep things simple and 
> > > clear as long as we have choice.
> > >
> > >   However, this check provides a good example of refactoring if in the 
> > > future we have the needs of organizing complicated naming styles. Moving 
> > > from simplicity to complexity is always easier. Thanks for pointing this 
> > > out for us.
> >
> >
> > My point is not flexibility of configuration, but handling of various types 
> > of identifiers in same check, even if conventions are different.
>
>
> Yes I understand but I mean "flexibility of configuration" is one of the 
> reasons of handling of various types of identifiers in same check, but we 
> don't need it here.


From user point of view, it's much easy to have one check which will check all 
possible types of identifiers, then set of not so obviously related checks.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D44773: [CMake] Use custom command and target to install libc++ headers

2018-04-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

There are a couple of new headers, `` and `` that should be 
added to the list before committing.


Repository:
  rCXX libc++

https://reviews.llvm.org/D44773



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


[PATCH] D44411: [libcxx] [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

In https://reviews.llvm.org/D44411#1056374, @EricWF wrote:

> Have you verified that we're not losing test coverage here? That is, are you 
> sure we still have tests for the rvalue overloads in other test files?


Yep. These containers already have tests for inserts with rvalues. No loss in 
test coverage here.


https://reviews.llvm.org/D44411



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


[PATCH] D44411: [libcxx] [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF closed this revision.
EricWF added a comment.

Committed as r329541.


https://reviews.llvm.org/D44411



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


[libcxx] r329541 - [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Apr  8 14:57:35 2018
New Revision: 329541

URL: http://llvm.org/viewvc/llvm-project?rev=329541=rev
Log:
[test] Fix Container::insert(value_type const&) tests

Patch from Joe Loser.

Several unit tests meaning to test the behavior of lvalue insertion incorrectly
pass rvalues. Fixes bug PR # 27394

Reviewed as https://reviews.llvm.org/D44411

Modified:
libcxx/trunk/test/std/containers/associative/multiset/insert_cv.pass.cpp
libcxx/trunk/test/std/containers/associative/set/insert_cv.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/multiset/insert_cv.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/insert_cv.pass.cpp?rev=329541=329540=329541=diff
==
--- libcxx/trunk/test/std/containers/associative/multiset/insert_cv.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/associative/multiset/insert_cv.pass.cpp 
Sun Apr  8 14:57:35 2018
@@ -18,56 +18,44 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_cv_test()
+{
+typedef Container M;
+typedef typename M::iterator R;
+typedef typename M::value_type VT;
+M m;
+const VT v1(2);
+R r = m.insert(v1);
+assert(r == m.begin());
+assert(m.size() == 1);
+assert(*r == 2);
+
+const VT v2(1);
+r = m.insert(v2);
+assert(r == m.begin());
+assert(m.size() == 2);
+assert(*r == 1);
+
+const VT v3(3);
+r = m.insert(v3);
+assert(r == prev(m.end()));
+assert(m.size() == 3);
+assert(*r == 3);
+
+r = m.insert(v3);
+assert(r == prev(m.end()));
+assert(m.size() == 4);
+assert(*r == 3);
+}
+
 int main()
 {
-{
-typedef std::multiset M;
-typedef M::iterator R;
-M m;
-R r = m.insert(M::value_type(2));
-assert(r == m.begin());
-assert(m.size() == 1);
-assert(*r == 2);
-
-r = m.insert(M::value_type(1));
-assert(r == m.begin());
-assert(m.size() == 2);
-assert(*r == 1);
-
-r = m.insert(M::value_type(3));
-assert(r == prev(m.end()));
-assert(m.size() == 3);
-assert(*r == 3);
-
-r = m.insert(M::value_type(3));
-assert(r == prev(m.end()));
-assert(m.size() == 4);
-assert(*r == 3);
-}
+do_insert_cv_test();
 #if TEST_STD_VER >= 11
 {
 typedef std::multiset M;
-typedef M::iterator R;
-M m;
-R r = m.insert(M::value_type(2));
-assert(r == m.begin());
-assert(m.size() == 1);
-assert(*r == 2);
-
-r = m.insert(M::value_type(1));
-assert(r == m.begin());
-assert(m.size() == 2);
-assert(*r == 1);
-
-r = m.insert(M::value_type(3));
-assert(r == prev(m.end()));
-assert(m.size() == 3);
-assert(*r == 3);
-
-r = m.insert(M::value_type(3));
-assert(r == prev(m.end()));
-assert(m.size() == 4);
-assert(*r == 3);
+do_insert_cv_test();
 }
 #endif
 }

Modified: libcxx/trunk/test/std/containers/associative/set/insert_cv.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/insert_cv.pass.cpp?rev=329541=329540=329541=diff
==
--- libcxx/trunk/test/std/containers/associative/set/insert_cv.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/associative/set/insert_cv.pass.cpp Sun Apr 
 8 14:57:35 2018
@@ -18,64 +18,49 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_cv_test()
+{
+typedef Container M;
+typedef std::pair R;
+typedef typename M::value_type VT;
+M m;
+
+const VT v1(2);
+R r = m.insert(v1);
+assert(r.second);
+assert(r.first == m.begin());
+assert(m.size() == 1);
+assert(*r.first == 2);
+
+const VT v2(1);
+r = m.insert(v2);
+assert(r.second);
+assert(r.first == m.begin());
+assert(m.size() == 2);
+assert(*r.first == 1);
+
+const VT v3(3);
+r = m.insert(v3);
+

[PATCH] D44411: [libcxx] [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D44411



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


[PATCH] D44411: [libcxx] [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Joe Loser via Phabricator via cfe-commits
jloser updated this revision to Diff 141573.
jloser added a comment.

Use `v3` rather than an rvalue of `3` in 
`libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp`


https://reviews.llvm.org/D44411

Files:
  libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp
  libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
  
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp

Index: libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
@@ -24,53 +24,42 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_hint_const_lvalue_test()
+{
+typedef Container C;
+typedef typename C::iterator R;
+typedef typename C::value_type VT;
+C c;
+typename C::const_iterator e = c.end();
+const VT v1(3.5);
+R r = c.insert(e, v1);
+assert(c.size() == 1);
+assert(*r == 3.5);
+
+r = c.insert(e, v1);
+assert(c.size() == 1);
+assert(*r == 3.5);
+
+const VT v2(4.5);
+r = c.insert(e, v2);
+assert(c.size() == 2);
+assert(*r == 4.5);
+
+const VT v3(5.5);
+r = c.insert(e, v3);
+assert(c.size() == 3);
+assert(*r == 5.5);
+}
+
 int main()
 {
-{
-typedef std::unordered_set C;
-typedef C::iterator R;
-typedef C::value_type P;
-C c;
-C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(4.5));
-assert(c.size() == 2);
-assert(*r == 4.5);
-
-r = c.insert(e, P(5.5));
-assert(c.size() == 3);
-assert(*r == 5.5);
-}
+do_insert_hint_const_lvalue_test();
 #if TEST_STD_VER >= 11
 {
 typedef std::unordered_set C;
-typedef C::iterator R;
-typedef C::value_type P;
-C c;
-C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(4.5));
-assert(c.size() == 2);
-assert(*r == 4.5);
-
-r = c.insert(e, P(5.5));
-assert(c.size() == 3);
-assert(*r == 5.5);
+do_insert_hint_const_lvalue_test();
 }
 #endif
 #if _LIBCPP_DEBUG >= 1
Index: libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
@@ -20,59 +20,45 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_const_lvalue_test()
+{
+typedef Container C;
+typedef std::pair R;
+typedef typename C::value_type VT;
+C c;
+const VT v1(3.5);
+R r = c.insert(v1);
+assert(c.size() == 1);
+assert(*r.first == 3.5);
+assert(r.second);
+
+r = c.insert(v1);
+assert(c.size() == 1);
+assert(*r.first == 3.5);
+assert(!r.second);
+
+const VT v2(4.5);
+r = c.insert(v2);
+assert(c.size() == 2);
+assert(*r.first == 4.5);
+assert(r.second);
+
+const VT v3(5.5);
+r = c.insert(v3);
+assert(c.size() == 3);
+assert(*r.first == 5.5);
+assert(r.second);
+}
+
 int main()
 {
-{
-typedef std::unordered_set C;
-typedef std::pair R;
-typedef C::value_type P;
-C c;
-R r = c.insert(P(3.5));
-assert(c.size() == 1);
-assert(*r.first == 3.5);
-assert(r.second);
-
-r = c.insert(P(3.5));
-assert(c.size() == 1);
-assert(*r.first == 3.5);
-assert(!r.second);
-
-r = c.insert(P(4.5));
-assert(c.size() == 2);
-assert(*r.first == 4.5);
-assert(r.second);
-
-r = 

[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-08 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

In https://reviews.llvm.org/D45392#1060971, @Eugene.Zelenko wrote:

> In https://reviews.llvm.org/D45392#1060912, @Wizard wrote:
>
> > In https://reviews.llvm.org/D45392#1060854, @Eugene.Zelenko wrote:
> >
> > > In https://reviews.llvm.org/D45392#1060845, @Wizard wrote:
> > >
> > > > In https://reviews.llvm.org/D45392#1060485, @Eugene.Zelenko wrote:
> > > >
> > > > > If this is Apple guideline, check name should reflect this. I think 
> > > > > will be good idea to have general check for Apple naming conventions 
> > > > > instead of separate checks for specific situations like 
> > > > > //objc-ivar-declaration// and //objc-property-declaration//.
> > > >
> > > >
> > > > Thanks for the suggestion. I understand your point that they are both 
> > > > naming convention, however, they are about different components and 
> > > > using totally different naming rules. PropertyDeclarationCheck is 
> > > > already a very complicated check (the most complicated one for ObjC), I 
> > > > would rather not make it more heavy and try my best to split 
> > > > independent logic to different checks.
> > >
> > >
> > > See readability-identifier-naming 
> > > 
> > >  as example of multiple rules in one check.
> >
> >
> > I took a look at IdentifierNamingCheck. Here's my thought:
> >
> > 1. IdentifierNamingCheck is trying to apply configurable naming convention 
> > to C++ identifiers, and all the identifiers will share the same style set. 
> > That is not the case of ObjC, where we follow Apple's programming guide, 
> > and different types of identifiers are using different style.
> > 2. Such pattern can handle complicated requirements but to me it is not 
> > simple enough to read and maintain. I would rather keep things simple and 
> > clear as long as we have choice.
> >
> >   However, this check provides a good example of refactoring if in the 
> > future we have the needs of organizing complicated naming styles. Moving 
> > from simplicity to complexity is always easier. Thanks for pointing this 
> > out for us.
>
>
> My point is not flexibility of configuration, but handling of various types 
> of identifiers in same check, even if conventions are different.


Yes I understand but I mean "flexibility of configuration" is one of the 
reasons of handling of various types of identifiers in same check, but we don't 
need it here.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-08 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 141561.
zinovy.nis added a comment.

- Updated ReleaseNotes.


https://reviews.llvm.org/D45405

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-min-type-name-length.cpp

Index: test/clang-tidy/modernize-use-auto-min-type-name-length.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-min-type-name-length.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.MinTypeNameLength, value: '5'}]}" \
+// RUN:   -- -std=c++11 -frtti
+
+extern int foo();
+
+using VeryVeryVeryLongTypeName = int;
+
+int bar() {
+  int a = static_cast(foo());
+  // strlen('int') = 4 <  5, so skip it, 
+  // even strlen('VeryVeryVeryLongTypeName') > 5.
+
+  unsigned b = static_cast(foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
+  // CHECK-FIXES: auto b = static_cast(foo());
+
+  bool c = static_cast(foo());
+  // strlen('bool') = 4 <  5, so skip it.
+
+  const bool c1 = static_cast(foo());
+  // strlen('bool') = 4 <  5, so skip it, even there's a 'const'.
+
+  unsigned long long ull = static_cast(foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
+  // CHECK-FIXES: auto ull = static_cast(foo());
+
+  return 1;
+}
+
Index: docs/clang-tidy/checks/modernize-use-auto.rst
===
--- docs/clang-tidy/checks/modernize-use-auto.rst
+++ docs/clang-tidy/checks/modernize-use-auto.rst
@@ -194,3 +194,23 @@
   // RemoveStars = 1
 
   auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;
+
+.. option:: MinTypeNameLength
+
+   If the option is set to any positive non-zero integer, the check will
+   neither warn nor fix type names having a length less than the option value.
+   The option affects expressions only, not iterators.
+
+.. code-block:: c++
+
+  // MinTypeNameLength = 0
+
+  int a = static_cast(foo());// ---> auto a = ...
+  bool b = new bool;  // ---> auto b = ...
+  unsigned c = static_cast(foo());  // ---> auto c = ...
+
+  // MinTypeNameLength = 8
+
+  int a = static_cast(foo());// ---> int  a = ...
+  bool b = new bool;  // ---> bool b = ...
+  unsigned c = static_cast(foo());  // ---> auto c = ...
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@
 Improvements to clang-tidy
 --
 
+- New option `MinTypeNameLength` for `modernize-use-auto` to limit the minimal
+  length of type names to be replaced with 'auto'. Use to skip replacing
+  short type names like 'int'/'bool' -> 'auto'.
+
 - New module `abseil` for checks related to the `Abseil `_
   library.
 
Index: clang-tidy/modernize/UseAutoCheck.h
===
--- clang-tidy/modernize/UseAutoCheck.h
+++ clang-tidy/modernize/UseAutoCheck.h
@@ -29,6 +29,7 @@
llvm::function_ref GetType,
StringRef Message);
 
+  const unsigned int MinTypeNameLength;
   const bool RemoveStars;
 };
 
Index: clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tidy/modernize/UseAutoCheck.cpp
@@ -286,10 +286,11 @@
 } // namespace
 
 UseAutoCheck::UseAutoCheck(StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  RemoveStars(Options.get("RemoveStars", 0)) {}
+: ClangTidyCheck(Name, Context), RemoveStars(Options.get("RemoveStars", 0)),
+  MinTypeNameLength(Options.get("MinTypeNameLength", 0)) {}
 
 void UseAutoCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "MinTypeNameLength", MinTypeNameLength);
   Options.store(Opts, "RemoveStars", RemoveStars ? 1 : 0);
 }
 
@@ -414,6 +415,13 @@
 Loc = Loc.getNextTypeLoc();
   }
   SourceRange Range(Loc.getSourceRange());
+
+  if (MinTypeNameLength != 0 &&
+  Lexer::getSourceText(CharSourceRange::getTokenRange(Range),
+   Context->getSourceManager(), Context->getLangOpts())
+  .size() < MinTypeNameLength)
+return;
+
   auto Diag = diag(Range.getBegin(), Message);
 
   // Space after 'auto' to handle cases where the '*' in the pointer type is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329515 - [libclang] Add clang_File_tryGetRealPathName

2018-04-08 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Sat Apr  7 13:50:35 2018
New Revision: 329515

URL: http://llvm.org/viewvc/llvm-project?rev=329515=rev
Log:
[libclang] Add clang_File_tryGetRealPathName

Summary:
clang_getFileName() may return a path relative to WorkingDir.
On Arch Linux, during clang_indexTranslationUnit(), clang_getFileName() on
CXIdxIncludedIncludedFileInfo::file may return
"/../lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/string",
for `#include `.

I presume WorkingDir is somehow changed to /usr/lib or /usr/include and
clang_getFileName() returns a path relative to WorkingDir.

clang_File_tryGetRealPathName() returns "/usr/include/c++/7.3.0/string"
which is more useful for the indexer in this case.

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports
cfe/trunk/unittests/libclang/LibclangTest.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=329515=329514=329515=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Sat Apr  7 13:50:35 2018
@@ -425,6 +425,13 @@ CINDEX_LINKAGE const char *clang_getFile
 CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
 
 /**
+ * \brief Returns the real path name of \c file.
+ *
+ * An empty string may be returned. Use \c clang_getFileName() in that case.
+ */
+CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
+
+/**
  * @}
  */
 

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=329515=329514=329515=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Sat Apr  7 13:50:35 2018
@@ -4249,6 +4249,14 @@ int clang_File_isEqual(CXFile file1, CXF
   return FEnt1->getUniqueID() == FEnt2->getUniqueID();
 }
 
+CXString clang_File_tryGetRealPathName(CXFile SFile) {
+  if (!SFile)
+return cxstring::createNull();
+
+  FileEntry *FEnt = static_cast(SFile);
+  return cxstring::createRef(FEnt->tryGetRealPathName());
+}
+
 
//===--===//
 // CXCursor Operations.
 
//===--===//

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=329515=329514=329515=diff
==
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Sat Apr  7 13:50:35 2018
@@ -46,6 +46,7 @@ clang_Cursor_isVariadic
 clang_Cursor_getModule
 clang_Cursor_getStorageClass
 clang_File_isEqual
+clang_File_tryGetRealPathName
 clang_Module_getASTFile
 clang_Module_getParent
 clang_Module_getName

Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=329515=329514=329515=diff
==
--- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
+++ cfe/trunk/unittests/libclang/LibclangTest.cpp Sat Apr  7 13:50:35 2018
@@ -482,6 +482,21 @@ public:
   }
 };
 
+TEST_F(LibclangReparseTest, FileName) {
+  std::string CppName = "main.cpp";
+  WriteFile(CppName, "int main() {}");
+  ClangTU = clang_parseTranslationUnit(Index, CppName.c_str(), nullptr, 0,
+   nullptr, 0, TUFlags);
+  CXFile cxf = clang_getFile(ClangTU, CppName.c_str());
+
+  CXString cxname = clang_getFileName(cxf);
+  ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str()));
+  clang_disposeString(cxname);
+
+  cxname = clang_File_tryGetRealPathName(cxf);
+  ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str()));
+  clang_disposeString(cxname);
+}
 
 TEST_F(LibclangReparseTest, Reparse) {
   const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;";


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


[PATCH] D45417: [analyzer] Don't crash on printing ConcreteInt of size >64 bits

2018-04-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: NoQ, dcoughlin, xazax.hun.
Herald added subscribers: cfe-commits, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

Printing of ConcreteInts with size >64 bits resulted in assertion failure in 
get[Z|S]ExtValue() :`getActiveBits() <= 64 && "Too many bits for uint64_t"' 
failed'`. This patch fixes the issue.

Patch by Ivan Sidorenko!


Repository:
  rC Clang

https://reviews.llvm.org/D45417

Files:
  lib/StaticAnalyzer/Core/SVals.cpp
  test/Analysis/egraph-dump-int128.c


Index: test/Analysis/egraph-dump-int128.c
===
--- /dev/null
+++ test/Analysis/egraph-dump-int128.c
@@ -0,0 +1,7 @@
+// RUN: rm -fR %t.dir
+// RUN: mkdir -p %t.dir
+// RUN: env TMPDIR=%t.dir TEMP=%t.dir TMP=%t.dir %clang_analyze_cc1 
-analyzer-checker=debug.ViewExplodedGraph %s
+
+unsigned __int128 get_big_value() {
+  return (unsigned __int128)5 << 64; // Do not crash
+}
Index: lib/StaticAnalyzer/Core/SVals.cpp
===
--- lib/StaticAnalyzer/Core/SVals.cpp
+++ lib/StaticAnalyzer/Core/SVals.cpp
@@ -301,12 +301,21 @@
   switch (getSubKind()) {
 case nonloc::ConcreteIntKind: {
   const nonloc::ConcreteInt& C = castAs();
-  if (C.getValue().isUnsigned())
-os << C.getValue().getZExtValue();
-  else
-os << C.getValue().getSExtValue();
-  os << ' ' << (C.getValue().isUnsigned() ? 'U' : 'S')
- << C.getValue().getBitWidth() << 'b';
+  bool IsSigned = C.getValue().isSigned();
+  // FIXME: We can just call C.getValue().print() for all cases, but it has
+  //rather slow performance (see implementation of toString()).
+  //Let's call it only for integer values > 64 bits.
+  if (C.getValue().getBitWidth() <= llvm::APInt::APINT_BITS_PER_WORD) {
+// NOTE: don't use ternary here! Otherwise, unsigned value will be
+// always printed due to implicit type conversion.
+if (IsSigned)
+  os << C.getValue().getSExtValue();
+else
+  os << C.getValue().getZExtValue();
+  } else {
+C.getValue().print(os, IsSigned);
+  }
+  os << ' ' << (IsSigned ? 'S' : 'U') << C.getValue().getBitWidth() << 'b';
   break;
 }
 case nonloc::SymbolValKind:


Index: test/Analysis/egraph-dump-int128.c
===
--- /dev/null
+++ test/Analysis/egraph-dump-int128.c
@@ -0,0 +1,7 @@
+// RUN: rm -fR %t.dir
+// RUN: mkdir -p %t.dir
+// RUN: env TMPDIR=%t.dir TEMP=%t.dir TMP=%t.dir %clang_analyze_cc1 -analyzer-checker=debug.ViewExplodedGraph %s
+
+unsigned __int128 get_big_value() {
+  return (unsigned __int128)5 << 64; // Do not crash
+}
Index: lib/StaticAnalyzer/Core/SVals.cpp
===
--- lib/StaticAnalyzer/Core/SVals.cpp
+++ lib/StaticAnalyzer/Core/SVals.cpp
@@ -301,12 +301,21 @@
   switch (getSubKind()) {
 case nonloc::ConcreteIntKind: {
   const nonloc::ConcreteInt& C = castAs();
-  if (C.getValue().isUnsigned())
-os << C.getValue().getZExtValue();
-  else
-os << C.getValue().getSExtValue();
-  os << ' ' << (C.getValue().isUnsigned() ? 'U' : 'S')
- << C.getValue().getBitWidth() << 'b';
+  bool IsSigned = C.getValue().isSigned();
+  // FIXME: We can just call C.getValue().print() for all cases, but it has
+  //rather slow performance (see implementation of toString()).
+  //Let's call it only for integer values > 64 bits.
+  if (C.getValue().getBitWidth() <= llvm::APInt::APINT_BITS_PER_WORD) {
+// NOTE: don't use ternary here! Otherwise, unsigned value will be
+// always printed due to implicit type conversion.
+if (IsSigned)
+  os << C.getValue().getSExtValue();
+else
+  os << C.getValue().getZExtValue();
+  } else {
+C.getValue().print(os, IsSigned);
+  }
+  os << ' ' << (IsSigned ? 'S' : 'U') << C.getValue().getBitWidth() << 'b';
   break;
 }
 case nonloc::SymbolValKind:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43779: [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-04-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Hmm.
Got back to this issue.

Not reproducible with gcc-4.8.5 and gcc-4.9.3 in ubuntu 16.04 chroot.
*Reproducible* with gcc-4.8.4 and gcc-4.9.2 in debian oldstable (Jessie) chroot.
So one might assume that it was fixed.

I did try to creduce the crasher, but not not much success, since gcc takes 10+ 
sec to crash.

Should i simply try to re-commit and see if the buildbots got upgraded so this 
is no longer an issue?


Repository:
  rL LLVM

https://reviews.llvm.org/D43779



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


[PATCH] D43764: [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-08 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule added a comment.

Thank you for applying the patch.

I suspect some undefined order when applying replacements as directly dependant 
in which order OS reads `file1.yaml`, `file2.yaml`and `file3.yaml`.
As I am not able to reproduce it on my machine, can you share with me the 
content of `output.txt`?


https://reviews.llvm.org/D43764



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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-08 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

I think that we emit empty method lists so that the GCC runtime doesn't choke 
on them, though there's no reason why we couldn't with the GNUstep ABI.  It 
would therefore be nice if the test failed if we did change to emitting null so 
that we could update the test at that point and check that it's actually doing 
the right thing.

The ELF version of the v2 ABI is mostly finished now, modulo writing a load of 
clang tests, so I'll upload that for review soon.

It would also help to have a gnu- prefix on the test name so that it's easy to 
identify the relevant tests, though not essential.


Repository:
  rC Clang

https://reviews.llvm.org/D45305



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


[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: NoQ, dcoughlin, xazax.hun.
Herald added subscribers: cfe-commits, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

Despite the fact that cast expressions return rvalues, GCC still handles  such 
outputs as lvalues when compiling inline assembler. Such code causes assertion 
failure in ExprEngine::VisitGCCAsmStmt. In this commit, we treat such rvalue 
outputs in the way similar to how CGStmt does it.


Repository:
  rC Clang

https://reviews.llvm.org/D45416

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/asm.c


Index: test/Analysis/asm.c
===
--- /dev/null
+++ test/Analysis/asm.c
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection 
-fheinous-gnu-extensions -w %s -verify
+
+int clang_analyzer_eval(int);
+
+int global;
+void testRValueOutput() {
+  global = 1;
+  __asm__("" : "=r"((int)global));  // don't crash on rvalue output operand
+  clang_analyzer_eval(global == 1); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3071,9 +3071,25 @@
   // outputs.
 
   ProgramStateRef state = Pred->getState();
+  const auto *LCtx = Pred->getLocationContext();
 
   for (const Expr *O : A->outputs()) {
-SVal X = state->getSVal(O, Pred->getLocationContext());
+// NOTE: GCC inline asm supports rvalue no-op-like casts as output
+// arguments (-fheinous-gnu-extensions).
+const Expr *LValueOutputE = O->IgnoreParenNoopCasts(getContext());
+SVal X = state->getSVal(LValueOutputE, LCtx);
+if (X.isUnknown()) {
+  // The value being casted to rvalue can be garbage-collected after
+  // the cast is modeled. Try to recover the memory region being casted
+  // if possible.
+  if (const auto *DRE = dyn_cast(LValueOutputE)) {
+if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  const VarRegion *VR =
+  getSValBuilder().getRegionManager().getVarRegion(VD, LCtx);
+  X = loc::MemRegionVal(VR);
+}
+  }
+}
 assert(!X.getAs());  // Should be an Lval, or unknown, undef.
 
 if (Optional LV = X.getAs())


Index: test/Analysis/asm.c
===
--- /dev/null
+++ test/Analysis/asm.c
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -fheinous-gnu-extensions -w %s -verify
+
+int clang_analyzer_eval(int);
+
+int global;
+void testRValueOutput() {
+  global = 1;
+  __asm__("" : "=r"((int)global));  // don't crash on rvalue output operand
+  clang_analyzer_eval(global == 1); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3071,9 +3071,25 @@
   // outputs.
 
   ProgramStateRef state = Pred->getState();
+  const auto *LCtx = Pred->getLocationContext();
 
   for (const Expr *O : A->outputs()) {
-SVal X = state->getSVal(O, Pred->getLocationContext());
+// NOTE: GCC inline asm supports rvalue no-op-like casts as output
+// arguments (-fheinous-gnu-extensions).
+const Expr *LValueOutputE = O->IgnoreParenNoopCasts(getContext());
+SVal X = state->getSVal(LValueOutputE, LCtx);
+if (X.isUnknown()) {
+  // The value being casted to rvalue can be garbage-collected after
+  // the cast is modeled. Try to recover the memory region being casted
+  // if possible.
+  if (const auto *DRE = dyn_cast(LValueOutputE)) {
+if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  const VarRegion *VR =
+  getSValBuilder().getRegionManager().getVarRegion(VD, LCtx);
+  X = loc::MemRegionVal(VR);
+}
+  }
+}
 assert(!X.getAs());  // Should be an Lval, or unknown, undef.
 
 if (Optional LV = X.getAs())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-04-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.
Herald added a subscriber: martong.

Hi Peter,
The changes needed for rebase are too large - they contain both fixes for 
compilation failures and fixes for test errors. Could you please upgrade the 
patch?


https://reviews.llvm.org/D38845



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


[PATCH] D45414: [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 141547.
JonasToth added a comment.

- fix std bitmask type shifting issue


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45414

Files:
  clang-tidy/hicpp/SignedBitwiseCheck.cpp
  docs/ReleaseNotes.rst
  test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
  test/clang-tidy/hicpp-signed-bitwise.cpp

Index: test/clang-tidy/hicpp-signed-bitwise.cpp
===
--- test/clang-tidy/hicpp-signed-bitwise.cpp
+++ test/clang-tidy/hicpp-signed-bitwise.cpp
@@ -41,9 +41,12 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
   UResult = SValue & -1;
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  UResult&= 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
 
   UResult = UValue & 1u; // Ok
   UResult = UValue & UValue; // Ok
+  UResult&= 2u;  // Ok
 
   unsigned char UByte1 = 0u;
   unsigned char UByte2 = 16u;
@@ -68,18 +71,30 @@
   UByte1 = UByte1 | UByte2; // Ok
   UByte1 = UByte1 | SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1|= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1|= UByte2; // Ok
 
   UByte1 = UByte1 ^ UByte2; // Ok
   UByte1 = UByte1 ^ SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1^= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1^= UByte2; // Ok
 
   UByte1 = UByte1 >> UByte2; // Ok
   UByte1 = UByte1 >> SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1>>= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1>>= UByte2; // Ok
 
   UByte1 = UByte1 << UByte2; // Ok
   UByte1 = UByte1 << SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1<<= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1<<= UByte2; // Ok
 
   int SignedInt1 = 1 << 12;
   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator
@@ -195,10 +210,16 @@
   int s3;
   s3 = IntOne | IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3|= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = IntOne & IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3&= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = IntOne ^ IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3^= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = s1 | s2; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
   s3 = s1 & s2; // Signed
Index: test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
===
--- test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
+++ test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
@@ -8,51 +8,57 @@
   std::locale::category C = std::locale::category::ctype;
 
   SResult = std::locale::category::none | std::locale::category::collate;
+  SResult|= std::locale::category::collate;
   SResult = std::locale::category::ctype & std::locale::category::monetary;
+  SResult&= std::locale::category::monetary;
   SResult = std::locale::category::numeric ^ std::locale::category::time;
+  SResult^= std::locale::category::time;
   SResult = std::locale::category::messages | std::locale::category::all;
 
   SResult = std::locale::category::all & C;
+  SResult&= std::locale::category::all;
   SResult = std::locale::category::all | C;
+  SResult|= std::locale::category::all;
   SResult = std::locale::category::all ^ C;
+  SResult^= std::locale::category::all;
 
   // std::ctype_base::mask
   std::ctype_base::mask M = std::ctype_base::mask::punct;
 
   SResult = std::ctype_base::mask::space | std::ctype_base::mask::print;
   SResult = std::ctype_base::mask::cntrl & std::ctype_base::mask::upper;
   SResult = std::ctype_base::mask::lower ^ 

[PATCH] D45414: [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, hokein, alexfh.
Herald added subscribers: cfe-commits, xazax.hun, klimek.

This patch resolves the bug https://bugs.llvm.org/show_bug.cgi?id=36963.

- implement missing assignment operators for `hicpp-signed-bitwise`
- add tests
- mention fix in release notes


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45414

Files:
  clang-tidy/hicpp/SignedBitwiseCheck.cpp
  docs/ReleaseNotes.rst
  test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
  test/clang-tidy/hicpp-signed-bitwise.cpp

Index: test/clang-tidy/hicpp-signed-bitwise.cpp
===
--- test/clang-tidy/hicpp-signed-bitwise.cpp
+++ test/clang-tidy/hicpp-signed-bitwise.cpp
@@ -41,9 +41,12 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
   UResult = SValue & -1;
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  UResult&= 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
 
   UResult = UValue & 1u; // Ok
   UResult = UValue & UValue; // Ok
+  UResult&= 2u;  // Ok
 
   unsigned char UByte1 = 0u;
   unsigned char UByte2 = 16u;
@@ -68,18 +71,30 @@
   UByte1 = UByte1 | UByte2; // Ok
   UByte1 = UByte1 | SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1|= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1|= UByte2; // Ok
 
   UByte1 = UByte1 ^ UByte2; // Ok
   UByte1 = UByte1 ^ SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1^= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1^= UByte2; // Ok
 
   UByte1 = UByte1 >> UByte2; // Ok
   UByte1 = UByte1 >> SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1>>= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1>>= UByte2; // Ok
 
   UByte1 = UByte1 << UByte2; // Ok
   UByte1 = UByte1 << SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1<<= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1<<= UByte2; // Ok
 
   int SignedInt1 = 1 << 12;
   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator
@@ -195,10 +210,16 @@
   int s3;
   s3 = IntOne | IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3|= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = IntOne & IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3&= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = IntOne ^ IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3^= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = s1 | s2; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
   s3 = s1 & s2; // Signed
Index: test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
===
--- test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
+++ test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
@@ -8,51 +8,57 @@
   std::locale::category C = std::locale::category::ctype;
 
   SResult = std::locale::category::none | std::locale::category::collate;
+  SResult|= std::locale::category::collate;
   SResult = std::locale::category::ctype & std::locale::category::monetary;
+  SResult&= std::locale::category::monetary;
   SResult = std::locale::category::numeric ^ std::locale::category::time;
+  SResult^= std::locale::category::time;
   SResult = std::locale::category::messages | std::locale::category::all;
 
   SResult = std::locale::category::all & C;
+  SResult&= std::locale::category::all;
   SResult = std::locale::category::all | C;
+  SResult|= std::locale::category::all;
   SResult = std::locale::category::all ^ C;
+  SResult^= std::locale::category::all;
 
   // std::ctype_base::mask
   std::ctype_base::mask M = 

[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D45392#1060912, @Wizard wrote:

> In https://reviews.llvm.org/D45392#1060854, @Eugene.Zelenko wrote:
>
> > In https://reviews.llvm.org/D45392#1060845, @Wizard wrote:
> >
> > > In https://reviews.llvm.org/D45392#1060485, @Eugene.Zelenko wrote:
> > >
> > > > If this is Apple guideline, check name should reflect this. I think 
> > > > will be good idea to have general check for Apple naming conventions 
> > > > instead of separate checks for specific situations like 
> > > > //objc-ivar-declaration// and //objc-property-declaration//.
> > >
> > >
> > > Thanks for the suggestion. I understand your point that they are both 
> > > naming convention, however, they are about different components and using 
> > > totally different naming rules. PropertyDeclarationCheck is already a 
> > > very complicated check (the most complicated one for ObjC), I would 
> > > rather not make it more heavy and try my best to split independent logic 
> > > to different checks.
> >
> >
> > See readability-identifier-naming 
> > 
> >  as example of multiple rules in one check.
>
>
> I took a look at IdentifierNamingCheck. Here's my thought:
>
> 1. IdentifierNamingCheck is trying to apply configurable naming convention to 
> C++ identifiers, and all the identifiers will share the same style set. That 
> is not the case of ObjC, where we follow Apple's programming guide, and 
> different types of identifiers are using different style.
> 2. Such pattern can handle complicated requirements but to me it is not 
> simple enough to read and maintain. I would rather keep things simple and 
> clear as long as we have choice.
>
>   However, this check provides a good example of refactoring if in the future 
> we have the needs of organizing complicated naming styles. Moving from 
> simplicity to complexity is always easier. Thanks for pointing this out for 
> us.


My point is not flexibility of configuration, but handling of various types of 
identifiers in same check, even if conventions are different.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D44079: [ASTImporter] Allow testing of import sequences; fix import of typedefs for anonymous decls

2018-04-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin updated this revision to Diff 141537.
a.sidorin added a comment.

Rebase to the latest master; add a suggestion from Adam Balogh (thanks!).


Repository:
  rC Clang

https://reviews.llvm.org/D44079

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -20,10 +20,15 @@
 
 #include "DeclMatcher.h"
 #include "gtest/gtest.h"
+#include "llvm/ADT/StringMap.h"
 
 namespace clang {
 namespace ast_matchers {
 
+using internal::Matcher;
+using internal::BindableMatcher;
+using llvm::StringMap;
+
 typedef std::vector ArgVector;
 typedef std::vector RunOptions;
 
@@ -70,22 +75,61 @@
 
 // Creates a virtual file and assigns that to the context of given AST. If the
 // file already exists then the file will not be created again as a duplicate.
-static void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
-  const std::string ) {
+static void
+createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
+  std::unique_ptr &) {
   assert(ToAST);
   ASTContext  = ToAST->getASTContext();
   auto *OFS = static_cast(
   ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
   auto *MFS =
   static_cast(OFS->overlays_begin()->get());
-  MFS->addFile(FileName, 0, llvm::MemoryBuffer::getMemBuffer(Code.c_str()));
+  MFS->addFile(FileName, 0, std::move(Buffer));
+}
+
+static void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
+  const std::string ) {
+  return createVirtualFileIfNeeded(
+  ToAST, FileName, llvm::MemoryBuffer::getMemBuffer(Code.c_str()));
 }
 
-template
+template 
+NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter ,
+NodeType Node) {
+  ASTContext  = To->getASTContext();
+
+  // Add 'From' file to virtual file system so importer can 'find' it
+  // while importing SourceLocations. It is safe to add same file multiple
+  // times - it just isn't replaced.
+  StringRef FromFileName = From->getMainFileName();
+  createVirtualFileIfNeeded(To, FromFileName,
+From->getBufferForFile(FromFileName));
+
+  auto Imported = Importer.Import(Node);
+
+  // This should dump source locations and assert if some source locations
+  // were not imported.
+  SmallString<1024> ImportChecker;
+  llvm::raw_svector_ostream ToNothing(ImportChecker);
+  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+
+  // This traverses the AST to catch certain bugs like poorly or not
+  // implemented subtrees.
+  Imported->dump(ToNothing);
+
+  return Imported;
+}
+
+const StringRef DeclToImportID = "declToImport";
+const StringRef DeclToVerifyID = "declToVerify";
+
+template 
 testing::AssertionResult
 testImport(const std::string , const ArgVector ,
const std::string , const ArgVector ,
-   MatchVerifier , const MatcherType ) {
+   MatchVerifier ,
+   const BindableMatcher ,
+   const BindableMatcher ) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -97,46 +141,47 @@
   ASTContext  = FromAST->getASTContext(),
= ToAST->getASTContext();
 
-  // Add input.cc to virtual file system so importer can 'find' it
-  // while importing SourceLocations.
-  createVirtualFileIfNeeded(ToAST.get(), InputFileName, FromCode);
-
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
 
-  IdentifierInfo *ImportedII = ("declToImport");
-  assert(ImportedII && "Declaration with 'declToImport' name"
-   "should be specified in test!");
-  DeclarationName ImportDeclName(ImportedII);
-  SmallVector FoundDecls;
-  FromCtx.getTranslationUnitDecl()->localUncachedLookup(
-ImportDeclName, FoundDecls);
+  auto FoundNodes = match(SearchMatcher, FromCtx);
+  if (FoundNodes.size() != 1)
+return testing::AssertionFailure()
+   << "Multiple potential nodes were found!";
 
-  if (FoundDecls.size() != 1)
-return testing::AssertionFailure() << "Multiple declarations were found!";
+  auto ToImport = selectFirst(DeclToImportID, FoundNodes);
+  if (!ToImport)
+return testing::AssertionFailure() << "Node type mismatch!";
 
   // Sanity check: the node being imported should match in the same way as
   // the result node.
-  EXPECT_TRUE(Verifier.match(FoundDecls.front(), AMatcher));
+  BindableMatcher WrapperMatcher(VerificationMatcher);
+  EXPECT_TRUE(Verifier.match(ToImport, WrapperMatcher));
 
-  auto Imported = Importer.Import(FoundDecls.front());
+  auto Imported = importNode(FromAST.get(), ToAST.get(), 

[PATCH] D45241: [analyzer] Invalidate union regions properly. Don't hesitate to load the default binding later.

2018-04-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45241



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


[PATCH] D44878: libFuzzer OpenBSD support

2018-04-08 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 141534.

https://reviews.llvm.org/D44878

Files:
  lib/Driver/ToolChains/OpenBSD.cpp


Index: lib/Driver/ToolChains/OpenBSD.cpp
===
--- lib/Driver/ToolChains/OpenBSD.cpp
+++ lib/Driver/ToolChains/OpenBSD.cpp
@@ -241,8 +241,11 @@
   // For future use, only UBsan at the moment
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
 
-  if (IsX86 || IsX86_64)
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
+  }
 
   return Res;
 }


Index: lib/Driver/ToolChains/OpenBSD.cpp
===
--- lib/Driver/ToolChains/OpenBSD.cpp
+++ lib/Driver/ToolChains/OpenBSD.cpp
@@ -241,8 +241,11 @@
   // For future use, only UBsan at the moment
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
 
-  if (IsX86 || IsX86_64)
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
+  }
 
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45406: Document -std= values for different languages

2018-04-08 Thread Dimitry Andric via Phabricator via cfe-commits
dim updated this revision to Diff 141529.
dim added a comment.

Attempt to put the standard values in to definition lists.  In the HTML
output, this looks fairly nice, but as a man page, it seems a bit
strange, for example:

  -std=
 Specify the language standard to compile for.
  
 Supported values for the C language are:
c89
c90
iso9899:1990
  
   ISO C 1990
iso9899:199409
  
   ISO C 1990 with amendment 1
gnu89
gnu90
  
   ISO C 1990 with GNU extensions
c99
iso9899:1999
  
   ISO C 1999
gnu99
  
   ISO C 1999 with GNU extensions
c11
iso9899:2011
  
   ISO C 2011
gnu11
  
   ISO C 2011 with GNU extensions
c17
iso9899:2017
  
   ISO C 2017
gnu17
  
   ISO C 2017 with GNU extensions
  
 The default C language standard is gnu11, except on PS4, where
 it is gnu99.


Repository:
  rC Clang

https://reviews.llvm.org/D45406

Files:
  docs/CommandGuide/clang.rst

Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -98,9 +98,128 @@
 
  Treat subsequent input files as having type language.
 
-.. option:: -std=
+.. option:: -std=
 
  Specify the language standard to compile for.
+
+ Supported values for the C language are:
+
+  | ``c89``
+  | ``c90``
+  | ``iso9899:1990``
+
+   ISO C 1990
+
+  | ``iso9899:199409``
+
+   ISO C 1990 with amendment 1
+
+  | ``gnu89``
+  | ``gnu90``
+
+   ISO C 1990 with GNU extensions
+
+  | ``c99``
+  | ``iso9899:1999``
+
+   ISO C 1999
+
+  | ``gnu99``
+
+   ISO C 1999 with GNU extensions
+
+  | ``c11``
+  | ``iso9899:2011``
+
+   ISO C 2011
+
+  | ``gnu11``
+
+   ISO C 2011 with GNU extensions
+
+  | ``c17``
+  | ``iso9899:2017``
+
+   ISO C 2017
+
+  | ``gnu17``
+
+   ISO C 2017 with GNU extensions
+
+ The default C language standard is ``gnu11``, except on PS4, where it is
+ ``gnu99``.
+
+ Supported values for the C++ language are:
+
+  | ``c++98``
+  | ``c++03``
+
+   ISO C++ 1998 with amendments
+
+  | ``gnu++98``
+  | ``gnu++03``
+
+   ISO C++ 1998 with amendments and GNU extensions
+
+  | ``c++11``
+
+   ISO C++ 2011 with amendments
+
+  | ``gnu++11``
+
+ISO C++ 2011 with amendments and GNU extensions
+
+  | ``c++14``
+
+   ISO C++ 2014 with amendments
+
+  | ``gnu++14``
+
+   ISO C++ 2014 with amendments and GNU extensions
+
+  | ``c++17``
+
+   ISO C++ 2017 with amendments
+
+  | ``gnu++17``
+
+   ISO C++ 2017 with amendments and GNU extensions
+
+  | ``c++2a``
+
+   Working draft for ISO C++ 2020
+
+  | ``gnu++2a``
+
+   Working draft for ISO C++ 2020 with GNU extensions
+
+ The default C++ language standard is ``gnu++14``.
+
+ Supported values for the OpenCL language are:
+
+  | ``cl1.0``
+
+   OpenCL 1.0
+
+  | ``cl1.1``
+
+   OpenCL 1.1
+
+  | ``cl1.2``
+
+   OpenCL 1.2
+
+  | ``cl2.0``
+
+   OpenCL 2.0
+
+ The default OpenCL language standard is ``cl1.0``.
+
+ Supported values for the CUDA language are:
+
+  | ``cuda``
+
+   NVIDIA CUDA(tm)
 
 .. option:: -stdlib=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45406: Document -std= values for different languages

2018-04-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I think you'd want a definition list 
 
instead then. But I haven't tested if they can be nested inside option lists.


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D45406: Document -std= values for different languages

2018-04-08 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In https://reviews.llvm.org/D45406#1060914, @mgorny wrote:

> Well, my idea was to list the standards one per line (like on GCC manpage), 
> and then the '(deprecated)' comments would probably stand out enough to apply 
> to a single line. Also, FWICS the gcc manpage simply lists which aliases are 
> deprecated in the description text. But skipping them entirely also works for 
> me.


Right, I see what you mean (as per 
https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-std-1), I'm not 
completely sure how to force a line break in RST with itemized lists, though.


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D45407: [StaticAnalyzer] Added notes to the plist output

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

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45407



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


[PATCH] D45406: Document -std= values for different languages

2018-04-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Well, my idea was to list the standards one per line (like on GCC manpage), and 
then the '(deprecated)' comments would probably stand out enough to apply to a 
single line. Also, FWICS the gcc manpage simply lists which aliases are 
deprecated in the description text. But skipping them entirely also works for 
me.


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-08 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

In https://reviews.llvm.org/D45392#1060854, @Eugene.Zelenko wrote:

> In https://reviews.llvm.org/D45392#1060845, @Wizard wrote:
>
> > In https://reviews.llvm.org/D45392#1060485, @Eugene.Zelenko wrote:
> >
> > > If this is Apple guideline, check name should reflect this. I think will 
> > > be good idea to have general check for Apple naming conventions instead 
> > > of separate checks for specific situations like //objc-ivar-declaration// 
> > > and //objc-property-declaration//.
> >
> >
> > Thanks for the suggestion. I understand your point that they are both 
> > naming convention, however, they are about different components and using 
> > totally different naming rules. PropertyDeclarationCheck is already a very 
> > complicated check (the most complicated one for ObjC), I would rather not 
> > make it more heavy and try my best to split independent logic to different 
> > checks.
>
>
> See readability-identifier-naming 
> 
>  as example of multiple rules in one check.


I took a look at IdentifierNamingCheck. Here's my thought:

1. IdentifierNamingCheck is trying to apply configurable naming convention to 
C++ identifiers, and all the identifiers will share the same style set. That is 
not the case of ObjC, where we follow Apple's programming guide, and different 
types of identifiers are using different style.
2. Such pattern can handle complicated requirements but to me it is not simple 
enough to read and maintain. I would rather keep things simple and clear as 
long as we have choice.

However, this check provides a good example of refactoring if in the future we 
have the needs of organizing complicated naming styles. Moving from simplicity 
to complexity is always easier. Thanks for pointing this out for us.




Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`objc-ivar-declaration
+  ` check

Eugene.Zelenko wrote:
> Wizard wrote:
> > Eugene.Zelenko wrote:
> > > Please place in new check list in alphabetical order.
> > I did not see a "new check list" in alphabetical order in this file. I 
> > believe they are ordered by commit time.If you mean the list.rst, they are 
> > already ordered alphabetically.
> Please read starting words in list of changes.
Hmm line 96 is "- New :doc:`fuchsia-multiple-inheritance 
` check", while line 101 is "- 
New :doc:`abseil-string-find-startswith 
` check". And similar thing 
happened to line 138. I thought it wasn't alphabetical. But that's probably 
mistakes from others. I will fix this one.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


r329521 - [Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.

2018-04-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Apr  7 23:21:33 2018
New Revision: 329521

URL: http://llvm.org/viewvc/llvm-project?rev=329521=rev
Log:
[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple 
bases.

Summary:
Currently clang doesn't do qualified lookup when building indirect field decl 
references. This causes ambiguity when the field is in a base class to which 
there are multiple valid paths  even though a qualified name is used.

For example:
```
class B {
protected:
 int i;
 union { int j; };
};

class X : public B { };
class Y : public B { };

class Z : public X, public Y {
 int a() { return X::i; } // works
 int b() { return X::j; } // fails
};
```

Reviewers: rsmith, aaron.ballman, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/PR35832.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=329521=329520=329521=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sat Apr  7 23:21:33 2018
@@ -848,7 +848,7 @@ Sema::BuildAnonymousStructUnionMemberRef
 // Build the first member access in the chain with full information.
 result =
 BuildFieldReferenceExpr(result, baseObjectIsPointer, SourceLocation(),
-EmptySS, field, foundDecl, memberNameInfo)
+SS, field, foundDecl, memberNameInfo)
 .get();
 if (!result)
   return ExprError();

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=329521=329520=329521=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Sat Apr  7 23:21:33 2018
@@ -2239,7 +2239,6 @@ public:
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
   // field is always of record type.
-  assert(!QualifierLoc && "Can't have an unnamed field with a qualifier!");
   assert(Member->getType()->isRecordType() &&
  "unnamed member not of record type?");
 

Added: cfe/trunk/test/SemaCXX/PR35832.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR35832.cpp?rev=329521=auto
==
--- cfe/trunk/test/SemaCXX/PR35832.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR35832.cpp Sat Apr  7 23:21:33 2018
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+class B {
+public:
+ int i;
+ struct {  struct { union { int j; }; };  };
+ union { int k; };
+};
+
+class X : public B { };
+class Y : public B { };
+
+class Z : public X, public Y {
+public:
+ int a() { return X::i; }
+ int b() { return X::j; }
+ int c() { return X::k; }
+ int d() { return this->X::j; }
+};


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


[PATCH] D45411: [Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.

2018-04-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 141527.
EricWF added a comment.

I missed a test failure. Reuploading and recommiting latest diff to keep the 
history.


https://reviews.llvm.org/D45411

Files:
  lib/Sema/SemaExprMember.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/PR35832.cpp


Index: test/SemaCXX/PR35832.cpp
===
--- /dev/null
+++ test/SemaCXX/PR35832.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+class B {
+public:
+ int i;
+ struct {  struct { union { int j; }; };  };
+ union { int k; };
+};
+
+class X : public B { };
+class Y : public B { };
+
+class Z : public X, public Y {
+public:
+ int a() { return X::i; }
+ int b() { return X::j; }
+ int c() { return X::k; }
+ int d() { return this->X::j; }
+};
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2239,7 +2239,6 @@
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
   // field is always of record type.
-  assert(!QualifierLoc && "Can't have an unnamed field with a qualifier!");
   assert(Member->getType()->isRecordType() &&
  "unnamed member not of record type?");
 
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -848,7 +848,7 @@
 // Build the first member access in the chain with full information.
 result =
 BuildFieldReferenceExpr(result, baseObjectIsPointer, SourceLocation(),
-EmptySS, field, foundDecl, memberNameInfo)
+SS, field, foundDecl, memberNameInfo)
 .get();
 if (!result)
   return ExprError();


Index: test/SemaCXX/PR35832.cpp
===
--- /dev/null
+++ test/SemaCXX/PR35832.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+class B {
+public:
+ int i;
+ struct {  struct { union { int j; }; };  };
+ union { int k; };
+};
+
+class X : public B { };
+class Y : public B { };
+
+class Z : public X, public Y {
+public:
+ int a() { return X::i; }
+ int b() { return X::j; }
+ int c() { return X::k; }
+ int d() { return this->X::j; }
+};
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2239,7 +2239,6 @@
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
   // field is always of record type.
-  assert(!QualifierLoc && "Can't have an unnamed field with a qualifier!");
   assert(Member->getType()->isRecordType() &&
  "unnamed member not of record type?");
 
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -848,7 +848,7 @@
 // Build the first member access in the chain with full information.
 result =
 BuildFieldReferenceExpr(result, baseObjectIsPointer, SourceLocation(),
-EmptySS, field, foundDecl, memberNameInfo)
+SS, field, foundDecl, memberNameInfo)
 .get();
 if (!result)
   return ExprError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329520 - Revert "[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases."

2018-04-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Apr  7 23:05:33 2018
New Revision: 329520

URL: http://llvm.org/viewvc/llvm-project?rev=329520=rev
Log:
Revert "[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with 
multiple bases."

This reverts commit r329519. There are some unaddressed test failures.

Removed:
cfe/trunk/test/SemaCXX/PR35832.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=329520=329519=329520=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sat Apr  7 23:05:33 2018
@@ -848,7 +848,7 @@ Sema::BuildAnonymousStructUnionMemberRef
 // Build the first member access in the chain with full information.
 result =
 BuildFieldReferenceExpr(result, baseObjectIsPointer, SourceLocation(),
-SS, field, foundDecl, memberNameInfo)
+EmptySS, field, foundDecl, memberNameInfo)
 .get();
 if (!result)
   return ExprError();

Removed: cfe/trunk/test/SemaCXX/PR35832.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR35832.cpp?rev=329519=auto
==
--- cfe/trunk/test/SemaCXX/PR35832.cpp (original)
+++ cfe/trunk/test/SemaCXX/PR35832.cpp (removed)
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-// expected-no-diagnostics
-
-class B {
-public:
- int i;
- struct {  struct { union { int j; }; };  };
-};
-
-class X : public B { };
-class Y : public B { };
-
-class Z : public X, Y {
-public:
- int a() { return X::i; }
- int b() { return X::j; }
- int c() { return this->X::j; }
-};


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