================ @@ -4049,5 +4050,13 @@ void Preprocessor::HandleEmbedDirective(SourceLocation HashLoc, Token &EmbedTok, if (Callbacks) Callbacks->EmbedDirective(HashLoc, Filename, isAngled, MaybeFileRef, *Params); - HandleEmbedDirectiveImpl(HashLoc, *Params, BinaryContents); + // getSpelling may return a string that is actually longer than + // FilenameTok.getLength(), so get the string of real length in ---------------- AaronBallman wrote:
Checking to see if I understand the comment (and if I do, maybe the comment can be updated to be more clear): the issue is that `getSpelling()` may return a buffer from the token itself or it may use the `SmallString` buffer we provided. If it uses the buffer, that buffer's lifetime ends at the end of this function, and we need the file name information to live far longer than that, which is why we effectively are doing a `strdup` here. Is that about right? https://github.com/llvm/llvm-project/pull/135957 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits