diff options
Diffstat (limited to 'clang/Lex')
| -rw-r--r-- | clang/Lex/HeaderSearch.cpp | 40 | ||||
| -rw-r--r-- | clang/Lex/IdentifierTable.cpp | 20 | ||||
| -rw-r--r-- | clang/Lex/Lexer.cpp | 3 | ||||
| -rw-r--r-- | clang/Lex/LiteralSupport.cpp | 13 | ||||
| -rw-r--r-- | clang/Lex/MacroExpander.cpp | 5 | ||||
| -rw-r--r-- | clang/Lex/MacroInfo.cpp | 1 | ||||
| -rw-r--r-- | clang/Lex/PPExpressions.cpp | 21 | ||||
| -rw-r--r-- | clang/Lex/Pragma.cpp | 3 | ||||
| -rw-r--r-- | clang/Lex/Preprocessor.cpp | 7 | ||||
| -rw-r--r-- | clang/Lex/ScratchBuffer.cpp | 5 |
10 files changed, 53 insertions, 65 deletions
diff --git a/clang/Lex/HeaderSearch.cpp b/clang/Lex/HeaderSearch.cpp index 7937024aaee..520205e1dae 100644 --- a/clang/Lex/HeaderSearch.cpp +++ b/clang/Lex/HeaderSearch.cpp @@ -16,8 +16,6 @@ #include "clang/Lex/IdentifierTable.h" #include "llvm/System/Path.h" #include "llvm/ADT/SmallString.h" -#include "llvm/Support/Streams.h" -using namespace llvm; using namespace clang; HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) { @@ -30,8 +28,8 @@ HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) { } void HeaderSearch::PrintStats() { - cerr << "\n*** HeaderSearch Stats:\n"; - cerr << FileInfo.size() << " files tracked.\n"; + fprintf(stderr, "\n*** HeaderSearch Stats:\n"); + fprintf(stderr, "%d files tracked.\n", (int)FileInfo.size()); unsigned NumOnceOnlyFiles = 0, MaxNumIncludes = 0, NumSingleIncludedFiles = 0; for (unsigned i = 0, e = FileInfo.size(); i != e; ++i) { NumOnceOnlyFiles += FileInfo[i].isImport; @@ -39,16 +37,16 @@ void HeaderSearch::PrintStats() { MaxNumIncludes = FileInfo[i].NumIncludes; NumSingleIncludedFiles += FileInfo[i].NumIncludes == 1; } - cerr << " " << NumOnceOnlyFiles << " #import/#pragma once files.\n"; - cerr << " " << NumSingleIncludedFiles << " included exactly once.\n"; - cerr << " " << MaxNumIncludes << " max times a file is included.\n"; + fprintf(stderr, " %d #import/#pragma once files.\n", NumOnceOnlyFiles); + fprintf(stderr, " %d included exactly once.\n", NumSingleIncludedFiles); + fprintf(stderr, " %d max times a file is included.\n", MaxNumIncludes); - cerr << " " << NumIncluded << " #include/#include_next/#import.\n"; - cerr << " " << NumMultiIncludeFileOptzn << " #includes skipped due to" - << " the multi-include optimization.\n"; + fprintf(stderr, " %d #include/#include_next/#import.\n", NumIncluded); + fprintf(stderr, " %d #includes skipped due to" + " the multi-include optimization.\n", NumMultiIncludeFileOptzn); - cerr << NumFrameworkLookups << " framework lookups.\n"; - cerr << NumSubFrameworkLookups << " subframework lookups.\n"; + fprintf(stderr, "%d framework lookups.\n", NumFrameworkLookups); + fprintf(stderr, "%d subframework lookups.\n", NumSubFrameworkLookups); } //===----------------------------------------------------------------------===// @@ -62,7 +60,7 @@ const FileEntry *HeaderSearch::DoFrameworkLookup(const DirectoryEntry *Dir, const char *SlashPos = std::find(FilenameStart, FilenameEnd, '/'); if (SlashPos == FilenameEnd) return 0; - StringMapEntry<const DirectoryEntry *> &CacheLookup = + llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup = FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos); // If it is some other directory, fail. @@ -70,7 +68,7 @@ const FileEntry *HeaderSearch::DoFrameworkLookup(const DirectoryEntry *Dir, return 0; // FrameworkName = "/System/Library/Frameworks/" - SmallString<1024> FrameworkName; + llvm::SmallString<1024> FrameworkName; FrameworkName += Dir->getName(); if (FrameworkName.empty() || FrameworkName.back() != '/') FrameworkName.push_back('/'); @@ -85,8 +83,8 @@ const FileEntry *HeaderSearch::DoFrameworkLookup(const DirectoryEntry *Dir, ++NumFrameworkLookups; // If the framework dir doesn't exist, we fail. - if (!sys::Path(std::string(FrameworkName.begin(), - FrameworkName.end())).exists()) + if (!llvm::sys::Path(std::string(FrameworkName.begin(), + FrameworkName.end())).exists()) return 0; // Otherwise, if it does, remember that this is the right direntry for this @@ -135,7 +133,7 @@ const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart, return FileMgr.getFile(FilenameStart, FilenameEnd); } - SmallString<1024> TmpDir; + llvm::SmallString<1024> TmpDir; // Step #0, unless disabled, check to see if the file is in the #includer's // directory. This search is not done for <> headers. @@ -214,15 +212,15 @@ LookupSubframeworkHeader(const char *FilenameStart, if (FrameworkPos == 0) return 0; - SmallString<1024> FrameworkName(ContextName, - FrameworkPos+strlen(".framework/")); + llvm::SmallString<1024> FrameworkName(ContextName, + FrameworkPos+strlen(".framework/")); // Append Frameworks/HIToolbox.framework/ FrameworkName += "Frameworks/"; FrameworkName.append(FilenameStart, SlashPos); FrameworkName += ".framework/"; - StringMapEntry<const DirectoryEntry *> &CacheLookup = + llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup = FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos); // Some other location? @@ -249,7 +247,7 @@ LookupSubframeworkHeader(const char *FilenameStart, const FileEntry *FE = 0; // Check ".../Frameworks/HIToolbox.framework/Headers/HIToolbox.h" - SmallString<1024> HeadersFilename(FrameworkName); + llvm::SmallString<1024> HeadersFilename(FrameworkName); HeadersFilename += "Headers/"; HeadersFilename.append(SlashPos+1, FilenameEnd); if (!(FE = FileMgr.getFile(HeadersFilename.begin(), diff --git a/clang/Lex/IdentifierTable.cpp b/clang/Lex/IdentifierTable.cpp index f86d4f8b40d..e671af98391 100644 --- a/clang/Lex/IdentifierTable.cpp +++ b/clang/Lex/IdentifierTable.cpp @@ -15,8 +15,6 @@ #include "clang/Lex/IdentifierTable.h" #include "clang/Lex/MacroInfo.h" #include "clang/Basic/LangOptions.h" -#include <iostream> -using namespace llvm; using namespace clang; //===----------------------------------------------------------------------===// @@ -168,7 +166,7 @@ void IdentifierTable::PrintStats() const { unsigned MaxIdentifierLength = 0; // TODO: Figure out maximum times an identifier had to probe for -stats. - for (StringMap<IdentifierInfo, BumpPtrAllocator>::const_iterator + for (llvm::StringMap<IdentifierInfo, llvm::BumpPtrAllocator>::const_iterator I = HashTable.begin(), E = HashTable.end(); I != E; ++I) { unsigned IdLen = I->getKeyLength(); AverageIdentifierSize += IdLen; @@ -176,14 +174,14 @@ void IdentifierTable::PrintStats() const { MaxIdentifierLength = IdLen; } - std::cerr << "\n*** Identifier Table Stats:\n"; - std::cerr << "# Identifiers: " << NumIdentifiers << "\n"; - std::cerr << "# Empty Buckets: " << NumEmptyBuckets << "\n"; - std::cerr << "Hash density (#identifiers per bucket): " - << NumIdentifiers/(double)NumBuckets << "\n"; - std::cerr << "Ave identifier length: " - << (AverageIdentifierSize/(double)NumIdentifiers) << "\n"; - std::cerr << "Max identifier length: " << MaxIdentifierLength << "\n"; + fprintf(stderr, "\n*** Identifier Table Stats:\n"); + fprintf(stderr, "# Identifiers: %d\n", NumIdentifiers); + fprintf(stderr, "# Empty Buckets: %d\n", NumEmptyBuckets); + fprintf(stderr, "Hash density (#identifiers per bucket): %f\n", + NumIdentifiers/(double)NumBuckets); + fprintf(stderr, "Ave identifier length: %f\n", + (AverageIdentifierSize/(double)NumIdentifiers)); + fprintf(stderr, "Max identifier length: %d\n", MaxIdentifierLength); // Compute statistics about the memory allocated for identifiers. HashTable.getAllocator().PrintStats(); diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 9c95af1475a..1775b2f7bf4 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -30,12 +30,11 @@ #include "clang/Basic/SourceLocation.h" #include "llvm/Support/MemoryBuffer.h" #include <cctype> -using namespace llvm; using namespace clang; static void InitCharacterInfo(); -Lexer::Lexer(const MemoryBuffer *File, unsigned fileid, Preprocessor &pp, +Lexer::Lexer(const llvm::MemoryBuffer *File, unsigned fileid, Preprocessor &pp, const char *BufStart, const char *BufEnd) : BufferEnd(BufEnd ? BufEnd : File->getBufferEnd()), InputFile(File), CurFileID(fileid), PP(pp), Features(PP.getLangOptions()) { diff --git a/clang/Lex/LiteralSupport.cpp b/clang/Lex/LiteralSupport.cpp index 5b13487f502..fbc34165439 100644 --- a/clang/Lex/LiteralSupport.cpp +++ b/clang/Lex/LiteralSupport.cpp @@ -18,7 +18,6 @@ #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/StringExtras.h" -using namespace llvm; using namespace clang; /// HexDigitValue - Return the value of the specified hex digit, or -1 if it's @@ -145,7 +144,7 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf, if (isgraph(ThisTokBuf[0])) { PP.Diag(Loc, diag::ext_unknown_escape, std::string()+(char)ResultChar); } else { - PP.Diag(Loc, diag::ext_unknown_escape, "x"+utohexstr(ResultChar)); + PP.Diag(Loc, diag::ext_unknown_escape, "x"+llvm::utohexstr(ResultChar)); } break; } @@ -377,13 +376,13 @@ NumericLiteralParser(const char *begin, const char *end, /// GetIntegerValue - Convert this numeric literal value to an APInt that /// matches Val's input width. If there is an overflow, set Val to the low bits /// of the result and return true. Otherwise, return false. -bool NumericLiteralParser::GetIntegerValue(APInt &Val) { +bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) { Val = 0; s = DigitsBegin; - APInt RadixVal(Val.getBitWidth(), radix); - APInt CharVal(Val.getBitWidth(), 0); - APInt OldVal = Val; + llvm::APInt RadixVal(Val.getBitWidth(), radix); + llvm::APInt CharVal(Val.getBitWidth(), 0); + llvm::APInt OldVal = Val; bool OverflowOccurred = false; while (s < SuffixBegin) { @@ -579,7 +578,7 @@ StringLiteralParser(const LexerToken *StringToks, unsigned NumStringToks, ResultBuf.resize(SizeBound); // Likewise, but for each string piece. - SmallString<512> TokenBuf; + llvm::SmallString<512> TokenBuf; TokenBuf.resize(MaxTokenLength); // Loop over all the strings, getting their spelling, and expanding them to diff --git a/clang/Lex/MacroExpander.cpp b/clang/Lex/MacroExpander.cpp index daf0c555ade..a45efbd86e9 100644 --- a/clang/Lex/MacroExpander.cpp +++ b/clang/Lex/MacroExpander.cpp @@ -17,7 +17,6 @@ #include "clang/Basic/SourceManager.h" #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/SmallVector.h" -using namespace llvm; using namespace clang; //===----------------------------------------------------------------------===// @@ -286,7 +285,7 @@ MacroExpander::~MacroExpander() { /// Expand the arguments of a function-like macro so that we can quickly /// return preexpanded tokens from MacroTokens. void MacroExpander::ExpandFunctionArguments() { - SmallVector<LexerToken, 128> ResultToks; + llvm::SmallVector<LexerToken, 128> ResultToks; // Loop through the MacroTokens tokens, expanding them into ResultToks. Keep // track of whether we change anything. If not, no need to keep them. If so, @@ -509,7 +508,7 @@ void MacroExpander::Lex(LexerToken &Tok) { /// operator. Read the ## and RHS, and paste the LHS/RHS together. If there /// are is another ## after it, chomp it iteratively. Return the result as Tok. void MacroExpander::PasteTokens(LexerToken &Tok) { - SmallVector<char, 128> Buffer; + llvm::SmallVector<char, 128> Buffer; do { // Consume the ## operator. SourceLocation PasteOpLoc = MacroTokens[CurToken].getLocation(); diff --git a/clang/Lex/MacroInfo.cpp b/clang/Lex/MacroInfo.cpp index bc3a27d7a15..e6dae42769f 100644 --- a/clang/Lex/MacroInfo.cpp +++ b/clang/Lex/MacroInfo.cpp @@ -13,7 +13,6 @@ #include "clang/Lex/MacroInfo.h" #include "clang/Lex/Preprocessor.h" -using namespace llvm; using namespace clang; MacroInfo::MacroInfo(SourceLocation DefLoc) : Location(DefLoc) { diff --git a/clang/Lex/PPExpressions.cpp b/clang/Lex/PPExpressions.cpp index 83679423a4b..b3457e79271 100644 --- a/clang/Lex/PPExpressions.cpp +++ b/clang/Lex/PPExpressions.cpp @@ -24,10 +24,9 @@ #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallString.h" -using namespace llvm; using namespace clang; -static bool EvaluateDirectiveSubExpr(APSInt &LHS, unsigned MinPrec, +static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, LexerToken &PeekTok, bool ValueLive, Preprocessor &PP); @@ -61,7 +60,7 @@ struct DefinedTracker { /// If ValueLive is false, then this value is being evaluated in a context where /// the result is not used. As such, avoid diagnostics that relate to /// evaluation. -static bool EvaluateValue(APSInt &Result, LexerToken &PeekTok, +static bool EvaluateValue(llvm::APSInt &Result, LexerToken &PeekTok, DefinedTracker &DT, bool ValueLive, Preprocessor &PP) { Result = 0; @@ -153,7 +152,7 @@ static bool EvaluateValue(APSInt &Result, LexerToken &PeekTok, PP.Diag(PeekTok, diag::err_pp_expected_value_in_expr); return true; case tok::numeric_constant: { - SmallString<64> IntegerBuffer; + llvm::SmallString<64> IntegerBuffer; IntegerBuffer.resize(PeekTok.getLength()); const char *ThisTokBegin = &IntegerBuffer[0]; unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin); @@ -193,7 +192,7 @@ static bool EvaluateValue(APSInt &Result, LexerToken &PeekTok, return false; } case tok::char_constant: { // 'x' - SmallString<32> CharBuffer; + llvm::SmallString<32> CharBuffer; CharBuffer.resize(PeekTok.getLength()); const char *ThisTokBegin = &CharBuffer[0]; unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin); @@ -211,7 +210,7 @@ static bool EvaluateValue(APSInt &Result, LexerToken &PeekTok, NumBits = TI.getCharWidth(PeekTok.getLocation()); // Set the width. - APSInt Val(NumBits); + llvm::APSInt Val(NumBits); // Set the value. Val = Literal.getValue(); // Set the signedness. @@ -360,7 +359,7 @@ static unsigned getPrecedence(tok::TokenKind Kind) { /// If ValueLive is false, then this value is being evaluated in a context where /// the result is not used. As such, avoid diagnostics that relate to /// evaluation. -static bool EvaluateDirectiveSubExpr(APSInt &LHS, unsigned MinPrec, +static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, LexerToken &PeekTok, bool ValueLive, Preprocessor &PP) { unsigned PeekPrec = getPrecedence(PeekTok.getKind()); @@ -397,7 +396,7 @@ static bool EvaluateDirectiveSubExpr(APSInt &LHS, unsigned MinPrec, LexerToken OpToken = PeekTok; PP.LexNonComment(PeekTok); - APSInt RHS(LHS.getBitWidth()); + llvm::APSInt RHS(LHS.getBitWidth()); // Parse the RHS of the operator. DefinedTracker DT; if (EvaluateValue(RHS, PeekTok, DT, RHSIsLive, PP)) return true; @@ -427,7 +426,7 @@ static bool EvaluateDirectiveSubExpr(APSInt &LHS, unsigned MinPrec, // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if // either operand is unsigned. Don't do this for x and y in "x ? y : z". - APSInt Res(LHS.getBitWidth()); + llvm::APSInt Res(LHS.getBitWidth()); if (Operator != tok::question) { Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned()); // If this just promoted something from signed to unsigned, and if the @@ -564,7 +563,7 @@ static bool EvaluateDirectiveSubExpr(APSInt &LHS, unsigned MinPrec, // Evaluate the value after the :. bool AfterColonLive = ValueLive && LHS == 0; - APSInt AfterColonVal(LHS.getBitWidth()); + llvm::APSInt AfterColonVal(LHS.getBitWidth()); DefinedTracker DT; if (EvaluateValue(AfterColonVal, PeekTok, DT, AfterColonLive, PP)) return true; @@ -613,7 +612,7 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { // C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t. unsigned BitWidth = getTargetInfo().getIntMaxTWidth(Tok.getLocation()); - APSInt ResVal(BitWidth); + llvm::APSInt ResVal(BitWidth); DefinedTracker DT; if (EvaluateValue(ResVal, Tok, DT, true, *this)) { // Parse error, skip the rest of the macro line. diff --git a/clang/Lex/Pragma.cpp b/clang/Lex/Pragma.cpp index 1b542feb183..de59934b4d0 100644 --- a/clang/Lex/Pragma.cpp +++ b/clang/Lex/Pragma.cpp @@ -20,7 +20,6 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/SmallVector.h" -using namespace llvm; using namespace clang; // Out-of-line destructor to provide a home for the class. @@ -256,7 +255,7 @@ void Preprocessor::HandlePragmaDependency(LexerToken &DependencyTok) { return; // Reserve a buffer to get the spelling. - SmallVector<char, 128> FilenameBuffer; + llvm::SmallVector<char, 128> FilenameBuffer; FilenameBuffer.resize(FilenameTok.getLength()); const char *FilenameStart = &FilenameBuffer[0], *FilenameEnd; diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp index 77e1677755a..104fb651521 100644 --- a/clang/Lex/Preprocessor.cpp +++ b/clang/Lex/Preprocessor.cpp @@ -37,7 +37,6 @@ #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/SmallVector.h" #include <iostream> -using namespace llvm; using namespace clang; //===----------------------------------------------------------------------===// @@ -343,7 +342,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, if (MaxIncludeStackDepth < IncludeMacroStack.size()) MaxIncludeStackDepth = IncludeMacroStack.size(); - const MemoryBuffer *Buffer = SourceMgr.getBuffer(FileID); + const llvm::MemoryBuffer *Buffer = SourceMgr.getBuffer(FileID); Lexer *TheLexer = new Lexer(Buffer, FileID, *this); if (isMainFile) TheLexer->setIsMainFile(); EnterSourceFileWithLexer(TheLexer, CurDir); @@ -658,7 +657,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName, // ArgTokens - Build up a list of tokens that make up each argument. Each // argument is separated by an EOF token. Use a SmallVector so we can avoid // heap allocations in the common case. - SmallVector<LexerToken, 64> ArgTokens; + llvm::SmallVector<LexerToken, 64> ArgTokens; unsigned NumActuals = 0; while (Tok.getKind() == tok::comma) { @@ -1556,7 +1555,7 @@ void Preprocessor::HandleIncludeDirective(LexerToken &IncludeTok, return; // Reserve a buffer to get the spelling. - SmallVector<char, 128> FilenameBuffer; + llvm::SmallVector<char, 128> FilenameBuffer; FilenameBuffer.resize(FilenameTok.getLength()); const char *FilenameStart = &FilenameBuffer[0], *FilenameEnd; diff --git a/clang/Lex/ScratchBuffer.cpp b/clang/Lex/ScratchBuffer.cpp index a53bb2e17ea..12cb0965ce8 100644 --- a/clang/Lex/ScratchBuffer.cpp +++ b/clang/Lex/ScratchBuffer.cpp @@ -14,7 +14,6 @@ #include "clang/Lex/ScratchBuffer.h" #include "clang/Basic/SourceManager.h" #include "llvm/Support/MemoryBuffer.h" -using namespace llvm; using namespace clang; // ScratchBufSize - The size of each chunk of scratch memory. Slightly less @@ -64,8 +63,8 @@ void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) { if (RequestLen < ScratchBufSize) RequestLen = ScratchBufSize; - MemoryBuffer *Buf = - MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>"); + llvm::MemoryBuffer *Buf = + llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>"); FileID = SourceMgr.createFileIDForMemBuffer(Buf); CurBuffer = const_cast<char*>(Buf->getBufferStart()); BytesUsed = 0; |

