summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-05-05 00:55:17 +0000
committerTed Kremenek <kremenek@apple.com>2010-05-05 00:55:17 +0000
commit458c2f190aa320d1641d204779d9874fdeff468f (patch)
tree33e060586ef5a882c9bd3342144bb0ff0cde9dff
parent63ac5999f1d20769f1381ed05ba59eef4339d83f (diff)
downloadbcm5719-llvm-458c2f190aa320d1641d204779d9874fdeff468f.tar.gz
bcm5719-llvm-458c2f190aa320d1641d204779d9874fdeff468f.zip
Move post-processing of token annotations to method in AnnotateTokensWorker.
llvm-svn: 103062
-rw-r--r--clang/tools/libclang/CIndex.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 5ced97ace99..23be3dfcb24 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2324,13 +2324,32 @@ typedef llvm::DenseMap<unsigned, CXCursor> AnnotateTokensData;
namespace {
class AnnotateTokensWorker {
AnnotateTokensData &Annotated;
+ CXToken *Tokens;
+ CXCursor *Cursors;
+ unsigned NumTokens;
public:
- AnnotateTokensWorker(AnnotateTokensData &annotated)
- : Annotated(annotated) {}
+ AnnotateTokensWorker(AnnotateTokensData &annotated,
+ CXToken *tokens, CXCursor *cursors, unsigned numTokens)
+ : Annotated(annotated), Tokens(tokens), Cursors(cursors),
+ NumTokens(numTokens) {}
+
+ void CompleteAnnotations();
+
enum CXChildVisitResult Visit(CXCursor cursor, CXCursor parent);
};
}
+void AnnotateTokensWorker::CompleteAnnotations() {
+ for (unsigned I = 0; I != NumTokens; ++I) {
+ // Determine whether we saw a cursor at this token's location.
+ AnnotateTokensData::iterator Pos = Annotated.find(Tokens[I].int_data[1]);
+ if (Pos == Annotated.end())
+ continue;
+
+ Cursors[I] = Pos->second;
+ }
+}
+
enum CXChildVisitResult
AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
// We only annotate the locations of declarations, simple
@@ -2462,19 +2481,11 @@ void clang_annotateTokens(CXTranslationUnit TU,
// Annotate all of the source locations in the region of interest that map to
// a specific cursor.
CXCursor Parent = clang_getTranslationUnitCursor(CXXUnit);
- AnnotateTokensWorker W(Annotated);
+ AnnotateTokensWorker W(Annotated, Tokens, Cursors, NumTokens);
CursorVisitor AnnotateVis(CXXUnit, AnnotateTokensVisitor, &W,
Decl::MaxPCHLevel, RegionOfInterest);
AnnotateVis.VisitChildren(Parent);
-
- for (unsigned I = 0; I != NumTokens; ++I) {
- // Determine whether we saw a cursor at this token's location.
- AnnotateTokensData::iterator Pos = Annotated.find(Tokens[I].int_data[1]);
- if (Pos == Annotated.end())
- continue;
-
- Cursors[I] = Pos->second;
- }
+ W.CompleteAnnotations();
}
} // end: extern "C"
OpenPOWER on IntegriCloud