Skip to content

Commit

Permalink
Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes.
Browse files Browse the repository at this point in the history
Differential revision: http://reviews.llvm.org/D16567

llvm-svn: 258836
  • Loading branch information
EugeneZelenko committed Jan 26, 2016
1 parent 2c8592a commit 1660a5d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 37 deletions.
6 changes: 3 additions & 3 deletions clang/include/clang/ASTMatchers/ASTMatchersInternal.h
Expand Up @@ -420,7 +420,7 @@ class Matcher {
template <typename From>
Matcher(const Matcher<From> &Other,
typename std::enable_if<std::is_base_of<From, T>::value &&
!std::is_same<From, T>::value>::type * = 0)
!std::is_same<From, T>::value>::type * = nullptr)
: Implementation(restrictMatcher(Other.Implementation)) {
assert(Implementation.getSupportedKind().isSame(
ast_type_traits::ASTNodeKind::getFromNodeKind<T>()));
Expand All @@ -433,7 +433,7 @@ class Matcher {
Matcher(const Matcher<TypeT> &Other,
typename std::enable_if<
std::is_same<T, QualType>::value &&
std::is_same<TypeT, Type>::value>::type* = 0)
std::is_same<TypeT, Type>::value>::type* = nullptr)
: Implementation(new TypeToQualType<TypeT>(Other)) {}

/// \brief Convert \c this into a \c Matcher<T> by applying dyn_cast<> to the
Expand Down Expand Up @@ -1600,4 +1600,4 @@ inline const Stmt *GetBodyMatcher<FunctionDecl>::get(const FunctionDecl &Node) {
} // end namespace ast_matchers
} // end namespace clang

#endif
#endif // LLVM_CLANG_ASTMATCHERS_ASTMATCHERSINTERNAL_H
4 changes: 2 additions & 2 deletions clang/include/clang/Sema/DeclSpec.h
Expand Up @@ -1552,7 +1552,7 @@ struct DeclaratorChunk {
I.Kind = Pipe;
I.Loc = Loc;
I.Cls.TypeQuals = TypeQuals;
I.Cls.AttrList = 0;
I.Cls.AttrList = nullptr;
return I;
}

Expand Down Expand Up @@ -2341,4 +2341,4 @@ struct LambdaIntroducer {

} // end namespace clang

#endif
#endif // LLVM_CLANG_SEMA_DECLSPEC_H
16 changes: 7 additions & 9 deletions clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -1,4 +1,4 @@
//===--- Marshallers.h - Generic matcher function marshallers -*- C++ -*-===//
//===--- Marshallers.h - Generic matcher function marshallers ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -32,7 +32,6 @@ namespace ast_matchers {
namespace dynamic {
namespace internal {


/// \brief Helper template class to just from argument type to the right is/get
/// functions in VariantValue.
/// Used to verify and extract the matcher arguments below.
Expand Down Expand Up @@ -234,7 +233,7 @@ static VariantMatcher outvalueToVariantMatcher(const DynTypedMatcher &Matcher) {
template <typename T>
static VariantMatcher outvalueToVariantMatcher(const T &PolyMatcher,
typename T::ReturnTypes * =
NULL) {
nullptr) {
std::vector<DynTypedMatcher> Matchers;
mergePolyMatchers(PolyMatcher, Matchers, typename T::ReturnTypes());
VariantMatcher Out = VariantMatcher::PolymorphicMatcher(std::move(Matchers));
Expand Down Expand Up @@ -410,7 +409,6 @@ class DynCastAllOfMatcherDescriptor : public VariadicFuncMatcherDescriptor {
return VariantMatcher(); \
}


/// \brief 0-arg marshaller function.
template <typename ReturnType>
static VariantMatcher matcherMarshall0(void (*Func)(), StringRef MatcherName,
Expand Down Expand Up @@ -708,9 +706,9 @@ makeMatcherAutoMarshall(ast_matchers::internal::VariadicOperatorMatcherFunc<
MatcherName);
}

} // namespace internal
} // namespace dynamic
} // namespace ast_matchers
} // namespace clang
} // namespace internal
} // namespace dynamic
} // namespace ast_matchers
} // namespace clang

#endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_MARSHALLERS_H
#endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_MARSHALLERS_H
9 changes: 5 additions & 4 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp
Expand Up @@ -2103,11 +2103,11 @@ CGOpenMPRuntime::createOffloadingBinaryDescriptorRegistration() {
CGM.getTypes().ConvertTypeForMem(getTgtOffloadEntryQTy());
llvm::GlobalVariable *HostEntriesBegin = new llvm::GlobalVariable(
M, OffloadEntryTy, /*isConstant=*/true,
llvm::GlobalValue::ExternalLinkage, /*Initializer=*/0,
llvm::GlobalValue::ExternalLinkage, /*Initializer=*/nullptr,
".omp_offloading.entries_begin");
llvm::GlobalVariable *HostEntriesEnd = new llvm::GlobalVariable(
M, OffloadEntryTy, /*isConstant=*/true,
llvm::GlobalValue::ExternalLinkage, /*Initializer=*/0,
llvm::GlobalValue::ExternalLinkage, /*Initializer=*/nullptr,
".omp_offloading.entries_end");

// Create all device images
Expand All @@ -2119,10 +2119,11 @@ CGOpenMPRuntime::createOffloadingBinaryDescriptorRegistration() {
StringRef T = Devices[i].getTriple();
auto *ImgBegin = new llvm::GlobalVariable(
M, CGM.Int8Ty, /*isConstant=*/true, llvm::GlobalValue::ExternalLinkage,
/*Initializer=*/0, Twine(".omp_offloading.img_start.") + Twine(T));
/*Initializer=*/nullptr,
Twine(".omp_offloading.img_start.") + Twine(T));
auto *ImgEnd = new llvm::GlobalVariable(
M, CGM.Int8Ty, /*isConstant=*/true, llvm::GlobalValue::ExternalLinkage,
/*Initializer=*/0, Twine(".omp_offloading.img_end.") + Twine(T));
/*Initializer=*/nullptr, Twine(".omp_offloading.img_end.") + Twine(T));

llvm::Constant *Dev =
llvm::ConstantStruct::get(DeviceImageTy, ImgBegin, ImgEnd,
Expand Down
19 changes: 7 additions & 12 deletions clang/lib/Sema/SemaType.cpp
Expand Up @@ -239,7 +239,7 @@ namespace {
savedAttrs.back()->setNext(nullptr);
}
};
}
} // end anonymous namespace

static void spliceAttrIntoList(AttributeList &attr, AttributeList *&head) {
attr.setNext(head);
Expand Down Expand Up @@ -1821,7 +1821,7 @@ namespace {
///
/// The values of this enum are used in diagnostics.
enum QualifiedFunctionKind { QFK_BlockPointer, QFK_Pointer, QFK_Reference };
}
} // end anonymous namespace

/// Check whether the type T is a qualified function type, and if it is,
/// diagnose that it cannot be contained within the given kind of declarator.
Expand Down Expand Up @@ -1971,7 +1971,6 @@ static bool isArraySizeVLA(Sema &S, Expr *ArraySize, llvm::APSInt &SizeVal) {
S.LangOpts.GNUMode).isInvalid();
}


/// \brief Build an array type.
///
/// \param T The type of each element in the array.
Expand Down Expand Up @@ -3004,7 +3003,7 @@ namespace {
BlockPointer,
MemberPointer,
};
}
} // end anonymous namespace

IdentifierInfo *Sema::getNullabilityKeyword(NullabilityKind nullability) {
switch (nullability) {
Expand Down Expand Up @@ -3064,7 +3063,7 @@ namespace {
// NSError**
NSErrorPointerPointer,
};
}
} // end anonymous namespace

/// Classify the given declarator, whose type-specified is \c type, based on
/// what kind of pointer it refers to.
Expand Down Expand Up @@ -3192,7 +3191,6 @@ static PointerDeclaratorKind classifyPointerDeclarator(Sema &S,
break;
} while (true);


switch (numNormalPointers) {
case 0:
return PointerDeclaratorKind::NonPointer;
Expand Down Expand Up @@ -3641,7 +3639,6 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
T = S.BuildPointerType(T, DeclType.Loc, Name);
if (DeclType.Ptr.TypeQuals)
T = S.BuildQualifiedType(T, DeclType.Loc, DeclType.Ptr.TypeQuals);

break;
case DeclaratorChunk::Reference: {
// Verify that we're not building a reference to pointer to function with
Expand Down Expand Up @@ -4068,7 +4065,6 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,

T = Context.getFunctionType(T, ParamTys, EPI);
}

break;
}
case DeclaratorChunk::MemberPointer: {
Expand Down Expand Up @@ -4725,7 +4721,7 @@ namespace {
void VisitPipeTypeLoc(PipeTypeLoc TL) {
TL.setKWLoc(DS.getTypeSpecTypeLoc());

TypeSourceInfo *TInfo = 0;
TypeSourceInfo *TInfo = nullptr;
Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
TL.getValueLoc().initializeFullCopy(TInfo->getTypeLoc());
}
Expand Down Expand Up @@ -4859,7 +4855,7 @@ namespace {
llvm_unreachable("unsupported TypeLoc kind in declarator!");
}
};
}
} // end anonymous namespace

static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk) {
SourceLocation Loc;
Expand Down Expand Up @@ -4995,7 +4991,6 @@ ParsedType Sema::ActOnObjCInstanceType(SourceLocation Loc) {
return CreateParsedType(T, TInfo);
}


//===----------------------------------------------------------------------===//
// Type Attribute Processing
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -5483,7 +5478,7 @@ namespace {
llvm_unreachable("unknown wrapping kind");
}
};
}
} // end anonymous namespace

static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State,
AttributeList &Attr,
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
Expand Up @@ -54,10 +54,10 @@ class VforkChecker : public Checker<check::PreCall, check::PostCall,
bool isCallWhitelisted(const IdentifierInfo *II, CheckerContext &C) const;

void reportBug(const char *What, CheckerContext &C,
const char *Details = 0) const;
const char *Details = nullptr) const;

public:
VforkChecker() : II_vfork(0) {}
VforkChecker() : II_vfork(nullptr) {}

void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
Expand Down Expand Up @@ -107,7 +107,7 @@ bool VforkChecker::isCallWhitelisted(const IdentifierInfo *II,
"execv",
"execvp",
"execvpe",
0,
nullptr
};

ASTContext &AC = C.getASTContext();
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
Expand Up @@ -75,8 +75,8 @@ bool clang::ento::containsBuiltinOffsetOf(const Stmt *S) {
// Extract lhs and rhs from assignment statement
std::pair<const clang::VarDecl *, const clang::Expr *>
clang::ento::parseAssignment(const Stmt *S) {
const VarDecl *VD = 0;
const Expr *RHS = 0;
const VarDecl *VD = nullptr;
const Expr *RHS = nullptr;

if (auto Assign = dyn_cast_or_null<BinaryOperator>(S)) {
if (Assign->isAssignmentOp()) {
Expand Down
3 changes: 1 addition & 2 deletions clang/unittests/Basic/VirtualFileSystemTest.cpp
Expand Up @@ -29,7 +29,7 @@ struct DummyFile : public vfs::File {
bool IsVolatile) override {
llvm_unreachable("unimplemented");
}
virtual std::error_code close() override { return std::error_code(); }
std::error_code close() override { return std::error_code(); }
};

class DummyFileSystem : public vfs::FileSystem {
Expand Down Expand Up @@ -348,7 +348,6 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) {
ASSERT_FALSE(EC);
ASSERT_NE(vfs::recursive_directory_iterator(), I);


std::vector<std::string> Contents;
for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
Expand Down

0 comments on commit 1660a5d

Please sign in to comment.