-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LLVM 4.0] Fix CreateCompileUnit #39747
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
cc #37609 |
@@ -1334,8 +1334,7 @@ extern "C" { | |||
|
|||
pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef, | |||
Lang: c_uint, | |||
File: *const c_char, | |||
Dir: *const c_char, | |||
File: DIFile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really nice!
let work_dir = path2cstr(&work_dir); | ||
let producer = CString::new(producer).unwrap(); | ||
let work_dir = path2cstr(&work_dir).as_ptr(); | ||
let producer = CString::new(producer).unwrap().as_ptr(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is wrong: it will drop the CString
and keep a raw pointer to its now-freed buffer around.
(The line above may have the same problem depending on what path2cstr
returns.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was wondering why the .as_ptr()
calls didn't match the line above.
@bors: r+ |
📌 Commit aebce5b has been approved by |
⌛ Testing commit aebce5b with merge ba7cf7c... |
…chton [LLVM 4.0] Fix CreateCompileUnit This is largely identical to @dylanmckay's [patch](https://github.com/dylanmckay), except that it doesn't try to use `file_metadata()`. I don't think that is necessary because we don't want the compile unit to be added to `debug_context.created_files`, though I'd like confirmation from someone who knows for sure. If that is needed, I can modify `file_metadata_()` so that it can be used from `compile_unit_metadata()`.
☀️ Test successful - status-appveyor, status-travis |
This is largely identical to @dylanmckay's patch, except that it doesn't try to use
file_metadata()
. I don't think that is necessary because we don't want the compile unit to be added todebug_context.created_files
, though I'd like confirmation from someone who knows for sure. If that is needed, I can modifyfile_metadata_()
so that it can be used fromcompile_unit_metadata()
.