-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ClangImporter: Take ownership of clang::TargetOptions
used for code generation
#82912
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
Conversation
@swift-ci please smoke test |
preset=buildbot_incremental,tools=RA,stdlib=RA @swift-ci please test with preset macOS |
clang::MacroBuilder builder(predefines); | ||
targetInfo->getTargetDefines(Instance->getLangOpts(), builder); | ||
} else { | ||
targetInfo = |
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.
Is my understanding right that TargetOpts
remains nullptr
when we use the existing invocation? I wonder if this can get a bit confusing that we don't have one unique way to refer to TargetOpts
regardless of which path we took.
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.
Yes, correct. That’s pretty much why I didn’t add a getter for TargetOpts
. It’s just there to keep the options alive for as long as CodeGenTargetInfo
when they differ from the importer invocation’s. You’re still supposed to access them through the invocation or getCodeGenTargetInfo
, depending on which you want.
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.
Added a doc comment to TargetOpts
.
generation Since llvm/llvm-project#106271, `clang::TargetInfo` does not co-own target options, so there is no longer anything to keep them alive after we discard the throwaway Clang invocation they originate from. Make the importer take ownership of a copy of code generation target options to avoid a use after free.
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.
Thank you.
Targeted test failures gone; merging. |
Since llvm/llvm-project#106271,
clang::TargetInfo
does not co-own target options, so there is no longer anything to keep them alive after we discard the throwaway Clang invocation they originate from. Make the importer take ownership of a copy of code generation target options to avoid a use after free.