Skip to content

Commit

Permalink
Format C++ at 4 columns
Browse files Browse the repository at this point in the history
Change clang-format settings to indent with 4 spaces instead of 2.
  • Loading branch information
apmasell committed Apr 12, 2022
1 parent 0eb153f commit 5ec3cc0
Show file tree
Hide file tree
Showing 15 changed files with 1,669 additions and 1,652 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
BasedOnStyle: LLVM
IndentWidth: 4
26 changes: 13 additions & 13 deletions ffi/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ extern "C" {
API_EXPORT(LLVMModuleRef)
LLVMPY_ParseAssembly(LLVMContextRef context, const char *ir,
const char **outmsg) {
using namespace llvm;
using namespace llvm;

SMDiagnostic error;
SMDiagnostic error;

Module *m = parseAssemblyString(ir, error, *unwrap(context)).release();
if (!m) {
// Error occurred
std::string osbuf;
raw_string_ostream os(osbuf);
error.print("", os);
os.flush();
*outmsg = LLVMPY_CreateString(os.str().c_str());
return NULL;
}
return wrap(m);
Module *m = parseAssemblyString(ir, error, *unwrap(context)).release();
if (!m) {
// Error occurred
std::string osbuf;
raw_string_ostream os(osbuf);
error.print("", os);
os.flush();
*outmsg = LLVMPY_CreateString(os.str().c_str());
return NULL;
}
return wrap(m);
}

} // end extern "C"
22 changes: 11 additions & 11 deletions ffi/bitcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ extern "C" {
API_EXPORT(void)
LLVMPY_WriteBitcodeToString(LLVMModuleRef M, const char **outbuf,
size_t *outlen) {
LLVMMemoryBufferRef MB = LLVMWriteBitcodeToMemoryBuffer(M);
*outlen = LLVMGetBufferSize(MB);
*outbuf = LLVMPY_CreateByteString(LLVMGetBufferStart(MB), *outlen);
LLVMDisposeMemoryBuffer(MB);
LLVMMemoryBufferRef MB = LLVMWriteBitcodeToMemoryBuffer(M);
*outlen = LLVMGetBufferSize(MB);
*outbuf = LLVMPY_CreateByteString(LLVMGetBufferStart(MB), *outlen);
LLVMDisposeMemoryBuffer(MB);
}

API_EXPORT(LLVMModuleRef)
LLVMPY_ParseBitcode(LLVMContextRef context, const char *bitcode,
size_t bitcodelen, char **outmsg) {
LLVMModuleRef ref;
LLVMMemoryBufferRef mem = LLVMCreateMemoryBufferWithMemoryRange(
bitcode, bitcodelen, "" /* BufferName*/, 0 /* RequiresNullTerminator*/
);
LLVMModuleRef ref;
LLVMMemoryBufferRef mem = LLVMCreateMemoryBufferWithMemoryRange(
bitcode, bitcodelen, "" /* BufferName*/, 0 /* RequiresNullTerminator*/
);

LLVMParseBitcodeInContext(context, mem, &ref, outmsg);
LLVMDisposeMemoryBuffer(mem);
return ref;
LLVMParseBitcodeInContext(context, mem, &ref, outmsg);
LLVMDisposeMemoryBuffer(mem);
return ref;
}

} // end extern "C"
18 changes: 9 additions & 9 deletions ffi/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ LLVMPY_CreateString(const char *msg) { return strdup(msg); }

API_EXPORT(const char *)
LLVMPY_CreateByteString(const char *buf, size_t len) {
char *dest = (char *)malloc(len + 1);
if (dest != NULL) {
memcpy(dest, buf, len);
dest[len] = '\0';
}
return dest;
char *dest = (char *)malloc(len + 1);
if (dest != NULL) {
memcpy(dest, buf, len);
dest[len] = '\0';
}
return dest;
}

API_EXPORT(void)
Expand All @@ -28,13 +28,13 @@ LLVMPY_ContextCreate() { return LLVMContextCreate(); }

API_EXPORT(void)
LLVMPY_ContextDispose(LLVMContextRef context) {
return LLVMContextDispose(context);
return LLVMContextDispose(context);
}

API_EXPORT(void)
LLVMPY_SetCommandLine(const char *name, const char *option) {
const char *argv[] = {name, option};
LLVMParseCommandLineOptions(2, argv, NULL);
const char *argv[] = {name, option};
LLVMParseCommandLineOptions(2, argv, NULL);
}

} // end extern "C"
Loading

0 comments on commit 5ec3cc0

Please sign in to comment.