[PATCH] D68413: [clang] [cmake] Add distribution install targets for remaining components

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373695: [clang] [cmake] Add distribution install targets for 
remaining components (authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68413?vs=223109=223141#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68413

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/tools/scan-build/CMakeLists.txt
  cfe/trunk/tools/scan-view/CMakeLists.txt
  cfe/trunk/utils/hmaptool/CMakeLists.txt

Index: cfe/trunk/utils/hmaptool/CMakeLists.txt
===
--- cfe/trunk/utils/hmaptool/CMakeLists.txt
+++ cfe/trunk/utils/hmaptool/CMakeLists.txt
@@ -9,8 +9,15 @@
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL})
 
 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
-install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION bin)
+install(PROGRAMS ${CLANG_HMAPTOOL}
+DESTINATION bin
+COMPONENT hmaptool)
 
 add_custom_target(hmaptool ALL DEPENDS ${Depends})
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 
+if(NOT LLVM_ENABLE_IDE)
+  add_llvm_install_targets("install-hmaptool"
+   DEPENDS hmaptool
+   COMPONENT hmaptool)
+endif()
Index: cfe/trunk/tools/scan-view/CMakeLists.txt
===
--- cfe/trunk/tools/scan-view/CMakeLists.txt
+++ cfe/trunk/tools/scan-view/CMakeLists.txt
@@ -21,7 +21,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-view)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -33,9 +35,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-view/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
-install(FILES share/${ShareFile} DESTINATION share/scan-view)
+install(FILES share/${ShareFile}
+DESTINATION share/scan-view
+COMPONENT scan-view)
   endforeach()
 
   add_custom_target(scan-view ALL DEPENDS ${Depends})
   set_target_properties(scan-view PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-view"
+ DEPENDS scan-view
+ COMPONENT scan-view)
+  endif()
 endif()
Index: cfe/trunk/tools/scan-build/CMakeLists.txt
===
--- cfe/trunk/tools/scan-build/CMakeLists.txt
+++ cfe/trunk/tools/scan-build/CMakeLists.txt
@@ -41,7 +41,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-build)
   endforeach()
 
   foreach(LibexecFile ${LibexecFiles})
@@ -53,7 +55,9 @@
  ${CMAKE_BINARY_DIR}/libexec/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
-install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
+install(PROGRAMS libexec/${LibexecFile}
+DESTINATION libexec
+COMPONENT scan-build)
   endforeach()
 
   foreach(ManPage ${ManPages})
@@ -65,7 +69,9 @@
  ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(PROGRAMS man/${ManPage}
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+COMPONENT scan-build)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -77,9 +83,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
-install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
+install(FILES share/scan-build/${ShareFile}
+DESTINATION share/scan-build
+COMPONENT scan-build)
   endforeach()
 
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build 

[PATCH] D68429: [clang] [cmake] Use add_clang_tool() to install all tools

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Well, they were installed for me, and all of them certainly have `install()` 
command right now. Not sure if there's some high magic making `install()` 
implicitly not install stuff here ;-).


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

https://reviews.llvm.org/D68429



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


r373695 - [clang] [cmake] Add distribution install targets for remaining components

2019-10-03 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Oct  3 22:43:20 2019
New Revision: 373695

URL: http://llvm.org/viewvc/llvm-project?rev=373695=rev
Log:
[clang] [cmake] Add distribution install targets for remaining components

Add install targets as necessary to install bash-autocomplete,
scan-build and scan-view via LLVM_DISTRIBUTION_TARGETS.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/scan-build/CMakeLists.txt
cfe/trunk/tools/scan-view/CMakeLists.txt
cfe/trunk/utils/hmaptool/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=373695=373694=373695=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Oct  3 22:43:20 2019
@@ -441,9 +441,15 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
  COMPONENT clang-headers)
   endif()
 
+  add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
   install(PROGRAMS utils/bash-autocomplete.sh
-DESTINATION share/clang
-)
+  DESTINATION share/clang
+  COMPONENT bash-autocomplete)
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-bash-autocomplete
+ DEPENDS bash-autocomplete
+ COMPONENT bash-autocomplete)
+  endif()
 endif()
 
 add_definitions( -D_GNU_SOURCE )

Modified: cfe/trunk/tools/scan-build/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/CMakeLists.txt?rev=373695=373694=373695=diff
==
--- cfe/trunk/tools/scan-build/CMakeLists.txt (original)
+++ cfe/trunk/tools/scan-build/CMakeLists.txt Thu Oct  3 22:43:20 2019
@@ -41,7 +41,9 @@ if(CLANG_INSTALL_SCANBUILD)
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-build)
   endforeach()
 
   foreach(LibexecFile ${LibexecFiles})
@@ -53,7 +55,9 @@ if(CLANG_INSTALL_SCANBUILD)
  ${CMAKE_BINARY_DIR}/libexec/
DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
-install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
+install(PROGRAMS libexec/${LibexecFile}
+DESTINATION libexec
+COMPONENT scan-build)
   endforeach()
 
   foreach(ManPage ${ManPages})
@@ -65,7 +69,9 @@ if(CLANG_INSTALL_SCANBUILD)
  ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
 list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(PROGRAMS man/${ManPage}
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+COMPONENT scan-build)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -77,9 +83,17 @@ if(CLANG_INSTALL_SCANBUILD)
  ${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
-install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
+install(FILES share/scan-build/${ShareFile}
+DESTINATION share/scan-build
+COMPONENT scan-build)
   endforeach()
 
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-build"
+ DEPENDS scan-build
+ COMPONENT scan-build)
+  endif()
 endif()

Modified: cfe/trunk/tools/scan-view/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/CMakeLists.txt?rev=373695=373694=373695=diff
==
--- cfe/trunk/tools/scan-view/CMakeLists.txt (original)
+++ cfe/trunk/tools/scan-view/CMakeLists.txt Thu Oct  3 22:43:20 2019
@@ -21,7 +21,9 @@ if(CLANG_INSTALL_SCANVIEW)
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-view)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -33,9 +35,17 @@ 

[PATCH] D68423: [clang-tools-extra] [cmake] Use add_clang_tool() to install tools

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373694: [clang-tools-extra] [cmake] Use add_clang_tool() to 
install tools (authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68423?vs=223093=223138#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68423

Files:
  clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt
  
clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt
  clang-tools-extra/trunk/pp-trace/CMakeLists.txt

Index: clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt
@@ -4,7 +4,7 @@
   Support
   )
 
-add_clang_executable(clang-change-namespace
+add_clang_tool(clang-change-namespace
   ClangChangeNamespace.cpp
   )
 target_link_libraries(clang-change-namespace
@@ -20,6 +20,3 @@
   clangTooling
   clangToolingCore
   )
-
-install(TARGETS clang-change-namespace
-  RUNTIME DESTINATION bin)
Index: clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-move
+add_clang_tool(clang-move
   ClangMove.cpp
   )
 
Index: clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-query
+add_clang_tool(clang-query
   ClangQuery.cpp
   )
 target_link_libraries(clang-query
@@ -14,5 +14,3 @@
   clangSerialization
   clangTooling
   )
-
-install(TARGETS clang-query RUNTIME DESTINATION bin)
Index: clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
@@ -14,6 +14,3 @@
   clangToolingCore
   clangToolingRefactoring
   )
-
-install(TARGETS clang-apply-replacements
-  RUNTIME DESTINATION bin)
Index: clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt
@@ -17,9 +17,6 @@
   findAllSymbols
   )
 
-install(TARGETS clang-include-fixer
-  RUNTIME DESTINATION bin)
-
 install(PROGRAMS clang-include-fixer.el
   DESTINATION share/clang
   COMPONENT clang-include-fixer)
Index: clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols
+add_clang_tool(find-all-symbols
   FindAllSymbolsMain.cpp
   )
 
@@ -16,9 +16,6 @@
   findAllSymbols
   )
 
-install(TARGETS find-all-symbols
-  RUNTIME DESTINATION bin)
-
 install(PROGRAMS run-find-all-symbols.py
   DESTINATION share/clang
   COMPONENT find-all-symbols)
Index: clang-tools-extra/trunk/pp-trace/CMakeLists.txt
===
--- clang-tools-extra/trunk/pp-trace/CMakeLists.txt
+++ clang-tools-extra/trunk/pp-trace/CMakeLists.txt
@@ -2,7 +2,7 @@
   Support
   )
 
-add_clang_executable(pp-trace
+add_clang_tool(pp-trace
   PPTrace.cpp
   PPCallbacksTracker.cpp
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r373694 - [clang-tools-extra] [cmake] Use add_clang_tool() to install tools

2019-10-03 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Oct  3 22:40:29 2019
New Revision: 373694

URL: http://llvm.org/viewvc/llvm-project?rev=373694=rev
Log:
[clang-tools-extra] [cmake] Use add_clang_tool() to install tools

Replace add_clang_executable() calls with add_clang_tool() that takes
care of creating correct, distribution-friendly install target.  While
at it, remove redundant install calls.

This change also causes clang-move and pp-trace to be installed.

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

Modified:
clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt

clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt
clang-tools-extra/trunk/pp-trace/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt?rev=373694=373693=373694=diff
==
--- clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt Thu 
Oct  3 22:40:29 2019
@@ -14,6 +14,3 @@ target_link_libraries(clang-apply-replac
   clangToolingCore
   clangToolingRefactoring
   )
-
-install(TARGETS clang-apply-replacements
-  RUNTIME DESTINATION bin)

Modified: clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt?rev=373694=373693=373694=diff
==
--- clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-change-namespace/tool/CMakeLists.txt Thu Oct  
3 22:40:29 2019
@@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-add_clang_executable(clang-change-namespace
+add_clang_tool(clang-change-namespace
   ClangChangeNamespace.cpp
   )
 target_link_libraries(clang-change-namespace
@@ -20,6 +20,3 @@ target_link_libraries(clang-change-names
   clangTooling
   clangToolingCore
   )
-
-install(TARGETS clang-change-namespace
-  RUNTIME DESTINATION bin)

Modified: 
clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt?rev=373694=373693=373694=diff
==
--- 
clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
 (original)
+++ 
clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
 Thu Oct  3 22:40:29 2019
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols
+add_clang_tool(find-all-symbols
   FindAllSymbolsMain.cpp
   )
 
@@ -16,9 +16,6 @@ target_link_libraries(find-all-symbols
   findAllSymbols
   )
 
-install(TARGETS find-all-symbols
-  RUNTIME DESTINATION bin)
-
 install(PROGRAMS run-find-all-symbols.py
   DESTINATION share/clang
   COMPONENT find-all-symbols)

Modified: clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt?rev=373694=373693=373694=diff
==
--- clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-include-fixer/tool/CMakeLists.txt Thu Oct  3 
22:40:29 2019
@@ -17,9 +17,6 @@ target_link_libraries(clang-include-fixe
   findAllSymbols
   )
 
-install(TARGETS clang-include-fixer
-  RUNTIME DESTINATION bin)
-
 install(PROGRAMS clang-include-fixer.el
   DESTINATION share/clang
   COMPONENT clang-include-fixer)

Modified: clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt?rev=373694=373693=373694=diff
==
--- clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-move/tool/CMakeLists.txt Thu Oct  3 22:40:29 
2019
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-move
+add_clang_tool(clang-move
   ClangMove.cpp
   )
 

Modified: clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt?rev=373694=373693=373694=diff

[PATCH] D67775: [Sema] Split out -Wformat-type-confusion from -Wformat-pedantic

2019-10-03 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/test/Sema/format-strings-pedantic.c:1
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-type-confusion %s
 

aaron.ballman wrote:
> Are we losing test coverage for `-Wformat-pedantic`, or do we have other 
> tests covering that elsewhere? I would have expected this test file's 
> contents to exercise pedantic cases.
The only warning that was in this file is now under -Wformat-type-confusion. 
New patch adds a test for the `printf("%p", (int*)0);` thing, which was 
otherwise untested.



Comment at: clang/test/Sema/format-type-confusion.c:13
+ b, // expected-warning {{format specifies type 'unsigned short' but 
the argument has type '_Bool'}}
+ b, b, b, b, b);
+

aaron.ballman wrote:
> Just double-checking, but the reason we don't diagnose the `%c` here is 
> because of `-Wno-format`?
Yup, exactly. I just wanted to test -Wformat-type-confusion alone in this file. 


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

https://reviews.llvm.org/D67775



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


[PATCH] D67775: [Sema] Split out -Wformat-type-confusion from -Wformat-pedantic

2019-10-03 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 223136.
erik.pilkington marked 6 inline comments as done.
erik.pilkington added a comment.

Address review comments.


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

https://reviews.llvm.org/D67775

Files:
  clang/include/clang/AST/FormatString.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/format-bool.c
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-type-confusion.c

Index: clang/test/Sema/format-type-confusion.c
===
--- /dev/null
+++ clang/test/Sema/format-type-confusion.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0 -fsyntax-only -verify -Wno-format -Wformat-type-confusion %s
+
+__attribute__((format(__printf__, 1, 2)))
+int printf(const char *msg, ...);
+
+#define FMT "%hd %hu %d %u %hhd %hhu %c"
+
+int main() {
+  _Bool b = 0;
+  printf(FMT,
+ b, // expected-warning {{format specifies type 'short' but the argument has type '_Bool'}}
+ b, // expected-warning {{format specifies type 'unsigned short' but the argument has type '_Bool'}}
+ b, b, b, b, b);
+
+  unsigned char uc = 0;
+  printf(FMT,
+ uc, // expected-warning {{format specifies type 'short' but the argument has type 'unsigned char'}}
+ uc, // expected-warning {{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
+ uc, uc, uc, uc, uc);
+
+  signed char sc = 0;
+  printf(FMT,
+ sc, // expected-warning {{format specifies type 'short' but the argument has type 'signed char'}}
+ sc, // expected-warning {{format specifies type 'unsigned short' but the argument has type 'signed char'}}
+ sc, sc, sc, sc, sc);
+}
Index: clang/test/Sema/format-strings-pedantic.c
===
--- clang/test/Sema/format-strings-pedantic.c
+++ clang/test/Sema/format-strings-pedantic.c
@@ -1,10 +1,20 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem %S/Inputs %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
+// RUN: %clang_cc1 -xobjective-c -fblocks -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
+// RUN: %clang_cc1 -xc++ -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
 
+__attribute__((format(printf, 1, 2)))
 int printf(const char *restrict, ...);
 
-typedef unsigned char uint8_t;
+int main() {
+  printf("%p", (int *)0); // expected-warning {{format specifies type 'void *' but the argument has type 'int *'}}
+  printf("%p", (void *)0);
 
-void print_char_as_short() {
-  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned char')}}
+#ifdef __OBJC__
+  printf("%p", ^{}); // expected-warning {{format specifies type 'void *' but the argument has type 'void (^)(void)'}}
+  printf("%p", (id)0); // expected-warning {{format specifies type 'void *' but the argument has type 'id'}}
+#endif
+
+#ifdef __cplusplus
+  printf("%p", nullptr); // expected-warning {{format specifies type 'void *' but the argument has type 'nullptr_t'}}
+#endif
 }
Index: clang/test/Sema/format-bool.c
===
--- clang/test/Sema/format-bool.c
+++ clang/test/Sema/format-bool.c
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -xc %s -verify -DBOOL=_Bool
 // RUN: %clang_cc1 -xc++ %s -verify -DBOOL=bool
 // RUN: %clang_cc1 -xobjective-c %s -verify -DBOOL=_Bool
-// RUN: %clang_cc1 -xc %s -verify -DBOOL=_Bool -Wformat-pedantic -DPEDANTIC
-// RUN: %clang_cc1 -xc++ %s -verify -DBOOL=bool -Wformat-pedantic -DPEDANTIC
+// RUN: %clang_cc1 -xc %s -verify -DBOOL=_Bool -Wformat-type-confusion -DTYPE_CONF
+// RUN: %clang_cc1 -xc++ %s -verify -DBOOL=bool -Wformat-type-confusion -DTYPE_CONF
 
 __attribute__((format(__printf__, 1, 2)))
 int p(const char *fmt, ...);
@@ -22,13 +22,13 @@
 int main() {
   p("%d", b);
   p("%hd", b);
-#ifdef PEDANTIC
+#ifdef TYPE_CONF
   // expected-warning@-2 {{format specifies type 'short' but the argument has type}}
 #endif
   p("%hhd", b);
   p("%u", b);
   p("%hu", b);
-#ifdef PEDANTIC
+#ifdef TYPE_CONF
   // expected-warning@-2 {{format specifies type 'unsigned short' but the argument has type}}
 #endif
   p("%hhu", b);
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8172,9 +8172,7 @@
 return true;
   }
 
-  const analyze_printf::ArgType::MatchKind Match =
-  AT.matchesType(S.Context, ExprTy);
-  bool Pedantic = Match == 

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Just linking relevant bug for the record: 
https://bugs.llvm.org/show_bug.cgi?id=43517

Also, I'm fairly certain `__forceinline` and `always_inline`, confusingly 
enough differ in semantics, with `__forceinline` only being a stronger hint on 
MSVC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-10-03 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:631
+  MachineBasicBlock::iterator NewMI =
+  BuildMI(MBB, MI, DL, TII.get(RISCV::PseudoCALL))
+  .add(MI->getOperand(0));

apazos wrote:
> Where are we making sure the PseudoCALL result in a0 is alive through the 
> riscv_restore call?
I did not find any other target that transforms a tail call back into a regular 
call.

The issue with doing this is that we don't have info about the return value of 
the original call.

If anyone knows how to do it, please give me some pointers.

I tried to fix this problem by adding implicit operands to  the riscv_restore 
tail call that are all the possible return value registers:
BuildMI(MBB, MI, DL, TII.get(RISCV::PseudoTAIL))
.addExternalSymbol(RestoreLibCall, RISCVII::MO_CALL)
-.setMIFlag(MachineInstr::FrameDestroy);
+.setMIFlag(MachineInstr::FrameDestroy)
+.addReg(RISCV::X10, RegState::Implicit)
+.addReg(RISCV::X11, RegState::Implicit)
+.addReg(RISCV::F10_F, RegState::Implicit)
+.addReg(RISCV::F11_F, RegState::Implicit)

With this change, some perennial tests now pass.

But there are still failures to be analyzed in SPEC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-10-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added a comment.

In D67536#1691107 , @hokein wrote:

> Could you add tests for this?


Certainly, I just wanted to discuss the general approach first, as it will 
affect what the tests look like.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:152
+  // Don't bother computing the offset for the end of the line, just 
use
+  // zero. The client will treat this highlighting kind specially, and
+  // highlight the entire line visually (i.e. not just to where the 
text

hokein wrote:
> This seems too couple with VSCode client, I would prefer to calculate the 
> range of the line and return to the client.
> 
> Is there any big differences in VSCode between highlighting with the 
> `isWholeLine` and highlighting with the range of the line? 
I took some screenshots to illustrate to difference.

Highlighting only to the end of the line of text:

{F10158508}

Highlighting the whole line:

{F10158515}

I think the first one looks pretty bad, and is inconsistent with existing 
practice.

Note also that the suggestion is not to special-case the VSCode client 
specifically; it's to special-case one particular highlighting, which any 
client can implement.

If this special-casing is really unpalatable, we could instead try this 
suggestion by @sammccall:

> Failing that, I'd suggest encoding a list of line-styles on 
> SemanticHighlightingInformation, that should be combined with any tokens on 
> that line.

I guess one consideration when evaluating these options is, do we expect to use 
that "list of line-styles" for anything else in the future? I can't think of 
anything at the moment, but perhaps there are other uses for it.

If not, we could do something slightly simpler, and add a single `isInactive` 
flag to `SemanticHighlightingInformation`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536



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


[PATCH] D68436: [clang-scan-deps] Improve string/character literal skipping

2019-10-03 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added inline comments.



Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:205
+  return;
+if (*First == '\\') {
+  if (++First == End)

Should you also check if the character right after a backslash is equal to 
Terminator and if it is, continue on without terminating? The case I'm thinking 
of is:

```
#define FOO "FOO \"doublequote\""
```

The testcase would be something like:

```
StringRef Source = "#define FOO \"FOO \\\"doublequote\\\"\"
... do rest
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68436



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


[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

One last idea is that we could teach LLD to automatically add this directory to 
library search path, but then users who link with Visual C++ (not many anymore) 
will run into this as a corner case issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65543



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


[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D65543#1691819 , @mstorsjo wrote:

> Another slightly related thread, regarding libs from the clang resource dir 
> and how they are specified to the linker (regarding the builtins library): 
> https://reviews.llvm.org/D51440


I support that effort. :)

In D65543#1687974 , @russell.gallop 
wrote:

> This does indeed break PGO self-host with lld-link (applied on top of 
> r373200):
>
>   <...>\bin\lld-link.exe /nologo utils\not\CMakeFiles\not.dir\not.cpp.obj 
> utils\not\CMakeFiles\not.dir\__\__\resources\windows_version_resource.rc.res 
> /out:bin\not.exe /implib:lib\not.lib /pdb:bin\not.pdb /version:0.0 
> /machine:x64 -fuse-ld=lld /STACK:1000 /INCREMENTAL:NO /subsystem:console 
> lib\LLVMSupport.lib psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib 
> delayimp.lib -delayload:shell32.dll -delayload:ole32.dll lib\LLVMDemangle.lib 
> kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib 
> oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST 
> /MANIFESTFILE:bin\not.exe.manifest
>   lld-link: warning: ignoring unknown argument '-fuse-ld=lld'
>   lld-link: error: could not open 'clang_rt.profile-x86_64.lib': no such file 
> or directory
>
>
> So at the very least this change would need that path adding.


I added a fragment to HandleLLVMOptions.cmake to ask clang for its resource 
directory and add it to the search path when compiling with instrumentation or 
sanitizers. I think it's not so bad, and we don't have to write down the 
version.

> I agree with Nico that having to add a path dependent on the LLVM version 
> sounds like a pain.
> 
> Is it possible for the compiler to embed a /libpath as well as the dependent 
> lib? That goes back to having a path embedded, though you could override it 
> if required so could be an improvement over things at the moment.

Nope, I tried it, got this:

  t.obj : warning LNK4229: invalid directive '/libpath:foo' encountered; ignored

> It sounds to me like:
> 
>> ...folks have to explicitly pass 
>> /libpath:\path\to\clang\lib\clang\$changing_version\lib\windows to the 
>> linker, which to me is a pretty poor experience
> 
> and
> 
>> I'd like to get away from having paths embedded in the object if possible.
> 
> are hard to reconcile.

True.

> It may be possible to have the Windows installer add the path to LIB 
> environment variable but that would rely on having run the installer, and 
> could cause problems if you have multiple versions of LLVM around.

Well, and I wouldn't want to follow Microsoft down the route of increasing 
dependence on the environment.

In D65543#1687338 , @thakis wrote:

> If you strongly feel that this is the right direction, go for it, you're code 
> owner here :)


I think I do feel strongly about it, but I don't want to be too pushy. :)

> To me, this feels like a regression. This change has no benefit that I can 
> see (at least none that anybody's asked for that I'm aware of – then again I 
> read llvm's bugzilla less than you do), and the drawback that folks have to 
> explicitly pass 
> `/libpath:\path\to\clang\lib\clang\$changing_version\lib\windows` to the 
> linker, which to me is a pretty poor experience. I'd prefer if we used this 
> qualified path for all runtime libs, so that users would never have to use 
> this libpath. (We currently use a qualified path for libprofile but not asan 
> and the like iirc.)

libgcc follows a similar model, FWIW, it lives in a compiler-version-dependent 
path. The difference just happens to be that, on this particular platform, 
there's no compiler driver running the link to paper over this detail for the 
user.

LLVM has a lot of runtime libraries these days:

- profile (pgo & coverage)
- asan, ubsan, msan, tsan, sancov
- libfuzzer
- openmp
- libc++
- parallel stl

It doesn't seem so bad to document that, if you want to use LLVM 
instrumentation tools, you have to add one library search path. So, speaking of 
documentation, we don't really have good holistic instructions for how to use 
clang-cl. Where is the most obvious place to put this? The main one I know 
about and haven't done yet is the release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65543



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D68430#1693964 , @jordan_rose wrote:

> I'm not quite sure //what// it's doing. The executable targets end up trying 
> to link against the static libraries anyway, which of course haven't been 
> built. It's possible that this is because the LIBTYPE is both STATIC and 
> OBJECT and if it were just OBJECT we might be better off, but I'm not sure if 
> Xcode's IDE features will be happy with a target that doesn't actually 
> produce a library. I can try it if you want, though.


I don't think that is necessary, it sounds like we just need to disable this 
functionality if Xcode is the build tool. That is unfortunate, but Xcode's 
build system is problematic to work with.

> (I did look at CMake's Xcode generator logic for OBJECT targets and it looks 
> completely bonkers to me, as if it's still building the static library but 
> then removing it to make sure it's not depended on or something. Even if it 
> builds cleanly I don't trust it to do dependency analysis correctly.)

Fair. Unfortunately Xcode's build dependencies aren't as expressive as other 
build systems, which causes some unfortunate limitations on what it can do.

> 
> 
>> This has the side-effect of making `libclang_cpp` effectively empty when you 
>> build with Xcode.
> 
> I can remove that target if you want, or have it link the libraries normally.

clang_cpp can't link the libraries "normally" because it has no unresolved 
symbols to force the contents of the libraries to link. I don't like it, but I 
think the best option is to disable clang_cpp under Xcode. You can add `AND 
XCODE` to the `if` on line 2 of clang/tools/clang-shlib/CMakeLists.txt, and 
that should do the trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


r373685 - Properly handle instantiation-dependent array bounds.

2019-10-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  3 18:25:59 2019
New Revision: 373685

URL: http://llvm.org/viewvc/llvm-project?rev=373685=rev
Log:
Properly handle instantiation-dependent array bounds.

We previously failed to treat an array with an instantiation-dependent
but not value-dependent bound as being an instantiation-dependent type.
We now track the array bound expression as part of a constant array type
if it's an instantiation-dependent expression.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=373685=373684=373685=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Oct  3 18:25:59 2019
@@ -185,7 +185,8 @@ private:
   mutable llvm::FoldingSet LValueReferenceTypes;
   mutable llvm::FoldingSet RValueReferenceTypes;
   mutable llvm::FoldingSet MemberPointerTypes;
-  mutable llvm::FoldingSet ConstantArrayTypes;
+  mutable llvm::ContextualFoldingSet
+  ConstantArrayTypes;
   mutable llvm::FoldingSet IncompleteArrayTypes;
   mutable std::vector VariableArrayTypes;
   mutable llvm::FoldingSet DependentSizedArrayTypes;
@@ -1330,6 +1331,7 @@ public:
   /// Return the unique reference to the type for a constant array of
   /// the specified element type.
   QualType getConstantArrayType(QualType EltTy, const llvm::APInt ,
+const Expr *SizeExpr,
 ArrayType::ArraySizeModifier ASM,
 unsigned IndexTypeQuals) const;
 

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=373685=373684=373685=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Oct  3 18:25:59 2019
@@ -959,8 +959,11 @@ DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO
 
 DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
 
-DEF_TRAVERSE_TYPE(ConstantArrayType,
-  { TRY_TO(TraverseType(T->getElementType())); })
+DEF_TRAVERSE_TYPE(ConstantArrayType, {
+  TRY_TO(TraverseType(T->getElementType()));
+  if (T->getSizeExpr())
+TRY_TO(TraverseStmt(const_cast(T->getSizeExpr(;
+})
 
 DEF_TRAVERSE_TYPE(IncompleteArrayType,
   { TRY_TO(TraverseType(T->getElementType())); })

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=373685=373684=373685=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Oct  3 18:25:59 2019
@@ -1513,6 +1513,15 @@ protected:
 unsigned SizeModifier : 3;
   };
 
+  class ConstantArrayTypeBitfields {
+friend class ConstantArrayType;
+
+unsigned : NumTypeBits + 3 + 3;
+
+/// Whether we have a stored size expression.
+unsigned HasStoredSizeExpr : 1;
+  };
+
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
@@ -1734,6 +1743,7 @@ protected:
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
+ConstantArrayTypeBitfields ConstantArrayTypeBits;
 AttributedTypeBitfields AttributedTypeBits;
 AutoTypeBitfields AutoTypeBits;
 BuiltinTypeBitfields BuiltinTypeBits;
@@ -2864,22 +2874,8 @@ private:
 protected:
   friend class ASTContext; // ASTContext creates these.
 
-  // C++ [temp.dep.type]p1:
-  // 

[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

I'm not quite sure //what// it's doing. The executable targets end up trying to 
link against the static libraries anyway, which of course haven't been built. 
It's possible that this is because the LIBTYPE is both STATIC and OBJECT and if 
it were just OBJECT we might be better off, but I'm not sure if Xcode's IDE 
features will be happy with a target that doesn't actually produce a library. I 
can try it if you want, though.

(I did look at CMake's Xcode generator logic for OBJECT targets and it looks 
completely bonkers to me, as if it's still building the static library but then 
removing it to make sure it's not depended on or something. Even if it builds 
cleanly I don't trust it to do dependency analysis correctly.)

> This has the side-effect of making `libclang_cpp` effectively empty when you 
> build with Xcode.

I can remove that target if you want, or have it link the libraries normally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 223128.
rnk added a comment.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.

- Fix PGO build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65543

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/sanitizer-ld.c
  llvm/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -850,6 +850,27 @@
   endif()
 endif()
 
+# When using clang-cl with an instrumentation-based tool, add clang's library
+# resource directory to the library search path. Because cmake invokes the
+# linker directly, it isn't sufficient to pass -fsanitize=* to the linker.
+if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
+  execute_process(
+COMMAND ${CMAKE_CXX_COMPILER} /clang:-print-resource-dir
+OUTPUT_VARIABLE clang_resource_dir
+ERROR_VARIABLE clang_cl_stderr
+OUTPUT_STRIP_TRAILING_WHITESPACE
+ERROR_STRIP_TRAILING_WHITESPACE
+RESULT_VARIABLE clang_cl_exit_code)
+  if (NOT "${clang_cl_exit_code}" STREQUAL "0")
+message(FATAL_ERROR
+  "Unable to invoke clang-cl to find resource dir: ${clang_cl_stderr}")
+  endif()
+  file(TO_CMAKE_PATH "${clang_resource_dir}" clang_resource_dir)
+  append("/libpath:${clang_resource_dir}/lib/windows"
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
+
 if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
   if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
 append("-fprofile-instr-use=\"${LLVM_PROFDATA_FILE}\""
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -656,16 +656,16 @@
 // RUN: -target x86_64-pc-windows \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN64 %s
-// CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats_client-x86_64.lib"
-// CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats-x86_64.lib"
+// CHECK-CFI-STATS-WIN64: "--dependent-lib=clang_rt.stats_client-x86_64.lib"
+// CHECK-CFI-STATS-WIN64: "--dependent-lib=clang_rt.stats-x86_64.lib"
 // CHECK-CFI-STATS-WIN64: "--linker-option=/include:__sanitizer_stats_register"
 
 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
 // RUN: -target i686-pc-windows \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN32 %s
-// CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats_client-i386.lib"
-// CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats-i386.lib"
+// CHECK-CFI-STATS-WIN32: "--dependent-lib=clang_rt.stats_client-i386.lib"
+// CHECK-CFI-STATS-WIN32: "--dependent-lib=clang_rt.stats-i386.lib"
 // CHECK-CFI-STATS-WIN32: "--linker-option=/include:___sanitizer_stats_register"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -67,11 +67,11 @@
 
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
-// CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+// CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib=clang_rt.profile-{{[^"]*}}.lib"
 // CHECK-PROFILE-INSTR-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 
 // RUN: %clang_cl -### /FA -fprofile-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib=clang_rt.profile-{{[^"]*}}.lib"
 
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -344,6 

[PATCH] D68436: [clang-scan-deps] Improve string/character literal skipping

2019-10-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: dexonsmith, Bigcheese, aganea, kousikk.
Herald added subscribers: ributzka, tschuett, jkorous.
Herald added a project: clang.

The existing string/character literal skipping code in the dependency 
directives source minimizer has two issues:

- It doesn't stop the scanning when a newline is reached before the terminating 
character, unlike the lexer which considers the token to be done (even if it's 
invalid) at the end of the line.
- It doesn't support whitespace between '\' and the newline when looking if the 
'\' is used as a line continuation character.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68436

Files:
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -583,6 +583,50 @@
   EXPECT_STREQ("#pragma once\n#include \n", Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest,
+ SkipLineStringCharLiteralsUntilNewline) {
+  SmallVector Out;
+
+  StringRef Source = R"(#if NEVER_ENABLED
+#define why(fmt, ...) #error don't try me
+#endif
+
+void foo();
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ(
+  "#if NEVER_ENABLED\n#define why(fmt,...) #error don't try me\n#endif\n",
+  Out.data());
+
+  Source = R"(#if NEVER_ENABLED
+  #define why(fmt, ...) "quote dropped
+  #endif
+
+  void foo();
+  )";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ(
+  "#if NEVER_ENABLED\n#define why(fmt,...) \"quote dropped\n#endif\n",
+  Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest,
+ SupportWhitespaceBeforeLineContinuationInStringSkipping) {
+  SmallVector Out;
+
+  StringRef Source = "#define X '\\ \t\nx'\nvoid foo() {}";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#define X '\\ \t\nx'\n", Out.data());
+
+  Source = "#define X \"\\ \r\nx\"\nvoid foo() {}";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#define X \"\\ \r\nx\"\n", Out.data());
+
+  Source = "#define X \"\\ \r\nx\n#include \n";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#define X \"\\ \r\nx\n#include \n", Out.data());
+}
+
 TEST(MinimizeSourceToDependencyDirectivesTest, CxxModules) {
   SmallVector Out;
   SmallVector Tokens;
Index: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -185,17 +185,6 @@
   }
 }
 
-static void skipString(const char *, const char *const End) {
-  assert(*First == '\'' || *First == '"' || *First == '<');
-  const char Terminator = *First == '<' ? '>' : *First;
-  for (++First; First != End && *First != Terminator; ++First)
-if (*First == '\\')
-  if (++First == End)
-return;
-  if (First != End)
-++First; // Finish off the string.
-}
-
 // Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
 static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
@@ -206,6 +195,32 @@
   return !!isVerticalWhitespace(First[0]);
 }
 
+static void skipString(const char *, const char *const End) {
+  assert(*First == '\'' || *First == '"' || *First == '<');
+  const char Terminator = *First == '<' ? '>' : *First;
+  for (++First; First != End && *First != Terminator; ++First) {
+// String and character literals don't extend past the end of the line.
+if (isVerticalWhitespace(*First))
+  return;
+if (*First == '\\') {
+  if (++First == End)
+return;
+  if (isWhitespace(*First)) {
+const char *FirstAfterBackslashPastSpace = First;
+skipOverSpaces(FirstAfterBackslashPastSpace, End);
+if (unsigned NLSize = isEOL(FirstAfterBackslashPastSpace, End)) {
+  // Advance the character pointer to the next line for the next
+  // iteration.
+  First = FirstAfterBackslashPastSpace + NLSize - 1;
+  continue;
+}
+  }
+}
+  }
+  if (First != End)
+++First; // Finish off the string.
+}
+
 // Returns the length of the skipped newline
 static unsigned skipNewline(const char *, const char *End) {
   if (First == End)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Buildbot numbers for the week of 09/15/2019 - 09/21/2019

2019-10-03 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 09/15/2019 - 09/21/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 clang-s390x-linux-multistage | 95:02:28
 clang-s390x-linux-lnt| 84:48:38
 clang-s390x-linux| 84:18:59
 ppc64le-lld-multistage-test  | 74:16:36
 clang-ppc64be-linux-lnt  | 55:33:08
 llvm-clang-x86_64-expensive-checks-win   | 50:58:43
 clang-ppc64le-linux-multistage   | 33:41:10
 sanitizer-windows| 26:43:33
 sanitizer-x86_64-linux-fast  | 24:47:10
 sanitizer-ppc64be-linux  | 24:09:00
 sanitizer-x86_64-linux-bootstrap | 23:52:50
 sanitizer-x86_64-linux-bootstrap-msan| 22:36:02
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan| 21:59:38
 clang-cuda-build | 19:51:42
 clang-lld-x86_64-2stage  | 19:35:24
 sanitizer-x86_64-linux-android   | 16:45:08
 clang-with-lto-ubuntu| 16:30:45
 clang-with-thin-lto-ubuntu   | 13:41:36
 clang-cmake-aarch64-lld  | 12:58:43
 lldb-x64-windows-ninja   | 12:43:28
 clang-ppc64be-linux-multistage   | 12:07:36
 clang-cmake-armv7-full   | 11:05:59
 clang-cmake-x86_64-sde-avx512-linux  | 10:59:56
 clang-ppc64le-linux  | 10:45:58
 clang-x64-windows-msvc   | 10:08:58
 reverse-iteration| 09:46:09
 sanitizer-x86_64-linux-bootstrap-ubsan   | 09:40:49
 clang-x86_64-debian-fast | 09:36:37
 lld-x86_64-ubuntu-fast   | 09:36:27
 clang-atom-d525-fedora-rel   | 09:36:27
 sanitizer-ppc64le-linux  | 09:02:50
 clang-ppc64le-linux-lnt  | 09:02:06
 clang-cmake-aarch64-full | 08:29:31
 clang-ppc64be-linux  | 08:16:42
 sanitizer-x86_64-linux   | 08:01:53
 clang-cmake-thumbv7-full-sh  | 07:38:25
 clang-cmake-armv7-selfhost-neon  | 05:19:44
 clang-cmake-armv7-selfhost   | 04:25:43
 clang-cmake-armv8-lld| 03:53:49
 clang-cmake-armv7-global-isel| 03:12:29
 clang-cmake-aarch64-global-isel  | 02:54:27
 clang-cmake-aarch64-quick| 02:39:56
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 02:37:28
 clang-cmake-armv7-lnt| 02:27:21
 clang-cmake-armv7-quick  | 01:47:21
 clang-cmake-x86_64-avx2-linux| 01:37:20
 sanitizer-x86_64-linux-fuzzer| 01:33:21
 clang-hexagon-elf| 01:30:49
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 01:19:45
 sanitizer-x86_64-linux-autoconf  | 01:09:03
 clang-x86_64-linux-abi-test  | 01:08:07
 lld-x86_64-win7  | 01:06:30
 lld-perf-testsuite   | 01:01:44
 llvm-clang-x86_64-win-fast   | 01:01:16
 lld-x86_64-darwin13  | 00:57:16
 lld-x86_64-freebsd   | 00:54:03
 clang-tools-sphinx-docs  | 00:51:38
 polly-arm-linux  | 00:45:45
 clang-sphinx-docs| 00:45:10
 llvm-hexagon-elf | 00:39:51
 clang-armv7-linux-build-cache| 00:37:18
 llvm-sphinx-docs | 00:32:24
 clang-aarch64-linux-build-cache  | 00:32:01
(63 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   buildername   | builds | changes
| status_change_ratio
-++-+
 sanitizer-x86_64-linux  | 93 

Buildbot numbers for the week of 09/22/2019 - 09/28/2019

2019-10-03 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 09/22/2019 -
09/28/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   | was_red
-+-
 clang-cmake-armv7-selfhost-neon | 90:20:13
 clang-cmake-armv7-selfhost  | 79:48:52
 clang-cmake-armv7-global-isel   | 79:47:33
 netbsd-amd64| 75:01:51
 llvm-clang-x86_64-expensive-checks-win  | 51:12:31
 clang-x64-windows-msvc  | 29:49:30
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 29:48:26
 clang-lld-x86_64-2stage | 16:05:29
 lldb-x64-windows-ninja  | 14:25:32
 sanitizer-x86_64-linux-bootstrap-msan   | 13:51:46
 sanitizer-x86_64-linux-fast | 12:50:47
 clang-with-lto-ubuntu   | 12:40:12
 sanitizer-x86_64-linux  | 12:23:26
 clang-ppc64be-linux-multistage  | 12:00:55
 sanitizer-x86_64-linux-bootstrap| 11:08:07
 clang-with-thin-lto-ubuntu  | 10:57:10
 ppc64le-lld-multistage-test | 10:33:00
 sanitizer-ppc64be-linux | 10:13:48
 clang-ppc64le-linux-multistage  | 09:11:38
 clang-cmake-armv7-full  | 09:09:00
 sanitizer-ppc64le-linux | 08:47:05
 clang-cmake-thumbv7-full-sh | 08:18:33
 clang-s390x-linux-multistage| 08:00:46
 clang-ppc64le-linux | 06:48:50
 clang-ppc64le-linux-lnt | 06:44:24
 clang-s390x-linux-lnt   | 06:38:59
 clang-s390x-linux   | 06:37:23
 clang-cmake-aarch64-full| 06:20:51
 sanitizer-x86_64-linux-android  | 06:14:17
 clang-ppc64be-linux-lnt | 06:13:36
 clang-ppc64be-linux | 06:11:42
 clang-cmake-aarch64-lld | 04:54:29
 clang-cmake-aarch64-quick   | 03:53:06
 sanitizer-x86_64-linux-bootstrap-ubsan  | 03:26:28
 clang-atom-d525-fedora-rel  | 03:21:01
 clang-hexagon-elf   | 02:53:03
 sanitizer-windows   | 02:48:57
 clang-cuda-build| 02:45:01
 clang-x86_64-debian-fast| 02:43:49
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 02:26:44
 clang-cmake-aarch64-global-isel | 02:22:13
 llvm-clang-x86_64-win-fast  | 02:14:58
 clang-cmake-armv7-lnt   | 02:12:08
 lld-x86_64-win7 | 02:09:40
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11 | 01:54:57
 clang-cmake-armv7-quick | 01:40:33
 clang-cmake-x86_64-sde-avx512-linux | 01:39:47
 clang-cmake-x86_64-avx2-linux   | 01:38:10
 reverse-iteration   | 01:37:36
 clang-x86_64-linux-abi-test | 01:21:36
 clang-cmake-armv8-lld   | 01:20:08
 sanitizer-x86_64-linux-fuzzer   | 01:09:57
 clang-tools-sphinx-docs | 01:07:55
 polly-arm-linux | 01:07:30
 clang-cmake-x86_64-avx2-linux-perf  | 01:07:00
 llvm-hexagon-elf| 00:53:25
 clang-aarch64-linux-build-cache | 00:41:08
 lld-x86_64-ubuntu-fast  | 00:39:48
 clang-armv7-linux-build-cache   | 00:36:23
 lld-perf-testsuite  | 00:27:57
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 00:25:12
 sanitizer-x86_64-linux-autoconf | 00:25:03
 

[PATCH] D68429: [clang] [cmake] Use add_clang_tool() to install all tools

2019-10-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Are these tools intended to be installed? I thought they were developer focused 
tools. I don't think we should make install targets for things that the project 
doesn't want to support publicly.

This also changes the behavior of the `install` target to include these extra 
tools, which will increase the size of installs that many people are using 
today with these tools. At the very least if we go down this direction we need 
to add some option like `LLVM_INSTALL_TOOLCHAIN_ONLY` so that we don't 
radically alter the current `install` behavior.


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

https://reviews.llvm.org/D68429



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


[PATCH] D68413: [clang] [cmake] Add distribution install targets for remaining components

2019-10-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D68413



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

This has the side-effect of making `libclang_cpp` effectively empty when you 
build with Xcode.

What exactly does Xcode do with `OBJECT` libraries?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68114: Fix for expanding __pragmas in macro arguments

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Nice, the solution was right in front of us the whole time. :)

lgtm, but please share the TokenCollector class.




Comment at: clang/lib/Lex/Pragma.cpp:169
 
   struct TokenCollector {
 Preprocessor 

Let's pull this class out to file scope (and put it in an anonymous namespace) 
so we can reuse it instead of copying it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68114



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


[PATCH] D67541: [ClangFormat] Future-proof Standard option, allow floating or pinning to arbitrary lang version

2019-10-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This broke the sphinx bot: 
http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/48207

  Warning, treated as error:
  
/home/buildbot/llvm-build-dir/clang-sphinx-docs/llvm/src/tools/clang/docs/ClangFormatStyleOptions.rst:2295:
 WARNING: Explicit markup ends without a blank line; unexpected unindent.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67541



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


[PATCH] D68423: [clang-tools-extra] [cmake] Use add_clang_tool() to install tools

2019-10-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D68423



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


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4399-4400
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];

jyknight wrote:
> I believe the semantics are stronger than this. It should get inlined unless 
> it cannot be.
Seemingly not for indirect function calls: https://godbolt.org/z/BoND-X


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D67723: [CodeView] Add option to disable inline line tables.

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1943
+def gno_inline_line_tables : Flag<["-"], "gno-inline-line-tables">,
+  Flags<[CC1Option, CoreOption]>, HelpText<"Don't emit inline line tables">;
 

aprantl wrote:
> As a DWARF person, this option name is a little confusing since in DWARF 
> inline info is part of debug info, not the line table, but few end-users 
> would actually know. I would probably have called it -gno-inline-info or 
> -gno-inlined-functions. I don't have strong feelings about it though.
The other two options we have that control this stuff are `-gmlt` / 
`-gline-tables-only`. gmlt stands for "g minimal line tables". So, our command 
line interface talks about "line tables" already, and IMO we should stick with 
it, even if it's not really a table after all.

And, technically, this option will greatly affect the `.debug_line` section. 
The inlined source locations are normally present in `.debug_line`, and this 
change suppresses them. Instead, the debugger will appear to be stopped at the 
inlined call site.



Comment at: llvm/docs/LangRef.rst:1437
+``"no-inline-line-tables"``
+When this attribute is set to true, inline line tables are not generated
+for this function if it is inlined and the location of the inlined code

aprantl wrote:
> Same comment for the attribute.
Maybe we could use more precise wording rather than talking about tables. Maybe 
we should describe what happens from the user perspective, something like:

When this attribute is present and set to true, the inliner will discard source 
locations while inlining code into the current function. Instead, the source 
location of the call site will be used for all inlined code. Breakpoints set on 
code that was inlined into the current function will not fire during the 
execution of the inlined call sites. If the debugger stops inside an inlined 
call site, it will appear to be stopped at the outermost inlined call site.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:1433-1446
   if (CalleeHasDebugInfo)
 continue;
 
   // If the inlined instruction has no line number, make it look as if it
   // originates from the call location. This is important for
   // ((__always_inline__, __nodebug__)) functions which must use caller
   // location for all instructions in their function body.

rnk wrote:
> Let's actually try to reuse this `!CalleeHasDebugInfo` code path when this 
> function attribute is present. They should do the same thing.
This suggestion makes less sense in light of the need to remove variable 
information. Use your best judgement.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:1426
+  // If we are not generating inline line tables, set the debug 
location
+  // of the inlined code to be the call site.
+  DebugLoc IDL =

aprantl wrote:
> aprantl wrote:
> > This will probably cause some IR Verifier failures and very confusing debug 
> > info when inlining dbg.value intrinsics. The correct thing to do here is 
> > probably to assign line 0 to the inlined instructions and remove all debug 
> > info intrinsics. Otherwise the inlined variables will show up in the parent 
> > frame, which will screw up debugging.
> cf. getMergedLocation() for how to do this.
Ah, yes, we should erase all debug info for inlined variables while inlining in 
this mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67723



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


[PATCH] D68321: Fix clang Visual Studio build instructions

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D68321



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose created this revision.
jordan_rose added a reviewer: beanz.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Undoes some of the effects of D61909  when 
using the Xcode CMake generator—it doesn't handle object libraries correctly at 
all. Attempts to still honor `BUILD_SHARED_LIBS` for Xcode, but I didn't 
actually test it. Should have no effect on non-Xcode generators.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68430

Files:
  clang/cmake/modules/AddClang.cmake


Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -86,11 +86,15 @@
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
 # so we need to handle it here.
 if(BUILD_SHARED_LIBS)
-  set(LIBTYPE SHARED OBJECT)
+  set(LIBTYPE SHARED)
 else()
-  set(LIBTYPE STATIC OBJECT)
+  set(LIBTYPE STATIC)
+endif()
+if(NOT XCODE)
+  # The Xcode generator doesn't handle object libraries correctly.
+  list(APPEND LIBTYPE OBJECT)
+  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 


Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -86,11 +86,15 @@
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
 # so we need to handle it here.
 if(BUILD_SHARED_LIBS)
-  set(LIBTYPE SHARED OBJECT)
+  set(LIBTYPE SHARED)
 else()
-  set(LIBTYPE STATIC OBJECT)
+  set(LIBTYPE STATIC)
+endif()
+if(NOT XCODE)
+  # The Xcode generator doesn't handle object libraries correctly.
+  list(APPEND LIBTYPE OBJECT)
+  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Committed the fix for the test.

Best regards,
Alexey Bataev

3 окт. 2019 г., в 17:48, Nico Weber  написал(а):


Looks like this fails on Windows: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }

+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->getVariantFuncRef()->IgnoreParenImpCasts())
   ->getDecl());
 }

@@ -11216,7 +11266,7 @@ bool CGOpenMPRuntime::emitDeclareVariant
   llvm::GlobalValue 

[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: include/clang/Basic/Builtins.def:483
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

aaron.ballman wrote:
> xbolva00 wrote:
> > aaron.ballman wrote:
> > > GCC doesn't seem to have `__builtin_memccpy`? https://godbolt.org/z/jbthQ3
> > Ok, I will drop it.
> If you drop it, won't that lose the builtin? I was mostly thinking it's in 
> the wrong part of the list of builtins.
Rebuilding LLVM + Clang in progress so I just checked it in godbolt with 
"strtol" - defined only as LIBBUILTIN, no __builtin version.

nobuiltin attribute is correctly handled, so I think it will work. 
https://godbolt.org/z/Olfv-w


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

https://reviews.llvm.org/D68377



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


r373672 - [OPENMP]Fix the test on Windows, NFC.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 15:10:33 2019
New Revision: 373672

URL: http://llvm.org/viewvc/llvm-project?rev=373672=rev
Log:
[OPENMP]Fix the test on Windows, NFC.

Modified:
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: 
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp?rev=373672=373671=373672=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp Thu 
Oct  3 15:10:33 2019
@@ -8,7 +8,7 @@
 // CHECK-DAG: @_ZN16SpecSpecialFuncs6MethodEv = {{.*}}alias i32 
(%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* 
@_ZN16SpecSpecialFuncs7method_Ev
 // CHECK-DAG: @_ZN16SpecSpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 
(%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* 
@_ZN16SpecSpecialFuncs7method_Ev
 // CHECK-DAG: @_ZN12SpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 
(%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* 
@_ZN12SpecialFuncs7method_Ev
-// CHECK-DAG: @_Z5prio_v = alias i32 (), i32 ()* @_Z4priov
+// CHECK-DAG: @_Z5prio_v = {{.*}}alias i32 (), i32 ()* @_Z4priov
 // CHECK-DAG: @_ZL6prio1_v = internal alias i32 (), i32 ()* @_ZL5prio2v
 // CHECK-DAG: @_Z4callv = {{.*}}alias i32 (), i32 ()* @_Z4testv
 // CHECK-DAG: @_ZL9stat_usedv = internal alias i32 (), i32 ()* 
@_ZL10stat_used_v


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


[PATCH] D68429: [clang] [cmake] Use add_clang_tool() to install all tools

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: compnerd, phosek, smeenai, beanz, tstellar.

Switch clang-check, clang-extdef-mapping and clang-offload-bundler
to use add_clang_tool() rather than add_clang_executable() with a custom
install rule.  This makes them LLVM_DISTRIBUTION_COMPONENTS-friendly.


https://reviews.llvm.org/D68429

Files:
  clang/tools/clang-check/CMakeLists.txt
  clang/tools/clang-extdef-mapping/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt


Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -4,7 +4,7 @@
   set(tablegen_deps intrinsics_gen)
 endif()
 
-add_clang_executable(clang-offload-bundler
+add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
   
   DEPENDS
@@ -21,5 +21,3 @@
   PRIVATE
   ${CLANG_OFFLOAD_BUNDLER_LIB_DEPS}
   )
-
-install(TARGETS clang-offload-bundler RUNTIME DESTINATION bin)
Index: clang/tools/clang-extdef-mapping/CMakeLists.txt
===
--- clang/tools/clang-extdef-mapping/CMakeLists.txt
+++ clang/tools/clang-extdef-mapping/CMakeLists.txt
@@ -3,7 +3,7 @@
   support
   )
 
-add_clang_executable(clang-extdef-mapping
+add_clang_tool(clang-extdef-mapping
   ClangExtDefMapGen.cpp
   )
 
@@ -16,6 +16,3 @@
   clangSerialization
   clangTooling
   )
-
-install(TARGETS clang-extdef-mapping
-  RUNTIME DESTINATION bin)
Index: clang/tools/clang-check/CMakeLists.txt
===
--- clang/tools/clang-check/CMakeLists.txt
+++ clang/tools/clang-check/CMakeLists.txt
@@ -4,7 +4,7 @@
   Support
   )
 
-add_clang_executable(clang-check
+add_clang_tool(clang-check
   ClangCheck.cpp
   )
 
@@ -19,6 +19,3 @@
   clangStaticAnalyzerFrontend
   clangTooling
   )
-
-install(TARGETS clang-check
-  RUNTIME DESTINATION bin)


Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -4,7 +4,7 @@
   set(tablegen_deps intrinsics_gen)
 endif()
 
-add_clang_executable(clang-offload-bundler
+add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
   
   DEPENDS
@@ -21,5 +21,3 @@
   PRIVATE
   ${CLANG_OFFLOAD_BUNDLER_LIB_DEPS}
   )
-
-install(TARGETS clang-offload-bundler RUNTIME DESTINATION bin)
Index: clang/tools/clang-extdef-mapping/CMakeLists.txt
===
--- clang/tools/clang-extdef-mapping/CMakeLists.txt
+++ clang/tools/clang-extdef-mapping/CMakeLists.txt
@@ -3,7 +3,7 @@
   support
   )
 
-add_clang_executable(clang-extdef-mapping
+add_clang_tool(clang-extdef-mapping
   ClangExtDefMapGen.cpp
   )
 
@@ -16,6 +16,3 @@
   clangSerialization
   clangTooling
   )
-
-install(TARGETS clang-extdef-mapping
-  RUNTIME DESTINATION bin)
Index: clang/tools/clang-check/CMakeLists.txt
===
--- clang/tools/clang-check/CMakeLists.txt
+++ clang/tools/clang-check/CMakeLists.txt
@@ -4,7 +4,7 @@
   Support
   )
 
-add_clang_executable(clang-check
+add_clang_tool(clang-check
   ClangCheck.cpp
   )
 
@@ -19,6 +19,3 @@
   clangStaticAnalyzerFrontend
   clangTooling
   )
-
-install(TARGETS clang-check
-  RUNTIME DESTINATION bin)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68413: [clang] [cmake] Add distribution install targets for remaining components

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 223109.
mgorny added a comment.

Include hmaptool as well.


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

https://reviews.llvm.org/D68413

Files:
  clang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt

Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -9,8 +9,15 @@
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL})
 
 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
-install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION bin)
+install(PROGRAMS ${CLANG_HMAPTOOL}
+DESTINATION bin
+COMPONENT hmaptool)
 
 add_custom_target(hmaptool ALL DEPENDS ${Depends})
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 
+if(NOT LLVM_ENABLE_IDE)
+  add_llvm_install_targets("install-hmaptool"
+   DEPENDS hmaptool
+   COMPONENT hmaptool)
+endif()
Index: clang/tools/scan-view/CMakeLists.txt
===
--- clang/tools/scan-view/CMakeLists.txt
+++ clang/tools/scan-view/CMakeLists.txt
@@ -21,7 +21,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-view)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -33,9 +35,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-view/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
-install(FILES share/${ShareFile} DESTINATION share/scan-view)
+install(FILES share/${ShareFile}
+DESTINATION share/scan-view
+COMPONENT scan-view)
   endforeach()
 
   add_custom_target(scan-view ALL DEPENDS ${Depends})
   set_target_properties(scan-view PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-view"
+ DEPENDS scan-view
+ COMPONENT scan-view)
+  endif()
 endif()
Index: clang/tools/scan-build/CMakeLists.txt
===
--- clang/tools/scan-build/CMakeLists.txt
+++ clang/tools/scan-build/CMakeLists.txt
@@ -41,7 +41,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-build)
   endforeach()
 
   foreach(LibexecFile ${LibexecFiles})
@@ -53,7 +55,9 @@
  ${CMAKE_BINARY_DIR}/libexec/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
-install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
+install(PROGRAMS libexec/${LibexecFile}
+DESTINATION libexec
+COMPONENT scan-build)
   endforeach()
 
   foreach(ManPage ${ManPages})
@@ -65,7 +69,9 @@
  ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(PROGRAMS man/${ManPage}
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+COMPONENT scan-build)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -77,9 +83,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
-install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
+install(FILES share/scan-build/${ShareFile}
+DESTINATION share/scan-build
+COMPONENT scan-build)
   endforeach()
 
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-build"
+ DEPENDS scan-build
+ COMPONENT scan-build)
+  endif()
 endif()
Index: clang/CMakeLists.txt
===
--- 

Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Yep, I see. Will fix in couple minutes

Best regards,
Alexey Bataev

3 окт. 2019 г., в 17:48, Nico Weber  написал(а):


Looks like this fails on Windows: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }

+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->getVariantFuncRef()->IgnoreParenImpCasts())
   ->getDecl());
 }

@@ -11216,7 +11266,7 @@ bool CGOpenMPRuntime::emitDeclareVariant
   

Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Yep, I see. Will fix in couple minutes

Best regards,
Alexey Bataev

3 окт. 2019 г., в 17:48, Nico Weber  написал(а):


Looks like this fails on Windows: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }

+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->getVariantFuncRef()->IgnoreParenImpCasts())
   ->getDecl());
 }

@@ -11216,7 +11266,7 @@ bool CGOpenMPRuntime::emitDeclareVariant
   

Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Nico Weber via cfe-commits
Looks like this fails on Windows:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Thu Oct  3 13:49:48 2019
> New Revision: 373661
>
> URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
> Log:
> [OPENMP50]Codegen support for scores in context selectors.
>
> If the context selector has associated score and several contexts
> selectors matches current context, the function with the highest score
> must be selected.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
> @@ -11175,37 +11175,87 @@ bool checkContextreturn !A->getImplVendor().compare("llvm");
>  }
>
> +static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr
> *RHS) {
> +  // If both scores are unknown, choose the very first one.
> +  if (!LHS && !RHS)
> +return true;
> +  // If only one is known, return this one.
> +  if (LHS && !RHS)
> +return true;
> +  if (!LHS && RHS)
> +return false;
> +  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
> +  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
> +  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
> +}
> +
> +namespace {
> +/// Comparator for the priority queue for context selector.
> +class OMPDeclareVariantAttrComparer
> +: public std::greater {
> +private:
> +  ASTContext 
> +
> +public:
> +  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
> +  bool operator()(const OMPDeclareVariantAttr *LHS,
> +  const OMPDeclareVariantAttr *RHS) const {
> +const Expr *LHSExpr = nullptr;
> +const Expr *RHSExpr = nullptr;
> +if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
> +  LHSExpr = LHS->getScore();
> +if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
> +  RHSExpr = RHS->getScore();
> +return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
> +  }
> +};
> +} // anonymous namespace
> +
>  /// Finds the variant function that matches current context with its
> context
>  /// selector.
> -static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl
> *FD) {
> +static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
> + const FunctionDecl
> *FD) {
>if (!FD->hasAttrs() || !FD->hasAttr())
>  return FD;
>// Iterate through all DeclareVariant attributes and check context
> selectors.
> -  SmallVector MatchingAttributes;
> -  for (const auto * A : FD->specific_attrs()) {
> +  auto & = [](const OMPDeclareVariantAttr *LHS,
> +   const OMPDeclareVariantAttr *RHS) {
> +const Expr *LHSExpr = nullptr;
> +const Expr *RHSExpr = nullptr;
> +if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
> +  LHSExpr = LHS->getScore();
> +if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
> +  RHSExpr = RHS->getScore();
> +return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
> +  };
> +  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
> +  for (const auto *A : FD->specific_attrs()) {
> +const OMPDeclareVariantAttr *SelectedAttr = nullptr;
>  switch (A->getCtxSelectorSet()) {
>  case OMPDeclareVariantAttr::CtxSetImplementation:
>switch (A->getCtxSelector()) {
>case OMPDeclareVariantAttr::CtxVendor:
>  if (checkContext   OMPDeclareVariantAttr::CtxVendor>(A))
> -  MatchingAttributes.push_back(A);
> +  SelectedAttr = A;
>  break;
>case OMPDeclareVariantAttr::CtxUnknown:
>  llvm_unreachable(
> -"Unknown context selector in implementation selctor set.");
> +"Unknown context selector in implementation selector set.");
>}
>break;
>  case OMPDeclareVariantAttr::CtxSetUnknown:
>llvm_unreachable("Unknown context selector set.");
>  }
> +// If the attribute matches the context, find the attribute with the
> highest
> +// score.
> +if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr,
> SelectedAttr)))
> +  TopMostAttr = SelectedAttr;
>}
> -  if (MatchingAttributes.empty())
> +  if (!TopMostAttr)
>  return FD;
> -  // TODO: implement score analysis of multiple context selectors.
> -  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
>return cast(
> -
> cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())

r373667 - ASTContext - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 14:47:42 2019
New Revision: 373667

URL: http://llvm.org/viewvc/llvm-project?rev=373667=rev
Log:
ASTContext - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should 
be able to use castAs<> directly and if not assert will fire for us.

We can also remove a number of explicit asserts and reply on the internal 
asserts in castAs<>

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=373667=373666=373667=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct  3 14:47:42 2019
@@ -1575,10 +1575,9 @@ void ASTContext::addedLocalImportDecl(Im
 /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified
 /// scalar floating point type.
 const llvm::fltSemantics ::getFloatTypeSemantics(QualType T) const {
-  const auto *BT = T->getAs();
-  assert(BT && "Not a floating point type!");
-  switch (BT->getKind()) {
-  default: llvm_unreachable("Not a floating point type!");
+  switch (T->castAs()->getKind()) {
+  default:
+llvm_unreachable("Not a floating point type!");
   case BuiltinType::Float16:
   case BuiltinType::Half:
 return Target->getHalfFormat();
@@ -2869,7 +2868,7 @@ QualType ASTContext::getFunctionTypeWith
 
   // Anything else must be a function type. Rebuild it with the new exception
   // specification.
-  const auto *Proto = Orig->getAs();
+  const auto *Proto = Orig->castAs();
   return getFunctionType(
   Proto->getReturnType(), Proto->getParamTypes(),
   Proto->getExtProtoInfo().withExceptionSpec(ESI));
@@ -5678,7 +5677,6 @@ static FloatingRank getFloatingRank(Qual
   if (const auto *CT = T->getAs())
 return getFloatingRank(CT->getElementType());
 
-  assert(T->getAs() && "getFloatingRank(): not a floating type");
   switch (T->castAs()->getKind()) {
   default: llvm_unreachable("getFloatingRank(): not a floating type");
   case BuiltinType::Float16:return Float16Rank;
@@ -6056,12 +6054,10 @@ QualType ASTContext::getObjCSuperType()
 }
 
 void ASTContext::setCFConstantStringType(QualType T) {
-  const auto *TD = T->getAs();
-  assert(TD && "Invalid CFConstantStringType");
+  const auto *TD = T->castAs();
   CFConstantStringTypeDecl = cast(TD->getDecl());
   const auto *TagType =
-  CFConstantStringTypeDecl->getUnderlyingType()->getAs();
-  assert(TagType && "Invalid CFConstantStringType");
+  CFConstantStringTypeDecl->getUnderlyingType()->castAs();
   CFConstantStringTagDecl = TagType->getDecl();
 }
 
@@ -9114,34 +9110,30 @@ QualType ASTContext::mergeTypes(QualType
 return {};
   case Type::Vector:
 // FIXME: The merged type should be an ExtVector!
-if (areCompatVectorTypes(LHSCan->getAs(),
- RHSCan->getAs()))
+if (areCompatVectorTypes(LHSCan->castAs(),
+ RHSCan->castAs()))
   return LHS;
 return {};
   case Type::ObjCObject: {
 // Check if the types are assignment compatible.
 // FIXME: This should be type compatibility, e.g. whether
 // "LHS x; RHS x;" at global scope is legal.
-const auto *LHSIface = LHS->getAs();
-const auto *RHSIface = RHS->getAs();
-if (canAssignObjCInterfaces(LHSIface, RHSIface))
+if (canAssignObjCInterfaces(LHS->castAs(),
+RHS->castAs()))
   return LHS;
-
 return {};
   }
   case Type::ObjCObjectPointer:
 if (OfBlockPointer) {
   if (canAssignObjCInterfacesInBlockPointer(
-  LHS->getAs(),
-  RHS->getAs(),
-  BlockReturnType))
+  LHS->castAs(),
+  RHS->castAs(), BlockReturnType))
 return LHS;
   return {};
 }
-if (canAssignObjCInterfaces(LHS->getAs(),
-RHS->getAs()))
+if (canAssignObjCInterfaces(LHS->castAs(),
+RHS->castAs()))
   return LHS;
-
 return {};
   case Type::Pipe:
 assert(LHS != RHS &&
@@ -9226,7 +9218,7 @@ QualType ASTContext::mergeObjCGCQualifie
 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
   // id foo(); ... __strong id foo(); or: __strong id foo(); ... id foo();
   // In either case, use OldReturnType to build the new function type.
-  const auto *F = LHS->getAs();
+  const auto *F = LHS->castAs();
   if (const auto *FPT = cast(F)) {
 FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
 EPI.ExtInfo = getFunctionExtInfo(LHS);
@@ -9304,9 +9296,7 @@ QualType ASTContext::getCorrespondingUns
   if (const auto *ETy = T->getAs())
 T = ETy->getDecl()->getIntegerType();
 
-  const auto *BTy = 

Re: r373406 - Use scope qualifiers in Clang's tblgen backends to get useful

2019-10-03 Thread John McCall via cfe-commits

On 3 Oct 2019, at 17:22, David Blaikie wrote:
(mostly joking) any interest in seeing what it'd take to make 
Clang/LLVM
-Wmissing-prototype clean? (which would also catch the same sort of 
issues,

I think?)


Sounds like a nice project for someone else. :)

John.



On Tue, Oct 1, 2019 at 4:10 PM John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:


Author: rjmccall
Date: Tue Oct  1 16:12:57 2019
New Revision: 373406

URL: http://llvm.org/viewvc/llvm-project?rev=373406=rev
Log:
Use scope qualifiers in Clang's tblgen backends to get useful
redeclaration checking.  NFC.

Modified:
cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp

cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
cfe/trunk/utils/TableGen/ClangOpcodesEmitter.cpp
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp?rev=373406=373405=373406=diff

==
--- cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp Tue Oct  1 
16:12:57

2019
@@ -10,6 +10,8 @@
 //

 
//===--===//

+#include "TableGenBackends.h"
+
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include 
@@ -173,15 +175,14 @@ void ClangASTNodesEmitter::run(raw_ostre
   OS << "#undef ABSTRACT_" << macroName(Root.getName()) << "\n";
 }

-namespace clang {
-void EmitClangASTNodes(RecordKeeper , raw_ostream ,
-   const std::string , const std::string ) {
+void clang::EmitClangASTNodes(RecordKeeper , raw_ostream ,
+  const std::string , const 
std::string )

{
   ClangASTNodesEmitter(RK, N, S).run(OS);
 }

 // Emits and addendum to a .inc file to enumerate the clang 
declaration

 // contexts.
-void EmitClangDeclContext(RecordKeeper , raw_ostream ) {
+void clang::EmitClangDeclContext(RecordKeeper , raw_ostream 
) {
   // FIXME: Find a .td file format to allow for this to be 
represented

better.

   emitSourceFileHeader("List of AST Decl nodes", OS);
@@ -225,4 +226,3 @@ void EmitClangDeclContext(RecordKeeper &
   OS << "#undef DECL_CONTEXT\n";
   OS << "#undef DECL_CONTEXT_BASE\n";
 }
-} // end namespace clang

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=373406=373405=373406=diff

==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Oct  1 16:12:57 
2019

@@ -10,6 +10,8 @@
 //

 
//===--===//

+#include "TableGenBackends.h"
+
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -2219,10 +2221,8 @@ static void emitClangAttrThisIsaIdentifi
   OS << "#endif // CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST\n\n";
 }

-namespace clang {
-
 // Emits the class definitions for attributes.
-void EmitClangAttrClass(RecordKeeper , raw_ostream ) {
+void clang::EmitClangAttrClass(RecordKeeper , raw_ostream 
) {

   emitSourceFileHeader("Attribute classes' definitions", OS);

   OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
@@ -2491,7 +2491,7 @@ void EmitClangAttrClass(RecordKeeper 
 }

 // Emits the class method definitions for attributes.
-void EmitClangAttrImpl(RecordKeeper , raw_ostream ) {
+void clang::EmitClangAttrImpl(RecordKeeper , raw_ostream 
) {
   emitSourceFileHeader("Attribute classes' member function 
definitions",

OS);

   std::vector Attrs = 
Records.getAllDerivedDefinitions("Attr");

@@ -2556,8 +2556,6 @@ void EmitClangAttrImpl(RecordKeeper 
   EmitFunc("printPretty(OS, Policy)");
 }

-} // end namespace clang
-
 static void emitAttrList(raw_ostream , StringRef Class,
  const std::vector ) {
   for (auto Cur : AttrList) {

Modified: cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp?rev=373406=373405=373406=diff

==
--- cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp 
(original)
+++ cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp Tue 
Oct  1

16:12:57 

r373665 - OverloadCandidate::getNumParams - silence static analyzer getAs null dereference warning. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 14:27:02 2019
New Revision: 373665

URL: http://llvm.org/viewvc/llvm-project?rev=373665=rev
Log:
OverloadCandidate::getNumParams - silence static analyzer 
getAs null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we 
should be able to use castAs directly and if not assert will 
fire for us.

Also replaces an auto to make the type more obvious.

Modified:
cfe/trunk/include/clang/Sema/Overload.h

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=373665=373664=373665=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Oct  3 14:27:02 2019
@@ -826,10 +826,10 @@ class Sema;
 
 unsigned getNumParams() const {
   if (IsSurrogate) {
-auto STy = Surrogate->getConversionType();
+QualType STy = Surrogate->getConversionType();
 while (STy->isPointerType() || STy->isReferenceType())
   STy = STy->getPointeeType();
-return STy->getAs()->getNumParams();
+return STy->castAs()->getNumParams();
   }
   if (Function)
 return Function->getNumParams();


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


Re: r373406 - Use scope qualifiers in Clang's tblgen backends to get useful

2019-10-03 Thread David Blaikie via cfe-commits
(mostly joking) any interest in seeing what it'd take to make Clang/LLVM
-Wmissing-prototype clean? (which would also catch the same sort of issues,
I think?)

On Tue, Oct 1, 2019 at 4:10 PM John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rjmccall
> Date: Tue Oct  1 16:12:57 2019
> New Revision: 373406
>
> URL: http://llvm.org/viewvc/llvm-project?rev=373406=rev
> Log:
> Use scope qualifiers in Clang's tblgen backends to get useful
> redeclaration checking.  NFC.
>
> Modified:
> cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
>
> cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
> cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
> cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
> cfe/trunk/utils/TableGen/ClangOpcodesEmitter.cpp
> cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
> cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
> cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
> cfe/trunk/utils/TableGen/NeonEmitter.cpp
>
> Modified: cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp?rev=373406=373405=373406=diff
>
> ==
> --- cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp (original)
> +++ cfe/trunk/utils/TableGen/ClangASTNodesEmitter.cpp Tue Oct  1 16:12:57
> 2019
> @@ -10,6 +10,8 @@
>  //
>
>  
> //===--===//
>
> +#include "TableGenBackends.h"
> +
>  #include "llvm/TableGen/Record.h"
>  #include "llvm/TableGen/TableGenBackend.h"
>  #include 
> @@ -173,15 +175,14 @@ void ClangASTNodesEmitter::run(raw_ostre
>OS << "#undef ABSTRACT_" << macroName(Root.getName()) << "\n";
>  }
>
> -namespace clang {
> -void EmitClangASTNodes(RecordKeeper , raw_ostream ,
> -   const std::string , const std::string ) {
> +void clang::EmitClangASTNodes(RecordKeeper , raw_ostream ,
> +  const std::string , const std::string )
> {
>ClangASTNodesEmitter(RK, N, S).run(OS);
>  }
>
>  // Emits and addendum to a .inc file to enumerate the clang declaration
>  // contexts.
> -void EmitClangDeclContext(RecordKeeper , raw_ostream ) {
> +void clang::EmitClangDeclContext(RecordKeeper , raw_ostream ) {
>// FIXME: Find a .td file format to allow for this to be represented
> better.
>
>emitSourceFileHeader("List of AST Decl nodes", OS);
> @@ -225,4 +226,3 @@ void EmitClangDeclContext(RecordKeeper &
>OS << "#undef DECL_CONTEXT\n";
>OS << "#undef DECL_CONTEXT_BASE\n";
>  }
> -} // end namespace clang
>
> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=373406=373405=373406=diff
>
> ==
> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Oct  1 16:12:57 2019
> @@ -10,6 +10,8 @@
>  //
>
>  
> //===--===//
>
> +#include "TableGenBackends.h"
> +
>  #include "llvm/ADT/ArrayRef.h"
>  #include "llvm/ADT/DenseMap.h"
>  #include "llvm/ADT/DenseSet.h"
> @@ -2219,10 +2221,8 @@ static void emitClangAttrThisIsaIdentifi
>OS << "#endif // CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST\n\n";
>  }
>
> -namespace clang {
> -
>  // Emits the class definitions for attributes.
> -void EmitClangAttrClass(RecordKeeper , raw_ostream ) {
> +void clang::EmitClangAttrClass(RecordKeeper , raw_ostream ) {
>emitSourceFileHeader("Attribute classes' definitions", OS);
>
>OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
> @@ -2491,7 +2491,7 @@ void EmitClangAttrClass(RecordKeeper 
>  }
>
>  // Emits the class method definitions for attributes.
> -void EmitClangAttrImpl(RecordKeeper , raw_ostream ) {
> +void clang::EmitClangAttrImpl(RecordKeeper , raw_ostream ) {
>emitSourceFileHeader("Attribute classes' member function definitions",
> OS);
>
>std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
> @@ -2556,8 +2556,6 @@ void EmitClangAttrImpl(RecordKeeper 
>EmitFunc("printPretty(OS, Policy)");
>  }
>
> -} // end namespace clang
> -
>  static void emitAttrList(raw_ostream , StringRef Class,
>   const std::vector ) {
>for (auto Cur : AttrList) {
>
> Modified: cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp?rev=373406=373405=373406=diff
>
> ==
> --- 

[PATCH] D68423: [clang-tools-extra] [cmake] Use add_clang_tool() to install tools

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: compnerd, beanz, phosek, tstellar, smeenai, jtsoftware, 
hokein.

Replace add_clang_executable() calls with add_clang_tool() that takes
care of creating correct, distribution-friendly install target.  While
at it, remove redundant install calls.

This change also causes clang-move and pp-trace to be installed.


https://reviews.llvm.org/D68423

Files:
  clang-tools-extra/clang-apply-replacements/tool/CMakeLists.txt
  clang-tools-extra/clang-change-namespace/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-move/tool/CMakeLists.txt
  clang-tools-extra/clang-query/tool/CMakeLists.txt
  clang-tools-extra/pp-trace/CMakeLists.txt

Index: clang-tools-extra/pp-trace/CMakeLists.txt
===
--- clang-tools-extra/pp-trace/CMakeLists.txt
+++ clang-tools-extra/pp-trace/CMakeLists.txt
@@ -2,7 +2,7 @@
   Support
   )
 
-add_clang_executable(pp-trace
+add_clang_tool(pp-trace
   PPTrace.cpp
   PPCallbacksTracker.cpp
   )
Index: clang-tools-extra/clang-query/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-query/tool/CMakeLists.txt
+++ clang-tools-extra/clang-query/tool/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-query
+add_clang_tool(clang-query
   ClangQuery.cpp
   )
 target_link_libraries(clang-query
@@ -14,5 +14,3 @@
   clangSerialization
   clangTooling
   )
-
-install(TARGETS clang-query RUNTIME DESTINATION bin)
Index: clang-tools-extra/clang-move/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-move/tool/CMakeLists.txt
+++ clang-tools-extra/clang-move/tool/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-move
+add_clang_tool(clang-move
   ClangMove.cpp
   )
 
Index: clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
+++ clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
@@ -17,9 +17,6 @@
   findAllSymbols
   )
 
-install(TARGETS clang-include-fixer
-  RUNTIME DESTINATION bin)
-
 install(PROGRAMS clang-include-fixer.el
   DESTINATION share/clang
   COMPONENT clang-include-fixer)
Index: clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
+++ clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols
+add_clang_tool(find-all-symbols
   FindAllSymbolsMain.cpp
   )
 
@@ -16,9 +16,6 @@
   findAllSymbols
   )
 
-install(TARGETS find-all-symbols
-  RUNTIME DESTINATION bin)
-
 install(PROGRAMS run-find-all-symbols.py
   DESTINATION share/clang
   COMPONENT find-all-symbols)
Index: clang-tools-extra/clang-change-namespace/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-change-namespace/tool/CMakeLists.txt
+++ clang-tools-extra/clang-change-namespace/tool/CMakeLists.txt
@@ -4,7 +4,7 @@
   Support
   )
 
-add_clang_executable(clang-change-namespace
+add_clang_tool(clang-change-namespace
   ClangChangeNamespace.cpp
   )
 target_link_libraries(clang-change-namespace
@@ -20,6 +20,3 @@
   clangTooling
   clangToolingCore
   )
-
-install(TARGETS clang-change-namespace
-  RUNTIME DESTINATION bin)
Index: clang-tools-extra/clang-apply-replacements/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-apply-replacements/tool/CMakeLists.txt
+++ clang-tools-extra/clang-apply-replacements/tool/CMakeLists.txt
@@ -14,6 +14,3 @@
   clangToolingCore
   clangToolingRefactoring
   )
-
-install(TARGETS clang-apply-replacements
-  RUNTIME DESTINATION bin)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67901: [clangd] Improve semantic highlighting in dependent contexts (fixes #154)

2019-10-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 2 inline comments as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:219
+  bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
+addToken(L.getNameLoc(), HighlightingKind::DependentType);
+return true;

ilya-biryukov wrote:
> nridge wrote:
> > hokein wrote:
> > > nit: we have `kindForType` for hanlding all types, so I'd move the logic 
> > > of detecting the dependent type there.
> > I did try this, but it doesn't quite work, because `VisitTypeLoc` adds the 
> > highlighting to the `TypeLoc`'s `getBeginLoc()`. For something like 
> > `typename T::type`, that highlights the `typename` token rather than the 
> > `type` token. By contrast, here I add the highlighting to the 
> > `DependentNameTypeLoc`'s `getNameLoc()` which will correctly highlight the 
> > `type` token.
> You'd want to implement `WalkUpFromDependentNameTypeLoc` instead of `Visit*` 
> to avoid adding extra highlightings in `VisitTypeLoc`.
> 
> In fact, I'm surprised we're not seeing them now.
We're not seeing extra highlightings with the current patch, because 
`VisitTypeLoc` does not add any highlightings for dependent types 
(`kindForType()` returns `None` for them). 

So, I don't think there's a problem with using `VisitDependentNameTypeLoc`?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:505
+  case HighlightingKind::DependentType:
+return "entity.name.type.dependent.cpp";
+  case HighlightingKind::DependentName:

hokein wrote:
> ilya-biryukov wrote:
> > Maybe have a separate category for all dependent entities instead, i.e. use
> > `entity.name.dependent.type.cpp` and `entity.name.dependent.other.cpp`?
> > 
> > This would allow to specify a single highlighting for both names by 
> > stopping at `dependent` subcategory.
> > I'm not sure how this plays into the default colors provided in the editors 
> > that support semantic highlighting...
> Having a dedicate dependent entity doesn't align with the existing textmate 
> patterns (the `dependent` type should be under the `entity.name.type` 
> umbrella) --  most highlighters don't have a specific pattern for 
> `dependent`, so we'll fallback to the `entity.name.type` color. If we use 
> `entity.name.dependent.type.cpp`, we'll fall back to `entity.name` color.
+1, I think it's more important that dependent types are highlighted as types 
out-of-the-box in cases where the theme contains a highlighting for types but 
not one specifically for dependent types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67901



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


[PATCH] D62731: [RFC] Add support for options -frounding-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-10-03 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 223090.
mibintc added a comment.

In the previous review, @rjmccall asked me to redo the existing floating point 
option documentation before submitting this patch.  I got the floating point 
documentation update committed, and I've worked on this patch more to get the 
floating point "render options" checking implemented.  This patch needs more 
test cases, and there might be a bug or 2 in the "render options" checking.   I 
wanted to show you this work especially to get your reaction to the changes to 
the floating point options

This patch adds support for frounding-math and ftrapping-math and new options 
fp-model= and fp-exception-behavior=; fp-model is an "umbrella" option.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true), RoundingFPMath(false),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
@@ -154,6 +154,11 @@
 /// specifies that there are no trap handlers to handle exceptions.
 unsigned NoTrappingFPMath : 1;
 
+/// RoundingFPMath - This flag is enabled when the
+/// -enable-rounding-fp-math is specified on the command line. This
+/// specifies dynamic rounding mode.
+unsigned RoundingFPMath : 1;
+
 /// NoSignedZerosFPMath - This flag is enabled when the
 /// -enable-no-signed-zeros-fp-math is specified on the command line. This
 /// specifies that optimizations are allowed to treat the sign of a zero
Index: clang/test/Driver/fast-math.c
===
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -170,11 +170,11 @@
 // RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // RUN: %clang -### -funsafe-math-optimizations -ffinite-math-only \
-// RUN: -fno-math-errno -ffp-contract=fast -c %s 2>&1 \
+// RUN: -fno-math-errno -ffp-contract=fast -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // RUN: %clang -### -fno-honor-infinities -fno-honor-nans -fno-math-errno \
 // RUN: -fassociative-math -freciprocal-math -fno-signed-zeros \
-// RUN: -fno-trapping-math -ffp-contract=fast -c %s 2>&1 \
+// RUN: -fno-trapping-math -ffp-contract=fast -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // CHECK-FAST-MATH: "-cc1"
 // CHECK-FAST-MATH: "-ffast-math"
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -320,7 +320,6 @@
 // RUN: -fprefetch-loop-arrays\
 // RUN: -fprofile-correction  \
 // RUN: -fprofile-values  \
-// RUN: -frounding-math   \
 // RUN: -fschedule-insns  \
 // RUN: -fsignaling-nans  \
 // RUN: -fstrength-reduce \
@@ -385,7 +384,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fprefetch-loop-arrays' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fprofile-correction' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fprofile-values' is not supported
-// CHECK-WARNING-DAG: optimization flag '-frounding-math' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsignaling-nans' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fstrength-reduce' is not supported
Index: clang/test/CodeGen/fpconstrained.c

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 223088.
nickdesaulniers marked 3 inline comments as done.
nickdesaulniers added a comment.

- add links
- remove extra whitespace
- rewording, split onto separate lines to ease code review
- add spellings to heading


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4391,3 +4391,22 @@
 
 }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inline heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the MSDN Inline docs`_, `the GCC Common Function Attribute docs`_,
+and `the GCC Inline docs`_.
+
+.. _the MSDN Inline docs: 
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -636,7 +636,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4391,3 +4391,22 @@
 
 }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inline heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the MSDN Inline docs`_, `the GCC Common Function Attribute docs`_,
+and `the GCC Inline docs`_.
+
+.. _the MSDN Inline docs: https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -636,7 +636,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-10-03 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 marked 7 inline comments as done.
boga95 added a comment.

Ping




Comment at: clang/test/Analysis/taint-generic.c:393-397
+void testConfigurationFilter3() {
+  int x = mySource1();
+  myFilter3();
+  Buffer[x] = 1; // no-warning
+}

NoQ wrote:
> In this example `myFilter3` promises not to alter the value of `x` due to 
> `const`-qualifier on the pointee type of the parameter. Additionally, the 
> function has no chance of preventing the program from reaching the buffer 
> overflow line, other than crashing the program (given that it's C and there 
> are no exceptions). Therefore i'd say this is also a false negative.
> 
> A better motivational example that doesn't immediately look like a false 
> negative may look like this:
> ```lang=c
> void testConfigurationFilter3() {
>   int x = mySource1();
>   if (isOutOfRange(x)) // the filter function
> return;
>   Buffer[x] = 1; // no-warning
> }
> ```
> In this case the function looks at the value of `x` (there's really no need 
> to pass it by pointer) and notifies the caller through its return value that 
> it is unsafe to access the buffer with such index. This is probably the only 
> situation where a "filter" annotation is actually worth it.
It could work with C++ despite it hasn't supported any specific feature (yet).

I pass it by `const int*` because it currently doesn't support the value 
semantics :(. It has been already in my TODO list.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:53-56
+  void Profile(llvm::FoldingSetNodeID ) const {
+ID.AddInteger(Arg);
+ID.AddInteger(TagType);
+  }

Szelethus wrote:
> Interesting, isn't this predefined for `std::pair`?
Unfortunately, it's not. 



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:474-476
+  const FunctionDecl *FDecl = C.getCalleeDecl(CE);
+  if (!FDecl || FDecl->getKind() != Decl::Function)
+return;

Szelethus wrote:
> When do these happen? For implicit functions in C? 
For example, a lambda doesn't have an FunctionDecl.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:478-480
+  StringRef Name = C.getCalleeName(FDecl);
+  if (Name.empty())
+return;

Szelethus wrote:
> And this? Lambdas maybe?
I haven't found any example of this. It's just a copy-paste refactoring so I 
don't know the intentions behind that.

I think the checker should work perfectly without it.



Comment at: lib/StaticAnalyzer/Checkers/Taint.h:25-28
 using TaintTagType = unsigned;
 
-static constexpr TaintTagType TaintTagGeneric = 0;
+static constexpr TaintTagType TaintTagNotTainted = 0;
+static constexpr TaintTagType TaintTagGeneric = 1;

Szelethus wrote:
> Is there a **very** good reason behind us not using an `enum` instead?
Unfortunately, enums cannot put into FoldingSet. It has to be a primitive type 
or a struct with the necessary functions. I can use enums and cast them to 
unsigned and back, but it isn't convenient.


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

https://reviews.llvm.org/D59516



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


r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }
 
+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->getVariantFuncRef()->IgnoreParenImpCasts())
   ->getDecl());
 }
 
@@ -11216,7 +11266,7 @@ bool CGOpenMPRuntime::emitDeclareVariant
   llvm::GlobalValue *Orig = CGM.GetGlobalValue(MangledName);
   if (Orig && !Orig->isDeclaration())
 return false;
-  const FunctionDecl *NewFD = getDeclareVariantFunction(D);
+  const FunctionDecl *NewFD = getDeclareVariantFunction(CGM.getContext(), D);
   // Emit original function if it does not have declare variant attribute or 
the
   // context does not match.
   if 

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4401
+disabled. Does not guarantee that inline substitution actually occurs.
+}];
+  let Heading = "always_inline";

It is more than that. This would imply that with optimizations enabled there is 
no effect. I would mention that the inline heuristic is disabled and inlining 
is always attempted, w/ or w/o optimizations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D68255: [X86] Remove AVX/AVX512 check from validateOperandSize, just always accept 512

2019-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: ahatanak, void.
rnk added a comment.

I notice that x86 is the only target for which validateInput/OutputSize are 
implemented. If you are going to disable these checks, perhaps we should get 
rid of these methods and leave all these errors to the backend? You could add 
`-S` to the x86_32-inline-asm.c test and turn it into an integration test that 
shows that we no longer crash. It would need `REQUIRES: x86-registered-target` 
if you do that.

Adding @void and @ahatanak, who added these long ago.




Comment at: clang/lib/Basic/Targets/X86.cpp:1768
   // XMM0
   if (SSELevel >= SSE1)
 return Size <= 128U;

I think the same issues apply to this SSELevel check. I suspect no one 
complains about these checks because everyone enables SSE2 in one way or 
another.


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

https://reviews.llvm.org/D68255



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

Thanks. Please commit on my behalf when you have a chance.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

understood, ok LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D68377#1693490 , @xbolva00 wrote:

>   It is not very obvious for me what kind of test should be done here. I 
> would be grateful if you could show me an example in tree.


I was thinking of something in CodeGen, like CodeGen/builtin-memfns.c

> Exactly for -fno-builtin-memccpy case?

That would be another good test case.




Comment at: include/clang/Basic/Builtins.def:483
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

xbolva00 wrote:
> aaron.ballman wrote:
> > GCC doesn't seem to have `__builtin_memccpy`? https://godbolt.org/z/jbthQ3
> Ok, I will drop it.
If you drop it, won't that lose the builtin? I was mostly thinking it's in the 
wrong part of the list of builtins.


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

https://reviews.llvm.org/D68377



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

If you want spaces in your C++11 initializers and nothing else, then you don't 
want the `Cpp11BracedListStyle` setting enabled. Turning it off gives you 
spaces inside without affecting anything else.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

what if you have this

  vector{1, 2, 3};
  new int[3]{1, 2, 3};
  foo(int f);

but want this:

  vector{ 1, 2, 3 };
  new int[3]{ 1, 2, 3 };
  foo(int f);

wouldn't turning on  `SpacesInParentheses: true` now mean you get

  vector{ 1, 2, 3 };
  new int[3]{ 1, 2, 3 };
  foo( int f );

so there is no way of still having `foo(int f);` without a space before the int 
and after the f?

Sorry did I miss something? Generally, I agree that the change is good for the 
braced case I just don't want to break everyones functions


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68346: [clang-format] Add new option to add spaces around conditions

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar requested changes to this revision.
mitchell-stellar added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2290
 
+**SpacesAroundConditions** (``bool``)
+  If ``true``, spaces will be inserted around if/for/while (and similar) 
conditions.

`SpacesInConditionalStatement` is probably a better name, remaining consistent 
with existing `SpacesIn*` options, as well as indicating it only affects the 
entire conditional statement, and not individual conditions within the 
statement.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2511
+  return t->isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, tok::kw_while,
+tok::kw_switch, tok::kw_constexpr, TT_ForEachMacro);
+};

It seems that you are mixing statement tokens `if`, `while`, etc. with 
preprocessor and macro tokens. Going by the documentation, this is unexpected.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2919
+  if (Right.is(tok::coloncolon) &&
+  !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
 return (Left.is(TT_TemplateOpener) &&

MyDeveloperDay wrote:
> I'm not sure I understand this change so you added a `tok::l_paren` here? but 
> its not just for your style, so something else must have changed. Did you run 
> all FormatTests?
> 
> one of the tests you add need to test why you added this here
This is not covered by your tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68346



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar updated this revision to Diff 223077.
mitchell-stellar added a comment.

Added additional unit tests to verify that the `SpaceInEmptyParentheses` 
setting is also correctly adhered to.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,34 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
+  verifyFormat("vector< int > x{};", SpaceBetweenBraces);
+  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2188,7 +2188,8 @@
 if (Current->is(TT_LineComment)) {
   if (Current->Previous->BlockKind == BK_BracedInit &&
   Current->Previous->opensScope())
-Current->SpacesRequiredBefore = Style.Cpp11BracedListStyle ? 0 : 1;
+Current->SpacesRequiredBefore =
+(Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
   else
 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
 
@@ -2628,7 +2629,7 @@
   if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) ||
   (Right.is(tok::r_brace) && Right.MatchingParen &&
Right.MatchingParen->BlockKind != BK_Block))
-return !Style.Cpp11BracedListStyle;
+return Style.Cpp11BracedListStyle ? Style.SpacesInParentheses : true;
   if (Left.is(TT_BlockComment))
 // No whitespace in x(/*foo=*/1), except for JavaScript.
 return Style.Language == FormatStyle::LK_JavaScript ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,34 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
+  verifyFormat("vector< int > x{};", SpaceBetweenBraces);
+  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/lib/Format/TokenAnnotator.cpp

[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added a comment.

It is not very obvious for me what kind of test should be done here. I would be 
grateful if you could show me an example in tree.




Comment at: include/clang/Basic/Builtins.def:483
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

aaron.ballman wrote:
> GCC doesn't seem to have `__builtin_memccpy`? https://godbolt.org/z/jbthQ3
Ok, I will drop it.


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

https://reviews.llvm.org/D68377



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

I don't think that's a good idea, considering the fact that braces can mean 
different things in different contexts, and it would cause trouble for existing 
clang-format settings.

If a hypothetical `SpacesInBraces` were `false` by default, then you could have 
clang-format output something like:

`[](int foo) {bar(foo);}`

Currently, it is `[](int foo) { bar(foo); }`.

If a hypothetical `SpacesInBraces` were `true` by default, then you could have 
clang-format output something like:

`vector x{ 1, 2, 3, 4 };`

Currently, it is `vector x{1, 2, 3, 4};`.

This patch is minimally invasive and adheres to the existing documentation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Should we have  `SpacesInBraces`?  as a first class formatting option, given 
that we have?

  SpaceBetweenBraces.SpacesInAngles = true;
  SpaceBetweenBraces.SpacesInParentheses = true;
  SpaceBetweenBraces.SpacesInSquareBrackets = true;


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68332: [clang-format] [PR43531] clang-format damages "alternative representations" for operators

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar requested changes to this revision.
mitchell-stellar added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2892
+  if (Left.is(TT_UnaryOperator)) {
+// Don't combine the unary operators !~ into "compl5" and "not5"
+// when using alternative operators "compl" and "not"

Without context, "compl5" and "not5" do not make sense. Can you try to rephrase 
this comment?



Comment at: clang/lib/Format/TokenAnnotator.cpp:2896
+if (!Right.is(tok::l_paren)) {
+  if (Left.is(tok::exclaim) && Left.TokenText.equals("not"))
+return true;

For consistency, `Left.TokenText == "not"` may be better. I cannot find another 
instance of `.equals()`.



Comment at: clang/unittests/Format/FormatTest.cpp:14445
+TEST_F(FormatTest, AlternativeOperators) {
+  // Test case for bug https://bugs.llvm.org/show_bug.cgi?id=43531
+  verifyFormat("int a and b;");

Instead of using a URL link, perhaps describe in words what this test is 
supposed to do?


Repository:
  rC Clang

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

https://reviews.llvm.org/D68332



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2019-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D67847#1691898 , @jyknight wrote:

> The `abort()` function raises SIGABRT, for which the default behavior is to 
> trigger a coredump. Do we actually want that behavior?
>
> Either `_exit()` (long available extension, which lld already uses) or 
> `quick_exit()` (the new C standard way) seem possibly preferable?


I think this patch is more for the purpose of making error handling better than 
for fixing PR35547. Fixing PR35547 is probably just a side effect. Apologies 
that I should have updated the summary to reflect that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Test cases?




Comment at: include/clang/Basic/Builtins.def:483
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

GCC doesn't seem to have `__builtin_memccpy`? https://godbolt.org/z/jbthQ3


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

https://reviews.llvm.org/D68377



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2019-10-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

The `abort()` function raises SIGABRT, for which the default behavior is to 
trigger a coredump. Do we actually want that behavior?

Either `_exit()` (long available extension, which lld already uses) or 
`quick_exit()` (the new C standard way) seem possibly preferable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: rsmith.
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1072
+NoBuiltinAttr *
+Sema::mergeNoBuiltinAttr(Sema , Decl *D, const AttributeCommonInfo ,
+ llvm::ArrayRef FunctionNames) {

gchatelet wrote:
> aaron.ballman wrote:
> > You're missing a call to this function within `mergeDeclAttribute()` in 
> > SemaDecl.cpp.
> Thx, I rearranged the signature a bit, do you happen to know how 
> `mergeDeclAttribute` is tested?
Through redeclarations, e.g.,
```
[[some_attr]] void func();
[[some_other_attr]] void func();

[[a_third_attr, some_attr]] void func() {
}
```



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1086-1089
+  if (FunctionNamesSet.count(Wildcard) > 0) {
+FunctionNamesSet.clear();
+FunctionNamesSet.insert(Wildcard);
+  }

gchatelet wrote:
> aaron.ballman wrote:
> > Rather than walking the entire set like this, would it make more sense to 
> > look for the wildcard in the above loop before inserting the name, and set 
> > a local variable if found, so that you can do the clear without having to 
> > rescan the entire list?
> This is is conflict with the `llvm::copy` suggestion above. Which one do you 
> prefer?
Walking the list and not calling `llvm::copy`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1098-1099
+
+  if (D->hasAttr())
+D->dropAttr();
+

gchatelet wrote:
> gchatelet wrote:
> > aaron.ballman wrote:
> > > Just making sure I understand the semantics you want: redeclarations do 
> > > not have to have matching lists of builtins, but instead the definition 
> > > will use a merged list? e.g.,
> > > ```
> > > [[clang::no_builtin("memset")]] void whatever();
> > > [[clang::no_builtin("memcpy")]] void whatever();
> > > 
> > > [[clang::no_builtin("memmove")]] void whatever() {
> > >  // Will not use memset, memcpy, or memmove builtins.
> > > }
> > > ```
> > > That seems a bit strange, to me. In fact, being able to apply this 
> > > attribute to a declaration seems a bit like a mistake -- this only 
> > > impacts the definition of the function, and I can't imagine good things 
> > > coming from hypothetical code like:
> > > ```
> > > [[clang::no_builtin("memset")]] void whatever();
> > > #include "whatever.h" // Provides a library declaration of whatever() 
> > > with no restrictions on it
> > > ```
> > > WDYT about restricting this attribute to only appear on definitions?
> > That's a very good point. Thx for noticing.
> > Indeed I think it only makes sense to have the attribute on the function 
> > definition.
> > 
> > I've tried to to use `FunctionDecl->hasBody()` during attribute handling in 
> > the Sema phase but it seems like the `FunctionDecl` is not complete at this 
> > point.
> > All calls to `hasBody()` return `false`, if I repeat the operation in 
> > `CGCall` then `hasBody` returns `true` and I can see the 
> > `CompoundStatement`.
> > 
> > Do you have any recommendations on where to perform the check?
> So after some investigations it turns out that 
> `FunctionDecl::isThisDeclarationADefinition` is buggy (returns always 
> `false`) when called from `ProcessDeclAttribute`.
> I believe it's because the `CompoundStatement` is not parsed at this point.
> 
> As a matter of fact all code using this function in `ProcessDeclAttribute` is 
> dead code (see D68379 which disables the dead code, tests are still passing)
> 
> 
> I'm unsure of how to fix this, it may be possible of using 
> `FunctionDecl::setWillHaveBody`in [[ 
> https://github.com/llvm/llvm-project/blob/0577a0cedbc5be4cd4c20ba53d3dbdac6bff9a0a/clang/lib/Sema/SemaDecl.cpp#L8820
>  | this switch ]].
> So after some investigations it turns out that 
> FunctionDecl::isThisDeclarationADefinition is buggy (returns always false) 
> when called from ProcessDeclAttribute.

That is a bit odd to me; we call it in a half dozen places in SemaDeclAttr.cpp, 
all of which get called from `ProcessDeclAttribute`. Are ALL of those uses 
broken currently?!

> As a matter of fact all code using this function in ProcessDeclAttribute is 
> dead code (see D68379 which disables the dead code, tests are still passing)

You got four of the six. What about the use in 
`handleObjCSuppresProtocolAttr()` and the second use in `handleAliasAttr()`?

> I'm unsure of how to fix this, it may be possible of using 
> FunctionDecl::setWillHaveBodyin this switch.

I'm also unsure of a good way forward. @rsmith may have ideas too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D67775: [Sema] Split out -Wformat-type-confusion from -Wformat-pedantic

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67775#1691999 , @erik.pilkington 
wrote:

> Ping!


Sorry for the delayed review -- thank you for working on clearing this up!




Comment at: clang/include/clang/AST/FormatString.h:259
+NoMatch = 0,
+/// The conversion specifier and the argument type are compatible.
+Match = 1,

Can you add: `For instance, "%d" and _Bool.`



Comment at: clang/lib/Sema/SemaChecking.cpp:8165
+if (ImplicitMatch == ArgType::NoMatchTypeConfusion)
+  Match = ArgType::NoMatchTypeConfusion;
   }

How about:
```
if (ImplicitMatch == ArgType::NoMatchPedantic ||
ImplicitMatch == ArgType::NoMatchTypeConfusion)
  Match = ImplicitMatch;
```



Comment at: clang/test/Sema/format-strings-pedantic.c:1
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-type-confusion %s
 

Are we losing test coverage for `-Wformat-pedantic`, or do we have other tests 
covering that elsewhere? I would have expected this test file's contents to 
exercise pedantic cases.



Comment at: clang/test/Sema/format-type-confusion.c:13
+ b, // expected-warning {{format specifies type 'unsigned short' but 
the argument has type '_Bool'}}
+ b, b, b, b, b);
+

Just double-checking, but the reason we don't diagnose the `%c` here is because 
of `-Wno-format`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67775



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


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Miguel Ojeda via Phabricator via cfe-commits
ojeda added a comment.

Note that the latest GCC docs (rather than 4.1.2) are at: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

For reference, this was triggered from: 
https://lore.kernel.org/lkml/cakwvodm_gouedjayxtqctuvdl+9vwvfeofhv06mlmyva75c...@mail.gmail.com/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar created this revision.
mitchell-stellar added reviewers: MyDeveloperDay, reuk, owenpan.
mitchell-stellar added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to the clang-format documentation, "Fundamentally, C++11 braced lists 
are formatted exactly like function calls would be formatted in their place. If 
the braced list follows a name (e.g. a type or variable name), clang-format 
formats as if the `{}` were the parentheses of a function call with that name."

This patch furthers the treatment of C++11 braced list braces as parentheses by 
respecting the `SpacesInParentheses` setting.


Repository:
  rC Clang

https://reviews.llvm.org/D68415

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,31 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2188,7 +2188,8 @@
 if (Current->is(TT_LineComment)) {
   if (Current->Previous->BlockKind == BK_BracedInit &&
   Current->Previous->opensScope())
-Current->SpacesRequiredBefore = Style.Cpp11BracedListStyle ? 0 : 1;
+Current->SpacesRequiredBefore =
+(Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
   else
 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
 
@@ -2628,7 +2629,7 @@
   if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) ||
   (Right.is(tok::r_brace) && Right.MatchingParen &&
Right.MatchingParen->BlockKind != BK_Block))
-return !Style.Cpp11BracedListStyle;
+return Style.Cpp11BracedListStyle ? Style.SpacesInParentheses : true;
   if (Left.is(TT_BlockComment))
 // No whitespace in x(/*foo=*/1), except for JavaScript.
 return Style.Language == FormatStyle::LK_JavaScript ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,31 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: 

[PATCH] D67159: [clang] New __attribute__((__clang_arm_mve_alias)).

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as done.
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Decl.cpp:3082
+static bool ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  // This will be filled in by Tablegen which isn't written yet
+  return false;

simon_tatham wrote:
> aaron.ballman wrote:
> > Comment should have a `FIXME` prefix, but tbh, I'm a little uncomfortable 
> > adopting the attribute without this being implemented. I assume the plan is 
> > to tablegen a header file that gets included here to provide the lookup?
> Yes: D67161, which I intend to commit as part of the same patch series once 
> everything in it is approved, fills in this function with tablegen output.
> 
> I could roll both into the same monolithic patch, but I thought it would be 
> better to break it up into manageable pieces as far as possible, especially 
> when some of them (like this one) would need to be reviewed by people with 
> significantly different expertise from the rest.
Ah, I didn't realize that was so involved; keeping them split makes sense.



Comment at: clang/lib/AST/Decl.cpp:3107
+if (!ArmMveAliasValid(BuiltinID, getIdentifier()->getName())) {
+  getASTContext().getDiagnostics().Report(
+getLocation(), diag::err_attribute_arm_mve_alias);

simon_tatham wrote:
> aaron.ballman wrote:
> > I'm not certain how comfortable I am with having this function produce a 
> > diagnostic. That seems like unexpected behavior for a function attempting 
> > to get a builtin ID. I think this should be the responsibility of the 
> > caller.
> The //caller//? But there are many possible callers of this function. You 
> surely didn't mean to suggest duplicating the diagnostic at all those call 
> sites.
> 
> Perhaps it would make more sense to have all the calculation in this 
> `getBuiltinID` method move into a function called once, early in the 
> `FunctionDecl`'s lifetime, which figures out the builtin ID (if any) and 
> stashes it in a member variable? Then //that// would issue the diagnostic, if 
> any (and it would be called from a context where that was a sensible thing to 
> do), and `getBuiltinID` itself would become a mere accessor function.
> The caller? But there are many possible callers of this function. You surely 
> didn't mean to suggest duplicating the diagnostic at all those call sites.

Yes, I did. :-) No caller is going to expect that calling a `const` function 
that gets a builtin ID is going to issue diagnostics and so this runs the risk 
of generating diagnostics in surprising situations, such as from AST matchers.

> Perhaps it would make more sense to have all the calculation in this 
> getBuiltinID method move into a function called once, early in the 
> FunctionDecl's lifetime, which figures out the builtin ID (if any) and 
> stashes it in a member variable? Then that would issue the diagnostic, if any 
> (and it would be called from a context where that was a sensible thing to 
> do), and getBuiltinID itself would become a mere accessor function.

That might make sense, but I don't have a good idea of what performance 
concerns that might raise. If there are a lot of functions and we never need to 
check if they have a builtin ID, that could be expensive for little gain.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7442
+  case ParsedAttr::AT_ClangBuiltinOverride:
+handleClangBuiltinOverrideAttribute(S, D, AL);
+break;

simon_tatham wrote:
> aaron.ballman wrote:
> > You should be able to call 
> > `handleSimpleAttribute()` instead.
> Oh, nearly forgot: apparently I can't, because that template expects the 
> attribute to have a constructor that takes only an `ASTContext` and an 
> `AttributeCommonInfo`. But the constructor for my attribute also takes an 
> `IdentifierInfo` giving the builtin name.
Ah, good point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


[PATCH] D67629: [clang-format] [PR43333] Fix C# breaking before function name when using Attributes

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar accepted this revision.
mitchell-stellar added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D67629



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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373649: [HIP] Use option -nogpulib to disable linking device 
lib (authored by yaxunl, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68300?vs=223024=223068#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68300

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Driver/ToolChains/HIP.cpp
  cfe/trunk/test/Driver/hip-no-device-libs.hip


Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -286,6 +286,9 @@
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -121,7 +121,7 @@
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto  : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2556,7 +2556,9 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, Alias;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
Index: cfe/trunk/test/Driver/hip-no-device-libs.hip
===
--- cfe/trunk/test/Driver/hip-no-device-libs.hip
+++ cfe/trunk/test/Driver/hip-no-device-libs.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+


Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -286,6 +286,9 @@
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -121,7 +121,7 @@
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto  : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2556,7 +2556,9 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;

r373649 - [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Oct  3 11:59:56 2019
New Revision: 373649

URL: http://llvm.org/viewvc/llvm-project?rev=373649=rev
Log:
[HIP] Use option -nogpulib to disable linking device lib

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

Added:
cfe/trunk/test/Driver/hip-no-device-libs.hip
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=373649=373648=373649=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct  3 11:59:56 2019
@@ -2556,7 +2556,9 @@ def no__dead__strip__inits__and__terms :
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, Alias;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=373649=373648=373649=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Oct  3 11:59:56 2019
@@ -121,7 +121,7 @@ CudaInstallationDetector::CudaInstallati
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto  : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@ void CudaToolChain::addClangTargetOption
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=373649=373648=373649=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Thu Oct  3 11:59:56 2019
@@ -286,6 +286,9 @@ void HIPToolChain::addClangTargetOptions
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.

Added: cfe/trunk/test/Driver/hip-no-device-libs.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-no-device-libs.hip?rev=373649=auto
==
--- cfe/trunk/test/Driver/hip-no-device-libs.hip (added)
+++ cfe/trunk/test/Driver/hip-no-device-libs.hip Thu Oct  3 11:59:56 2019
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+


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


r373648 - Check for qualified function types after substituting into the operand

2019-10-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  3 11:55:23 2019
New Revision: 373648

URL: http://llvm.org/viewvc/llvm-project?rev=373648=rev
Log:
Check for qualified function types after substituting into the operand
of 'typeid'.

This is a rare place where it's valid for a function type to be
substituted but not valid for a qualified function type to be
substituted, so needs a special check.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=373648=373647=373648=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct  3 11:55:23 
2019
@@ -6211,6 +6211,8 @@ def err_invalid_qualified_function_type
 def err_compound_qualified_function_type : Error<
   "%select{block pointer|pointer|reference}0 to function type %select{%2 |}1"
   "cannot have '%3' qualifier">;
+def err_qualified_function_typeid : Error<
+  "type operand %0 of 'typeid' cannot have '%1' qualifier">;
 
 def err_ref_qualifier_overload : Error<
   "cannot overload a member function %select{without a ref-qualifier|with "

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=373648=373647=373648=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct  3 11:55:23 2019
@@ -1522,6 +1522,8 @@ public:
   QualType BuildAddressSpaceAttr(QualType , Expr *AddrSpace,
  SourceLocation AttrLoc);
 
+  bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc);
+
   bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
 
   /// Build a function type.

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=373648=373647=373648=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct  3 11:55:23 2019
@@ -453,6 +453,9 @@ ExprResult Sema::BuildCXXTypeId(QualType
   if (T->isVariablyModifiedType())
 return ExprError(Diag(TypeidLoc, diag::err_variably_modified_typeid) << T);
 
+  if (CheckQualifiedFunctionForTypeId(T, TypeidLoc))
+return ExprError();
+
   return new (Context) CXXTypeidExpr(TypeInfoType.withConst(), Operand,
  SourceRange(TypeidLoc, RParenLoc));
 }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=373648=373647=373648=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Oct  3 11:55:23 2019
@@ -1955,7 +1955,8 @@ static bool checkQualifiedFunction(Sema
QualifiedFunctionKind QFK) {
   // Does T refer to a function type with a cv-qualifier or a ref-qualifier?
   const FunctionProtoType *FPT = T->getAs();
-  if (!FPT || (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == 
RQ_None))
+  if (!FPT ||
+  (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == RQ_None))
 return false;
 
   S.Diag(Loc, diag::err_compound_qualified_function_type)
@@ -1964,6 +1965,17 @@ static bool checkQualifiedFunction(Sema
   return true;
 }
 
+bool Sema::CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc) {
+  const FunctionProtoType *FPT = T->getAs();
+  if (!FPT ||
+  (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == RQ_None))
+return false;
+
+  Diag(Loc, diag::err_qualified_function_typeid)
+  << T << getFunctionQualifiersAsString(FPT);
+  return true;
+}
+
 /// Build a pointer type.
 ///
 /// \param T The type to which we'll be building a pointer.

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp?rev=373648=373647=373648=diff
==
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Thu Oct  3 11:55:23 2019
@@ -192,6 +192,13 @@ struct TypeId0 {
   }
 };
 
+template
+struct TypeId1 {
+  const std::type_info () {
+return typeid(T); // expected-error-re 2{{type operand 'void () 
{{const|&}}' of 'typeid' cannot have '{{const|&}}' qualifier}}
+  }
+};
+
 struct Abstract {
   virtual void f() 

[PATCH] D67660: [clang-format] [PR43338] C# clang format has space issues betweern C# only keywords

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar accepted this revision.
mitchell-stellar added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D67660



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


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4400
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];

It may make sense to link back to MSDN and GCC if we're honoring their 
semantics. We seem to do this for MSDN regularly, but a bit less common for the 
GCC docs.



Comment at: clang/include/clang/Basic/AttrDocs.td:4402
+}];
+  let Heading = "always_inline";
+}

Can you add the various spellings to this heading?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D68296: [clang-format] Add ability to wrap braces after multi-line control statements

2019-10-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373647: [clang-format] Add ability to wrap braces after 
multi-line control statements (authored by paulhoad, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68296?vs=223058=223066#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68296

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -782,6 +782,40 @@
   /// The brace breaking style to use.
   BraceBreakingStyle BreakBeforeBraces;
 
+  // Different ways to wrap braces after control statements.
+  enum BraceWrappingAfterControlStatementStyle {
+/// Never wrap braces after a control statement.
+/// \code
+///   if (foo()) {
+///   } else {
+///   }
+///   for (int i = 0; i < 10; ++i) {
+///   }
+/// \endcode
+BWACS_Never,
+/// Only wrap braces after a multi-line control statement.
+/// \code
+///   if (foo && bar &&
+///   baz)
+///   {
+/// quux();
+///   }
+///   while (foo || bar) {
+///   }
+/// \endcode
+BWACS_MultiLine,
+/// Always wrap braces after a control statement.
+/// \code
+///   if (foo())
+///   {
+///   } else
+///   {}
+///   for (int i = 0; i < 10; ++i)
+///   {}
+/// \endcode
+BWACS_Always
+  };
+
   /// Precise control over the wrapping of braces.
   /// \code
   ///   # Should be declared this way:
@@ -817,23 +851,7 @@
 /// \endcode
 bool AfterClass;
 /// Wrap control statements (``if``/``for``/``while``/``switch``/..).
-/// \code
-///   true:
-///   if (foo())
-///   {
-///   } else
-///   {}
-///   for (int i = 0; i < 10; ++i)
-///   {}
-///
-///   false:
-///   if (foo()) {
-///   } else {
-///   }
-///   for (int i = 0; i < 10; ++i) {
-///   }
-/// \endcode
-bool AfterControlStatement;
+BraceWrappingAfterControlStatementStyle AfterControlStatement;
 /// Wrap enum definitions.
 /// \code
 ///   true:
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -306,8 +306,24 @@
 }
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
-TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
-  return Style.BraceWrapping.AfterControlStatement
+(TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
+ tok::kw_switch, tok::kw_try, tok::kw_do) ||
+ (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
+  TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
+Style.BraceWrapping.AfterControlStatement ==
+FormatStyle::BWACS_MultiLine) {
+  // If possible, merge the next line's wrapped left brace with the current
+  // line. Otherwise, leave it on the next line, as this is a multi-line
+  // control statement.
+  return (Style.ColumnLimit == 0 ||
+  TheLine->Last->TotalLength <= Style.ColumnLimit)
+ ? 1
+ : 0;
+} else if (I[1]->First->is(tok::l_brace) &&
+   TheLine->First->isOneOf(tok::kw_if, tok::kw_while,
+   tok::kw_for)) {
+  return (Style.BraceWrapping.AfterControlStatement ==
+  FormatStyle::BWACS_Always)
  ? tryMergeSimpleBlock(I, E, Limit)
  : 0;
 }
@@ -410,7 +426,8 @@
   SmallVectorImpl::const_iterator E, unsigned Limit) {
 if (Limit == 0)
   return 0;
-if (Style.BraceWrapping.AfterControlStatement &&
+if (Style.BraceWrapping.AfterControlStatement ==
+FormatStyle::BWACS_Always &&
 I[1]->First->is(tok::l_brace) &&
 Style.AllowShortBlocksOnASingleLine == FormatStyle::SBS_Never)
   return 0;
@@ -523,8 +540,9 @@
 return 0;
   if (!Style.AllowShortIfStatementsOnASingleLine &&
   Line.startsWith(tok::kw_if) &&
-  Style.BraceWrapping.AfterControlStatement && I + 2 != E &&
-  !I[2]->First->is(tok::r_brace))
+  Style.BraceWrapping.AfterControlStatement ==
+  FormatStyle::BWACS_Always 

[PATCH] D68412: [clang] [cmake] Support LLVM_DISTRIBUTION_COMPONENTS in stand-alone build

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: compnerd, tstellar, phosek, beanz, smeenai.

https://reviews.llvm.org/D68412

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,6 +114,7 @@
   include(TableGen)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
+  include(LLVMDistributionSupport)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 
@@ -852,6 +853,10 @@
 endif()
 add_subdirectory(utils/hmaptool)
 
+if(CLANG_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,6 +114,7 @@
   include(TableGen)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
+  include(LLVMDistributionSupport)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 
@@ -852,6 +853,10 @@
 endif()
 add_subdirectory(utils/hmaptool)
 
+if(CLANG_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68413: [clang] [cmake] Add distribution install targets for remaining components

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: compnerd, phosek, smeenai, beanz, tstellar.

Add install targets as necessary to install bash-autocomplete,
scan-build and scan-view via LLVM_DISTRIBUTION_TARGETS.


https://reviews.llvm.org/D68413

Files:
  clang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt

Index: clang/tools/scan-view/CMakeLists.txt
===
--- clang/tools/scan-view/CMakeLists.txt
+++ clang/tools/scan-view/CMakeLists.txt
@@ -21,7 +21,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-view)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -33,9 +35,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-view/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
-install(FILES share/${ShareFile} DESTINATION share/scan-view)
+install(FILES share/${ShareFile}
+DESTINATION share/scan-view
+COMPONENT scan-view)
   endforeach()
 
   add_custom_target(scan-view ALL DEPENDS ${Depends})
   set_target_properties(scan-view PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-view"
+ DEPENDS scan-view
+ COMPONENT scan-view)
+  endif()
 endif()
Index: clang/tools/scan-build/CMakeLists.txt
===
--- clang/tools/scan-build/CMakeLists.txt
+++ clang/tools/scan-build/CMakeLists.txt
@@ -41,7 +41,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-build)
   endforeach()
 
   foreach(LibexecFile ${LibexecFiles})
@@ -53,7 +55,9 @@
  ${CMAKE_BINARY_DIR}/libexec/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
-install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
+install(PROGRAMS libexec/${LibexecFile}
+DESTINATION libexec
+COMPONENT scan-build)
   endforeach()
 
   foreach(ManPage ${ManPages})
@@ -65,7 +69,9 @@
  ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(PROGRAMS man/${ManPage}
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+COMPONENT scan-build)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -77,9 +83,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
-install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
+install(FILES share/scan-build/${ShareFile}
+DESTINATION share/scan-build
+COMPONENT scan-build)
   endforeach()
 
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-build"
+ DEPENDS scan-build
+ COMPONENT scan-build)
+  endif()
 endif()
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -442,9 +442,15 @@
  COMPONENT clang-headers)
   endif()
 
+  add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
   install(PROGRAMS utils/bash-autocomplete.sh
-DESTINATION share/clang
-)
+  DESTINATION share/clang
+  COMPONENT bash-autocomplete)
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-bash-autocomplete
+ DEPENDS bash-autocomplete
+ COMPONENT bash-autocomplete)
+  endif()
 endif()
 
 add_definitions( -D_GNU_SOURCE )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a reviewer: aaron.ballman.
lebedev.ri added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4394-4395
 }
+
+
+def AlwaysInlineDocs : Documentation {

One too many lines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4399-4400
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];

I believe the semantics are stronger than this. It should get inlined unless it 
cannot be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


r373647 - [clang-format] Add ability to wrap braces after multi-line control statements

2019-10-03 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Thu Oct  3 11:42:31 2019
New Revision: 373647

URL: http://llvm.org/viewvc/llvm-project?rev=373647=rev
Log:
[clang-format] Add ability to wrap braces after multi-line control statements

Summary:
Change the BraceWrappingFlags' AfterControlStatement from a bool to an enum 
with three values:

* "Never": This is the default, and does not do any brace wrapping after 
control statements.
* "MultiLine": This only wraps braces after multi-line control statements (this 
really only happens when a ColumnLimit is specified).
* "Always": This always wraps braces after control statements.

The first and last options are backwards-compatible with "false" and "true", 
respectively.

The new "MultiLine" option is useful for when a wrapped control statement's 
indentation matches the subsequent block's indentation. It makes it easier to 
see at a glance where the control statement ends and where the block's code 
begins. For example:

```
if (
  foo
  && bar )
{
  baz();
}
```

vs.

```
if (
  foo
  && bar ) {
  baz();
}
```

Short control statements (1 line) do not wrap the brace to the next line, e.g.

```
if (foo) {
  bar();
} else {
  baz();
}
```

Reviewers: sammccall, owenpan, reuk, MyDeveloperDay, klimek

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Patch By: mitchell-stellar

Tags: #clang-format, #clang, #clang-tools-extra

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=373647=373646=373647=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Oct  3 11:42:31 2019
@@ -778,24 +778,46 @@ the configuration (without a prefix: ``A
   class foo
   {};
 
-  * ``bool AfterControlStatement`` Wrap control statements 
(``if``/``for``/``while``/``switch``/..).
+  * ``BraceWrappingAfterControlStatementStyle AfterControlStatement``
+Wrap control statements (``if``/``for``/``while``/``switch``/..).
 
-.. code-block:: c++
+Possible values:
 
-  true:
-  if (foo())
-  {
-  } else
-  {}
-  for (int i = 0; i < 10; ++i)
-  {}
-
-  false:
-  if (foo()) {
-  } else {
-  }
-  for (int i = 0; i < 10; ++i) {
-  }
+* ``BWACS_Never`` (in configuration: ``Never``)
+  Never wrap braces after a control statement.
+
+  .. code-block:: c++
+
+if (foo()) {
+} else {
+}
+for (int i = 0; i < 10; ++i) {
+}
+
+* ``BWACS_MultiLine`` (in configuration: ``MultiLine``)
+  Only wrap braces after a multi-line control statement.
+
+  .. code-block:: c++
+
+if (foo && bar &&
+baz)
+{
+  quux();
+}
+while (foo || bar) {
+}
+
+* ``BWACS_Always`` (in configuration: ``Always``)
+  Always wrap braces after a control statement.
+
+  .. code-block:: c++
+
+if (foo())
+{
+} else
+{}
+for (int i = 0; i < 10; ++i)
+{}
 
   * ``bool AfterEnum`` Wrap enum definitions.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=373647=373646=373647=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Oct  3 11:42:31 2019
@@ -782,6 +782,40 @@ struct FormatStyle {
   /// The brace breaking style to use.
   BraceBreakingStyle BreakBeforeBraces;
 
+  // Different ways to wrap braces after control statements.
+  enum BraceWrappingAfterControlStatementStyle {
+/// Never wrap braces after a control statement.
+/// \code
+///   if (foo()) {
+///   } else {
+///   }
+///   for (int i = 0; i < 10; ++i) {
+///   }
+/// \endcode
+BWACS_Never,
+/// Only wrap braces after a multi-line control statement.
+/// \code
+///   if (foo && bar &&
+///   baz)
+///   {
+/// quux();
+///   }
+///   while (foo || bar) {
+///   }
+/// \endcode
+BWACS_MultiLine,
+/// Always wrap braces after a control statement.
+/// \code
+///   if (foo())
+///   {
+///   } else
+///   {}
+///   for (int i = 0; i < 10; ++i)
+///   {}
+/// \endcode
+BWACS_Always
+  };
+
   /// Precise control over the wrapping of braces.
   /// \code
   ///   # Should be declared 

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: chandlerc, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68410

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4391,3 +4391,13 @@
 
 }];
 }
+
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];
+  let Heading = "always_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -636,7 +636,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4391,3 +4391,13 @@
 
 }];
 }
+
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];
+  let Heading = "always_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -636,7 +636,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68242: [clang-format] [PR42417] clang-format inserts a space after '->' for operator->() overloading

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D68242



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


[PATCH] D68296: [clang-format] Add ability to wrap braces after multi-line control statements

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar updated this revision to Diff 223058.
mitchell-stellar added a comment.

Rebased against master, and also added test case for 'do' statements.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68296

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestObjC.cpp

Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -207,7 +207,7 @@
"  f();\n"
"}\n");
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   verifyFormat("@autoreleasepool\n"
"{\n"
"  f();\n"
@@ -237,7 +237,7 @@
"  f();\n"
"}\n");
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   verifyFormat("@synchronized(self)\n"
"{\n"
"  f();\n"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -644,7 +644,8 @@
   AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
   FormatStyle::SIS_WithoutElse;
   AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
-  AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement = true;
+  AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement =
+  FormatStyle::BWACS_Always;
 
   verifyFormat("if (true) {}", AllowSimpleBracedStatements);
   verifyFormat("if constexpr (true) {}", AllowSimpleBracedStatements);
@@ -1168,7 +1169,7 @@
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterCaseLabel = true;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   EXPECT_EQ("switch (n)\n"
 "{\n"
 "  case 0:\n"
@@ -1370,7 +1371,7 @@
   Style.AllowShortCaseLabelsOnASingleLine = true;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterCaseLabel = true;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   EXPECT_EQ("switch (n)\n"
 "{\n"
 "  case 0:\n"
@@ -1441,6 +1442,131 @@
"}");
 }
 
+TEST_F(FormatTest, MultiLineControlStatements) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
+  Style.ColumnLimit = 20;
+  // Short lines should keep opening brace on same line.
+  EXPECT_EQ("if (foo) {\n"
+"  bar();\n"
+"}",
+format("if(foo){bar();}", Style));
+  EXPECT_EQ("if (foo) {\n"
+"  bar();\n"
+"} else {\n"
+"  baz();\n"
+"}",
+format("if(foo){bar();}else{baz();}", Style));
+  EXPECT_EQ("if (foo && bar) {\n"
+"  baz();\n"
+"}",
+format("if(foo&){baz();}", Style));
+  EXPECT_EQ("if (foo) {\n"
+"  bar();\n"
+"} else if (baz) {\n"
+"  quux();\n"
+"}",
+format("if(foo){bar();}else if(baz){quux();}", Style));
+  EXPECT_EQ(
+  "if (foo) {\n"
+  "  bar();\n"
+  "} else if (baz) {\n"
+  "  quux();\n"
+  "} else {\n"
+  "  foobar();\n"
+  "}",
+  format("if(foo){bar();}else if(baz){quux();}else{foobar();}", Style));
+  EXPECT_EQ("for (;;) {\n"
+"  foo();\n"
+"}",
+format("for(;;){foo();}"));
+  EXPECT_EQ("while (1) {\n"
+"  foo();\n"
+"}",
+format("while(1){foo();}", Style));
+  EXPECT_EQ("switch (foo) {\n"
+"case bar:\n"
+"  return;\n"
+"}",
+format("switch(foo){case bar:return;}", Style));
+  EXPECT_EQ("try {\n"
+"  foo();\n"
+"} catch (...) {\n"
+"  bar();\n"
+"}",
+format("try{foo();}catch(...){bar();}", Style));
+  EXPECT_EQ("do {\n"
+"  foo();\n"
+"} while (bar &&\n"
+" baz);",
+format("do{foo();}while(bar&);", Style));
+  // Long lines should put opening brace on new line.
+  

r373643 - PR43547: substitute into the type of a non-type template parameter if

2019-10-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  3 11:24:40 2019
New Revision: 373643

URL: http://llvm.org/viewvc/llvm-project?rev=373643=rev
Log:
PR43547: substitute into the type of a non-type template parameter if
it's instantiation-dependent, even if it's not dependent.

There might be a SFINAE check in the parameter type.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=373643=373642=373643=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Oct  3 11:24:40 2019
@@ -4922,9 +4922,7 @@ bool Sema::CheckTemplateArgument(NamedDe
 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
   NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
 
-// FIXME: Do we need to substitute into parameters here if they're
-// instantiation-dependent but not dependent?
-if (NTTPType->isDependentType() &&
+if (NTTPType->isInstantiationDependentType() &&
 !isa(Template) &&
 !Template->getDeclContext()->isDependentContext()) {
   // Do substitution on the type of the non-type template parameter.

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=373643=373642=373643=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Thu Oct  3 11:24:40 2019
@@ -482,3 +482,15 @@ namespace dependent_backreference {
   template void a() { X x; }
   template void b() { X x; } // expected-note 
{{substituting}}
 }
+
+namespace instantiation_dependent {
+  template void f(int);
+  template int (...);
+  int  = f(0);
+
+  // FIXME: This fails because we mishandle instantiation-dependent array 
bounds :(
+  int arr[sizeof(sizeof(int))];
+  template void g(int);
+  template int (...);
+  int  = g(0); // expected-error {{cannot bind}}
+}


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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373634: [HIP] Enable specifying different default gpu arch 
for HIP/CUDA. (authored by hliao, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68394?vs=223015=223055#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68394

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/hip-default-gpu-arch.hip


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2329,6 +2329,10 @@
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation , DerivedArgList ,
   const Driver::InputList ,
@@ -2518,7 +2522,7 @@
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@
   public:
 CudaActionBuilder(Compilation , DerivedArgList ,
   const Driver::InputList )
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences ,
@@ -2645,7 +2651,9 @@
   public:
 HIPActionBuilder(Compilation , DerivedArgList ,
  const Driver::InputList )
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX803;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 
Index: cfe/trunk/test/Driver/hip-default-gpu-arch.hip
===
--- cfe/trunk/test/Driver/hip-default-gpu-arch.hip
+++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2329,6 +2329,10 @@
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation , DerivedArgList ,
   const Driver::InputList ,
@@ -2518,7 +2522,7 @@
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@
   public:
 CudaActionBuilder(Compilation , DerivedArgList ,
   const Driver::InputList )
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences ,
@@ -2645,7 +2651,9 @@
   public:
 HIPActionBuilder(Compilation , DerivedArgList ,
  const Driver::InputList )
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX803;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 
Index: cfe/trunk/test/Driver/hip-default-gpu-arch.hip
===
--- cfe/trunk/test/Driver/hip-default-gpu-arch.hip
+++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373634 - [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via cfe-commits
Author: hliao
Date: Thu Oct  3 10:49:20 2019
New Revision: 373634

URL: http://llvm.org/viewvc/llvm-project?rev=373634=rev
Log:
[HIP] Enable specifying different default gpu arch for HIP/CUDA.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Driver/hip-default-gpu-arch.hip
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=373634=373633=373634=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct  3 10:49:20 2019
@@ -2329,6 +2329,10 @@ class OffloadingActionBuilder final {
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation , DerivedArgList ,
   const Driver::InputList ,
@@ -2518,7 +2522,7 @@ class OffloadingActionBuilder final {
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@ class OffloadingActionBuilder final {
   public:
 CudaActionBuilder(Compilation , DerivedArgList ,
   const Driver::InputList )
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences ,
@@ -2645,7 +2651,9 @@ class OffloadingActionBuilder final {
   public:
 HIPActionBuilder(Compilation , DerivedArgList ,
  const Driver::InputList )
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX803;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 

Added: cfe/trunk/test/Driver/hip-default-gpu-arch.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-default-gpu-arch.hip?rev=373634=auto
==
--- cfe/trunk/test/Driver/hip-default-gpu-arch.hip (added)
+++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip Thu Oct  3 10:49:20 2019
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"


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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 accepted this revision.
ashi1 added a comment.

LGTM - Thanks for generalizing


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

https://reviews.llvm.org/D68300



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


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Work in progress because this needs tests (and probably clang-format too).

My assumption is that libgcc should be used in preference if it is available. 
At the moment this either uses libgcc and libgcc's crtbegin/crtend, or the 
Clang equivalents. Potentially a user might want to mix compiler-rt builtins 
with libgcc's crt*.o files, but for now that's not possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68407



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


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
edward-jones added a reviewer: asb.
Herald added subscribers: cfe-commits, pzheng, simoncook, s.egerton, lenary, 
Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, 
rogfer01, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
apazos, johnrusso, rbar, dberris.
Herald added a project: clang.

If a GCC installation is not detected, they this attempts to use compiler-rt 
and the compiler-rt crtbegin/crtend implementations as a fallback.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h


Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain , bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -36,7 +36,8 @@
 }
 
 Tool *RISCVToolChain::buildLinker() const {
-  return new tools::RISCV::Linker(*this);
+  bool useLibGCC = GCCInstallation.isValid();
+  return new tools::RISCV::Linker(*this, useLibGCC);
 }
 
 void RISCVToolChain::addClangTargetOptions(
@@ -94,7 +95,7 @@
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
-  const ToolChain  = getToolChain();
+  const auto  = getToolChain();
   const Driver  = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -106,9 +107,28 @@
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
+  const char *crtbegin, *crtend, *rtlib;
+  if (UseLibGCC) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+rtlib = "-lgcc";
+  } else {
+auto Arch = ToolChain.getTriple().getArch();
+if (Arch == llvm::Triple::ArchType::riscv32) {
+  crtbegin = "clang_rt.crtbegin-riscv32.o";
+  crtend = "clang_rt.crtend-riscv32.o";
+  rtlib = "-lclang_rt.builtins-riscv32";
+} else {
+  assert(Arch == llvm::Triple::ArchType::riscv64);
+  crtbegin = "clang_rt.crtbegin-riscv64.o";
+  crtend = "clang_rt.crtend-riscv64.o";
+  rtlib = "-lclang_rt.builtins-riscv64";
+}
+  }
+
   if (WantCRTs) {
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -129,11 +149,11 @@
 CmdArgs.push_back("-lc");
 CmdArgs.push_back("-lgloss");
 CmdArgs.push_back("--end-group");
-CmdArgs.push_back("-lgcc");
+CmdArgs.push_back(rtlib);
   }
 
   if (WantCRTs)
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
 
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());


Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain , bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp

[PATCH] D20561: Warn when taking address of packed member

2019-10-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

I think I found a false negative with this where if the member is accessed from 
a packed struct type returned from a function, the warning does not appear:

  typedef struct {
uint8_t a;
uint32_t b; 
  } __attribute__((packed)) registers_t;
  
  registers_t *Class::method() { return registers_; }
  
  void Class::func() {
other_func(()->b);  // I think the warning should appear here?
  }


Repository:
  rL LLVM

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

https://reviews.llvm.org/D20561



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


[libunwind] r373628 - [libunwind] Adjust libunwind_01.pass.cpp test for ARM EHABI

2019-10-03 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Thu Oct  3 10:01:04 2019
New Revision: 373628

URL: http://llvm.org/viewvc/llvm-project?rev=373628=rev
Log:
[libunwind] Adjust libunwind_01.pass.cpp test for ARM EHABI

ARM EHABI unwinding tables only store the start address of each function, so the
last function is assumed to cover the entire address space after it. The test
picks an address on the stack assuming that it's in no function, but because of
the above it's actually resolved to the last function. Fix this by using address
0 instead.

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

Modified:
libunwind/trunk/test/libunwind_01.pass.cpp

Modified: libunwind/trunk/test/libunwind_01.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/libunwind_01.pass.cpp?rev=373628=373627=373628=diff
==
--- libunwind/trunk/test/libunwind_01.pass.cpp (original)
+++ libunwind/trunk/test/libunwind_01.pass.cpp Thu Oct  3 10:01:04 2019
@@ -48,7 +48,7 @@ void test_no_info() {
 abort();
 
   // Set the IP to an address clearly outside any function.
-  unw_set_reg(, UNW_REG_IP, (unw_word_t));
+  unw_set_reg(, UNW_REG_IP, (unw_word_t)0);
 
   ret = unw_get_proc_info(, );
   if (ret != UNW_ENOINFO)


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


r373626 - DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 09:58:01 2019
New Revision: 373626

URL: http://llvm.org/viewvc/llvm-project?rev=373626=rev
Log:
DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null 
dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=373626=373625=373626=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Oct  3 09:58:01 2019
@@ -959,11 +959,11 @@ const FunctionType *Decl::getFunctionTyp
 return nullptr;
 
   if (Ty->isFunctionPointerType())
-Ty = Ty->getAs()->getPointeeType();
+Ty = Ty->castAs()->getPointeeType();
   else if (Ty->isFunctionReferenceType())
-Ty = Ty->getAs()->getPointeeType();
+Ty = Ty->castAs()->getPointeeType();
   else if (BlocksToo && Ty->isBlockPointerType())
-Ty = Ty->getAs()->getPointeeType();
+Ty = Ty->castAs()->getPointeeType();
 
   return Ty->getAs();
 }

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=373626=373625=373626=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Oct  3 09:58:01 2019
@@ -2566,7 +2566,7 @@ bool CXXConstructorDecl::isConvertingCon
 return false;
 
   return (getNumParams() == 0 &&
-  getType()->getAs()->isVariadic()) ||
+  getType()->castAs()->isVariadic()) ||
  (getNumParams() == 1) ||
  (getNumParams() > 1 &&
   (getParamDecl(1)->hasDefaultArg() ||

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=373626=373625=373626=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Oct  3 09:58:01 2019
@@ -519,15 +519,15 @@ SourceRange TemplateTypeParmDecl::getSou
 }
 
 unsigned TemplateTypeParmDecl::getDepth() const {
-  return getTypeForDecl()->getAs()->getDepth();
+  return getTypeForDecl()->castAs()->getDepth();
 }
 
 unsigned TemplateTypeParmDecl::getIndex() const {
-  return getTypeForDecl()->getAs()->getIndex();
+  return getTypeForDecl()->castAs()->getIndex();
 }
 
 bool TemplateTypeParmDecl::isParameterPack() const {
-  return getTypeForDecl()->getAs()->isParameterPack();
+  return getTypeForDecl()->castAs()->isParameterPack();
 }
 
 
//===--===//


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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/Driver.cpp:2538
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}

hliao wrote:
> tra wrote:
> > This technically depends on the CUDA version.
> > We do have CUDA version info in `clang/lib/Driver/ToolChains/Cuda.h`
> > The default for NVCC has been sm_30 since CUDA-9.0.  In fact sm_20 is not 
> > supported at all by CUDA-9.0+ at all , so we should bump the default to 
> > sm_30 for those versions.
> > 
> unfortunately, when the action build is running, the CUDA is not detected 
> yet, I probably revise the detection logic to update CUDA's default gpu arch 
> after successful detection
OK. If there's no easy way to do it here, it's probably not worth doing it just 
to keep sm_20 as the default.
sm_20 has not been supported by the last two major CUDA releases and it makes 
little sense to have the default that does not work for the majority of current 
users.

I think we should just bump the default to sm_30 for all currently supported 
CUDA versions in a separate patch. I can do it once this patch lands.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


r373624 - [OPENMP]Fix emission of the declare target variables in device mode.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 09:46:49 2019
New Revision: 373624

URL: http://llvm.org/viewvc/llvm-project?rev=373624=rev
Log:
[OPENMP]Fix emission of the declare target variables in device mode.

Declare target variables must be emitted in device mode, target triples
can be empty in this case.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373624=373623=373624=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 09:46:49 2019
@@ -2868,7 +2868,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
 bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
  llvm::GlobalVariable 
*Addr,
  bool PerformInit) {
-  if (CGM.getLangOpts().OMPTargetTriples.empty())
+  if (CGM.getLangOpts().OMPTargetTriples.empty() &&
+  !CGM.getLangOpts().OpenMPIsDevice)
 return false;
   Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
@@ -9806,7 +9807,8 @@ CGOpenMPRuntime::registerTargetFirstpriv
 
 void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
llvm::Constant *Addr) {
-  if (CGM.getLangOpts().OMPTargetTriples.empty())
+  if (CGM.getLangOpts().OMPTargetTriples.empty() &&
+  !CGM.getLangOpts().OpenMPIsDevice)
 return;
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=373624=373623=373624=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Thu Oct  3 09:46:49 2019
@@ -1,29 +1,22 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-emit-pch -o %t
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-include-pch %t -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix HOST5
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc 
-fopenmp-version=50 -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 -DOMP5 | 
FileCheck %s --check-prefix DEV5
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix DEV5
 
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -o - -fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 
KMPC-ONLY
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50 -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 

[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: include/clang/Driver/Options.td:606
+def flink_builtin_bitcode : Flag<["-"], "flink-builtin-bitcode">,
+  Flags<[CC1Option]>, HelpText<"Link builtin bitcode for HIP device 
compilation.">;
+def fno_link_builtin_bitcode : Flag<["-"], "fno-link-builtin-bitcode">;

tra wrote:
> hliao wrote:
> > tra wrote:
> > > yaxunl wrote:
> > > > ashi1 wrote:
> > > > > Since this is a more generic approach, we won't need to specify HIP ?
> > > > this patch only implemented this option for HIP. If it is used for 
> > > > other languages, this help text should be updated.
> > > Hmm. Cuda currently uses `-nocudalib` for essentially the same purpose 
> > > (Sort of like `-nostdlib`, but for CUDA). Perhaps we should consolidate 
> > > all these into `-nogpulib` and alias `-nocudalib` to it. 
> > how about other relevant options, such as replacing cuda-device-only with 
> > gpu-device-only or hip-device-only to avoid confusing with CUDA.
> We seem to be doing exactly that, only incrementally. In general it does make 
> sense to consolidate the flags where the functionality is common.
> `cuda-device-only`, `cuda_host_only`, `cuda_compile_host_device`  and 
> `cuda-gpu-arch` could be generalized to `gpu-`. 
> 
> This should be a separate patch, though.
agree


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

https://reviews.llvm.org/D68300



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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2655
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX600;
+}

hliao wrote:
> Sam, could you let me know which reasonable default arch should we use here?
I think it should be gfx803 since as far as I know it is the lowest one that 
supports HIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: include/clang/Driver/Options.td:606
+def flink_builtin_bitcode : Flag<["-"], "flink-builtin-bitcode">,
+  Flags<[CC1Option]>, HelpText<"Link builtin bitcode for HIP device 
compilation.">;
+def fno_link_builtin_bitcode : Flag<["-"], "fno-link-builtin-bitcode">;

hliao wrote:
> tra wrote:
> > yaxunl wrote:
> > > ashi1 wrote:
> > > > Since this is a more generic approach, we won't need to specify HIP ?
> > > this patch only implemented this option for HIP. If it is used for other 
> > > languages, this help text should be updated.
> > Hmm. Cuda currently uses `-nocudalib` for essentially the same purpose 
> > (Sort of like `-nostdlib`, but for CUDA). Perhaps we should consolidate all 
> > these into `-nogpulib` and alias `-nocudalib` to it. 
> how about other relevant options, such as replacing cuda-device-only with 
> gpu-device-only or hip-device-only to avoid confusing with CUDA.
We seem to be doing exactly that, only incrementally. In general it does make 
sense to consolidate the flags where the functionality is common.
`cuda-device-only`, `cuda_host_only`, `cuda_compile_host_device`  and 
`cuda-gpu-arch` could be generalized to `gpu-`. 

This should be a separate patch, though.


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

https://reviews.llvm.org/D68300



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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2538
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}

tra wrote:
> This technically depends on the CUDA version.
> We do have CUDA version info in `clang/lib/Driver/ToolChains/Cuda.h`
> The default for NVCC has been sm_30 since CUDA-9.0.  In fact sm_20 is not 
> supported at all by CUDA-9.0+ at all , so we should bump the default to sm_30 
> for those versions.
> 
unfortunately, when the action build is running, the CUDA is not detected yet, 
I probably revise the detection logic to update CUDA's default gpu arch after 
successful detection


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


[PATCH] D68403: [OpenCL] PR43145: preserve addrspace for class accesses

2019-10-03 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.

PR43145 revealed two places where Clang was attempting to create a
bitcast without considering the address space of class types during
C++ class codegen.


Repository:
  rC Clang

https://reviews.llvm.org/D68403

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -11,6 +11,7 @@
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D 
addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -246,7 +246,8 @@
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 CGM.GetNonVirtualBaseClassOffset(Derived, PathBegin, PathEnd);


Index: test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -11,6 +11,7 @@
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -246,7 +246,8 @@
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 

  1   2   >