diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/StmtDumper.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Analysis/LiveVariables.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Basic/SourceLocation.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 32 | ||||
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 30 | ||||
-rw-r--r-- | clang/lib/Lex/PreprocessorLexer.cpp | 2 |
9 files changed, 61 insertions, 60 deletions
diff --git a/clang/lib/AST/StmtDumper.cpp b/clang/lib/AST/StmtDumper.cpp index c3ce92de60b..1ee3efab0a2 100644 --- a/clang/lib/AST/StmtDumper.cpp +++ b/clang/lib/AST/StmtDumper.cpp @@ -152,21 +152,22 @@ namespace { //===----------------------------------------------------------------------===// void StmtDumper::DumpLocation(SourceLocation Loc) { - SourceLocation PhysLoc = SM->getPhysicalLoc(Loc); + SourceLocation SpellingLoc = SM->getSpellingLoc(Loc); // The general format we print out is filename:line:col, but we drop pieces // that haven't changed since the last loc printed. - const char *Filename = SM->getSourceName(PhysLoc); - unsigned LineNo = SM->getLineNumber(PhysLoc); + const char *Filename = SM->getSourceName(SpellingLoc); + unsigned LineNo = SM->getLineNumber(SpellingLoc); + unsigned ColNo = SM->getColumnNumber(SpellingLoc); if (strcmp(Filename, LastLocFilename) != 0) { - fprintf(stderr, "%s:%u:%u", Filename, LineNo, SM->getColumnNumber(PhysLoc)); + fprintf(stderr, "%s:%u:%u", Filename, LineNo, ColNo); LastLocFilename = Filename; LastLocLine = LineNo; } else if (LineNo != LastLocLine) { - fprintf(stderr, "line:%u:%u", LineNo, SM->getColumnNumber(PhysLoc)); + fprintf(stderr, "line:%u:%u", LineNo, ColNo); LastLocLine = LineNo; } else { - fprintf(stderr, "col:%u", SM->getColumnNumber(PhysLoc)); + fprintf(stderr, "col:%u", ColNo); } } diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index 8105e38b674..ac0aa9ba8c6 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/lib/Analysis/LiveVariables.cpp @@ -358,13 +358,13 @@ void LiveVariables::dumpLiveness(const ValTy& V, SourceManager& SM) const { for (AnalysisDataTy::decl_iterator I = AD.begin_decl(), E = AD.end_decl(); I!=E; ++I) if (V.getDeclBit(I->second)) { - SourceLocation PhysLoc = SM.getPhysicalLoc(I->first->getLocation()); + SourceLocation SpellingLoc = SM.getSpellingLoc(I->first->getLocation()); fprintf(stderr, " %s <%s:%u:%u>\n", I->first->getIdentifier()->getName(), - SM.getSourceName(PhysLoc), - SM.getLineNumber(PhysLoc), - SM.getColumnNumber(PhysLoc)); + SM.getSourceName(SpellingLoc), + SM.getLineNumber(SpellingLoc), + SM.getColumnNumber(SpellingLoc)); } } diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 88532a7e732..340ef28846c 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -244,7 +244,7 @@ void Diagnostic::ProcessDiag() { Info.getID() < diag::NUM_BUILTIN_DIAGNOSTICS && getBuiltinDiagClass(Info.getID()) != ERROR && Info.getLocation().isValid() && - Info.getLocation().getPhysicalLoc().isInSystemHeader()) + Info.getLocation().getSpellingLoc().isInSystemHeader()) return; if (DiagLevel >= Diagnostic::Error) { diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp index 5236bfaffba..bb8cac2f9f0 100644 --- a/clang/lib/Basic/SourceLocation.cpp +++ b/clang/lib/Basic/SourceLocation.cpp @@ -42,9 +42,9 @@ FullSourceLoc FullSourceLoc::getLogicalLoc() const { return FullSourceLoc(SrcMgr->getLogicalLoc(Loc), *SrcMgr); } -FullSourceLoc FullSourceLoc::getPhysicalLoc() const { - assert (isValid()); - return FullSourceLoc(SrcMgr->getPhysicalLoc(Loc), *SrcMgr); +FullSourceLoc FullSourceLoc::getSpellingLoc() const { + assert(isValid()); + return FullSourceLoc(SrcMgr->getSpellingLoc(Loc), *SrcMgr); } FullSourceLoc FullSourceLoc::getIncludeLoc() const { @@ -73,14 +73,14 @@ unsigned FullSourceLoc::getLogicalColumnNumber() const { return SrcMgr->getLogicalColumnNumber(Loc); } -unsigned FullSourceLoc::getPhysicalLineNumber() const { +unsigned FullSourceLoc::getSpellingLineNumber() const { assert (isValid()); - return SrcMgr->getPhysicalLineNumber(Loc); + return SrcMgr->getSpellingLineNumber(Loc); } -unsigned FullSourceLoc::getPhysicalColumnNumber() const { +unsigned FullSourceLoc::getSpellingColumnNumber() const { assert (isValid()); - return SrcMgr->getPhysicalColumnNumber(Loc); + return SrcMgr->getSpellingColumnNumber(Loc); } const char* FullSourceLoc::getSourceName() const { @@ -120,13 +120,13 @@ void FullSourceLoc::dump() const { } if (isFileID()) { - // The logical and physical pos is identical for file locs. + // The logical and spelling pos is identical for file locs. fprintf(stderr, "File Loc from '%s': %d: %d\n", getSourceName(), getLogicalLineNumber(), getLogicalColumnNumber()); } else { - fprintf(stderr, "Macro Loc (\n Physical: "); - getPhysicalLoc().dump(); + fprintf(stderr, "Macro Loc (\n Spelling: "); + getSpellingLoc().dump(); fprintf(stderr, " Logical: "); getLogicalLoc().dump(); fprintf(stderr, ")\n"); diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 8691b53d565..719d29aa795 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -146,14 +146,14 @@ unsigned SourceManager::createFileID(const ContentCache *File, } /// getInstantiationLoc - Return a new SourceLocation that encodes the fact -/// that a token from physloc PhysLoc should actually be referenced from +/// that a token from SpellingLoc should actually be referenced from /// InstantiationLoc. -SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc, +SourceLocation SourceManager::getInstantiationLoc(SourceLocation SpellingLoc, SourceLocation InstantLoc) { // The specified source location may be a mapped location, due to a macro // instantiation or #line directive. Strip off this information to find out // where the characters are actually located. - PhysLoc = getPhysicalLoc(PhysLoc); + SpellingLoc = getSpellingLoc(SpellingLoc); // Resolve InstantLoc down to a real logical location. InstantLoc = getLogicalLoc(InstantLoc); @@ -164,21 +164,21 @@ SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc, for (int i = MacroIDs.size()-1, e = MacroIDs.size()-6; i >= 0 && i != e; --i){ MacroIDInfo &LastOne = MacroIDs[i]; - // The instanitation point and source physloc have to exactly match to reuse - // (for now). We could allow "nearby" instantiations in the future. + // The instanitation point and source SpellingLoc have to exactly match to + // reuse (for now). We could allow "nearby" instantiations in the future. if (LastOne.getVirtualLoc() != InstantLoc || - LastOne.getPhysicalLoc().getFileID() != PhysLoc.getFileID()) + LastOne.getSpellingLoc().getFileID() != SpellingLoc.getFileID()) continue; - // Check to see if the physloc of the token came from near enough to reuse. - int PhysDelta = PhysLoc.getRawFilePos() - - LastOne.getPhysicalLoc().getRawFilePos(); - if (SourceLocation::isValidMacroPhysOffs(PhysDelta)) - return SourceLocation::getMacroLoc(i, PhysDelta); + // Check to see if the spellloc of the token came from near enough to reuse. + int SpellDelta = SpellingLoc.getRawFilePos() - + LastOne.getSpellingLoc().getRawFilePos(); + if (SourceLocation::isValidMacroSpellingOffs(SpellDelta)) + return SourceLocation::getMacroLoc(i, SpellDelta); } - MacroIDs.push_back(MacroIDInfo::get(InstantLoc, PhysLoc)); + MacroIDs.push_back(MacroIDInfo::get(InstantLoc, SpellingLoc)); return SourceLocation::getMacroLoc(MacroIDs.size()-1, 0); } @@ -196,7 +196,7 @@ SourceManager::getBufferData(unsigned FileID) const { const char *SourceManager::getCharacterData(SourceLocation SL) const { // Note that this is a hot function in the getSpelling() path, which is // heavily used by -E mode. - SL = getPhysicalLoc(SL); + SL = getSpellingLoc(SL); // Note that calling 'getBuffer()' may lazily page in a source file. return getContentCache(SL.getFileID())->getBuffer()->getBufferStart() + @@ -279,7 +279,7 @@ static void ComputeLineNumbers(ContentCache* FI) { std::copy(LineOffsets.begin(), LineOffsets.end(), FI->SourceLineCache); } -/// getLineNumber - Given a SourceLocation, return the physical line number +/// getLineNumber - Given a SourceLocation, return the spelling line number /// for the position indicated. This requires building and caching a table of /// line offsets for the MemoryBuffer, so this is not cheap: use only when /// about to emit a diagnostic. @@ -481,13 +481,13 @@ FileIDInfo FileIDInfo::ReadVal(llvm::Deserializer& D) { void MacroIDInfo::Emit(llvm::Serializer& S) const { S.Emit(VirtualLoc); - S.Emit(PhysicalLoc); + S.Emit(SpellingLoc); } MacroIDInfo MacroIDInfo::ReadVal(llvm::Deserializer& D) { MacroIDInfo I; I.VirtualLoc = SourceLocation::ReadVal(D); - I.PhysicalLoc = SourceLocation::ReadVal(D); + I.SpellingLoc = SourceLocation::ReadVal(D); return I; } diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index e6030ad1d45..96295d042fb 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -68,7 +68,7 @@ Lexer::Lexer(SourceLocation fileloc, Preprocessor &pp, Features(pp.getLangOptions()) { SourceManager &SourceMgr = PP->getSourceManager(); - unsigned InputFileID = SourceMgr.getPhysicalLoc(FileLoc).getFileID(); + unsigned InputFileID = SourceMgr.getSpellingLoc(FileLoc).getFileID(); const llvm::MemoryBuffer *InputFile = SourceMgr.getBuffer(InputFileID); Is_PragmaLexer = false; @@ -281,15 +281,15 @@ static SourceLocation GetMappedTokenLoc(Preprocessor &PP, unsigned CharNo) { // Otherwise, we're lexing "mapped tokens". This is used for things like // _Pragma handling. Combine the instantiation location of FileLoc with the - // physical location. + // spelling location. SourceManager &SourceMgr = PP.getSourceManager(); // Create a new SLoc which is expanded from logical(FileLoc) but whose - // characters come from phys(FileLoc)+Offset. + // characters come from spelling(FileLoc)+Offset. SourceLocation VirtLoc = SourceMgr.getLogicalLoc(FileLoc); - SourceLocation PhysLoc = SourceMgr.getPhysicalLoc(FileLoc); - PhysLoc = SourceLocation::getFileLoc(PhysLoc.getFileID(), CharNo); - return SourceMgr.getInstantiationLoc(PhysLoc, VirtLoc); + SourceLocation SpellingLoc = SourceMgr.getSpellingLoc(FileLoc); + SpellingLoc = SourceLocation::getFileLoc(SpellingLoc.getFileID(), CharNo); + return SourceMgr.getInstantiationLoc(SpellingLoc, VirtLoc); } /// getSourceLocation - Return a source location identifier for the specified diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index 19ff4942a88..6401b9ac8fd 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -422,7 +422,7 @@ unsigned PTHSpellingSearch::getSpellingBinarySearch(unsigned fpos, unsigned PTHLexer::getSpelling(SourceLocation sloc, const char *&Buffer) { SourceManager& SM = PP->getSourceManager(); - sloc = SM.getPhysicalLoc(sloc); + sloc = SM.getSpellingLoc(sloc); unsigned fid = SM.getCanonicalFileID(sloc); unsigned fpos = SM.getFullFilePos(sloc); diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index cac78fe6e00..c1d30573cda 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -145,10 +145,10 @@ void Preprocessor::DumpLocation(SourceLocation Loc) const { << SourceMgr.getLineNumber(LogLoc) << ':' << SourceMgr.getColumnNumber(LogLoc); - SourceLocation PhysLoc = SourceMgr.getPhysicalLoc(Loc); - if (PhysLoc != LogLoc) { - llvm::cerr << " <PhysLoc="; - DumpLocation(PhysLoc); + SourceLocation SpellingLoc = SourceMgr.getSpellingLoc(Loc); + if (SpellingLoc != LogLoc) { + llvm::cerr << " <SpellingLoc="; + DumpLocation(SpellingLoc); llvm::cerr << ">"; } } @@ -199,12 +199,12 @@ std::string Preprocessor::getSpelling(const Token &Tok) const { const char* TokStart; if (PTH) { - SourceLocation sloc = SourceMgr.getPhysicalLoc(Tok.getLocation()); - unsigned fid = SourceMgr.getCanonicalFileID(sloc); - unsigned fpos = SourceMgr.getFullFilePos(sloc); - if (unsigned len = PTH->getSpelling(fid, fpos, TokStart)) { + SourceLocation SLoc = SourceMgr.getSpellingLoc(Tok.getLocation()); + unsigned fid = SourceMgr.getCanonicalFileID(SLoc); + unsigned fpos = SourceMgr.getFullFilePos(SLoc); + if (unsigned Len = PTH->getSpelling(fid, fpos, TokStart)) { assert(!Tok.needsCleaning()); - return std::string(TokStart, TokStart+len); + return std::string(TokStart, TokStart+Len); } } @@ -251,7 +251,7 @@ unsigned Preprocessor::getSpelling(const Token &Tok, // If using PTH, try and get the spelling from the PTH file. if (PTH) { - unsigned len; + unsigned Len; if (CurPTHLexer) { // We perform the const_cast<> here because we will only have a PTHLexer @@ -260,22 +260,22 @@ unsigned Preprocessor::getSpelling(const Token &Tok, // getting token spellings in the order of tokens, and thus can update // its internal state so that it can quickly fetch spellings from the PTH // file. - len = + Len = const_cast<PTHLexer*>(CurPTHLexer.get())->getSpelling(Tok.getLocation(), Buffer); } else { - SourceLocation sloc = SourceMgr.getPhysicalLoc(Tok.getLocation()); + SourceLocation sloc = SourceMgr.getSpellingLoc(Tok.getLocation()); unsigned fid = SourceMgr.getCanonicalFileID(sloc); unsigned fpos = SourceMgr.getFullFilePos(sloc); - len = PTH->getSpelling(fid, fpos, Buffer); + Len = PTH->getSpelling(fid, fpos, Buffer); } // Did we find a spelling? If so return its length. Otherwise fall // back to the default behavior for getting the spelling by looking at // at the source code. - if (len) - return len; + if (Len) + return Len; } // Otherwise, compute the start of the token in the input lexer buffer. diff --git a/clang/lib/Lex/PreprocessorLexer.cpp b/clang/lib/Lex/PreprocessorLexer.cpp index 5b3538a45b1..07329e0cc78 100644 --- a/clang/lib/Lex/PreprocessorLexer.cpp +++ b/clang/lib/Lex/PreprocessorLexer.cpp @@ -18,7 +18,7 @@ using namespace clang; PreprocessorLexer::PreprocessorLexer(Preprocessor* pp, SourceLocation L) - : PP(pp), FileID(pp->getSourceManager().getPhysicalLoc(L).getFileID()), + : PP(pp), FileID(pp->getSourceManager().getSpellingLoc(L).getFileID()), ParsingPreprocessorDirective(false), ParsingFilename(false), LexingRawMode(false) {} |