[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 285362.
abhina.sreeskantharajan added a comment.

Thanks Hubert and Fanbo for reviewing. I updated the comment to Hubert's 
suggestion, and updated both testcases as requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/trigraphs.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,25 @@
-// RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck 
--check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify=notri
+// RUN: %clang_cc1 -std=c++1z %s -verify=tri -ftrigraphs
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+??= define foo ;
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} 
expected-warning {{trigraph ignored}}
+static_assert("??="[0] == '#', "");
 
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
 // ??/  
-error here; // expected-error {{}}
+error here;
+
+#ifndef __MVS__
+// notri-error@4 {{}} notri-warning@4 {{trigraph ignored}} tri-warning@4 
{{trigraph converted}}
+// notri-error@6 {{failed}} notri-warning@6 {{trigraph ignored}} tri-warning@6 
{{trigraph converted}}
+// notri-error@9 {{}}
+// tri-warning@12 {{backslash and newline separated by space}}
+// notri-error@13 {{}}
+#else
+// notri-warning@4 {{trigraph converted}} tri-warning@4 {{trigraph converted}}
+// notri-warning@6 {{trigraph converted}} tri-warning@6 {{trigraph converted}}
+// notri-warning@12 {{backslash and newline separated by space}} 
tri-warning@12 {{backslash and newline separated by space}}
+#endif
Index: clang/test/Frontend/trigraphs.cpp
===
--- clang/test/Frontend/trigraphs.cpp
+++ clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,14 @@
 // RUN: %clang_cc1 -DSTDCPP17 -std=c++1z -verify -fsyntax-only %s
 // RUN: %clang_cc1 -DSTDCPP17TRI -ftrigraphs -std=c++1z -verify -fsyntax-only 
%s
 // RUN: %clang_cc1 -DMSCOMPAT -fms-compatibility -std=c++11 -verify 
-fsyntax-only %s
+// RUN: %clang_cc1 -DNOTRI -fno-trigraphs -verify -fsyntax-only %s
 
 void foo() {
 #if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
-defined(STDCPP17TRI)
+defined(STDCPP17TRI) || (defined(__MVS__) && !defined(NOTRI))
   const char c[] = "??/n"; // expected-warning{{trigraph converted to '\' 
character}}
-#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT)
+#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT) || \
+defined(NOTRI)
   const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
 #else
 #error Not handled.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2787,7 +2787,9 @@
   // Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
   // is specified, or -std is set to a conforming mode.
   // Trigraphs are disabled by default in c++1z onwards.
-  Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+  // For z/OS, trigraphs are enabled by default (without regard to the above).
+  Opts.Trigraphs =
+  (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =
   Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,25 @@
-// RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck --check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify=notri
+// RUN: %clang_cc1 -std=c++1z %s -verify=tri -ftrigraphs
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+??= define foo ;
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+static_assert("??="[0] == '#', "");
 
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
 // ??/  
-error here; // expected-e

[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 3 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2791
+  Opts.Trigraphs =
+  (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =

hubert.reinterpretcast wrote:
> I would like to point out that processing trigraphs when most platforms don't 
> would be a portability concern. Clang appears to mitigate this somewhat with 
> warnings.
Unfortunately we can't move away from this because the system headers currently 
use trigraphs. But we will definitely look into whether we can update these 
headers to not be dependent on trigraphs and improve portability.



Comment at: clang/test/Frontend/trigraphs.cpp:8
+// RUN: %clang_cc1 -DZOS -triple=s390x-none-zos -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DZOSNOTRI -triple=s390x-none-zos -fno-trigraphs -verify 
-fsyntax-only %s
 

hubert.reinterpretcast wrote:
> Do we know if `-fno-trigraphs` is meaningfully functional on z/OS? I believe 
> trigraph usage might need to be replaced to use digraphs in the system 
> headers before using `-fno-trigraphs` can be expected to work in a real user 
> application.
With the current system headers, compiling with -fno-trigraphs would not work 
in a user application. As mentioned above, we will look into whether we can 
remove this dependency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

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


[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 285399.
abhina.sreeskantharajan added a comment.

Thanks Hubert for the suggestion. I've updated the lit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/trigraphs.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,31 @@
 // RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck 
--check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify -ftrigraphs -DENABLED_TRIGRAPHS=1
+// RUN: %clang_cc1 -std=c++1z %s -verify -fno-trigraphs -DENABLED_TRIGRAPHS=0
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+#ifdef __MVS__
+#ifndef ENABLED_TRIGRAPHS
+#define ENABLED_TRIGRAPHS 1
+#endif
+#endif
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} 
expected-warning {{trigraph ignored}}
+??= define foo ;
 
+static_assert("??="[0] == '#', "");
+
+// ??/
+error here;
+
+// Note, there is intentionally trailing whitespace one lines below.
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
-// ??/  
-error here; // expected-error {{}}
+#if !ENABLED_TRIGRAPHS
+// expected-error@11 {{}} expected-warning@11 {{trigraph ignored}}
+// expected-error@13 {{}} {failed}} expected-warning@13 {{trigraph ignored}}
+// expected-error@16 {{}}
+// expected-error@20 {{}}
+#else
+// expected-warning@11 {{trigraph converted}}
+// expected-warning@13 {{trigraph converted}}
+// expected-warning@19 {{backslash and newline separated by space}}
+#endif
Index: clang/test/Frontend/trigraphs.cpp
===
--- clang/test/Frontend/trigraphs.cpp
+++ clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,14 @@
 // RUN: %clang_cc1 -DSTDCPP17 -std=c++1z -verify -fsyntax-only %s
 // RUN: %clang_cc1 -DSTDCPP17TRI -ftrigraphs -std=c++1z -verify -fsyntax-only 
%s
 // RUN: %clang_cc1 -DMSCOMPAT -fms-compatibility -std=c++11 -verify 
-fsyntax-only %s
+// RUN: %clang_cc1 -DNOTRI -fno-trigraphs -verify -fsyntax-only %s
 
 void foo() {
 #if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
-defined(STDCPP17TRI)
+defined(STDCPP17TRI) || (defined(__MVS__) && !defined(NOTRI))
   const char c[] = "??/n"; // expected-warning{{trigraph converted to '\' 
character}}
-#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT)
+#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT) || \
+defined(NOTRI)
   const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
 #else
 #error Not handled.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2787,7 +2787,9 @@
   // Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
   // is specified, or -std is set to a conforming mode.
   // Trigraphs are disabled by default in c++1z onwards.
-  Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+  // For z/OS, trigraphs are enabled by default (without regard to the above).
+  Opts.Trigraphs =
+  (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =
   Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,31 @@
 // RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck --check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify -ftrigraphs -DENABLED_TRIGRAPHS=1
+// RUN: %clang_cc1 -std=c++1z %s -verify -fno-trigraphs -DENABLED_TRIGRAPHS=0
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+#ifdef __MVS__
+#ifndef ENABLED_TRIGRAPHS
+#define ENABLED_TRIGRAPHS 1
+#endif
+#endif
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+??= define foo ;
 
+static_assert("??="[0] == '#', "");
+
+// ??/
+error here;
+
+// Note, there is intentionally trailing whitespace one lines below.
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
-// ??/  
-error here

[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 285427.
abhina.sreeskantharajan added a comment.

Thanks for catching that. I fixed up the testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/trigraphs.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,31 @@
 // RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck 
--check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify -ftrigraphs -DENABLED_TRIGRAPHS=1
+// RUN: %clang_cc1 -std=c++1z %s -verify -fno-trigraphs -DENABLED_TRIGRAPHS=0
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+#ifdef __MVS__
+#ifndef ENABLED_TRIGRAPHS
+#define ENABLED_TRIGRAPHS 1
+#endif
+#endif
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} 
expected-warning {{trigraph ignored}}
+??= define foo ;
+
+static_assert("??="[0] == '#', "");
 
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
 // ??/  
-error here; // expected-error {{}}
+error here;
+
+#if !ENABLED_TRIGRAPHS
+// expected-error@11 {{}} expected-warning@11 {{trigraph ignored}}
+// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}}
+// expected-error@16 {{}}
+// expected-error@20 {{}}
+#else
+// expected-warning@11 {{trigraph converted}}
+// expected-warning@13 {{trigraph converted}}
+// expected-warning@19 {{backslash and newline separated by space}}
+#endif
Index: clang/test/Frontend/trigraphs.cpp
===
--- clang/test/Frontend/trigraphs.cpp
+++ clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,14 @@
 // RUN: %clang_cc1 -DSTDCPP17 -std=c++1z -verify -fsyntax-only %s
 // RUN: %clang_cc1 -DSTDCPP17TRI -ftrigraphs -std=c++1z -verify -fsyntax-only 
%s
 // RUN: %clang_cc1 -DMSCOMPAT -fms-compatibility -std=c++11 -verify 
-fsyntax-only %s
+// RUN: %clang_cc1 -DNOTRI -fno-trigraphs -verify -fsyntax-only %s
 
 void foo() {
 #if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
-defined(STDCPP17TRI)
+defined(STDCPP17TRI) || (defined(__MVS__) && !defined(NOTRI))
   const char c[] = "??/n"; // expected-warning{{trigraph converted to '\' 
character}}
-#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT)
+#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT) || \
+defined(NOTRI)
   const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
 #else
 #error Not handled.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2787,7 +2787,9 @@
   // Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
   // is specified, or -std is set to a conforming mode.
   // Trigraphs are disabled by default in c++1z onwards.
-  Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+  // For z/OS, trigraphs are enabled by default (without regard to the above).
+  Opts.Trigraphs =
+  (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =
   Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,31 @@
 // RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck --check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify -ftrigraphs -DENABLED_TRIGRAPHS=1
+// RUN: %clang_cc1 -std=c++1z %s -verify -fno-trigraphs -DENABLED_TRIGRAPHS=0
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+#ifdef __MVS__
+#ifndef ENABLED_TRIGRAPHS
+#define ENABLED_TRIGRAPHS 1
+#endif
+#endif
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+??= define foo ;
+
+static_assert("??="[0] == '#', "");
 
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
 // ??/  
-error here; // expected-error {{}}
+error here;
+
+#if !E

[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:730
+MacroBuilder &Builder) const override {
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");

hubert.reinterpretcast wrote:
> The comment from https://reviews.llvm.org/D85324?id=283290#inline-786609 
> applies here as well. `_LONG_LONG` should not be defined under `-std=c89 
> -pedantic-errors` or `-std=c89 -Werror=long-long`.
I can add a FIXME here similar to what AIX did. 

```
//FIXME: LONG_LONG should not be defined under -std=c89
```
Let me know if there is a better solution.



Comment at: clang/lib/Basic/Targets/OSTargets.h:755
+  // is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+  // XOPEN_SOURCE=600 is required to build libcxx.

hubert.reinterpretcast wrote:
> The corresponding AIX code checks for `-Xclang -fno-wchar`. The behaviour of 
> `stddef.h` differs when using `-fno-wchar` between AIX and Linux though. 
> Linux suppresses the typedef based on `__cplusplus`. Arguably, the OS header 
> difference should not really factor into whether the compiler defines a macro 
> that indicates the presence of a `wchar_t` fundamental type.
Thanks, I will add the same guard that AIX uses.



Comment at: clang/lib/Basic/Targets/OSTargets.h:766
+if (Opts.C11 || Opts.GNUMode) {
+  Builder.defineMacro("__IBM_UTF_LITERAL");
+  Builder.defineMacro("__IBMC_NORETURN");

hubert.reinterpretcast wrote:
> The GNU extension modes do not cause u-prefixed, etc. string literals to be 
> accepted where the base language level would treat the prefix as a separate 
> identifier. Also noting here that the previous comment from 
> https://reviews.llvm.org/D85324?id=283290#inline-786628 was made based on 
> noting that `__IBM_UTF_LITERAL` is defined by the XL compiler in the 
> appropriate C++ modes.
We've updated the system headers so that we no longer need to define these 
macros.



Comment at: clang/lib/Basic/Targets/OSTargets.h:767
+  Builder.defineMacro("__IBM_UTF_LITERAL");
+  Builder.defineMacro("__IBMC_NORETURN");
+}

hubert.reinterpretcast wrote:
> I would expect that the Clang implementation of the "IBM-style" feature test 
> macros would behave similarly to the native feature testing in Clang. That 
> is, `__IBMC_NORETURN` is defined when `_Noreturn` is available as an 
> extension. `_Noreturn` is available as an "orthogonal" or "conforming" 
> extension in modes such as `-std=c89` and `-std=c++03`. The extension is 
> disabled via warnings-as-errors.
Right, we are able to remove this macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 286014.
abhina.sreeskantharajan added a comment.

Addressed Hubert's comments, and removed some macros that are unnecessary with 
system header updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1038,6 +1038,38 @@
 // S390X:#define __s390__ 1
 // S390X:#define __s390x__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-C %s
+// RUN: %clang_cc1 -E -dM -std=gnu99 -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -E -dM -std=gnu11 -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+// RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-C99 %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+// RUN: %clang_cc1 -x c++ -std=c++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX -check-prefix S390X-ZOS-GXX %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX -check-prefix S390X-ZOS-GXX %s
+//
+// S390X-ZOS-GXX:#define _EXT 1
+// S390X-ZOS-C99:#define _ISOC99_SOURCE 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-CXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-CXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-CXX:#define __wchar_t 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,57 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+// FIXME: LONG_LONG should not be defined under -std=c89.
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Buil

[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 286092.
abhina.sreeskantharajan added a comment.

Thanks MaskRay. I moved the zos testcase to a new file called init-zos.c 
instead and reduced the number of RUN commands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-zos.c

Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-C99 %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+//
+// S390X-ZOS-CXX:#define _EXT 1
+// S390X-ZOS-C99:#define _ISOC99_SOURCE 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-CXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-CXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-CXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-CXX:#define __wchar_t 1
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,57 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+// FIXME: LONG_LONG should not be defined under -std=c89
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Builder.defineMacro("__TOS_MVS__");
+Builder.defineMacro("__XPLINK__");
+
+if (this->PointerWidth == 64)
+  Builder.defineMacro("__64BIT__");
+
+if (Opts.C99)
+  Builder.defineMacro("_ISOC99_SOURCE");
+
+if (Opts.CPlusPlus) {
+  Builder.defineMacro("__DLL__");
+  // XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}
+
+if (Opts.GNUMode) {
+  Builder.defineMacro("_MI_BUILTIN");
+  Builder.defineMacro("_EXT");
+}
+
+if (Opts.CPlusPlus && Opts.WChar) {
+  // Macro __wchar_t is defined so that the wchar_t data
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}
+  }
+
+public:
+  ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : OSTargetInfo(Triple, Opts) {}
+};
+
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
MacroBuilder &Builder);
 
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -450,6 +450,8 @@
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::ZOS:
+  return new ZOSTargetInfo(Triple, Opts);
 default:
   return new SystemZTargetInfo(Triple, Opts);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/test/Preprocessor/init.c:1041
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
S390X-ZOS %s
+// RUN: %clang_cc1 -x c -E -dM -ffreestanding -triple=s390x-none-zos 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
S390X-ZOS -check-prefix S390X-ZOS-C %s

MaskRay wrote:
> The file has been split. You'll want to add new tests to `init-zos.c` or the 
> like.
> 
> Not sure it is important to run so many invocations of clang_cc1. Can you 
> pick some essential ones? The many invocations make the test slow.
Thanks for the suggestion. I created a new file and reduced the number of 
invocations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D106890: [z/OS] Make MinGlobalAlign consistent with SystemZ

2021-07-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106890

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


[PATCH] D121628: Only run this test for x86 registed targets.

2022-03-14 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a project: All.
abhina.sreeskantharajan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121628

Files:
  clang/test/CodeGen/sanitize-coverage-old-pm.c


Index: clang/test/CodeGen/sanitize-coverage-old-pm.c
===
--- clang/test/CodeGen/sanitize-coverage-old-pm.c
+++ clang/test/CodeGen/sanitize-coverage-old-pm.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S   
-fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | 
FileCheck %s --check-prefixes=CHECK
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=address-fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=bounds -fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,BOUNDS


Index: clang/test/CodeGen/sanitize-coverage-old-pm.c
===
--- clang/test/CodeGen/sanitize-coverage-old-pm.c
+++ clang/test/CodeGen/sanitize-coverage-old-pm.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S   -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=address-fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=bounds -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,BOUNDS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123498: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets

2022-04-11 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

this LGTM from a systemz perspective! thanks for refactoring




Comment at: clang/lib/Headers/CMakeLists.txt:173
   __wmmintrin_pclmul.h
   x86gprintrin.h
   x86intrin.h

nit: There are some x86 headers here that appear to be x86 only. Should these 
be moved to x86_files list?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123498

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


[PATCH] D123498: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets

2022-04-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:173
   __wmmintrin_pclmul.h
   x86gprintrin.h
   x86intrin.h

qiongsiwu1 wrote:
> abhina.sreeskantharajan wrote:
> > nit: There are some x86 headers here that appear to be x86 only. Should 
> > these be moved to x86_files list?
> Thanks for the comment! Yes indeed. I think currently the `x86gprintrin.h` 
> header is in the `x86_files` list (list starts at line 88). Did I miss some 
> other x86 files? 
Ah sorry, you're right, I think I read the list wrong. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123498

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


[PATCH] D87624: [SystemZ][z/OS] Set default wchar_t type for zOS

2020-09-14 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: abdulras, uweigand, 
hubert.reinterpretcast, fanbo-meng, Kai, ro, zibi, SeanP.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abhina.sreeskantharajan requested review of this revision.

Set the default wchar_t type on z/OS, and unsigned as the default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87624

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/wchar-size.c
  clang/test/Lexer/wchar-signedness.c
  clang/test/Preprocessor/wchar_t.c
  clang/test/Sema/wchar.c


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -6,7 +6,7 @@
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
  || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
   #define WCHAR_T_TYPE unsigned short
-#elif defined(__arm) || defined(__aarch64__)
+#elif defined(__arm) || defined(__aarch64__) || defined(__MVS__)
   #define WCHAR_T_TYPE unsigned int
 #elif defined(__sun)
   #if defined(__LP64__)
Index: clang/test/Preprocessor/wchar_t.c
===
--- clang/test/Preprocessor/wchar_t.c
+++ clang/test/Preprocessor/wchar_t.c
@@ -48,6 +48,11 @@
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
 
+// RUN: %clang_cc1 -triple s390x-none-zos -fwchar-type=int -fno-signed-wchar 
-dM -E %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// CHECK-ZOS: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ZOS: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+
 // RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
 // CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
 // CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
Index: clang/test/Lexer/wchar-signedness.c
===
--- clang/test/Lexer/wchar-signedness.c
+++ clang/test/Lexer/wchar-signedness.c
@@ -1,9 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | 
FileCheck %s --check-prefix=CHECK-X86
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck 
%s --check-prefix=CHECK-ARM
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | 
FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple s390x-none-zos | FileCheck 
%s --check-prefix=CHECK-ZOS
 
 // CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
 // CHECK-X86: #define __WINT_UNSIGNED__ 1
 
 // CHECK-ARM: #define __WCHAR_UNSIGNED__ 1
 // CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1
+
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+// CHECK-ZOS-NOT: #define __WINT_UNSIGNED__ 1
Index: clang/test/CodeGen/wchar-size.c
===
--- clang/test/CodeGen/wchar-size.c
+++ clang/test/CodeGen/wchar-size.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple s390x-none-zos -emit-llvm -o - %s | FileCheck %s 
-check-prefix=LONG-WCHAR
 // Note: -fno-short-wchar implies the target default is used; so there is no
 // need to test this separately here.
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3408,8 +3408,8 @@
 } else {
   bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
   CmdArgs.push_back("-fwchar-type=int");
-  if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
- T.isOSOpenBSD()))
+  if (T.isOSzOS() ||
+  (IsARM && !(T.isOSWindows() || T.isOSNetBSD() || T.isOSOpenBSD(
 CmdArgs.push_back("-fno-signed-wchar");
   else
 CmdArgs.push_back("-fsigned-wchar");
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -774,7 +774,9 @@
 
 public:
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : OSTargetInfo(Triple, Opts) {}
+  : OSTargetInfo(Triple, Opts) {
+this->WCharType = TargetInfo::UnsignedInt;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,


Index: clang/test/Sema/wchar.c
=

[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:773-774
 }
+
+this->PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());;
   }

There is an extra semi-colon.


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

https://reviews.llvm.org/D87611

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2240ca0bd150: [SystemZ][z/OS] Set aligned allocation 
unavailable by default for z/OS (authored by fanbo-meng, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/Lexer/aligned-allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,12 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DZOS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DZOS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -62,40 +65,40 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
+// expected-error-re@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}}
 // expected-note@-27 {{if you supply your own 

[PATCH] D87624: [SystemZ][z/OS] Set default wchar_t type for zOS

2020-09-22 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fb97fd6a4f2: [SystemZ][z/OS] Set default wchar_t type for 
zOS (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87624

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/wchar-size.c
  clang/test/Lexer/wchar-signedness.c
  clang/test/Preprocessor/wchar_t.c
  clang/test/Sema/wchar.c


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -6,7 +6,7 @@
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
  || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
   #define WCHAR_T_TYPE unsigned short
-#elif defined(__arm) || defined(__aarch64__)
+#elif defined(__arm) || defined(__aarch64__) || defined(__MVS__)
   #define WCHAR_T_TYPE unsigned int
 #elif defined(__sun)
   #if defined(__LP64__)
Index: clang/test/Preprocessor/wchar_t.c
===
--- clang/test/Preprocessor/wchar_t.c
+++ clang/test/Preprocessor/wchar_t.c
@@ -48,6 +48,11 @@
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
 // CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
 
+// RUN: %clang_cc1 -triple s390x-none-zos -fwchar-type=int -fno-signed-wchar 
-dM -E %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// CHECK-ZOS: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ZOS: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+
 // RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
 // CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
 // CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
Index: clang/test/Lexer/wchar-signedness.c
===
--- clang/test/Lexer/wchar-signedness.c
+++ clang/test/Lexer/wchar-signedness.c
@@ -1,9 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | 
FileCheck %s --check-prefix=CHECK-X86
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck 
%s --check-prefix=CHECK-ARM
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | 
FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple s390x-none-zos | FileCheck 
%s --check-prefix=CHECK-ZOS
 
 // CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
 // CHECK-X86: #define __WINT_UNSIGNED__ 1
 
 // CHECK-ARM: #define __WCHAR_UNSIGNED__ 1
 // CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1
+
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+// CHECK-ZOS-NOT: #define __WINT_UNSIGNED__ 1
Index: clang/test/CodeGen/wchar-size.c
===
--- clang/test/CodeGen/wchar-size.c
+++ clang/test/CodeGen/wchar-size.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple s390x-none-zos -emit-llvm -o - %s | FileCheck %s 
-check-prefix=LONG-WCHAR
 // Note: -fno-short-wchar implies the target default is used; so there is no
 // need to test this separately here.
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3409,8 +3409,8 @@
 } else {
   bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
   CmdArgs.push_back("-fwchar-type=int");
-  if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
- T.isOSOpenBSD()))
+  if (T.isOSzOS() ||
+  (IsARM && !(T.isOSWindows() || T.isOSNetBSD() || T.isOSOpenBSD(
 CmdArgs.push_back("-fno-signed-wchar");
   else
 CmdArgs.push_back("-fsigned-wchar");
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -776,7 +776,9 @@
 
 public:
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : OSTargetInfo(Triple, Opts) {}
+  : OSTargetInfo(Triple, Opts) {
+this->WCharType = TargetInfo::UnsignedInt;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -6

[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-20 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 286853.
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added a comment.

Thanks Hubert, I updated the comments, and also the check-prefix to your 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-zos.c

Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-C99 %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+//
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS-C99:#define _ISOC99_SOURCE 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-GNUXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-GNUXX:#define __wchar_t 1
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,58 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+// FIXME: _LONG_LONG should not be defined under -std=c89.
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should be defined under strict -std=c89.
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Builder.defineMacro("__TOS_MVS__");
+Builder.defineMacro("__XPLINK__");
+
+if (this->PointerWidth == 64)
+  Builder.defineMacro("__64BIT__");
+
+if (Opts.C99)
+  Builder.defineMacro("_ISOC99_SOURCE");
+
+if (Opts.CPlusPlus) {
+  Builder.defineMacro("__DLL__");
+  // XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}
+
+if (Opts.GNUMode) {
+  Builder.defineMacro("_MI_BUILTIN");
+  Builder.defineMacro("_EXT");
+}
+
+if (Opts.CPlusPlus && Opts.WChar) {
+  // Macro __wchar_t is defined so that the wchar_t data
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}
+  }
+
+public:
+  ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : OSTargetInfo(Triple, Opts) {}
+};
+
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
MacroBuilder &Builder);
 
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -450,6 +450,8 @@
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::ZOS:
+  return new ZOSTargetInfo(Triple, Opts);
 default:
   return new SystemZTargetInfo(Triple, Opts);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-20 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 3 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:743
+Builder.defineMacro("__BFP__");
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");

hubert.reinterpretcast wrote:
> Sorry for not catching this earlier, but this also needs a FIXME re: strict 
> C89.
I've added a comment here.



Comment at: clang/test/Preprocessor/init-zos.c:5
+//
+// S390X-ZOS-CXX:#define _EXT 1
+// S390X-ZOS-C99:#define _ISOC99_SOURCE 1

hubert.reinterpretcast wrote:
> Should this be `GNUXX`?
I agree this is a better name, I've updated the name to your suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 287043.
abhina.sreeskantharajan added a comment.

Thanks for reviewing. I've updated the comments and removed ISOC99_SOURCE 
macro. I've updated the lit test to reflect these changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-zos.c


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding 
-triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-GNUXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-GNUXX:#define __wchar_t 1
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,55 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+// FIXME: _LONG_LONG should not be defined under -std=c89.
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should not be defined under -std=c89.
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Builder.defineMacro("__TOS_MVS__");
+Builder.defineMacro("__XPLINK__");
+
+if (this->PointerWidth == 64)
+  Builder.defineMacro("__64BIT__");
+
+if (Opts.CPlusPlus) {
+  Builder.defineMacro("__DLL__");
+  // XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}
+
+if (Opts.GNUMode) {
+  Builder.defineMacro("_MI_BUILTIN");
+  Builder.defineMacro("_EXT");
+}
+
+if (Opts.CPlusPlus && Opts.WChar) {
+  // Macro __wchar_t is defined so that the wchar_t data
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}
+  }
+
+public:
+  ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : OSTargetInfo(Triple, Opts) {}
+};
+
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
MacroBuilder &Builder);
 
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -450,6 +450,8 @@
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::ZOS:
+  return new ZOSTargetInfo(Triple, Opts);
 default:
   return new SystemZTargetInfo(Triple, Opts);
 }


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-Z

[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 5 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:743
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should be defined under strict -std=c89.
+Builder.defineMacro("__BOOL__");

hubert.reinterpretcast wrote:
> MaskRay wrote:
> > What is strict -std=c89? `!Opts.C99` ?
> The comment has a typo. The macro should //not// be defined with strict C89 
> modes.
> 
> > What is strict -std=c89? `!Opts.C99` ?
> 
> In the context of this macro, "strict C89" means `!Opts.C99` and the severity 
> of `ext_c99_feature` diagnostics is at least an error. This occurs, for 
> example, with `-std=gnu89 -Werror=c99-extensions`.
> 
Thanks, I've fixed the comment.



Comment at: clang/lib/Basic/Targets/OSTargets.h:757
+if (Opts.C99)
+  Builder.defineMacro("_ISOC99_SOURCE");
+

MaskRay wrote:
> This is strange. On other systems the user requests it.
Thanks, I've removed this macro to maintain consistency with other platforms.



Comment at: clang/lib/Basic/Targets/OSTargets.h:773
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}

MaskRay wrote:
> Does it need a value?
No, this macro doesn't require a number. This macro is defined when the wchar_t 
type is available, so that the system headers do not declare it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 287338.
abhina.sreeskantharajan added a comment.

Thanks Hubert, I fixed the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-zos.c


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding 
-triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-GNUXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-GNUXX:#define __wchar_t 1
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,55 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+// FIXME: _LONG_LONG should not be defined under -std=c89.
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should not be defined under -std=c89.
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Builder.defineMacro("__TOS_MVS__");
+Builder.defineMacro("__XPLINK__");
+
+if (this->PointerWidth == 64)
+  Builder.defineMacro("__64BIT__");
+
+if (Opts.CPlusPlus) {
+  Builder.defineMacro("__DLL__");
+  // _XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}
+
+if (Opts.GNUMode) {
+  Builder.defineMacro("_MI_BUILTIN");
+  Builder.defineMacro("_EXT");
+}
+
+if (Opts.CPlusPlus && Opts.WChar) {
+  // Macro __wchar_t is defined so that the wchar_t data
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}
+  }
+
+public:
+  ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : OSTargetInfo(Triple, Opts) {}
+};
+
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
MacroBuilder &Builder);
 
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -450,6 +450,8 @@
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::ZOS:
+  return new ZOSTargetInfo(Triple, Opts);
 default:
   return new SystemZTargetInfo(Triple, Opts);
 }


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT_

[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D85324#2234712 , 
@hubert.reinterpretcast wrote:

> In D85324#2233290 , 
> @abhina.sreeskantharajan wrote:
>
>> Thanks Hubert, I fixed the comment.
>
> Got it; I'll look into committing this.

Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/test/Preprocessor/init-zos.c:4
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1

MaskRay wrote:
> --match-full-lines  is different from --match-full-lines --strict-whitespace. 
> You can freely add leading and trailing spaces to align `#` for readability.
> 
> Might not be necessary changing now.
Thanks MaskRay, I will try to update this testcase in upcoming patches that 
touch this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-08-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: Kai, uweigand, hubert.reinterpretcast, 
stevewan, SeanP, lalovic.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
abhina.sreeskantharajan requested review of this revision.

This patch adds the initial toolchain for z/OS that will set some defaults. In 
subsequent patches, we plan to add support to use the system linker and 
assembler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86707

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h

Index: clang/lib/Driver/ToolChains/ZOS.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -0,0 +1,36 @@
+//===--- ZOS.h - z/OS ToolChain Implementations -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY ZOS : public ToolChain {
+public:
+  ZOS(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+  ~ZOS() override;
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -0,0 +1,23 @@
+//===--- ZOS.cpp - z/OS ToolChain Implementations ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ZOS.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace llvm::opt;
+using namespace clang;
+
+ZOS::ZOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+: ToolChain(D, Triple, Args) {}
+
+ZOS::~ZOS() {}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -46,6 +46,7 @@
 #include "ToolChains/VEToolchain.h"
 #include "ToolChains/WebAssembly.h"
 #include "ToolChains/XCore.h"
+#include "ToolChains/ZOS.h"
 #include "clang/Basic/TargetID.h"
 #include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
@@ -5072,6 +5073,9 @@
 case llvm::Triple::Hurd:
   TC = std::make_unique(*this, Target, Args);
   break;
+case llvm::Triple::ZOS:
+  TC = std::make_unique(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -73,6 +73,7 @@
   ToolChains/XCore.cpp
   ToolChains/PPCLinux.cpp
   ToolChains/InterfaceStubs.cpp
+  ToolChains/ZOS.cpp
   Types.cpp
   XRayArgs.cpp
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-08-31 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Driver/ToolChains/ZOS.h:25
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }

hubert.reinterpretcast wrote:
> According to the RFC re: LLVM on z/OS, the initial support in LLVM for z/OS 
> is only for XPLink. My understanding is that all XPLink applications are 
> DLL-enabled. Does being DLL-enabled not imply that the code is 
> position-independent?
> 
> I understand that the value of the `__DLL__` predefined macro from the XL C 
> compiler does not reflect the implicit DLL-enablement of XPLink code; 
> however, I also note that the same compiler claims falsely that `Option NODLL 
> is ignored because option XPLINK is specified` when `-qnodll` does actually 
> suppress the effect of an earlier `-qdll` in causing `__DLL__` to be defined.
This is not always true because we do not require code to be PIC on z/OS, even 
for XPLink applications. Absolute addresses may be present in code sections for 
easier access (e.g. in calls to linkages, branch tables). We also may link to 
libraries that contain non-PIC code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86707

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


[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-09-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 289148.
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added a comment.

Thanks Hubert, I removed the lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86707

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h

Index: clang/lib/Driver/ToolChains/ZOS.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -0,0 +1,36 @@
+//===--- ZOS.h - z/OS ToolChain Implementations -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY ZOS : public ToolChain {
+public:
+  ZOS(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+  ~ZOS() override;
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -0,0 +1,21 @@
+//===--- ZOS.cpp - z/OS ToolChain Implementations ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ZOS.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang::driver::toolchains;
+using namespace llvm::opt;
+
+ZOS::ZOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+: ToolChain(D, Triple, Args) {}
+
+ZOS::~ZOS() {}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -46,6 +46,7 @@
 #include "ToolChains/VEToolchain.h"
 #include "ToolChains/WebAssembly.h"
 #include "ToolChains/XCore.h"
+#include "ToolChains/ZOS.h"
 #include "clang/Basic/TargetID.h"
 #include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
@@ -5072,6 +5073,9 @@
 case llvm::Triple::Hurd:
   TC = std::make_unique(*this, Target, Args);
   break;
+case llvm::Triple::ZOS:
+  TC = std::make_unique(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -73,6 +73,7 @@
   ToolChains/XCore.cpp
   ToolChains/PPCLinux.cpp
   ToolChains/InterfaceStubs.cpp
+  ToolChains/ZOS.cpp
   Types.cpp
   XRayArgs.cpp
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-09-01 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e1e5f54492d: [SystemZ][z/OS] Adding initial toolchain for 
z/OS (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86707

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h

Index: clang/lib/Driver/ToolChains/ZOS.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -0,0 +1,36 @@
+//===--- ZOS.h - z/OS ToolChain Implementations -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY ZOS : public ToolChain {
+public:
+  ZOS(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+  ~ZOS() override;
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -0,0 +1,21 @@
+//===--- ZOS.cpp - z/OS ToolChain Implementations ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ZOS.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang::driver::toolchains;
+using namespace llvm::opt;
+
+ZOS::ZOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+: ToolChain(D, Triple, Args) {}
+
+ZOS::~ZOS() {}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -46,6 +46,7 @@
 #include "ToolChains/VEToolchain.h"
 #include "ToolChains/WebAssembly.h"
 #include "ToolChains/XCore.h"
+#include "ToolChains/ZOS.h"
 #include "clang/Basic/TargetID.h"
 #include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
@@ -5072,6 +5073,9 @@
 case llvm::Triple::Hurd:
   TC = std::make_unique(*this, Target, Args);
   break;
+case llvm::Triple::ZOS:
+  TC = std::make_unique(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -73,6 +73,7 @@
   ToolChains/XCore.cpp
   ToolChains/PPCLinux.cpp
   ToolChains/InterfaceStubs.cpp
+  ToolChains/ZOS.cpp
   Types.cpp
   XRayArgs.cpp
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93031: Enable fexec-charset option

2020-12-10 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, dang, hiraditya, mgorny.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch enables the fexec-charset option to control the execution charset of 
string literals. It sets the default internal charset, system charset, and 
execution charset for z/OS and UTF-8 for all other platforms. 
This patch depends on https://reviews.llvm.org/D88741


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/LiteralTranslator.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/LiteralTranslator.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1023,6 +1023,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -390,6 +390,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,8 +209,8 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=iso8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-VALID-INPUT-CHARSET %s
+// CHECK-VALID-INPUT-CHARSET-NOT: error: invalid value 'iso8859-1' in '-fexec-charset=iso8859-1'
 
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,10 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
-//
+// /execution-charset: should not warn on character sets.
+// RUN: %clang_cl /execution-charset:iso8859-1 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-iso8859-1 %s
+// execution-charset-iso8859-1-NOT: invalid value 'iso8859-1' in '/execution-charset:iso8859-1'
+
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
Index: clang/test/CodeGen/systemz-charset.c
===
--- /dev/null
+++ clang/test/CodeGen/systemz-charset.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple s390x-none-zos -fexec-charset IBM-1047 -o - | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -target s390x-ibm-zos -o - | FileCheck %s
+
+char *UpperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+// CHECK: c"\C1\C2\C3\C4\C5\C6\C7\C8\C9\D1\D2\D3\D4\D5\D6\D7\D8\D9\E2\E3\E4\E5\E6\E7\E8\E9\00"
+
+char *LowerCaseLetters = "abcdefghijklmnopqrstuvwxyz";
+//CHECK: c"\81\82\83\84\85

[PATCH] D93031: Enable fexec-charset option

2020-12-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 311911.
abhina.sreeskantharajan added a comment.

Thanks for your quick reviews! I haven't addressed all the comments yet but I 
plan to address all of them. I put up this patch early because it has a few 
major changes:

- moves LiteralTranslator class to Preprocessor instead of being a static 
global class
- add isUTFLiteral() function to detect strings like u8"..." and stop 
translation
- translate wide string literals to the system charset for now (we don't have 
an implementation plan for -fwide-charset right now)
- remove tests that check fexec-charset will not accept non-UTF charsets




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/LiteralTranslator.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/LiteralTranslator.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1023,6 +1023,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -390,6 +390,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,9 +209,6 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
-
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
 // RUN: -falign-functions -falign-functions=2 -fno-align-functions\
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,6 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
-//
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
Index: clang/test/CodeGen/systemz-charset.c
===
--- /dev/null
+++ clang/test/CodeGen/systemz-charset.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple s390x-none-zos -fexec-charset IBM-1047 -o - | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -target s390x-ibm-zos -o - | FileCheck %s
+
+char *UpperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+// CHECK: c"\C1\C2\C3\C4\C5\C6\C7\C8\C9\D1\D2\D3\D4\D5\D6\D7\D8\D9\E2\E3\E4\E5\E6\E7\E8\E9\00"
+
+char *LowerCaseLetters = "abcdefghijklmnopqrstuvwxyz";
+//CHECK: c"\81\82\83\84\85\86\87\88\89\91\92\93\94\95\96\97\98\99\A2\A3\A4\A5\A6\A7\A8\A9\00"
+
+char *Digits = "0123456789";
+// CHECK: c"\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\00"
+
+char *SpecialCharac

[PATCH] D93031: Enable fexec-charset option

2020-12-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 9 inline comments as done.
abhina.sreeskantharajan added a comment.

In D93031#2447230 , @rsmith wrote:

> I'm overall pretty happy about how clean and non-invasive the changes 
> required here are. But please make sure you don't change the encodings of 
> `u8"..."` / `u"..."` / `U"..."` literals; those need to stay as UTF-8 / 
> UTF-16 / UTF-32. Also, we should have a story for how the wide execution 
> character set is controlled -- is it derived from the narrow execution 
> character set, or can the two be changed independently, or ...?
>
> We should use the original source form of the string literal when 
> pretty-printing a `StringLiteral` or `CharacterLiteral`; there are a bunch of 
> UTF-8 assumptions baked into `StmtPrinter` that will need revisiting. And 
> we'll need to modify the handful of places that put the contents of 
> `StringLiteral`s into diagnostics (`#warning`, `#error`, `static_assert`) and 
> make them use a different `ConversionState`, since our assumption is that 
> diagnostic output should be in UTF-8.

Yes, these are some of the complications we will need to visit in later 
patches. We may need to somehow save the original string or reverse the 
translation.




Comment at: clang/include/clang/Driver/Options.td:3583-3584
 
+def fexec_charset : Separate<["-"], "fexec-charset">, 
MetaVarName<"">,
+  HelpText<"Set the execution  for string and character literals">;
 def target_cpu : Separate<["-"], "target-cpu">,

tahonermann wrote:
> How about substituting "character set", "character encoding", or "charset" 
> for "codepage"?
> 
> This doesn't state what names are recognized.  The ones provided by the 
> system iconv() implementation (as is the case for gcc)?  Or all names and 
> aliases specified by the [[ 
> https://www.iana.org/assignments/character-sets/character-sets.xhtml | IANA 
> character set registry ]]?
> 
> The set of recognized names can be a superset of the names that are actually 
> supported.
I've updated the description from codepage to charset.

It's hard to specify what charsets are supported because iconv library differs 
between targets, so the list will not be the same on every platform.



Comment at: clang/include/clang/Lex/LiteralTranslator.h:32
+  static llvm::StringRef ExecCharset;
+  static llvm::StringMap ExecCharsetTables;
+

rsmith wrote:
> Similarly, use of a global cache here will require you guard it with a mutex.
> 
> As an alternative, how about we move all this state to be per-instance state, 
> and store an instance of `LiteralTranslator` on the `Preprocessor`?
Thanks, I've added an instance of LiteralTranslator to Preprocessor instead and 
use that when the Preprocessor is available. There is one constructor of 
StringLiteralParser that does not pass Preprocessor as an argument, so I had to 
create a LiteralTranslator instance there as well.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5969-5977
+  // Pass all -fexec-charset options to cc1.
+  std::vector vList =
+  Args.getAllArgValues(options::OPT_fexec_charset_EQ);
+  // Set the default fexec-charset as the system charset.
+  CmdArgs.push_back("-fexec-charset");
+  CmdArgs.push_back(Args.MakeArgString(Triple.getSystemCharset()));
+  for (auto it = vList.begin(), ie = vList.end(); it != ie; ++it) {

tahonermann wrote:
> I think it would be preferable to diagnose an unrecognized character encoding 
> name here if possible.  The current changes will result in an unrecognized 
> name (as opposed to one that is unsupported for the target) being diagnosed 
> for each compiler instance.
Since we do not know what charsets are supported by the iconv library on the 
target platform, we don't know what charsets are actually invalid until we try 
creating a CharSetConverter.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3573
+StringRef Value = ExecCharset->getValue();
+Opts.ExecCharset = (std::string)Value;
+  }

tahonermann wrote:
> I wouldn't expect the cast to `std::string` to be needed here.
Without that cast, I get the following build error:
```
 error: no viable overloaded '='
```



Comment at: clang/test/Driver/cl-options.c:214
+// RUN: %clang_cl /execution-charset:iso8859-1 -### -- %s 2>&1 | FileCheck 
-check-prefix=execution-charset-iso8859-1 %s
+// execution-charset-iso8859-1-NOT: invalid value 'iso8859-1' in 
'/execution-charset:iso8859-1'
+

rsmith wrote:
> Checking for "don't produce exactly this one spelling of this one diagnostic" 
> is not a useful test; if we started warning on this again, there's a good 
> chance the warning would be spelled differently, so your test does not do a 
> good job of determining whether the code under test is bad (it passes in most 
> bad states as well as in the good state). `...-NOT: error` and 

[PATCH] D93031: Enable fexec-charset option

2020-12-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 313112.
abhina.sreeskantharajan added a comment.

Thanks for your patience, I've addressed some more comments. Here is the 
summary of the changes in this patch:

- add translation for UCN strings, update testcase
- fix helptext for fexec-charset option in Options.td
- check for invalid charsets when parsing driver options.
- fix up char conversion code




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/LiteralTranslator.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/LiteralTranslator.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/CodeGen/systemz-charset.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1023,6 +1023,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -390,6 +390,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,8 +209,8 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset'
 
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,11 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
+// /execution-charset: should warn on invalid charsets.
+// RUN: %clang_cl /execution-charset:invalid-charset -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-invalid %s
+// execution-charset-invalid: invalid value 'invalid-charset' in '-fexec-charset'
 //
+
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
Index: clang/test/CodeGen/systemz-charset.cpp
===
--- /dev/null
+++ clang/test/CodeGen/systemz-charset.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang %s -std=c++17 -emit-llvm -S -target s390x-ibm-zos -o - | FileCheck %s
+
+const char *RawString = R"(Hello\n)";
+//CHECK: c"\C8\85\93\93\96\E0\95\00"
+
+char UnicodeChar8 = u8'1';
+//CHECK: i8 49
+char16_t UnicodeChar16 = u'1';
+//CHECK: i16 49
+char32_t UnicodeChar32 = U'1';
+//CHECK: i32 49
+
+const char *UnicodeString8 = u8"Hello";
+//CHECK: c"Hello\

[PATCH] D93031: Enable fexec-charset option

2020-12-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 11 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3583-3584
 
+def fexec_charset : Separate<["-"], "fexec-charset">, 
MetaVarName<"">,
+  HelpText<"Set the execution  for string and character literals">;
 def target_cpu : Separate<["-"], "target-cpu">,

tahonermann wrote:
> abhina.sreeskantharajan wrote:
> > tahonermann wrote:
> > > How about substituting "character set", "character encoding", or 
> > > "charset" for "codepage"?
> > > 
> > > This doesn't state what names are recognized.  The ones provided by the 
> > > system iconv() implementation (as is the case for gcc)?  Or all names and 
> > > aliases specified by the [[ 
> > > https://www.iana.org/assignments/character-sets/character-sets.xhtml | 
> > > IANA character set registry ]]?
> > > 
> > > The set of recognized names can be a superset of the names that are 
> > > actually supported.
> > I've updated the description from codepage to charset.
> > 
> > It's hard to specify what charsets are supported because iconv library 
> > differs between targets, so the list will not be the same on every platform.
> Being dependent on the host iconv library seems fine by me; that is the case 
> for gcc today.  I suggest making that explicit here:
>   def fexec_charset : Separate<["-"], "fexec-charset">, 
> MetaVarName<"">,
> HelpText<"Set the execution  for string and character literals.  
> Supported character encodings include XXX and those supported by the host 
> iconv library.">;
I've updated the HelpText with your suggested description.



Comment at: clang/include/clang/Lex/LiteralSupport.h:192
+ConversionState translationState = TranslateToExecCharset);
+  ConversionState TranslationState;
 

tahonermann wrote:
> Does the conversion state need to be persisted as a data member?  The literal 
> is consumed in the constructor.
Thanks, I've removed this.



Comment at: clang/include/clang/Lex/LiteralSupport.h:244
   bool Pascal;
+  ConversionState TranslationState;
+

tahonermann wrote:
> Same concern here with respect to persisting the conversion state as a data 
> member.
If this member is removed in StringLiteralParser, we will need to pass the 
State to multiple functions in StringLiteralParser like init(). Would this 
solution be preferable to keeping a data member?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5969-5977
+  // Pass all -fexec-charset options to cc1.
+  std::vector vList =
+  Args.getAllArgValues(options::OPT_fexec_charset_EQ);
+  // Set the default fexec-charset as the system charset.
+  CmdArgs.push_back("-fexec-charset");
+  CmdArgs.push_back(Args.MakeArgString(Triple.getSystemCharset()));
+  for (auto it = vList.begin(), ie = vList.end(); it != ie; ++it) {

tahonermann wrote:
> abhina.sreeskantharajan wrote:
> > tahonermann wrote:
> > > I think it would be preferable to diagnose an unrecognized character 
> > > encoding name here if possible.  The current changes will result in an 
> > > unrecognized name (as opposed to one that is unsupported for the target) 
> > > being diagnosed for each compiler instance.
> > Since we do not know what charsets are supported by the iconv library on 
> > the target platform, we don't know what charsets are actually invalid until 
> > we try creating a CharSetConverter.
> Understood, but what would be the harm in performing a lookup (constructing a 
> `CharSetConverter`) here?
I initially thought it will be a performance issue if we are creating the 
Converter twice, once here and once in the Preprocessor. But I do think its a 
good idea to diagnose this early. I've modified the code to diagnose and error 
here.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3573
+StringRef Value = ExecCharset->getValue();
+Opts.ExecCharset = (std::string)Value;
+  }

tahonermann wrote:
> abhina.sreeskantharajan wrote:
> > tahonermann wrote:
> > > I wouldn't expect the cast to `std::string` to be needed here.
> > Without that cast, I get the following build error:
> > ```
> >  error: no viable overloaded '='
> > ```
> Ok, rather than a cast, I suggest:
>   Opts.ExecCharset = Value.str();
Thanks, I've applied this change.



Comment at: clang/lib/Lex/LiteralSupport.cpp:231-239
+  if (Translate && Converter) {
+// ResultChar is either UTF-8 or ASCII literal and can only be converted
+// to EBCDIC on z/OS if the character can be represented in one byte.
+if (ResultChar < 0x100) {
+  SmallString<8> ResultCharConv;
+  Converter->convert(StringRef((char *)&ResultChar), ResultCharConv);
+  void *Pointer = &ResultChar;

tahonermann wrote:
> rsmith wrote:
> > Is it correct, in general, to do character-at-a-time translation here, when 
> > processing

[PATCH] D93031: Enable fexec-charset option

2020-12-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1322-1323
+  TranslationState = translationState;
+  if (Kind == tok::wide_string_literal)
+TranslationState = TranslateToSystemCharset;
+  else if (isUTFLiteral(Kind))

tahonermann wrote:
> Converting wide character literals to the system encoding doesn't seem right 
> to me.  For z/OS, this should presumably convert to the wide EBCDIC encoding, 
> but for all other supported platforms, the wide execution character set is 
> either UTF-16 or UTF-32 depending on the size of `wchar_t` (which may be 
> influenced by the `-fshort-wchar` option).
Since we don't implement -fwide-exec-charset yet, what do you think should be 
the default behaviour for the interim?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2020-11-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abhina.sreeskantharajan requested review of this revision.

This patch creates a SystemZ folder in clang/test/CodeGen to contain 
systemz-related lit tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91628

Files:
  clang/test/CodeGen/SystemZ/align-systemz.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz.c
  clang/test/CodeGen/SystemZ/mbackchain-2.c
  clang/test/CodeGen/SystemZ/mbackchain-3.c
  clang/test/CodeGen/SystemZ/mbackchain.c
  clang/test/CodeGen/SystemZ/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/SystemZ/zos-alignment.c
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/SystemZ/zvector2.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/builtins-systemz-error.c
  clang/test/CodeGen/builtins-systemz-error2.c
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector-error.c
  clang/test/CodeGen/builtins-systemz-vector.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-error.c
  clang/test/CodeGen/builtins-systemz-vector2.c
  clang/test/CodeGen/builtins-systemz-vector3-error.c
  clang/test/CodeGen/builtins-systemz-vector3.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/builtins-systemz-zvector3.c
  clang/test/CodeGen/builtins-systemz.c
  clang/test/CodeGen/mbackchain-2.c
  clang/test/CodeGen/mbackchain-3.c
  clang/test/CodeGen/mbackchain.c
  clang/test/CodeGen/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/systemz-abi-vector.c
  clang/test/CodeGen/systemz-abi.c
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c
  clang/test/CodeGen/zos-alignment.c
  clang/test/CodeGen/zvector.c
  clang/test/CodeGen/zvector2.c




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


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2020-11-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 305781.
abhina.sreeskantharajan added a comment.

Add one more testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91628

Files:
  clang/test/CodeGen/SystemZ/align-systemz.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz.c
  clang/test/CodeGen/SystemZ/mbackchain-2.c
  clang/test/CodeGen/SystemZ/mbackchain-3.c
  clang/test/CodeGen/SystemZ/mbackchain.c
  clang/test/CodeGen/SystemZ/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-abi.cpp
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/SystemZ/zos-alignment.c
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/SystemZ/zvector2.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/builtins-systemz-error.c
  clang/test/CodeGen/builtins-systemz-error2.c
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector-error.c
  clang/test/CodeGen/builtins-systemz-vector.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-error.c
  clang/test/CodeGen/builtins-systemz-vector2.c
  clang/test/CodeGen/builtins-systemz-vector3-error.c
  clang/test/CodeGen/builtins-systemz-vector3.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/builtins-systemz-zvector3.c
  clang/test/CodeGen/builtins-systemz.c
  clang/test/CodeGen/mbackchain-2.c
  clang/test/CodeGen/mbackchain-3.c
  clang/test/CodeGen/mbackchain.c
  clang/test/CodeGen/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/systemz-abi-vector.c
  clang/test/CodeGen/systemz-abi.c
  clang/test/CodeGen/systemz-abi.cpp
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c
  clang/test/CodeGen/zos-alignment.c
  clang/test/CodeGen/zvector.c
  clang/test/CodeGen/zvector2.c




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


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2020-11-18 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG057e6bb5540b: [SystemZ][NFC] Group SystemZ tests in SystemZ 
folder (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91628

Files:
  clang/test/CodeGen/SystemZ/align-systemz.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz.c
  clang/test/CodeGen/SystemZ/mbackchain-2.c
  clang/test/CodeGen/SystemZ/mbackchain-3.c
  clang/test/CodeGen/SystemZ/mbackchain.c
  clang/test/CodeGen/SystemZ/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-abi.cpp
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/SystemZ/zos-alignment.c
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/SystemZ/zvector2.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/builtins-systemz-error.c
  clang/test/CodeGen/builtins-systemz-error2.c
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector-error.c
  clang/test/CodeGen/builtins-systemz-vector.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-error.c
  clang/test/CodeGen/builtins-systemz-vector2.c
  clang/test/CodeGen/builtins-systemz-vector3-error.c
  clang/test/CodeGen/builtins-systemz-vector3.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/builtins-systemz-zvector3.c
  clang/test/CodeGen/builtins-systemz.c
  clang/test/CodeGen/mbackchain-2.c
  clang/test/CodeGen/mbackchain-3.c
  clang/test/CodeGen/mbackchain.c
  clang/test/CodeGen/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/systemz-abi-vector.c
  clang/test/CodeGen/systemz-abi.c
  clang/test/CodeGen/systemz-abi.cpp
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c
  clang/test/CodeGen/zos-alignment.c
  clang/test/CodeGen/zvector.c
  clang/test/CodeGen/zvector2.c




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


[PATCH] D88845: [SystemZ][z/OS] Set default alignment rules for z/OS target

2020-10-06 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88845

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


[PATCH] D88845: [SystemZ][z/OS] Set default alignment rules for z/OS target

2020-10-06 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc781dc74a8b2: [SystemZ][z/OS] Set default alignment rules 
for z/OS target (authored by fanbo-meng, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88845

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/CodeGen/zos-alignment.c

Index: clang/test/CodeGen/zos-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/zos-alignment.c
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos -fdump-record-layouts %s -o - | FileCheck %s
+
+struct s0 {
+  short a:3;
+  long b:5;
+  int c:1;
+  long d:10;
+  char e:5;
+} S0;
+// CHECK:  0 | struct s0
+// CHECK-NEXT: 0:0-2 |   short a
+// CHECK-NEXT: 0:3-7 |   long b
+// CHECK-NEXT: 1:0-0 |   int c
+// CHECK-NEXT:1:1-10 |   long d
+// CHECK-NEXT: 2:3-7 |   char e
+// CHECK-NEXT:   | [sizeof=3, align=1]
+
+struct s1 {
+  char a:7;
+  long b:27;
+  int c:2;
+} S1;
+// CHECK:  0 | struct s1
+// CHECK-NEXT: 0:0-6 |   char a
+// CHECK-NEXT:0:7-33 |   long b
+// CHECK-NEXT: 4:2-3 |   int c
+// CHECK-NEXT:   | [sizeof=5, align=1]
+
+struct s2 {
+  char a:7;
+  char  :0;
+  short :0;
+  short :0;
+} S2;
+// CHECK:  0 | struct s2
+// CHECK-NEXT: 0:0-6 |   char a
+// CHECK-NEXT:   4:- |   char
+// CHECK-NEXT:   4:- |   short
+// CHECK-NEXT:   4:- |   short
+// CHECK-NEXT:   | [sizeof=4, align=4]
+
+struct s3 {
+  int a;
+  int b:16;
+  char  :0;
+  char c:1;
+} S3;
+// CHECK:  0 | struct s3
+// CHECK-NEXT: 0 |   int a
+// CHECK-NEXT:4:0-15 |   int b
+// CHECK-NEXT:   8:- |   char
+// CHECK-NEXT: 8:0-0 |   char c
+// CHECK-NEXT:   | [sizeof=12, align=4]
+
+struct s4 {
+ unsigned int __attribute__((aligned(32))) a;
+} S4;
+// CHECK:  0 | struct s4
+// CHECK-NEXT: 0 |   unsigned int a
+// CHECK-NEXT:   | [sizeof=32, align=32]
+
+struct s5 {
+  char a;
+  int  b:19 __attribute__((aligned(4)));
+  int  c:22 __attribute__((aligned(8)));
+  int  :0;
+  int  d:10;
+} S5;
+// CHECK:  0 | struct s5
+// CHECK-NEXT: 0 |   char a
+// CHECK-NEXT:4:0-18 |   int b
+// CHECK-NEXT:8:0-21 |   int c
+// CHECK-NEXT:  12:- |   int
+// CHECK-NEXT:12:0-9 |   int d
+// CHECK-NEXT:   | [sizeof=16, align=8]
+
+struct s6 {
+  char * a;
+  char * b[];
+} S6;
+// CHECK:  0 | struct s6
+// CHECK-NEXT: 0 |   char * a
+// CHECK-NEXT: 8 |   char *[] b
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+struct s10 {
+ unsigned int __attribute__((aligned)) a;
+} S10;
+// CHECK:  0 | struct s10
+// CHECK-NEXT: 0 |   unsigned int a
+// CHECK-NEXT:   | [sizeof=16, align=16]
+
+union u0 {
+  unsigned short d1 __attribute__((packed));
+  intd2:10;
+  long   d3;
+} U0 __attribute__((aligned(8)));
+// CHECK:  0 | union u0
+// CHECK-NEXT: 0 |   unsigned short d1
+// CHECK-NEXT: 0:0-9 |   int d2
+// CHECK-NEXT: 0 |   long d3
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+union u1 {
+  unsigned int:0;
+  short   a;
+} U1;
+// CHECK:  0 | union u1
+// CHECK-NEXT:   0:- |   unsigned int
+// CHECK-NEXT: 0 |   short a
+// CHECK-NEXT:   | [sizeof=4, align=4]
+
+union u2 {
+  long  :0;
+  short  a;
+} U2;
+// CHECK:  0 | union u2
+// CHECK-NEXT:   0:- |   long
+// CHECK-NEXT: 0 |   short a
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+union u3 {
+  unsigned char :0;
+  unsigned short :0;
+} U3;
+// CHECK:  0 | union u3
+// CHECK-NEXT:   0:- |   unsigned char
+// CHECK-NEXT:   0:- |   unsigned short
+// CHECK-NEXT:   | [sizeof=0, align=4]
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -779,6 +779,11 @@
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedInt;
+this->UseBitFieldTypeAlignment = false;
+this->UseZeroLengthBitfieldAlignment = true;
+this->ZeroLengthBitfieldBoundary = 32;
+this->MinGlobalAlign = 0;
+this->DefaultAlignForAttributeAligned = 128;
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88963: [SystemZ][z/OS] Add test of zero length bitfield type size larger than target zero length bitfield boundary

2020-10-07 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9908ee567059: [SystemZ][z/OS] Add test of zero length 
bitfield type size larger than target… (authored by fanbo-meng, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88963

Files:
  clang/test/CodeGen/zos-alignment.c


Index: clang/test/CodeGen/zos-alignment.c
===
--- clang/test/CodeGen/zos-alignment.c
+++ clang/test/CodeGen/zos-alignment.c
@@ -90,6 +90,17 @@
 // CHECK-NEXT: 0 |   unsigned int a
 // CHECK-NEXT:   | [sizeof=16, align=16]
 
+struct s11 {
+  char a;
+  long :0;
+  char b;
+} S11;
+// CHECK:  0 | struct s11
+// CHECK-NEXT: 0 |   char a
+// CHECK-NEXT:   8:- |   long
+// CHECK-NEXT: 8 |   char b
+// CHECK-NEXT:   | [sizeof=16, align=8]
+
 union u0 {
   unsigned short d1 __attribute__((packed));
   intd2:10;


Index: clang/test/CodeGen/zos-alignment.c
===
--- clang/test/CodeGen/zos-alignment.c
+++ clang/test/CodeGen/zos-alignment.c
@@ -90,6 +90,17 @@
 // CHECK-NEXT: 0 |   unsigned int a
 // CHECK-NEXT:   | [sizeof=16, align=16]
 
+struct s11 {
+  char a;
+  long :0;
+  char b;
+} S11;
+// CHECK:  0 | struct s11
+// CHECK-NEXT: 0 |   char a
+// CHECK-NEXT:   8:- |   long
+// CHECK-NEXT: 8 |   char b
+// CHECK-NEXT:   | [sizeof=16, align=8]
+
 union u0 {
   unsigned short d1 __attribute__((packed));
   intd2:10;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89127: [SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test

2020-10-09 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89127

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


[PATCH] D91565: Guard init_priority attribute within libc++

2020-11-20 Thread Abhina Sree via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c7e24c4b689: Guard init_priority attribute within libc++ 
(authored by zibi, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91565

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/test/SemaCXX/init-priority-attr.cpp
  libcxx/include/__config
  libcxx/src/experimental/memory_resource.cpp
  libcxx/src/iostream.cpp

Index: libcxx/src/iostream.cpp
===
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,7 @@
 #endif
 ;
 
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101)));
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX;
 
 // On Windows the TLS storage for locales needs to be initialized before we create
 // the standard streams, otherwise it may not be alive during program termination
Index: libcxx/src/experimental/memory_resource.cpp
===
--- libcxx/src/experimental/memory_resource.cpp
+++ libcxx/src/experimental/memory_resource.cpp
@@ -76,16 +76,6 @@
   ~ResourceInitHelper() {}
 };
 
-// Detect if the init_priority attribute is supported.
-#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
-  || defined(_LIBCPP_COMPILER_MSVC)
-// GCC on Apple doesn't support the init priority attribute,
-// and MSVC doesn't support any GCC attributes.
-# define _LIBCPP_INIT_PRIORITY_MAX
-#else
-# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
-#endif
-
 // When compiled in C++14 this initialization should be a constant expression.
 // Only in C++11 is "init_priority" needed to ensure initialization order.
 #if _LIBCPP_STD_VER > 11
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1421,6 +1421,12 @@
 #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
 #endif
 
+#if __has_attribute(init_priority)
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG
Index: clang/test/SemaCXX/init-priority-attr.cpp
===
--- clang/test/SemaCXX/init-priority-attr.cpp
+++ clang/test/SemaCXX/init-priority-attr.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DSYSTEM -verify %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -DSYSTEM -verify %s
+// RUN: %clang_cc1 -triple=s390x-none-zos -fsyntax-only -verify=unknown %s
+// RUN: %clang_cc1 -triple=s390x-none-zos -fsyntax-only -DSYSTEM -verify=unknown-system %s
 
 #if defined(SYSTEM)
 #5 "init-priority-attr.cpp" 3 // system header
@@ -23,25 +25,35 @@
 extern Two koo[];
 
 Two foo __attribute__((init_priority(101))) ( 5, 6 );
+ // unknown-system-no-diagnostics
+ // unknown-warning@-2 {{unknown attribute 'init_priority' ignored}}
 
 Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_priority' attribute takes one argument}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
 
 Two coo[2]  __attribute__((init_priority(100)));
 #if !defined(SYSTEM)
-// expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+  // expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+  // unknown-warning@-3 {{unknown attribute 'init_priority' ignored}}
 #endif
 
 Two boo[2]  __attribute__((init_priority(65536)));
 #if !defined(SYSTEM)
-// expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+ // expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+ // unknown-warning@-3 {{unknown attribute 'init_priority' ignored}}
 #endif
 
 Two koo[4]  __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
 
 Two func()  __attribute__((init_priority(1001))); // expected-error {{'init_priority' attribute only applies to variables}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
+
 
 int i  __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' 

[PATCH] D92048: [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

2020-11-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: fanbo-meng, Kai, uweigand, 
Jonathan.Crowther, muiez.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
abhina.sreeskantharajan requested review of this revision.

This patch moves all s390x tests in init.c and init-zos.c to init-s390x.c.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92048

Files:
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-zos.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -855,189 +855,6 @@
 // AMDGPU:#define cl_khr_local_int32_base_atomics 1
 // AMDGPU:#define cl_khr_local_int32_extended_atomics 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X -check-prefix S390X-CXX %s
-//
-// S390X:#define __BIGGEST_ALIGNMENT__ 8
-// S390X:#define __CHAR16_TYPE__ unsigned short
-// S390X:#define __CHAR32_TYPE__ unsigned int
-// S390X:#define __CHAR_BIT__ 8
-// S390X:#define __CHAR_UNSIGNED__ 1
-// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// S390X:#define __DBL_DIG__ 15
-// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// S390X:#define __DBL_HAS_DENORM__ 1
-// S390X:#define __DBL_HAS_INFINITY__ 1
-// S390X:#define __DBL_HAS_QUIET_NAN__ 1
-// S390X:#define __DBL_MANT_DIG__ 53
-// S390X:#define __DBL_MAX_10_EXP__ 308
-// S390X:#define __DBL_MAX_EXP__ 1024
-// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
-// S390X:#define __DBL_MIN_10_EXP__ (-307)
-// S390X:#define __DBL_MIN_EXP__ (-1021)
-// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
-// S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// S390X:#define __FLT_DIG__ 6
-// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
-// S390X:#define __FLT_EVAL_METHOD__ 0
-// S390X:#define __FLT_HAS_DENORM__ 1
-// S390X:#define __FLT_HAS_INFINITY__ 1
-// S390X:#define __FLT_HAS_QUIET_NAN__ 1
-// S390X:#define __FLT_MANT_DIG__ 24
-// S390X:#define __FLT_MAX_10_EXP__ 38
-// S390X:#define __FLT_MAX_EXP__ 128
-// S390X:#define __FLT_MAX__ 3.40282347e+38F
-// S390X:#define __FLT_MIN_10_EXP__ (-37)
-// S390X:#define __FLT_MIN_EXP__ (-125)
-// S390X:#define __FLT_MIN__ 1.17549435e-38F
-// S390X:#define __FLT_RADIX__ 2
-// S390X:#define __INT16_C_SUFFIX__
-// S390X:#define __INT16_FMTd__ "hd"
-// S390X:#define __INT16_FMTi__ "hi"
-// S390X:#define __INT16_MAX__ 32767
-// S390X:#define __INT16_TYPE__ short
-// S390X:#define __INT32_C_SUFFIX__
-// S390X:#define __INT32_FMTd__ "d"
-// S390X:#define __INT32_FMTi__ "i"
-// S390X:#define __INT32_MAX__ 2147483647
-// S390X:#define __INT32_TYPE__ int
-// S390X:#define __INT64_C_SUFFIX__ L
-// S390X:#define __INT64_FMTd__ "ld"
-// S390X:#define __INT64_FMTi__ "li"
-// S390X:#define __INT64_MAX__ 9223372036854775807L
-// S390X:#define __INT64_TYPE__ long int
-// S390X:#define __INT8_C_SUFFIX__
-// S390X:#define __INT8_FMTd__ "hhd"
-// S390X:#define __INT8_FMTi__ "hhi"
-// S390X:#define __INT8_MAX__ 127
-// S390X:#define __INT8_TYPE__ signed char
-// S390X:#define __INTMAX_C_SUFFIX__ L
-// S390X:#define __INTMAX_FMTd__ "ld"
-// S390X:#define __INTMAX_FMTi__ "li"
-// S390X:#define __INTMAX_MAX__ 9223372036854775807L
-// S390X:#define __INTMAX_TYPE__ long int
-// S390X:#define __INTMAX_WIDTH__ 64
-// S390X:#define __INTPTR_FMTd__ "ld"
-// S390X:#define __INTPTR_FMTi__ "li"
-// S390X:#define __INTPTR_MAX__ 9223372036854775807L
-// S390X:#define __INTPTR_TYPE__ long int
-// S390X:#define __INTPTR_WIDTH__ 64
-// S390X:#define __INT_FAST16_FMTd__ "hd"
-// S390X:#define __INT_FAST16_FMTi__ "hi"
-// S390X:#define __INT_FAST16_MAX__ 32767
-// S390X:#define __INT_FAST16_TYPE__ short
-// S390X:#define __INT_FAST32_FMTd__ "d"
-// S390X:#define __INT_FAST32_FMTi__ "i"
-// S390X:#define __INT_FAST32_MAX__ 2147483647
-// S390X:#define __INT_FAST32_TYPE__ int
-// S390X:#define __INT_FAST64_FMTd__ "ld"
-// S390X:#define __INT_FAST64_FMTi__ "li"
-// S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
-// S390X:#define __INT_FAST64_TYPE__ long int
-// S390X:#define __INT_FAST8_FMTd__ "hhd"
-// S390X:#define __INT_FAST8_FMTi__ "hhi"
-// S390X:#define __INT_FAST8_MAX__ 127
-// S390X:#define __INT_FAST8_TYPE__ signed char
-// S390X:#define __INT_LEAST16_FMTd__ "hd"
-// S390X:#define __INT_LEAST16_FMTi__ "hi"
-// S390X:#define __INT_LEAST16_MAX__ 32767
-// S390X:#define __INT_LEAST16_TYPE__ short
-// S390X:#define __INT_LEAST32_FMTd__ "d"
-// S390X:#define __INT_LEAST32_FMTi__ "i"
-// S390X:#define __INT_LEAST32_MAX__ 2147483647
-// S390X:#define __INT_LEAST32_TYPE__ int
-// S390X:#define __INT_LEAS

[PATCH] D92048: [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

2020-12-02 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf770ec1a4e8d: [SystemZ][NFC]Move all SystemZ tests to 
init-s390x.c (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92048

Files:
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-zos.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -855,189 +855,6 @@
 // AMDGPU:#define cl_khr_local_int32_base_atomics 1
 // AMDGPU:#define cl_khr_local_int32_extended_atomics 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X -check-prefix S390X-CXX %s
-//
-// S390X:#define __BIGGEST_ALIGNMENT__ 8
-// S390X:#define __CHAR16_TYPE__ unsigned short
-// S390X:#define __CHAR32_TYPE__ unsigned int
-// S390X:#define __CHAR_BIT__ 8
-// S390X:#define __CHAR_UNSIGNED__ 1
-// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// S390X:#define __DBL_DIG__ 15
-// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// S390X:#define __DBL_HAS_DENORM__ 1
-// S390X:#define __DBL_HAS_INFINITY__ 1
-// S390X:#define __DBL_HAS_QUIET_NAN__ 1
-// S390X:#define __DBL_MANT_DIG__ 53
-// S390X:#define __DBL_MAX_10_EXP__ 308
-// S390X:#define __DBL_MAX_EXP__ 1024
-// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
-// S390X:#define __DBL_MIN_10_EXP__ (-307)
-// S390X:#define __DBL_MIN_EXP__ (-1021)
-// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
-// S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// S390X:#define __FLT_DIG__ 6
-// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
-// S390X:#define __FLT_EVAL_METHOD__ 0
-// S390X:#define __FLT_HAS_DENORM__ 1
-// S390X:#define __FLT_HAS_INFINITY__ 1
-// S390X:#define __FLT_HAS_QUIET_NAN__ 1
-// S390X:#define __FLT_MANT_DIG__ 24
-// S390X:#define __FLT_MAX_10_EXP__ 38
-// S390X:#define __FLT_MAX_EXP__ 128
-// S390X:#define __FLT_MAX__ 3.40282347e+38F
-// S390X:#define __FLT_MIN_10_EXP__ (-37)
-// S390X:#define __FLT_MIN_EXP__ (-125)
-// S390X:#define __FLT_MIN__ 1.17549435e-38F
-// S390X:#define __FLT_RADIX__ 2
-// S390X:#define __INT16_C_SUFFIX__
-// S390X:#define __INT16_FMTd__ "hd"
-// S390X:#define __INT16_FMTi__ "hi"
-// S390X:#define __INT16_MAX__ 32767
-// S390X:#define __INT16_TYPE__ short
-// S390X:#define __INT32_C_SUFFIX__
-// S390X:#define __INT32_FMTd__ "d"
-// S390X:#define __INT32_FMTi__ "i"
-// S390X:#define __INT32_MAX__ 2147483647
-// S390X:#define __INT32_TYPE__ int
-// S390X:#define __INT64_C_SUFFIX__ L
-// S390X:#define __INT64_FMTd__ "ld"
-// S390X:#define __INT64_FMTi__ "li"
-// S390X:#define __INT64_MAX__ 9223372036854775807L
-// S390X:#define __INT64_TYPE__ long int
-// S390X:#define __INT8_C_SUFFIX__
-// S390X:#define __INT8_FMTd__ "hhd"
-// S390X:#define __INT8_FMTi__ "hhi"
-// S390X:#define __INT8_MAX__ 127
-// S390X:#define __INT8_TYPE__ signed char
-// S390X:#define __INTMAX_C_SUFFIX__ L
-// S390X:#define __INTMAX_FMTd__ "ld"
-// S390X:#define __INTMAX_FMTi__ "li"
-// S390X:#define __INTMAX_MAX__ 9223372036854775807L
-// S390X:#define __INTMAX_TYPE__ long int
-// S390X:#define __INTMAX_WIDTH__ 64
-// S390X:#define __INTPTR_FMTd__ "ld"
-// S390X:#define __INTPTR_FMTi__ "li"
-// S390X:#define __INTPTR_MAX__ 9223372036854775807L
-// S390X:#define __INTPTR_TYPE__ long int
-// S390X:#define __INTPTR_WIDTH__ 64
-// S390X:#define __INT_FAST16_FMTd__ "hd"
-// S390X:#define __INT_FAST16_FMTi__ "hi"
-// S390X:#define __INT_FAST16_MAX__ 32767
-// S390X:#define __INT_FAST16_TYPE__ short
-// S390X:#define __INT_FAST32_FMTd__ "d"
-// S390X:#define __INT_FAST32_FMTi__ "i"
-// S390X:#define __INT_FAST32_MAX__ 2147483647
-// S390X:#define __INT_FAST32_TYPE__ int
-// S390X:#define __INT_FAST64_FMTd__ "ld"
-// S390X:#define __INT_FAST64_FMTi__ "li"
-// S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
-// S390X:#define __INT_FAST64_TYPE__ long int
-// S390X:#define __INT_FAST8_FMTd__ "hhd"
-// S390X:#define __INT_FAST8_FMTi__ "hhi"
-// S390X:#define __INT_FAST8_MAX__ 127
-// S390X:#define __INT_FAST8_TYPE__ signed char
-// S390X:#define __INT_LEAST16_FMTd__ "hd"
-// S390X:#define __INT_LEAST16_FMTi__ "hi"
-// S390X:#define __INT_LEAST16_MAX__ 32767
-// S390X:#define __INT_LEAST16_TYPE__ short
-// S390X:#define __INT_LEAST32_FMTd__ "d"
-// S390X:#define __INT_LEAST32_FMTi__ "i"
-// S390X:#define __INT_LEAST32_MAX__ 2147483647
-// S390X:#define __INT_LEAST32_TYPE__ int
-// S390X:#define __INT_LEAST64_FMTd__ "ld"
-// S390X:#define __INT_LEAST64_FMTi__ "li"
-// S390X:#define __INT_LEA

[PATCH] D89801: [SystemZ][z/OS] Set short-enums as the default for z/OS

2020-10-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D89801

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


[PATCH] D89801: [SystemZ][z/OS] Set short-enums as the default for z/OS

2020-10-22 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9bc02e892f54: [SystemZ][z/OS] Set short-enums as the default 
for z/OS (authored by Jonathan.Crowther, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89801

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/zos-driver-defaults.c


Index: clang/test/Driver/zos-driver-defaults.c
===
--- /dev/null
+++ clang/test/Driver/zos-driver-defaults.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck 
--check-prefix=CHECK-SHORT-ENUMS %s
+// RUN: %clang -### --target=s390x-none-zos -fno-short-enums -fsyntax-only %s 
2>&1 | FileCheck %s
+// REQUIRES: clang-driver
+
+//CHECK-SHORT-ENUMS: -fshort-enums
+//CHECK-SHORT-ENUMS: -fno-signed-char
+
+//CHECK-NOT: -fshort-enums
+//CHECK: -fno-signed-char
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5645,9 +5645,9 @@
(RTTIMode == ToolChain::RM_Disabled)))
 CmdArgs.push_back("-fno-rtti");
 
-  // -fshort-enums=0 is default for all architectures except Hexagon.
+  // -fshort-enums=0 is default for all architectures except Hexagon and z/OS.
   if (Args.hasFlag(options::OPT_fshort_enums, options::OPT_fno_short_enums,
-   TC.getArch() == llvm::Triple::hexagon))
+   TC.getArch() == llvm::Triple::hexagon || Triple.isOSzOS()))
 CmdArgs.push_back("-fshort-enums");
 
   RenderCharacterOptions(Args, AuxTriple ? *AuxTriple : RawTriple, CmdArgs);


Index: clang/test/Driver/zos-driver-defaults.c
===
--- /dev/null
+++ clang/test/Driver/zos-driver-defaults.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-SHORT-ENUMS %s
+// RUN: %clang -### --target=s390x-none-zos -fno-short-enums -fsyntax-only %s 2>&1 | FileCheck %s
+// REQUIRES: clang-driver
+
+//CHECK-SHORT-ENUMS: -fshort-enums
+//CHECK-SHORT-ENUMS: -fno-signed-char
+
+//CHECK-NOT: -fshort-enums
+//CHECK: -fno-signed-char
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5645,9 +5645,9 @@
(RTTIMode == ToolChain::RM_Disabled)))
 CmdArgs.push_back("-fno-rtti");
 
-  // -fshort-enums=0 is default for all architectures except Hexagon.
+  // -fshort-enums=0 is default for all architectures except Hexagon and z/OS.
   if (Args.hasFlag(options::OPT_fshort_enums, options::OPT_fno_short_enums,
-   TC.getArch() == llvm::Triple::hexagon))
+   TC.getArch() == llvm::Triple::hexagon || Triple.isOSzOS()))
 CmdArgs.push_back("-fshort-enums");
 
   RenderCharacterOptions(Args, AuxTriple ? *AuxTriple : RawTriple, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2021-05-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D91628#2762190 , @MaskRay wrote:

> .ll -> .s tests should be placed in llvm/test/CodeGen/SystemZ, not in clang

Sorry for the late reply, I was on vacation. Is there a specific test you are 
referring to? All the testcases I moved in this commit already existed in 
clang/test/CodeGen and all seem to start with `.c` or `.cpp`, not `.ll`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91628

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: fanbo-meng, anirudhp, muiez, Kai, 
yusra.syeda.
Herald added subscribers: rupprecht, steven_wu, hiraditya, sbc100.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, aheejin.
Herald added projects: clang, LLVM.

This is a continuation of https://reviews.llvm.org/D94239. I missed some other 
spellings of the same error.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  llvm/test/Object/archive-extract-dir.test
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/error-opening-directory.test
  llvm/test/tools/llvm-ar/move.test
  llvm/test/tools/llvm-ar/print.test
  llvm/test/tools/llvm-ar/quick-append.test
  llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
  llvm/test/tools/llvm-lipo/create-arch.test
  llvm/test/tools/llvm-lipo/replace-invalid-input.test
  llvm/test/tools/llvm-lto/error.ll
  llvm/test/tools/llvm-objcopy/wasm/dump-section.test
  llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test

Index: llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
===
--- llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
+++ llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
@@ -4,7 +4,7 @@
 
 llvm-symbolizer should print one error and two unknown line info records.
 
-ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{N|n}}o such file or directory
+ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{.*}}{{N|n}}o such file or directory
 ERROR-NOT: error reading file
 
 CHECK: ??
Index: llvm/test/tools/llvm-objcopy/wasm/dump-section.test
===
--- llvm/test/tools/llvm-objcopy/wasm/dump-section.test
+++ llvm/test/tools/llvm-objcopy/wasm/dump-section.test
@@ -11,7 +11,7 @@
 # CHECK: 020 63 6c 61 6e 67 05 39 2e 30 2e 30
 
 # NONEXISTENT: section 'nonexistent' not found
-# DIROUT: error: {{.*}}/bar': {{[nN]}}o such file or directory
+# DIROUT: error: {{.*}}/bar': {{.*}}{{[nN]}}o such file or directory
 
 ## Check that dumping and removing a section works in the same invocation
 # RUN: llvm-objcopy --dump-section=producers=%t.sec --remove-section=producers %t %t2
Index: llvm/test/tools/llvm-lto/error.ll
===
--- llvm/test/tools/llvm-lto/error.ll
+++ llvm/test/tools/llvm-lto/error.ll
@@ -1,5 +1,5 @@
 ; RUN: not llvm-lto foobar 2>&1 | FileCheck %s
-; CHECK: llvm-lto: error loading file 'foobar': {{N|n}}o such file or directory
+; CHECK: llvm-lto: error loading file 'foobar': {{.*}}{{N|n}}o such file or directory
 
 ; RUN: not llvm-lto --list-symbols-only %S/Inputs/empty.bc 2>&1 | FileCheck %s --check-prefix=CHECK-LIST
 ; CHECK-LIST: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': The file was not recognized as a valid object file
Index: llvm/test/tools/llvm-lipo/replace-invalid-input.test
===
--- llvm/test/tools/llvm-lipo/replace-invalid-input.test
+++ llvm/test/tools/llvm-lipo/replace-invalid-input.test
@@ -12,7 +12,7 @@
 # INPUT_ARGS: error: replace expects a single input file
 
 # RUN: not llvm-lipo %t-universal.o -replace i386 %t-33.o  -o %t.o 2>&1 | FileCheck --check-prefix=INVALID_FILE %s
-# INVALID_FILE: {{[nN]}}o such file or directory
+# INVALID_FILE: {{.*}}{{[nN]}}o such file or directory
 
 # RUN: not llvm-lipo %t-universal.o -replace i3866 %t-32.o -o %t.o 2>&1 | FileCheck --check-prefix=INVALID_ARCH %s
 # INVALID_ARCH: error: Invalid architecture: i3866
Index: llvm/test/tools/llvm-lipo/create-arch.test
===
--- llvm/test/tools/llvm-lipo/create-arch.test
+++ llvm/test/tools/llvm-lipo/create-arch.test
@@ -14,4 +14,4 @@
 # INVALID_ARCH: error: Invalid architecture: i3866
 #
 # RUN: not llvm-lipo -arch i386 %t-33.o -create -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID_FILE %s
-# INVALID_FILE: {{[nN]}}o such file or directory
+# INVALID_FILE: {{.*}}{{[nN]}}o such file or directory
Index: llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
===
--- llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
+++ llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
@@ -28,7 +28,7 @@
 # RUN: not llvm-libtool-darwin -static -o %t.lib %t.missing 2>&1 | \
 # RUN:   FileCheck %s --check-prefix=NO-FILE -DFILE=%t.missing
 
-# NO-FILE: error: '[[FILE]]': {{[nN]}}o such file or directory
+# NO-FILE: error: '[[FILE]]': {{.*}}{{[nN]}}o such file or directory
 

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-22 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG520b5ecf8561: [SystemZ][z/OS] Fix No such file or directory 
expression error matching in lit… (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  llvm/test/Object/archive-extract-dir.test
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/error-opening-directory.test
  llvm/test/tools/llvm-ar/move.test
  llvm/test/tools/llvm-ar/print.test
  llvm/test/tools/llvm-ar/quick-append.test
  llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
  llvm/test/tools/llvm-lipo/create-arch.test
  llvm/test/tools/llvm-lipo/replace-invalid-input.test
  llvm/test/tools/llvm-lto/error.ll
  llvm/test/tools/llvm-objcopy/wasm/dump-section.test
  llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test

Index: llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
===
--- llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
+++ llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
@@ -4,7 +4,7 @@
 
 llvm-symbolizer should print one error and two unknown line info records.
 
-ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{N|n}}o such file or directory
+ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{.*}}{{N|n}}o such file or directory
 ERROR-NOT: error reading file
 
 CHECK: ??
Index: llvm/test/tools/llvm-objcopy/wasm/dump-section.test
===
--- llvm/test/tools/llvm-objcopy/wasm/dump-section.test
+++ llvm/test/tools/llvm-objcopy/wasm/dump-section.test
@@ -11,7 +11,7 @@
 # CHECK: 020 63 6c 61 6e 67 05 39 2e 30 2e 30
 
 # NONEXISTENT: section 'nonexistent' not found
-# DIROUT: error: {{.*}}/bar': {{[nN]}}o such file or directory
+# DIROUT: error: {{.*}}/bar': {{.*}}{{[nN]}}o such file or directory
 
 ## Check that dumping and removing a section works in the same invocation
 # RUN: llvm-objcopy --dump-section=producers=%t.sec --remove-section=producers %t %t2
Index: llvm/test/tools/llvm-lto/error.ll
===
--- llvm/test/tools/llvm-lto/error.ll
+++ llvm/test/tools/llvm-lto/error.ll
@@ -1,5 +1,5 @@
 ; RUN: not llvm-lto foobar 2>&1 | FileCheck %s
-; CHECK: llvm-lto: error loading file 'foobar': {{N|n}}o such file or directory
+; CHECK: llvm-lto: error loading file 'foobar': {{.*}}{{N|n}}o such file or directory
 
 ; RUN: not llvm-lto --list-symbols-only %S/Inputs/empty.bc 2>&1 | FileCheck %s --check-prefix=CHECK-LIST
 ; CHECK-LIST: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': The file was not recognized as a valid object file
Index: llvm/test/tools/llvm-lipo/replace-invalid-input.test
===
--- llvm/test/tools/llvm-lipo/replace-invalid-input.test
+++ llvm/test/tools/llvm-lipo/replace-invalid-input.test
@@ -12,7 +12,7 @@
 # INPUT_ARGS: error: replace expects a single input file
 
 # RUN: not llvm-lipo %t-universal.o -replace i386 %t-33.o  -o %t.o 2>&1 | FileCheck --check-prefix=INVALID_FILE %s
-# INVALID_FILE: {{[nN]}}o such file or directory
+# INVALID_FILE: {{.*}}{{[nN]}}o such file or directory
 
 # RUN: not llvm-lipo %t-universal.o -replace i3866 %t-32.o -o %t.o 2>&1 | FileCheck --check-prefix=INVALID_ARCH %s
 # INVALID_ARCH: error: Invalid architecture: i3866
Index: llvm/test/tools/llvm-lipo/create-arch.test
===
--- llvm/test/tools/llvm-lipo/create-arch.test
+++ llvm/test/tools/llvm-lipo/create-arch.test
@@ -14,4 +14,4 @@
 # INVALID_ARCH: error: Invalid architecture: i3866
 #
 # RUN: not llvm-lipo -arch i386 %t-33.o -create -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID_FILE %s
-# INVALID_FILE: {{[nN]}}o such file or directory
+# INVALID_FILE: {{.*}}{{[nN]}}o such file or directory
Index: llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
===
--- llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
+++ llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
@@ -28,7 +28,7 @@
 # RUN: not llvm-libtool-darwin -static -o %t.lib %t.missing 2>&1 | \
 # RUN:   FileCheck %s --check-prefix=NO-FILE -DFILE=%t.missing
 
-# NO-FILE: error: '[[FILE]]': {{[nN]}}o such file or directory
+# NO-FILE: error: '[[FILE]]': {{.*}}{{[nN]}}o such file or directory
 
 ## Input file is not an object file:
 # RUN: touch %t.invalid
Index: llvm/test/tools/llvm-ar/quick-append.test
===
--- llvm/test/tools/llvm-ar/quick-append.test
+++ llvm/test/tools/llvm-ar/quick-append.test
@@ -60,7 +60,7 @@
 # RU

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan reopened this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

In D95246#2518989 , @jhenderson wrote:

> Sorry, could you revert this please. I don't think this is a good fix, as 
> you've reduced coverage within the test, and some changes are completly 
> redundant/add extra noise. I've commented inline with examples. Skimming 
> D94239  suggests that has the same issue.
>
> Could you also please explain the messages your system is actually producing 
> so we can provide a better solution than this fix.
>
> I'm also concerned that you are doing this to fix this test for a system, yet 
> there are no build bots that report this error. A future contributor is 
> likely to break them in the same way/add new tests with the same issue. If 
> your system is a system that is supposed to be supported by LLVM, there needs 
> to be a build bot. If it isn't supported, you should bring this up on 
> llvm-dev (if you haven't already) to get buy-in for support.

Thanks for the feedback. I've reverted my changes from these two patches. We 
have indicated that we wish to add support for the z/OS platform but we have 
not set up a buildbot yet.

In D95246#2519086 , @grimar wrote:

> As far I understand, looking on the description of D94239 
> , the message on z/OS looks like "EDC5129I 
> No such file or directory.".
> I guess the `EDC5129I` is a stable error code? So why not to check for a 
> possible `EDC5129I` prefix word instead of `.*`?
> (The same applies for other possible errors)

As grimar noted, this is indeed the correct error message.  "EDC5129I No such 
file or directory." (Note the extra period at the end)
Based on your feedback, these are the better alternatives that were suggested:

  '{{.*N|n}}o such file or directory'

  {{EDC5129I N|N|n}}o such file or directory'

Some testcases fail because of the extra period at the end. For those 
testcases, this is a possible alternative.

  {{.*N|n}}o such file or directory{{\.?}}

Please let me know if there are better alternatives I could look into.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2519729 , @jhenderson wrote:

> In D95246#2519642 , 
> @abhina.sreeskantharajan wrote:
>
>> In D95246#2518989 , @jhenderson 
>> wrote:
>>
>>> Sorry, could you revert this please. I don't think this is a good fix, as 
>>> you've reduced coverage within the test, and some changes are completly 
>>> redundant/add extra noise. I've commented inline with examples. Skimming 
>>> D94239  suggests that has the same issue.
>>>
>>> Could you also please explain the messages your system is actually 
>>> producing so we can provide a better solution than this fix.
>>>
>>> I'm also concerned that you are doing this to fix this test for a system, 
>>> yet there are no build bots that report this error. A future contributor is 
>>> likely to break them in the same way/add new tests with the same issue. If 
>>> your system is a system that is supposed to be supported by LLVM, there 
>>> needs to be a build bot. If it isn't supported, you should bring this up on 
>>> llvm-dev (if you haven't already) to get buy-in for support.
>>
>> Thanks for the feedback. I've reverted my changes from these two patches. We 
>> have indicated that we wish to add support for the z/OS platform but we have 
>> not set up a buildbot yet.
>>
>> In D95246#2519086 , @grimar wrote:
>>
>>> As far I understand, looking on the description of D94239 
>>> , the message on z/OS looks like "EDC5129I 
>>> No such file or directory.".
>>> I guess the `EDC5129I` is a stable error code? So why not to check for a 
>>> possible `EDC5129I` prefix word instead of `.*`?
>>> (The same applies for other possible errors)
>>
>> As grimar noted, this is indeed the correct error message.  "EDC5129I No 
>> such file or directory." (Note the extra period at the end)
>> Based on your feedback, these are the better alternatives that were 
>> suggested:
>
> Slightly off-the-wall idea: I'm assuming you don't control your system in 
> such a way that you can change the error message to omit the error code?

Right, I'm not able to change the error message.

>>   '{{.*N|n}}o such file or directory'

>>   {{EDC5129I N|N|n}}o such file or directory'
>>
>> Some testcases fail because of the extra period at the end. For those 
>> testcases, this is a possible alternative.
>>
>>   {{.*N|n}}o such file or directory{{\.?}}
>>
>> Please let me know if there are better alternatives I could look into.
>
> I think you can just omit the trailing full stop in those cases. If the test 
> isn't using --match-full-lines, it should be fine. If it is, adding `{{.?}}` 
> seems reasonable.
>
> Having the error code explicitly in the pattern looks like the right solution 
> for now, but a thought on that - it seems like tests will still have the 
> fragility problem for when someone else writes a new test that checks the 
> message due to the error code not being present on most systems. Is the error 
> code different for each system error message (I'm guessing it is)? I wonder 
> if we would be better off adding some sort of lit substitution or similar 
> that expands to the right string for the given host OS, which could in turn 
> be fed to FileCheck. It might look a bit like this in practice:
>
>   # RUN: not do-a-thing %t 2>&1 | FileCheck %s -DMSG=%enoent -DFILE=%t
>   
>   # CHECK: error: '[[FILE]]': [[MSG]]
>
> What do you think?

I like the lit substitution solution, it will be a lot cleaner compared to a 
complicated regex. I've noticed there are already different regex for the same 
error message so this will help the error messages be uniform as well. I can 
look into implementing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319048.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a reviewer: grimar.
abhina.sreeskantharajan added a comment.
Herald added subscribers: sstefan1, delcypher.
Herald added a reviewer: jdoerfert.

I've implemented the initial solution suggested by James. I haven't updated all 
the testcases yet because I wanted to get feedback on the implementation first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  llvm/test/Object/archive-extract.test
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,14 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self, triple):
+if (re.match(r's390x-.*-zos', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'EDC5129I 
No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'no such 
file or directory\''))
+else:
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'No such 
file or directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -357,6 +365,10 @@
 
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
+
+if self.config.host_triple:
+   self.add_err_msg_substitutions(self.config.host_triple) 
+
 
 def use_llvm_tool(self, name, search_env=None, required=False, 
quiet=False):
 """Find the executable program 'name', optionally using the specified
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt 
-DMSG=%err_no_such_file_or_directory
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s 
--check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s 
--DMSG=%err_no_such_file_or_directory --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: clang/test/Frontend/stats-file.c
===
--- clang/test/Frontend/stats-file.c
+++ clang/test/Frontend/stats-file.c
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
-// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | 
FileCheck -DMSG=%err_no_such_file_or_directory -check-prefix=OUTPUTFAIL %s
+// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '[[MSG]]'
Index: clang/test/Frontend/output-failures.c
===
--- clang/test/Frontend/output-failures.c
+++ clang/test/Frontend/output-failures.c
@@ -1,4 +1,4 @@
 // RUN: not %clang_cc1 -emit-llvm -o %t.doesnotexist/somename %s 2> %t
-// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
+// RUN: FileCheck -check-prefix=OUTPUTFAIL 
-DMSG=%err_no_such_file_or_directory -input-file=%t %s
 
-// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
+// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '[[MSG]]'
Index: clang/test/Driver/clang-offload-bundler.c
===
--- 

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319078.
abhina.sreeskantharajan added a comment.

FIx CI, check if host_triple exists.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  llvm/test/Object/archive-extract.test
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,14 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self, triple):
+if (re.match(r's390x-.*-zos', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'EDC5129I 
No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'no such 
file or directory\''))
+else:
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'No such 
file or directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +366,10 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+if hasattr(self.config, 'host_triple'):
+   self.add_err_msg_substitutions(self.config.host_triple) 
+
+
 def use_llvm_tool(self, name, search_env=None, required=False, 
quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt 
-DMSG=%err_no_such_file_or_directory
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s 
--check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s 
--DMSG=%err_no_such_file_or_directory --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: clang/test/Frontend/stats-file.c
===
--- clang/test/Frontend/stats-file.c
+++ clang/test/Frontend/stats-file.c
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
-// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | 
FileCheck -DMSG=%err_no_such_file_or_directory -check-prefix=OUTPUTFAIL %s
+// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '[[MSG]]'
Index: clang/test/Frontend/output-failures.c
===
--- clang/test/Frontend/output-failures.c
+++ clang/test/Frontend/output-failures.c
@@ -1,4 +1,4 @@
 // RUN: not %clang_cc1 -emit-llvm -o %t.doesnotexist/somename %s 2> %t
-// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
+// RUN: FileCheck -check-prefix=OUTPUTFAIL 
-DMSG=%err_no_such_file_or_directory -input-file=%t %s
 
-// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
+// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '[[MSG]]'
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -70,9 +70,9 @@
 // RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gn

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319276.
abhina.sreeskantharajan added a comment.
Herald added subscribers: mgorny, emaste.

This patch makes the following changes:

- Define LLVM_HOST_TRIPLE for lld tests. (This was the project that didn't have 
host defined.)
- Change %err_no_such_file_or_directory to %errc_ENOENT as suggested by 
jhenderson

I've also created a post on llvm-dev about this patch: 
https://lists.llvm.org/pipermail/llvm-dev/2021-January/148089.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/CMakeLists.txt
  lld/test/ELF/basic.s
  lld/test/lit.site.cfg.py.in
  llvm/test/Object/archive-extract.test
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,14 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self, triple):
+if (re.match(r's390x-.*-zos', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +366,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions(self.config.host_triple)
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: lld/test/lit.site.cfg.py.in
===
--- lld/test/lit.site.cfg.py.in
+++ lld/test/lit.site.cfg.py.in
@@ -11,6 +11,7 @@
 config.lld_obj_root = "@LLD_BINARY_DIR@"
 config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
 config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MISSING: cannot open {{.*}}.foo: [[MSG]]
 
 # RUN: not ld.lld -o /dev/null 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -111,6 +111,10 @@
 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
 set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+if (LLD_BUILT_STANDALONE)
+  set(LLVM_HOST_TRIPLE ${TARGET_TRIPLE})
+endif()
+
 set(LLD_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with ve

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan requested review of this revision.
abhina.sreeskantharajan marked 4 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-354
+if (re.match(r's390x-.*-zos', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'EDC5129I 
No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'no such 
file or directory\''))
+else:
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'No such 
file or directory\''))

jhenderson wrote:
> These lines are quite long, so probably want reflowing.
> 
> I wonder if `%errc_...` might be a better name? That way, it ties to the 
> `std::errc` values these match up with.
Thanks, I've changed the error messages to your suggestion.



Comment at: llvm/utils/lit/lit/llvm/config.py:369-370
 
+if hasattr(self.config, 'host_triple'):
+   self.add_err_msg_substitutions(self.config.host_triple) 
+

jhenderson wrote:
> Under what conditions can there not be a `host_triple`? In those cases, what 
> happens to the tests that use the new substitution?
This was not defined for lld. I added changes to define this for lld and 
removed the check. I think this is defined in all the other projects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319309.
abhina.sreeskantharajan added a comment.

Fix CI: Other projects like flang also do not specify LLVM_HOST_TRIPLE. If this 
is not specified, set the triple to an empty string.

I also added one more error code %errc_EISDIR and updated the TestingGuide. 
Please let me know if there are other guides I will need to update that I'm not 
aware of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/CMakeLists.txt
  lld/test/ELF/basic.s
  lld/test/lit.site.cfg.py.in
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,21 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple
+
+if (re.match(r's390x-.*-zos', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +373,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,14 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   Example (%errc_ENOENT): ``No such file or directory``
+
+   Example (%errc_ENOENT): ``no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/lit.site.cfg.py.in
===
--- lld/test/lit.site.cfg.py.in
+++ lld/test/lit.site.cfg.py.in
@@ -11,6 +11,7 @@
 config.lld_obj_root = "@LLD

[PATCH] D93031: Enable fexec-charset option

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.
Herald added a reviewer: jansvoboda11.

ping :)
Is there any more feedback on the implementation inside ProcessCharEscape()?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319543.
abhina.sreeskantharajan added a comment.

I've changed the host check to use python's sys.platform to determine the host 
as an alternative to using LLVM_HOST_TRIPLE. It will save us the effort of 
making sure it's defined in all projects as well.

I noticed that llvm/docs/CommandGuide/lit.rst only lists substitutions that are 
done in TestRunner.py and refers to llvm/docs/TestingGuide.rst for information 
on the remaining substitutions. I think if we move the error substitution code 
into TestRunner.py, then it would be appropriate to update the lit.rst. Where 
do you think is the appropriate place to define the error substitutions, 
TestRunner.py or config.py?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/test/ELF/basic.s
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,14 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   Example: ``Linux %errc_ENOENT: No such file or directory``
+
+   Example: ``Windows %errc_ENOENT: no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/ELF/basic.s
=

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 2 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-351
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple

jhenderson wrote:
> I'm concerned that someone might start using these substitutions in a project 
> for the first time, and get confused why they don't work on non-windows 
> platforms. Maybe the solution is simply to require LLVM_HOST_TRIPLE to be set 
> in all projects, i.e. go back to what you were doing before, and letting 
> python fail if it isn't set.
> 
> Happy to hear other ideas too.
I think using sys.platform or platform.system() could be a better alternative. 
What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319547.
abhina.sreeskantharajan added a comment.

Fix CI: Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/ELF/basic.s
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,14 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   Example: ``Linux %errc_ENOENT: No such file or directory``
+
+   Example: ``Windows %errc_ENOENT: no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MISSING: cannot open {{.*}}.foo: [[MSG]]
 
 # RUN: not ld.lld -o /dev/null 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
Index: clang/test/Frontend/stats-file.c

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-351
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple

jhenderson wrote:
> abhina.sreeskantharajan wrote:
> > jhenderson wrote:
> > > I'm concerned that someone might start using these substitutions in a 
> > > project for the first time, and get confused why they don't work on 
> > > non-windows platforms. Maybe the solution is simply to require 
> > > LLVM_HOST_TRIPLE to be set in all projects, i.e. go back to what you were 
> > > doing before, and letting python fail if it isn't set.
> > > 
> > > Happy to hear other ideas too.
> > I think using sys.platform or platform.system() could be a better 
> > alternative. What do you think?
> Makes sense to me. Slight issue: cygwin on Windows uses `cygwin`. What error 
> message does it produce though?
I tested this out. On a cygwin terminal on Windows it emits the same error 
message as Linux so it should take the else path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319839.
abhina.sreeskantharajan added a comment.

Address syntax comments, and add a list of supported error code substitutions 
in the guide.

If these changes are ok, I would like to start making changes to all affected 
testcases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/ELF/basic.s
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,16 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   The following error codes are supported: ENOENT, EISDIR.
+
+   Example: ``Linux %errc_ENOENT: No such file or directory``
+
+   Example: ``Windows %errc_ENOENT: no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MI

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2527961 , @jhenderson wrote:

> One nit, but otherwise looks good to me, thanks! Please go ahead with the 
> other test updates. Do you plan on doing them in this patch?

This was my initial thought. But if it's preferred to create a second patch to 
make the remaining changes to affected testcases, I have no issue with doing 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319844.
abhina.sreeskantharajan added a comment.

Add currently in TestingGuide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/ELF/basic.s
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,16 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   The following error codes are currently supported: ENOENT, EISDIR.
+
+   Example: ``Linux %errc_ENOENT: No such file or directory``
+
+   Example: ``Windows %errc_ENOENT: no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MISSING: cannot open {{.*}}.foo: [[MSG]]
 
 # RUN: not ld.lld -o /dev/null 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
Index: clang/te

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319873.
abhina.sreeskantharajan retitled this revision from "[SystemZ][z/OS] Fix No 
such file or directory expression error matching in lit tests - continued" to 
"[test] Use host platform specific error message substitution in lit tests ".
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.
Herald added a reviewer: JDevlieghere.
Herald added subscribers: wenlei, gbedwell.
Herald added a reviewer: andreadb.

Update all testcases to use -DMSG.
I've also updated the summary to match the changes in the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/CodeGen/basic-block-sections.c
  clang/test/CodeGen/ubsan-blacklist-vfs.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/COFF/driver.test
  lld/test/COFF/manifestinput-error.test
  lld/test/COFF/nodefaultlib.test
  lld/test/COFF/pdb-type-server-invalid-signature.yaml
  lld/test/COFF/pdb-type-server-missing.yaml
  lld/test/ELF/archive-thin-missing-member.s
  lld/test/ELF/basic.s
  lld/test/ELF/reproduce-error.s
  lld/test/ELF/symbol-ordering-file.s
  lld/test/MachO/invalid/no-filelist.s
  llvm/docs/TestingGuide.rst
  llvm/test/DebugInfo/symbolize-missing-file.test
  llvm/test/MC/Hexagon/not_found.s
  llvm/test/Object/archive-extract-dir.test
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/dsymutil/X86/papertrail-warnings.test
  llvm/test/tools/dsymutil/archive-timestamp.test
  llvm/test/tools/dsymutil/debug-map-parsing.test
  llvm/test/tools/llvm-ar/error-opening-directory.test
  llvm/test/tools/llvm-ar/missing-thin-archive-member.test
  llvm/test/tools/llvm-ar/move.test
  llvm/test/tools/llvm-ar/print.test
  llvm/test/tools/llvm-ar/quick-append.test
  llvm/test/tools/llvm-ar/replace.test
  llvm/test/tools/llvm-ar/response.test
  llvm/test/tools/llvm-cxxdump/trivial.test
  llvm/test/tools/llvm-libtool-darwin/filelist.test
  llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
  llvm/test/tools/llvm-lipo/create-arch.test
  llvm/test/tools/llvm-lipo/replace-invalid-input.test
  llvm/test/tools/llvm-lto/error.ll
  llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
  llvm/test/tools/llvm-mc/basic.test
  llvm/test/tools/llvm-mca/invalid_input_file_name.test
  llvm/test/tools/llvm-ml/basic.test
  llvm/test/tools/llvm-objcopy/COFF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/error-format.test
  llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
  llvm/test/tools/llvm-objcopy/redefine-symbols.test
  llvm/test/tools/llvm-objcopy/wasm/dump-section.test
  llvm/test/tools/llvm-profdata/weight-instr.test
  llvm/test/tools/llvm-profdata/weight-sample.test
  llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
  llvm/test/tools/llvm-readobj/basic.test
  llvm/test/tools/llvm-readobj/thin-archive.test
  llvm/test/tools/llvm-size/no-input.test
  llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
  llvm/test/tools/llvm-xray/X86/no-such-file.txt
  llvm/test/tools/obj2yaml/invalid_input_file.test
  llvm/test/tools/yaml2obj/output-file.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/yaml2obj/output-file.yaml
=

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-01-29 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42a21778f61c: [test] Use host platform specific error 
message substitution in lit tests (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/CodeGen/basic-block-sections.c
  clang/test/CodeGen/ubsan-blacklist-vfs.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/COFF/driver.test
  lld/test/COFF/manifestinput-error.test
  lld/test/COFF/nodefaultlib.test
  lld/test/COFF/pdb-type-server-invalid-signature.yaml
  lld/test/COFF/pdb-type-server-missing.yaml
  lld/test/ELF/archive-thin-missing-member.s
  lld/test/ELF/basic.s
  lld/test/ELF/reproduce-error.s
  lld/test/ELF/symbol-ordering-file.s
  lld/test/MachO/invalid/no-filelist.s
  llvm/docs/TestingGuide.rst
  llvm/test/DebugInfo/symbolize-missing-file.test
  llvm/test/MC/Hexagon/not_found.s
  llvm/test/Object/archive-extract-dir.test
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/dsymutil/X86/papertrail-warnings.test
  llvm/test/tools/dsymutil/archive-timestamp.test
  llvm/test/tools/dsymutil/debug-map-parsing.test
  llvm/test/tools/llvm-ar/error-opening-directory.test
  llvm/test/tools/llvm-ar/missing-thin-archive-member.test
  llvm/test/tools/llvm-ar/move.test
  llvm/test/tools/llvm-ar/print.test
  llvm/test/tools/llvm-ar/quick-append.test
  llvm/test/tools/llvm-ar/replace.test
  llvm/test/tools/llvm-ar/response.test
  llvm/test/tools/llvm-cxxdump/trivial.test
  llvm/test/tools/llvm-libtool-darwin/filelist.test
  llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
  llvm/test/tools/llvm-lipo/create-arch.test
  llvm/test/tools/llvm-lipo/replace-invalid-input.test
  llvm/test/tools/llvm-lto/error.ll
  llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
  llvm/test/tools/llvm-mc/basic.test
  llvm/test/tools/llvm-mca/invalid_input_file_name.test
  llvm/test/tools/llvm-ml/basic.test
  llvm/test/tools/llvm-objcopy/COFF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/error-format.test
  llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
  llvm/test/tools/llvm-objcopy/redefine-symbols.test
  llvm/test/tools/llvm-objcopy/wasm/dump-section.test
  llvm/test/tools/llvm-profdata/weight-instr.test
  llvm/test/tools/llvm-profdata/weight-sample.test
  llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
  llvm/test/tools/llvm-readobj/basic.test
  llvm/test/tools/llvm-readobj/thin-archive.test
  llvm/test/tools/llvm-size/no-input.test
  llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
  llvm/test/tools/llvm-xray/X86/no-such-file.txt
  llvm/test/tools/obj2yaml/invalid_input_file.test
  llvm/test/tools/yaml2obj/output-file.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/yaml2obj/output-file.yaml
===
--- llvm/test/tools/yaml2obj/output-file.yaml
+++ llvm/test/tools/yaml2obj/output-file.yaml
@@ -7,9 +7,9 @@
 # RUN: yaml2obj %s -o%t
 # RUN: ls %t
 
-# RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck %s
+# RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
 
-# CHECK: yaml2obj: error: fai

[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-02-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: muiez, fanbo-meng, Kai, jhenderson, 
grimar.
Herald added subscribers: delcypher, emaste.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

On z/OS, the another error message is not matched correctly in lit tests.

  EDC5121I Invalid argument.

This patch adds a lit substitution to fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95808

Files:
  clang/test/Analysis/taint-generic.c
  clang/test/Format/style-on-command-line.cpp
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -349,12 +349,15 @@
 if (sys.platform == 'zos'):
 self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No 
such file or directory.\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a 
directory.\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I 
Invalid argument.\''))
 elif (sys.platform == 'win32'):
 self.config.substitutions.append(('%errc_ENOENT', '\'no such file 
or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'is a 
directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'invalid 
argument\''))
 else:
 self.config.substitutions.append(('%errc_ENOENT', '\'No such file 
or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'Is a 
directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'Invalid 
argument\''))
 
 def use_default_substitutions(self):
 tool_patterns = [
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
@@ -225,12 +225,12 @@
 
 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
 
-# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck %s 
--check-prefix=MISSING-KEY --ignore-case
+# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL 
%s --check-prefix=MISSING-KEY --ignore-case
 
 #  MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
 # MISSING-KEY-NEXT:   - DieOffset: 0x12345678
 # MISSING-KEY-NEXT: ^
-# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: Invalid 
argument
+# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: clang/test/Format/style-on-command-line.cpp
===
--- clang/test/Format/style-on-command-line.cpp
+++ clang/test/Format/style-on-command-line.cpp
@@ -1,7 +1,7 @@
 // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | 
FileCheck -strict-whitespace -check-prefix=CHECK1 %s
 // RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | 
FileCheck -strict-whitespace -check-prefix=CHECK2 %s
-// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" 
-fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK3 %s
-// RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | 
FileCheck -strict-whitespace -check-prefix=CHECK4 %s
+// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" 
-fallback-style=LLVM %s 2>&1 | FileCheck -DMSG=%errc_EINVAL -strict-whitespace 
-check-prefix=CHECK3 %s
+// RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | 
FileCheck -DMSG=%errc_EINVAL -strict-whitespace -check-prefix=CHECK4 %s
 // RUN: mkdir -p %t
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %t/.clang-format
 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck 
-strict-whitespace -check-prefix=CHECK5 %s
@@ -24,8 +24,8 @@
 // CHECK1: {{^int\* i;$}}
 // CHECK2: {{^   int \*i;$}}
 // CHECK3: Unknown value for BasedOnStyle: invalid
-// CHECK3: Error parsing -style: {{I|i}}nvalid argument
-// CHECK4: Error parsing -style: {{I|i}}nvalid argument
+// CHECK3: Error parsing -style: [[MSG]]
+// CHECK4: Error parsing -style: [[MSG]]
 // CHECK5: {{^ int\* i;$}}
 // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
 // CHECK7: {{^  int\* i;$}}
Index: clang/test/Analysis/taint-generic.c
===
--- clang/test/Analysis/taint-generic.c
+++ clang/test/Analysis/taint-generic.c
@@ -28,11 +28,11 @@
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-config \
 // RUN: 

[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-02-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 320571.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.
Herald added subscribers: rupprecht, arphaman, steven_wu, hiraditya.

I've previously changed Permission denied errors before. Fixing these testcases 
with a lit substitution as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95808

Files:
  clang/test/Analysis/taint-generic.c
  clang/test/Format/style-on-command-line.cpp
  lld/test/COFF/thinlto-emit-imports.ll
  lld/test/ELF/lto/resolution-err.ll
  lld/test/ELF/lto/thinlto-cant-write-index.ll
  lld/test/ELF/lto/thinlto-emit-imports.ll
  llvm/test/tools/llvm-ar/error-opening-permission.test
  llvm/test/tools/llvm-elfabi/fail-file-write.test
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -349,12 +349,18 @@
 if (sys.platform == 'zos'):
 self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I Invalid argument.\''))
+self.config.substitutions.append(('%errc_EACCES', '\'EDC5111I Permission denied.\''))
 elif (sys.platform == 'win32'):
 self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
+self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
 else:
 self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'Invalid argument\''))
+self.config.substitutions.append(('%errc_EACCES', '\'Permission denied\''))
 
 def use_default_substitutions(self):
 tool_patterns = [
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
@@ -225,12 +225,12 @@
 
 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
 
-# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck %s --check-prefix=MISSING-KEY --ignore-case
+# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY --ignore-case
 
 #  MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
 # MISSING-KEY-NEXT:   - DieOffset: 0x12345678
 # MISSING-KEY-NEXT: ^
-# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: Invalid argument
+# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/tools/llvm-elfabi/fail-file-write.test
===
--- llvm/test/tools/llvm-elfabi/fail-file-write.test
+++ llvm/test/tools/llvm-elfabi/fail-file-write.test
@@ -5,7 +5,7 @@
 # RUN: mkdir %t.TestDir
 # RUN: touch %t.TestDir/Output.TestFile
 # RUN: chmod 400 %t.TestDir
-# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
 # RUN: chmod 777 %t.TestDir
 # RUN: rm -rf %t.TestDir
 
@@ -15,4 +15,4 @@
 Symbols: {}
 ...
 
-# ERR: {{.*}}Permission denied{{.*}} when trying to open `{{.*}}.TestDir/Output.TestFile` for writing
+# ERR: [[MSG]] when trying to open `{{.*}}.TestDir/Output.TestFile` for writing
Index: llvm/test/tools/llvm-ar/error-opening-permission.test
===
--- llvm/test/tools/llvm-ar/error-opening-permission.test
+++ llvm/test/tools/llvm-ar/error-opening-permission.test
@@ -9,6 +9,6 @@
 # RUN: llvm-ar rc %t/permission.b %t/1.txt
 # RUN: chmod 100 %t/permission.b
 # RUN: not llvm-ar p %t/permission.b 2>&1 | \
-# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b
+# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b -DMSG=%errc_EACCES
 
-# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': {{.*}}{{[pP]}}ermission denied
+# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': [[MSG]]
Index: lld/test/ELF/lto/thinlto-emi

[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-02-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 320745.
abhina.sreeskantharajan added a comment.

Thank you for reminding me, I've updated the TestingGuide.rst.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95808

Files:
  clang/test/Analysis/taint-generic.c
  clang/test/Format/style-on-command-line.cpp
  lld/test/COFF/thinlto-emit-imports.ll
  lld/test/ELF/lto/resolution-err.ll
  lld/test/ELF/lto/thinlto-cant-write-index.ll
  lld/test/ELF/lto/thinlto-emit-imports.ll
  llvm/docs/TestingGuide.rst
  llvm/test/tools/llvm-ar/error-opening-permission.test
  llvm/test/tools/llvm-elfabi/fail-file-write.test
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -349,12 +349,18 @@
 if (sys.platform == 'zos'):
 self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I Invalid argument.\''))
+self.config.substitutions.append(('%errc_EACCES', '\'EDC5111I Permission denied.\''))
 elif (sys.platform == 'win32'):
 self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
+self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
 else:
 self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'Invalid argument\''))
+self.config.substitutions.append(('%errc_EACCES', '\'Permission denied\''))
 
 def use_default_substitutions(self):
 tool_patterns = [
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
@@ -225,12 +225,12 @@
 
 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
 
-# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck %s --check-prefix=MISSING-KEY --ignore-case
+# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY --ignore-case
 
 #  MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
 # MISSING-KEY-NEXT:   - DieOffset: 0x12345678
 # MISSING-KEY-NEXT: ^
-# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: Invalid argument
+# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/tools/llvm-elfabi/fail-file-write.test
===
--- llvm/test/tools/llvm-elfabi/fail-file-write.test
+++ llvm/test/tools/llvm-elfabi/fail-file-write.test
@@ -5,7 +5,7 @@
 # RUN: mkdir %t.TestDir
 # RUN: touch %t.TestDir/Output.TestFile
 # RUN: chmod 400 %t.TestDir
-# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
 # RUN: chmod 777 %t.TestDir
 # RUN: rm -rf %t.TestDir
 
@@ -15,4 +15,4 @@
 Symbols: {}
 ...
 
-# ERR: {{.*}}Permission denied{{.*}} when trying to open `{{.*}}.TestDir/Output.TestFile` for writing
+# ERR: [[MSG]] when trying to open `{{.*}}.TestDir/Output.TestFile` for writing
Index: llvm/test/tools/llvm-ar/error-opening-permission.test
===
--- llvm/test/tools/llvm-ar/error-opening-permission.test
+++ llvm/test/tools/llvm-ar/error-opening-permission.test
@@ -9,6 +9,6 @@
 # RUN: llvm-ar rc %t/permission.b %t/1.txt
 # RUN: chmod 100 %t/permission.b
 # RUN: not llvm-ar p %t/permission.b 2>&1 | \
-# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b
+# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b -DMSG=%errc_EACCES
 
-# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': {{.*}}{{[pP]}}ermission denied
+# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -542,7 +542,8 @@
  S

[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/test/CodeGenCXX/global-init.cpp:84
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();

nit: the lines above omit the end of the line. It's probably better to be 
consistent




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

https://reviews.llvm.org/D95822

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D95822

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


[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-02-03 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe59d336e75f4: [test] Use host platform specific error 
message substitution in lit tests… (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95808

Files:
  clang/test/Analysis/taint-generic.c
  clang/test/Format/style-on-command-line.cpp
  lld/test/COFF/thinlto-emit-imports.ll
  lld/test/ELF/lto/resolution-err.ll
  lld/test/ELF/lto/thinlto-cant-write-index.ll
  lld/test/ELF/lto/thinlto-emit-imports.ll
  llvm/docs/TestingGuide.rst
  llvm/test/tools/llvm-ar/error-opening-permission.test
  llvm/test/tools/llvm-elfabi/fail-file-write.test
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -349,12 +349,18 @@
 if (sys.platform == 'zos'):
 self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I Invalid argument.\''))
+self.config.substitutions.append(('%errc_EACCES', '\'EDC5111I Permission denied.\''))
 elif (sys.platform == 'win32'):
 self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
+self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
 else:
 self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'Invalid argument\''))
+self.config.substitutions.append(('%errc_EACCES', '\'Permission denied\''))
 
 def use_default_substitutions(self):
 tool_patterns = [
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
@@ -225,12 +225,12 @@
 
 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
 
-# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck %s --check-prefix=MISSING-KEY --ignore-case
+# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY --ignore-case
 
 #  MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
 # MISSING-KEY-NEXT:   - DieOffset: 0x12345678
 # MISSING-KEY-NEXT: ^
-# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: Invalid argument
+# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/tools/llvm-elfabi/fail-file-write.test
===
--- llvm/test/tools/llvm-elfabi/fail-file-write.test
+++ llvm/test/tools/llvm-elfabi/fail-file-write.test
@@ -5,7 +5,7 @@
 # RUN: mkdir %t.TestDir
 # RUN: touch %t.TestDir/Output.TestFile
 # RUN: chmod 400 %t.TestDir
-# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
 # RUN: chmod 777 %t.TestDir
 # RUN: rm -rf %t.TestDir
 
@@ -15,4 +15,4 @@
 Symbols: {}
 ...
 
-# ERR: {{.*}}Permission denied{{.*}} when trying to open `{{.*}}.TestDir/Output.TestFile` for writing
+# ERR: [[MSG]] when trying to open `{{.*}}.TestDir/Output.TestFile` for writing
Index: llvm/test/tools/llvm-ar/error-opening-permission.test
===
--- llvm/test/tools/llvm-ar/error-opening-permission.test
+++ llvm/test/tools/llvm-ar/error-opening-permission.test
@@ -9,6 +9,6 @@
 # RUN: llvm-ar rc %t/permission.b %t/1.txt
 # RUN: chmod 100 %t/permission.b
 # RUN: not llvm-ar p %t/permission.b 2>&1 | \
-# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b
+# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b -DMSG=%errc_EACCES
 
-# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': {{.*}}{{[pP]}}ermission denied
+# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': [[MSG]]
Index: llvm/docs/TestingGuide.rst
===

[PATCH] D96363: Mark output as text if it is really text

2021-02-09 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a reviewer: JDevlieghere.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This is a continuation of https://reviews.llvm.org/D67696. The following places 
need to set the OF_Text flag correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96363

Files:
  clang/lib/ARCMigrate/FileRemapper.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();
Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -121,7 +121,7 @@
 
   std::error_code EC;
   std::string infoFile = std::string(outputPath);
-  llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_None);
+  llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_Text);
   if (EC)
 return report(EC.message(), Diag);
 


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
=

[PATCH] D96363: Mark output as text if it is really text

2021-02-09 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 322479.
abhina.sreeskantharajan added a comment.

Remove ARCMigrate change in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();
__

[PATCH] D96363: Mark output as text if it is really text

2021-02-10 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 322658.
abhina.sreeskantharajan added a comment.

Rerun CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();
___
cfe-commits m

[PATCH] D96363: Mark output as text if it is really text

2021-02-11 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 323093.
abhina.sreeskantharajan added a comment.

Thanks for reviewing! Addressing inline comments by adding /*Binary*/ comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error gene

[PATCH] D96363: Mark output as text if it is really text

2021-02-12 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfdb640ea30d4: Mark output as text if it is really text 
(authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1445,7 +1445,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1445,7 +1445,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::dia

[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2564137 , @ASDenysPetrov 
wrote:

> This patch causes fails in a bunch of test files. When I roll it back, it 
> passes.
> Below you can see fail output of `ubsan-blacklist-vfs.c` and 
> `basic-block-sections.c`.
> F15539561: fail_output.txt 
>
> Please, pay attention to this. 
> I'm using build on Win10 + GCC config.
>
> P.S. The similar trouble is in D95808 . I've 
> commented there as well.

Hi Denys, thanks for bringing this to my attention, I'll look into this 
failure. I do know that the CI test for this patch and the other patch ran on 
Windows and did not report any errors. 
https://buildkite.com/llvm-project/premerge-checks/builds/23727#63570ad0-0e74-4825-b1dc-8f53a4d4dad0
Do you know what is different between your environments which is causing the 
spelling to be capitalized? This might help me determine how to fix the current 
host platform check in llvm/utils/lit/lit/llvm/config.py.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2566029 , @ASDenysPetrov 
wrote:

> In D95246#2565351 , 
> @abhina.sreeskantharajan wrote:
>
>> 
>
>
>
>> Do you know what is different between your environments which is causing the 
>> spelling to be capitalized? This might help me determine how to fix the 
>> current host platform check in llvm/utils/lit/lit/llvm/config.py.
>
> I'd love to help you. I'm using ordinary Win10. Here is my python output:
>
>   >>> os.name
>   'nt'
>   >>> sys.platform
>   'win32'
>   >>> platform.system()
>   'Windows'
>   >>> platform.release()
>   '10'
>   >>>
>
> If you would say what exact info you need I would execute and send you.
> BTW my python3 uses //Sentence case capitalization// in errors as you can see:
>
>   >>> open('some')
>   Traceback (most recent call last):
> File "", line 1, in 
>   FileNotFoundError: [Errno 2] No such file or directory: 'some'
>   >>>

Thanks! The following Windows bot (clang-x64-windows-msvc) is also passing 
http://lab.llvm.org:8011/#/builders/123, I expect it would have the same output 
in python as your machine.  James mentioned that this issue might be caused by 
a difference in standard library.

I was curious if all of these modified testcases are now failing or only the 
three you mentioned. I also don't know how this change can cause a pop-up to 
occur, is there more information you can provide? 
And lastly, if you have the time, does this testcase pass for you?

  llvm/test/tools/llvm-elfabi/fail-file-write-windows.test

I did not modify this but it requires system-windows and has a lower-case error 
message. I expect if my change causes failures for you, then this testcase 
should also fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-18 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2568084 , @ASDenysPetrov 
wrote:

> @jhenderson
>
>> @ASDenysPetrov, could you provide your link command-line for one of the 
>> tools that produces the failing message, please, e.g. llvm-ar?
>
> Here is output of running tests in llvm-ar folder: F15562458: 
> fail_output_llvm_ar.txt 
>
>> Not that I'm saying we shouldn't try to fix your use-case, but if you aren't 
>> using Cygwin, it's worth noting that 
>> https://llvm.org/docs/GettingStarted.html#hardware states that only Visual 
>> Studio builds (whether via the IDE or some other tool like ninja) are known 
>> to work for Windows.
>
> I'm using MSYS2 instead of Cygwin. I found it as a better alternative. I'm 
> using GCC+MSYS2+Ninja.

MSYS2 is based on a modified version of Cygwin according to its description, 
maybe if we can detect that in config.py this will solve your issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

@ASDenysPetrov are you running python inside MSYS bash that is installed by

> pacman -S --needed base-devel mingw-w64-x86_64-toolchain

? I learned that the python should give different output

  >>> sys.platform
  msys
  >>> platform.system()
  MSYS_NT-10.0-19041
  >>> sysconfig.get_platform()
  msys-3.1.7-x86_64

After taking a look at the CMakeCache.txt, I think a potential workaround would 
be to check if config.host_cxx contains MSYS2 which is set to 
CMAKE_CXX_COMPILER:FILEPATH=D:/WORK/Utilities/MSYS2/mingw64/bin/c++.exe if we 
can't determine MSYS through python.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2587452 , @jhenderson wrote:

> In D95246#2587410 , @ASDenysPetrov 
> wrote:
>
>> @jhenderson
>> I think I'm done.
>> Here is output: F15648076: linker_trace_output.txt 
>> 
>> Is it OK now?
>
> Thanks, yes that does the trick. As I expected, you can see that all the 
> libraries that are used are contained withing the msys2/mingw subdirectory, 
> and therefore are not the standard Windows SDK files that you would typically 
> use for a Windows build using Visual Studio. One of those will contain the 
> definitions we are talking about.
>
> @abhina.sreeskantharajan - I think you could this issue in one of two ways. 
> One would be to detect when the tools/libraries used are within the 
> msys2/mingw installation. Another way might be to actually build and run a 
> miniature program at CMake time that prints out the messages, in such a way 
> that CMake can inspect the output and use it to populate the lit 
> configuration. Note: I am not a CMake expert, so don't know if this is 
> strictly possible. The advantage of this approach is that you can remove the 
> reliance on the system.platform call in python, and just always use the 
> output of this simple program.

Thanks, I'm also not sure if the second way is possible. I had another idea but 
I will need @ASDenysPetrov to test it out.
Does the following python program print out the correct error string for you?

  import errno
  import os
  print ( os.strerror(errno.ENOENT))

If so, we can use this as the error message instead of hardcoding it per 
platform.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

I created the following review https://reviews.llvm.org/D97472 which I think 
should fix the error on all platforms. Let me know if this fixes the issue on 
MSYS2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, hiraditya.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch https://reviews.llvm.org/D102876 caused some lit regressions on z/OS 
because tmp files were no longer being opened based on binary/text mode. This 
patch passes OpenFlags when creating tmp files so we can open files in 
different modes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103806

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,11 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags Flags) {
   int FD;
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, 
Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags Flags = OF_Delete);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,10 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+llvm::sys::fs::OF_Delete |
+(Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text));
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,11 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags Flags) {
   int FD;
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags Flags = OF_Delete);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,10 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+llvm::sys::fs::OF_Delete |
+(Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text));
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: llvm/lib/Support/Path.cpp:1295
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, 
Mode))
 return errorCodeToError(EC);

rnk wrote:
> Instead of requiring the caller to add `OF_Delete`, I think it would be 
> better to pass `OF_Delete | Flags` here.
Sure, I'll make that change. Do you think we should change the name to 
"ExtraFlags" to indicate there is a default, or is the current name is fine?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103806

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


[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 350386.
abhina.sreeskantharajan added a comment.

Address rnk's comments and rename to ExtraFlags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103806

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,12 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags ExtraFlags) {
   int FD;
   SmallString<128> ResultPath;
   if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  createUniqueFile(Model, FD, ResultPath, OF_Delete | ExtraFlags, 
Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,9 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,12 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags ExtraFlags) {
   int FD;
   SmallString<128> ResultPath;
   if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  createUniqueFile(Model, FD, ResultPath, OF_Delete | ExtraFlags, Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,9 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-08 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e8506debae3: [SystemZ][z/OS] Pass OpenFlags when creating 
tmp files (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103806

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,12 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags ExtraFlags) {
   int FD;
   SmallString<128> ResultPath;
   if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  createUniqueFile(Model, FD, ResultPath, OF_Delete | ExtraFlags, 
Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,9 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,12 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags ExtraFlags) {
   int FD;
   SmallString<128> ResultPath;
   if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  createUniqueFile(Model, FD, ResultPath, OF_Delete | ExtraFlags, Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,9 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107189: [z/OS]Remove overriding default attribute aligned value

2021-07-30 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107189

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


[PATCH] D107565: Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test"

2021-08-05 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107565

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


[PATCH] D93031: Enable fexec-charset option

2021-03-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 327470.
abhina.sreeskantharajan added a comment.

Thanks for the feedback! I haven't addressed all the comments yet but I've made 
major renaming changes and hope to get feedback on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralConverter.h
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralConverter.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/CodeGen/systemz-charset.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1038,6 +1038,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -395,6 +395,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,8 +209,14 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset'
+
+// Test that we support the following exec charsets.
+// RUN: %clang -### -S -fexec-charset=UTF-8 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=ISO8859-1 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=IBM-1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID-NOT: error: invalid value
 
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
@@ -224,7 +230,7 @@
 // RUN: -fident -fno-ident\
 // RUN: -fimplicit-templates -fno-implicit-templates  \
 // RUN: -finput-charset=UTF-8 \
-// RUN: -fexec-charset=UTF-8 \
+// RUN: -fexec-charset=UTF-8  \
 // RUN: -fivopts -fno-ivopts  \
 // RUN: -fnon-call-exceptions -fno-non-call-exceptions\
 // RUN: -fpermissive -fno-permissive  \
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,11 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
+// /execution-charset: should warn on invalid charsets.
+// RUN: %clang_cl /execution-charset:invalid-charset -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-invalid %s
+// exe

[PATCH] D93031: Enable fexec-charset option

2021-03-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 6 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/include/clang/Lex/LiteralSupport.h:191
+Preprocessor &PP, tok::TokenKind kind,
+ConversionState TranslationState = TranslateToExecCharset);
 

tahonermann wrote:
> Is the default argument for `TranslationState` actually used anywhere?  I'm 
> skeptical that a default argument provides a benefit here.
> 
> Actually, this diff doesn't include any changes to construct a 
> `CharLiteralParser` with an explicit argument.  It seems this argument isn't 
> actually needed.
> 
> The only places I see objects of `CharLiteralParser` type constructed are in 
> `EvaluateValue()` in `clang/lib/Lex/PPExpressions.cpp` and 
> `Sema::ActOnCharacterConstant()` in `clang/lib/Sema/SemaExpr.cpp`.
You're right, we don't have any cases that use this arg yet so we can remove it.



Comment at: clang/include/clang/Lex/LiteralSupport.h:238-239
+ResultPtr(ResultBuf.data()), hadError(false), Pascal(false) {
+LT = new LiteralTranslator();
+LT->setTranslationTables(Features, Target, *Diags);
+init(StringToks, TranslationState);

tahonermann wrote:
> I don't think a `LiteralTranslator` object is actually needed in this case.  
> The only use of this constructor that I see is in 
> `ModuleMapParser::consumeToken()` in `clang/lib/Lex/ModuleMap.cpp` and, in 
> that case, I don't think any translation is necessary.
> 
> This suggests that `TranslationState` is not needed for this constructor 
> either; `NoTranslation` can be passed to `init()`.
Thanks, I've removed it.



Comment at: clang/include/clang/Lex/Preprocessor.h:145
   ModuleLoader  &TheModuleLoader;
+  LiteralTranslator *LT = nullptr;
 

tahonermann wrote:
> I don't see a reason for `LT` to be a pointer.  Can it be made a reference 
> or, better, a non-reference, non-pointer data member?
Thanks, I've changed it to a non-reference non-pointer member.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1322-1324
+  ConversionState State = isUTFLiteral(Kind) ? NoTranslation : 
TranslationState;
+  llvm::CharSetConverter *Converter =
+  LT ? LT->getCharConversionTable(State) : nullptr;

tahonermann wrote:
> Per the comment associated with the constructor declaration, I don't think 
> the new constructor parameter is needed; translation to execution character 
> set is always desired for non-UTF character literals.  I think this can be 
> something like:
>   llvm::CharSetConverter *Converter = nullptr;
>   if (! isUTFLiteral(Kind)) {
> assert(LT);
> Converter = LT->getCharConversionTable(TranslateToExecCharset);
>   }
I can't add an assertion here because LT might not be created in the case of 
the second StringLiteralParser constructor which does not pass the 
Preprocessor. But I have added the remaining changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D93031: Enable fexec-charset option

2021-03-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

Hi Tom, @tahonermann I renamed the LiteralTranslator class to 
LiteralConverter.cpp and have renamed a lot of the functions. Let me know what 
you think. I agree that the setConverters function is awkward, the problem 
stems from initializing the member early in Preprocessor but only being able to 
create the Converters once we know the target host later in the compilation 
process.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, martong, thopre, hiraditya.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch consists of changes to help distinguish between text and binary 
content correctly on z/OS. I would like to get feedback from Windows users on 
setting OF_None for all ToolOutputFiles. This seems to have been done as an 
optimization to prevent CRLF translation on Windows in the past.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97785

Files:
  clang/lib/ARCMigrate/FileRemapper.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename, -1,
+   true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(Filename, EC,
+   HostTriple.isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // 

[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-03 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 327790.
abhina.sreeskantharajan added a comment.

Remove some changes that cause lit failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename, -1,
+   true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(Filename, EC,
+   HostTriple.isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // If open fails, no cleanup is needed.
   if (EC)
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -816,13 +816,7 @@
 
 std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
  SmallVectorImpl &ResultPath,
-   

[PATCH] D97796: [test] Fix apparent typo in clang/test/Driver/std.c

2021-03-03 Thread Abhina Sree via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9403b59a7dbb: [test] Fix apparent typo in 
clang/test/Driver/std.c (authored by DanielMcIntosh-IBM, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97796

Files:
  clang/test/Driver/std.c


Index: clang/test/Driver/std.c
===
--- clang/test/Driver/std.c
+++ clang/test/Driver/std.c
@@ -1,6 +1,6 @@
 // RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=OVERRIDE %s
 // OVERRIDE: ??(??)
-// RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=FOVERRIDE %s
+// RUN: %clang -w -std=c99 -ftrigraphs -std=gnu99 %s -E -o - | FileCheck 
-check-prefix=FOVERRIDE %s
 // FOVERRIDE: ??(??)
 // RUN: %clang -w -ansi %s -E -o - | FileCheck -check-prefix=ANSI %s
 // ANSI: []


Index: clang/test/Driver/std.c
===
--- clang/test/Driver/std.c
+++ clang/test/Driver/std.c
@@ -1,6 +1,6 @@
 // RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=OVERRIDE %s
 // OVERRIDE: ??(??)
-// RUN: %clang -w -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=FOVERRIDE %s
+// RUN: %clang -w -std=c99 -ftrigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=FOVERRIDE %s
 // FOVERRIDE: ??(??)
 // RUN: %clang -w -ansi %s -E -o - | FileCheck -check-prefix=ANSI %s
 // ANSI: []
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93031: Enable fexec-charset option

2021-03-04 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 328151.
abhina.sreeskantharajan added a comment.

Addressing some more comments. Updating the argument parsing, lit tests, some 
more renaming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralConverter.h
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralConverter.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/CodeGen/systemz-charset.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1038,6 +1038,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -395,6 +395,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,8 +209,14 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset=invalid-charset'
+
+// Test that we support the following exec charsets.
+// RUN: %clang -### -S -fexec-charset=UTF-8 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=ISO8859-1 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=IBM-1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID-NOT: error: invalid value
 
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
@@ -224,7 +230,7 @@
 // RUN: -fident -fno-ident\
 // RUN: -fimplicit-templates -fno-implicit-templates  \
 // RUN: -finput-charset=UTF-8 \
-// RUN: -fexec-charset=UTF-8 \
+// RUN: -fexec-charset=UTF-8  \
 // RUN: -fivopts -fno-ivopts  \
 // RUN: -fnon-call-exceptions -fno-non-call-exceptions\
 // RUN: -fpermissive -fno-permissive  \
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,11 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
+// /execution-charset: should warn on invalid charsets.
+// RUN: %clang_cl /execution-charset:invalid-charset -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-invalid %s
+// execution-charset-invalid: in

[PATCH] D93031: Enable fexec-charset option

2021-03-04 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 4 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/include/clang/Lex/Preprocessor.h:145
   ModuleLoader  &TheModuleLoader;
+  LiteralConverter  LT;
 

rsmith wrote:
> Please give this a longer name. Abbreviation names should only be used in 
> fairly small scopes where it's easy to look up what they refer to.
> 
> Also: why `LT`? What does the `T` stand for?
Thanks for catching this. This was a change I missed when renaming 
LiteralTranslator to LiteralConverter. I've added a longer name.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6178
+  CmdArgs.push_back(Args.MakeArgString(Triple.getSystemCharset()));
+  for (auto it = vList.begin(), ie = vList.end(); it != ie; ++it) {
+llvm::ErrorOr ErrorOrConverter =

rsmith wrote:
> Looping over all the arguments is a little unusual. Normally we'd get the 
> last argument value and only check that one. Do you need to pass more than 
> one value onto the frontend?
Thanks, I've changed it back to get the LastArg only and use the spelling of 
the argument to fix the diagnostic error message in the driver lit tests.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1363-1364
+  if (!HadError && Converter) {
+assert(Kind != tok::wide_char_constant &&
+   "Wide character translation not supported");
+SmallString<1> ConvertedChar;

rsmith wrote:
> Why is this case not possible?
This case should be handled when fwide-exec-charset option is implemented. 
Until then, we thought it was best to emit a error message that wide literal 
translation is not supported.



Comment at: clang/lib/Lex/LiteralSupport.cpp:234
+SmallString<8> ResultCharConv;
+Converter->convert(std::string(1, ByteChar), ResultCharConv);
+memcpy((void *)&ResultChar, ResultCharConv.data(), sizeof(unsigned));

rsmith wrote:
> abhina.sreeskantharajan wrote:
> > tahonermann wrote:
> > > Conversion can fail here, particularly in the scenario corresponding to 
> > > the default switch case above; `ResultChar` could contain, for example, a 
> > > lead byte of a UTF-8 sequence.  Something sensible should be done here; 
> > > either rejecting the code with an error or substituting `?` (in the 
> > > execution encoding) seems appropriate to me.
> > Thanks, I added the substitution with the '?' character for invalid escapes.
> This is a regression. Our prior behavior for unknown escapes was to leave the 
> character alone. We should still do that wherever possible -- eg, `\q` should 
> produce `q` -- and take fallback action only if the character is unencodable. 
> Producing a `?` seems unlikely to ever be what anyone wants; producing a hard 
> error would seem preferable.
Hi @tahonermann, do you also agree we should use the original behaviour or give 
a hard error instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-03-05 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan requested review of this revision.
abhina.sreeskantharajan added a comment.

This issue has been fixed in https://reviews.llvm.org/D97472.
@ASDenysPetrov I'm unable to close this revision and the other one 
https://reviews.llvm.org/D95808.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-05 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Frontend/FrontendActions.cpp:841
 }
   }
 

amccarth wrote:
> The preceding block that detects the type of line separator seems ripe for 
> factoring out into a separate function.  It's a lot of low-level detail that 
> visually outweighs the primary intent of this method.
> 
> But I'm fine with the change as it doesn't impact Windows and--as far as I 
> understand--Posix platforms don't distinguish between text and binary mode.
Right, my intention was not to change the current behaviour, but only limit it 
to Windows which is the only affected platform.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-05 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 328483.
abhina.sreeskantharajan added reviewers: amccarth, MaskRay, jhenderson.
abhina.sreeskantharajan added a comment.

Fix formatting from lint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr =
+MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(Filename, EC,
+   HostTriple.isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // If open fails, no cleanup is needed.
   if (EC)
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -816,13 +816,7 @@
 
 std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
  SmallVectorImpl &ResultPath,
- 

  1   2   3   >