diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-17 18:18:49 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-17 18:18:49 +0000 |
commit | 6cc68a47b5a08af88d9bf1cef6c6c9799b3ac581 (patch) | |
tree | e9df1c14f72f215cb7912b116e39f712d2edad63 /clang/lib/Frontend/PCHWriter.cpp | |
parent | 059c6f6293ac34cc4bc4d249fd8a11d2867bd5c0 (diff) | |
download | bcm5719-llvm-6cc68a47b5a08af88d9bf1cef6c6c9799b3ac581.tar.gz bcm5719-llvm-6cc68a47b5a08af88d9bf1cef6c6c9799b3ac581.zip |
PCH support for labels and goto.
llvm-svn: 69364
Diffstat (limited to 'clang/lib/Frontend/PCHWriter.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index 4b4e8971661..bde859665f1 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/lib/Frontend/PCHWriter.cpp @@ -451,11 +451,13 @@ namespace { void VisitSwitchCase(SwitchCase *S); void VisitCaseStmt(CaseStmt *S); void VisitDefaultStmt(DefaultStmt *S); + void VisitLabelStmt(LabelStmt *S); void VisitIfStmt(IfStmt *S); void VisitSwitchStmt(SwitchStmt *S); void VisitWhileStmt(WhileStmt *S); void VisitDoStmt(DoStmt *S); void VisitForStmt(ForStmt *S); + void VisitGotoStmt(GotoStmt *S); void VisitContinueStmt(ContinueStmt *S); void VisitBreakStmt(BreakStmt *S); void VisitReturnStmt(ReturnStmt *S); @@ -536,6 +538,15 @@ void PCHStmtWriter::VisitDefaultStmt(DefaultStmt *S) { Code = pch::STMT_DEFAULT; } +void PCHStmtWriter::VisitLabelStmt(LabelStmt *S) { + VisitStmt(S); + Writer.AddIdentifierRef(S->getID(), Record); + Writer.WriteSubStmt(S->getSubStmt()); + Writer.AddSourceLocation(S->getIdentLoc(), Record); + Record.push_back(Writer.GetLabelID(S)); + Code = pch::STMT_LABEL; +} + void PCHStmtWriter::VisitIfStmt(IfStmt *S) { VisitStmt(S); Writer.WriteSubStmt(S->getCond()); @@ -582,6 +593,14 @@ void PCHStmtWriter::VisitForStmt(ForStmt *S) { Code = pch::STMT_FOR; } +void PCHStmtWriter::VisitGotoStmt(GotoStmt *S) { + VisitStmt(S); + Record.push_back(Writer.GetLabelID(S->getLabel())); + Writer.AddSourceLocation(S->getGotoLoc(), Record); + Writer.AddSourceLocation(S->getLabelLoc(), Record); + Code = pch::STMT_GOTO; +} + void PCHStmtWriter::VisitContinueStmt(ContinueStmt *S) { VisitStmt(S); Writer.AddSourceLocation(S->getContinueLoc(), Record); @@ -1857,3 +1876,15 @@ unsigned PCHWriter::getSwitchCaseID(SwitchCase *S) { "SwitchCase hasn't been seen yet"); return SwitchCaseIDs[S]; } + +/// \brief Retrieve the ID for the given label statement, which may +/// or may not have been emitted yet. +unsigned PCHWriter::GetLabelID(LabelStmt *S) { + std::map<LabelStmt *, unsigned>::iterator Pos = LabelIDs.find(S); + if (Pos != LabelIDs.end()) + return Pos->second; + + unsigned NextID = LabelIDs.size(); + LabelIDs[S] = NextID; + return NextID; +} |