Subzero: Change llvm::OwningPtr to C++11's std::unique_ptr. While I'm at it, normalize the #include order: 1. C++ library headers 2. LLVM headers 3. Subzero headers A blank line between each group. Each group sorted alphabetically, case-insensitive. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930 R=jfb@chromium.org, jvoung@chromium.org Review URL: https://codereview.chromium.org/622443002
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp index d2c83ab..b4c7aca 100644 --- a/src/IceCfg.cpp +++ b/src/IceCfg.cpp
@@ -26,7 +26,7 @@ Cfg::Cfg(GlobalContext *Ctx) : Ctx(Ctx), FunctionName(""), ReturnType(IceType_void), IsInternalLinkage(false), HasError(false), ErrorMessage(""), Entry(NULL), - NextInstNumber(1), Live(NULL), + NextInstNumber(1), Live(nullptr), Target(TargetLowering::createLowering(Ctx->getTargetArch(), this)), VMetadata(new VariablesMetadata(this)), TargetAssembler(
diff --git a/src/IceCfg.h b/src/IceCfg.h index 1de7795..5a4c4a1 100644 --- a/src/IceCfg.h +++ b/src/IceCfg.h
@@ -15,15 +15,15 @@ #ifndef SUBZERO_SRC_ICECFG_H #define SUBZERO_SRC_ICECFG_H -#include "IceDefs.h" -#include "IceTypes.h" +#include <memory> + +#include "llvm/Support/Allocator.h" #include "assembler.h" #include "IceClFlags.h" +#include "IceDefs.h" #include "IceGlobalContext.h" - -#include "llvm/ADT/OwningPtr.h" -#include "llvm/Support/Allocator.h" +#include "IceTypes.h" namespace Ice { @@ -172,10 +172,10 @@ VarList Variables; VarList Args; // subset of Variables, in argument order VarList ImplicitArgs; // subset of Variables - llvm::OwningPtr<Liveness> Live; - llvm::OwningPtr<TargetLowering> Target; - llvm::OwningPtr<VariablesMetadata> VMetadata; - llvm::OwningPtr<Assembler> TargetAssembler; + std::unique_ptr<Liveness> Live; + std::unique_ptr<TargetLowering> Target; + std::unique_ptr<VariablesMetadata> VMetadata; + std::unique_ptr<Assembler> TargetAssembler; // CurrentNode is maintained during dumping/emitting just for // validating Variable::DefNode. Normally, a traversal over
diff --git a/src/IceConverter.cpp b/src/IceConverter.cpp index 9910f06..9d59c56 100644 --- a/src/IceConverter.cpp +++ b/src/IceConverter.cpp
@@ -11,6 +11,16 @@ // //===----------------------------------------------------------------------===// +#include <iostream> + +#include "llvm/IR/Constant.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" + #include "IceCfg.h" #include "IceCfgNode.h" #include "IceClFlags.h" @@ -23,16 +33,6 @@ #include "IceTypes.h" #include "IceTypeConverter.h" -#include "llvm/IR/Constant.h" -#include "llvm/IR/Constants.h" -#include "llvm/IR/DataLayout.h" -#include "llvm/IR/Instruction.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/IR/Module.h" - -#include <iostream> - using namespace llvm; namespace {
diff --git a/src/IceDefs.h b/src/IceDefs.h index 68f30c7..2555b20 100644 --- a/src/IceDefs.h +++ b/src/IceDefs.h
@@ -16,9 +16,8 @@ #ifndef SUBZERO_SRC_ICEDEFS_H #define SUBZERO_SRC_ICEDEFS_H -#include <stdint.h> // TODO: <cstdint> with C++11 - #include <cassert> +#include <cstdint> #include <cstdio> // snprintf #include <functional> // std::less #include <limits>
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp index 4cca6c9..251635f 100644 --- a/src/IceGlobalContext.cpp +++ b/src/IceGlobalContext.cpp
@@ -15,14 +15,14 @@ #include <ctype.h> // isdigit(), isupper() #include <locale> // locale -#include "IceDefs.h" -#include "IceTypes.h" #include "IceCfg.h" #include "IceClFlags.h" +#include "IceDefs.h" #include "IceGlobalContext.h" #include "IceOperand.h" #include "IceTargetLowering.h" #include "IceTimerTree.h" +#include "IceTypes.h" namespace Ice {
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h index 3c53773..8dca08f 100644 --- a/src/IceGlobalContext.h +++ b/src/IceGlobalContext.h
@@ -15,7 +15,8 @@ #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H #define SUBZERO_SRC_ICEGLOBALCONTEXT_H -#include "llvm/ADT/OwningPtr.h" +#include <memory> + #include "llvm/Support/Allocator.h" #include "llvm/Support/raw_ostream.h" @@ -161,7 +162,7 @@ llvm::BumpPtrAllocator Allocator; VerboseMask VMask; - llvm::OwningPtr<class ConstantPool> ConstPool; + std::unique_ptr<class ConstantPool> ConstPool; Intrinsics IntrinsicsInfo; const TargetArch Arch; const OptLevel Opt; @@ -171,7 +172,7 @@ RandomNumberGenerator RNG; CodeStats StatsFunction; CodeStats StatsCumulative; - llvm::OwningPtr<class TimerStack> Timers; + std::unique_ptr<class TimerStack> Timers; GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION;
diff --git a/src/IceLiveness.cpp b/src/IceLiveness.cpp index e2703c2..9b58b43 100644 --- a/src/IceLiveness.cpp +++ b/src/IceLiveness.cpp
@@ -19,9 +19,9 @@ // //===----------------------------------------------------------------------===// -#include "IceDefs.h" #include "IceCfg.h" #include "IceCfgNode.h" +#include "IceDefs.h" #include "IceInst.h" #include "IceLiveness.h" #include "IceOperand.h"
diff --git a/src/IceRNG.h b/src/IceRNG.h index 4d6c397..4260b4e 100644 --- a/src/IceRNG.h +++ b/src/IceRNG.h
@@ -14,7 +14,8 @@ #ifndef SUBZERO_SRC_ICERNG_H #define SUBZERO_SRC_ICERNG_H -#include <stdint.h> +#include <cstdint> + #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h"
diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp index 76d3473..6dc46b1 100644 --- a/src/IceTargetLowering.cpp +++ b/src/IceTargetLowering.cpp
@@ -15,6 +15,8 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/CommandLine.h" + #include "assembler_ia32.h" #include "IceCfg.h" // setError() #include "IceCfgNode.h" @@ -23,8 +25,6 @@ #include "IceTargetLowering.h" #include "IceTargetLoweringX8632.h" -#include "llvm/Support/CommandLine.h" - namespace Ice { namespace {
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h index 37e14df..1995124 100644 --- a/src/IceTargetLowering.h +++ b/src/IceTargetLowering.h
@@ -19,9 +19,8 @@ #define SUBZERO_SRC_ICETARGETLOWERING_H #include "IceDefs.h" -#include "IceTypes.h" - #include "IceInst.h" // for the names of the Inst subtypes +#include "IceTypes.h" namespace Ice {
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp index b9d3170..9d9f6dc 100644 --- a/src/IceTargetLoweringX8632.cpp +++ b/src/IceTargetLoweringX8632.cpp
@@ -15,19 +15,20 @@ // //===----------------------------------------------------------------------===// -#include "IceDefs.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/MathExtras.h" + #include "IceCfg.h" #include "IceCfgNode.h" #include "IceClFlags.h" +#include "IceDefs.h" #include "IceInstX8632.h" #include "IceOperand.h" #include "IceRegistersX8632.h" #include "IceTargetLoweringX8632.def" #include "IceTargetLoweringX8632.h" #include "IceUtils.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/Support/MathExtras.h" -#include "llvm/Support/CommandLine.h" namespace Ice {
diff --git a/src/IceTargetLoweringX8632.h b/src/IceTargetLoweringX8632.h index 1533ae3..37f7fef 100644 --- a/src/IceTargetLoweringX8632.h +++ b/src/IceTargetLoweringX8632.h
@@ -16,11 +16,11 @@ #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H #define SUBZERO_SRC_ICETARGETLOWERINGX8632_H -#include "IceDefs.h" -#include "IceTargetLowering.h" #include "assembler_ia32.h" +#include "IceDefs.h" #include "IceInstX8632.h" #include "IceRegistersX8632.h" +#include "IceTargetLowering.h" namespace Ice {
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp index 91dcfd4..9cc97a0 100644 --- a/src/IceTranslator.cpp +++ b/src/IceTranslator.cpp
@@ -12,16 +12,18 @@ // //===----------------------------------------------------------------------===// +#include <iostream> +#include <memory> + +#include "llvm/IR/Constant.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/Module.h" + #include "IceCfg.h" #include "IceClFlags.h" #include "IceDefs.h" #include "IceTargetLowering.h" #include "IceTranslator.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Constant.h" -#include "llvm/IR/Constants.h" - -#include <iostream> using namespace Ice; @@ -96,7 +98,7 @@ } void Translator::convertGlobals(llvm::Module *Mod) { - llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering( + std::unique_ptr<TargetGlobalInitLowering> GlobalLowering( TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); for (llvm::Module::const_global_iterator I = Mod->global_begin(), E = Mod->global_end();
diff --git a/src/IceTranslator.h b/src/IceTranslator.h index b5adbdc..9480fb0 100644 --- a/src/IceTranslator.h +++ b/src/IceTranslator.h
@@ -15,7 +15,7 @@ #ifndef SUBZERO_SRC_ICETRANSLATOR_H #define SUBZERO_SRC_ICETRANSLATOR_H -#include "llvm/ADT/OwningPtr.h" +#include <memory> namespace llvm { class Module; @@ -75,7 +75,7 @@ // object, change all Constant related functions to use // GlobalContext instead of Cfg, and then make emitConstantPool use // that. - llvm::OwningPtr<Cfg> Func; + std::unique_ptr<Cfg> Func; private: Translator(const Translator &) LLVM_DELETED_FUNCTION;
diff --git a/src/IceTypeConverter.cpp b/src/IceTypeConverter.cpp index 078c664b..6e8138f 100644 --- a/src/IceTypeConverter.cpp +++ b/src/IceTypeConverter.cpp
@@ -12,9 +12,10 @@ // //===----------------------------------------------------------------------===// -#include "IceTypeConverter.h" #include "llvm/Support/raw_ostream.h" +#include "IceTypeConverter.h" + namespace Ice { TypeConverter::TypeConverter(llvm::LLVMContext &Context) {
diff --git a/src/IceTypeConverter.h b/src/IceTypeConverter.h index f436e43..089c923 100644 --- a/src/IceTypeConverter.h +++ b/src/IceTypeConverter.h
@@ -15,9 +15,10 @@ #ifndef SUBZERO_SRC_ICETYPECONVERTER_H #define SUBZERO_SRC_ICETYPECONVERTER_H +#include "llvm/IR/DerivedTypes.h" + #include "IceDefs.h" #include "IceTypes.h" -#include "llvm/IR/DerivedTypes.h" namespace llvm { class LLVMContext;
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp index e1925df..c160daa 100644 --- a/src/PNaClTranslator.cpp +++ b/src/PNaClTranslator.cpp
@@ -12,14 +12,10 @@ // //===----------------------------------------------------------------------===// -#include "IceCfg.h" -#include "IceCfgNode.h" -#include "IceClFlags.h" -#include "IceDefs.h" -#include "IceInst.h" -#include "IceOperand.h" -#include "IceTypeConverter.h" -#include "PNaClTranslator.h" +#include <cassert> +#include <memory> +#include <vector> + #include "llvm/Analysis/NaCl/PNaClABIProps.h" #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h" #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h" @@ -34,8 +30,14 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Support/ValueHandle.h" -#include <vector> -#include <cassert> +#include "IceCfg.h" +#include "IceCfgNode.h" +#include "IceClFlags.h" +#include "IceDefs.h" +#include "IceInst.h" +#include "IceOperand.h" +#include "IceTypeConverter.h" +#include "PNaClTranslator.h" using namespace llvm; @@ -252,7 +254,7 @@ // The translator associated with the parser. Ice::Translator &Translator; // The parsed module. - OwningPtr<Module> Mod; + std::unique_ptr<Module> Mod; // The data layout to use. DataLayout DL; // The bitcode header.
diff --git a/src/PNaClTranslator.h b/src/PNaClTranslator.h index 87284fa..464d65b 100644 --- a/src/PNaClTranslator.h +++ b/src/PNaClTranslator.h
@@ -15,9 +15,10 @@ #ifndef SUBZERO_SRC_PNACLTRANSLATOR_H #define SUBZERO_SRC_PNACLTRANSLATOR_H -#include "IceTranslator.h" #include <string> +#include "IceTranslator.h" + namespace Ice { class PNaClTranslator : public Translator {
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp index 7f1fc38..f95c02e 100644 --- a/src/llvm2ice.cpp +++ b/src/llvm2ice.cpp
@@ -13,10 +13,8 @@ // //===----------------------------------------------------------------------===// -#include "IceCfg.h" -#include "IceClFlags.h" -#include "IceConverter.h" -#include "PNaClTranslator.h" +#include <fstream> +#include <iostream> #include "llvm/IR/LLVMContext.h" #include "llvm/IRReader/IRReader.h" @@ -24,8 +22,10 @@ #include "llvm/Support/raw_os_ostream.h" #include "llvm/Support/SourceMgr.h" -#include <fstream> -#include <iostream> +#include "IceCfg.h" +#include "IceClFlags.h" +#include "IceConverter.h" +#include "PNaClTranslator.h" using namespace llvm;