Skip to content

Commit

Permalink
[Graph Writer] Limit the length of the graph name because Windows can…
Browse files Browse the repository at this point in the history
…'t handle it.

Windows can't handle paths longer than 260 code points without \\?\. Even
with \\?\ it can't handle path components longer than 255 code points. So
limit graph names to the arbitrary length of 140. Random characters are still
added to the end, so it's ok if graph names collide.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209483 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Bigcheese committed May 22, 2014
1 parent ef518f1 commit c86ebbd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/llvm/Support/GraphWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ template <typename GraphType>
std::string WriteGraph(const GraphType &G, const Twine &Name,
bool ShortNames = false, const Twine &Title = "") {
int FD;
std::string Filename = createGraphFilename(Name, FD);
// Windows can't always handle long paths, so limit the length of the name.
std::string N = Name.str();
N = N.substr(0, std::min<std::size_t>(N.size(), 140));
std::string Filename = createGraphFilename(N, FD);
raw_fd_ostream O(FD, /*shouldClose=*/ true);

if (FD == -1) {
Expand Down

0 comments on commit c86ebbd

Please sign in to comment.