[llvm-commits] [llvm] r74694 - in /llvm/trunk: include/llvm-c/BitReader.h include/llvm-c/Core.h lib/Bitcode/Reader/BitReader.cpp lib/VMCore/Core.cpp

Owen Anderson resistor at mac.com
Thu Jul 2 00:17:58 PDT 2009


Author: resistor
Date: Thu Jul  2 02:17:57 2009
New Revision: 74694

URL: http://llvm.org/viewvc/llvm-project?rev=74694&view=rev
Log:
Restore other bits of the C API that I tore up.  All pre-existing APIs default to using the
default global context, while new *InContext() APIs have been added that take a LLVMContextRef parameter.

Apologies to anyone affected by this breakage.

Modified:
    llvm/trunk/include/llvm-c/BitReader.h
    llvm/trunk/include/llvm-c/Core.h
    llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
    llvm/trunk/lib/VMCore/Core.cpp

Modified: llvm/trunk/include/llvm-c/BitReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/BitReader.h?rev=74694&r1=74693&r2=74694&view=diff

==============================================================================
--- llvm/trunk/include/llvm-c/BitReader.h (original)
+++ llvm/trunk/include/llvm-c/BitReader.h Thu Jul  2 02:17:57 2009
@@ -29,17 +29,25 @@
 /* Builds a module from the bitcode in the specified memory buffer, returning a
    reference to the module via the OutModule parameter. Returns 0 on success.
    Optionally returns a human-readable error message via OutMessage. */ 
-int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMContextRef ContextRef,
+int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf,
                      LLVMModuleRef *OutModule, char **OutMessage);
 
+int LLVMParseBitcodeInContext(LLVMMemoryBufferRef MemBuf,
+                              LLVMContextRef ContextRef,
+                              LLVMModuleRef *OutModule, char **OutMessage);
+
 /* Reads a module from the specified path, returning via the OutMP parameter
    a module provider which performs lazy deserialization. Returns 0 on success.
    Optionally returns a human-readable error message via OutMessage. */ 
 int LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf,
-                                 LLVMContextRef ContextRef,
                                  LLVMModuleProviderRef *OutMP,
                                  char **OutMessage);
 
+int LLVMGetBitcodeModuleProviderInContext(LLVMMemoryBufferRef MemBuf,
+                                          LLVMContextRef ContextRef,
+                                          LLVMModuleProviderRef *OutMP,
+                                          char **OutMessage);
+
 
 #ifdef __cplusplus
 }

Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=74694&r1=74693&r2=74694&view=diff

==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Thu Jul  2 02:17:57 2009
@@ -201,6 +201,8 @@
 /* Create and destroy modules. */ 
 /** See llvm::Module::Module. */
 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
+LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
+                                                LLVMContextRef C);
 
 /** See llvm::Module::~Module. */
 void LLVMDisposeModule(LLVMModuleRef M);

Modified: llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitReader.cpp?rev=74694&r1=74693&r2=74694&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Thu Jul  2 02:17:57 2009
@@ -9,6 +9,7 @@
 
 #include "llvm-c/BitReader.h"
 #include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <string>
 #include <cstring>
@@ -18,10 +19,26 @@
 /* Builds a module from the bitcode in the specified memory buffer, returning a
    reference to the module via the OutModule parameter. Returns 0 on success.
    Optionally returns a human-readable error message via OutMessage. */ 
-int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMContextRef ContextRef,
+int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf,
                      LLVMModuleRef *OutModule, char **OutMessage) {
   std::string Message;
   
+  *OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), getGlobalContext(),  
+                                     &Message));
+  if (!*OutModule) {
+    if (OutMessage)
+      *OutMessage = strdup(Message.c_str());
+    return 1;
+  }
+  
+  return 0;
+}
+
+int LLVMParseBitcodeInContext(LLVMMemoryBufferRef MemBuf,
+                              LLVMContextRef ContextRef,
+                              LLVMModuleRef *OutModule, char **OutMessage) {
+  std::string Message;
+  
   *OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), *unwrap(ContextRef),  
                                      &Message));
   if (!*OutModule) {
@@ -39,7 +56,25 @@
 int LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf,
                                  LLVMContextRef ContextRef,
                                  LLVMModuleProviderRef *OutMP,
-                                 char **OutMessage) {
+                                  char **OutMessage) {
+  std::string Message;
+
+  *OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), getGlobalContext(), 
+                                         &Message));
+                                         
+  if (!*OutMP) {
+    if (OutMessage)
+      *OutMessage = strdup(Message.c_str());
+      return 1;
+  }
+
+  return 0;
+}
+
+int LLVMGetBitcodeModuleProviderInContext(LLVMMemoryBufferRef MemBuf,
+                                          LLVMContextRef ContextRef,
+                                          LLVMModuleProviderRef *OutMP,
+                                          char **OutMessage) {
   std::string Message;
   
   *OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), *unwrap(ContextRef), 

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=74694&r1=74693&r2=74694&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Thu Jul  2 02:17:57 2009
@@ -56,7 +56,12 @@
 
 /*===-- Operations on modules ---------------------------------------------===*/
 
-LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID, LLVMContextRef C) {
+LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID) {
+  return wrap(new Module(ModuleID, getGlobalContext()));
+}
+
+LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, 
+                                                LLVMContextRef C) {
   return wrap(new Module(ModuleID, *unwrap(C)));
 }
 





More information about the llvm-commits mailing list