diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-06-25 12:14:22 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-06-25 12:14:22 +0200 |
commit | cfaa38627b3d315d47ddad295962fe0c92d74b84 (patch) | |
tree | e80dd9650b1e6a45b5029d8fdf9a956760d78934 | |
parent | 2e3b0deae9e367e4fb35982981ae18c54235260a (diff) | |
download | blog-cfaa38627b3d315d47ddad295962fe0c92d74b84.tar.gz blog-cfaa38627b3d315d47ddad295962fe0c92d74b84.zip |
clang: enhance comment for EmitLLVMOnlyAction
-rw-r--r-- | content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc b/content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc index a2055e4..3c251b6 100644 --- a/content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc +++ b/content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc @@ -81,6 +81,13 @@ int main() { cc.getPreprocessorOpts().addRemappedFile(code_fname, code_buffer.release()); // Create action to generate LLVM IR. + // + // If created with default arguments, the EmitLLVMOnlyAction will allocate + // an owned LLVMContext and free it once the action goes out of scope. + // + // To keep the context after the action goes out of scope, either pass a + // LLVMContext (borrowed) when creating the EmitLLVMOnlyAction or call + // takeLLVMContext() to move ownership out of the action. EmitLLVMOnlyAction action; // Run action against our compiler instance. if (!cc.ExecuteAction(action)) { |