Index: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp =================================================================== --- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp +++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp @@ -1,4 +1,4 @@ -//===- ThreadSafetyCommon.cpp ----------------------------------*- C++ --*-===// +//===- ThreadSafetyCommon.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -31,6 +31,7 @@ #include #include #include + using namespace clang; using namespace threadSafety; @@ -66,7 +67,6 @@ typedef SExprBuilder::CallingContext CallingContext; - til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) { auto It = SMap.find(S); if (It != SMap.end()) @@ -74,7 +74,6 @@ return nullptr; } - til::SCFG *SExprBuilder::buildCFG(CFGWalker &Walker) { Walker.walk(*this); return Scfg; @@ -85,7 +84,6 @@ return ME ? ME->isArrow() : false; } - /// \brief Translate a clang expression in an attribute to a til::SExpr. /// Constructs the context from D, DeclExp, and SelfDecl. /// @@ -148,7 +146,6 @@ return translateAttrExpr(AttrExp, &Ctx); } - /// \brief Translate a clang expression in an attribute to a til::SExpr. // This assumes a CallingContext has already been created. CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp, @@ -195,8 +192,6 @@ return CapabilityExpr(E, Neg); } - - // Translate a clang statement or expression to a TIL expression. // Also performs substitution of variables; Ctx provides the context. // Dispatches on the type of S. @@ -268,8 +263,6 @@ return new (Arena) til::Undefined(S); } - - til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE, CallingContext *Ctx) { const ValueDecl *VD = cast(DRE->getDecl()->getCanonicalDecl()); @@ -294,7 +287,6 @@ return new (Arena) til::LiteralPtr(VD); } - til::SExpr *SExprBuilder::translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx) { // Substitute for 'this' @@ -313,7 +305,7 @@ return P->clangDecl(); if (auto *L = dyn_cast(E)) return L->clangDecl(); - return 0; + return nullptr; } static bool hasCppPointerType(const til::SExpr *E) { @@ -355,7 +347,6 @@ return P; } - til::SExpr *SExprBuilder::translateCallExpr(const CallExpr *CE, CallingContext *Ctx, const Expr *SelfE) { @@ -381,7 +372,6 @@ return new (Arena) til::Call(E, CE); } - til::SExpr *SExprBuilder::translateCXXMemberCallExpr( const CXXMemberCallExpr *ME, CallingContext *Ctx) { if (CapabilityExprMode) { @@ -397,7 +387,6 @@ ME->getImplicitObjectArgument()); } - til::SExpr *SExprBuilder::translateCXXOperatorCallExpr( const CXXOperatorCallExpr *OCE, CallingContext *Ctx) { if (CapabilityExprMode) { @@ -412,7 +401,6 @@ return translateCallExpr(cast(OCE), Ctx); } - til::SExpr *SExprBuilder::translateUnaryOperator(const UnaryOperator *UO, CallingContext *Ctx) { switch (UO->getOpcode()) { @@ -462,7 +450,6 @@ return new (Arena) til::Undefined(UO); } - til::SExpr *SExprBuilder::translateBinOp(til::TIL_BinaryOpcode Op, const BinaryOperator *BO, CallingContext *Ctx, bool Reverse) { @@ -474,7 +461,6 @@ return new (Arena) til::BinaryOp(Op, E0, E1); } - til::SExpr *SExprBuilder::translateBinAssign(til::TIL_BinaryOpcode Op, const BinaryOperator *BO, CallingContext *Ctx, @@ -501,7 +487,6 @@ return new (Arena) til::Store(E0, E1); } - til::SExpr *SExprBuilder::translateBinaryOperator(const BinaryOperator *BO, CallingContext *Ctx) { switch (BO->getOpcode()) { @@ -547,7 +532,6 @@ return new (Arena) til::Undefined(BO); } - til::SExpr *SExprBuilder::translateCastExpr(const CastExpr *CE, CallingContext *Ctx) { clang::CastKind K = CE->getCastKind(); @@ -581,7 +565,6 @@ } } - til::SExpr * SExprBuilder::translateArraySubscriptExpr(const ArraySubscriptExpr *E, CallingContext *Ctx) { @@ -590,7 +573,6 @@ return new (Arena) til::ArrayIndex(E0, E1); } - til::SExpr * SExprBuilder::translateAbstractConditionalOperator( const AbstractConditionalOperator *CO, CallingContext *Ctx) { @@ -600,7 +582,6 @@ return new (Arena) til::IfThenElse(C, T, E); } - til::SExpr * SExprBuilder::translateDeclStmt(const DeclStmt *S, CallingContext *Ctx) { DeclGroupRef DGrp = S->getDeclGroup(); @@ -622,8 +603,6 @@ return nullptr; } - - // If (E) is non-trivial, then add it to the current basic block, and // update the statement map so that S refers to E. Returns a new variable // that refers to E. @@ -640,7 +619,6 @@ return E; } - // Returns the current value of VD, if known, and nullptr otherwise. til::SExpr *SExprBuilder::lookupVarDecl(const ValueDecl *VD) { auto It = LVarIdxMap.find(VD); @@ -651,7 +629,6 @@ return nullptr; } - // if E is a til::Variable, update its clangDecl. static void maybeUpdateVD(til::SExpr *E, const ValueDecl *VD) { if (!E) @@ -671,7 +648,6 @@ return E; } - // Updates a current variable declaration. (E.g. by assignment) til::SExpr *SExprBuilder::updateVarDecl(const ValueDecl *VD, til::SExpr *E) { maybeUpdateVD(E, VD); @@ -686,7 +662,6 @@ return E; } - // Make a Phi node in the current block for the i^th variable in CurrentVarMap. // If E != null, sets Phi[CurrentBlockInfo->ArgIndex] = E. // If E == null, this is a backedge and will be set later. @@ -729,7 +704,6 @@ CurrentLVarMap.elem(i).second = Ph; } - // Merge values from Map into the current variable map. // This will construct Phi nodes in the current basic block as necessary. void SExprBuilder::mergeEntryMap(LVarDefinitionMap Map) { @@ -764,7 +738,6 @@ } } - // Merge a back edge into the current variable map. // This will create phi nodes for all variables in the variable map. void SExprBuilder::mergeEntryMapBackEdge() { @@ -791,7 +764,6 @@ } } - // Update the phi nodes that were initially created for a back edge // once the variable definitions have been computed. // I.e., merge the current variable map into the phi nodes for Blk. @@ -844,7 +816,6 @@ } } - void SExprBuilder::enterCFGBlock(const CFGBlock *B) { // Intialize TIL basic block and add it to the CFG. CurrentBB = lookupBlock(B); @@ -858,7 +829,6 @@ // assert(!CurrentLVarMap.valid() && "CurrentLVarMap already initialized."); } - void SExprBuilder::handlePredecessor(const CFGBlock *Pred) { // Compute CurrentLVarMap on entry from ExitMaps of predecessors @@ -874,12 +844,10 @@ ++CurrentBlockInfo->ProcessedPredecessors; } - void SExprBuilder::handlePredecessorBackEdge(const CFGBlock *Pred) { mergeEntryMapBackEdge(); } - void SExprBuilder::enterCFGBlockBody(const CFGBlock *B) { // The merge*() methods have created arguments. // Push those arguments onto the basic block. @@ -889,13 +857,11 @@ CurrentBB->addArgument(A); } - void SExprBuilder::handleStatement(const Stmt *S) { til::SExpr *E = translate(S, nullptr); addStatement(E, S); } - void SExprBuilder::handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD) { til::SExpr *Sf = new (Arena) til::LiteralPtr(VD); @@ -905,8 +871,6 @@ addStatement(E, nullptr); } - - void SExprBuilder::exitCFGBlockBody(const CFGBlock *B) { CurrentBB->instructions().reserve( static_cast(CurrentInstructions.size()), Arena); @@ -934,18 +898,15 @@ } } - void SExprBuilder::handleSuccessor(const CFGBlock *Succ) { ++CurrentBlockInfo->UnprocessedSuccessors; } - void SExprBuilder::handleSuccessorBackEdge(const CFGBlock *Succ) { mergePhiNodesBackEdge(Succ); ++BBInfo[Succ->getBlockID()].ProcessedPredecessors; } - void SExprBuilder::exitCFGBlock(const CFGBlock *B) { CurrentArguments.clear(); CurrentInstructions.clear(); @@ -954,7 +915,6 @@ CurrentBlockInfo = nullptr; } - void SExprBuilder::exitCFG(const CFGBlock *Last) { for (auto *Ph : IncompleteArgs) { if (Ph->status() == til::Phi::PH_Incomplete) @@ -966,7 +926,6 @@ IncompleteArgs.clear(); } - /* void printSCFG(CFGWalker &Walker) { llvm::BumpPtrAllocator Bpa; Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGBlocks.cpp +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp @@ -1,4 +1,4 @@ -//===--- CGBlocks.cpp - Emit LLVM Code for declarations -------------------===// +//===--- CGBlocks.cpp - Emit LLVM Code for declarations ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -78,7 +78,7 @@ ASTContext &C = CGM.getContext(); llvm::Type *ulong = CGM.getTypes().ConvertType(C.UnsignedLongTy); - llvm::Type *i8p = NULL; + llvm::Type *i8p = nullptr; if (CGM.getLangOpts().OpenCL) i8p = llvm::Type::getInt8PtrTy( @@ -232,7 +232,7 @@ return getPrefOrder(left) < getPrefOrder(right); } -} +} // end anonymous namespace /// Determines if the given type is safe for constant capture in C++. static bool isSafeForCXXConstantCapture(QualType type) { @@ -943,7 +943,6 @@ return GenericBlockLiteralType; } - RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue) { const BlockPointerType *BPT = @@ -1305,7 +1304,6 @@ } */ - /// Generate the copy-helper function for a block closure object: /// static void block_copy_helper(block_t *dst, block_t *src); /// The runtime will have previously initialized 'dst' by doing a @@ -2252,7 +2250,7 @@ CGF.BuildBlockRelease(Addr, BLOCK_FIELD_IS_BYREF); } }; -} +} // end anonymous namespace /// Enter a cleanup to destroy a __block variable. Note that this /// cleanup should be a no-op if the variable hasn't left the stack Index: cfe/trunk/lib/CodeGen/CGClass.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGClass.cpp +++ cfe/trunk/lib/CodeGen/CGClass.cpp @@ -1,4 +1,4 @@ -//===--- CGClass.cpp - Emit LLVM Code for C++ classes ---------------------===// +//===--- CGClass.cpp - Emit LLVM Code for C++ classes -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -508,7 +508,7 @@ // external code might potentially access the vtable. void VisitCXXThisExpr(const CXXThisExpr *E) { UsesThis = true; } }; -} +} // end anonymous namespace static bool BaseInitializerUsesThis(ASTContext &C, const Expr *Init) { DynamicThisUseChecker Checker(C); @@ -930,7 +930,7 @@ return; } - const FunctionDecl *Definition = 0; + const FunctionDecl *Definition = nullptr; Stmt *Body = Ctor->getBody(Definition); assert(Definition == Ctor && "emitting wrong constructor body"); @@ -987,7 +987,7 @@ SanitizerSet OldSanOpts; }; } - + namespace { class FieldMemcpyizer { public: @@ -1342,8 +1342,7 @@ emitAggregatedStmts(); } }; - -} +} // end anonymous namespace static bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit) { const Type *BaseType = BaseInit->getBaseClass(); @@ -1802,7 +1801,7 @@ EmitSanitizerDtorCallback(CGF, VTablePtr, PoisonSize); } }; -} +} // end anonymous namespace /// \brief Emit all code that comes at the end of class's /// destructor. This is to call destructors on members and base classes @@ -1941,7 +1940,6 @@ Address arrayBase, const CXXConstructExpr *E, bool zeroInitialize) { - // It's legal for numElements to be zero. This can happen both // dynamically, because x can be zero in 'new A[x]', and statically, // because of GCC extensions that permit zero-length arrays. There @@ -2240,7 +2238,7 @@ /*Delegating=*/true, Addr); } }; -} +} // end anonymous namespace void CodeGenFunction::EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, @@ -2520,7 +2518,7 @@ if (!SanOpts.has(SanitizerKind::CFICastStrict)) ClassDecl = LeastDerivedClassWithSameLayout(ClassDecl); - llvm::BasicBlock *ContBlock = 0; + llvm::BasicBlock *ContBlock = nullptr; if (MayBeNull) { llvm::Value *DerivedNotNull = Index: cfe/trunk/lib/CodeGen/CGException.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGException.cpp +++ cfe/trunk/lib/CodeGen/CGException.cpp @@ -1,4 +1,4 @@ -//===--- CGException.cpp - Emit LLVM Code for C++ exceptions --------------===// +//===--- CGException.cpp - Emit LLVM Code for C++ exceptions ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -346,7 +346,7 @@ CGF.EmitNounwindRuntimeCall(getFreeExceptionFn(CGF.CGM), exn); } }; -} +} // end anonymous namespace // Emits an exception expression into the given location. This // differs from EmitAnyExprToMem only in that, if a final copy-ctor @@ -1191,7 +1191,7 @@ CGF.EnsureInsertPoint(); } }; -} +} // end anonymous namespace /// Enters a finally block for an implementation using zero-cost /// exceptions. This is mostly general, but hard-codes some @@ -1313,7 +1313,7 @@ llvm::StructType::get(Int8PtrTy, Int32Ty, nullptr), 0); LPadInst->addClause(getCatchAllValue(*this)); - llvm::Value *Exn = 0; + llvm::Value *Exn = nullptr; if (getLangOpts().CPlusPlus) Exn = Builder.CreateExtractValue(LPadInst, 0); llvm::CallInst *terminateCall = @@ -1341,7 +1341,7 @@ EHPersonality::get(*this).isMSVCPersonality()) { Builder.CreateTerminatePad(/*UnwindBB=*/nullptr, CGM.getTerminateFn()); } else { - llvm::Value *Exn = 0; + llvm::Value *Exn = nullptr; if (getLangOpts().CPlusPlus) Exn = getExceptionFromSlot(); llvm::CallInst *terminateCall = @@ -1465,7 +1465,7 @@ CleanupEndBB); } }; -} +} // end anonymous namespace namespace { /// Find all local variable captures in the statement. @@ -1524,7 +1524,7 @@ } } }; -} +} // end anonymous namespace Address CodeGenFunction::recoverAddrOfEscapedLocal( CodeGenFunction &ParentCGF, Address ParentVar, llvm::Value *ParentFP) { Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp @@ -970,7 +970,6 @@ llvm::Constant *getBitmapBlockLayout(bool ComputeByrefLayout); - /// GetIvarLayoutName - Returns a unique constant for the given /// ivar layout bitmap. llvm::Constant *GetIvarLayoutName(IdentifierInfo *Ident, @@ -6718,7 +6717,7 @@ llvm::Value *CGObjCNonFragileABIMac::EmitNSAutoreleasePoolClassRef( CodeGenFunction &CGF) { IdentifierInfo *II = &CGM.getContext().Idents.get("NSAutoreleasePool"); - return EmitClassRefFromId(CGF, II, false, 0); + return EmitClassRefFromId(CGF, II, false, nullptr); } llvm::Value * Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp @@ -604,7 +604,7 @@ RecordNextStmtCount = true; } }; -} +} // end anonymous namespace void PGOHash::combine(HashType Type) { // Check that we never combine 0 and only have six bits. @@ -763,7 +763,7 @@ return; uint64_t MaxFunctionCount = PGOReader->getMaximumFunctionCount(); - uint64_t FunctionCount = getRegionCount(0); + uint64_t FunctionCount = getRegionCount(nullptr); if (FunctionCount >= (uint64_t)(0.3 * (double)MaxFunctionCount)) // Turn on InlineHint attribute for hot functions. // FIXME: 30% is from preliminary tuning on SPEC, it may not be optimal. Index: cfe/trunk/lib/Driver/ToolChains.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -1,4 +1,4 @@ -//===--- ToolChains.cpp - ToolChain Implementations -----------------------===// +//===--- ToolChains.cpp - ToolChain Implementations -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -142,7 +142,7 @@ return "arm64"; case llvm::Triple::thumb: - case llvm::Triple::arm: { + case llvm::Triple::arm: if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) if (const char *Arch = ArmMachOArchName(A->getValue())) return Arch; @@ -153,7 +153,6 @@ return "arm"; } - } } Darwin::~Darwin() {} @@ -572,7 +571,7 @@ CmdArgs.push_back("-lc++"); break; - case ToolChain::CST_Libstdcxx: { + case ToolChain::CST_Libstdcxx: // Unfortunately, -lstdc++ doesn't always exist in the standard search path; // it was previously found in the gcc lib dir. However, for all the Darwin // platforms we care about it was -lstdc++.6, so we search for that @@ -606,7 +605,6 @@ CmdArgs.push_back("-lstdc++"); break; } - } } void DarwinClang::AddCCKextLibArgs(const ArgList &Args, @@ -1464,7 +1462,6 @@ LibDirs.append(begin(SystemZLibDirs), end(SystemZLibDirs)); TripleAliases.append(begin(SystemZTriples), end(SystemZTriples)); break; - default: // By default, just rely on the standard lib directories and the original // triple. @@ -2217,7 +2214,7 @@ if (A) return "0"; - return 0; + return nullptr; } bool HexagonToolChain::UsesG0(const char *smallDataThreshold) { @@ -2436,34 +2433,30 @@ std::string ToolPath(getDriver().ResourceDir + "/lib/"); switch (Triple.getArch()) { - case llvm::Triple::x86: { + case llvm::Triple::x86: file_paths.push_back(FilePath + "x86_64-nacl/lib32"); file_paths.push_back(FilePath + "i686-nacl/usr/lib"); prog_paths.push_back(ProgPath + "x86_64-nacl/bin"); file_paths.push_back(ToolPath + "i686-nacl"); break; - } - case llvm::Triple::x86_64: { + case llvm::Triple::x86_64: file_paths.push_back(FilePath + "x86_64-nacl/lib"); file_paths.push_back(FilePath + "x86_64-nacl/usr/lib"); prog_paths.push_back(ProgPath + "x86_64-nacl/bin"); file_paths.push_back(ToolPath + "x86_64-nacl"); break; - } - case llvm::Triple::arm: { + case llvm::Triple::arm: file_paths.push_back(FilePath + "arm-nacl/lib"); file_paths.push_back(FilePath + "arm-nacl/usr/lib"); prog_paths.push_back(ProgPath + "arm-nacl/bin"); file_paths.push_back(ToolPath + "arm-nacl"); break; - } - case llvm::Triple::mipsel: { + case llvm::Triple::mipsel: file_paths.push_back(FilePath + "mipsel-nacl/lib"); file_paths.push_back(FilePath + "mipsel-nacl/usr/lib"); prog_paths.push_back(ProgPath + "bin"); file_paths.push_back(ToolPath + "mipsel-nacl"); break; - } default: break; } Index: cfe/trunk/lib/Frontend/ASTUnit.cpp =================================================================== --- cfe/trunk/lib/Frontend/ASTUnit.cpp +++ cfe/trunk/lib/Frontend/ASTUnit.cpp @@ -1,4 +1,4 @@ -//===--- ASTUnit.cpp - ASTUnit utility ------------------------------------===// +//===--- ASTUnit.cpp - ASTUnit utility --------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -47,6 +47,7 @@ #include #include #include + using namespace clang; using llvm::TimeRecord; @@ -973,7 +974,7 @@ } }; -} +} // anonymous namespace std::unique_ptr PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI, @@ -2120,7 +2121,7 @@ return Next.getCodeCompletionTUInfo(); } }; -} +} // anonymous namespace /// \brief Helper function that computes which global names are hidden by the /// local code-completion results. @@ -2206,7 +2207,6 @@ } } - void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, @@ -2840,9 +2840,9 @@ #else // NDEBUG -ASTUnit::ConcurrencyState::ConcurrencyState() { Mutex = 0; } +ASTUnit::ConcurrencyState::ConcurrencyState() { Mutex = nullptr; } ASTUnit::ConcurrencyState::~ConcurrencyState() {} void ASTUnit::ConcurrencyState::start() {} void ASTUnit::ConcurrencyState::finish() {} -#endif +#endif // NDEBUG Index: cfe/trunk/lib/Parse/ParseDecl.cpp =================================================================== --- cfe/trunk/lib/Parse/ParseDecl.cpp +++ cfe/trunk/lib/Parse/ParseDecl.cpp @@ -1,4 +1,4 @@ -//===--- ParseDecl.cpp - Declaration Parsing ------------------------------===// +//===--- ParseDecl.cpp - Declaration Parsing --------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -27,6 +27,7 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" + using namespace clang; //===----------------------------------------------------------------------===// @@ -67,7 +68,6 @@ return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); } - /// isAttributeLateParsed - Return true if the attribute has arguments that /// require late parsing. static bool isAttributeLateParsed(const IdentifierInfo &II) { @@ -1153,7 +1153,6 @@ Class.TagOrTemplate); } - /// \brief Parse all attributes in LAs, and attach them to Decl D. void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D, bool EnterScope, bool OnDefinition) { @@ -1168,7 +1167,6 @@ LAs.clear(); } - /// \brief Finish parsing an attribute for which parsing was delayed. /// This will be called at the end of parsing a class declaration /// for each LateParsedAttribute. We consume the saved tokens and @@ -2201,7 +2199,6 @@ tok::colon); } - /// ParseImplicitInt - This method is called when we have an non-typename /// identifier in a declspec (which normally terminates the decl spec) when /// the declspec has no type specifier. In this case, the declspec is either @@ -2619,8 +2616,6 @@ /// [OpenCL] '__kernel' /// 'friend': [C++ dcl.friend] /// 'constexpr': [C++0x dcl.constexpr] - -/// void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, @@ -4833,7 +4828,6 @@ } } - /// ParseDeclarator - Parse and verify a newly-initialized declarator. /// void Parser::ParseDeclarator(Declarator &D) { @@ -5481,7 +5475,7 @@ SmallVector DynamicExceptions; SmallVector DynamicExceptionRanges; ExprResult NoexceptExpr; - CachedTokens *ExceptionSpecTokens = 0; + CachedTokens *ExceptionSpecTokens = nullptr; ParsedAttributes FnAttrs(AttrFactory); TypeResult TrailingReturnType; @@ -6238,7 +6232,6 @@ Diag(StartLoc, DiagID) << PrevSpec; } - /// TryAltiVecVectorTokenOutOfLine - Out of line body that should only be called /// from TryAltiVecVectorToken. bool Parser::TryAltiVecVectorTokenOutOfLine() { Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp =================================================================== --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp @@ -1,4 +1,4 @@ -//===--- ParseDeclCXX.cpp - C++ Declaration Parsing -----------------------===// +//===--- ParseDeclCXX.cpp - C++ Declaration Parsing -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -26,6 +26,7 @@ #include "clang/Sema/Scope.h" #include "clang/Sema/SemaDiagnostic.h" #include "llvm/ADT/SmallString.h" + using namespace clang; /// ParseNamespace - We know that the current token is a namespace keyword. This @@ -118,7 +119,6 @@ return ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd); } - BalancedDelimiterTracker T(*this, tok::l_brace); if (T.consumeOpen()) { if (Ident) @@ -1968,7 +1968,7 @@ // Stash the exception-specification tokens in the late-pased method. LateMethod->ExceptionSpecTokens = FTI.ExceptionSpecTokens; - FTI.ExceptionSpecTokens = 0; + FTI.ExceptionSpecTokens = nullptr; // Push tokens for each parameter. Those that do not have // defaults will be NULL. @@ -3319,7 +3319,7 @@ ExprResult &NoexceptExpr, CachedTokens *&ExceptionSpecTokens) { ExceptionSpecificationType Result = EST_None; - ExceptionSpecTokens = 0; + ExceptionSpecTokens = nullptr; // Handle delayed parsing of exception-specifications. if (Delayed) { @@ -3336,7 +3336,7 @@ // If this is a bare 'noexcept', we're done. if (IsNoexcept) { Diag(Tok, diag::warn_cxx98_compat_noexcept_decl); - NoexceptExpr = 0; + NoexceptExpr = nullptr; return EST_BasicNoexcept; } @@ -3617,9 +3617,8 @@ case AttributeList::AT_CarriesDependency: case AttributeList::AT_Deprecated: case AttributeList::AT_FallThrough: - case AttributeList::AT_CXX11NoReturn: { + case AttributeList::AT_CXX11NoReturn: return true; - } default: return false; Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp =================================================================== --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp @@ -99,7 +99,7 @@ } } }; -} +} // anonymous namespace /// CheckUnreachable - Check for unreachable code. static void CheckUnreachable(Sema &S, AnalysisDeclContext &AC) { @@ -157,7 +157,7 @@ << DiagRange << isAlwaysTrue; } }; -} // namespace +} // anonymous namespace //===----------------------------------------------------------------------===// // Check for infinite self-recursion in functions @@ -506,7 +506,7 @@ } }; -} +} // anonymous namespace /// CheckFallThroughForFunctionDef - Check that we don't fall off the end of a /// function that should return a value. Check that we don't fall off the end @@ -614,7 +614,7 @@ bool doesContainReference() const { return FoundReference; } }; -} +} // anonymous namespace static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) { QualType VariableTy = VD->getType().getCanonicalType(); @@ -850,7 +850,6 @@ static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD, const UninitUse &Use, bool alwaysReportSelfInit = false) { - if (const DeclRefExpr *DRE = dyn_cast(Use.getUser())) { // Inspect the initializer of the variable declaration which is // being referenced prior to its initialization. We emit @@ -1072,7 +1071,7 @@ Sema &S; llvm::SmallPtrSet ReachableBlocks; }; -} +} // anonymous namespace static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, bool PerFunction) { @@ -1183,7 +1182,6 @@ return false; } - static void diagnoseRepeatedUseOfWeak(Sema &S, const sema::FunctionScopeInfo *CurFn, const Decl *D, @@ -1426,7 +1424,7 @@ }); } }; -} +} // anonymous namespace namespace clang { namespace { @@ -1444,7 +1442,8 @@ return SM.isBeforeInTranslationUnit(left.first.first, right.first.first); } }; -}} +} // anonymous namespace +} // namespace clang //===----------------------------------------------------------------------===// // -Wthread-safety @@ -1683,7 +1682,6 @@ Warnings.emplace_back(std::move(Warning), getNotes()); } - void handleFunExcludesLock(StringRef Kind, Name FunName, Name LockName, SourceLocation Loc) override { PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_fun_excludes_mutex) @@ -1709,10 +1707,10 @@ } void leaveFunction(const FunctionDecl* FD) override { - CurrentFunction = 0; + CurrentFunction = nullptr; } }; -} // namespace +} // anonymous namespace } // namespace threadSafety } // namespace clang @@ -1805,7 +1803,9 @@ Warnings.emplace_back(std::move(Warning), OptionalNotes()); } }; -}}} +} // anonymous namespace +} // namespace consumed +} // namespace clang //===----------------------------------------------------------------------===// // AnalysisBasedWarnings - Worker object used by Sema to execute analysis-based @@ -1971,7 +1971,6 @@ flushDiagnostics(S, fscope); } - // Warning: check missing 'return' if (P.enableCheckFallThrough) { const CheckFallThroughDiagnostics &CD = Index: cfe/trunk/lib/Sema/SemaDeclObjC.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp @@ -449,7 +449,7 @@ ObjCInterfaceDecl *CurrentIDecl; }; -} +} // end anonymous namespace static void diagnoseUseOfProtocols(Sema &TheSema, ObjCContainerDecl *CD, @@ -484,7 +484,7 @@ if (TypoCorrection Corrected = CorrectTypo( DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope, - NULL, llvm::make_unique(IDecl), + nullptr, llvm::make_unique(IDecl), CTK_ErrorRecovery)) { diagnoseTypo(Corrected, PDiag(diag::err_undef_superclass_suggest) << SuperName << ClassName); @@ -507,7 +507,7 @@ SuperClassType = Context.getObjCInterfaceType(SuperClassDecl); } - if (PrevDecl && SuperClassDecl == 0) { + if (PrevDecl && !SuperClassDecl) { // The previous declaration was not a class decl. Check if we have a // typedef. If we do, get the underlying class type. if (const TypedefNameDecl *TDecl = @@ -548,7 +548,7 @@ SuperClassDecl->getDeclName(), ClassName, SourceRange(AtInterfaceLoc, ClassLoc))) { - SuperClassDecl = 0; + SuperClassDecl = nullptr; SuperClassType = QualType(); } } @@ -746,7 +746,7 @@ Category, Extension }; -} +} // end anonymous namespace /// Check consistency between two Objective-C type parameter lists, e.g., /// between a category/extension and an \@interface or between an \@class and an @@ -1500,8 +1500,8 @@ SourceLocation(), SourceLocation(), SourceLocation()), - parsedAttrs, - starLoc); + parsedAttrs, + starLoc); // Diagnose the missing '*'. Diag(loc, diag::err_objc_type_arg_missing_star) @@ -3724,7 +3724,6 @@ return ClassDecl; } - /// CvtQTToAstBitMask - utility routine to produce an AST bitmask for /// objective-c's type qualifier from the parser version of the same info. static Decl::ObjCDeclQualifier @@ -3891,7 +3890,6 @@ search(Interface); } - void search(const ObjCProtocolList &protocols) { for (ObjCProtocolList::iterator i = protocols.begin(), e = protocols.end(); i != e; ++i) @@ -3919,7 +3917,7 @@ searchFromContainer(container); } }; -} +} // end anonymous namespace void Sema::CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, @@ -4514,7 +4512,6 @@ if (!LookupImplementedMethodInGlobalPool(Sel)) Diag(Loc, diag::warn_unimplemented_selector) << Sel; } - return; } ObjCIvarDecl * @@ -4577,7 +4574,7 @@ return true; } }; -} +} // end anonymous namespace void Sema::DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD) { Index: cfe/trunk/lib/Sema/SemaLookup.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaLookup.cpp +++ cfe/trunk/lib/Sema/SemaLookup.cpp @@ -1,4 +1,4 @@ -//===--------------------- SemaLookup.cpp - Name Lookup ------------------===// +//===--------------------- SemaLookup.cpp - Name Lookup --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,6 +11,7 @@ // Objective-C++. // //===----------------------------------------------------------------------===// + #include "clang/Sema/Lookup.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTMutationListener.h" @@ -204,7 +205,7 @@ UnqualUsingEntry::Comparator())); } }; -} +} // end anonymous namespace // Retrieve the set of identifier namespaces that correspond to a // specific kind of name lookup. @@ -967,7 +968,7 @@ LookupResult &R; bool OldFindLocalExtern; }; -} +} // end anonymous namespace bool Sema::CppLookupName(LookupResult &R, Scope *S) { assert(getLangOpts().CPlusPlus && "Can perform only C++ lookup"); @@ -2234,7 +2235,7 @@ Sema::AssociatedClassSet &Classes; SourceLocation InstantiationLoc; }; -} +} // end anonymous namespace static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T); @@ -3920,7 +3921,8 @@ // current correction candidate is the name of that class, then skip // it as it is unlikely a qualified version of the class' constructor // is an appropriate correction. - if (CXXRecordDecl *NSDecl = NSType ? NSType->getAsCXXRecordDecl() : 0) { + if (CXXRecordDecl *NSDecl = NSType ? NSType->getAsCXXRecordDecl() : + nullptr) { if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo()) continue; } Index: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp =================================================================== --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp @@ -26,6 +26,7 @@ #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" #include "llvm/Support/SaveAndRestore.h" + using namespace clang; using namespace clang::serialization; @@ -160,7 +161,7 @@ public: FindExistingResult(ASTReader &Reader) : Reader(Reader), New(nullptr), Existing(nullptr), AddResult(false), - AnonymousDeclNumber(0), TypedefNameForLinkage(0) {} + AnonymousDeclNumber(0), TypedefNameForLinkage(nullptr) {} FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing, unsigned AnonymousDeclNumber, @@ -370,7 +371,7 @@ } } }; -} +} // end namespace clang namespace { /// Iterator over the redeclarations of a declaration that have already @@ -406,7 +407,8 @@ return A.Current != B.Current; } }; -} +} // end anonymous namespace + template llvm::iterator_range> merged_redecls(DeclT *D) { return llvm::iterator_range>( @@ -1095,7 +1097,6 @@ D->IvarInitializers = Reader.ReadCXXCtorInitializersRef(F, Record, Idx); } - void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { VisitDecl(D); D->setAtLoc(ReadSourceLocation(Record, Idx)); @@ -1295,7 +1296,6 @@ D->setLocStart(ReadSourceLocation(Record, Idx)); } - void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { RedeclarableResult Redecl = VisitRedeclarable(D); VisitNamedDecl(D); @@ -2741,12 +2741,12 @@ // declaration, then we want that inner declaration. Declarations from // AST files are handled via ImportedTypedefNamesForLinkage. if (Found->isFromASTFile()) - return 0; + return nullptr; if (auto *TND = dyn_cast(Found)) return TND->getAnonDeclWithTypedefName(); - return 0; + return nullptr; } NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader, @@ -2916,6 +2916,7 @@ D->RedeclLink.setPrevious(cast(Previous)); D->First = cast(Previous)->First; } + namespace clang { template<> void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, @@ -2961,7 +2962,8 @@ std::make_pair(Canon, IsUnresolved ? PrevFD : FD)); } } -} +} // end namespace clang + void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, ...) { llvm_unreachable("attachPreviousDecl on non-redeclarable declaration"); } @@ -3539,7 +3541,7 @@ return true; } }; -} +} // end anonymous namespace void ASTReader::loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -234,6 +234,7 @@ return RefVal(getKind(), getObjKind(), getCount(), getAutoreleaseCount(), getType(), IvarAccessHistory::AccessedDirectly); } + RefVal releaseViaIvar() const { assert(getIvarAccessHistory() == IvarAccessHistory::AccessedDirectly); return RefVal(getKind(), getObjKind(), getCount(), getAutoreleaseCount(), @@ -484,7 +485,7 @@ IdentifierInfo *getIdentifier() const { return II; } Selector getSelector() const { return S; } }; -} +} // end anonymous namespace namespace llvm { template <> struct DenseMapInfo { @@ -985,7 +986,6 @@ ModifiableSummaryTemplate->setRetEffect(RetEffect::MakeNoRet()); } } - } } @@ -2414,7 +2414,7 @@ // FIXME: This will crash the analyzer if an allocation comes from an // implicit call (ex: a destructor call). // (Currently there are no such allocations in Cocoa, though.) - const Stmt *AllocStmt = 0; + const Stmt *AllocStmt = nullptr; ProgramPoint P = AllocNode->getLocation(); if (Optional Exit = P.getAs()) AllocStmt = Exit->getCalleeContext()->getCallSite(); @@ -3129,7 +3129,6 @@ } } - ProgramStateRef RetainCountChecker::updateSymbol(ProgramStateRef state, SymbolRef sym, RefVal V, ArgEffect E, RefVal::Kind &hasErr, @@ -3531,7 +3530,7 @@ ExplodedNode *Pred, RetEffect RE, RefVal X, SymbolRef Sym, - ProgramStateRef state) const { + ProgramStateRef state) const { // HACK: Ignore retain-count issues on values accessed through ivars, // because of cases like this: // [_contentView retain]; @@ -3669,7 +3668,6 @@ ProgramStateRef RetainCountChecker::evalAssume(ProgramStateRef state, SVal Cond, bool Assumption) const { - // FIXME: We may add to the interface of evalAssume the list of symbols // whose assumptions have changed. For now we just iterate through the // bindings and check if any of the tracked symbols are NULL. This isn't @@ -3993,7 +3991,9 @@ // Implementation of the CallEffects API. //===----------------------------------------------------------------------===// -namespace clang { namespace ento { namespace objc_retain { +namespace clang { +namespace ento { +namespace objc_retain { // This is a bit gross, but it allows us to populate CallEffects without // creating a bunch of accessors. This kind is very localized, so the @@ -4022,4 +4022,6 @@ #undef createCallEffect -}}} +} // end namespace objc_retain +} // end namespace ento +} // end namespace clang Index: cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp =================================================================== --- cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp +++ cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp @@ -25,6 +25,7 @@ #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" + using namespace clang; //===----------------------------------------------------------------------===// @@ -56,7 +57,7 @@ return mem; } }; -} +} // end anonymous namespace //===----------------------------------------------------------------------===// // Cleanup. @@ -246,7 +247,7 @@ CXDiagnosticSet load(const char *file); }; -} +} // end anonymous namespace CXDiagnosticSet DiagLoader::load(const char *file) { TopDiags = llvm::make_unique(); @@ -264,7 +265,7 @@ reportInvalidFile(EC.message()); break; } - return 0; + return nullptr; } return (CXDiagnosticSet)TopDiags.release(); Index: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp =================================================================== --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/SourceMgr.h" #include "gtest/gtest.h" #include + using namespace clang; using namespace llvm; using llvm::sys::fs::UniqueID; @@ -285,7 +286,7 @@ } operator StringRef() { return Path.str(); } }; -} +} // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); @@ -1006,7 +1007,7 @@ "]\n" "}", Lower); - ASSERT_TRUE(FS.get() != NULL); + ASSERT_TRUE(FS.get() != nullptr); IntrusiveRefCntPtr O( new vfs::OverlayFileSystem(Lower)); Index: cfe/trunk/unittests/CodeGen/BufferSourceTest.cpp =================================================================== --- cfe/trunk/unittests/CodeGen/BufferSourceTest.cpp +++ cfe/trunk/unittests/CodeGen/BufferSourceTest.cpp @@ -67,7 +67,7 @@ compiler.getCodeGenOpts(), llvm::getGlobalContext()))); - compiler.createSema(clang::TU_Prefix,NULL); + compiler.createSema(clang::TU_Prefix, nullptr); clang::SourceManager &sm = compiler.getSourceManager(); sm.setMainFileID(sm.createFileID( @@ -76,4 +76,4 @@ clang::ParseAST(compiler.getSema(), false, false); } -} +} // end anonymous namespace Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp @@ -54,7 +54,7 @@ const std::string &nameSpace() const { return NS; } bool knownToGCC() const { return K; } }; -} // namespace +} // end anonymous namespace static std::vector GetFlattenedSpellings(const Record &Attr) { @@ -176,7 +176,7 @@ upperName[0] = std::toupper(upperName[0]); } } - virtual ~Argument() {} + virtual ~Argument() = default; StringRef getLowerName() const { return lowerName; } StringRef getUpperName() const { return upperName; } @@ -1018,7 +1018,7 @@ getType(), "SA->get" + std::string(getUpperName()) + "Loc()"); } }; -} +} // end anonymous namespace static std::unique_ptr createArgument(const Record &Arg, StringRef Attr, @@ -1950,7 +1950,7 @@ if (Attr->isSubClassOf("TargetSpecificAttr")) { const Record *R = Attr->getValueAsDef("Target"); std::vector Arches = R->getValueAsListOfStrings("Arches"); - GenerateTargetSpecificAttrChecks(R, Arches, Test, 0); + GenerateTargetSpecificAttrChecks(R, Arches, Test, nullptr); // If this is the C++11 variety, also add in the LangOpts test. if (Variety == "CXX11") @@ -2363,6 +2363,7 @@ return "Decl"; return B + "Decl"; } + static std::string GenerateCustomAppertainsTo(const Record &Subject, raw_ostream &OS) { std::string FnName = "is" + Subject.getName();