Rename getInstantiationLineNumber to getExpansionLineNumber in both

SourceManager and FullSourceLoc.

llvm-svn: 135969
This commit is contained in:
Chandler Carruth 2011-07-25 21:09:52 +00:00
parent 3ddf6aa503
commit d48db2115a
17 changed files with 37 additions and 39 deletions

View File

@ -277,7 +277,7 @@ public:
FullSourceLoc getExpansionLoc() const; FullSourceLoc getExpansionLoc() const;
FullSourceLoc getSpellingLoc() const; FullSourceLoc getSpellingLoc() const;
unsigned getInstantiationLineNumber(bool *Invalid = 0) const; unsigned getExpansionLineNumber(bool *Invalid = 0) const;
unsigned getExpansionColumnNumber(bool *Invalid = 0) const; unsigned getExpansionColumnNumber(bool *Invalid = 0) const;
unsigned getSpellingLineNumber(bool *Invalid = 0) const; unsigned getSpellingLineNumber(bool *Invalid = 0) const;

View File

@ -839,8 +839,7 @@ public:
/// about to emit a diagnostic. /// about to emit a diagnostic.
unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid = 0) const; unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid = 0) const;
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid = 0) const; unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid = 0) const;
unsigned getInstantiationLineNumber(SourceLocation Loc, unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid = 0) const;
bool *Invalid = 0) const;
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid = 0) const; unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid = 0) const;
/// Return the filename or buffer identifier of the buffer the location is in. /// Return the filename or buffer identifier of the buffer the location is in.

View File

@ -55,7 +55,7 @@ static void EmitLocation(raw_ostream& o, const SourceManager &SM,
Indent(o, indent) << "<dict>\n"; Indent(o, indent) << "<dict>\n";
Indent(o, indent) << " <key>line</key><integer>" Indent(o, indent) << " <key>line</key><integer>"
<< Loc.getInstantiationLineNumber() << "</integer>\n"; << Loc.getExpansionLineNumber() << "</integer>\n";
Indent(o, indent) << " <key>col</key><integer>" Indent(o, indent) << " <key>col</key><integer>"
<< Loc.getExpansionColumnNumber() + offset << "</integer>\n"; << Loc.getExpansionColumnNumber() + offset << "</integer>\n";
Indent(o, indent) << " <key>file</key><integer>" Indent(o, indent) << " <key>file</key><integer>"

View File

@ -85,9 +85,9 @@ FullSourceLoc FullSourceLoc::getSpellingLoc() const {
return FullSourceLoc(SrcMgr->getSpellingLoc(*this), *SrcMgr); return FullSourceLoc(SrcMgr->getSpellingLoc(*this), *SrcMgr);
} }
unsigned FullSourceLoc::getInstantiationLineNumber(bool *Invalid) const { unsigned FullSourceLoc::getExpansionLineNumber(bool *Invalid) const {
assert(isValid()); assert(isValid());
return SrcMgr->getInstantiationLineNumber(*this, Invalid); return SrcMgr->getExpansionLineNumber(*this, Invalid);
} }
unsigned FullSourceLoc::getExpansionColumnNumber(bool *Invalid) const { unsigned FullSourceLoc::getExpansionColumnNumber(bool *Invalid) const {

View File

@ -1153,7 +1153,7 @@ unsigned SourceManager::getSpellingLineNumber(SourceLocation Loc,
std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(Loc); std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(Loc);
return getLineNumber(LocInfo.first, LocInfo.second); return getLineNumber(LocInfo.first, LocInfo.second);
} }
unsigned SourceManager::getInstantiationLineNumber(SourceLocation Loc, unsigned SourceManager::getExpansionLineNumber(SourceLocation Loc,
bool *Invalid) const { bool *Invalid) const {
if (isInvalid(Loc, Invalid)) return 0; if (isInvalid(Loc, Invalid)) return 0;
std::pair<FileID, unsigned> LocInfo = getDecomposedExpansionLoc(Loc); std::pair<FileID, unsigned> LocInfo = getDecomposedExpansionLoc(Loc);

View File

@ -274,8 +274,7 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) { if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) {
SourceManager &SM = CGM.getContext().getSourceManager(); SourceManager &SM = CGM.getContext().getSourceManager();
llvm::Constant *Ann = llvm::Constant *Ann =
CGM.EmitAnnotateAttr(GV, AA, CGM.EmitAnnotateAttr(GV, AA, SM.getExpansionLineNumber(D.getLocation()));
SM.getInstantiationLineNumber(D.getLocation()));
CGM.AddAnnotation(Ann); CGM.AddAnnotation(Ann);
} }

View File

@ -1311,8 +1311,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
if (const AnnotateAttr *AA = D->getAttr<AnnotateAttr>()) { if (const AnnotateAttr *AA = D->getAttr<AnnotateAttr>()) {
SourceManager &SM = Context.getSourceManager(); SourceManager &SM = Context.getSourceManager();
AddAnnotation(EmitAnnotateAttr(GV, AA, AddAnnotation(EmitAnnotateAttr(
SM.getInstantiationLineNumber(D->getLocation()))); GV, AA, SM.getExpansionLineNumber(D->getLocation())));
} }
GV->setInitializer(Init); GV->setInitializer(Init);

View File

@ -96,11 +96,11 @@ void TextDiagnosticPrinter::HighlightRange(const CharSourceRange &R,
if (Begin == End && R.getEnd().isMacroID()) if (Begin == End && R.getEnd().isMacroID())
End = SM.getExpansionRange(R.getEnd()).second; End = SM.getExpansionRange(R.getEnd()).second;
unsigned StartLineNo = SM.getInstantiationLineNumber(Begin); unsigned StartLineNo = SM.getExpansionLineNumber(Begin);
if (StartLineNo > LineNo || SM.getFileID(Begin) != FID) if (StartLineNo > LineNo || SM.getFileID(Begin) != FID)
return; // No intersection. return; // No intersection.
unsigned EndLineNo = SM.getInstantiationLineNumber(End); unsigned EndLineNo = SM.getExpansionLineNumber(End);
if (EndLineNo < LineNo || SM.getFileID(End) != FID) if (EndLineNo < LineNo || SM.getFileID(End) != FID)
return; // No intersection. return; // No intersection.

View File

@ -1567,12 +1567,12 @@ StmtResult Parser::FuzzyParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
// that the rest of the line is an assembly-language statement. // that the rest of the line is an assembly-language statement.
SourceManager &SrcMgr = PP.getSourceManager(); SourceManager &SrcMgr = PP.getSourceManager();
SourceLocation TokLoc = Tok.getLocation(); SourceLocation TokLoc = Tok.getLocation();
unsigned LineNo = SrcMgr.getInstantiationLineNumber(TokLoc); unsigned LineNo = SrcMgr.getExpansionLineNumber(TokLoc);
do { do {
EndLoc = TokLoc; EndLoc = TokLoc;
ConsumeAnyToken(); ConsumeAnyToken();
TokLoc = Tok.getLocation(); TokLoc = Tok.getLocation();
} while ((SrcMgr.getInstantiationLineNumber(TokLoc) == LineNo) && } while ((SrcMgr.getExpansionLineNumber(TokLoc) == LineNo) &&
Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) && Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
Tok.isNot(tok::eof)); Tok.isNot(tok::eof));
} }

View File

@ -933,8 +933,8 @@ void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
SourceLocation LocStart = Method->getLocStart(); SourceLocation LocStart = Method->getLocStart();
SourceLocation LocEnd = Method->getLocEnd(); SourceLocation LocEnd = Method->getLocEnd();
if (SM->getInstantiationLineNumber(LocEnd) > if (SM->getExpansionLineNumber(LocEnd) >
SM->getInstantiationLineNumber(LocStart)) { SM->getExpansionLineNumber(LocStart)) {
InsertText(LocStart, "#if 0\n"); InsertText(LocStart, "#if 0\n");
ReplaceText(LocEnd, 1, ";\n#endif\n"); ReplaceText(LocEnd, 1, ";\n#endif\n");
} else { } else {

View File

@ -53,7 +53,7 @@ SourceRange StackAddrEscapeChecker::GenName(raw_ostream &os,
const CompoundLiteralExpr* CL = CR->getLiteralExpr(); const CompoundLiteralExpr* CL = CR->getLiteralExpr();
os << "stack memory associated with a compound literal " os << "stack memory associated with a compound literal "
"declared on line " "declared on line "
<< SM.getInstantiationLineNumber(CL->getLocStart()) << SM.getExpansionLineNumber(CL->getLocStart())
<< " returned to caller"; << " returned to caller";
range = CL->getSourceRange(); range = CL->getSourceRange();
} }
@ -62,14 +62,14 @@ SourceRange StackAddrEscapeChecker::GenName(raw_ostream &os,
SourceLocation L = ARE->getLocStart(); SourceLocation L = ARE->getLocStart();
range = ARE->getSourceRange(); range = ARE->getSourceRange();
os << "stack memory allocated by call to alloca() on line " os << "stack memory allocated by call to alloca() on line "
<< SM.getInstantiationLineNumber(L); << SM.getExpansionLineNumber(L);
} }
else if (const BlockDataRegion *BR = dyn_cast<BlockDataRegion>(R)) { else if (const BlockDataRegion *BR = dyn_cast<BlockDataRegion>(R)) {
const BlockDecl *BD = BR->getCodeRegion()->getDecl(); const BlockDecl *BD = BR->getCodeRegion()->getDecl();
SourceLocation L = BD->getLocStart(); SourceLocation L = BD->getLocStart();
range = BD->getSourceRange(); range = BD->getSourceRange();
os << "stack-allocated block declared on line " os << "stack-allocated block declared on line "
<< SM.getInstantiationLineNumber(L); << SM.getExpansionLineNumber(L);
} }
else if (const VarRegion *VR = dyn_cast<VarRegion>(R)) { else if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
os << "stack memory associated with local variable '" os << "stack memory associated with local variable '"

View File

@ -213,7 +213,7 @@ PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream& os,
if (Loc.asStmt()) if (Loc.asStmt())
os << "Execution continues on line " os << "Execution continues on line "
<< getSourceManager().getInstantiationLineNumber(Loc.asLocation()) << getSourceManager().getExpansionLineNumber(Loc.asLocation())
<< '.'; << '.';
else { else {
os << "Execution jumps to the end of the "; os << "Execution jumps to the end of the ";
@ -560,7 +560,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
const PathDiagnosticLocation &End = PDB.getEnclosingStmtLocation(S); const PathDiagnosticLocation &End = PDB.getEnclosingStmtLocation(S);
os << "Control jumps to line " os << "Control jumps to line "
<< End.asLocation().getInstantiationLineNumber(); << End.asLocation().getExpansionLineNumber();
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End, PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str())); os.str()));
break; break;
@ -578,11 +578,11 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
default: default:
os << "No cases match in the switch statement. " os << "No cases match in the switch statement. "
"Control jumps to line " "Control jumps to line "
<< End.asLocation().getInstantiationLineNumber(); << End.asLocation().getExpansionLineNumber();
break; break;
case Stmt::DefaultStmtClass: case Stmt::DefaultStmtClass:
os << "Control jumps to the 'default' case at line " os << "Control jumps to the 'default' case at line "
<< End.asLocation().getInstantiationLineNumber(); << End.asLocation().getExpansionLineNumber();
break; break;
case Stmt::CaseStmtClass: { case Stmt::CaseStmtClass: {
@ -609,7 +609,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
os << LHS->EvaluateAsInt(PDB.getASTContext()); os << LHS->EvaluateAsInt(PDB.getASTContext());
os << ":' at line " os << ":' at line "
<< End.asLocation().getInstantiationLineNumber(); << End.asLocation().getExpansionLineNumber();
break; break;
} }
} }
@ -979,10 +979,10 @@ bool EdgeBuilder::containsLocation(const PathDiagnosticLocation &Container,
SourceLocation ContaineeRBeg = SM.getExpansionLoc(ContaineeR.getBegin()); SourceLocation ContaineeRBeg = SM.getExpansionLoc(ContaineeR.getBegin());
SourceLocation ContaineeREnd = SM.getExpansionLoc(ContaineeR.getEnd()); SourceLocation ContaineeREnd = SM.getExpansionLoc(ContaineeR.getEnd());
unsigned ContainerBegLine = SM.getInstantiationLineNumber(ContainerRBeg); unsigned ContainerBegLine = SM.getExpansionLineNumber(ContainerRBeg);
unsigned ContainerEndLine = SM.getInstantiationLineNumber(ContainerREnd); unsigned ContainerEndLine = SM.getExpansionLineNumber(ContainerREnd);
unsigned ContaineeBegLine = SM.getInstantiationLineNumber(ContaineeRBeg); unsigned ContaineeBegLine = SM.getExpansionLineNumber(ContaineeRBeg);
unsigned ContaineeEndLine = SM.getInstantiationLineNumber(ContaineeREnd); unsigned ContaineeEndLine = SM.getExpansionLineNumber(ContaineeREnd);
assert(ContainerBegLine <= ContainerEndLine); assert(ContainerBegLine <= ContainerEndLine);
assert(ContaineeBegLine <= ContaineeEndLine); assert(ContaineeBegLine <= ContaineeEndLine);

View File

@ -2480,7 +2480,7 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf,
Description.clear(); Description.clear();
llvm::raw_string_ostream os(Description); llvm::raw_string_ostream os(Description);
SourceManager& SMgr = Eng.getContext().getSourceManager(); SourceManager& SMgr = Eng.getContext().getSourceManager();
unsigned AllocLine = SMgr.getInstantiationLineNumber(AllocSite); unsigned AllocLine = SMgr.getExpansionLineNumber(AllocSite);
os << "Potential leak "; os << "Potential leak ";
if (tf.isGCEnabled()) { if (tf.isGCEnabled()) {
os << "(when using garbage collection) "; os << "(when using garbage collection) ";

View File

@ -3099,7 +3099,7 @@ struct DOTGraphTraits<ExplodedNode*> :
if (SLoc.isFileID()) { if (SLoc.isFileID()) {
Out << "\\lline=" Out << "\\lline="
<< GraphPrintSourceManager->getInstantiationLineNumber(SLoc) << GraphPrintSourceManager->getExpansionLineNumber(SLoc)
<< " col=" << " col="
<< GraphPrintSourceManager->getExpansionColumnNumber(SLoc) << GraphPrintSourceManager->getExpansionColumnNumber(SLoc)
<< "\\l"; << "\\l";
@ -3152,7 +3152,7 @@ struct DOTGraphTraits<ExplodedNode*> :
if (SLoc.isFileID()) { if (SLoc.isFileID()) {
Out << "\\lline=" Out << "\\lline="
<< GraphPrintSourceManager->getInstantiationLineNumber(SLoc) << GraphPrintSourceManager->getExpansionLineNumber(SLoc)
<< " col=" << " col="
<< GraphPrintSourceManager->getExpansionColumnNumber(SLoc); << GraphPrintSourceManager->getExpansionColumnNumber(SLoc);
} }

View File

@ -221,7 +221,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
<< html::EscapeText(Entry->getName()) << html::EscapeText(Entry->getName())
<< "</td></tr>\n<tr><td class=\"rowname\">Location:</td><td>" << "</td></tr>\n<tr><td class=\"rowname\">Location:</td><td>"
"<a href=\"#EndPath\">line " "<a href=\"#EndPath\">line "
<< (*D.rbegin()).getLocation().asLocation().getInstantiationLineNumber() << (*D.rbegin()).getLocation().asLocation().getExpansionLineNumber()
<< ", column " << ", column "
<< (*D.rbegin()).getLocation().asLocation().getExpansionColumnNumber() << (*D.rbegin()).getLocation().asLocation().getExpansionColumnNumber()
<< "</a></td></tr>\n" << "</a></td></tr>\n"
@ -261,7 +261,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
os << "\n<!-- BUGFILE " << DirName << Entry->getName() << " -->\n"; os << "\n<!-- BUGFILE " << DirName << Entry->getName() << " -->\n";
os << "\n<!-- BUGLINE " os << "\n<!-- BUGLINE "
<< D.back()->getLocation().asLocation().getInstantiationLineNumber() << D.back()->getLocation().asLocation().getExpansionLineNumber()
<< " -->\n"; << " -->\n";
os << "\n<!-- BUGPATHLENGTH " << D.size() << " -->\n"; os << "\n<!-- BUGPATHLENGTH " << D.size() << " -->\n";
@ -550,10 +550,10 @@ void HTMLDiagnostics::HighlightRange(Rewriter& R, FileID BugFileID,
const LangOptions &LangOpts = R.getLangOpts(); const LangOptions &LangOpts = R.getLangOpts();
SourceLocation InstantiationStart = SM.getExpansionLoc(Range.getBegin()); SourceLocation InstantiationStart = SM.getExpansionLoc(Range.getBegin());
unsigned StartLineNo = SM.getInstantiationLineNumber(InstantiationStart); unsigned StartLineNo = SM.getExpansionLineNumber(InstantiationStart);
SourceLocation InstantiationEnd = SM.getExpansionLoc(Range.getEnd()); SourceLocation InstantiationEnd = SM.getExpansionLoc(Range.getEnd());
unsigned EndLineNo = SM.getInstantiationLineNumber(InstantiationEnd); unsigned EndLineNo = SM.getExpansionLineNumber(InstantiationEnd);
if (EndLineNo < StartLineNo) if (EndLineNo < StartLineNo)
return; return;

View File

@ -142,7 +142,7 @@ static void EmitLocation(raw_ostream& o, const SourceManager &SM,
Indent(o, indent) << "<dict>\n"; Indent(o, indent) << "<dict>\n";
Indent(o, indent) << " <key>line</key><integer>" Indent(o, indent) << " <key>line</key><integer>"
<< Loc.getInstantiationLineNumber() << "</integer>\n"; << Loc.getExpansionLineNumber() << "</integer>\n";
Indent(o, indent) << " <key>col</key><integer>" Indent(o, indent) << " <key>col</key><integer>"
<< Loc.getExpansionColumnNumber() + offset << "</integer>\n"; << Loc.getExpansionColumnNumber() + offset << "</integer>\n";
Indent(o, indent) << " <key>file</key><integer>" Indent(o, indent) << " <key>file</key><integer>"

View File

@ -2838,7 +2838,7 @@ void clang_getInstantiationLocation(CXSourceLocation location,
if (file) if (file)
*file = (void *)SM.getFileEntryForSLocEntry(sloc); *file = (void *)SM.getFileEntryForSLocEntry(sloc);
if (line) if (line)
*line = SM.getInstantiationLineNumber(InstLoc); *line = SM.getExpansionLineNumber(InstLoc);
if (column) if (column)
*column = SM.getExpansionColumnNumber(InstLoc); *column = SM.getExpansionColumnNumber(InstLoc);
if (offset) if (offset)