From: Kristina Brooks Date: Thu, 16 May 2019 02:46:12 +0000 (+0000) Subject: Fix assumption about Win32 paths in r360833 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c81e2857a67a56294c28f17abddb4cff9e3c8a43;p=clang Fix assumption about Win32 paths in r360833 Attempt to fix Windows buildbots due to differences in path handling (caused by r360833). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360839 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 148fc67c43..bc25dcd8ea 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -1501,8 +1501,14 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { // the last part of __FILE__. if (II == Ident__FILE_NAME__) { // Try to get the last path component. - StringRef PLFileName = PLoc.getFilename(); - size_t LastSep = PLFileName.find_last_of('/'); + StringRef PLFileName = PLoc.getFilename(); + size_t LastSep = PLFileName.find_last_of('/'); +#ifdef _WIN32 + // On Windows targets, absolute paths can be normalized to use + // backslashes instead - handle this potential case here. + if (LastSep == StringRef::npos) + LastSep = PLFileName.find_last_of('\\'); +#endif // Skip the separator and get the last part, otherwise fall back on // returning the original full filename. if (LastSep != StringRef::npos)