From 9f1e3ff3b3095967e2b92b57a53524e2d6bb141c Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 18 Mar 2010 00:42:48 +0000 Subject: Experimental stab at using relexing to identify preprocessor directives while annotating tokens in CIndex. This functionality should probably be factored out of this routine, but we're not there yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98786 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/CIndex/CXCursor.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools/CIndex/CXCursor.cpp') diff --git a/tools/CIndex/CXCursor.cpp b/tools/CIndex/CXCursor.cpp index 0fa73a513d..f2294b0996 100644 --- a/tools/CIndex/CXCursor.cpp +++ b/tools/CIndex/CXCursor.cpp @@ -296,6 +296,24 @@ cxcursor::getCursorTypeRef(CXCursor C) { reinterpret_cast(C.data[1]))); } +CXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range, + ASTUnit *TU) { + CXCursor C = { CXCursor_PreprocessingDirective, + { reinterpret_cast(Range.getBegin().getRawEncoding()), + reinterpret_cast(Range.getEnd().getRawEncoding()), + TU } + }; + return C; +} + +SourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) { + assert(C.kind == CXCursor_PreprocessingDirective); + return SourceRange(SourceLocation::getFromRawEncoding( + reinterpret_cast (C.data[0])), + SourceLocation::getFromRawEncoding( + reinterpret_cast (C.data[1]))); +} + Decl *cxcursor::getCursorDecl(CXCursor Cursor) { return (Decl *)Cursor.data[0]; } -- cgit v1.2.3-70-g09d2