diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-05-17 23:10:59 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-05-17 23:10:59 +0000 |
commit | d2d442ca7385fe5c50f43c2731710ab1ac564ddb (patch) | |
tree | c942d260a048a2c5df5cc9f8ee62b2d34769d1c2 /clang/lib/Lex/PPMacroExpansion.cpp | |
parent | f3a5a5c54698150c264ddda39cb61a219184e5ae (diff) | |
download | bcm5719-llvm-d2d442ca7385fe5c50f43c2731710ab1ac564ddb.tar.gz bcm5719-llvm-d2d442ca7385fe5c50f43c2731710ab1ac564ddb.zip |
[C++11] Use 'nullptr'. Lex edition.
llvm-svn: 209083
Diffstat (limited to 'clang/lib/Lex/PPMacroExpansion.cpp')
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index fa517e7fa81..4278faef708 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -103,8 +103,8 @@ void Preprocessor::RegisterBuiltinMacros() { Ident__identifier = RegisterBuiltinMacro(*this, "__identifier"); Ident__pragma = RegisterBuiltinMacro(*this, "__pragma"); } else { - Ident__identifier = 0; - Ident__pragma = 0; + Ident__identifier = nullptr; + Ident__pragma = nullptr; } // Clang Extensions. @@ -125,10 +125,10 @@ void Preprocessor::RegisterBuiltinMacros() { if (!LangOpts.CurrentModule.empty()) Ident__MODULE__ = RegisterBuiltinMacro(*this, "__MODULE__"); else - Ident__MODULE__ = 0; + Ident__MODULE__ = nullptr; } else { - Ident__building_module = 0; - Ident__MODULE__ = 0; + Ident__building_module = nullptr; + Ident__MODULE__ = nullptr; } } @@ -140,7 +140,7 @@ static bool isTrivialSingleTokenExpansion(const MacroInfo *MI, IdentifierInfo *II = MI->getReplacementToken(0).getIdentifierInfo(); // If the token isn't an identifier, it's always literally expanded. - if (II == 0) return true; + if (!II) return true; // If the information about this identifier is out of date, update it from // the external source. @@ -228,7 +228,8 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // If this is a builtin macro, like __LINE__ or _Pragma, handle it specially. if (MI->isBuiltinMacro()) { if (Callbacks) Callbacks->MacroExpands(Identifier, MD, - Identifier.getLocation(),/*Args=*/0); + Identifier.getLocation(), + /*Args=*/nullptr); ExpandBuiltinMacro(Identifier); return true; } @@ -236,7 +237,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, /// Args - If this is a function-like macro expansion, this contains, /// for each macro argument, the list of tokens that were provided to the /// invocation. - MacroArgs *Args = 0; + MacroArgs *Args = nullptr; // Remember where the end of the expansion occurred. For an object-like // macro, this is the identifier. For a function-like macro, this is the ')'. @@ -254,7 +255,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, InMacroArgs = false; // If there was an error parsing the arguments, bail out. - if (Args == 0) return true; + if (!Args) return true; ++NumFnMacroExpanded; } else { @@ -282,7 +283,8 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, for (unsigned i=0, e = DelayedMacroExpandsCallbacks.size(); i!=e; ++i) { MacroExpandsInfo &Info = DelayedMacroExpandsCallbacks[i]; // FIXME: We lose macro args info with delayed callback. - Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range, /*Args=*/0); + Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range, + /*Args=*/nullptr); } DelayedMacroExpandsCallbacks.clear(); } @@ -557,7 +559,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, << MacroName.getIdentifierInfo(); // Do not lose the EOF/EOD. Return it to the client. MacroName = Tok; - return 0; + return nullptr; } else { // Do not lose the EOF/EOD. Token *Toks = new Token[1]; @@ -589,7 +591,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // If this is a comment token in the argument list and we're just in // -C mode (not -CC mode), discard the comment. continue; - } else if (Tok.getIdentifierInfo() != 0) { + } else if (Tok.getIdentifierInfo() != nullptr) { // Reading macro arguments can cause macros that we are currently // expanding from to be popped off the expansion stack. Doing so causes // them to be reenabled for expansion. Here we record whether any @@ -681,10 +683,10 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, DB << *Range; } } - return 0; + return nullptr; } if (FixedNumArgs != MinArgsExpected) - return 0; + return nullptr; DiagnosticBuilder DB = Diag(MacroName, diag::note_suggest_parens_for_macro); for (SmallVector<SourceRange, 4>::iterator @@ -751,7 +753,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, Diag(Tok, diag::err_too_few_args_in_macro_invoc); Diag(MI->getDefinitionLoc(), diag::note_macro_here) << MacroName.getIdentifierInfo(); - return 0; + return nullptr; } // Add a marker EOF token to the end of the token list for this argument. @@ -773,7 +775,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, Diag(MacroName, diag::err_too_many_args_in_macro_invoc); Diag(MI->getDefinitionLoc(), diag::note_macro_here) << MacroName.getIdentifierInfo(); - return 0; + return nullptr; } return MacroArgs::create(MI, ArgTokens, isVarargsElided, *this); @@ -788,7 +790,7 @@ Token *Preprocessor::cacheMacroExpandedTokens(TokenLexer *tokLexer, ArrayRef<Token> tokens) { assert(tokLexer); if (tokens.empty()) - return 0; + return nullptr; size_t newIndex = MacroExpandedTokens.size(); bool cacheNeedsToGrow = tokens.size() > @@ -824,7 +826,7 @@ void Preprocessor::removeCachedMacroExpandedTokensOfLastLexer() { /// the identifier tokens inserted. static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP) { - time_t TT = time(0); + time_t TT = time(nullptr); struct tm *TM = localtime(&TT); static const char * const Months[] = { @@ -1154,18 +1156,18 @@ static bool EvaluateHasIncludeCommon(Token &Tok, // Search include directories. const DirectoryLookup *CurDir; const FileEntry *File = - PP.LookupFile(FilenameLoc, Filename, isAngled, LookupFrom, CurDir, NULL, - NULL, NULL); + PP.LookupFile(FilenameLoc, Filename, isAngled, LookupFrom, CurDir, + nullptr, nullptr, nullptr); // Get the result value. A result of true means the file exists. - return File != 0; + return File != nullptr; } /// EvaluateHasInclude - Process a '__has_include("path")' expression. /// Returns true if successful. static bool EvaluateHasInclude(Token &Tok, IdentifierInfo *II, Preprocessor &PP) { - return EvaluateHasIncludeCommon(Tok, II, PP, NULL); + return EvaluateHasIncludeCommon(Tok, II, PP, nullptr); } /// EvaluateHasIncludeNext - Process '__has_include_next("path")' expression. @@ -1177,9 +1179,9 @@ static bool EvaluateHasIncludeNext(Token &Tok, // issue a diagnostic. const DirectoryLookup *Lookup = PP.GetCurDirLookup(); if (PP.isInPrimaryFile()) { - Lookup = 0; + Lookup = nullptr; PP.Diag(Tok, diag::pp_include_next_in_primary); - } else if (Lookup == 0) { + } else if (!Lookup) { PP.Diag(Tok, diag::pp_include_next_absolute_path); } else { // Start looking up in the next directory. @@ -1252,7 +1254,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { llvm::raw_svector_ostream OS(TmpBuffer); // Set up the return result. - Tok.setIdentifierInfo(0); + Tok.setIdentifierInfo(nullptr); Tok.clearFlag(Token::NeedsCleaning); if (II == Ident__LINE__) { @@ -1341,7 +1343,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { // Get the file that we are lexing out of. If we're currently lexing from // a macro, dig into the include stack. - const FileEntry *CurFile = 0; + const FileEntry *CurFile = nullptr; PreprocessorLexer *TheLexer = getCurrentFileLexer(); if (TheLexer) @@ -1371,7 +1373,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { SourceLocation StartLoc = Tok.getLocation(); bool IsValid = false; - IdentifierInfo *FeatureII = 0; + IdentifierInfo *FeatureII = nullptr; // Read the '('. LexUnexpandedToken(Tok); |