[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-03 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

> ! In https://reviews.llvm.org/D33852#772290, @davide wrote:
>  This assumption is not quite right. Also GCC, when targeting Linux, provides 
> a `-fms-extensions` flag.
>  There's a bunch of software out there that unfortunately has to target ELF 
> and build with `-fms-extensions` on, e.g. PS4.

Seems like bad practice but on a second look that is does appear that PS4 and 
CUDA both use `-fms-extensions` and rely on it for some things. argh
CUDA does have a note to move off this in future.
Thanks for clarifying davide

This patch does LGTM minus the nit above.
Adding `selectany` spelling to `-fdeclspec` as well as `-fms-extensions` should 
cover all use cases.
The MachO issue would have been present before `rL300562` so I don't think that 
should have to be fixed here.
It could be covered in a follow up differential as this fixes a regression on 
my part.




Comment at: test/Sema/attr-selectany.c:3
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fms-extensions %s
 

Based on the current changes you can change `-fms-extensions` to `-fdeclspec`
The `-fms-extensions` coverage is covered in `attr-selectany.cpp` below


https://reviews.llvm.org/D33852



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-03 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

In https://reviews.llvm.org/D33852#772230, @martell wrote:

> @Prazek it was not disabled by mistake.
>  This was a MS extension and it appeared as though the test case should have 
> been for windows.
>  I updated it and made the extension available to windows only. (MSVC, 
> Cygwin, Mingw etc)
>  It didn't expect anyone would want a MS extension for a linux target.


This assumption is not quite right. Also GCC, when targeting Linux, provides a 
`-fms-extensions` flag.
There's a bunch of software out there that unfortunately has to target ELF and 
build with `-fms-extensions` on, e.g. PS4.


https://reviews.llvm.org/D33852



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-03 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@Prazek it wasn't disabled by mistake.
This was a MS extension and it appeared as though the test case should have 
been for windows.
I updated it and made the extension available to windows only. (MSVC, Cygwin, 
Mingw etc)
It didn't expect anyone would want a MS extension for a linux target.

I don't think it is unreasonable to have support for this though. 
Adding @rnk here as he may have some comments.


https://reviews.llvm.org/D33852



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-03 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

It seems that this is separate issue - we don't generate comdat for MachO. 
Indeed we should warn on not supported declspec for macho.


https://reviews.llvm.org/D33852



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


Re: r304663 - Fixed warning: enum constant in boolean context.

2017-06-03 Thread Richard Smith via cfe-commits
Can we get a testcase for this bug? Seems like we can't have any coverage
for the case where IsArmArch is supposed to be false.

On 3 Jun 2017 9:47 am, "Galina Kistanova via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: gkistanova
Date: Sat Jun  3 11:47:06 2017
New Revision: 304663

URL: http://llvm.org/viewvc/llvm-project?rev=304663&view=rev
Log:
Fixed warning: enum constant in boolean context.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
ToolChains/Linux.cpp?rev=304663&r1=304662&r2=304663&view=diff

==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Sat Jun  3 11:47:06 2017
@@ -822,8 +822,9 @@ SanitizerMask Linux::getSupportedSanitiz
   const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
  getTriple().getArch() == llvm::Triple::aarch64_be;
   const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
- llvm::Triple::thumb || llvm::Triple::armeb ||
- llvm::Triple::thumbeb;
+ getTriple().getArch() == llvm::Triple::thumb ||
+ getTriple().getArch() == llvm::Triple::armeb ||
+ getTriple().getArch() == llvm::Triple::thumbeb;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;


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


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

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

This causes a test failure with non-standard CLANG_RESOURCE_DIR:

  Command Output (stderr):
  --
  
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/baremetal.cpp:8:22:
 error: expected string not found in input
  // CHECK-V6M-C-SAME: "-resource-dir" 
"[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
   ^
  :5:128: note: scanning from here
   
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/clang"
 "-cc1" "-triple" "thumbv6m-none--eabi" "-emit-obj" "-mrelax-all" 
"-disable-free" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "baremetal.cpp" "-mrelocation-model" "static" 
"-mthread-model" "single" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-mconstructor-aliases" "-nostdsysteminc" "-target-cpu" 
"cortex-m0" "-target-feature" "+soft-float-abi" "-target-feature" 
"+strict-align" "-target-abi" "aapcs" "-mfloat-abi" "soft" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0"
 "-isysroot" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include/c++/v1"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0/include"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include"
 "-fdeprecated-macro" "-fdebug-compilation-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" 
"-fallow-half-arguments-and-returns" "-fno-signed-char" "-fobjc-runtime=gcc" 
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" 
"/var/tmp/portage/sys-devel/clang-/temp/baremetal-6b1d37.o" "-x" "c++" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/baremetal.cpp"

 ^
  :5:128: note: with variable "PREFIX_DIR" equal to 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/."
   
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/clang"
 "-cc1" "-triple" "thumbv6m-none--eabi" "-emit-obj" "-mrelax-all" 
"-disable-free" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "baremetal.cpp" "-mrelocation-model" "static" 
"-mthread-model" "single" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-mconstructor-aliases" "-nostdsysteminc" "-target-cpu" 
"cortex-m0" "-target-feature" "+soft-float-abi" "-target-feature" 
"+strict-align" "-target-abi" "aapcs" "-mfloat-abi" "soft" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0"
 "-isysroot" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include/c++/v1"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0/include"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include"
 "-fdeprecated-macro" "-fdebug-compilation-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" 
"-fallow-half-arguments-and-returns" "-fno-signed-char" "-fobjc-runtime=gcc" 
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" 
"/var/tmp/portage/sys-devel/clang-/temp/baremetal-6b1d37.o" "-x" "c++" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/baremetal.cpp"

 ^
  :5:588: note: possible intended match here
   
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/clang"
 "-cc1" "-triple" "thumbv6m-none--eabi" "-emit-obj" "-mrelax-all" 
"-disable-free" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "baremetal.cpp" "-mrelocation-model" "static" 
"-mthread-model" "single" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-mconstructor-aliases" "-nostdsysteminc" "-target-cpu" 
"cortex-m0" "-target-feature" "+soft-float-abi" "-target-feature" 
"+strict-align" "-target-abi" "aapcs" "-mfloat-abi" "soft" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin

[libcxxabi] r304664 - [libcxxabi] HandleLLVMOptions in out of tree build

2017-06-03 Thread Martell Malone via cfe-commits
Author: martell
Date: Sat Jun  3 12:23:19 2017
New Revision: 304664

URL: http://llvm.org/viewvc/llvm-project?rev=304664&view=rev
Log:
[libcxxabi] HandleLLVMOptions in out of tree build

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

Modified:
libcxxabi/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake

Modified: libcxxabi/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=304664&r1=304663&r2=304664&view=diff
==
--- libcxxabi/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxxabi/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Sat Jun  3 12:23:19 
2017
@@ -93,6 +93,7 @@ macro(configure_out_of_tree_llvm)
   endif()
   if (LLVM_FOUND)
 include(AddLLVM OPTIONAL)
+include(HandleLLVMOptions OPTIONAL)
   endif()
 
   # LLVM Options --


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


r304663 - Fixed warning: enum constant in boolean context.

2017-06-03 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Sat Jun  3 11:47:06 2017
New Revision: 304663

URL: http://llvm.org/viewvc/llvm-project?rev=304663&view=rev
Log:
Fixed warning: enum constant in boolean context.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=304663&r1=304662&r2=304663&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Sat Jun  3 11:47:06 2017
@@ -822,8 +822,9 @@ SanitizerMask Linux::getSupportedSanitiz
   const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
  getTriple().getArch() == llvm::Triple::aarch64_be;
   const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
- llvm::Triple::thumb || llvm::Triple::armeb ||
- llvm::Triple::thumbeb;
+ getTriple().getArch() == llvm::Triple::thumb ||
+ getTriple().getArch() == llvm::Triple::armeb ||
+ getTriple().getArch() == llvm::Triple::thumbeb;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;


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


r304662 - tests: silence -Wobjc-root-class warnings

2017-06-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Jun  3 11:18:13 2017
New Revision: 304662

URL: http://llvm.org/viewvc/llvm-project?rev=304662&view=rev
Log:
tests: silence -Wobjc-root-class warnings

Silence warnings about no ObjC class root for the types defined for the
tests.

Modified:
cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m
cfe/trunk/test/CodeGenObjC/metadata_symbols.m
cfe/trunk/test/CodeGenObjC/non-lazy-classes.m

Modified: cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m?rev=304662&r1=304661&r2=304662&view=diff
==
--- cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m (original)
+++ cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m Sat Jun  3 11:18:13 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions 
-fobjc-exceptions -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm 
-Wno-objc-root-class -fexceptions -fobjc-exceptions -o %t %s
 // RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s
 // RUN: FileCheck -check-prefix=CHECK-EHTYPE < %t %s
 // rdar://16462586
@@ -19,7 +19,7 @@
 // CHECK-X86_64: define internal void @"\01-[A im0]"
 // CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-exceptions 
-fvisibility hidden -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class 
-fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s
 // RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s
 
 // CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_MySecretNamespace.A" = hidden global 
{{.*}}, section "__DATA, __objc_data", align 8
@@ -30,7 +30,7 @@
 // CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
 // CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
 
-// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu 
-fobjc-exceptions -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu 
-Wno-objc-root-class -fobjc-exceptions -emit-llvm -o %t %s
 // RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
 
 // CHECK-ARMV6: @"OBJC_CLASS_$_MySecretNamespace.A" = global {{.*}}, section 
"__DATA, __objc_data", align 4

Modified: cfe/trunk/test/CodeGenObjC/metadata_symbols.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/metadata_symbols.m?rev=304662&r1=304661&r2=304662&view=diff
==
--- cfe/trunk/test/CodeGenObjC/metadata_symbols.m (original)
+++ cfe/trunk/test/CodeGenObjC/metadata_symbols.m Sat Jun  3 11:18:13 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions 
-fobjc-exceptions -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm 
-Wno-objc-root-class -fexceptions -fobjc-exceptions -o %t %s
 // RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s
 // RUN: FileCheck -check-prefix=CHECK-EHTYPE < %t %s
 
@@ -18,7 +18,7 @@
 // CHECK-X86_64: define internal void @"\01-[A im0]"
 // CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-exceptions 
-fvisibility hidden -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class 
-fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s
 // RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s
 
 // CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section 
"__DATA, __objc_data", align 8
@@ -29,7 +29,7 @@
 // CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
 // CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
 
-// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu 
-fobjc-exceptions -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu 
-Wno-objc-root-class -fobjc-exceptions -emit-llvm -o %t %s
 // RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
 
 // CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, 
__objc_data", align 4

Modified: cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/non-lazy-classes.m?rev=304662&r1=304661&r2=304662&view=diff
==
--- cfe/trunk/test/CodeGenObjC/non-lazy-classes.m (original)
+++ cfe/trunk/test/CodeGenObjC/non-lazy-classes.m Sat Jun  3 11:18:13 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class 
-emit-llvm -o - %s | \
 // RUN: FileCheck %s
 // CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [1 x {{.*}}] 
{{.*}}@"OBJC_CLASS_$_A"{{.*}}, section 
"__DATA,__objc_nlclslist,regular,no_dead_strip", align 8
 // CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private g

r304661 - CodeGen: fix section names for different file formats

2017-06-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Jun  3 11:18:09 2017
New Revision: 304661

URL: http://llvm.org/viewvc/llvm-project?rev=304661&view=rev
Log:
CodeGen: fix section names for different file formats

This changes the codegen to match the section names according to the
ObjC rewriter as well as the runtime.  The changes to the test are
simply whitespace changes to the section attributes and names and are
functionally equivalent (the whitespace is ignored by the linker).

Added:
cfe/trunk/test/CodeGenObjC/sections.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m
cfe/trunk/test/CodeGenObjC/image-info.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-64.m
cfe/trunk/test/CodeGenObjC/metadata_symbols.m
cfe/trunk/test/CodeGenObjC/non-lazy-classes.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=304661&r1=304660&r2=304661&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Jun  3 11:18:09 2017
@@ -1004,6 +1004,8 @@ protected:
   const ObjCInterfaceDecl *ID,
   ObjCCommonTypesHelper &ObjCTypes);
 
+  std::string GetSectionName(StringRef Section, StringRef MachOAttributes);
+
 public:
   /// CreateMetadataVar - Create a global variable with internal
   /// linkage for use by the Objective-C runtime.
@@ -4786,6 +4788,27 @@ llvm::Value *CGObjCMac::EmitIvarOffset(C
 
 /* *** Private Interface *** */
 
+std::string CGObjCCommonMac::GetSectionName(StringRef Section,
+StringRef MachOAttributes) {
+  switch (CGM.getTriple().getObjectFormat()) {
+  default:
+llvm_unreachable("unexpected object file format");
+  case llvm::Triple::MachO: {
+if (MachOAttributes.empty())
+  return ("__DATA," + Section).str();
+return ("__DATA," + Section + "," + MachOAttributes).str();
+  }
+  case llvm::Triple::ELF:
+assert(Section.substr(0, 2) == "__" &&
+   "expected the name to begin with __");
+return Section.substr(2).str();
+  case llvm::Triple::COFF:
+assert(Section.substr(0, 2) == "__" &&
+   "expected the name to begin with __");
+return ("." + Section.substr(2) + "$B").str();
+  }
+}
+
 /// EmitImageInfo - Emit the image info marker used to encode some module
 /// level information.
 ///
@@ -4809,9 +4832,10 @@ enum ImageInfoFlags {
 
 void CGObjCCommonMac::EmitImageInfo() {
   unsigned version = 0; // Version is unused?
-  const char *Section = (ObjCABI == 1) ?
-"__OBJC, __image_info,regular" :
-"__DATA, __objc_imageinfo, regular, no_dead_strip";
+  std::string Section =
+  (ObjCABI == 1)
+  ? "__OBJC,__image_info,regular"
+  : GetSectionName("__objc_imageinfo", "regular,no_dead_strip");
 
   // Generate module-level named metadata to convey this information to the
   // linker and code-gen.
@@ -4822,7 +4846,7 @@ void CGObjCCommonMac::EmitImageInfo() {
   Mod.addModuleFlag(llvm::Module::Error, "Objective-C Image Info Version",
 version);
   Mod.addModuleFlag(llvm::Module::Error, "Objective-C Image Info Section",
-llvm::MDString::get(VMContext,Section));
+llvm::MDString::get(VMContext, Section));
 
   if (CGM.getLangOpts().getGC() == LangOptions::NonGC) {
 // Non-GC overrides those files which specify GC.
@@ -5930,17 +5954,21 @@ void CGObjCNonFragileABIMac::FinishNonFr
   }
 
   AddModuleClassList(DefinedClasses, "OBJC_LABEL_CLASS_$",
- "__DATA, __objc_classlist, regular, no_dead_strip");
+ GetSectionName("__objc_classlist",
+"regular,no_dead_strip"));
 
   AddModuleClassList(DefinedNonLazyClasses, "OBJC_LABEL_NONLAZY_CLASS_$",
- "__DATA, __objc_nlclslist, regular, no_dead_strip");
+ GetSectionName("__objc_nlclslist",
+"regular,no_dead_strip"));
 
   // Build list of all implemented category addresses in array
   // L_OBJC_LABEL_CATEGORY_$.
   AddModuleClassList(DefinedCategories, "OBJC_LABEL_CATEGORY_$",
- "__DATA, __objc_catlist, regular, no_dead_strip");
+ GetSectionName("__objc_catlist",
+"regular,no_dead_strip"));
   AddModuleClassList(DefinedNonLazyCategories, "OBJC_LABEL_NONLAZY_CATEGORY_$",
- "__DATA, __objc_nlcatlist, regular, no_dead_strip");
+ GetSectionName("__objc_nlcatlist",
+"regular,no_dead_strip"));
 
   EmitImageInfo();
 }
@@ -6359,7 +6387,8 @@ llvm::Value *CGObjCNonFragileABIMac::Gen
 llvm::GlobalValue::WeakAnyLinkage,
 Init,
 ProtocolName);
-  PTGV->setSection("__DATA, __objc_p

[clang-tools-extra] r304657 - [clang-tidy] Make misc-static-assert accept assert(!"msg")

2017-06-03 Thread Florian Gross via cfe-commits
Author: fgross
Date: Sat Jun  3 05:13:55 2017
New Revision: 304657

URL: http://llvm.org/viewvc/llvm-project?rev=304657&view=rev
Log:
[clang-tidy] Make misc-static-assert accept assert(!"msg")

Added negated string literals to the set of IsAlwaysFalse expressions to avoid 
flagging of assert(!"msg").

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp?rev=304657&r1=304656&r2=304657&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Sat Jun  3 
05:13:55 2017
@@ -33,9 +33,11 @@ void StaticAssertCheck::registerMatchers
   if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
+  auto NegatedString = unaryOperator(
+  hasOperatorName("!"), 
hasUnaryOperand(ignoringImpCasts(stringLiteral(;
   auto IsAlwaysFalse =
   expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
- cxxNullPtrLiteralExpr(), gnuNullExpr()))
+ cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
   .bind("isAlwaysFalse");
   auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
   IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp?rev=304657&r1=304656&r2=304657&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp Sat Jun  3 
05:13:55 2017
@@ -76,6 +76,9 @@ int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
   // CHECK-FIXES: {{^  }}static_assert(ZERO_MACRO, "");
 
+  assert(!"Don't report me!");
+  // CHECK-FIXES: {{^  }}assert(!"Don't report me!");
+
   assert(0 && "Don't report me!");
   // CHECK-FIXES: {{^  }}assert(0 && "Don't report me!");
 


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


[PATCH] D33827: [clang-tidy] misc-static-assert shouldn't flag assert(!"msg")

2017-06-03 Thread Florian Gross via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304657: [clang-tidy] Make misc-static-assert accept 
assert(!"msg") (authored by fgross).

Changed prior to commit:
  https://reviews.llvm.org/D33827?vs=101197&id=101311#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33827

Files:
  clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
@@ -76,6 +76,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
   // CHECK-FIXES: {{^  }}static_assert(ZERO_MACRO, "");
 
+  assert(!"Don't report me!");
+  // CHECK-FIXES: {{^  }}assert(!"Don't report me!");
+
   assert(0 && "Don't report me!");
   // CHECK-FIXES: {{^  }}assert(0 && "Don't report me!");
 
Index: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
@@ -33,9 +33,11 @@
   if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
+  auto NegatedString = unaryOperator(
+  hasOperatorName("!"), 
hasUnaryOperand(ignoringImpCasts(stringLiteral(;
   auto IsAlwaysFalse =
   expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
- cxxNullPtrLiteralExpr(), gnuNullExpr()))
+ cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
   .bind("isAlwaysFalse");
   auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
   IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))


Index: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
@@ -76,6 +76,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
   // CHECK-FIXES: {{^  }}static_assert(ZERO_MACRO, "");
 
+  assert(!"Don't report me!");
+  // CHECK-FIXES: {{^  }}assert(!"Don't report me!");
+
   assert(0 && "Don't report me!");
   // CHECK-FIXES: {{^  }}assert(0 && "Don't report me!");
 
Index: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
@@ -33,9 +33,11 @@
   if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
+  auto NegatedString = unaryOperator(
+  hasOperatorName("!"), hasUnaryOperand(ignoringImpCasts(stringLiteral(;
   auto IsAlwaysFalse =
   expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
- cxxNullPtrLiteralExpr(), gnuNullExpr()))
+ cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
   .bind("isAlwaysFalse");
   auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
   IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits