diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-18 17:52:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-18 17:52:52 +0000 |
commit | 065f8d11caf73d75fbdedbe3a0fc0cddf56cb8a9 (patch) | |
tree | dff6501bcf881cd09ff08dba336dd158ab03fa19 /clang/tools/CIndex/CXCursor.cpp | |
parent | eaceb9fd392f8e4b80477055003e833c5642f9ca (diff) | |
download | bcm5719-llvm-065f8d11caf73d75fbdedbe3a0fc0cddf56cb8a9.tar.gz bcm5719-llvm-065f8d11caf73d75fbdedbe3a0fc0cddf56cb8a9.zip |
Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.
The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.
Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.
Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.
llvm-svn: 98836
Diffstat (limited to 'clang/tools/CIndex/CXCursor.cpp')
-rw-r--r-- | clang/tools/CIndex/CXCursor.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/clang/tools/CIndex/CXCursor.cpp b/clang/tools/CIndex/CXCursor.cpp index aa81d60f61d..1e5265ee9af 100644 --- a/clang/tools/CIndex/CXCursor.cpp +++ b/clang/tools/CIndex/CXCursor.cpp @@ -314,22 +314,15 @@ SourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) { reinterpret_cast<uintptr_t> (C.data[1]))); } -CXCursor cxcursor::MakeMacroInstantiationCursor(SourceRange Range, +CXCursor cxcursor::MakeMacroInstantiationCursor(MacroInstantiation *MI, ASTUnit *TU) { - CXCursor C = { CXCursor_MacroInstantiation, - { reinterpret_cast<void *>(Range.getBegin().getRawEncoding()), - reinterpret_cast<void *>(Range.getEnd().getRawEncoding()), - TU } - }; + CXCursor C = { CXCursor_MacroInstantiation, { MI, 0, TU } }; return C; } -SourceRange cxcursor::getCursorMacroInstantiation(CXCursor C) { +MacroInstantiation *cxcursor::getCursorMacroInstantiation(CXCursor C) { assert(C.kind == CXCursor_MacroInstantiation); - return SourceRange(SourceLocation::getFromRawEncoding( - reinterpret_cast<uintptr_t> (C.data[0])), - SourceLocation::getFromRawEncoding( - reinterpret_cast<uintptr_t> (C.data[1]))); + return static_cast<MacroInstantiation *>(C.data[0]); } Decl *cxcursor::getCursorDecl(CXCursor Cursor) { |