[flang-commits] [mlir] [libunwind] [clang-tools-extra] [lld] [lldb] [compiler-rt] [libcxxabi] [clang] [llvm] [libc] [flang] [libcxx] PR#72453 : Exceeding maximum file name length (PR #72654)

Shahid Iqbal via flang-commits flang-commits at lists.llvm.org
Fri Nov 17 06:46:32 PST 2023


https://github.com/shahidiqbal13 created https://github.com/llvm/llvm-project/pull/72654

This issue is raised by @DrTodd13

The code in include/llvm/Analysis/DOTGraphTraitsPass.h will exceed most normal file system's maximum filename length of 255 if, e.g., the function's name is that length.

>From b6bfb18e25c111baf6c95a0a4a1c3d667bb25b6d Mon Sep 17 00:00:00 2001
From: Shahid Iqbal <shahidiqbal13 at gmail.com>
Date: Thu, 16 Nov 2023 11:26:43 -0500
Subject: [PATCH 1/2] TESTING infra

---
 clang/NOTES.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/NOTES.txt b/clang/NOTES.txt
index f06ea8c70cd3409..c83dda52a1fc21e 100644
--- a/clang/NOTES.txt
+++ b/clang/NOTES.txt
@@ -4,6 +4,8 @@
 
 //===---------------------------------------------------------------------===//
 
+//TESTING git infra//
+
 To time GCC preprocessing speed without output, use:
    "time gcc -MM file"
 This is similar to -Eonly.

>From 7662d4f177d32c3159c1c48b11ce3884e4ea78c8 Mon Sep 17 00:00:00 2001
From: Shahid Iqbal <shahidiqbal13 at gmail.com>
Date: Fri, 17 Nov 2023 09:26:31 -0500
Subject: [PATCH 2/2] PR#72453 : Exceeding maximum file name length

---
 llvm/include/llvm/Analysis/DOTGraphTraitsPass.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
index 07c08bc1cc3bcb6..f78d8ff52ee3932 100644
--- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
+++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
@@ -17,6 +17,8 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/GraphWriter.h"
 
+#define MAX_FILENAME_LEN 255
+
 namespace llvm {
 
 /// Default traits class for extracting a graph from an analysis pass.
@@ -94,7 +96,7 @@ void printGraphForFunction(Function &F, GraphT Graph, StringRef Name,
   raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF);
   std::string GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
 
-  if (!EC)
+  if (!EC && (Filename.length() <= MAX_FILENAME_LEN ))
     WriteGraph(File, Graph, IsSimple,
                GraphName + " for '" + F.getName() + "' function");
   else
@@ -280,7 +282,7 @@ class DOTGraphTraitsModulePrinterWrapperPass : public ModulePass {
     raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF);
     std::string Title = DOTGraphTraits<GraphT>::getGraphName(Graph);
 
-    if (!EC)
+    if (!EC && (Filename.length() <= MAX_FILENAME_LEN ))
       WriteGraph(File, Graph, IsSimple, Title);
     else
       errs() << "  error opening file for writing!";
@@ -310,7 +312,7 @@ void WriteDOTGraphToFile(Function &F, GraphT &&Graph,
   std::string GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
   std::string Title = GraphName + " for '" + F.getName().str() + "' function";
 
-  if (!EC)
+  if (!EC && (Filename.length() <= MAX_FILENAME_LEN ))
     WriteGraph(File, Graph, IsSimple, Title);
   else
     errs() << "  error opening file for writing!";



More information about the flang-commits mailing list