Explorar o código

Fix Clang-tidy modernize-use-nullptr warnings in examples and include directories; other minor cleanups.

Patch by Eugene Zelenko!

Differential Revision: http://reviews.llvm.org/D13172

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248811 91177308-0d34-0410-b5e6-96231b3b80d8
Hans Wennborg %!s(int64=10) %!d(string=hai) anos
pai
achega
d16725c31f

+ 3 - 7
examples/BrainF/BrainF.cpp

@@ -29,6 +29,7 @@
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Intrinsics.h"
 #include <iostream>
 #include <iostream>
+
 using namespace llvm;
 using namespace llvm;
 
 
 //Set the constants for naming
 //Set the constants for naming
@@ -44,7 +45,7 @@ Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
   comflag  = cf;
   comflag  = cf;
 
 
   header(Context);
   header(Context);
-  readloop(0, 0, 0, Context);
+  readloop(nullptr, nullptr, nullptr, Context);
   delete builder;
   delete builder;
   return module;
   return module;
 }
 }
@@ -68,7 +69,6 @@ void BrainF::header(LLVMContext& C) {
     getOrInsertFunction("putchar", IntegerType::getInt32Ty(C),
     getOrInsertFunction("putchar", IntegerType::getInt32Ty(C),
                         IntegerType::getInt32Ty(C), NULL));
                         IntegerType::getInt32Ty(C), NULL));
 
 
-
   //Function header
   //Function header
 
 
   //define void @brainf()
   //define void @brainf()
@@ -85,7 +85,7 @@ void BrainF::header(LLVMContext& C) {
   Constant* allocsize = ConstantExpr::getSizeOf(Int8Ty);
   Constant* allocsize = ConstantExpr::getSizeOf(Int8Ty);
   allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy);
   allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy);
   ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, 
   ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, 
-                                   NULL, "arr");
+                                   nullptr, "arr");
   BB->getInstList().push_back(cast<Instruction>(ptr_arr));
   BB->getInstList().push_back(cast<Instruction>(ptr_arr));
 
 
   //call void @llvm.memset.p0i8.i32(i8 *%arr, i8 0, i32 %d, i32 1, i1 0)
   //call void @llvm.memset.p0i8.i32(i8 *%arr, i8 0, i32 %d, i32 1, i1 0)
@@ -114,8 +114,6 @@ void BrainF::header(LLVMContext& C) {
                                ConstantInt::get(C, APInt(32, memtotal/2)),
                                ConstantInt::get(C, APInt(32, memtotal/2)),
                                headreg);
                                headreg);
 
 
-
-
   //Function footer
   //Function footer
 
 
   //brainf.end:
   //brainf.end:
@@ -127,8 +125,6 @@ void BrainF::header(LLVMContext& C) {
   //ret void
   //ret void
   ReturnInst::Create(C, endbb);
   ReturnInst::Create(C, endbb);
 
 
-
-
   //Error block for array out of bounds
   //Error block for array out of bounds
   if (comflag & flag_arraybounds)
   if (comflag & flag_arraybounds)
   {
   {

+ 2 - 2
examples/Fibonacci/fibonacci.cpp

@@ -33,6 +33,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
+
 using namespace llvm;
 using namespace llvm;
 
 
 static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
 static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
@@ -41,7 +42,7 @@ static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
   Function *FibF =
   Function *FibF =
     cast<Function>(M->getOrInsertFunction("fib", Type::getInt32Ty(Context),
     cast<Function>(M->getOrInsertFunction("fib", Type::getInt32Ty(Context),
                                           Type::getInt32Ty(Context),
                                           Type::getInt32Ty(Context),
-                                          (Type *)0));
+                                          nullptr));
 
 
   // Add a basic block to the function.
   // Add a basic block to the function.
   BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", FibF);
   BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", FibF);
@@ -87,7 +88,6 @@ static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
   return FibF;
   return FibF;
 }
 }
 
 
-
 int main(int argc, char **argv) {
 int main(int argc, char **argv) {
   int n = argc > 1 ? atol(argv[1]) : 24;
   int n = argc > 1 ? atol(argv[1]) : 24;
 
 

+ 2 - 3
examples/HowToUseJIT/HowToUseJIT.cpp

@@ -65,7 +65,7 @@ int main() {
   Function *Add1F =
   Function *Add1F =
     cast<Function>(M->getOrInsertFunction("add1", Type::getInt32Ty(Context),
     cast<Function>(M->getOrInsertFunction("add1", Type::getInt32Ty(Context),
                                           Type::getInt32Ty(Context),
                                           Type::getInt32Ty(Context),
-                                          (Type *)0));
+                                          nullptr));
 
 
   // Add a basic block to the function. As before, it automatically inserts
   // Add a basic block to the function. As before, it automatically inserts
   // because of the last argument.
   // because of the last argument.
@@ -91,12 +91,11 @@ int main() {
 
 
   // Now, function add1 is ready.
   // Now, function add1 is ready.
 
 
-
   // Now we're going to create function `foo', which returns an int and takes no
   // Now we're going to create function `foo', which returns an int and takes no
   // arguments.
   // arguments.
   Function *FooF =
   Function *FooF =
     cast<Function>(M->getOrInsertFunction("foo", Type::getInt32Ty(Context),
     cast<Function>(M->getOrInsertFunction("foo", Type::getInt32Ty(Context),
-                                          (Type *)0));
+                                          nullptr));
 
 
   // Add a basic block to the FooF function.
   // Add a basic block to the FooF function.
   BB = BasicBlock::Create(Context, "EntryBlock", FooF);
   BB = BasicBlock::Create(Context, "EntryBlock", FooF);

+ 1 - 1
examples/Kaleidoscope/Chapter2/toy.cpp

@@ -53,7 +53,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 

+ 3 - 1
examples/Kaleidoscope/Chapter3/toy.cpp

@@ -8,6 +8,7 @@
 #include <map>
 #include <map>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
+
 using namespace llvm;
 using namespace llvm;
 
 
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
@@ -58,7 +59,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -193,6 +194,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
   fprintf(stderr, "Error: %s\n", Str);
   fprintf(stderr, "Error: %s\n", Str);
   return nullptr;
   return nullptr;
 }
 }
+
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
   Error(Str);
   Error(Str);
   return nullptr;
   return nullptr;

+ 2 - 1
examples/Kaleidoscope/Chapter4/toy.cpp

@@ -65,7 +65,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -200,6 +200,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
   fprintf(stderr, "Error: %s\n", Str);
   fprintf(stderr, "Error: %s\n", Str);
   return nullptr;
   return nullptr;
 }
 }
+
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
   Error(Str);
   Error(Str);
   return nullptr;
   return nullptr;

+ 2 - 1
examples/Kaleidoscope/Chapter5/toy.cpp

@@ -82,7 +82,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -242,6 +242,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
   fprintf(stderr, "Error: %s\n", Str);
   fprintf(stderr, "Error: %s\n", Str);
   return nullptr;
   return nullptr;
 }
 }
+
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
   Error(Str);
   Error(Str);
   return nullptr;
   return nullptr;

+ 2 - 1
examples/Kaleidoscope/Chapter6/toy.cpp

@@ -90,7 +90,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -275,6 +275,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
   fprintf(stderr, "Error: %s\n", Str);
   fprintf(stderr, "Error: %s\n", Str);
   return nullptr;
   return nullptr;
 }
 }
+
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
   Error(Str);
   Error(Str);
   return nullptr;
   return nullptr;

+ 3 - 2
examples/Kaleidoscope/Chapter7/toy.cpp

@@ -95,7 +95,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -294,6 +294,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
   fprintf(stderr, "Error: %s\n", Str);
   fprintf(stderr, "Error: %s\n", Str);
   return nullptr;
   return nullptr;
 }
 }
+
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
   Error(Str);
   Error(Str);
   return nullptr;
   return nullptr;
@@ -703,7 +704,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
                                           const std::string &VarName) {
                                           const std::string &VarName) {
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                    TheFunction->getEntryBlock().begin());
                    TheFunction->getEntryBlock().begin());
-  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
                            VarName.c_str());
                            VarName.c_str());
 }
 }
 
 

+ 3 - 2
examples/Kaleidoscope/Chapter8/toy.cpp

@@ -163,7 +163,7 @@ static int gettok() {
       LastChar = advance();
       LastChar = advance();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -431,6 +431,7 @@ std::unique_ptr<ExprAST> Error(const char *Str) {
   fprintf(stderr, "Error: %s\n", Str);
   fprintf(stderr, "Error: %s\n", Str);
   return nullptr;
   return nullptr;
 }
 }
+
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
 std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
   Error(Str);
   Error(Str);
   return nullptr;
   return nullptr;
@@ -886,7 +887,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
                                           const std::string &VarName) {
                                           const std::string &VarName) {
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                    TheFunction->getEntryBlock().begin());
                    TheFunction->getEntryBlock().begin());
-  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
                            VarName.c_str());
                            VarName.c_str());
 }
 }
 
 

+ 5 - 7
examples/Kaleidoscope/Orc/fully_lazy/toy.cpp

@@ -87,7 +87,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -387,7 +387,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
     return ErrorU<ForExprAST>("expected '=' after for");
     return ErrorU<ForExprAST>("expected '=' after for");
   getNextToken();  // eat '='.
   getNextToken();  // eat '='.
 
 
-
   auto Start = ParseExpression();
   auto Start = ParseExpression();
   if (!Start)
   if (!Start)
     return nullptr;
     return nullptr;
@@ -748,7 +747,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
                                           const std::string &VarName) {
                                           const std::string &VarName) {
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                  TheFunction->getEntryBlock().begin());
                  TheFunction->getEntryBlock().begin());
-  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
                            VarName.c_str());
                            VarName.c_str());
 }
 }
 
 
@@ -760,7 +759,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
   // Look this variable up in the function.
   // Look this variable up in the function.
   Value *V = C.NamedValues[Name];
   Value *V = C.NamedValues[Name];
 
 
-  if (V == 0)
+  if (!V)
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
 
 
   // Load the value.
   // Load the value.
@@ -960,7 +959,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
 
 
   // Compute the end condition.
   // Compute the end condition.
   Value *EndCond = End->IRGen(C);
   Value *EndCond = End->IRGen(C);
-  if (EndCond == 0) return EndCond;
+  if (!EndCond) return nullptr;
 
 
   // Reload, increment, and restore the alloca.  This handles the case where
   // Reload, increment, and restore the alloca.  This handles the case where
   // the body of the loop mutates the variable.
   // the body of the loop mutates the variable.
@@ -988,7 +987,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
   else
   else
     C.NamedValues.erase(VarName);
     C.NamedValues.erase(VarName);
 
 
-
   // for expr always returns 0.0.
   // for expr always returns 0.0.
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
 }
 }
@@ -1236,7 +1234,7 @@ private:
   RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
   RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
     auto DefI = FunctionDefs.find(Name);
     auto DefI = FunctionDefs.find(Name);
     if (DefI == FunctionDefs.end())
     if (DefI == FunctionDefs.end())
-      return 0;
+      return nullptr;
 
 
     // Return the address of the stub.
     // Return the address of the stub.
     // Take the FunctionAST out of the map.
     // Take the FunctionAST out of the map.

+ 4 - 6
examples/Kaleidoscope/Orc/initial/toy.cpp

@@ -86,7 +86,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -386,7 +386,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
     return ErrorU<ForExprAST>("expected '=' after for");
     return ErrorU<ForExprAST>("expected '=' after for");
   getNextToken();  // eat '='.
   getNextToken();  // eat '='.
 
 
-
   auto Start = ParseExpression();
   auto Start = ParseExpression();
   if (!Start)
   if (!Start)
     return nullptr;
     return nullptr;
@@ -747,7 +746,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
                                           const std::string &VarName) {
                                           const std::string &VarName) {
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                  TheFunction->getEntryBlock().begin());
                  TheFunction->getEntryBlock().begin());
-  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
                            VarName.c_str());
                            VarName.c_str());
 }
 }
 
 
@@ -759,7 +758,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
   // Look this variable up in the function.
   // Look this variable up in the function.
   Value *V = C.NamedValues[Name];
   Value *V = C.NamedValues[Name];
 
 
-  if (V == 0)
+  if (!V)
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
 
 
   // Load the value.
   // Load the value.
@@ -959,7 +958,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
 
 
   // Compute the end condition.
   // Compute the end condition.
   Value *EndCond = End->IRGen(C);
   Value *EndCond = End->IRGen(C);
-  if (EndCond == 0) return EndCond;
+  if (!EndCond) return nullptr;
 
 
   // Reload, increment, and restore the alloca.  This handles the case where
   // Reload, increment, and restore the alloca.  This handles the case where
   // the body of the loop mutates the variable.
   // the body of the loop mutates the variable.
@@ -987,7 +986,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
   else
   else
     C.NamedValues.erase(VarName);
     C.NamedValues.erase(VarName);
 
 
-
   // for expr always returns 0.0.
   // for expr always returns 0.0.
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
 }
 }

+ 4 - 6
examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp

@@ -86,7 +86,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -386,7 +386,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
     return ErrorU<ForExprAST>("expected '=' after for");
     return ErrorU<ForExprAST>("expected '=' after for");
   getNextToken();  // eat '='.
   getNextToken();  // eat '='.
 
 
-
   auto Start = ParseExpression();
   auto Start = ParseExpression();
   if (!Start)
   if (!Start)
     return nullptr;
     return nullptr;
@@ -747,7 +746,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
                                           const std::string &VarName) {
                                           const std::string &VarName) {
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                  TheFunction->getEntryBlock().begin());
                  TheFunction->getEntryBlock().begin());
-  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
                            VarName.c_str());
                            VarName.c_str());
 }
 }
 
 
@@ -759,7 +758,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
   // Look this variable up in the function.
   // Look this variable up in the function.
   Value *V = C.NamedValues[Name];
   Value *V = C.NamedValues[Name];
 
 
-  if (V == 0)
+  if (!V)
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
 
 
   // Load the value.
   // Load the value.
@@ -959,7 +958,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
 
 
   // Compute the end condition.
   // Compute the end condition.
   Value *EndCond = End->IRGen(C);
   Value *EndCond = End->IRGen(C);
-  if (EndCond == 0) return EndCond;
+  if (!EndCond) return nullptr;
 
 
   // Reload, increment, and restore the alloca.  This handles the case where
   // Reload, increment, and restore the alloca.  This handles the case where
   // the body of the loop mutates the variable.
   // the body of the loop mutates the variable.
@@ -987,7 +986,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
   else
   else
     C.NamedValues.erase(VarName);
     C.NamedValues.erase(VarName);
 
 
-
   // for expr always returns 0.0.
   // for expr always returns 0.0.
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
 }
 }

+ 5 - 7
examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp

@@ -86,7 +86,7 @@ static int gettok() {
       LastChar = getchar();
       LastChar = getchar();
     } while (isdigit(LastChar) || LastChar == '.');
     } while (isdigit(LastChar) || LastChar == '.');
 
 
-    NumVal = strtod(NumStr.c_str(), 0);
+    NumVal = strtod(NumStr.c_str(), nullptr);
     return tok_number;
     return tok_number;
   }
   }
 
 
@@ -386,7 +386,6 @@ static std::unique_ptr<ForExprAST> ParseForExpr() {
     return ErrorU<ForExprAST>("expected '=' after for");
     return ErrorU<ForExprAST>("expected '=' after for");
   getNextToken();  // eat '='.
   getNextToken();  // eat '='.
 
 
-
   auto Start = ParseExpression();
   auto Start = ParseExpression();
   if (!Start)
   if (!Start)
     return nullptr;
     return nullptr;
@@ -747,7 +746,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
                                           const std::string &VarName) {
                                           const std::string &VarName) {
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
   IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                  TheFunction->getEntryBlock().begin());
                  TheFunction->getEntryBlock().begin());
-  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+  return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), nullptr,
                            VarName.c_str());
                            VarName.c_str());
 }
 }
 
 
@@ -759,7 +758,7 @@ Value *VariableExprAST::IRGen(IRGenContext &C) const {
   // Look this variable up in the function.
   // Look this variable up in the function.
   Value *V = C.NamedValues[Name];
   Value *V = C.NamedValues[Name];
 
 
-  if (V == 0)
+  if (!V)
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
     return ErrorP<Value>("Unknown variable name '" + Name + "'");
 
 
   // Load the value.
   // Load the value.
@@ -959,7 +958,7 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
 
 
   // Compute the end condition.
   // Compute the end condition.
   Value *EndCond = End->IRGen(C);
   Value *EndCond = End->IRGen(C);
-  if (EndCond == 0) return EndCond;
+  if (!EndCond) return nullptr;
 
 
   // Reload, increment, and restore the alloca.  This handles the case where
   // Reload, increment, and restore the alloca.  This handles the case where
   // the body of the loop mutates the variable.
   // the body of the loop mutates the variable.
@@ -987,7 +986,6 @@ Value *ForExprAST::IRGen(IRGenContext &C) const {
   else
   else
     C.NamedValues.erase(VarName);
     C.NamedValues.erase(VarName);
 
 
-
   // for expr always returns 0.0.
   // for expr always returns 0.0.
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
   return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
 }
 }
@@ -1223,7 +1221,7 @@ private:
   RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
   RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
     auto DefI = FunctionDefs.find(Name);
     auto DefI = FunctionDefs.find(Name);
     if (DefI == FunctionDefs.end())
     if (DefI == FunctionDefs.end())
-      return 0;
+      return nullptr;
 
 
     // Take the FunctionAST out of the map.
     // Take the FunctionAST out of the map.
     auto FnAST = std::move(DefI->second);
     auto FnAST = std::move(DefI->second);

+ 8 - 7
examples/ParallelJIT/ParallelJIT.cpp

@@ -28,6 +28,7 @@
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TargetSelect.h"
 #include <iostream>
 #include <iostream>
 #include <pthread.h>
 #include <pthread.h>
+
 using namespace llvm;
 using namespace llvm;
 
 
 static Function* createAdd1(Module *M) {
 static Function* createAdd1(Module *M) {
@@ -38,7 +39,7 @@ static Function* createAdd1(Module *M) {
     cast<Function>(M->getOrInsertFunction("add1",
     cast<Function>(M->getOrInsertFunction("add1",
                                           Type::getInt32Ty(M->getContext()),
                                           Type::getInt32Ty(M->getContext()),
                                           Type::getInt32Ty(M->getContext()),
                                           Type::getInt32Ty(M->getContext()),
-                                          (Type *)0));
+                                          nullptr));
 
 
   // Add a basic block to the function. As before, it automatically inserts
   // Add a basic block to the function. As before, it automatically inserts
   // because of the last argument.
   // because of the last argument.
@@ -69,7 +70,7 @@ static Function *CreateFibFunction(Module *M) {
     cast<Function>(M->getOrInsertFunction("fib",
     cast<Function>(M->getOrInsertFunction("fib",
                                           Type::getInt32Ty(M->getContext()),
                                           Type::getInt32Ty(M->getContext()),
                                           Type::getInt32Ty(M->getContext()),
                                           Type::getInt32Ty(M->getContext()),
-                                          (Type *)0));
+                                          nullptr));
 
 
   // Add a basic block to the function.
   // Add a basic block to the function.
   BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", FibF);
   BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", FibF);
@@ -129,10 +130,10 @@ public:
     n = 0;
     n = 0;
     waitFor = 0;
     waitFor = 0;
 
 
-    int result = pthread_cond_init( &condition, NULL );
+    int result = pthread_cond_init( &condition, nullptr );
     assert( result == 0 );
     assert( result == 0 );
 
 
-    result = pthread_mutex_init( &mutex, NULL );
+    result = pthread_mutex_init( &mutex, nullptr );
     assert( result == 0 );
     assert( result == 0 );
   }
   }
 
 
@@ -261,21 +262,21 @@ int main() {
   struct threadParams fib2 = { EE, fibF, 42 };
   struct threadParams fib2 = { EE, fibF, 42 };
 
 
   pthread_t add1Thread;
   pthread_t add1Thread;
-  int result = pthread_create( &add1Thread, NULL, callFunc, &add1 );
+  int result = pthread_create( &add1Thread, nullptr, callFunc, &add1 );
   if ( result != 0 ) {
   if ( result != 0 ) {
           std::cerr << "Could not create thread" << std::endl;
           std::cerr << "Could not create thread" << std::endl;
           return 1;
           return 1;
   }
   }
 
 
   pthread_t fibThread1;
   pthread_t fibThread1;
-  result = pthread_create( &fibThread1, NULL, callFunc, &fib1 );
+  result = pthread_create( &fibThread1, nullptr, callFunc, &fib1 );
   if ( result != 0 ) {
   if ( result != 0 ) {
           std::cerr << "Could not create thread" << std::endl;
           std::cerr << "Could not create thread" << std::endl;
           return 1;
           return 1;
   }
   }
 
 
   pthread_t fibThread2;
   pthread_t fibThread2;
-  result = pthread_create( &fibThread2, NULL, callFunc, &fib2 );
+  result = pthread_create( &fibThread2, nullptr, callFunc, &fib2 );
   if ( result != 0 ) {
   if ( result != 0 ) {
           std::cerr << "Could not create thread" << std::endl;
           std::cerr << "Could not create thread" << std::endl;
           return 1;
           return 1;

+ 6 - 6
include/llvm/ADT/ImmutableList.h

@@ -28,7 +28,7 @@ class ImmutableListImpl : public FoldingSetNode {
   T Head;
   T Head;
   const ImmutableListImpl* Tail;
   const ImmutableListImpl* Tail;
 
 
-  ImmutableListImpl(const T& head, const ImmutableListImpl* tail = 0)
+  ImmutableListImpl(const T& head, const ImmutableListImpl* tail = nullptr)
     : Head(head), Tail(tail) {}
     : Head(head), Tail(tail) {}
 
 
   friend class ImmutableListFactory<T>;
   friend class ImmutableListFactory<T>;
@@ -72,7 +72,7 @@ public:
   // This constructor should normally only be called by ImmutableListFactory<T>.
   // This constructor should normally only be called by ImmutableListFactory<T>.
   // There may be cases, however, when one needs to extract the internal pointer
   // There may be cases, however, when one needs to extract the internal pointer
   // and reconstruct a list object from that pointer.
   // and reconstruct a list object from that pointer.
-  ImmutableList(const ImmutableListImpl<T>* x = 0) : X(x) {}
+  ImmutableList(const ImmutableListImpl<T>* x = nullptr) : X(x) {}
 
 
   const ImmutableListImpl<T>* getInternalPointer() const {
   const ImmutableListImpl<T>* getInternalPointer() const {
     return X;
     return X;
@@ -81,7 +81,7 @@ public:
   class iterator {
   class iterator {
     const ImmutableListImpl<T>* L;
     const ImmutableListImpl<T>* L;
   public:
   public:
-    iterator() : L(0) {}
+    iterator() : L(nullptr) {}
     iterator(ImmutableList l) : L(l.getInternalPointer()) {}
     iterator(ImmutableList l) : L(l.getInternalPointer()) {}
 
 
     iterator& operator++() { L = L->getTail(); return *this; }
     iterator& operator++() { L = L->getTail(); return *this; }
@@ -128,7 +128,7 @@ public:
   /// getTail - Returns the tail of the list, which is another (possibly empty)
   /// getTail - Returns the tail of the list, which is another (possibly empty)
   ///  ImmutableList.
   ///  ImmutableList.
   ImmutableList getTail() {
   ImmutableList getTail() {
-    return X ? X->getTail() : 0;
+    return X ? X->getTail() : nullptr;
   }
   }
 
 
   void Profile(FoldingSetNodeID& ID) const {
   void Profile(FoldingSetNodeID& ID) const {
@@ -190,7 +190,7 @@ public:
   }
   }
 
 
   ImmutableList<T> getEmptyList() const {
   ImmutableList<T> getEmptyList() const {
-    return ImmutableList<T>(0);
+    return ImmutableList<T>(nullptr);
   }
   }
 
 
   ImmutableList<T> create(const T& X) {
   ImmutableList<T> create(const T& X) {
@@ -226,4 +226,4 @@ struct isPodLike<ImmutableList<T> > { static const bool value = true; };
 
 
 } // end llvm namespace
 } // end llvm namespace
 
 
-#endif
+#endif // LLVM_ADT_IMMUTABLELIST_H

+ 5 - 2
include/llvm/ADT/ImmutableMap.h

@@ -78,9 +78,11 @@ public:
   explicit ImmutableMap(const TreeTy* R) : Root(const_cast<TreeTy*>(R)) {
   explicit ImmutableMap(const TreeTy* R) : Root(const_cast<TreeTy*>(R)) {
     if (Root) { Root->retain(); }
     if (Root) { Root->retain(); }
   }
   }
+
   ImmutableMap(const ImmutableMap &X) : Root(X.Root) {
   ImmutableMap(const ImmutableMap &X) : Root(X.Root) {
     if (Root) { Root->retain(); }
     if (Root) { Root->retain(); }
   }
   }
+
   ImmutableMap &operator=(const ImmutableMap &X) {
   ImmutableMap &operator=(const ImmutableMap &X) {
     if (Root != X.Root) {
     if (Root != X.Root) {
       if (X.Root) { X.Root->retain(); }
       if (X.Root) { X.Root->retain(); }
@@ -89,6 +91,7 @@ public:
     }
     }
     return *this;
     return *this;
   }
   }
+
   ~ImmutableMap() {
   ~ImmutableMap() {
     if (Root) { Root->release(); }
     if (Root) { Root->release(); }
   }
   }
@@ -377,7 +380,7 @@ public:
       if (T) return &T->getValue().second;
       if (T) return &T->getValue().second;
     }
     }
 
 
-    return 0;
+    return nullptr;
   }
   }
 
 
   /// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
   /// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
@@ -402,4 +405,4 @@ public:
 
 
 } // end namespace llvm
 } // end namespace llvm
 
 
-#endif
+#endif // LLVM_ADT_IMMUTABLEMAP_H

+ 2 - 2
include/llvm/ADT/IntrusiveRefCntPtr.h

@@ -154,7 +154,7 @@ public:
 
 
     template <class X>
     template <class X>
     IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.get()) {
     IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.get()) {
-      S.Obj = 0;
+      S.Obj = nullptr;
     }
     }
 
 
     template <class X>
     template <class X>
@@ -190,7 +190,7 @@ public:
     }
     }
 
 
     void resetWithoutRelease() {
     void resetWithoutRelease() {
-      Obj = 0;
+      Obj = nullptr;
     }
     }
 
 
   private:
   private:

+ 6 - 10
include/llvm/ADT/SparseBitVector.h

@@ -39,7 +39,6 @@ namespace llvm {
 /// etc) do not perform as well in practice as a linked list with this iterator
 /// etc) do not perform as well in practice as a linked list with this iterator
 /// kept up to date.  They are also significantly more memory intensive.
 /// kept up to date.  They are also significantly more memory intensive.
 
 
-
 template <unsigned ElementSize = 128>
 template <unsigned ElementSize = 128>
 struct SparseBitVectorElement
 struct SparseBitVectorElement
   : public ilist_node<SparseBitVectorElement<ElementSize> > {
   : public ilist_node<SparseBitVectorElement<ElementSize> > {
@@ -204,6 +203,7 @@ public:
     BecameZero = allzero;
     BecameZero = allzero;
     return changed;
     return changed;
   }
   }
+
   // Intersect this Element with the complement of RHS and return true if this
   // Intersect this Element with the complement of RHS and return true if this
   // one changed.  BecameZero is set to true if this element became all-zero
   // one changed.  BecameZero is set to true if this element became all-zero
   // bits.
   // bits.
@@ -226,6 +226,7 @@ public:
     BecameZero = allzero;
     BecameZero = allzero;
     return changed;
     return changed;
   }
   }
+
   // Three argument version of intersectWithComplement that intersects
   // Three argument version of intersectWithComplement that intersects
   // RHS1 & ~RHS2 into this element
   // RHS1 & ~RHS2 into this element
   void intersectWithComplement(const SparseBitVectorElement &RHS1,
   void intersectWithComplement(const SparseBitVectorElement &RHS1,
@@ -408,12 +409,13 @@ class SparseBitVector {
       // bitmap.
       // bitmap.
       return AtEnd == RHS.AtEnd && RHS.BitNumber == BitNumber;
       return AtEnd == RHS.AtEnd && RHS.BitNumber == BitNumber;
     }
     }
+
     bool operator!=(const SparseBitVectorIterator &RHS) const {
     bool operator!=(const SparseBitVectorIterator &RHS) const {
       return !(*this == RHS);
       return !(*this == RHS);
     }
     }
-    SparseBitVectorIterator(): BitVector(NULL) {
-    }
 
 
+    SparseBitVectorIterator(): BitVector(nullptr) {
+    }
 
 
     SparseBitVectorIterator(const SparseBitVector<ElementSize> *RHS,
     SparseBitVectorIterator(const SparseBitVector<ElementSize> *RHS,
                             bool end = false):BitVector(RHS) {
                             bool end = false):BitVector(RHS) {
@@ -690,7 +692,6 @@ public:
     return intersectWithComplement(*RHS);
     return intersectWithComplement(*RHS);
   }
   }
 
 
-
   //  Three argument version of intersectWithComplement.
   //  Three argument version of intersectWithComplement.
   //  Result of RHS1 & ~RHS2 is stored into this bitmap.
   //  Result of RHS1 & ~RHS2 is stored into this bitmap.
   void intersectWithComplement(const SparseBitVector<ElementSize> &RHS1,
   void intersectWithComplement(const SparseBitVector<ElementSize> &RHS1,
@@ -749,8 +750,6 @@ public:
         Elements.push_back(NewElement);
         Elements.push_back(NewElement);
         ++Iter1;
         ++Iter1;
       }
       }
-
-    return;
   }
   }
 
 
   void intersectWithComplement(const SparseBitVector<ElementSize> *RHS1,
   void intersectWithComplement(const SparseBitVector<ElementSize> *RHS1,
@@ -885,9 +884,6 @@ operator-(const SparseBitVector<ElementSize> &LHS,
   return Result;
   return Result;
 }
 }
 
 
-
-
-
 // Dump a SparseBitVector to a stream
 // Dump a SparseBitVector to a stream
 template <unsigned ElementSize>
 template <unsigned ElementSize>
 void dump(const SparseBitVector<ElementSize> &LHS, raw_ostream &out) {
 void dump(const SparseBitVector<ElementSize> &LHS, raw_ostream &out) {
@@ -905,4 +901,4 @@ void dump(const SparseBitVector<ElementSize> &LHS, raw_ostream &out) {
 }
 }
 } // end namespace llvm
 } // end namespace llvm
 
 
-#endif
+#endif // LLVM_ADT_SPARSEBITVECTOR_H

+ 4 - 3
include/llvm/IR/IRBuilder.h

@@ -426,7 +426,7 @@ public:
 
 
   /// \brief Create a call to Masked Load intrinsic
   /// \brief Create a call to Masked Load intrinsic
   CallInst *CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask,
   CallInst *CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask,
-                             Value *PassThru = 0, const Twine &Name = "");
+                             Value *PassThru = nullptr, const Twine &Name = "");
 
 
   /// \brief Create a call to Masked Store intrinsic
   /// \brief Create a call to Masked Store intrinsic
   CallInst *CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align,
   CallInst *CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align,
@@ -1745,6 +1745,7 @@ public:
 
 
 // Create wrappers for C Binding types (see CBindingWrapping.h).
 // Create wrappers for C Binding types (see CBindingWrapping.h).
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef)
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef)
-}
 
 
-#endif
+} // end namespace llvm
+
+#endif // LLVM_IR_IRBUILDER_H

+ 4 - 4
include/llvm/IR/InstrTypes.h

@@ -687,7 +687,7 @@ public:
     Value *S,                ///< The pointer value to be casted (operand 0)
     Value *S,                ///< The pointer value to be casted (operand 0)
     Type *Ty,          ///< The type to which cast should be made
     Type *Ty,          ///< The type to which cast should be made
     const Twine &Name = "", ///< Name for the instruction
     const Twine &Name = "", ///< Name for the instruction
-    Instruction *InsertBefore = 0 ///< Place to insert the instruction
+    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
   );
   );
 
 
   /// @brief Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
   /// @brief Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
@@ -700,7 +700,7 @@ public:
     Value *S,                ///< The pointer value to be casted (operand 0)
     Value *S,                ///< The pointer value to be casted (operand 0)
     Type *Ty,          ///< The type to which cast should be made
     Type *Ty,          ///< The type to which cast should be made
     const Twine &Name = "", ///< Name for the instruction
     const Twine &Name = "", ///< Name for the instruction
-    Instruction *InsertBefore = 0 ///< Place to insert the instruction
+    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
   );
   );
 
 
   /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
   /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
@@ -1321,6 +1321,6 @@ protected:
   }
   }
 };
 };
 
 
-} // End llvm namespace
+} // end llvm namespace
 
 
-#endif
+#endif // LLVM_IR_INSTRTYPES_H

+ 5 - 3
include/llvm/IR/Metadata.h

@@ -573,10 +573,12 @@ struct AAMDNodes {
 template<>
 template<>
 struct DenseMapInfo<AAMDNodes> {
 struct DenseMapInfo<AAMDNodes> {
   static inline AAMDNodes getEmptyKey() {
   static inline AAMDNodes getEmptyKey() {
-    return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(), 0, 0);
+    return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(),
+                     nullptr, nullptr);
   }
   }
   static inline AAMDNodes getTombstoneKey() {
   static inline AAMDNodes getTombstoneKey() {
-    return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(), 0, 0);
+    return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(),
+                     nullptr, nullptr);
   }
   }
   static unsigned getHashValue(const AAMDNodes &Val) {
   static unsigned getHashValue(const AAMDNodes &Val) {
     return DenseMapInfo<MDNode *>::getHashValue(Val.TBAA) ^
     return DenseMapInfo<MDNode *>::getHashValue(Val.TBAA) ^
@@ -1219,4 +1221,4 @@ public:
 
 
 } // end llvm namespace
 } // end llvm namespace
 
 
-#endif
+#endif // LLVM_IR_METADATA_H

+ 2 - 2
include/llvm/IR/UseListOrder.h

@@ -34,7 +34,7 @@ struct UseListOrder {
   UseListOrder(const Value *V, const Function *F, size_t ShuffleSize)
   UseListOrder(const Value *V, const Function *F, size_t ShuffleSize)
       : V(V), F(F), Shuffle(ShuffleSize) {}
       : V(V), F(F), Shuffle(ShuffleSize) {}
 
 
-  UseListOrder() : V(0), F(0) {}
+  UseListOrder() : V(nullptr), F(nullptr) {}
   UseListOrder(UseListOrder &&X)
   UseListOrder(UseListOrder &&X)
       : V(X.V), F(X.F), Shuffle(std::move(X.Shuffle)) {}
       : V(X.V), F(X.F), Shuffle(std::move(X.Shuffle)) {}
   UseListOrder &operator=(UseListOrder &&X) {
   UseListOrder &operator=(UseListOrder &&X) {
@@ -53,4 +53,4 @@ typedef std::vector<UseListOrder> UseListOrderStack;
 
 
 } // end namespace llvm
 } // end namespace llvm
 
 
-#endif
+#endif // LLVM_IR_USELISTORDER_H

+ 4 - 4
include/llvm/Support/CrashRecoveryContext.h

@@ -137,7 +137,7 @@ public:
       if (CrashRecoveryContext *context = CrashRecoveryContext::GetCurrent())
       if (CrashRecoveryContext *context = CrashRecoveryContext::GetCurrent())
         return new DERIVED(context, x);
         return new DERIVED(context, x);
     }
     }
-    return 0;
+    return nullptr;
   }
   }
 };
 };
 
 
@@ -195,9 +195,9 @@ public:
   void unregister() {
   void unregister() {
     if (cleanup && !cleanup->cleanupFired)
     if (cleanup && !cleanup->cleanupFired)
       cleanup->getContext()->unregisterCleanup(cleanup);
       cleanup->getContext()->unregisterCleanup(cleanup);
-    cleanup = 0;
+    cleanup = nullptr;
   }
   }
 };
 };
-}
+} // end namespace llvm
 
 
-#endif
+#endif // LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H

+ 3 - 9
include/llvm/Support/Registry.h

@@ -37,7 +37,6 @@ namespace llvm {
     std::unique_ptr<T> instantiate() const { return Ctor(); }
     std::unique_ptr<T> instantiate() const { return Ctor(); }
   };
   };
 
 
-
   /// Traits for registry entries. If using other than SimpleRegistryEntry, it
   /// Traits for registry entries. If using other than SimpleRegistryEntry, it
   /// is necessary to define an alternate traits class.
   /// is necessary to define an alternate traits class.
   template <typename T>
   template <typename T>
@@ -53,7 +52,6 @@ namespace llvm {
     static const char *descof(const entry &Entry) { return Entry.getDesc(); }
     static const char *descof(const entry &Entry) { return Entry.getDesc(); }
   };
   };
 
 
-
   /// A global registry used in conjunction with static constructors to make
   /// A global registry used in conjunction with static constructors to make
   /// pluggable components (like targets or garbage collectors) "just work" when
   /// pluggable components (like targets or garbage collectors) "just work" when
   /// linked with an executable.
   /// linked with an executable.
@@ -102,7 +100,6 @@ namespace llvm {
       }
       }
     };
     };
 
 
-
     /// Iterators for registry entries.
     /// Iterators for registry entries.
     ///
     ///
     class iterator {
     class iterator {
@@ -125,7 +122,6 @@ namespace llvm {
       return iterator_range<iterator>(begin(), end());
       return iterator_range<iterator>(begin(), end());
     }
     }
 
 
-
     /// Abstract base class for registry listeners, which are informed when new
     /// Abstract base class for registry listeners, which are informed when new
     /// entries are added to the registry. Simply subclass and instantiate:
     /// entries are added to the registry. Simply subclass and instantiate:
     ///
     ///
@@ -160,7 +156,7 @@ namespace llvm {
       }
       }
 
 
     public:
     public:
-      listener() : Prev(ListenerTail), Next(0) {
+      listener() : Prev(ListenerTail), Next(nullptr) {
         if (Prev)
         if (Prev)
           Prev->Next = this;
           Prev->Next = this;
         else
         else
@@ -180,7 +176,6 @@ namespace llvm {
       }
       }
     };
     };
 
 
-
     /// A static registration template. Use like such:
     /// A static registration template. Use like such:
     ///
     ///
     ///   Registry<Collector>::Add<FancyGC>
     ///   Registry<Collector>::Add<FancyGC>
@@ -210,7 +205,6 @@ namespace llvm {
     };
     };
 
 
     /// Registry::Parser now lives in llvm/Support/RegistryParser.h.
     /// Registry::Parser now lives in llvm/Support/RegistryParser.h.
-
   };
   };
 
 
   // Since these are defined in a header file, plugins must be sure to export
   // Since these are defined in a header file, plugins must be sure to export
@@ -228,6 +222,6 @@ namespace llvm {
   template <typename T, typename U>
   template <typename T, typename U>
   typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
   typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
 
 
-}
+} // end namespace llvm
 
 
-#endif
+#endif // LLVM_SUPPORT_REGISTRY_H

+ 1 - 48
include/llvm/Support/YAMLTraits.h

@@ -10,7 +10,6 @@
 #ifndef LLVM_SUPPORT_YAMLTRAITS_H
 #ifndef LLVM_SUPPORT_YAMLTRAITS_H
 #define LLVM_SUPPORT_YAMLTRAITS_H
 #define LLVM_SUPPORT_YAMLTRAITS_H
 
 
-
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/Optional.h"
@@ -29,7 +28,6 @@
 namespace llvm {
 namespace llvm {
 namespace yaml {
 namespace yaml {
 
 
-
 /// This class should be specialized by any type that needs to be converted
 /// This class should be specialized by any type that needs to be converted
 /// to/from a YAML mapping.  For example:
 /// to/from a YAML mapping.  For example:
 ///
 ///
@@ -52,7 +50,6 @@ struct MappingTraits {
   // static const bool flow = true;
   // static const bool flow = true;
 };
 };
 
 
-
 /// This class should be specialized by any integral type that converts
 /// This class should be specialized by any integral type that converts
 /// to/from a YAML scalar where there is a one-to-one mapping between
 /// to/from a YAML scalar where there is a one-to-one mapping between
 /// in-memory values and a string in YAML.  For example:
 /// in-memory values and a string in YAML.  For example:
@@ -70,7 +67,6 @@ struct ScalarEnumerationTraits {
   // static void enumeration(IO &io, T &value);
   // static void enumeration(IO &io, T &value);
 };
 };
 
 
-
 /// This class should be specialized by any integer type that is a union
 /// This class should be specialized by any integer type that is a union
 /// of bit values and the YAML representation is a flow sequence of
 /// of bit values and the YAML representation is a flow sequence of
 /// strings.  For example:
 /// strings.  For example:
@@ -88,7 +84,6 @@ struct ScalarBitSetTraits {
   // static void bitset(IO &io, T &value);
   // static void bitset(IO &io, T &value);
 };
 };
 
 
-
 /// This class should be specialized by type that requires custom conversion
 /// This class should be specialized by type that requires custom conversion
 /// to/from a yaml scalar.  For example:
 /// to/from a yaml scalar.  For example:
 ///
 ///
@@ -149,7 +144,6 @@ struct BlockScalarTraits {
   // static StringRef input(StringRef Scalar, void *ctxt, T &Value);
   // static StringRef input(StringRef Scalar, void *ctxt, T &Value);
 };
 };
 
 
-
 /// This class should be specialized by any type that needs to be converted
 /// This class should be specialized by any type that needs to be converted
 /// to/from a YAML sequence.  For example:
 /// to/from a YAML sequence.  For example:
 ///
 ///
@@ -175,7 +169,6 @@ struct SequenceTraits {
   // static const bool flow = true;
   // static const bool flow = true;
 };
 };
 
 
-
 /// This class should be specialized by any type that needs to be converted
 /// This class should be specialized by any type that needs to be converted
 /// to/from a list of YAML documents.
 /// to/from a list of YAML documents.
 template<typename T>
 template<typename T>
@@ -185,7 +178,6 @@ struct DocumentListTraits {
   // static T::value_type& element(IO &io, T &seq, size_t index);
   // static T::value_type& element(IO &io, T &seq, size_t index);
 };
 };
 
 
-
 // Only used by compiler if both template types are the same
 // Only used by compiler if both template types are the same
 template <typename T, T>
 template <typename T, T>
 struct SameType;
 struct SameType;
@@ -194,8 +186,6 @@ struct SameType;
 template <typename T>
 template <typename T>
 struct MissingTrait;
 struct MissingTrait;
 
 
-
-
 // Test if ScalarEnumerationTraits<T> is defined on type T.
 // Test if ScalarEnumerationTraits<T> is defined on type T.
 template <class T>
 template <class T>
 struct has_ScalarEnumerationTraits
 struct has_ScalarEnumerationTraits
@@ -213,7 +203,6 @@ public:
     (sizeof(test<ScalarEnumerationTraits<T> >(nullptr)) == 1);
     (sizeof(test<ScalarEnumerationTraits<T> >(nullptr)) == 1);
 };
 };
 
 
-
 // Test if ScalarBitSetTraits<T> is defined on type T.
 // Test if ScalarBitSetTraits<T> is defined on type T.
 template <class T>
 template <class T>
 struct has_ScalarBitSetTraits
 struct has_ScalarBitSetTraits
@@ -230,7 +219,6 @@ public:
   static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
   static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
 };
 };
 
 
-
 // Test if ScalarTraits<T> is defined on type T.
 // Test if ScalarTraits<T> is defined on type T.
 template <class T>
 template <class T>
 struct has_ScalarTraits
 struct has_ScalarTraits
@@ -252,7 +240,6 @@ public:
       (sizeof(test<ScalarTraits<T>>(nullptr, nullptr, nullptr)) == 1);
       (sizeof(test<ScalarTraits<T>>(nullptr, nullptr, nullptr)) == 1);
 };
 };
 
 
-
 // Test if BlockScalarTraits<T> is defined on type T.
 // Test if BlockScalarTraits<T> is defined on type T.
 template <class T>
 template <class T>
 struct has_BlockScalarTraits
 struct has_BlockScalarTraits
@@ -272,7 +259,6 @@ public:
       (sizeof(test<BlockScalarTraits<T>>(nullptr, nullptr)) == 1);
       (sizeof(test<BlockScalarTraits<T>>(nullptr, nullptr)) == 1);
 };
 };
 
 
-
 // Test if MappingTraits<T> is defined on type T.
 // Test if MappingTraits<T> is defined on type T.
 template <class T>
 template <class T>
 struct has_MappingTraits
 struct has_MappingTraits
@@ -305,8 +291,6 @@ public:
   static bool const value = (sizeof(test<MappingTraits<T> >(nullptr)) == 1);
   static bool const value = (sizeof(test<MappingTraits<T> >(nullptr)) == 1);
 };
 };
 
 
-
-
 // Test if SequenceTraits<T> is defined on type T.
 // Test if SequenceTraits<T> is defined on type T.
 template <class T>
 template <class T>
 struct has_SequenceMethodTraits
 struct has_SequenceMethodTraits
@@ -323,7 +307,6 @@ public:
   static bool const value =  (sizeof(test<SequenceTraits<T> >(nullptr)) == 1);
   static bool const value =  (sizeof(test<SequenceTraits<T> >(nullptr)) == 1);
 };
 };
 
 
-
 // has_FlowTraits<int> will cause an error with some compilers because
 // has_FlowTraits<int> will cause an error with some compilers because
 // it subclasses int.  Using this wrapper only instantiates the
 // it subclasses int.  Using this wrapper only instantiates the
 // real has_FlowTraits only if the template type is a class.
 // real has_FlowTraits only if the template type is a class.
@@ -353,14 +336,11 @@ public:
   static bool const value = sizeof(f<Derived>(nullptr)) == 2;
   static bool const value = sizeof(f<Derived>(nullptr)) == 2;
 };
 };
 
 
-
-
 // Test if SequenceTraits<T> is defined on type T
 // Test if SequenceTraits<T> is defined on type T
 template<typename T>
 template<typename T>
 struct has_SequenceTraits : public std::integral_constant<bool,
 struct has_SequenceTraits : public std::integral_constant<bool,
                                       has_SequenceMethodTraits<T>::value > { };
                                       has_SequenceMethodTraits<T>::value > { };
 
 
-
 // Test if DocumentListTraits<T> is defined on type T
 // Test if DocumentListTraits<T> is defined on type T
 template <class T>
 template <class T>
 struct has_DocumentListTraits
 struct has_DocumentListTraits
@@ -453,7 +433,6 @@ inline bool needsQuotes(StringRef S) {
   return false;
   return false;
 }
 }
 
 
-
 template<typename T>
 template<typename T>
 struct missingTraits : public std::integral_constant<bool,
 struct missingTraits : public std::integral_constant<bool,
                                          !has_ScalarEnumerationTraits<T>::value
                                          !has_ScalarEnumerationTraits<T>::value
@@ -654,8 +633,6 @@ private:
   void  *Ctxt;
   void  *Ctxt;
 };
 };
 
 
-
-
 template<typename T>
 template<typename T>
 typename std::enable_if<has_ScalarEnumerationTraits<T>::value,void>::type
 typename std::enable_if<has_ScalarEnumerationTraits<T>::value,void>::type
 yamlize(IO &io, T &Val, bool) {
 yamlize(IO &io, T &Val, bool) {
@@ -676,7 +653,6 @@ yamlize(IO &io, T &Val, bool) {
   }
   }
 }
 }
 
 
-
 template<typename T>
 template<typename T>
 typename std::enable_if<has_ScalarTraits<T>::value,void>::type
 typename std::enable_if<has_ScalarTraits<T>::value,void>::type
 yamlize(IO &io, T &Val, bool) {
 yamlize(IO &io, T &Val, bool) {
@@ -791,7 +767,6 @@ yamlize(IO &io, T &Seq, bool) {
   }
   }
 }
 }
 
 
-
 template<>
 template<>
 struct ScalarTraits<bool> {
 struct ScalarTraits<bool> {
   static void output(const bool &, void*, llvm::raw_ostream &);
   static void output(const bool &, void*, llvm::raw_ostream &);
@@ -883,8 +858,6 @@ struct ScalarTraits<double> {
   static bool mustQuote(StringRef) { return false; }
   static bool mustQuote(StringRef) { return false; }
 };
 };
 
 
-
-
 // Utility for use within MappingTraits<>::mapping() method
 // Utility for use within MappingTraits<>::mapping() method
 // to [de]normalize an object for use with YAML conversion.
 // to [de]normalize an object for use with YAML conversion.
 template <typename TNorm, typename TFinal>
 template <typename TNorm, typename TFinal>
@@ -917,14 +890,12 @@ private:
   TFinal       &Result;
   TFinal       &Result;
 };
 };
 
 
-
-
 // Utility for use within MappingTraits<>::mapping() method
 // Utility for use within MappingTraits<>::mapping() method
 // to [de]normalize an object for use with YAML conversion.
 // to [de]normalize an object for use with YAML conversion.
 template <typename TNorm, typename TFinal>
 template <typename TNorm, typename TFinal>
 struct MappingNormalizationHeap {
 struct MappingNormalizationHeap {
   MappingNormalizationHeap(IO &i_o, TFinal &Obj)
   MappingNormalizationHeap(IO &i_o, TFinal &Obj)
-    : io(i_o), BufPtr(NULL), Result(Obj) {
+    : io(i_o), BufPtr(nullptr), Result(Obj) {
     if ( io.outputting() ) {
     if ( io.outputting() ) {
       BufPtr = new (&Buffer) TNorm(io, Obj);
       BufPtr = new (&Buffer) TNorm(io, Obj);
     }
     }
@@ -953,8 +924,6 @@ private:
   TFinal       &Result;
   TFinal       &Result;
 };
 };
 
 
-
-
 ///
 ///
 /// The Input class is used to parse a yaml document into in-memory structs
 /// The Input class is used to parse a yaml document into in-memory structs
 /// and vectors.
 /// and vectors.
@@ -1083,7 +1052,6 @@ private:
   void setError(HNode *hnode, const Twine &message);
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
   void setError(Node *node, const Twine &message);
 
 
-
 public:
 public:
   // These are only used by operator>>. They could be private
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
   // if those templated things could be made friends.
@@ -1105,9 +1073,6 @@ private:
   bool                                ScalarMatchFound;
   bool                                ScalarMatchFound;
 };
 };
 
 
-
-
-
 ///
 ///
 /// The Output class is used to generate a yaml document from in-memory structs
 /// The Output class is used to generate a yaml document from in-memory structs
 /// and vectors.
 /// and vectors.
@@ -1181,9 +1146,6 @@ private:
   bool                     NeedsNewLine;
   bool                     NeedsNewLine;
 };
 };
 
 
-
-
-
 /// YAML I/O does conversion based on types. But often native data types
 /// YAML I/O does conversion based on types. But often native data types
 /// are just a typedef of built in intergral types (e.g. int).  But the C++
 /// are just a typedef of built in intergral types (e.g. int).  But the C++
 /// type matching system sees through the typedef and all the typedefed types
 /// type matching system sees through the typedef and all the typedefed types
@@ -1206,8 +1168,6 @@ private:
         _base value;                                                           \
         _base value;                                                           \
     };
     };
 
 
-
-
 ///
 ///
 /// Use these types instead of uintXX_t in any mapping to have
 /// Use these types instead of uintXX_t in any mapping to have
 /// its yaml output formatted as hexadecimal.
 /// its yaml output formatted as hexadecimal.
@@ -1217,7 +1177,6 @@ LLVM_YAML_STRONG_TYPEDEF(uint16_t, Hex16)
 LLVM_YAML_STRONG_TYPEDEF(uint32_t, Hex32)
 LLVM_YAML_STRONG_TYPEDEF(uint32_t, Hex32)
 LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
 LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
 
 
-
 template<>
 template<>
 struct ScalarTraits<Hex8> {
 struct ScalarTraits<Hex8> {
   static void output(const Hex8 &, void*, llvm::raw_ostream &);
   static void output(const Hex8 &, void*, llvm::raw_ostream &);
@@ -1246,7 +1205,6 @@ struct ScalarTraits<Hex64> {
   static bool mustQuote(StringRef) { return false; }
   static bool mustQuote(StringRef) { return false; }
 };
 };
 
 
-
 // Define non-member operator>> so that Input can stream in a document list.
 // Define non-member operator>> so that Input can stream in a document list.
 template <typename T>
 template <typename T>
 inline
 inline
@@ -1303,7 +1261,6 @@ operator>>(Input &yin, T &docSeq) {
   return yin;
   return yin;
 }
 }
 
 
-
 // Define non-member operator<< so that Output can stream out document list.
 // Define non-member operator<< so that Output can stream out document list.
 template <typename T>
 template <typename T>
 inline
 inline
@@ -1372,11 +1329,9 @@ operator<<(Output &yout, T &seq) {
   return yout;
   return yout;
 }
 }
 
 
-
 } // namespace yaml
 } // namespace yaml
 } // namespace llvm
 } // namespace llvm
 
 
-
 /// Utility for declaring that a std::vector of a particular type
 /// Utility for declaring that a std::vector of a particular type
 /// should be considered a YAML sequence.
 /// should be considered a YAML sequence.
 #define LLVM_YAML_IS_SEQUENCE_VECTOR(_type)                                 \
 #define LLVM_YAML_IS_SEQUENCE_VECTOR(_type)                                 \
@@ -1436,6 +1391,4 @@ operator<<(Output &yout, T &seq) {
   }                                                                         \
   }                                                                         \
   }
   }
 
 
-
-
 #endif // LLVM_SUPPORT_YAMLTRAITS_H
 #endif // LLVM_SUPPORT_YAMLTRAITS_H

+ 5 - 4
tools/llvm-objdump/MachODump.cpp

@@ -133,6 +133,7 @@ static cl::opt<bool> NoSymbolicOperands(
 static cl::list<std::string>
 static cl::list<std::string>
     ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
     ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
               cl::ZeroOrMore);
               cl::ZeroOrMore);
+
 bool ArchAll = false;
 bool ArchAll = false;
 
 
 static std::string ThumbTripleName;
 static std::string ThumbTripleName;
@@ -4460,7 +4461,7 @@ static void print_class64_t(uint64_t p, struct DisassembleInfo *info) {
   bool is_meta_class;
   bool is_meta_class;
   print_class_ro64_t((c.data + n_value) & ~0x7, info, is_meta_class);
   print_class_ro64_t((c.data + n_value) & ~0x7, info, is_meta_class);
 
 
-  if (is_meta_class == false) {
+  if (!is_meta_class) {
     outs() << "Meta Class\n";
     outs() << "Meta Class\n";
     print_class64_t(c.isa + isa_n_value, info);
     print_class64_t(c.isa + isa_n_value, info);
   }
   }
@@ -4525,7 +4526,7 @@ static void print_class32_t(uint32_t p, struct DisassembleInfo *info) {
   bool is_meta_class;
   bool is_meta_class;
   print_class_ro32_t(c.data & ~0x3, info, is_meta_class);
   print_class_ro32_t(c.data & ~0x3, info, is_meta_class);
 
 
-  if (is_meta_class == false) {
+  if (!is_meta_class) {
     outs() << "Meta Class\n";
     outs() << "Meta Class\n";
     print_class32_t(c.isa, info);
     print_class32_t(c.isa, info);
   }
   }
@@ -4833,7 +4834,7 @@ static void print_category32_t(uint32_t p, struct DisassembleInfo *info) {
   outs() << "              name " << format("0x%" PRIx32, c.name);
   outs() << "              name " << format("0x%" PRIx32, c.name);
   name = get_symbol_32(offset + offsetof(struct category32_t, name), S, info,
   name = get_symbol_32(offset + offsetof(struct category32_t, name), S, info,
                        c.name);
                        c.name);
-  if (name != NULL)
+  if (name)
     outs() << " " << name;
     outs() << " " << name;
   outs() << "\n";
   outs() << "\n";
 
 
@@ -5527,7 +5528,7 @@ static void printObjcMetaData(MachOObjectFile *O, bool verbose) {
       // binary for the iOS simulator which is the second Objective-C
       // binary for the iOS simulator which is the second Objective-C
       // ABI.  In that case printObjc1_32bit_MetaData() will determine that
       // ABI.  In that case printObjc1_32bit_MetaData() will determine that
       // and return false.
       // and return false.
-      if (printObjc1_32bit_MetaData(O, verbose) == false)
+      if (!printObjc1_32bit_MetaData(O, verbose))
         printObjc2_32bit_MetaData(O, verbose);
         printObjc2_32bit_MetaData(O, verbose);
     }
     }
   }
   }