cor3ntin added a comment. > In terms of the encoding question I was asking, that's information we'll have > to figure out (CC @tahonermann and @cor3ntin for text encoding question). My > guess (which needs verification) is that we convert the file name from the > system encoding to UTF-8 internally, and this builtin will likely return > UTF-8 as a result. If that's correct, I think that behavior is reasonable, > but I've CCed some experts who can tell me all the things I forgot to > consider.
These things are bag of bytes - we likely can't promise _anything_ because there is no requirements of filenames to be encodable in _any_ encoding on some systems. In practice we can assume it's UTF-8 everywhere and convert to UTF-8 on windows because that's the only string literal encoding clang supports for now. If we did support other literal encodings, we would need to answer that question. IE, we could try to convert, but the conversion might not work. ================ Comment at: clang/include/clang/Lex/Preprocessor.h:2859 + template <unsigned InternalLen> + static void processPathToFilename(SmallString<InternalLen> &FileName, + const PresumedLoc &PLoc, ---------------- `processPathToFileName` would be better for consistency ================ Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1993-1994 + +template <unsigned InternalLen> +void Preprocessor::processPathToFilename(SmallString<InternalLen> &FileName, + const PresumedLoc &PLoc, ---------------- we probably want to pass a `SmallVectorImpl<char>` here, instead of a `SmallString`, to avoid making that function a template (look at `processPathForFileMacro` definition for example) ================ Comment at: clang/lib/Lex/PPMacroExpansion.cpp:2000-2001 + // presumed location. + StringRef PLFileName = llvm::sys::path::filename(PLoc.getFilename()); + if (PLFileName != "") + FileName += PLFileName; ---------------- CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144878/new/ https://reviews.llvm.org/D144878 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits