aboutsummaryrefslogtreecommitdiffhomepage
path: root/content
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-06-25 12:14:22 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-06-25 12:14:22 +0200
commitcfaa38627b3d315d47ddad295962fe0c92d74b84 (patch)
treee80dd9650b1e6a45b5029d8fdf9a956760d78934 /content
parent2e3b0deae9e367e4fb35982981ae18c54235260a (diff)
downloadblog-cfaa38627b3d315d47ddad295962fe0c92d74b84.tar.gz
blog-cfaa38627b3d315d47ddad295962fe0c92d74b84.zip
clang: enhance comment for EmitLLVMOnlyAction
Diffstat (limited to 'content')
-rw-r--r--content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc7
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)) {