[PATCH] D158254: Fixing the memory leak using split() instead of strtok

2023-08-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 rGc3c8f16fc32c: Fixing the memory leak using split() instead 
of strtok (authored by hchilama, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158254

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp


Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -188,11 +188,10 @@
   CmdArgs.push_back(
   Args.MakeArgString("//'" + LEHLQ + ".SCEELIB(CELQS003)'"));
 } else {
-  char *ld_side_deck = strdup(ld_env_var.str().c_str());
-  ld_side_deck = strtok(ld_side_deck, ":");
-  while (ld_side_deck != nullptr) {
-CmdArgs.push_back(ld_side_deck);
-ld_side_deck = strtok(nullptr, ":");
+  SmallVector ld_side_deck;
+  ld_env_var.split(ld_side_deck, ":");
+  for (StringRef ld_loc : ld_side_deck) {
+CmdArgs.push_back((ld_loc.str()).c_str());
   }
 }
   }


Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -188,11 +188,10 @@
   CmdArgs.push_back(
   Args.MakeArgString("//'" + LEHLQ + ".SCEELIB(CELQS003)'"));
 } else {
-  char *ld_side_deck = strdup(ld_env_var.str().c_str());
-  ld_side_deck = strtok(ld_side_deck, ":");
-  while (ld_side_deck != nullptr) {
-CmdArgs.push_back(ld_side_deck);
-ld_side_deck = strtok(nullptr, ":");
+  SmallVector ld_side_deck;
+  ld_env_var.split(ld_side_deck, ":");
+  for (StringRef ld_loc : ld_side_deck) {
+CmdArgs.push_back((ld_loc.str()).c_str());
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158254: Fixing the memory leak using split() instead of strtok

2023-08-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D158254#4607027 , @hchilama wrote:

> Hi @abhina.sreeskantharajan , Thanks for letting me know the process and 
> please help me in commiting this patch.

I'd like to put your name and email as the commit's author. What email should I 
use? `git commit --amend --author="Harini Chilamantula "`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158254

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


[PATCH] D158254: Fixing the memory leak using split() instead of strtok

2023-08-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D158254#4605050 , @hchilama wrote:

> Hi @abhina.sreeskantharajan can I please know the next process on how to land 
> this revision to opensource?

Usually you need to have someone with commit access commit the changes for you 
for your first couple of patches and then you can request commit access 
yourself. This is outlined here 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access
 I'd be happy to commit this patch for you if needed :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158254

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


[PATCH] D158254: Fixing the memory leak using split() instead of strtok

2023-08-21 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.

In D158254#4603765 , @hchilama wrote:

> Hi @abhina.sreeskantharajan I have verified the fix aganist the clang-format, 
> seems fine. (FYI: I saw clean build on Friday)
>
> I have modified this object with the edit policy "All Users"
>
> Please let me know if I need to do anything else here?

I think the format should be good then, the CI might be failing due to another 
commit. LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158254

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


[PATCH] D158254: Fixing the memory leak using split() instead of strtok

2023-08-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

It seems like clang-format might be failing with this patch which should be 
fixed first.

And I think I cannot actually accept this patch because I see the following 
`hchilama created this object with edit policy "Administrators".`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158254

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


[PATCH] D158254: Fixing the memory leak using split() instead of strtok

2023-08-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158254

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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-14 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

I've discussed offline with @hubert.reinterpretcast and agree with him that 
with the addition of fexec-charset support, the set of characters deemed 
printable will not be accurate when other encodings are used. This will be 
similar to the printf/scanf format string validation issue I mentioned in my 
RFC and would require us to reverse the conversion or keep the original string 
around to check if the character is printable. I don't think we have finalized 
a solution on how to handle these issues yet.


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

https://reviews.llvm.org/D155610

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


[PATCH] D155234: [SystemZ][z/OS] Forward headers to z/os system headers

2023-07-28 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/D155234/new/

https://reviews.llvm.org/D155234

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


[PATCH] D155651: [SystemZ][z/OS] Add OpenFlags to CreateMissingDirectories path when creating temp files

2023-07-24 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4a5b61d7675: [SystemZ][z/OS] Add OpenFlags to 
CreateMissingDirectories path when creating… (authored by tltao, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155651

Files:
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -895,10 +895,12 @@
 TempPath += "-";
 TempPath += OutputExtension;
 TempPath += ".tmp";
+llvm::sys::fs::OpenFlags BinaryFlags =
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text;
 Expected ExpectedFile =
 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);
+BinaryFlags);
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError ) -> llvm::Error {
@@ -908,7 +910,9 @@
 StringRef Parent = llvm::sys::path::parent_path(OutputPath);
 EC = llvm::sys::fs::create_directories(Parent);
 if (!EC) {
-  ExpectedFile = llvm::sys::fs::TempFile::create(TempPath);
+  ExpectedFile = llvm::sys::fs::TempFile::create(
+  TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+  BinaryFlags);
   if (!ExpectedFile)
 return llvm::errorCodeToError(
 llvm::errc::no_such_file_or_directory);


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -895,10 +895,12 @@
 TempPath += "-";
 TempPath += OutputExtension;
 TempPath += ".tmp";
+llvm::sys::fs::OpenFlags BinaryFlags =
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text;
 Expected ExpectedFile =
 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);
+BinaryFlags);
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError ) -> llvm::Error {
@@ -908,7 +910,9 @@
 StringRef Parent = llvm::sys::path::parent_path(OutputPath);
 EC = llvm::sys::fs::create_directories(Parent);
 if (!EC) {
-  ExpectedFile = llvm::sys::fs::TempFile::create(TempPath);
+  ExpectedFile = llvm::sys::fs::TempFile::create(
+  TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+  BinaryFlags);
   if (!ExpectedFile)
 return llvm::errorCodeToError(
 llvm::errc::no_such_file_or_directory);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155651: [SystemZ][z/OS] Add OpenFlags to CreateMissingDirectories path when creating temp files

2023-07-19 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/D155651/new/

https://reviews.llvm.org/D155651

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-07-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D153418#4478766 , @tahonermann 
wrote:

>> Please correct me if I'm wrong, I'm not too familiar with icu4c, but I think 
>> adding support for ICU would be the better long-term solution since it seems 
>> to allow the same behaviour across different platforms.
>
> I tend to agree. Additionally, as more Unicode support is added to C++, the 
> likelihood that we'll want to use other functionality from ICU increases.
>
>> However, the issue on the z/OS platform is that there currently isn't 
>> support for this library so iconv seems to be the only solution we can use 
>> until we do get support. So would an alternative be to use iconv only on 
>> z/OS (and hopefully this is a temporary solution until icu is supported on 
>> z/OS) and use icu on all other platforms?
>
> ICU isn't supported on z/OS because the historical z/OS compiler (xlC) never 
> gained support for C++11 or later so support for z/OS was dropped when ICU 
> moved to C++11. Now that IBM has embraced LLVM and Clang, I would expect it 
> to be possible to build ICU for z/OS again with moderate porting effort. It 
> would be great if someone from IBM could confirm whether such an effort is 
> underway (@hubert.reinterpretcast?).

We currently have no plan or resources allocated towards porting ICU on z/OS. 
Our users also rely on iconv for the system locales, but (and please correct me 
if I'm wrong) it seems like ICU does not use system locales so this may not 
meet our users' needs. So we would still prefer to have iconv support available 
at the very least for z/OS, even if ICU is the preferred default.

I'll also post the same reply on the RFC so we can continue the discussion there


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D153582: [SystemZ][z/OS] Add required options/macro/etc for z/os compilation step

2023-06-30 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 rGd32fb5e5f51d: [SystemZ][z/OS] Add required options/macro/etc 
 for z/os compilation step (authored by SeanP, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153582

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/zos-comp-cxx.cpp
  clang/test/Driver/zos-comp.c
  clang/test/Driver/zos-driver-defaults.c
  clang/test/Preprocessor/init-s390x.c

Index: clang/test/Preprocessor/init-s390x.c
===
--- clang/test/Preprocessor/init-s390x.c
+++ clang/test/Preprocessor/init-s390x.c
@@ -183,17 +183,12 @@
 // 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 __COMPILER_VER__ 0x5000
 // S390X-ZOS:   #define __LONGNAME__ 1
 // S390X-ZOS:   #define __MVS__ 1
 // S390X-ZOS:   #define __THW_370__ 1
Index: clang/test/Driver/zos-driver-defaults.c
===
--- clang/test/Driver/zos-driver-defaults.c
+++ clang/test/Driver/zos-driver-defaults.c
@@ -1,8 +1,23 @@
-// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-SHORT-ENUMS %s
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefixes=CHECK-C-MACRO,CHECK-SHORT-ENUMS %s
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-ZOS-INCLUDES %s
 // RUN: %clang -### --target=s390x-none-zos -fno-short-enums -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clangxx -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck --check-prefixes=CHECK-C-MACRO,CHECK-CXX-MACRO %s
+// RUN: %clang -### --target=s390x-none-zos -x c++ -fsyntax-only %s 2>&1 | FileCheck --check-prefixes=CHECK-C-MACRO,CHECK-CXX-MACRO %s
+
+//CHECK-C-MACRO: -D_UNIX03_WITHDRAWN
+//CHECK-C-MACRO: -D_OPEN_DEFAULT
+
+//CHECK-CXX-MACRO: -D_XOPEN_SOURCE=600
+//CHECK-USER-CXX-MACRO-NOT: -D_XOPEN_SOURCE=600
+//CHECK-USER-CXX-MACRO: "-D" "_XOPEN_SOURCE=700"
 
 //CHECK-SHORT-ENUMS: -fshort-enums
 //CHECK-SHORT-ENUMS: -fno-signed-char
 
+//CHECK-ZOS-INCLUDES: clang{{.*}} "-cc1" "-triple" "s390x-none-zos"
+//CHECK-ZOS-INCLUDES-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+//CHECK-ZOS-INCLUDES-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include{{(/|)}}zos_wrappers"
+//CHECK-ZOS-INCLUDES-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+//
 //CHECK-NOT: -fshort-enums
 //CHECK: -fno-signed-char
Index: clang/test/Driver/zos-comp.c
===
--- /dev/null
+++ clang/test/Driver/zos-comp.c
@@ -0,0 +1,75 @@
+// Tests that the z/OS toolchain adds system includes to its search path.
+
+// RUN: %clang -c -### %s --target=s390x-ibm-zos 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK: "-D_UNIX03_WITHDRAWN"
+// CHECK-SAME: "-D_OPEN_DEFAULT"
+// CHECK-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include{{(/|)}}zos_wrappers"
+// CHECK-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-SAME: "-internal-isystem" "/usr/include"
+// CHECK-SAME: "-fshort-enums"
+// CHECK-SAME: "-fno-signed-char"
+// CHECK-SAME: "-fno-signed-wchar"
+
+// RUN: %clang -c -### -mzos-sys-include=/ABC/DEF %s 2>&1 \
+// RUN:		--target=s390x-ibm-zos \
+// RUN:   | FileCheck --check-prefixes=CHECK2 %s
+
+// CHECK2: "-D_UNIX03_WITHDRAWN"
+// CHECK2-SAME: "-D_OPEN_DEFAULT"
+// CHECK2-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK2-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include{{(/|)}}zos_wrappers"
+// CHECK2-SAME: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK2-SAME: "-internal-isystem" "/ABC/DEF"
+// CHECK2-NOT: "-internal-isystem" 

[PATCH] D153580: [SystemZ][z/OS] Add support for z/OS link step (executable and shared libs)

2023-06-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 rG5e87ec1e19ce: [SystemZ][z/OS] Add support for z/OS link step 
(executable and shared libs) (authored by SeanP, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153580

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/zos-ld.c

Index: clang/test/Driver/zos-ld.c
===
--- /dev/null
+++ clang/test/Driver/zos-ld.c
@@ -0,0 +1,123 @@
+// General tests that ld invocations for z/OS are valid.
+
+// 1. General C link for executable
+// RUN: %clang -### --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=C-LD %s
+
+// C-LD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// C-LD: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// C-LD-SAME: "-e" "CELQSTRT"
+// C-LD-SAME: "-O" "CELQSTRT"
+// C-LD-SAME: "-u" "CELQMAIN"
+// C-LD-SAME: "-x" "/dev/null"
+// C-LD-SAME: "-S" "//'CEE.SCEEBND2'"
+// C-LD-SAME: "-S" "//'SYS1.CSSLIB'"
+// C-LD-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// C-LD-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// C-LD-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 2. General C link for dll
+// RUN: %clang -### --shared --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=C-LD-DLL %s
+
+// C-LD-DLL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// C-LD-DLL: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// C-LD-DLL-NOT: "-e" "CELQSTRT"
+// C-LD-DLL-NOT: "-O" "CELQSTRT"
+// C-LD-DLL-NOT: "-u" "CELQMAIN"
+// C-LD-DLL-SAME: "-x" "{{.*}}.x"
+// C-LD-DLL-SAME: "-S" "//'CEE.SCEEBND2'"
+// C-LD-DLL-SAME: "-S" "//'SYS1.CSSLIB'"
+// C-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// C-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// C-LD-DLL-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 3. General C++ link for executable
+// RUN: %clangxx -### --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CXX-LD %s
+
+// CXX-LD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CXX-LD: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// CXX-LD-SAME: "-e" "CELQSTRT"
+// CXX-LD-SAME: "-O" "CELQSTRT"
+// CXX-LD-SAME: "-u" "CELQMAIN"
+// CXX-LD-SAME: "-x" "/dev/null"
+// CXX-LD-SAME: "-S" "//'CEE.SCEEBND2'"
+// CXX-LD-SAME: "-S" "//'SYS1.CSSLIB'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXE)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXS)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXP)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXA)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQXLA)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQUNW)'"
+// CXX-LD-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 4. General C++ link for dll
+// RUN: %clangxx -### --shared --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CXX-LD-DLL %s
+
+// CXX-LD-DLL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CXX-LD-DLL: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// CXX-LD-DLL-NOT: "-e" "CELQSTRT"
+// CXX-LD-DLL-NOT: "-O" "CELQSTRT"
+// CXX-LD-DLL-NOT: "-u" "CELQMAIN"
+// CXX-LD-DLL-SAME: "-x" "{{.*}}.x"
+// CXX-LD-DLL-SAME: "-S" "//'CEE.SCEEBND2'"
+// CXX-LD-DLL-SAME: "-S" "//'SYS1.CSSLIB'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXE)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXS)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXP)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXA)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQXLA)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQUNW)'"
+// CXX-LD-DLL-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 5. C++ link for executable w/ -mzos-hlq-le=, -mzos-hlq-csslib=
+// RUN: %clangxx -### --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   -mzos-hlq-le= -mzos-hlq-csslib= \
+// RUN:   | FileCheck --check-prefix=CXX-LD5 %s
+
+// CXX-LD5: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CXX-LD5: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// CXX-LD5-SAME: "-e" "CELQSTRT"
+// CXX-LD5-SAME: "-O" "CELQSTRT"
+// CXX-LD5-SAME: "-u" "CELQMAIN"
+// CXX-LD5-SAME: "-x" "/dev/null"
+// CXX-LD5-SAME: "-S" "//'.SCEEBND2'"
+// CXX-LD5-SAME: "-S" "//'.CSSLIB'"
+// CXX-LD5-SAME: "//'.SCEELIB(CELQS001)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CELQS003)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXE)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXS)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXP)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXA)'"
+// CXX-LD5-SAME: 

[PATCH] D153582: [SystemZ][z/OS] Add required options/macro/etc for z/os compilation step

2023-06-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.

new changes LGTM


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

https://reviews.llvm.org/D153582

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


[PATCH] D153417: New CharSetConverter wrapper class for ConverterEBCDIC

2023-06-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

> I don't think anyone is particularly against the concept of adding a charset 
> conversion API; most of the discussion is around the choice to implement the 
> API as a thin wrapper around POSIX iconv().  And that concern applies equally 
> no matter where the code is located in the source tree.

Sorry, I misremembered where it was. That discussion I mentioned was from the 
previous patch https://reviews.llvm.org/D88741, not my RFC.

@cor3ntin had the following concerns:

> If we do use iconv though, i would like us to have a better understanding of 
> use cases, The patch currently links iconv to all llvm libraries, which might 
> be overkill if the only project using it is Clang, and I wonder how that 
> affects packaging
> on linux distributions.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153417

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


[PATCH] D153417: New CharSetConverter wrapper class for ConverterEBCDIC

2023-06-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D153417#4438764 , @efriedma wrote:

> As I mentioned at 
> https://discourse.llvm.org/t/rfc-enabling-fexec-charset-support-to-llvm-and-clang-reposting/71512
>  , I think SimplifyLibCalls needs to be aware of encodings.  To make that 
> work, this probably needs to be somewhere in llvm/ , not clang/ .

There was previous resistance to putting this in LLVM 
https://discourse.llvm.org/t/rfc-adding-a-charset-converter-to-the-llvm-support-library/69795/17,
 I'm not sure if that sentiment has changed. I think it would be best to have 
some sort of implementation plan to tackle the SimplifyLibCalls issue before 
shifting this code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153417

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


[PATCH] D153582: [SystemZ][z/OS] Add required options/macro/etc for z/os compilation step

2023-06-26 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, it looks like CI is failing for some unrelated reason, but it would be 
good to kick it off again


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

https://reviews.llvm.org/D153582

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


[PATCH] D153580: [SystemZ][z/OS] Add support for z/OS link step (executable and shared libs)

2023-06-26 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/D153580/new/

https://reviews.llvm.org/D153580

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


[PATCH] D153582: [SystemZ][z/OS] Add required options/macro/etc for z/os compilation step

2023-06-23 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

The CI shows the following lit tests are failing due to this patch which should 
be resolved first

Failed Tests (7):

  Clang :: CodeGen/SystemZ/zos-alignment.c
  Clang :: CodeGen/target-data.c
  Clang :: CodeGen/wchar-size.c
  Clang :: Driver/zos-comp-cxx.cpp
  Clang :: Driver/zos-driver-defaults.c
  Clang :: Driver/zos-dwarfversion.c
  Clang :: Preprocessor/init-s390x.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153582

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D153418#4441603 , @efriedma wrote:

> Even if we do decide we have to use platform-specific facilities because 
> there's no suitable library, I think we should at least have a hardcoded set 
> of encodings we recognize, so we aren't passing arbitrary encoding names 
> directly from the command-line to the iconv() call.
>
> Do you have a list of specific encodings you care about?

I think this is reasonable since gcc's fexec-charset option also says the name 
can be any encoding supported by the iconv library  (copy pasted below from 
https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc.pdf) so this would match that 
behaviour. Unfortunately, I don't think we are able to provide a hardcoded list 
because the locales installed can differ between machines and the only thing we 
can guarantee is -fexec-charset=utf-8 is always supported.

  -fexec-charset=charset
  Set the execution character set, used for string and character constants. The
  default is UTF-8. charset can be any encoding supported by the system’s iconv
  library routine.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added a comment.

Please correct me if I'm wrong, I'm not too familiar with icu4c, but I think 
adding support for ICU would be the better long-term solution since it seems to 
allow the same behaviour across different platforms. However, the issue on the 
z/OS platform is that there currently isn't support for this library so iconv 
seems to be the only solution we can use until we do get support. So would an 
alternative be to use iconv only on z/OS (and hopefully this is a temporary 
solution until icu is supported on z/OS) and use icu on all other platforms?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 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/Basic/CMakeLists.txt:62
+if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
+  set(system_libs ${system_libs} ${Iconv_LIBRARIES})
+endif()

michaelplatings wrote:
> This doesn't look like an idomatic way to link a library. Could you use [[ 
> https://cmake.org/cmake/help/latest/command/target_link_libraries.html | 
> target_link_libraries ]] instead?
Thanks, I've made this change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 533352.
abhina.sreeskantharajan added a reviewer: michaelplatings.
abhina.sreeskantharajan added a comment.

Use target_link_libraries instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

Files:
  clang/include/clang/Basic/CharSet.h
  clang/include/clang/Config/config.h.cmake
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/CharSet.cpp
  clang/unittests/Basic/CharSetTest.cpp

Index: clang/unittests/Basic/CharSetTest.cpp
===
--- clang/unittests/Basic/CharSetTest.cpp
+++ clang/unittests/Basic/CharSetTest.cpp
@@ -40,6 +40,29 @@
 // String with Cyrillic character ya.
 static const char CyrillicUTF[] = "\xd0\xaf";
 
+// String "Earth地球".
+// ISO-2022-JP: Sequence ESC $ B (\x1B\x24\x42) switches to JIS X 0208-1983, and
+// sequence ESC ( B (\x1B\x28\x42) switches back to ASCII.
+// IBM-939: Byte 0x0E shifts from single byte to double byte, and 0x0F shifts
+// back.
+static const char EarthUTF[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90\x83";
+// Identical to above, except the final character (球) has its last byte taken
+// away from it.
+static const char EarthUTFBroken[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90";
+static const char EarthISO2022[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65\x1B\x28\x42";
+static const char EarthISO2022ShiftBack[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65";
+static const char EarthIBM939[] =
+"\xc5\x81\x99\xa3\x88\x0e\x45\xc2\x48\xdb\x0f";
+static const char ShiftBackOnly[] = "\x1B\x28\x42";
+
+// String "地球".
+static const char EarthKanjiOnlyUTF[] = "\xe5\x9c\xb0\xe7\x90\x83";
+static const char EarthKanjiOnlyISO2022[] =
+"\x1B\x24\x42\x43\x4F\x35\x65\x1b\x28\x42";
+static const char EarthKanjiOnlyIBM939[] = "\x0e\x45\xc2\x48\xdb\x0f";
+
 TEST(CharSet, FromUTF8) {
   // Hello string.
   StringRef Src(HelloA);
@@ -98,4 +121,154 @@
   EXPECT_STREQ(AccentUTF, static_cast(Dst).c_str());
 }
 
+TEST(CharSet, RoundTrip) {
+  ErrorOr ConvToUTF16 =
+  CharSetConverter::create("IBM-1047", "UTF-16");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF16) {
+ASSERT_EQ(ConvToUTF16.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToUTF32 =
+  CharSetConverter::create("UTF-16", "UTF-32");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF32) {
+ASSERT_EQ(ConvToUTF32.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToEBCDIC =
+  CharSetConverter::create("UTF-32", "IBM-1047");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToEBCDIC) {
+ASSERT_EQ(ConvToEBCDIC.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Setup source string.
+  char SrcStr[256];
+  for (size_t I = 0; I < 256; ++I)
+SrcStr[I] = (I + 1) % 256;
+
+  SmallString<99> Dst1Str, Dst2Str, Dst3Str;
+
+  std::error_code EC = ConvToUTF16->convert(StringRef(SrcStr), Dst1Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToUTF32->convert(Dst1Str, Dst2Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToEBCDIC->convert(Dst2Str, Dst3Str, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(SrcStr, static_cast(Dst3Str).c_str());
+}
+
+TEST(CharSet, ShiftState2022) {
+  // Earth string.
+  StringRef Src(EarthUTF);
+  SmallString<64> Dst;
+
+  ErrorOr ConvTo2022 =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvTo2022) {
+ASSERT_EQ(ConvTo2022.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Check that the string is properly converted.
+  std::error_code EC = ConvTo2022->convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(EarthISO2022, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, ShiftState2022Flush) {
+  StringRef Src0(EarthUTFBroken);
+  StringRef Src1(EarthKanjiOnlyUTF);
+  SmallString<64> Dst0;
+  SmallString<64> Dst1;
+  ErrorOr ConvTo2022Flush =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  if (!ConvTo2022Flush) {
+ASSERT_EQ(ConvTo2022Flush.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // This should emit an error; there is a malformed multibyte character in the
+  // input string.
+  std::error_code EC0 = ConvTo2022Flush->convert(Src0, Dst0, true);
+  EXPECT_TRUE(EC0);
+  std::error_code EC1 = ConvTo2022Flush->flush();
+  EXPECT_TRUE(!EC1);
+  std::error_code EC2 = ConvTo2022Flush->convert(Src1, Dst1, true);
+  EXPECT_TRUE(!EC2);
+  EXPECT_STREQ(EarthKanjiOnlyISO2022, static_cast(Dst1).c_str());
+}
+
+TEST(CharSet, 

[PATCH] D93031: Enable fexec-charset option

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan abandoned this revision.
abhina.sreeskantharajan added a comment.

I have opened a new patch https://reviews.llvm.org/D153419 and am closing this 
revision


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] D153419: Enable fexec-charset option

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

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 adding the CharSetConverter class 
https://reviews.llvm.org/D153417


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153419

Files:
  clang/docs/LanguageExtensions.rst
  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/Frontend/InitPreprocessor.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
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-x86.c
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/TargetParser/Triple.cpp

Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -1193,6 +1193,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 VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   Version.tryParse(Name);
Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -436,6 +436,9 @@
   /// string (separated by a '-' 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/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1297,7 +1297,7 @@
 // X86_64-CLOUDABI:#define __amd64 1
 // X86_64-CLOUDABI:#define __amd64__ 1
 // X86_64-CLOUDABI:#define __clang__ 1
-// X86_64-CLOUDABI:#define __clang_literal_encoding__ {{.*}}
+// X86_64-CLOUDABI:#define __clang_literal_encoding__ UTF-8
 // X86_64-CLOUDABI:#define __clang_major__ {{.*}}
 // X86_64-CLOUDABI:#define __clang_minor__ {{.*}}
 // X86_64-CLOUDABI:#define __clang_patchlevel__ {{.*}}
Index: clang/test/Preprocessor/init-s390x.c
===
--- clang/test/Preprocessor/init-s390x.c
+++ clang/test/Preprocessor/init-s390x.c
@@ -201,4 +201,5 @@
 // S390X-ZOS:   #define __TOS_390__ 1
 // S390X-ZOS:   #define __TOS_MVS__ 1
 // S390X-ZOS:   #define __XPLINK__ 1
+// S390X-ZOS:   #define __clang_literal_encoding__ IBM-1047
 // S390X-ZOS-GNUXX: #define __wchar_t 1
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -226,8 +226,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 

[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 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.

This patch adds iconv support to the CharSetConverter class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153418

Files:
  clang/include/clang/Basic/CharSet.h
  clang/include/clang/Config/config.h.cmake
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/CharSet.cpp
  clang/unittests/Basic/CharSetTest.cpp

Index: clang/unittests/Basic/CharSetTest.cpp
===
--- clang/unittests/Basic/CharSetTest.cpp
+++ clang/unittests/Basic/CharSetTest.cpp
@@ -40,6 +40,29 @@
 // String with Cyrillic character ya.
 static const char CyrillicUTF[] = "\xd0\xaf";
 
+// String "Earth地球".
+// ISO-2022-JP: Sequence ESC $ B (\x1B\x24\x42) switches to JIS X 0208-1983, and
+// sequence ESC ( B (\x1B\x28\x42) switches back to ASCII.
+// IBM-939: Byte 0x0E shifts from single byte to double byte, and 0x0F shifts
+// back.
+static const char EarthUTF[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90\x83";
+// Identical to above, except the final character (球) has its last byte taken
+// away from it.
+static const char EarthUTFBroken[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90";
+static const char EarthISO2022[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65\x1B\x28\x42";
+static const char EarthISO2022ShiftBack[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65";
+static const char EarthIBM939[] =
+"\xc5\x81\x99\xa3\x88\x0e\x45\xc2\x48\xdb\x0f";
+static const char ShiftBackOnly[] = "\x1B\x28\x42";
+
+// String "地球".
+static const char EarthKanjiOnlyUTF[] = "\xe5\x9c\xb0\xe7\x90\x83";
+static const char EarthKanjiOnlyISO2022[] =
+"\x1B\x24\x42\x43\x4F\x35\x65\x1b\x28\x42";
+static const char EarthKanjiOnlyIBM939[] = "\x0e\x45\xc2\x48\xdb\x0f";
+
 TEST(CharSet, FromUTF8) {
   // Hello string.
   StringRef Src(HelloA);
@@ -98,4 +121,154 @@
   EXPECT_STREQ(AccentUTF, static_cast(Dst).c_str());
 }
 
+TEST(CharSet, RoundTrip) {
+  ErrorOr ConvToUTF16 =
+  CharSetConverter::create("IBM-1047", "UTF-16");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF16) {
+ASSERT_EQ(ConvToUTF16.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToUTF32 =
+  CharSetConverter::create("UTF-16", "UTF-32");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF32) {
+ASSERT_EQ(ConvToUTF32.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToEBCDIC =
+  CharSetConverter::create("UTF-32", "IBM-1047");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToEBCDIC) {
+ASSERT_EQ(ConvToEBCDIC.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Setup source string.
+  char SrcStr[256];
+  for (size_t I = 0; I < 256; ++I)
+SrcStr[I] = (I + 1) % 256;
+
+  SmallString<99> Dst1Str, Dst2Str, Dst3Str;
+
+  std::error_code EC = ConvToUTF16->convert(StringRef(SrcStr), Dst1Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToUTF32->convert(Dst1Str, Dst2Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToEBCDIC->convert(Dst2Str, Dst3Str, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(SrcStr, static_cast(Dst3Str).c_str());
+}
+
+TEST(CharSet, ShiftState2022) {
+  // Earth string.
+  StringRef Src(EarthUTF);
+  SmallString<64> Dst;
+
+  ErrorOr ConvTo2022 =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvTo2022) {
+ASSERT_EQ(ConvTo2022.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Check that the string is properly converted.
+  std::error_code EC = ConvTo2022->convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(EarthISO2022, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, ShiftState2022Flush) {
+  StringRef Src0(EarthUTFBroken);
+  StringRef Src1(EarthKanjiOnlyUTF);
+  SmallString<64> Dst0;
+  SmallString<64> Dst1;
+  ErrorOr ConvTo2022Flush =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  if (!ConvTo2022Flush) {
+ASSERT_EQ(ConvTo2022Flush.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // This should emit an error; there is a malformed multibyte character in the
+  // input string.
+  std::error_code EC0 = ConvTo2022Flush->convert(Src0, Dst0, true);
+  EXPECT_TRUE(EC0);
+  std::error_code EC1 = ConvTo2022Flush->flush();
+  EXPECT_TRUE(!EC1);
+  std::error_code EC2 = ConvTo2022Flush->convert(Src1, Dst1, true);
+  EXPECT_TRUE(!EC2);
+  EXPECT_STREQ(EarthKanjiOnlyISO2022, static_cast(Dst1).c_str());
+}
+
+TEST(CharSet, 

[PATCH] D153417: New CharSetConverter wrapper class for ConverterEBCDIC

2023-06-21 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.

This patch is adding a wrapper class called CharSetConverter for 
ConverterEBCDIC which was added previously here 
https://reviews.llvm.org/rGb42718dcecdd6787e0fde826ef7377f4e3cdd7bd.

This is the base for two patches, the first will add-on iconv support to this 
CharSetConverter class so we can support more charsets. The other patch is the 
implementation of fexec-charset which relies on this CharSetConverter class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153417

Files:
  clang/include/clang/Basic/CharSet.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/CharSet.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/CharSetTest.cpp

Index: clang/unittests/Basic/CharSetTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/CharSetTest.cpp
@@ -0,0 +1,101 @@
+//===- unittests/Support/CharSetTest.cpp - Charset conversion tests ---===//
+//
+// 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 "clang/Basic/CharSet.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+using namespace llvm;
+
+namespace {
+
+// String "Hello World!"
+static const char HelloA[] =
+"\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x0a";
+static const char HelloE[] =
+"\xC8\x85\x93\x93\x96\x40\xE6\x96\x99\x93\x84\x5A\x15";
+
+// String "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+static const char ABCStrA[] =
+"\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52"
+"\x53\x54\x55\x56\x57\x58\x59\x5A\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A"
+"\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A";
+static const char ABCStrE[] =
+"\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9"
+"\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91"
+"\x92\x93\x94\x95\x96\x97\x98\x99\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9";
+
+// String "¡¢£AÄÅÆEÈÉÊaàáâãäeèéêë"
+static const char AccentUTF[] =
+"\xc2\xa1\xc2\xa2\xc2\xa3\x41\xc3\x84\xc3\x85\xc3\x86\x45\xc3\x88\xc3\x89"
+"\xc3\x8a\x61\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3\xc3\xa4\x65\xc3\xa8\xc3\xa9"
+"\xc3\xaa\xc3\xab";
+static const char AccentE[] = "\xaa\x4a\xb1\xc1\x63\x67\x9e\xc5\x74\x71\x72"
+  "\x81\x44\x45\x42\x46\x43\x85\x54\x51\x52\x53";
+
+// String with Cyrillic character ya.
+static const char CyrillicUTF[] = "\xd0\xaf";
+
+TEST(CharSet, FromUTF8) {
+  // Hello string.
+  StringRef Src(HelloA);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(text_encoding::id::UTF8,
+   text_encoding::id::IBM1047);
+  std::error_code EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloE, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // ABC string.
+  Src = ABCStrA;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrE, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // Accent string.
+  Src = AccentUTF;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(AccentE, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // Cyrillic string. Results in error because not representable in 1047.
+  Src = CyrillicUTF;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_EQ(EC, std::errc::illegal_byte_sequence);
+}
+
+TEST(CharSet, ToUTF8) {
+  // Hello string.
+  StringRef Src(HelloE);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(text_encoding::id::IBM1047,
+   text_encoding::id::UTF8);
+  std::error_code EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloA, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // ABC string.
+  Src = ABCStrE;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrA, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // Accent string.
+  Src = AccentE;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(AccentUTF, static_cast(Dst).c_str());
+}
+
+} // namespace
Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(BasicTests
   CharInfoTest.cpp
+  CharSetTest.cpp
   DarwinSDKInfoTest.cpp
   DiagnosticTest.cpp
   FileEntryTest.cpp
Index: clang/lib/Basic/CharSet.cpp

[PATCH] D152016: Remove 3-byte characters causing clang-tblgen to get I/O error.

2023-06-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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152016

___
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

2023-05-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D93031#4308764 , @barannikov88 
wrote:

> @abhina.sreeskantharajan
> What is the status of this patch?

Hello, I was waiting for the CharSetConverter patch to land. Now that this 
patch has landed https://reviews.llvm.org/D148821 to add limited EBCDIC <-> 
UTF-8 conversion support, I have started to refactor my patch to use this 
instead. This implementation also heavily relies on iconv support which is 
still being discussed in the CharSet Converter RFC here 
https://discourse.llvm.org/t/rfc-adding-a-charset-converter-to-the-llvm-support-library/69795/16


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] D145158: Make clang/test/C/C2x/n2934.c compatible with targets that do not support thread_local storage.

2023-03-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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145158

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


[PATCH] D134034: [test] Use host platform specific error message substitution

2022-09-16 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce193431141d: [test] Use host platform specific error 
message substitution (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134034

Files:
  clang/test/Format/style-on-command-line.cpp
  llvm/test/tools/llvm-dis/errors.test
  llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
  llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
  llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test


Index: llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
===
--- llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
+++ llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
@@ -1,3 +1,3 @@
-; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck 
%s
+; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck 
-DMSG=%errc_ENOENT %s
 
-; CHECK: error: {{.*}}v4.tbd' {{[Nn]}}o such file or directory
+; CHECK: error: {{.*}}v4.tbd' [[MSG]]
Index: llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
===
--- llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
+++ llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
@@ -1,4 +1,4 @@
 # REQUIRES: amdgpu-registered-target
-# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg 
%s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck 
-check-prefix=ERR %s
+# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg 
%s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck 
-DMSG=%errc_ENOENT -check-prefix=ERR %s
 
-# ERR: {{.*}}llvm-reduce{{.*}}: {{[Nn]}}o such file or directory
+# ERR: {{.*}}llvm-reduce{{.*}}: [[MSG]]
Index: llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
===
--- llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
+++ llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
@@ -3,11 +3,11 @@
 RUN: cd %t
 RUN: cp %p/../Inputs/dwos_list_from_exec/b.dwo b.dwo
 RUN: cp %p/../Inputs/dwos_list_from_exec/main main
-RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-BIN
-RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-1ST-DWO
+RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT 
%s --check-prefix=CHECK-BIN
+RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=CHECK-1ST-DWO
 RUN: cp %p/../Inputs/dwos_list_from_exec/a.dwo a.dwo
 RUN: rm b.dwo
-RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-2ND-DWO
+RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=CHECK-2ND-DWO
 
 Build commands for the test binaries:
 
@@ -23,6 +23,6 @@
  return 0;
   }
 
-CHECK-BIN: error: 'binary': {{[Nn]}}o such file or directory
-CHECK-1ST-DWO: error: './a.dwo': {{[Nn]}}o such file or directory
-CHECK-2ND-DWO: error: './b.dwo': {{[Nn]}}o such file or directory
+CHECK-BIN: error: 'binary': [[MSG]]
+CHECK-1ST-DWO: error: './a.dwo': [[MSG]]
+CHECK-2ND-DWO: error: './b.dwo': [[MSG]]
Index: llvm/test/tools/llvm-dis/errors.test
===
--- llvm/test/tools/llvm-dis/errors.test
+++ llvm/test/tools/llvm-dis/errors.test
@@ -1,3 +1,3 @@
-# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck %s 
--check-prefix=MISSING --ignore-case
+# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=MISSING --ignore-case
 
-# MISSING: error: missing-file-path: no such file or directory
+# MISSING: error: missing-file-path: [[MSG]]
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
@@ -6,7 +6,7 @@
 // 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
 // RUN: printf "Invalid:\n" > %t/.clang-format
-// RUN: not clang-format -style=file -fallback-style=webkit 
-assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK6 %s
+// RUN: not clang-format -style=file -fallback-style=webkit 
-assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -DMSG=%errc_EINVAL 
-strict-whitespace -check-prefix=CHECK6 %s
 // RUN: rm %t/.clang-format
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %t/_clang-format
 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck 
-strict-whitespace -check-prefix=CHECK7 %s
@@ -35,7 +35,7 @@
 // CHECK4: Error 

[PATCH] D134034: [test] Use host platform specific error message substitution

2022-09-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 460828.
abhina.sreeskantharajan added a comment.

Move subsitution outside regex


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134034

Files:
  clang/test/Format/style-on-command-line.cpp
  llvm/test/tools/llvm-dis/errors.test
  llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
  llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
  llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test


Index: llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
===
--- llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
+++ llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
@@ -1,3 +1,3 @@
-; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck 
%s
+; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck 
-DMSG=%errc_ENOENT %s
 
-; CHECK: error: {{.*}}v4.tbd' {{[Nn]}}o such file or directory
+; CHECK: error: {{.*}}v4.tbd' [[MSG]]
Index: llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
===
--- llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
+++ llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
@@ -1,4 +1,4 @@
 # REQUIRES: amdgpu-registered-target
-# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg 
%s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck 
-check-prefix=ERR %s
+# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg 
%s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck 
-DMSG=%errc_ENOENT -check-prefix=ERR %s
 
-# ERR: {{.*}}llvm-reduce{{.*}}: {{[Nn]}}o such file or directory
+# ERR: {{.*}}llvm-reduce{{.*}}: [[MSG]]
Index: llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
===
--- llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
+++ llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
@@ -3,11 +3,11 @@
 RUN: cd %t
 RUN: cp %p/../Inputs/dwos_list_from_exec/b.dwo b.dwo
 RUN: cp %p/../Inputs/dwos_list_from_exec/main main
-RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-BIN
-RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-1ST-DWO
+RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT 
%s --check-prefix=CHECK-BIN
+RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=CHECK-1ST-DWO
 RUN: cp %p/../Inputs/dwos_list_from_exec/a.dwo a.dwo
 RUN: rm b.dwo
-RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-2ND-DWO
+RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=CHECK-2ND-DWO
 
 Build commands for the test binaries:
 
@@ -23,6 +23,6 @@
  return 0;
   }
 
-CHECK-BIN: error: 'binary': {{[Nn]}}o such file or directory
-CHECK-1ST-DWO: error: './a.dwo': {{[Nn]}}o such file or directory
-CHECK-2ND-DWO: error: './b.dwo': {{[Nn]}}o such file or directory
+CHECK-BIN: error: 'binary': [[MSG]]
+CHECK-1ST-DWO: error: './a.dwo': [[MSG]]
+CHECK-2ND-DWO: error: './b.dwo': [[MSG]]
Index: llvm/test/tools/llvm-dis/errors.test
===
--- llvm/test/tools/llvm-dis/errors.test
+++ llvm/test/tools/llvm-dis/errors.test
@@ -1,3 +1,3 @@
-# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck %s 
--check-prefix=MISSING --ignore-case
+# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=MISSING --ignore-case
 
-# MISSING: error: missing-file-path: no such file or directory
+# MISSING: error: missing-file-path: [[MSG]]
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
@@ -6,7 +6,7 @@
 // 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
 // RUN: printf "Invalid:\n" > %t/.clang-format
-// RUN: not clang-format -style=file -fallback-style=webkit 
-assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK6 %s
+// RUN: not clang-format -style=file -fallback-style=webkit 
-assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -DMSG=%errc_EINVAL 
-strict-whitespace -check-prefix=CHECK6 %s
 // RUN: rm %t/.clang-format
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %t/_clang-format
 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck 
-strict-whitespace -check-prefix=CHECK7 %s
@@ -35,7 +35,7 @@
 // CHECK4: Error parsing -style: [[MSG]]
 // CHECK5: {{^ int\* i;$}}
 // CHECK6: 

[PATCH] D134034: [test] Use host platform specific error message substitution

2022-09-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 460761.
abhina.sreeskantharajan added a comment.
Herald added subscribers: cfe-commits, ormris.
Herald added a project: clang.

Add some more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134034

Files:
  clang/test/Format/style-on-command-line.cpp
  llvm/test/tools/llvm-dis/errors.test
  llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
  llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
  llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test


Index: llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
===
--- llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
+++ llvm/test/tools/llvm-tapi-diff/misspelled-tbd.test
@@ -1,3 +1,3 @@
-; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck 
%s
+; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck 
-DMSG=%errc_ENOENT %s
 
-; CHECK: error: {{.*}}v4.tbd' {{[Nn]}}o such file or directory
+; CHECK: error: {{.*}}v4.tbd' [[MSG]]
Index: llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
===
--- llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
+++ llvm/test/tools/llvm-reduce/mir/input-file-does-not-exist.mir
@@ -1,4 +1,4 @@
 # REQUIRES: amdgpu-registered-target
-# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg 
%s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck 
-check-prefix=ERR %s
+# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg 
%s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck 
-DMSG=%errc_ENOENT -check-prefix=ERR %s
 
-# ERR: {{.*}}llvm-reduce{{.*}}: {{[Nn]}}o such file or directory
+# ERR: {{.*}}llvm-reduce{{.*}}: [[MSG]]
Index: llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
===
--- llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
+++ llvm/test/tools/llvm-dwp/X86/diagnose_missing_dwos.test
@@ -3,11 +3,11 @@
 RUN: cd %t
 RUN: cp %p/../Inputs/dwos_list_from_exec/b.dwo b.dwo
 RUN: cp %p/../Inputs/dwos_list_from_exec/main main
-RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-BIN
-RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-1ST-DWO
+RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT 
%s --check-prefix=CHECK-BIN
+RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=CHECK-1ST-DWO
 RUN: cp %p/../Inputs/dwos_list_from_exec/a.dwo a.dwo
 RUN: rm b.dwo
-RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=CHECK-2ND-DWO
+RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=CHECK-2ND-DWO
 
 Build commands for the test binaries:
 
@@ -23,6 +23,6 @@
  return 0;
   }
 
-CHECK-BIN: error: 'binary': {{[Nn]}}o such file or directory
-CHECK-1ST-DWO: error: './a.dwo': {{[Nn]}}o such file or directory
-CHECK-2ND-DWO: error: './b.dwo': {{[Nn]}}o such file or directory
+CHECK-BIN: error: 'binary': [[MSG]]
+CHECK-1ST-DWO: error: './a.dwo': [[MSG]]
+CHECK-2ND-DWO: error: './b.dwo': [[MSG]]
Index: llvm/test/tools/llvm-dis/errors.test
===
--- llvm/test/tools/llvm-dis/errors.test
+++ llvm/test/tools/llvm-dis/errors.test
@@ -1,3 +1,3 @@
-# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck %s 
--check-prefix=MISSING --ignore-case
+# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck -DMSG=%errc_ENOENT %s 
--check-prefix=MISSING --ignore-case
 
-# MISSING: error: missing-file-path: no such file or directory
+# MISSING: error: missing-file-path: [[MSG]]
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
@@ -6,7 +6,7 @@
 // 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
 // RUN: printf "Invalid:\n" > %t/.clang-format
-// RUN: not clang-format -style=file -fallback-style=webkit 
-assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK6 %s
+// RUN: not clang-format -style=file -fallback-style=webkit 
-assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -DMSG=%errc_EINVAL 
-strict-whitespace -check-prefix=CHECK6 %s
 // RUN: rm %t/.clang-format
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %t/_clang-format
 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck 
-strict-whitespace -check-prefix=CHECK7 %s
@@ -35,7 +35,7 @@
 // CHECK4: Error 

[PATCH] D127498: [SystemZ/z/OS] Set DWARF version to 4 for z/OS.

2022-06-10 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/D127498/new/

https://reviews.llvm.org/D127498

___
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] 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] 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] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-07 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/D109362/new/

https://reviews.llvm.org/D109362

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


[PATCH] D108998: [SystemZ][z/OS] Create html report file with text flag

2021-08-31 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/D108998/new/

https://reviews.llvm.org/D108998

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


[PATCH] D108819: [MCParser][z/OS] Mark test as unsupported for the z/OS Target

2021-08-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/D108819/new/

https://reviews.llvm.org/D108819

___
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] 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] 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] 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 , unsigned Mode) {
+Expected TempFile::create(const Twine , 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 ,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &);
   TempFile =(TempFile &);
 
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 ) -> 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 , unsigned Mode) {
+Expected TempFile::create(const Twine , 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 ,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &);
   TempFile =(TempFile &);
 
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 ) -> 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-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 , unsigned Mode) {
+Expected TempFile::create(const Twine , 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 ,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &);
   TempFile =(TempFile &);
 
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 ) -> 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 , unsigned Mode) {
+Expected TempFile::create(const Twine , 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 ,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags ExtraFlags = OF_None);
   TempFile(TempFile &);
   TempFile =(TempFile &);
 
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 ) -> 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-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 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 , unsigned Mode) {
+Expected TempFile::create(const Twine , 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 ,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags Flags = OF_Delete);
   TempFile(TempFile &);
   TempFile =(TempFile &);
 
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 ) -> 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 , unsigned Mode) {
+Expected TempFile::create(const Twine , 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 ,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags Flags = OF_Delete);
   TempFile(TempFile &);
   TempFile =(TempFile &);
 
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 ) -> llvm::Error {
___
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] D100872: Use OpenFlags instead of boolean to set a file as text/binary

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



Comment at: clang/include/clang/Frontend/CompilerInstance.h:738-740
+  createOutputFileImpl(StringRef OutputPath, llvm::sys::fs::OpenFlags Flags,
bool RemoveFileOnSignal, bool UseTemporary,
bool CreateMissingDirectories);

dexonsmith wrote:
> abhina.sreeskantharajan wrote:
> > rnk wrote:
> > > I think this is only going to be worth it if we can roll up all of these 
> > > booleans into a new flags enum for compiler instance. It also prevents 
> > > introducing a new use of FileSystem.h, which is an expensive header to 
> > > include.
> > Sorry, I don't think I completely understand your suggestion. Are you 
> > proposing that we create a new enum just for CompilerInstance.h for the 
> > other booleans like RemoveFileOnSignal, UseTemporary, 
> > CreateMissingDirectories? And this new enum also contain text/binary flags 
> > so we don't need to use the enum in FileSystem.h? 
> > 
> > For background, I need this specific change to set some more text files 
> > with OF_Text because my old commit got reverted since it caused CRLF issues 
> > on Windows https://reviews.llvm.org/D96363.
> > 
> Yes, I think that's what @rnk is suggesting, maybe along the lines of the 
> OutputConfigFlag in the (languishing, I need to get back to it) 
> OutputBackend/OutputManager proposal I have (see, e.g., 
> https://reviews.llvm.org/D95501, which needs to be split up), or maybe as a 
> struct with named members as @sammccall suggests there.
> 
> > It also prevents introducing a new use of FileSystem.h, which is an 
> > expensive header to include.
> Another option that'd be more isolated would be to split the OpenFlag enum 
> (and/or its friends) out to another header in 
> llvm/include/llvm/Support/FileSystem/ (say, 
> .../FileSystem/FileSystemEnums.h), like was done for UniqueID.h.
Thanks for clarifying. I think having a duplicate copy of the OpenFlags may be 
confusing. I like the idea of putting the enums in its own header file. But can 
that be done in a separate change than this patch? It will be a much larger 
change touching more files than this patcch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100872

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


[PATCH] D100872: Use OpenFlags instead of boolean to set a file as text/binary

2021-04-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100872

___
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-04-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D93031#2706660 , @cor3ntin wrote:

>>> 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.
>
> The operation is destructive and therefore cannot be reverted.
> So I do believe the correct behavior here would indeed be to keep the 
> original spelling around - with *some* of phase 5 applied (replacement of 
> UCNs and replacement of numeric escape sequences).
> An alternative would be to do the conversion lazily when the strings are 
> evaluated, rather than during lexing, although that might be more involved

Thanks for the input! I agree doing the conversion lazily will help avoid 
hitting these issues since we push translation to a later stage but as you 
mentioned it will be more involved. I think keeping the original spelling might 
be the best solution. We can make a extra member in StringLiteralParser to save 
the string prior to translation. But we would need to go through each use of 
StringLiteralParser and save the original encoding (possibly print it in the 
.ll file along with the translated string or as an attribute?). Let me know 
what you think.


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-04-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 339355.
abhina.sreeskantharajan added a reviewer: ThePhD.
abhina.sreeskantharajan added a comment.

Thanks for catching that. This sets the   __clang_literal_encoding__ to 
Opts.ExecCharset or defaults to SystemCharset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

Files:
  clang/docs/LanguageExtensions.rst
  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/Frontend/InitPreprocessor.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
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-x86.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
@@ -1046,6 +1046,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 ) {
   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
@@ -397,6 +397,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/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1306,7 +1306,7 @@
 // X86_64-CLOUDABI:#define __amd64 1
 // X86_64-CLOUDABI:#define __amd64__ 1
 // X86_64-CLOUDABI:#define __clang__ 1
-// X86_64-CLOUDABI:#define __clang_literal_encoding__ {{.*}}
+// X86_64-CLOUDABI:#define __clang_literal_encoding__ UTF-8
 // X86_64-CLOUDABI:#define __clang_major__ {{.*}}
 // X86_64-CLOUDABI:#define __clang_minor__ {{.*}}
 // X86_64-CLOUDABI:#define __clang_patchlevel__ {{.*}}
Index: clang/test/Preprocessor/init-s390x.c
===
--- clang/test/Preprocessor/init-s390x.c
+++ clang/test/Preprocessor/init-s390x.c
@@ -202,4 +202,5 @@
 // S390X-ZOS:   #define __TOS_390__ 1
 // S390X-ZOS:   #define __TOS_MVS__ 1
 // S390X-ZOS:   #define __XPLINK__ 1
+// S390X-ZOS:   #define __clang_literal_encoding__ IBM-1047
 // S390X-ZOS-GNUXX: #define __wchar_t 1
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -222,8 +222,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\
@@ -237,7 +243,7 @@
 // RUN: -fident -fno-ident\
 // RUN: -fimplicit-templates -fno-implicit-templates  \
 // RUN: -finput-charset=UTF-8 

[PATCH] D100872: Use OpenFlags instead of boolean to set a file as text/binary

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



Comment at: clang/include/clang/Frontend/CompilerInstance.h:738-740
+  createOutputFileImpl(StringRef OutputPath, llvm::sys::fs::OpenFlags Flags,
bool RemoveFileOnSignal, bool UseTemporary,
bool CreateMissingDirectories);

rnk wrote:
> I think this is only going to be worth it if we can roll up all of these 
> booleans into a new flags enum for compiler instance. It also prevents 
> introducing a new use of FileSystem.h, which is an expensive header to 
> include.
Sorry, I don't think I completely understand your suggestion. Are you proposing 
that we create a new enum just for CompilerInstance.h for the other booleans 
like RemoveFileOnSignal, UseTemporary, CreateMissingDirectories? And this new 
enum also contain text/binary flags so we don't need to use the enum in 
FileSystem.h? 

For background, I need this specific change to set some more text files with 
OF_Text because my old commit got reverted since it caused CRLF issues on 
Windows https://reviews.llvm.org/D96363.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100872

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


[PATCH] D100872: Use OpenFlags instead of boolean to set a file as text/binary

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

This patch updates the functions createDefaultOutputFile, createOutputFile, 
createOutputFileImpl to use OpenFlags instead of a boolean binary flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100872

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -254,9 +254,10 @@
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
 llvm::sys::path::replace_extension(Path, "json");
-if (auto profilerOutput = Clang->createOutputFile(
-Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
-/*useTemporary=*/false)) {
+if (auto profilerOutput =
+Clang->createOutputFile(Path.str(), llvm::sys::fs::OF_TextWithCRLF,
+/*RemoveFileOnSignal=*/false,
+/*useTemporary=*/false)) {
   llvm::timeTraceProfilerWrite(*profilerOutput);
   // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
   profilerOutput->flush();
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -40,7 +40,7 @@
 std::unique_ptr
 HTMLPrintAction::CreateASTConsumer(CompilerInstance , StringRef InFile) {
   if (std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, InFile))
+  CI.createDefaultOutputFile(llvm::sys::fs::OF_TextWithCRLF, InFile))
 return CreateHTMLPrinter(std::move(OS), CI.getPreprocessor());
   return nullptr;
 }
@@ -162,8 +162,8 @@
 
 std::unique_ptr
 RewriteObjCAction::CreateASTConsumer(CompilerInstance , StringRef InFile) {
-  if (std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, InFile, "cpp")) {
+  if (std::unique_ptr OS = CI.createDefaultOutputFile(
+  llvm::sys::fs::OF_TextWithCRLF, InFile, "cpp")) {
 if (CI.getLangOpts().ObjCRuntime.isNonFragile())
   return CreateModernObjCRewriter(
   std::string(InFile), std::move(OS), CI.getDiagnostics(),
@@ -184,8 +184,8 @@
 
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
-  std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
+  std::unique_ptr OS = CI.createDefaultOutputFile(
+  llvm::sys::fs::OF_None, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -193,8 +193,8 @@
 
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
-  std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
+  std::unique_ptr OS = CI.createDefaultOutputFile(
+  llvm::sys::fs::OF_TextWithCRLF, getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -269,8 +269,8 @@
 
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
-OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
+OutputStream = CI.createDefaultOutputFile(llvm::sys::fs::OF_None,
+  getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -266,7 +266,8 @@
 v.TraverseDecl(context.getTranslationUnitDecl());
 
 MangledSymbols Symbols;
-auto OS = Instance.createDefaultOutputFile(/*Binary=*/false, InFile, "ifs");
+auto OS = Instance.createDefaultOutputFile(llvm::sys::fs::OF_TextWithCRLF,
+   InFile, "ifs");
 if (!OS)
   return;
 
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -69,7 +69,7 @@
 std::unique_ptr
 ASTPrintAction::CreateASTConsumer(CompilerInstance , StringRef InFile) {
   if (std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, InFile))
+  

[PATCH] D93031: Enable fexec-charset option

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

Rebase + set size of char as 1 when creating a StringRef to fix lit failure


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
@@ -1046,6 +1046,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 ) {
   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
@@ -397,6 +397,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
@@ -222,8 +222,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\
@@ -237,7 +243,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
@@ -210,10 +210,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 

[PATCH] D100654: [SystemZ][z/OS] Set more text files as text

2021-04-19 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05b4babc9d85: [SystemZ][z/OS] Set more text files as text 
(authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100654

Files:
  clang/tools/driver/cc1gen_reproducer_main.cpp
  clang/tools/libclang/CIndexer.cpp
  llvm/include/llvm/Support/GraphWriter.h


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100056: [SystemZ][z/OS] Set files in FileRemapper.cpp are text

2021-04-19 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfbc325934661: [SystemZ][z/OS] Set files in FileRemapper.cpp 
are text (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100056

Files:
  clang/lib/ARCMigrate/FileRemapper.cpp


Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -63,7 +63,7 @@
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile);
+  llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
 
@@ -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);
 
@@ -142,9 +142,10 @@
 
   SmallString<64> tempPath;
   int fd;
-  if (fs::createTemporaryFile(path::filename(origFE->getName()),
-  
path::extension(origFE->getName()).drop_front(), fd,
-  tempPath))
+  if (fs::createTemporaryFile(
+  path::filename(origFE->getName()),
+  path::extension(origFE->getName()).drop_front(), fd, tempPath,
+  llvm::sys::fs::OF_Text))
 return report("Could not create file: " + tempPath.str(), Diag);
 
   llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);


Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -63,7 +63,7 @@
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile);
+  llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
 
@@ -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);
 
@@ -142,9 +142,10 @@
 
   SmallString<64> tempPath;
   int fd;
-  if (fs::createTemporaryFile(path::filename(origFE->getName()),
-  path::extension(origFE->getName()).drop_front(), fd,
-  tempPath))
+  if (fs::createTemporaryFile(
+  path::filename(origFE->getName()),
+  path::extension(origFE->getName()).drop_front(), fd, tempPath,
+  llvm::sys::fs::OF_Text))
 return report("Could not create file: " + tempPath.str(), Diag);
 
   llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100056: [SystemZ][z/OS] Set files in FileRemapper.cpp are text

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

fix formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100056

Files:
  clang/lib/ARCMigrate/FileRemapper.cpp


Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -63,7 +63,7 @@
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile);
+  llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
 
@@ -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);
 
@@ -142,9 +142,10 @@
 
   SmallString<64> tempPath;
   int fd;
-  if (fs::createTemporaryFile(path::filename(origFE->getName()),
-  
path::extension(origFE->getName()).drop_front(), fd,
-  tempPath))
+  if (fs::createTemporaryFile(
+  path::filename(origFE->getName()),
+  path::extension(origFE->getName()).drop_front(), fd, tempPath,
+  llvm::sys::fs::OF_Text))
 return report("Could not create file: " + tempPath.str(), Diag);
 
   llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);


Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -63,7 +63,7 @@
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile);
+  llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
 
@@ -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);
 
@@ -142,9 +142,10 @@
 
   SmallString<64> tempPath;
   int fd;
-  if (fs::createTemporaryFile(path::filename(origFE->getName()),
-  path::extension(origFE->getName()).drop_front(), fd,
-  tempPath))
+  if (fs::createTemporaryFile(
+  path::filename(origFE->getName()),
+  path::extension(origFE->getName()).drop_front(), fd, tempPath,
+  llvm::sys::fs::OF_Text))
 return report("Could not create file: " + tempPath.str(), Diag);
 
   llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100654: [SystemZ][z/OS] Set more text files as text

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

This patch corrects more instances of text files being opened as text.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100654

Files:
  clang/tools/driver/cc1gen_reproducer_main.cpp
  clang/tools/libclang/CIndexer.cpp
  llvm/include/llvm/Support/GraphWriter.h


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-16 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 rGe71994a239d5: [SystemZ][z/OS] Add IsText Argument to GetFile 
and GetFileOrSTDIN (authored by Jonathan.Crowther, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

Files:
  clang/tools/driver/cc1as_main.cpp
  llvm/lib/AsmParser/Parser.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/Testing/Support/SupportHelpers.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp

Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -343,7 +343,7 @@
   Triple TheTriple(TripleName);
 
   ErrorOr> BufferPtr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (std::error_code EC = BufferPtr.getError()) {
 WithColor::error(errs(), ProgName)
 << InputFilename << ": " << EC.message() << '\n';
Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -182,7 +182,7 @@
 static Expected> readInputFile(StringRef FilePath) {
   // Read in file.
   ErrorOr> BufOrError =
-  MemoryBuffer::getFileOrSTDIN(FilePath);
+  MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true);
   if (!BufOrError)
 return createStringError(BufOrError.getError(), "Could not open `%s`",
  FilePath.data());
Index: llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
===
--- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -334,7 +334,7 @@
 Expected
 InstructionBenchmark::readYaml(const LLVMState , StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 InstructionBenchmark Benchmark;
@@ -351,7 +351,7 @@
 Expected>
 InstructionBenchmark::readYamls(const LLVMState , StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 std::vector Benchmarks;
Index: llvm/lib/Testing/Support/SupportHelpers.cpp
===
--- llvm/lib/Testing/Support/SupportHelpers.cpp
+++ llvm/lib/Testing/Support/SupportHelpers.cpp
@@ -40,7 +40,7 @@
 
   EXPECT_TRUE(Found) << "Unit test source directory file does not exist.";
 
-  auto File = MemoryBuffer::getFile(InputFilePath);
+  auto File = MemoryBuffer::getFile(InputFilePath, /*IsText=*/true);
 
   EXPECT_TRUE(static_cast(File))
   << "Could not open unit test source directory file.";
Index: llvm/lib/ProfileData/SampleProfReader.cpp
===
--- llvm/lib/ProfileData/SampleProfReader.cpp
+++ llvm/lib/ProfileData/SampleProfReader.cpp
@@ -1575,7 +1575,7 @@
 /// \returns an error code indicating the status of the buffer.
 static ErrorOr>
 setupMemoryBuffer(const Twine ) {
-  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return EC;
   auto Buffer = std::move(BufferOrErr.get());
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -41,7 +41,7 @@
 static Expected>
 setupMemoryBuffer(const Twine ) {
   ErrorOr> BufferOrErr =
-  MemoryBuffer::getFileOrSTDIN(Path);
+  MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return errorCodeToError(EC);
   return std::move(BufferOrErr.get());
Index: llvm/lib/CodeGen/MIRParser/MIRParser.cpp
===
--- llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -984,7 +984,7 @@
 std::unique_ptr llvm::createMIRParserFromFile(
 StringRef Filename, SMDiagnostic , LLVMContext ,
 std::function ProcessIRFunction) {
-  auto FileOrErr = 

[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

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

In D100488#2692772 , @rnk wrote:

> In D100488#2689494 , @amccarth 
> wrote:
>
>> Personally, I'm not a fan of boolean function parameters because of the 
>> inline comments necessary to make the call site understandable.  But it 
>> appears to be consistent with LLVM Coding Standards and other APIs, so this 
>> looks right to me.
>
> I think it would be a reasonable follow-up change to turn these optional 
> boolean parameters into a flags enum.

That's a good idea. There hasn't been a usage of getFile or getFileOrSTDIN that 
wanted CRLF translation so far, but this may not be the case always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

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


[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-15 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/D100488/new/

https://reviews.llvm.org/D100488

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


[PATCH] D100197: Enable creation of large response file on z/OS

2021-04-12 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06c8b29d23ac: Enable creation of large response file on z/OS 
(authored by SeanP, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100197

Files:
  clang/test/Driver/Inputs/gen-response.c
  clang/test/Driver/response-file.c


Index: clang/test/Driver/response-file.c
===
--- clang/test/Driver/response-file.c
+++ clang/test/Driver/response-file.c
@@ -13,7 +13,7 @@
 // But there's no guarantee that we actually will (the system limit could be
 // *huge*), so just check that invoking cc1 succeeds under these conditions.
 //
-// RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
+// RUN: %python  -c 'print(*("-DTEST" for x in range(30)))' >%t.1.txt
 // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
 // LONG: extern int it_works;
 
Index: clang/test/Driver/Inputs/gen-response.c
===
--- clang/test/Driver/Inputs/gen-response.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define M -DTEST
-#define M1 M M M M M M M M M M
-#define M2 M1 M1 M1 M1 M1 M1 M1 M1 M1 M1
-#define M3 M2 M2 M2 M2 M2 M2 M2 M2 M2 M2
-#define M4 M3 M3 M3 M3 M3 M3 M3 M3 M3 M3
-#define M5 M4 M4 M4 M4 M4 M4 M4 M4 M4 M4
-#define TEXT M5 M5 M5
-TEXT


Index: clang/test/Driver/response-file.c
===
--- clang/test/Driver/response-file.c
+++ clang/test/Driver/response-file.c
@@ -13,7 +13,7 @@
 // But there's no guarantee that we actually will (the system limit could be
 // *huge*), so just check that invoking cc1 succeeds under these conditions.
 //
-// RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
+// RUN: %python  -c 'print(*("-DTEST" for x in range(30)))' >%t.1.txt
 // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
 // LONG: extern int it_works;
 
Index: clang/test/Driver/Inputs/gen-response.c
===
--- clang/test/Driver/Inputs/gen-response.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define M -DTEST
-#define M1 M M M M M M M M M M
-#define M2 M1 M1 M1 M1 M1 M1 M1 M1 M1 M1
-#define M3 M2 M2 M2 M2 M2 M2 M2 M2 M2 M2
-#define M4 M3 M3 M3 M3 M3 M3 M3 M3 M3 M3
-#define M5 M4 M4 M4 M4 M4 M4 M4 M4 M4 M4
-#define TEXT M5 M5 M5
-TEXT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100197: Enable creation of large response file on z/OS

2021-04-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/D100197/new/

https://reviews.llvm.org/D100197

___
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-04-09 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 336417.
abhina.sreeskantharajan added a comment.

Accidentally added dependent patch in this one. Removing that


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
@@ -1046,6 +1046,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 ) {
   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
@@ -397,6 +397,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
@@ -210,10 +210,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 

[PATCH] D93031: Enable fexec-charset option

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

Rebase + fix CharLiteralParser endian issue by saving the char to a char 
variable first and then creating a StringRef


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/cmake/config-ix.cmake
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Config/config.h.cmake
  llvm/include/llvm/Support/CharSet.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CharSet.cpp
  llvm/lib/Support/Triple.cpp
  llvm/unittests/Support/CMakeLists.txt
  llvm/unittests/Support/CharSetTest.cpp

Index: llvm/unittests/Support/CharSetTest.cpp
===
--- /dev/null
+++ llvm/unittests/Support/CharSetTest.cpp
@@ -0,0 +1,191 @@
+//===- unittests/Support/CharSetTest.cpp - Charset conversion tests ---===//
+//
+// 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 "llvm/Support/CharSet.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+using namespace llvm;
+
+namespace {
+
+// String "Hello World!"
+static const char HelloA[] =
+"\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x0a";
+static const char HelloE[] =
+"\xC8\x85\x93\x93\x96\x40\xE6\x96\x99\x93\x84\x5A\x15";
+
+// String "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+static const char ABCStrA[] =
+"\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52"
+"\x53\x54\x55\x56\x57\x58\x59\x5A\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A"
+"\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A";
+static const char ABCStrE[] =
+"\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9"
+"\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91"
+"\x92\x93\x94\x95\x96\x97\x98\x99\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9";
+
+// String "¡¢£AÄÅÆEÈÉÊaàáâãäeèéêë"
+static const char AccentUTF[] =
+"\xc2\xa1\xc2\xa2\xc2\xa3\x41\xc3\x84\xc3\x85\xc3\x86\x45\xc3\x88\xc3\x89"
+"\xc3\x8a\x61\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3\xc3\xa4\x65\xc3\xa8\xc3\xa9"
+"\xc3\xaa\xc3\xab";
+static const char AccentE[] = "\xaa\x4a\xb1\xc1\x63\x67\x9e\xc5\x74\x71\x72"
+  "\x81\x44\x45\x42\x46\x43\x85\x54\x51\x52\x53";
+
+TEST(CharSet, FromASCII) {
+  // Hello string.
+  StringRef Src(HelloA);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(
+  CharSetConverter::CS_LATIN1, CharSetConverter::CS_IBM1047);
+  std::error_code EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloE, static_cast(Dst).c_str());
+
+  // ABC string.
+  Src = ABCStrA;
+  Dst.clear();
+  EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrE, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, ToASCII) {
+  // Hello string.
+  StringRef Src(HelloE);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(CharSetConverter::CS_IBM1047,
+   CharSetConverter::CS_LATIN1);
+  std::error_code EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloA, static_cast(Dst).c_str());
+
+  // ABC string.
+  Src = ABCStrE;
+  Dst.clear();
+  EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrA, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, FromUTF8) {
+  // Hello string.
+  StringRef Src(HelloA);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(
+  CharSetConverter::CS_UTF8, CharSetConverter::CS_IBM1047);
+  std::error_code EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloE, static_cast(Dst).c_str());
+
+  // ABC string.
+  Src = ABCStrA;
+  Dst.clear();
+  EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrE, static_cast(Dst).c_str());
+
+  // Accent string.
+  Src = AccentUTF;
+  Dst.clear();
+  EC = Conv.convert(Src, Dst);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(AccentE, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, ToUTF8) {
+  // Hello string.
+  StringRef 

[PATCH] D100056: [SystemZ][z/OS] Set files in FileRemapper.cpp are text

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

This patch sets files in FileRemapper to open as text.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100056

Files:
  clang/lib/ARCMigrate/FileRemapper.cpp


Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -63,7 +63,7 @@
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile);
+  llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
 
@@ -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);
 
@@ -144,7 +144,7 @@
   int fd;
   if (fs::createTemporaryFile(path::filename(origFE->getName()),
   
path::extension(origFE->getName()).drop_front(), fd,
-  tempPath))
+  tempPath, llvm::sys::fs::OF_Text))
 return report("Could not create file: " + tempPath.str(), Diag);
 
   llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);


Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -63,7 +63,7 @@
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile);
+  llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
 
@@ -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);
 
@@ -144,7 +144,7 @@
   int fd;
   if (fs::createTemporaryFile(path::filename(origFE->getName()),
   path::extension(origFE->getName()).drop_front(), fd,
-  tempPath))
+  tempPath, llvm::sys::fs::OF_Text))
 return report("Could not create file: " + tempPath.str(), Diag);
 
   llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99973: [Windows] Add test coverage for line endings when rewriting includes

2021-04-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, thanks for adding a testcase!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99973

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D99426#2670552 , @yroux wrote:

> Hi,
>
> Sorry I'm bit lost in the various patches proposed to fix the issue 
> introduced by https://reviews.llvm.org/D97785 
> My understanding is that this is missing one to fix our Windows on ARM bots 
> (broken for more than 2 weeks now)
> So it'd be great to have it applied

I've committed this and it looks like the bot is back to green :) 
https://lab.llvm.org/buildbot/#/builders/65/builds/1400. Sorry for the delayed 
fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 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 rG82b3e28e836d: [SystemZ][z/OS][Windows] Add new 
OF_TextWithCRLF flag and use this flag instead… (authored by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+ 

[PATCH] D99837: [Windows] Turn off text mode correctly in Rewriter to stop CRLF translation

2021-04-06 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 rG23929af383f2: [Windows] Turn off text mode correctly in 
Rewriter to stop CRLF translation (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99837

Files:
  clang/lib/Frontend/Rewrite/FrontendActions.cpp


Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }


Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

Is there any more feedback on this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

In D99426#2666341 , @aganea wrote:

> In D99426#2666141 , 
> @abhina.sreeskantharajan wrote:
>
>> In D99426#2665361 , @aganea wrote:
>>
>>> I am still concerned by the fact that this patch doesn't fix the issue 
>>> mentionned in https://reviews.llvm.org/D96363#2650460
>>> Was the intention to fix that issue? Will the fix be done in a subsequent 
>>> patch?
>>
>> I was fairly confident that if https://reviews.llvm.org/D96363 was the patch 
>> that was causing the issue for you
>
> That is the case! I've confirmed that `git checkout 
> fdb640ea30d416368b76b68b106deda580c6aced~1 && ninja clang -C build` generates 
> a `clang-cl.exe` that works with my above test case. `git revert 
> fdb640ea30d416368b76b68b106deda580c6aced` locally over ToT fixes the issue.

After scratching my head, I realized that I accidentally changed another 
function to Binary in clang/lib/Frontend/Rewrite/FrontendActions.cpp so that 
change was never properly reverted. I fixed this in 
https://reviews.llvm.org/D99837. Hopefully, this will fix your issue. Apologies 
for the confusion on my side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99837: [Windows] Turn off text mode correctly in Rewriter to stop CRLF translation

2021-04-03 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added a reviewer: aganea.
abhina.sreeskantharajan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I incorrectly changed the RewriteTestAction::ExecuteAction's file to binary 
instead of the proper RewriteIncludesAction::BeginSourceFileAction in 
https://reviews.llvm.org/rGbc5d4bcc2deb71ab647270c9754a83484b3d6f87. In the 
original commit, I actually changed 
RewriteIncludesAction::BeginSourceFileAction in 
https://reviews.llvm.org/rGfdb640ea30d416368b76b68b106deda580c6aced. This 
should fix the issue @aganea is facing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99837

Files:
  clang/lib/Frontend/Rewrite/FrontendActions.cpp


Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }


Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 334941.
abhina.sreeskantharajan retitled this revision from "[Windows] Add new 
OF_TextWithCRLF flag and use this flag instead of OF_Text" to 
"[SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag 
instead of OF_Text".
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

Updated comments and assertion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags 

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

In D99426#2665361 , @aganea wrote:

> I am still concerned by the fact that this patch doesn't fix the issue 
> mentionned in https://reviews.llvm.org/D96363#2650460
> Was the intention to fix that issue? Will the fix be done in a subsequent 
> patch?

I was fairly confident that if https://reviews.llvm.org/D96363 was the patch 
that was causing the issue for you, then this patch would have fixed the 
problem. I've already reverted the change in 
clang/lib/Frontend/Rewrite/FrontendActions.cpp and you mentioned that reverting 
the change in clang/lib/Driver/Driver.cpp didn't resolve the issue either. This 
patch should turn off CRLF translation in the remaining 2 files modified in 
that patch (Driver.cpp and DwarfLinkerForBinary.cpp). Since this doesn't seem 
to fix your problem, I'll need to do further investigation into which patch 
actually does cause the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

In D99426#2664841 , @MaskRay wrote:

>   /// The file should be opened in text mode on platforms like z/OS that make
>   /// this distinction.
>   OF_Text = 1,
>   F_Text = 1, // For compatibility
>   
>   /// The file should use a carriage linefeed '\r\n'.
>   /// Only makes a difference on windows.
>   OF_CRLF = 2,
>   
>   /// The file should be opened in text mode and use a carriage linefeed 
> '\r\n'
>   /// on platforms that make this distinction.
>   OF_TextWithCRLF = OF_Text | OF_CRLF,
>
> `OF_TextWithCRLF` needs to say what platforms make a difference.
>
> Can you mention in the description for Windows and z/OS, how these flags make 
> a difference, and how developers should use these flags for portability?
> It's still a bit unclear to me.
>
> e.g. when I need to use `OF_CRLR` instead of `OF_Text`?

So developers should use either the OF_Text or OF_TextWithCRLF for text files 
and OF_None for binary files. If the developer doesn't want carriage returns on 
Windows, they should use OF_Text, if they do want carriage returns on Windows, 
they should use OF_TextWithCRLF.

So this is the behaviour per platform with my patch:

z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return

This is the old behaviour for comparison:
z/OS:
OF_None: open in binary mode
OF_Text: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with carriage return


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

Update comment in FileSystem.h for OF_TextWithCRLF


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+OutputAssembly ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None;
 Out.reset(new ToolOutputFile(OutputFilename, EC, Flags));
 

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

@MaskRay is there still any confusion about the problem this patch is trying to 
solve and concerns about the renaming?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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



Comment at: llvm/include/llvm/Support/FileSystem.h:757
+  /// OF_TextWithCRLF = OF_Text | OF_CRLF
+  OF_TextWithCRLF = 3,
+

amccarth wrote:
> Nit:  If it were me, I'd put the `OF_Text | OF_CRLF` directly in the code (in 
> place of the `3`) instead of in the comment.
Thanks, your solution will also prevent future errors if there is any 
renumbering


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

Specified z/OS in FileSystem.h comments, added an assertion in Window's Path.inc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+OutputAssembly ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None;
 Out.reset(new 

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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



Comment at: llvm/lib/Support/Windows/Path.inc:1086
 
-  if (Flags & OF_Text)
+  if (Flags & OF_CRLF)
 CrtOpenFlags |= _O_TEXT;

amccarth wrote:
> I assume it would be weird to set `OF_CRLF` without also setting `OF_Text`, 
> so this change seems right for correctness.  But maybe this Windows-only code 
> would better express the intent if it were written:
> 
> ```
> if (Flags & (OF_CRLF | OF_Text))
> ```
> 
> Another idea would be to assert if `OF_CRLF` is set but `OF_Text` is not.
> 
> Or maybe it's fine as it is.
I chose to create OF_CRLF flag because I only want Windows to turn on text mode 
for OF_TextWithCRLF and not OF_Text. 
This solution would return true even if Flags was just OF_Text. 
```
if (Flags & (OF_CRLF | OF_Text))
```

I think adding an assertion here would be a good idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

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

In D99363#2656913 , @aganea wrote:

> In D99363#2653476 , 
> @abhina.sreeskantharajan wrote:
>
>> There were a lot of similar patches so reverting all of them might be more 
>> work than isolating the change that caused it and reverting that. It seems 
>> that the patch you initially commented on did not contain the problematic 
>> change since reverting the change doesn't fix your issue. I created the 
>> following patch https://reviews.llvm.org/D99426 based on @rnk suggestion. I 
>> created a new flag for OF_TextWithCRLF on Windows and made sure my most 
>> recent text changes use the OF_Text flag while all other uses were changed 
>> to OF_TextWithCRLF. This should solve any CRLF issues that were introduced 
>> recently by my patches. If you have time, would you be able to test if that 
>> patch fixes your issue?
>
> I've applied https://reviews.llvm.org/D99426#2656738 over 
> rGc4d5b956170dd85941c1c2787abaa2e01575234c 
>  but I'm 
> still seeing the issue in https://reviews.llvm.org/D96363#2650460.

Ok, I missed the change in llvm/tools/dsymutil/DwarfLinkerForBinary.cpp.

In D99363#2656913 , @aganea wrote:

> In D99363#2653476 , 
> @abhina.sreeskantharajan wrote:
>
>> There were a lot of similar patches so reverting all of them might be more 
>> work than isolating the change that caused it and reverting that. It seems 
>> that the patch you initially commented on did not contain the problematic 
>> change since reverting the change doesn't fix your issue. I created the 
>> following patch https://reviews.llvm.org/D99426 based on @rnk suggestion. I 
>> created a new flag for OF_TextWithCRLF on Windows and made sure my most 
>> recent text changes use the OF_Text flag while all other uses were changed 
>> to OF_TextWithCRLF. This should solve any CRLF issues that were introduced 
>> recently by my patches. If you have time, would you be able to test if that 
>> patch fixes your issue?
>
> I've applied https://reviews.llvm.org/D99426#2656738 over 
> rGc4d5b956170dd85941c1c2787abaa2e01575234c 
>  but I'm 
> still seeing the issue in https://reviews.llvm.org/D96363#2650460.

Sorry, I realized the change for DwarfLinkerForBinary.cpp was missing. This was 
only other file from https://reviews.llvm.org/D96363 that was using 
OF_TextWithCRLF instead of OF_Text. Please let me know if this latest patch 
https://reviews.llvm.org/file/data/2jljo4tfl5aiisvwpzg2/PHID-FILE-egbpcbhz3t7b7a2tcjka/D99426.diff
 fixes your issue. If not, I will revert the remaining changes in my old commit 
to unblock you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99363

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-03-30 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 334110.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

Set OF_Text for llvm/tools/dsymutil/DwarfLinkerForBinary.cpp instead of 
OF_TextWithCRLF. This was also another file I recently changed to text from 
binary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : 

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-03-29 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 333965.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

mention OF_CRLF is Windows-only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+OutputAssembly ? 

[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

In D99426#2656582 , @MaskRay wrote:

> In D99426#2656217 , @rnk wrote:
>
>> In D99426#2653725 , @MaskRay wrote:
>>
>>> This touches a lot of files. I am a bit worried that it would not be easy 
>>> for a contributor to know OF_TextWithCRLF is needed to make SystemZ happy.
>>
>> Right, we need to separate text-ness for System/Z EBCDIC re-encoding from 
>> Windows CRLF translation. I think it's best to have a separate, positive 
>> CRLF bit, and to make that spelling longer than OF_Text. I think, in 
>> general, more problems are caused by extra unintended CRLF than by missing 
>> carriage returns.
>
> OK.
>
>> OF_CRLF which indicates that CRLF translation is used.
>> OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses 
>> CRLF translation.
>
> My confusion came from I do not know what "CRLF translation" in the 
> description refers to. So it seems like EBCDIC->ASCII translation for CRLF? I 
> thought it was related to Windows.
>
> The current comment in the source code should be clarified too:
>
>   /// The file should be opened with CRLF translation on platforms that
>   /// make this distinction.
>   OF_CRLF = 2,
>   OF_TextWithCRLF = 3,

Sorry for causing confusion. CRLF in text files is a Windows-only problem, it 
doesn't affect z/OS. On z/OS we only need text files to be marked accurately as 
text. I updated the description and comments in FileSystem.h to be more clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-03-29 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 333960.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

Rebase + I updated the comments in FileSystem.h to be a bit more descriptive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module ) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =

[PATCH] D99514: [NFC] clang-formatting zos-alignment.c

2021-03-29 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/D99514/new/

https://reviews.llvm.org/D99514

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


[PATCH] D99508: [SystemZ][z/OS] Add test of leading zero length bitfield in const/volatile struct

2021-03-29 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, have a small nit




Comment at: clang/test/CodeGen/SystemZ/zos-alignment.c:26
+  long:0;
+  short   a;
+} VS0;

nit: spacing is off


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99508

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

In D99426#2653949 , @MaskRay wrote:

> In D99426#2653869 , 
> @abhina.sreeskantharajan wrote:
>
>> In D99426#2653725 , @MaskRay wrote:
>>
>>> This touches a lot of files. I am a bit worried that it would not be easy 
>>> for a contributor to know OF_TextWithCRLF is needed to make SystemZ happy.
>>>
 On SystemZ we need to open text files in text mode,
>>>
>>> Why can't it be served without CRLF translation?
>>
>> So this is a quick summary of the problem we're facing: 
>> On SystemZ, we can accept both OF_Text or OF_TextWithCRLF, it makes no 
>> difference. However, there are many text files that are marked as 
>> binary/OF_None to suppress CRLF translation on Windows. (e.g. patches like 
>> this one 
>> https://reviews.llvm.org/rGe78a7a0ecddc747129512fabf4836e22d1805f00). On 
>> SystemZ we need the text files to be marked as text and have made patches in 
>> the past to do so (e.g. https://reviews.llvm.org/D67696). These efforts are 
>> conflicting with each other, so Reid suggested this solution where we create 
>> a new flag that will set text mode and turn on CRLF translation on Windows 
>> platform. Then we will be able to mark all remaining text files with OF_Text 
>> and not turn on CRLF translation for Windows.
>>
>> I agree this patch is touching a lot of files,  I can maybe do the opposite 
>> and create a flag called OF_TextWithoutCRLF. I'm open to any new solutions 
>> to this problem.
>
> Hmm. I am still confused after seeting 
> rGe78a7a0ecddc747129512fabf4836e22d1805f00 
>  (does 
> it imply that using OF_None on Windows is fine?)
> If `OF_None` is used on SystemZ, does that regress functionality?

On Windows, OF_None suppresses CRLF translation and OF_Text will allow CRLF 
translation. On SystemZ it does regress functionality by causing file encoding 
issues. z/OS uses a file's text/binary mode to determine whether to perform 
translation to the system encoding EBCDIC if needed. (On binary files, no 
translation should be performed)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

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

In D99426#2653725 , @MaskRay wrote:

> This touches a lot of files. I am a bit worried that it would not be easy for 
> a contributor to know OF_TextWithCRLF is needed to make SystemZ happy.
>
>> On SystemZ we need to open text files in text mode,
>
> Why can't it be served without CRLF translation?

So this is a quick summary of the problem we're facing: 
On SystemZ, we can accept both OF_Text or OF_TextWithCRLF, it makes no 
difference. However, there are many text files that are marked as 
binary/OF_None to suppress CRLF translation on Windows. (e.g. patches like this 
one https://reviews.llvm.org/rGe78a7a0ecddc747129512fabf4836e22d1805f00). On 
SystemZ we need the text files to be marked as text and have made patches in 
the past to do so (e.g. https://reviews.llvm.org/D67696). These efforts are 
conflicting with each other, so Reid suggested this solution where we create a 
new flag that will set text mode and turn on CRLF translation on Windows 
platform. Then we will be able to mark all remaining text files with OF_Text 
and not turn on CRLF translation for Windows.

I agree this patch is touching a lot of files,  I can maybe do the opposite and 
create a flag called OF_TextWithoutCRLF. I'm open to any new solutions to this 
problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

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

In D99363#2653201 , @aganea wrote:

> I'm just wondering if D96363  and all 
> attached subsequent patches shouldn't be reverted for now. This is a quite 
> trivial case uncovered by tests. On re-land, I would then add a test 
> validating the issue on Windows:
>
>   $ cat -A rewrite-includes-clang-cl.cpp
>   // REQUIRES: system-windows^M$
>   // RUN: %clang_cl /E -Xclang -frewrite-includes %s | %clang_cl /c /Tp -^M$
>   ^M$
>   int foo();^M$
>   int bar();^M$
>   #define HELLO \^M$
> foo(); \^M$
> bar();^M$
>   ^M$
>   int main() {^M$
> HELLO^M$
> return 0;^M$
>   }^M$

There were a lot of similar patches so reverting all of them might be more work 
than isolating the change that caused it and reverting that. It seems that the 
patch you initially commented on did not contain the problematic change since 
reverting the change doesn't fix your issue. I created the following patch 
https://reviews.llvm.org/D99426 based on @rnk suggestion. I created a new flag 
for OF_TextWithCRLF on Windows and made sure my most recent text changes use 
the OF_Text flag while all other uses were changed to OF_TextWithCRLF. This 
should solve any CRLF issues that were introduced recently by my patches. If 
you have time, would you be able to test if that patch fixes your issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99363

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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-03-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, wenlei, okura, kuter, cmtice, martong, 
steven_wu, gbedwell, hiraditya, qcolombet, MatzeB.
Herald added a reviewer: bollu.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: andreadb.
Herald added a reviewer: jhenderson.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, bbn, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added projects: clang, LLDB, LLVM, clang-tools-extra.

On SystemZ we need to open text files in text mode, but on Windows this may not 
be desirable if we want to suppress CRLF translation. This patch adds two new 
flags

- OF_CRLF which indicates that CRLF translation is used.
- OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses 
CRLF translation.

Major change in llvm/lib/Support/Windows/Path.inc to only set text mode if the 
OF_CRLF is set.

  if (Flags & OF_CRLF)
CrtOpenFlags |= _O_TEXT;




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ 

[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

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

In D99363#2652899 , @aganea wrote:

> Sorry, but after this patch, I still see the issue mentioned in 
> https://reviews.llvm.org/D96363#2650460
> @abhina.sreeskantharajan are you able to confirm the issue on your end?

I don't have a Windows machine to test on, but I assumed since the problem was 
in rewrite then this patch should have fixed it. Would you be able to confirm 
if reverting the change in clang/lib/Driver/Driver.cpp fixes the problem for 
you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99363

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


[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

2021-03-26 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc5d4bcc2deb: [Windows] Turn off text mode in TableGen and 
Rewriter to stop CRLF translation (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99363

Files:
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/lib/TableGen/Main.cpp


Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -138,7 +138,7 @@
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
 if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, /*IsText=*/true))
+MemoryBuffer::getFile(OutputFilename, /*IsText=*/false))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
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  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());


Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -138,7 +138,7 @@
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
 if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, /*IsText=*/true))
+MemoryBuffer::getFile(OutputFilename, /*IsText=*/false))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
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  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

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



Comment at: clang/lib/Frontend/Rewrite/FrontendActions.cpp:190
+  std::unique_ptr OS = CI.createDefaultOutputFile(
+  /*Binary=*/llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows(),
+  getCurrentFileOrBufferName());

rnk wrote:
> In the long run, we really don't want this "is windows" check here in the 
> caller. We really want a flag to push this logic down into the support 
> library. Since we already know where we are going, I think these are the 
> proper steps:
> - revert to green
> - add OF_TextWithCrLF, with the same behavior as OF_Text today
> - update all callers that used OF_Text before these System/Z patches to 
> OF_TextWithCrlf (NFC)
> - make OF_Text skip CRLF conversion on Windows (check for breakage)
> - start relanding OF_Text changes for System/Z again
> 
> Landing this patch as it is creates more code that we will have to edit and 
> refactor later back to just OF_Text.
Yes, this sounds like a good plan. It doesn't seem like z/OS and Windows can 
share the same OF_Text flag as I originally thought. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99363

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


[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

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

Revert changes that cause errors instead by turning on binary mode again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99363

Files:
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/lib/TableGen/Main.cpp


Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -138,7 +138,7 @@
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
 if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, /*IsText=*/true))
+MemoryBuffer::getFile(OutputFilename, /*IsText=*/false))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
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  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());


Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -138,7 +138,7 @@
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
 if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, /*IsText=*/true))
+MemoryBuffer::getFile(OutputFilename, /*IsText=*/false))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
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  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
___
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-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D97785#2651008 , @amccarth wrote:

> When changing an IO stream's mode from binary to text breaks only Windows, 
> it's likely due to the fact that Windows uses CR+LF as the newline indicator. 
>  Not only are the CRs sometimes unexpected, they can also throw off code that 
> tries to seek to a computed file position.

Yes, this is probably the cause. I created a patch to set Binary mode on 
Windows only https://reviews.llvm.org/D99363 which should workaround the issue 
and unblock the bot. I do plan to investigate a better fix.


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] D96363: Mark output as text if it is really text

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

In D96363#2651116 , @rnk wrote:

> In D96363#2650999 , 
> @abhina.sreeskantharajan wrote:
>
>> Right, adding a new flag like OF_TextNoCrlf is something I can look into as 
>> a solution. However, if Windows is always using binary mode and has no use 
>> for OF_Text flag, maybe I can globally set that mode similar to how I set it 
>> for ToolOutputFiles. I don't think any other platform is affected by the 
>> binary/text mode.
>
> I can't say for sure if we always want LF output on Windows, so I'm not sure 
> we should commit to that simplification. I think we usually want to avoid 
> CRLF when we are writing code-like output files, things like JSON, YAML, or 
> C++ .inc files, but we might want to retain CRLF when writing to things like 
> log files or IDEs. And even if we audit all current use cases, someone in the 
> future might want CRLF conversion. On the other hand, it does leave behind a 
> bit of a trap for developers, who will probably pick OF_Text before 
> OF_TextNoCrlf. Maybe OF_Text should not do the conversion, and a longer 
> OF_TextWithCrlf should enable CRLF conversion.

Ok, I've created a patch to workaround the errors 
https://reviews.llvm.org/D99363. But I do plan to investigate a better solution 
going forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

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


[PATCH] D99363: [Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

2021-03-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: rnk, amccarth, yroux, aganea.
Herald added a subscriber: hiraditya.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch should fix the errors shown on the Windows bots by turning off text 
mode. I plan to investigate a better fix but this should unblock the buildbots 
for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99363

Files:
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/lib/TableGen/Main.cpp


Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -17,6 +17,7 @@
 #include "llvm/TableGen/Main.h"
 #include "TGParser.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -90,10 +91,13 @@
 Records.startPhaseTiming();
 
   // Parse the input file.
+  // On Windows, set binary mode to turn off CRLF translation.
+  bool IsWindows = llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows();
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename,
+   IsWindows ? /*IsText=*/false : true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,8 +141,8 @@
 // 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, /*IsText=*/true))
+if (auto ExistingOrErr = MemoryBuffer::getFile(
+OutputFilename, IsWindows ? /*IsText=*/false : true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -24,6 +24,7 @@
 #include "clang/Serialization/ModuleFile.h"
 #include "clang/Serialization/ModuleManager.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -184,8 +185,10 @@
 
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
-  std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+  // On Windows, set binary mode to avoid CRLF translation.
+  std::unique_ptr OS = CI.createDefaultOutputFile(
+  /*Binary=*/llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows(),
+  getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -193,8 +196,10 @@
 
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
-  std::unique_ptr OS =
-  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
+  // On Windows, set binary mode to avoid CRLF translation.
+  std::unique_ptr OS = CI.createDefaultOutputFile(
+  /*Binary=*/llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows(),
+  getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());


Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -17,6 +17,7 @@
 #include "llvm/TableGen/Main.h"
 #include "TGParser.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -90,10 +91,13 @@
 Records.startPhaseTiming();
 
   // Parse the input file.
+  // On Windows, set binary mode to turn off CRLF translation.
+  bool IsWindows = llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows();
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename,
+   IsWindows ? /*IsText=*/false : true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,8 +141,8 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all 

  1   2   3   >