Squashed 'third_party/autocxx/' content from commit 629e8fa53

git-subtree-dir: third_party/autocxx
git-subtree-split: 629e8fa531a633164c0b52e2a3cab536d4cd0849
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
Change-Id: I62a03b0049f49adf029e0204639cdb5468dde1a1
diff --git a/examples/llvm/Cargo.toml b/examples/llvm/Cargo.toml
new file mode 100644
index 0000000..d8806c8
--- /dev/null
+++ b/examples/llvm/Cargo.toml
@@ -0,0 +1,21 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+[package]
+name = "autocxx-llvm-example"
+version = "0.1.0"
+authors = ["Adrian Taylor <adetaylor@chromium.org>"]
+edition = "2021"
+
+[dependencies]
+cxx = "1.0.54"
+autocxx = { path = "../..", version="0.17.2" }
+
+[build-dependencies]
+autocxx-build = { path = "../../gen/build", version="0.17.2" }
+miette = { version="4.3", features = [ "fancy" ] }
diff --git a/examples/llvm/build.rs b/examples/llvm/build.rs
new file mode 100644
index 0000000..1bb82ce
--- /dev/null
+++ b/examples/llvm/build.rs
@@ -0,0 +1,23 @@
+// Copyright 2022 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::path::PathBuf;
+fn main() -> miette::Result<()> {
+    let mut b = autocxx_build::Builder::new(
+        "src/lib.rs",
+        &[
+            PathBuf::from("/usr/include/llvm-13"),
+            PathBuf::from("/usr/include/llvm-c-13"),
+        ],
+    )
+    .build()?;
+
+    b.flag_if_supported("-std=c++14").compile("llvm");
+    println!("cargo:rerun-if-changed=src/lib.rs");
+    Ok(())
+}
diff --git a/examples/llvm/src/lib.rs b/examples/llvm/src/lib.rs
new file mode 100644
index 0000000..bd18880
--- /dev/null
+++ b/examples/llvm/src/lib.rs
@@ -0,0 +1,23 @@
+// Copyright 2022 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use autocxx::prelude::*; // use all the main autocxx functions
+
+include_cpp! {
+    #include "llvm/Support/MemoryBuffer.h"
+    safety!(unsafe)
+    generate!("llvm::MemoryBuffer")
+}
+
+// Simply re-export the MemoryBuffer API to users of this library.
+// Generally speaking, the APIs generated by autocxx (or similar tools)
+// still contain C++-isms, and it's wise to consider making idiomatic
+// Rust wrappers instead of doing this.
+pub use ffi::llvm::MemoryBuffer;
+
+// It would be advisable to add tests here.