Skip to content
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

Fixes to build with to clang-15 #110

Open
mingodad opened this issue Nov 8, 2022 · 1 comment
Open

Fixes to build with to clang-15 #110

mingodad opened this issue Nov 8, 2022 · 1 comment

Comments

@mingodad
Copy link

mingodad commented Nov 8, 2022

Here are the fixes to build with clang-15:

diff --git a/src/AST.cpp b/src/AST.cpp
index a87920b..56e3912 100644
--- a/src/AST.cpp
+++ b/src/AST.cpp
@@ -221,7 +221,7 @@ Decl* C2FFIASTConsumer::make_decl(const clang::FunctionDecl* d, bool is_toplevel
     return fd;
 }
 
-static bool convertUTF32ToUTF8String(const llvm::ArrayRef<char> &Source, std::string &Result) {
+static bool convert_UTF32ToUTF8String(const llvm::ArrayRef<char> &Source, std::string &Result) {
     const char*  SourceBegins = Source.data();
     const size_t SourceLength = Source.size();
     const char*  SourceEnding = SourceBegins + SourceLength;
@@ -274,14 +274,14 @@ Decl* C2FFIASTConsumer::make_decl(const clang::VarDecl* d, bool is_toplevel)
                         {
                             is_string = true;
 
-                            if(s->isAscii() || s->isUTF8()) {
+                            if(s->isOrdinary() || s->isUTF8()) {
                                 value = s->getString();
                             } else if(s->getCharByteWidth() == 2) {
                                 llvm::StringRef bytes = s->getBytes();
                                 llvm::convertUTF16ToUTF8String(llvm::ArrayRef<char>(bytes.data(), bytes.size()), value);
                             } else if(s->getCharByteWidth() == 4) {
                                 llvm::StringRef bytes = s->getBytes();
-                                convertUTF32ToUTF8String(llvm::ArrayRef<char>(bytes.data(), bytes.size()), value);
+                                convert_UTF32ToUTF8String(llvm::ArrayRef<char>(bytes.data(), bytes.size()), value);
                             } else {
                             }
                         }
diff --git a/src/Expr.cpp b/src/Expr.cpp
index 38f594f..020a312 100644
--- a/src/Expr.cpp
+++ b/src/Expr.cpp
@@ -109,7 +109,7 @@ static best_guess macro_type(
     if(owns_seen) seen = new StringSet;
     seen->insert(macro_name);
 
-    for(clang::MacroInfo::tokens_iterator j = mi->tokens_begin(); j != mi->tokens_end(); j++) {
+    for(clang::MacroInfo::const_tokens_iterator j = mi->tokens_begin(); j != mi->tokens_end(); j++) {
         const clang::Token& t = (*j);
 
         if(t.isLiteral()) {
@@ -152,7 +152,7 @@ static std::string macro_to_string(const clang::Preprocessor& pp, const clang::M
 {
     std::stringstream ss;
 
-    for(clang::MacroInfo::tokens_iterator j = mi->tokens_begin(); j != mi->tokens_end(); j++) {
+    for(clang::MacroInfo::const_tokens_iterator j = mi->tokens_begin(); j != mi->tokens_end(); j++) {
         const clang::Token& t = (*j);
 
         if(t.getFlags() & clang::Token::LeadingSpace) ss << " ";
diff --git a/src/drivers/JSON.cpp b/src/drivers/JSON.cpp
index a4abcf0..2896098 100644
--- a/src/drivers/JSON.cpp
+++ b/src/drivers/JSON.cpp
@@ -29,7 +29,7 @@ using namespace c2ffi;
 
 namespace c2ffi {
     class JSONOutputDriver : public OutputDriver {
-        void write_object(const char *type, bool open, bool close, ...) {
+        void write_object(const char *type, bool open, int close, ...) {
             va_list ap;
             char *ptr = NULL;
 
diff --git a/src/init.cpp b/src/init.cpp
index 1730d8e..af8014d 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -199,7 +199,7 @@ void c2ffi::init_ci(config &c, clang::CompilerInstance &ci) {
         lo.WCharSize = c.wchar_size;
 
     std::vector<std::string> includes;
-    ci.getInvocation().setLangDefaults(lo, c.kind, pti->getTriple(), includes, c.std);
+    ci.getLangOpts().setLangDefaults(lo, c.kind.getLanguage(), pti->getTriple(), includes, c.std);
     ci.createFileManager();
     ci.createSourceManager(ci.getFileManager());
rheaplex added a commit to rheaplex/c2ffi that referenced this issue Feb 15, 2023
@michaeldelago
Copy link

For Arch linux users working with the aur/c2ffi-git package, this can be applied during the PKGBUILD.

Add the initial comments patch to src/llvm-15.patch, and apply this patch

diff --git a/PKGBUILD b/PKGBUILD
index 8154a1c..b574cd7 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -40,6 +40,10 @@ build() {
   make
 }

+prepare() {
+  patch --directory="c2ffi" --forward --strip=1 --input="${srcdir}/llvm-15.patch"
+}
+
 package() {
   cd c2ffi
   make DESTDIR="$pkgdir/" install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants