From ef7964c1b78f57e277e74bda4f38e1143d1363fe Mon Sep 17 00:00:00 2001 From: Joe Abbey Date: Mon, 1 Apr 2013 02:28:07 +0000 Subject: Whitespace cleanup git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178454 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitstreamReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Bitcode/Reader') diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp index 942346b44e..9dafe2a036 100644 --- a/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/lib/Bitcode/Reader/BitstreamReader.cpp @@ -292,7 +292,7 @@ void BitstreamCursor::ReadAbbrevRecord() { Abbv->Add(BitCodeAbbrevOp(0)); continue; } - + Abbv->Add(BitCodeAbbrevOp(E, Data)); } else Abbv->Add(BitCodeAbbrevOp(E)); -- cgit v1.2.3-70-g09d2 From 3e39731e88f2d4f597cebc74388fd6650ca4f604 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 22 Apr 2013 22:47:22 +0000 Subject: Move C++ code out of the C headers and into either C++ headers or the C++ files themselves. This enables people to use just a C compiler to interoperate with LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180063 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 106 ------------------ include/llvm-c/ExecutionEngine.h | 22 +--- include/llvm-c/Object.h | 46 -------- include/llvm-c/Target.h | 23 ---- include/llvm-c/TargetMachine.h | 22 ---- include/llvm-c/Transforms/PassManagerBuilder.h | 10 -- include/llvm/Target/TargetMachine.h | 1 + include/llvm/Wrap.h | 119 +++++++++++++++++++++ lib/Analysis/Analysis.cpp | 1 + lib/Analysis/IPA/IPA.cpp | 1 + lib/Bitcode/Reader/BitReader.cpp | 1 + lib/Bitcode/Writer/BitWriter.cpp | 1 + lib/CodeGen/CodeGen.cpp | 1 + lib/ExecutionEngine/ExecutionEngineBindings.cpp | 22 ++++ lib/IR/Core.cpp | 1 + lib/Linker/LinkModules.cpp | 1 + lib/Object/Object.cpp | 39 +++++++ lib/Target/Target.cpp | 18 ++++ lib/Target/TargetMachineC.cpp | 30 ++++++ lib/Transforms/IPO/IPO.cpp | 1 + lib/Transforms/IPO/PassManagerBuilder.cpp | 9 ++ .../InstCombine/InstructionCombining.cpp | 1 + lib/Transforms/Instrumentation/Instrumentation.cpp | 1 + lib/Transforms/ObjCARC/ObjCARC.cpp | 1 + lib/Transforms/Scalar/Scalar.cpp | 1 + lib/Transforms/Utils/Utils.cpp | 1 + lib/Transforms/Vectorize/Vectorize.cpp | 1 + 27 files changed, 253 insertions(+), 228 deletions(-) create mode 100644 include/llvm/Wrap.h (limited to 'lib/Bitcode/Reader') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 96359af51a..559c50ed3c 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -18,13 +18,6 @@ #include "llvm/Support/DataTypes.h" #ifdef __cplusplus - -/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' - and 'unwrap' conversion functions. */ -#include "llvm/IR/IRBuilder.h" -#include "llvm/IR/Module.h" -#include "llvm/PassRegistry.h" - extern "C" { #endif @@ -60,11 +53,6 @@ extern "C" { * with C++ due to name mangling. So in addition to C, this interface enables * tools written in such languages. * - * When included into a C++ source file, also declares 'wrap' and 'unwrap' - * helpers to perform opaque reference<-->pointer conversions. These helpers - * are shorter and more tightly typed than writing the casts by hand when - * authoring bindings. In assert builds, they will do runtime type checking. - * * @{ */ @@ -2690,100 +2678,6 @@ LLVMBool LLVMIsMultithreaded(); #ifdef __cplusplus } - -namespace llvm { - class MemoryBuffer; - class PassManagerBase; - - #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - inline ty *unwrap(ref P) { \ - return reinterpret_cast(P); \ - } \ - \ - inline ref wrap(const ty *P) { \ - return reinterpret_cast(const_cast(P)); \ - } - - #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - \ - template \ - inline T *unwrap(ref P) { \ - return cast(unwrap(P)); \ - } - - #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - \ - template \ - inline T *unwrap(ref P) { \ - T *Q = (T*)unwrap(P); \ - assert(Q && "Invalid cast!"); \ - return Q; \ - } - - DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) - DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) - DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) - DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef ) - /* LLVMModuleProviderRef exists for historical reasons, but now just holds a - * Module. - */ - inline Module *unwrap(LLVMModuleProviderRef MP) { - return reinterpret_cast(MP); - } - - #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS - #undef DEFINE_ISA_CONVERSION_FUNCTIONS - #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS - - /* Specialized opaque context conversions. - */ - inline LLVMContext **unwrap(LLVMContextRef* Tys) { - return reinterpret_cast(Tys); - } - - inline LLVMContextRef *wrap(const LLVMContext **Tys) { - return reinterpret_cast(const_cast(Tys)); - } - - /* Specialized opaque type conversions. - */ - inline Type **unwrap(LLVMTypeRef* Tys) { - return reinterpret_cast(Tys); - } - - inline LLVMTypeRef *wrap(Type **Tys) { - return reinterpret_cast(const_cast(Tys)); - } - - /* Specialized opaque value conversions. - */ - inline Value **unwrap(LLVMValueRef *Vals) { - return reinterpret_cast(Vals); - } - - template - inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { - #ifdef DEBUG - for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) - cast(*I); - #endif - (void)Length; - return reinterpret_cast(Vals); - } - - inline LLVMValueRef *wrap(const Value **Vals) { - return reinterpret_cast(const_cast(Vals)); - } -} - #endif /* !defined(__cplusplus) */ #endif /* !defined(LLVM_C_CORE_H) */ diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index cb77bb2e2e..be763312d2 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -137,27 +137,7 @@ void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global); */ #ifdef __cplusplus -} - -namespace llvm { - struct GenericValue; - class ExecutionEngine; - - #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - inline ty *unwrap(ref P) { \ - return reinterpret_cast(P); \ - } \ - \ - inline ref wrap(const ty *P) { \ - return reinterpret_cast(const_cast(P)); \ - } - - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef) - - #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS -} - +} #endif /* defined(__cplusplus) */ #endif diff --git a/include/llvm-c/Object.h b/include/llvm-c/Object.h index e2dad62b4e..ecccfeed7f 100644 --- a/include/llvm-c/Object.h +++ b/include/llvm-c/Object.h @@ -23,8 +23,6 @@ #include "llvm/Config/llvm-config.h" #ifdef __cplusplus -#include "llvm/Object/ObjectFile.h" - extern "C" { #endif @@ -99,50 +97,6 @@ const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI); #ifdef __cplusplus } - -namespace llvm { - namespace object { - inline ObjectFile *unwrap(LLVMObjectFileRef OF) { - return reinterpret_cast(OF); - } - - inline LLVMObjectFileRef wrap(const ObjectFile *OF) { - return reinterpret_cast(const_cast(OF)); - } - - inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { - return reinterpret_cast(SI); - } - - inline LLVMSectionIteratorRef - wrap(const section_iterator *SI) { - return reinterpret_cast - (const_cast(SI)); - } - - inline symbol_iterator *unwrap(LLVMSymbolIteratorRef SI) { - return reinterpret_cast(SI); - } - - inline LLVMSymbolIteratorRef - wrap(const symbol_iterator *SI) { - return reinterpret_cast - (const_cast(SI)); - } - - inline relocation_iterator *unwrap(LLVMRelocationIteratorRef SI) { - return reinterpret_cast(SI); - } - - inline LLVMRelocationIteratorRef - wrap(const relocation_iterator *SI) { - return reinterpret_cast - (const_cast(SI)); - } - - } -} - #endif /* defined(__cplusplus) */ #endif diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 57abfa0207..80fc3e5ad7 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -235,29 +235,6 @@ void LLVMDisposeTargetData(LLVMTargetDataRef); #ifdef __cplusplus } - -namespace llvm { - class DataLayout; - class TargetLibraryInfo; - - inline DataLayout *unwrap(LLVMTargetDataRef P) { - return reinterpret_cast(P); - } - - inline LLVMTargetDataRef wrap(const DataLayout *P) { - return reinterpret_cast(const_cast(P)); - } - - inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { - return reinterpret_cast(P); - } - - inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { - TargetLibraryInfo *X = const_cast(P); - return reinterpret_cast(X); - } -} - #endif /* defined(__cplusplus) */ #endif diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h index a02161aaa4..5878723508 100644 --- a/include/llvm-c/TargetMachine.h +++ b/include/llvm-c/TargetMachine.h @@ -117,30 +117,8 @@ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, /** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */ LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf); - - - #ifdef __cplusplus } - -namespace llvm { - class TargetMachine; - class Target; - - inline TargetMachine *unwrap(LLVMTargetMachineRef P) { - return reinterpret_cast(P); - } - inline Target *unwrap(LLVMTargetRef P) { - return reinterpret_cast(P); - } - inline LLVMTargetMachineRef wrap(const TargetMachine *P) { - return reinterpret_cast( - const_cast(P)); - } - inline LLVMTargetRef wrap(const Target * P) { - return reinterpret_cast(const_cast(P)); - } -} #endif #endif diff --git a/include/llvm-c/Transforms/PassManagerBuilder.h b/include/llvm-c/Transforms/PassManagerBuilder.h index 82e513d490..545f8aae8c 100644 --- a/include/llvm-c/Transforms/PassManagerBuilder.h +++ b/include/llvm-c/Transforms/PassManagerBuilder.h @@ -86,16 +86,6 @@ void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, #ifdef __cplusplus } - -namespace llvm { - inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) { - return reinterpret_cast(P); - } - - inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) { - return reinterpret_cast(P); - } -} #endif #endif diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 66f3a3c71b..37a79fe852 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -32,6 +32,7 @@ class MCContext; class PassManagerBase; class Target; class DataLayout; +class TargetLibraryInfo; class TargetFrameLowering; class TargetInstrInfo; class TargetIntrinsicInfo; diff --git a/include/llvm/Wrap.h b/include/llvm/Wrap.h new file mode 100644 index 0000000000..79790d4ea9 --- /dev/null +++ b/include/llvm/Wrap.h @@ -0,0 +1,119 @@ +//===- llvm/Wrap.h - C++ Type Wrapping for the C Interface -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the wrapping functions for the C interface. +// +//===----------------------------------------------------------------------===// + +#include "llvm-c/Core.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/IRBuilder.h" +#include "llvm/IR/Module.h" +#include "llvm/IR/Type.h" +#include "llvm/PassRegistry.h" + +/* When included into a C++ source file, also declares 'wrap' and 'unwrap' + helpers to perform opaque reference<-->pointer conversions. These helpers + are shorter and more tightly typed than writing the casts by hand when + authoring bindings. In assert builds, they will do runtime type checking. + + Need these includes to support the LLVM 'cast' template for the C++ 'wrap' + and 'unwrap' conversion functions. */ + +namespace llvm { + class MemoryBuffer; + class PassManagerBase; + struct GenericValue; + class ExecutionEngine; + + #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + inline ty *unwrap(ref P) { \ + return reinterpret_cast(P); \ + } \ + \ + inline ref wrap(const ty *P) { \ + return reinterpret_cast(const_cast(P)); \ + } + + #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + \ + template \ + inline T *unwrap(ref P) { \ + return cast(unwrap(P)); \ + } + + #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + \ + template \ + inline T *unwrap(ref P) { \ + T *Q = (T*)unwrap(P); \ + assert(Q && "Invalid cast!"); \ + return Q; \ + } + + DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) + DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) + DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) + DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef ) + + /* LLVMModuleProviderRef exists for historical reasons, but now just holds a + * Module. + */ + inline Module *unwrap(LLVMModuleProviderRef MP) { + return reinterpret_cast(MP); + } + + /* Specialized opaque context conversions. + */ + inline LLVMContext **unwrap(LLVMContextRef* Tys) { + return reinterpret_cast(Tys); + } + + inline LLVMContextRef *wrap(const LLVMContext **Tys) { + return reinterpret_cast(const_cast(Tys)); + } + + /* Specialized opaque type conversions. + */ + inline Type **unwrap(LLVMTypeRef* Tys) { + return reinterpret_cast(Tys); + } + + inline LLVMTypeRef *wrap(Type **Tys) { + return reinterpret_cast(const_cast(Tys)); + } + + /* Specialized opaque value conversions. + */ + inline Value **unwrap(LLVMValueRef *Vals) { + return reinterpret_cast(Vals); + } + + template + inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { + #ifdef DEBUG + for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) + cast(*I); + #endif + (void)Length; + return reinterpret_cast(Vals); + } + + inline LLVMValueRef *wrap(const Value **Vals) { + return reinterpret_cast(const_cast(Vals)); + } +} diff --git a/lib/Analysis/Analysis.cpp b/lib/Analysis/Analysis.cpp index 66e416cd14..141a493aa8 100644 --- a/lib/Analysis/Analysis.cpp +++ b/lib/Analysis/Analysis.cpp @@ -9,6 +9,7 @@ #include "llvm-c/Analysis.h" #include "llvm-c/Initialization.h" +#include "llvm/Wrap.h" #include "llvm/Analysis/Verifier.h" #include "llvm/InitializePasses.h" #include diff --git a/lib/Analysis/IPA/IPA.cpp b/lib/Analysis/IPA/IPA.cpp index aa5164e9e7..e164e1dafd 100644 --- a/lib/Analysis/IPA/IPA.cpp +++ b/lib/Analysis/IPA/IPA.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" +#include "llvm/Wrap.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/Bitcode/Reader/BitReader.cpp b/lib/Bitcode/Reader/BitReader.cpp index 5cd6c552bd..d777c8c6aa 100644 --- a/lib/Bitcode/Reader/BitReader.cpp +++ b/lib/Bitcode/Reader/BitReader.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm-c/BitReader.h" +#include "llvm/Wrap.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/MemoryBuffer.h" diff --git a/lib/Bitcode/Writer/BitWriter.cpp b/lib/Bitcode/Writer/BitWriter.cpp index 9f51c35ad9..a8b0cc4f4b 100644 --- a/lib/Bitcode/Writer/BitWriter.cpp +++ b/lib/Bitcode/Writer/BitWriter.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm-c/BitWriter.h" +#include "llvm/Wrap.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/lib/CodeGen/CodeGen.cpp b/lib/CodeGen/CodeGen.cpp index 35ec68d00c..124fd4008a 100644 --- a/lib/CodeGen/CodeGen.cpp +++ b/lib/CodeGen/CodeGen.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" +#include "llvm/Wrap.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/lib/ExecutionEngine/ExecutionEngineBindings.cpp index f4e8246476..03500c396f 100644 --- a/lib/ExecutionEngine/ExecutionEngineBindings.cpp +++ b/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -16,10 +16,32 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Wrap.h" #include using namespace llvm; +// Wrapping the C bindings types. +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef ) +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef) + +inline DataLayout *unwrap(LLVMTargetDataRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetDataRef wrap(const DataLayout *P) { + return reinterpret_cast(const_cast(P)); +} + +inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { + TargetLibraryInfo *X = const_cast(P); + return reinterpret_cast(X); +} + /*===-- Operations on generic values --------------------------------------===*/ LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty, diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index a47976f29c..1585f25d6a 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm-c/Core.h" +#include "llvm/Wrap.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 74cbdadd61..d3526a6901 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Linker.h" +#include "llvm/Wrap.h" #include "llvm-c/Linker.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp index f061ea7ceb..ea641a4831 100644 --- a/lib/Object/Object.cpp +++ b/lib/Object/Object.cpp @@ -14,10 +14,49 @@ #include "llvm/Object/ObjectFile.h" #include "llvm-c/Object.h" +#include "llvm/Wrap.h" using namespace llvm; using namespace object; +inline ObjectFile *unwrap(LLVMObjectFileRef OF) { + return reinterpret_cast(OF); +} + +inline LLVMObjectFileRef wrap(const ObjectFile *OF) { + return reinterpret_cast(const_cast(OF)); +} + +inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { + return reinterpret_cast(SI); +} + +inline LLVMSectionIteratorRef +wrap(const section_iterator *SI) { + return reinterpret_cast + (const_cast(SI)); +} + +inline symbol_iterator *unwrap(LLVMSymbolIteratorRef SI) { + return reinterpret_cast(SI); +} + +inline LLVMSymbolIteratorRef +wrap(const symbol_iterator *SI) { + return reinterpret_cast + (const_cast(SI)); +} + +inline relocation_iterator *unwrap(LLVMRelocationIteratorRef SI) { + return reinterpret_cast(SI); +} + +inline LLVMRelocationIteratorRef +wrap(const relocation_iterator *SI) { + return reinterpret_cast + (const_cast(SI)); +} + // ObjectFile creation LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) { return wrap(ObjectFile::createObjectFile(unwrap(MemBuf))); diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp index 9a78ebc3fa..c96235c953 100644 --- a/lib/Target/Target.cpp +++ b/lib/Target/Target.cpp @@ -18,11 +18,29 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" #include "llvm/Target/TargetLibraryInfo.h" #include using namespace llvm; +inline DataLayout *unwrap(LLVMTargetDataRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetDataRef wrap(const DataLayout *P) { + return reinterpret_cast(const_cast(P)); +} + +inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { + TargetLibraryInfo *X = const_cast(P); + return reinterpret_cast(X); +} + void llvm::initializeTarget(PassRegistry &Registry) { initializeDataLayoutPass(Registry); initializeTargetLibraryInfoPass(Registry); diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index 11a5d7a684..7c644fcfca 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Module.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/TargetRegistry.h" @@ -28,7 +29,36 @@ using namespace llvm; +inline DataLayout *unwrap(LLVMTargetDataRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetDataRef wrap(const DataLayout *P) { + return reinterpret_cast(const_cast(P)); +} +inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { + TargetLibraryInfo *X = const_cast(P); + return reinterpret_cast(X); +} + +inline TargetMachine *unwrap(LLVMTargetMachineRef P) { + return reinterpret_cast(P); +} +inline Target *unwrap(LLVMTargetRef P) { + return reinterpret_cast(P); +} +inline LLVMTargetMachineRef wrap(const TargetMachine *P) { + return + reinterpret_cast(const_cast(P)); +} +inline LLVMTargetRef wrap(const Target * P) { + return reinterpret_cast(const_cast(P)); +} LLVMTargetRef LLVMGetFirstTarget() { const Target* target = &*TargetRegistry::begin(); diff --git a/lib/Transforms/IPO/IPO.cpp b/lib/Transforms/IPO/IPO.cpp index 5d563d8bbf..f40a1b1f02 100644 --- a/lib/Transforms/IPO/IPO.cpp +++ b/lib/Transforms/IPO/IPO.cpp @@ -17,6 +17,7 @@ #include "llvm-c/Transforms/IPO.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" #include "llvm/Transforms/IPO.h" using namespace llvm; diff --git a/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index ffd07b6afc..e6e6f6ace4 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -19,6 +19,7 @@ #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Target/TargetLibraryInfo.h" @@ -330,6 +331,14 @@ void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, PM.add(createGlobalDCEPass()); } +inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) { + return reinterpret_cast(P); +} + +inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) { + return reinterpret_cast(P); +} + LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() { PassManagerBuilder *PMB = new PassManagerBuilder(); return wrap(PMB); diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index c6115e3e91..fc832dc0c3 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -53,6 +53,7 @@ #include "llvm/Support/ValueHandle.h" #include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Wrap.h" #include #include using namespace llvm; diff --git a/lib/Transforms/Instrumentation/Instrumentation.cpp b/lib/Transforms/Instrumentation/Instrumentation.cpp index 8ba102559b..d5207b74ba 100644 --- a/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" +#include "llvm/Wrap.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/Transforms/ObjCARC/ObjCARC.cpp b/lib/Transforms/ObjCARC/ObjCARC.cpp index 373168e898..b76a33668d 100644 --- a/lib/Transforms/ObjCARC/ObjCARC.cpp +++ b/lib/Transforms/ObjCARC/ObjCARC.cpp @@ -17,6 +17,7 @@ #include "llvm-c/Core.h" #include "llvm-c/Initialization.h" #include "llvm/InitializePasses.h" +#include "llvm/Wrap.h" #include "llvm/Support/CommandLine.h" namespace llvm { diff --git a/lib/Transforms/Scalar/Scalar.cpp b/lib/Transforms/Scalar/Scalar.cpp index 8a9c7da113..a7dc26e202 100644 --- a/lib/Transforms/Scalar/Scalar.cpp +++ b/lib/Transforms/Scalar/Scalar.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" using namespace llvm; diff --git a/lib/Transforms/Utils/Utils.cpp b/lib/Transforms/Utils/Utils.cpp index 5812d4607d..b7f92df203 100644 --- a/lib/Transforms/Utils/Utils.cpp +++ b/lib/Transforms/Utils/Utils.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" +#include "llvm/Wrap.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/Transforms/Vectorize/Vectorize.cpp b/lib/Transforms/Vectorize/Vectorize.cpp index a927fe1451..29e59fa592 100644 --- a/lib/Transforms/Vectorize/Vectorize.cpp +++ b/lib/Transforms/Vectorize/Vectorize.cpp @@ -20,6 +20,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" using namespace llvm; -- cgit v1.2.3-70-g09d2 From 40be1e85665d10f5444186f0e7106e368dd735b8 Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Wed, 1 May 2013 20:59:00 +0000 Subject: This patch breaks up Wrap.h so that it does not have to include all of the things, and renames it to CBindingWrapping.h. I also moved CBindingWrapping.h into Support/. This new file just contains the macros for defining different wrap/unwrap methods. The calls to those macros, as well as any custom wrap/unwrap definitions (like for array of Values for example), are put into corresponding C++ headers. Doing this required some #include surgery, since some .cpp files relied on the fact that including Wrap.h implicitly caused the inclusion of a bunch of other things. This also now means that the C++ headers will include their corresponding C API headers; for example Value.h must include llvm-c/Core.h. I think this is harmless, since the C API headers contain just external function declarations and some C types, so I don't believe there should be any nasty dependency issues here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180881 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 4 +- include/llvm/IR/BasicBlock.h | 4 + include/llvm/IR/IRBuilder.h | 4 + include/llvm/IR/LLVMContext.h | 15 +++ include/llvm/IR/Module.h | 11 ++ include/llvm/IR/Type.h | 15 +++ include/llvm/IR/Use.h | 5 + include/llvm/IR/Value.h | 25 +++++ include/llvm/PassManager.h | 4 + include/llvm/PassRegistry.h | 5 + include/llvm/Support/CBindingWrapping.h | 46 ++++++++ include/llvm/Support/MemoryBuffer.h | 5 + include/llvm/Wrap.h | 124 --------------------- lib/Analysis/Analysis.cpp | 3 +- lib/Analysis/IPA/IPA.cpp | 2 +- lib/Bitcode/Reader/BitReader.cpp | 2 +- lib/Bitcode/Writer/BitWriter.cpp | 2 +- lib/CodeGen/CodeGen.cpp | 2 +- lib/ExecutionEngine/ExecutionEngineBindings.cpp | 4 +- lib/IR/Core.cpp | 3 +- lib/Linker/LinkModules.cpp | 1 - lib/Object/Object.cpp | 2 +- lib/Target/Target.cpp | 2 +- lib/Target/TargetMachineC.cpp | 1 - lib/Transforms/IPO/IPO.cpp | 1 - lib/Transforms/IPO/PassManagerBuilder.cpp | 1 - .../InstCombine/InstructionCombining.cpp | 1 - lib/Transforms/Instrumentation/Instrumentation.cpp | 2 +- lib/Transforms/ObjCARC/ObjCARC.cpp | 1 - lib/Transforms/Scalar/Scalar.cpp | 1 - lib/Transforms/Utils/Utils.cpp | 2 +- lib/Transforms/Vectorize/Vectorize.cpp | 1 - 32 files changed, 156 insertions(+), 145 deletions(-) create mode 100644 include/llvm/Support/CBindingWrapping.h delete mode 100644 include/llvm/Wrap.h (limited to 'lib/Bitcode/Reader') diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 9800759484..bbaebc6f90 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -26,7 +26,6 @@ #include "llvm/Support/ValueHandle.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Wrap.h" #include #include #include @@ -634,7 +633,8 @@ public: ExecutionEngine *create(TargetMachine *TM); }; -DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef) +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef) } // End llvm namespace diff --git a/include/llvm/IR/BasicBlock.h b/include/llvm/IR/BasicBlock.h index ea5695a9e6..3bdc95d556 100644 --- a/include/llvm/IR/BasicBlock.h +++ b/include/llvm/IR/BasicBlock.h @@ -18,6 +18,7 @@ #include "llvm/ADT/ilist.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/SymbolTableListTraits.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -298,6 +299,9 @@ private: } }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef) + } // End llvm namespace #endif diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 1c71d0a901..189ba3d305 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -23,6 +23,7 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Operator.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/ConstantFolder.h" namespace llvm { @@ -1396,6 +1397,9 @@ public: } }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef) + } #endif diff --git a/include/llvm/IR/LLVMContext.h b/include/llvm/IR/LLVMContext.h index ae81e5b1c3..f25d820c2b 100644 --- a/include/llvm/IR/LLVMContext.h +++ b/include/llvm/IR/LLVMContext.h @@ -15,7 +15,9 @@ #ifndef LLVM_IR_LLVMCONTEXT_H #define LLVM_IR_LLVMCONTEXT_H +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Compiler.h" +#include "llvm-c/Core.h" namespace llvm { @@ -109,6 +111,19 @@ private: /// only care about operating on a single thread. extern LLVMContext &getGlobalContext(); +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef) + +/* Specialized opaque context conversions. + */ +inline LLVMContext **unwrap(LLVMContextRef* Tys) { + return reinterpret_cast(Tys); +} + +inline LLVMContextRef *wrap(const LLVMContext **Tys) { + return reinterpret_cast(const_cast(Tys)); +} + } #endif diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index 4460aa435b..cb500ffe7c 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -20,6 +20,7 @@ #include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Metadata.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -584,6 +585,16 @@ inline raw_ostream &operator<<(raw_ostream &O, const Module &M) { return O; } +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef) + +/* LLVMModuleProviderRef exists for historical reasons, but now just holds a + * Module. + */ +inline Module *unwrap(LLVMModuleProviderRef MP) { + return reinterpret_cast(MP); +} + } // End llvm namespace #endif diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index d89ae243f5..1bf8789d30 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -17,8 +17,10 @@ #include "llvm/ADT/APFloat.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm-c/Core.h" namespace llvm { @@ -467,6 +469,19 @@ template <> struct GraphTraits { } }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_ISA_CONVERSION_FUNCTIONS(Type, LLVMTypeRef) + +/* Specialized opaque type conversions. + */ +inline Type **unwrap(LLVMTypeRef* Tys) { + return reinterpret_cast(Tys); +} + +inline LLVMTypeRef *wrap(Type **Tys) { + return reinterpret_cast(const_cast(Tys)); +} + } // End llvm namespace #endif diff --git a/include/llvm/IR/Use.h b/include/llvm/IR/Use.h index 4bc7ce5000..efd8b48a0e 100644 --- a/include/llvm/IR/Use.h +++ b/include/llvm/IR/Use.h @@ -26,7 +26,9 @@ #define LLVM_IR_USE_H #include "llvm/ADT/PointerIntPair.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Compiler.h" +#include "llvm-c/Core.h" #include #include @@ -214,6 +216,9 @@ public: unsigned getOperandNo() const; }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef) + } // End llvm namespace #endif diff --git a/include/llvm/IR/Value.h b/include/llvm/IR/Value.h index a4f78627a8..fb61a2ac70 100644 --- a/include/llvm/IR/Value.h +++ b/include/llvm/IR/Value.h @@ -16,7 +16,9 @@ #include "llvm/IR/Use.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Compiler.h" +#include "llvm-c/Core.h" namespace llvm { @@ -406,6 +408,29 @@ public: enum { NumLowBitsAvailable = 2 }; }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_ISA_CONVERSION_FUNCTIONS(Value, LLVMValueRef) + +/* Specialized opaque value conversions. + */ +inline Value **unwrap(LLVMValueRef *Vals) { + return reinterpret_cast(Vals); +} + +template +inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { +#ifdef DEBUG + for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) + cast(*I); +#endif + (void)Length; + return reinterpret_cast(Vals); +} + +inline LLVMValueRef *wrap(const Value **Vals) { + return reinterpret_cast(const_cast(Vals)); +} + } // End llvm namespace #endif diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index ce5fda79f9..b6a8186a4e 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -18,6 +18,7 @@ #define LLVM_PASSMANAGER_H #include "llvm/Pass.h" +#include "llvm/Support/CBindingWrapping.h" namespace llvm { @@ -98,6 +99,9 @@ private: Module *M; }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef) + } // End llvm namespace #endif diff --git a/include/llvm/PassRegistry.h b/include/llvm/PassRegistry.h index 5d89c49221..f49c953e44 100644 --- a/include/llvm/PassRegistry.h +++ b/include/llvm/PassRegistry.h @@ -18,6 +18,8 @@ #define LLVM_PASSREGISTRY_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/CBindingWrapping.h" +#include "llvm-c/Core.h" namespace llvm { @@ -79,6 +81,9 @@ public: void removeRegistrationListener(PassRegistrationListener *L); }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef) + } #endif diff --git a/include/llvm/Support/CBindingWrapping.h b/include/llvm/Support/CBindingWrapping.h new file mode 100644 index 0000000000..58ecb41a88 --- /dev/null +++ b/include/llvm/Support/CBindingWrapping.h @@ -0,0 +1,46 @@ +//===- llvm/Wrap.h - C++ Type Wrapping for the C Interface -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the wrapping macros for the C interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_C_BINDING_WRAPPING_H +#define LLVM_C_BINDING_WRAPPING_H + +#include "llvm/Support/Casting.h" + +#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + inline ty *unwrap(ref P) { \ + return reinterpret_cast(P); \ + } \ + \ + inline ref wrap(const ty *P) { \ + return reinterpret_cast(const_cast(P)); \ + } + +#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + \ + template \ + inline T *unwrap(ref P) { \ + return cast(unwrap(P)); \ + } + +#define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + \ + template \ + inline T *unwrap(ref P) { \ + T *Q = (T*)unwrap(P); \ + assert(Q && "Invalid cast!"); \ + return Q; \ + } + +#endif diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index 1f02907d9f..0cce726d48 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -15,8 +15,10 @@ #define LLVM_SUPPORT_MEMORYBUFFER_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" +#include "llvm-c/Core.h" namespace llvm { @@ -137,6 +139,9 @@ public: virtual BufferKind getBufferKind() const = 0; }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef) + } // end namespace llvm #endif diff --git a/include/llvm/Wrap.h b/include/llvm/Wrap.h deleted file mode 100644 index 0dc5c78bd1..0000000000 --- a/include/llvm/Wrap.h +++ /dev/null @@ -1,124 +0,0 @@ -//===- llvm/Wrap.h - C++ Type Wrapping for the C Interface -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the wrapping functions for the C interface. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_WRAP_H -#define LLVM_WRAP_H - -#include "llvm-c/Core.h" -#include "llvm/IR/BasicBlock.h" -#include "llvm/IR/IRBuilder.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Type.h" -#include "llvm/PassRegistry.h" - -/* When included into a C++ source file, also declares 'wrap' and 'unwrap' - helpers to perform opaque reference<-->pointer conversions. These helpers - are shorter and more tightly typed than writing the casts by hand when - authoring bindings. In assert builds, they will do runtime type checking. - - Need these includes to support the LLVM 'cast' template for the C++ 'wrap' - and 'unwrap' conversion functions. */ - -namespace llvm { - class MemoryBuffer; - class PassManagerBase; - struct GenericValue; - class ExecutionEngine; - - #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - inline ty *unwrap(ref P) { \ - return reinterpret_cast(P); \ - } \ - \ - inline ref wrap(const ty *P) { \ - return reinterpret_cast(const_cast(P)); \ - } - - #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - \ - template \ - inline T *unwrap(ref P) { \ - return cast(unwrap(P)); \ - } - - #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ - \ - template \ - inline T *unwrap(ref P) { \ - T *Q = (T*)unwrap(P); \ - assert(Q && "Invalid cast!"); \ - return Q; \ - } - - DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) - DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) - DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) - DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef ) - - /* LLVMModuleProviderRef exists for historical reasons, but now just holds a - * Module. - */ - inline Module *unwrap(LLVMModuleProviderRef MP) { - return reinterpret_cast(MP); - } - - /* Specialized opaque context conversions. - */ - inline LLVMContext **unwrap(LLVMContextRef* Tys) { - return reinterpret_cast(Tys); - } - - inline LLVMContextRef *wrap(const LLVMContext **Tys) { - return reinterpret_cast(const_cast(Tys)); - } - - /* Specialized opaque type conversions. - */ - inline Type **unwrap(LLVMTypeRef* Tys) { - return reinterpret_cast(Tys); - } - - inline LLVMTypeRef *wrap(Type **Tys) { - return reinterpret_cast(const_cast(Tys)); - } - - /* Specialized opaque value conversions. - */ - inline Value **unwrap(LLVMValueRef *Vals) { - return reinterpret_cast(Vals); - } - - template - inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { - #ifdef DEBUG - for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) - cast(*I); - #endif - (void)Length; - return reinterpret_cast(Vals); - } - - inline LLVMValueRef *wrap(const Value **Vals) { - return reinterpret_cast(const_cast(Vals)); - } -} - -#endif diff --git a/lib/Analysis/Analysis.cpp b/lib/Analysis/Analysis.cpp index 141a493aa8..349c4178c2 100644 --- a/lib/Analysis/Analysis.cpp +++ b/lib/Analysis/Analysis.cpp @@ -9,9 +9,10 @@ #include "llvm-c/Analysis.h" #include "llvm-c/Initialization.h" -#include "llvm/Wrap.h" #include "llvm/Analysis/Verifier.h" #include "llvm/InitializePasses.h" +#include "llvm/IR/Module.h" +#include "llvm/PassRegistry.h" #include using namespace llvm; diff --git a/lib/Analysis/IPA/IPA.cpp b/lib/Analysis/IPA/IPA.cpp index e164e1dafd..1c1816dfd8 100644 --- a/lib/Analysis/IPA/IPA.cpp +++ b/lib/Analysis/IPA/IPA.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" -#include "llvm/Wrap.h" +#include "llvm/PassRegistry.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/Bitcode/Reader/BitReader.cpp b/lib/Bitcode/Reader/BitReader.cpp index d777c8c6aa..23630e5525 100644 --- a/lib/Bitcode/Reader/BitReader.cpp +++ b/lib/Bitcode/Reader/BitReader.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "llvm-c/BitReader.h" -#include "llvm/Wrap.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" #include "llvm/Support/MemoryBuffer.h" #include #include diff --git a/lib/Bitcode/Writer/BitWriter.cpp b/lib/Bitcode/Writer/BitWriter.cpp index a8b0cc4f4b..985208c40f 100644 --- a/lib/Bitcode/Writer/BitWriter.cpp +++ b/lib/Bitcode/Writer/BitWriter.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "llvm-c/BitWriter.h" -#include "llvm/Wrap.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/IR/Module.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/lib/CodeGen/CodeGen.cpp b/lib/CodeGen/CodeGen.cpp index 124fd4008a..c641991d40 100644 --- a/lib/CodeGen/CodeGen.cpp +++ b/lib/CodeGen/CodeGen.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" -#include "llvm/Wrap.h" +#include "llvm/PassRegistry.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/lib/ExecutionEngine/ExecutionEngineBindings.cpp index 44fa92205b..f66dc1dfea 100644 --- a/lib/ExecutionEngine/ExecutionEngineBindings.cpp +++ b/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -15,13 +15,15 @@ #include "llvm-c/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Module.h" #include "llvm/Support/ErrorHandling.h" #include using namespace llvm; // Wrapping the C bindings types. -DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef ) +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef) inline DataLayout *unwrap(LLVMTargetDataRef P) { return reinterpret_cast(P); diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index c79c483774..889d574290 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm-c/Core.h" -#include "llvm/Wrap.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" @@ -22,7 +21,9 @@ #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/IRBuilder.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" diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index d3526a6901..74cbdadd61 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Linker.h" -#include "llvm/Wrap.h" #include "llvm-c/Linker.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp index ea641a4831..3e2c78ec47 100644 --- a/lib/Object/Object.cpp +++ b/lib/Object/Object.cpp @@ -12,9 +12,9 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/SmallVector.h" #include "llvm/Object/ObjectFile.h" #include "llvm-c/Object.h" -#include "llvm/Wrap.h" using namespace llvm; using namespace object; diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp index c96235c953..3d92f297be 100644 --- a/lib/Target/Target.cpp +++ b/lib/Target/Target.cpp @@ -16,9 +16,9 @@ #include "llvm-c/Initialization.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Value.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" -#include "llvm/Wrap.h" #include "llvm/Target/TargetLibraryInfo.h" #include diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index 7c644fcfca..19e78b83a7 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -17,7 +17,6 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Module.h" #include "llvm/PassManager.h" -#include "llvm/Wrap.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/TargetRegistry.h" diff --git a/lib/Transforms/IPO/IPO.cpp b/lib/Transforms/IPO/IPO.cpp index f40a1b1f02..5d563d8bbf 100644 --- a/lib/Transforms/IPO/IPO.cpp +++ b/lib/Transforms/IPO/IPO.cpp @@ -17,7 +17,6 @@ #include "llvm-c/Transforms/IPO.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" -#include "llvm/Wrap.h" #include "llvm/Transforms/IPO.h" using namespace llvm; diff --git a/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index e6e6f6ace4..986c0b8928 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -19,7 +19,6 @@ #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" #include "llvm/PassManager.h" -#include "llvm/Wrap.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Target/TargetLibraryInfo.h" diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index fc832dc0c3..c6115e3e91 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -53,7 +53,6 @@ #include "llvm/Support/ValueHandle.h" #include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Transforms/Utils/Local.h" -#include "llvm/Wrap.h" #include #include using namespace llvm; diff --git a/lib/Transforms/Instrumentation/Instrumentation.cpp b/lib/Transforms/Instrumentation/Instrumentation.cpp index d5207b74ba..9f353967f3 100644 --- a/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" -#include "llvm/Wrap.h" +#include "llvm/PassRegistry.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/Transforms/ObjCARC/ObjCARC.cpp b/lib/Transforms/ObjCARC/ObjCARC.cpp index b76a33668d..373168e898 100644 --- a/lib/Transforms/ObjCARC/ObjCARC.cpp +++ b/lib/Transforms/ObjCARC/ObjCARC.cpp @@ -17,7 +17,6 @@ #include "llvm-c/Core.h" #include "llvm-c/Initialization.h" #include "llvm/InitializePasses.h" -#include "llvm/Wrap.h" #include "llvm/Support/CommandLine.h" namespace llvm { diff --git a/lib/Transforms/Scalar/Scalar.cpp b/lib/Transforms/Scalar/Scalar.cpp index a7dc26e202..8a9c7da113 100644 --- a/lib/Transforms/Scalar/Scalar.cpp +++ b/lib/Transforms/Scalar/Scalar.cpp @@ -21,7 +21,6 @@ #include "llvm/IR/DataLayout.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" -#include "llvm/Wrap.h" using namespace llvm; diff --git a/lib/Transforms/Utils/Utils.cpp b/lib/Transforms/Utils/Utils.cpp index b7f92df203..c3df215c29 100644 --- a/lib/Transforms/Utils/Utils.cpp +++ b/lib/Transforms/Utils/Utils.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/InitializePasses.h" -#include "llvm/Wrap.h" +#include "llvm/PassRegistry.h" #include "llvm-c/Initialization.h" using namespace llvm; diff --git a/lib/Transforms/Vectorize/Vectorize.cpp b/lib/Transforms/Vectorize/Vectorize.cpp index 29e59fa592..a927fe1451 100644 --- a/lib/Transforms/Vectorize/Vectorize.cpp +++ b/lib/Transforms/Vectorize/Vectorize.cpp @@ -20,7 +20,6 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" -#include "llvm/Wrap.h" using namespace llvm; -- cgit v1.2.3-70-g09d2 From 5c332dbd30d9398ed25b30c3080506f7b8e92290 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sun, 5 May 2013 00:40:33 +0000 Subject: Add ArrayRef constructor from None, and do the cleanups that this constructor enables Patch by Robert Wilhelm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181138 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ArrayRef.h | 9 ++++++++- include/llvm/CodeGen/LiveRangeEdit.h | 3 +-- include/llvm/CodeGen/MachineTraceMetrics.h | 7 +++---- include/llvm/IR/Intrinsics.h | 9 ++++----- include/llvm/MC/MCParser/MCAsmParser.h | 7 +++---- include/llvm/Support/SourceMgr.h | 12 ++++++------ lib/AsmParser/LLParser.cpp | 2 +- lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 ++-- lib/CodeGen/ShrinkWrapping.cpp | 4 ++-- lib/IR/ConstantsContext.h | 2 +- lib/IR/PassManager.cpp | 4 ++-- lib/IR/Type.cpp | 4 ++-- lib/MC/MCParser/AsmParser.cpp | 6 +++--- lib/Support/YAMLParser.cpp | 2 +- lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 4 ++-- lib/Target/X86/AsmParser/X86AsmParser.cpp | 4 ++-- lib/Transforms/InstCombine/InstructionCombining.cpp | 2 +- lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 3 +-- lib/Transforms/Utils/ValueMapper.cpp | 2 +- lib/Transforms/Vectorize/LoopVectorize.cpp | 2 +- 21 files changed, 48 insertions(+), 46 deletions(-) (limited to 'lib/Bitcode/Reader') diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index c555c1c2b1..d4152ec727 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -10,6 +10,7 @@ #ifndef LLVM_ADT_ARRAYREF_H #define LLVM_ADT_ARRAYREF_H +#include "llvm/ADT/None.h" #include "llvm/ADT/SmallVector.h" #include @@ -49,6 +50,9 @@ namespace llvm { /// Construct an empty ArrayRef. /*implicit*/ ArrayRef() : Data(0), Length(0) {} + /// Construct an empty ArrayRef from None. + /*implicit*/ ArrayRef(NoneType) : Data(0), Length(0) {} + /// Construct an ArrayRef from a single element. /*implicit*/ ArrayRef(const T &OneElt) : Data(&OneElt), Length(1) {} @@ -174,9 +178,12 @@ namespace llvm { public: typedef T *iterator; - /// Construct an empty ArrayRef. + /// Construct an empty MutableArrayRef. /*implicit*/ MutableArrayRef() : ArrayRef() {} + /// Construct an empty MutableArrayRef from None. + /*implicit*/ MutableArrayRef(NoneType) : ArrayRef() {} + /// Construct an MutableArrayRef from a single element. /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef(OneElt) {} diff --git a/include/llvm/CodeGen/LiveRangeEdit.h b/include/llvm/CodeGen/LiveRangeEdit.h index 8a32a3c11a..e59276fd6d 100644 --- a/include/llvm/CodeGen/LiveRangeEdit.h +++ b/include/llvm/CodeGen/LiveRangeEdit.h @@ -196,8 +196,7 @@ public: /// allocator. These registers should not be split into new intervals /// as currently those new intervals are not guaranteed to spill. void eliminateDeadDefs(SmallVectorImpl &Dead, - ArrayRef RegsBeingSpilled - = ArrayRef()); + ArrayRef RegsBeingSpilled = None); /// calculateRegClassAndHint - Recompute register class and hint for each new /// register. diff --git a/include/llvm/CodeGen/MachineTraceMetrics.h b/include/llvm/CodeGen/MachineTraceMetrics.h index 4e087fc62d..9794707e35 100644 --- a/include/llvm/CodeGen/MachineTraceMetrics.h +++ b/include/llvm/CodeGen/MachineTraceMetrics.h @@ -263,10 +263,9 @@ public: /// trace. Likewise, extra resources required by the specified scheduling /// classes are included. For the caller to account for extra machine /// instructions, it must first resolve each instruction's scheduling class. - unsigned getResourceLength(ArrayRef Extrablocks = - ArrayRef(), - ArrayRef ExtraInstrs = - ArrayRef()) const; + unsigned getResourceLength( + ArrayRef Extrablocks = None, + ArrayRef ExtraInstrs = None) const; /// Return the length of the (data dependency) critical path through the /// trace. diff --git a/include/llvm/IR/Intrinsics.h b/include/llvm/IR/Intrinsics.h index e69ddec1e3..c81d110e3b 100644 --- a/include/llvm/IR/Intrinsics.h +++ b/include/llvm/IR/Intrinsics.h @@ -45,12 +45,12 @@ namespace Intrinsic { /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as /// "llvm.ppc.altivec.lvx". - std::string getName(ID id, ArrayRef Tys = ArrayRef()); - + std::string getName(ID id, ArrayRef Tys = None); + /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// FunctionType *getType(LLVMContext &Context, ID id, - ArrayRef Tys = ArrayRef()); + ArrayRef Tys = None); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. @@ -67,8 +67,7 @@ namespace Intrinsic { /// using iAny, fAny, vAny, or iPTRAny). For a declaration of an overloaded /// intrinsic, Tys must provide exactly one type for each overloaded type in /// the intrinsic. - Function *getDeclaration(Module *M, ID id, - ArrayRef Tys = ArrayRef()); + Function *getDeclaration(Module *M, ID id, ArrayRef Tys = None); /// Map a GCC builtin name to an intrinsic ID. ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName); diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index 7f012c65b0..dcc9886333 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -122,14 +122,14 @@ public: /// /// \return The return value is true, if warnings are fatal. virtual bool Warning(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef()) = 0; + ArrayRef Ranges = None) = 0; /// Error - Emit an error at the location \p L, with the message \p Msg. /// /// \return The return value is always true, as an idiomatic convenience to /// clients. virtual bool Error(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef()) = 0; + ArrayRef Ranges = None) = 0; /// Lex - Get the next AsmToken in the stream, possibly handling file /// inclusion first. @@ -139,8 +139,7 @@ public: const AsmToken &getTok(); /// \brief Report an error at the current lexer location. - bool TokError(const Twine &Msg, - ArrayRef Ranges = ArrayRef()); + bool TokError(const Twine &Msg, ArrayRef Ranges = None); /// parseIdentifier - Parse an identifier or string (as a quoted identifier) /// and set \p Res to the identifier contents. diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index 02abf92daa..d67914a1b8 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -145,8 +145,8 @@ public: /// @param ShowColors - Display colored messages if output is a terminal and /// the default error handler is used. void PrintMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, - ArrayRef Ranges = ArrayRef(), - ArrayRef FixIts = ArrayRef(), + ArrayRef Ranges = None, + ArrayRef FixIts = None, bool ShowColors = true) const; @@ -155,9 +155,9 @@ public: /// /// @param Msg If non-null, the kind of message (e.g., "error") which is /// prefixed to the message. - SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, - ArrayRef Ranges = ArrayRef(), - ArrayRef FixIts = ArrayRef()) const; + SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, + ArrayRef Ranges = None, + ArrayRef FixIts = None) const; /// PrintIncludeStack - Prints the names of included files and the line of the /// file they were included from. A diagnostic handler can use this before @@ -227,7 +227,7 @@ public: int Line, int Col, SourceMgr::DiagKind Kind, StringRef Msg, StringRef LineStr, ArrayRef > Ranges, - ArrayRef FixIts = ArrayRef()); + ArrayRef FixIts = None); const SourceMgr *getSourceMgr() const { return SM; } SMLoc getLoc() const { return Loc; } diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 998bca5212..62d8070d18 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -528,7 +528,7 @@ bool LLParser::ParseMDNodeID(MDNode *&Result) { if (Result) return false; // Otherwise, create MDNode forward reference. - MDNode *FwdNode = MDNode::getTemporary(Context, ArrayRef()); + MDNode *FwdNode = MDNode::getTemporary(Context, None); ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc()); if (NumberedMetadata.size() <= MID) diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index f34884391a..e6ff4b43b1 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -405,7 +405,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { } // Create and return a placeholder, which will later be RAUW'd. - Value *V = MDNode::getTemporary(Context, ArrayRef()); + Value *V = MDNode::getTemporary(Context, None); MDValuePtrs[Idx] = V; return V; } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 5e30c251e7..15235c8ac3 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -5252,7 +5252,7 @@ SDNode *SelectionDAG::MorphNodeTo(SDNode *N, unsigned Opc, MachineSDNode * SelectionDAG::getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT) { SDVTList VTs = getVTList(VT); - return getMachineNode(Opcode, dl, VTs, ArrayRef()); + return getMachineNode(Opcode, dl, VTs, None); } MachineSDNode * @@ -5288,7 +5288,7 @@ SelectionDAG::getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT, MachineSDNode * SelectionDAG::getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2) { SDVTList VTs = getVTList(VT1, VT2); - return getMachineNode(Opcode, dl, VTs, ArrayRef()); + return getMachineNode(Opcode, dl, VTs, None); } MachineSDNode * diff --git a/lib/CodeGen/ShrinkWrapping.cpp b/lib/CodeGen/ShrinkWrapping.cpp index 9ab491808f..2feea59c03 100644 --- a/lib/CodeGen/ShrinkWrapping.cpp +++ b/lib/CodeGen/ShrinkWrapping.cpp @@ -70,14 +70,14 @@ ShrinkWrapFunc("shrink-wrap-func", cl::Hidden, // Debugging level for shrink wrapping. enum ShrinkWrapDebugLevel { - None, BasicInfo, Iterations, Details + Disabled, BasicInfo, Iterations, Details }; static cl::opt ShrinkWrapDebugging("shrink-wrap-dbg", cl::Hidden, cl::desc("Print shrink wrapping debugging information"), cl::values( - clEnumVal(None , "disable debug output"), + clEnumVal(Disabled , "disable debug output"), clEnumVal(BasicInfo , "print basic DF sets"), clEnumVal(Iterations, "print SR sets for each iteration"), clEnumVal(Details , "print all DF sets"), diff --git a/lib/IR/ConstantsContext.h b/lib/IR/ConstantsContext.h index e9958589f5..32bed95e21 100644 --- a/lib/IR/ConstantsContext.h +++ b/lib/IR/ConstantsContext.h @@ -318,7 +318,7 @@ struct ExprMapKeyType { ArrayRef ops, unsigned short flags = 0, unsigned short optionalflags = 0, - ArrayRef inds = ArrayRef()) + ArrayRef inds = None) : opcode(opc), subclassoptionaldata(optionalflags), subclassdata(flags), operands(ops.begin(), ops.end()), indices(inds.begin(), inds.end()) {} uint8_t opcode; diff --git a/lib/IR/PassManager.cpp b/lib/IR/PassManager.cpp index 3c968aac16..387094a0e3 100644 --- a/lib/IR/PassManager.cpp +++ b/lib/IR/PassManager.cpp @@ -42,14 +42,14 @@ namespace llvm { // Different debug levels that can be enabled... enum PassDebugLevel { - None, Arguments, Structure, Executions, Details + Disabled, Arguments, Structure, Executions, Details }; static cl::opt PassDebugging("debug-pass", cl::Hidden, cl::desc("Print PassManager debugging information"), cl::values( - clEnumVal(None , "disable debug output"), + clEnumVal(Disabled , "disable debug output"), clEnumVal(Arguments , "print pass arguments to pass to 'opt'"), clEnumVal(Structure , "print pass structure before run()"), clEnumVal(Executions, "print pass name before it is executed"), diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index 1e6a51ab10..46c61fc06e 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -380,7 +380,7 @@ FunctionType *FunctionType::get(Type *ReturnType, } FunctionType *FunctionType::get(Type *Result, bool isVarArg) { - return get(Result, ArrayRef(), isVarArg); + return get(Result, None, isVarArg); } /// isValidReturnType - Return true if the specified type is valid as a return @@ -499,7 +499,7 @@ StructType *StructType::create(LLVMContext &Context, StringRef Name) { } StructType *StructType::get(LLVMContext &Context, bool isPacked) { - return get(Context, llvm::ArrayRef(), isPacked); + return get(Context, None, isPacked); } StructType *StructType::get(Type *type, ...) { diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index a903771bdb..2368e9e86a 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -201,9 +201,9 @@ public: } virtual bool Warning(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef()); + ArrayRef Ranges = None); virtual bool Error(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef()); + ArrayRef Ranges = None); virtual const AsmToken &Lex(); @@ -286,7 +286,7 @@ private: void PrintMacroInstantiations(); void PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Msg, - ArrayRef Ranges = ArrayRef()) const { + ArrayRef Ranges = None) const { SrcMgr.PrintMessage(Loc, Kind, Msg, Ranges); } static void DiagHandler(const SMDiagnostic &Diag, void *Context); diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp index 2cead20c0b..213f5e1568 100644 --- a/lib/Support/YAMLParser.cpp +++ b/lib/Support/YAMLParser.cpp @@ -260,7 +260,7 @@ public: Token getNext(); void printError(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Message, - ArrayRef Ranges = ArrayRef()) { + ArrayRef Ranges = None) { SM.PrintMessage(Loc, Kind, Message, Ranges); } diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 114cc9e5c0..1dd2953b29 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -86,11 +86,11 @@ class ARMAsmParser : public MCTargetAsmParser { MCAsmLexer &getLexer() const { return Parser.getLexer(); } bool Warning(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef()) { + ArrayRef Ranges = None) { return Parser.Warning(L, Msg, Ranges); } bool Error(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef()) { + ArrayRef Ranges = None) { return Parser.Error(L, Msg, Ranges); } diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 5c09434854..68908abb57 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -477,7 +477,7 @@ private: MCAsmLexer &getLexer() const { return Parser.getLexer(); } bool Error(SMLoc L, const Twine &Msg, - ArrayRef Ranges = ArrayRef(), + ArrayRef Ranges = None, bool MatchingInlineAsm = false) { if (MatchingInlineAsm) return true; return Parser.Error(L, Msg, Ranges); @@ -2204,7 +2204,7 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, assert(!Operands.empty() && "Unexpect empty operand list!"); X86Operand *Op = static_cast(Operands[0]); assert(Op->isToken() && "Leading operand should always be a mnemonic!"); - ArrayRef EmptyRanges = ArrayRef(); + ArrayRef EmptyRanges = None; // First, handle aliases that expand to multiple instructions. // FIXME: This should be replaced with a real .td file alias mechanism. diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index c6115e3e91..ec10751202 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1483,7 +1483,7 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) { Module *M = II->getParent()->getParent()->getParent(); Function *F = Intrinsic::getDeclaration(M, Intrinsic::donothing); InvokeInst::Create(F, II->getNormalDest(), II->getUnwindDest(), - ArrayRef(), "", II->getParent()); + None, "", II->getParent()); } return EraseInstFromFunction(MI); } diff --git a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index e3d51d5d74..43e2e20035 100644 --- a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -1472,8 +1472,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) { CallInst *NewCall = CallInst::Create(getReleaseCallee(F.getParent()), Call->getArgOperand(0), "", Call); - NewCall->setMetadata(ImpreciseReleaseMDKind, - MDNode::get(C, ArrayRef())); + NewCall->setMetadata(ImpreciseReleaseMDKind, MDNode::get(C, None)); DEBUG(dbgs() << "Replacing autorelease{,RV}(x) with objc_release(x) " "since x is otherwise unused.\nOld: " << *Call << "\nNew: " diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index b5941bdf24..544c5eed7e 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -57,7 +57,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags, return VM[V] = const_cast(V); // Create a dummy node in case we have a metadata cycle. - MDNode *Dummy = MDNode::getTemporary(V->getContext(), ArrayRef()); + MDNode *Dummy = MDNode::getTemporary(V->getContext(), None); VM[V] = Dummy; // Check all operands to see if any need to be remapped. diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index b00b50e761..2250712a8e 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1231,7 +1231,7 @@ InnerLoopVectorizer::createEmptyLoop(LoopVectorizationLegality *Legal) { // Mark the old scalar loop with metadata that tells us not to vectorize this // loop again if we run into it. - MDNode *MD = MDNode::get(OldBasicBlock->getContext(), ArrayRef()); + MDNode *MD = MDNode::get(OldBasicBlock->getContext(), None); OldBasicBlock->getTerminator()->setMetadata(AlreadyVectorizedMDName, MD); // Some loops have a single integer induction variable, while other loops -- cgit v1.2.3-70-g09d2