#include "llvm-c/Core.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/Attributes.h"
+#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/PassManager.h"
-#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
initializePrintModulePassWrapperPass(Registry);
initializePrintFunctionPassWrapperPass(Registry);
initializePrintBasicBlockPassPass(Registry);
- initializeVerifierPass(Registry);
+ initializeVerifierLegacyPassPass(Registry);
}
void LLVMInitializeCore(LLVMPassRegistryRef R) {
/*--.. Data layout .........................................................--*/
const char * LLVMGetDataLayout(LLVMModuleRef M) {
- return unwrap(M)->getDataLayout().c_str();
+ return unwrap(M)->getDataLayoutStr().c_str();
}
void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple) {
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
char **ErrorMessage) {
std::string error;
- raw_fd_ostream dest(Filename, error);
+ raw_fd_ostream dest(Filename, error, sys::fs::F_Text);
if (!error.empty()) {
*ErrorMessage = strdup(error.c_str());
return true;
Value::use_iterator I = V->use_begin();
if (I == V->use_end())
return 0;
- return wrap(&(I.getUse()));
+ return wrap(&*I);
}
LLVMUseRef LLVMGetNextUse(LLVMUseRef U) {
return LLVMInternalLinkage;
case GlobalValue::PrivateLinkage:
return LLVMPrivateLinkage;
- case GlobalValue::LinkerPrivateLinkage:
- return LLVMLinkerPrivateLinkage;
- case GlobalValue::LinkerPrivateWeakLinkage:
- return LLVMLinkerPrivateWeakLinkage;
case GlobalValue::ExternalWeakLinkage:
return LLVMExternalWeakLinkage;
case GlobalValue::CommonLinkage:
GV->setLinkage(GlobalValue::PrivateLinkage);
break;
case LLVMLinkerPrivateLinkage:
- GV->setLinkage(GlobalValue::LinkerPrivateLinkage);
+ GV->setLinkage(GlobalValue::PrivateLinkage);
break;
case LLVMLinkerPrivateWeakLinkage:
- GV->setLinkage(GlobalValue::LinkerPrivateWeakLinkage);
+ GV->setLinkage(GlobalValue::PrivateLinkage);
break;
case LLVMDLLImportLinkage:
DEBUG(errs()
->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
}
+LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global) {
+ return static_cast<LLVMDLLStorageClass>(
+ unwrap<GlobalValue>(Global)->getDLLStorageClass());
+}
+
+void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class) {
+ unwrap<GlobalValue>(Global)->setDLLStorageClass(
+ static_cast<GlobalValue::DLLStorageClassTypes>(Class));
+}
+
+LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global) {
+ return unwrap<GlobalValue>(Global)->hasUnnamedAddr();
+}
+
+void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr) {
+ unwrap<GlobalValue>(Global)->setUnnamedAddr(HasUnnamedAddr);
+}
+
/*--.. Operations on global variables, load and store instructions .........--*/
unsigned LLVMGetAlignment(LLVMValueRef V) {
Value *P = unwrap<Value>(V);
if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
return GV->getAlignment();
+ if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
+ return AI->getAlignment();
if (LoadInst *LI = dyn_cast<LoadInst>(P))
return LI->getAlignment();
if (StoreInst *SI = dyn_cast<StoreInst>(P))
return SI->getAlignment();
- llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
+ llvm_unreachable(
+ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
}
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
Value *P = unwrap<Value>(V);
if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
GV->setAlignment(Bytes);
+ else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
+ AI->setAlignment(Bytes);
else if (LoadInst *LI = dyn_cast<LoadInst>(P))
LI->setAlignment(Bytes);
else if (StoreInst *SI = dyn_cast<StoreInst>(P))
SI->setAlignment(Bytes);
else
- llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
+ llvm_unreachable(
+ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
}
/*--.. Operations on global variables ......................................--*/
LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage) {
- OwningPtr<MemoryBuffer> MB;
+ std::unique_ptr<MemoryBuffer> MB;
error_code ec;
if (!(ec = MemoryBuffer::getFile(Path, MB))) {
- *OutMemBuf = wrap(MB.take());
+ *OutMemBuf = wrap(MB.release());
return 0;
}
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage) {
- OwningPtr<MemoryBuffer> MB;
+ std::unique_ptr<MemoryBuffer> MB;
error_code ec;
if (!(ec = MemoryBuffer::getSTDIN(MB))) {
- *OutMemBuf = wrap(MB.take());
+ *OutMemBuf = wrap(MB.release());
return 0;
}