diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-01-18 22:13:09 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-01-18 22:13:09 +0000 |
| commit | 49c4baf4301676abcd7e38dc8d1d37c94ddb6e6f (patch) | |
| tree | 49bc114ebd520fcbba44fdccfa9b68f5fab82b2e /clang | |
| parent | 85b27528fc661b695b3f2688ad6f2f9c85940dc2 (diff) | |
| download | bcm5719-llvm-49c4baf4301676abcd7e38dc8d1d37c94ddb6e6f.tar.gz bcm5719-llvm-49c4baf4301676abcd7e38dc8d1d37c94ddb6e6f.zip | |
Clean up the CIndex API slightly.
Renamed CXSourceFileLine to CXSourceLocation and added a CXFile, to
better match Clang's SourceLocation. Teach clang_getDeclExtent to fill
in the CXFile properly.
Renamed CXSourceExtent to CXSourceRange, to better match Clang's
SourceLocation.
llvm-svn: 93783
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang-c/Index.h | 26 | ||||
| -rw-r--r-- | clang/tools/CIndex/CIndex.cpp | 9 | ||||
| -rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 2 |
3 files changed, 25 insertions, 12 deletions
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index c7b0a5197c6..380dec77966 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -339,22 +339,34 @@ CINDEX_LINKAGE unsigned clang_getDeclColumn(CXDecl); CINDEX_LINKAGE const char *clang_getDeclSource(CXDecl); /* deprecate */ CINDEX_LINKAGE CXFile clang_getDeclSourceFile(CXDecl); -typedef struct CXSourceLineColumn { +/** + * \brief Identifies a specific source location given its file, line, and + * column. + */ +typedef struct { + CXFile file; unsigned line; unsigned column; -} CXSourceLineColumn; +} CXSourceLocation; -typedef struct CXDeclExtent { - CXSourceLineColumn begin; - CXSourceLineColumn end; -} CXSourceExtent; +/** + * \brief Identifies a range of source locations identified by the starting and + * ending locations of that range. + * + * The \c begin location points to the first character in the range and the + * \c end location points to the last character in the range. + */ +typedef struct { + CXSourceLocation begin; + CXSourceLocation end; +} CXSourceRange; /* clang_getDeclExtent() returns the physical extent of a declaration. The * beginning line/column pair points to the start of the first token in the * declaration, and the ending line/column pair points to the last character in * the last token of the declaration. */ -CINDEX_LINKAGE CXSourceExtent clang_getDeclExtent(CXDecl); +CINDEX_LINKAGE CXSourceRange clang_getDeclExtent(CXDecl); /* * CXCursor Operations. diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index c5c7409ffcf..a11f54b8793 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -643,7 +643,7 @@ unsigned clang_getDeclColumn(CXDecl AnonDecl) { return SourceMgr.getSpellingColumnNumber(ND->getLocation()); } -CXDeclExtent clang_getDeclExtent(CXDecl AnonDecl) { +CXSourceRange clang_getDeclExtent(CXDecl AnonDecl) { assert(AnonDecl && "Passed null CXDecl"); NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl); SourceManager &SM = ND->getASTContext().getSourceManager(); @@ -653,7 +653,7 @@ CXDeclExtent clang_getDeclExtent(CXDecl AnonDecl) { SourceLocation End = SM.getInstantiationLoc(R.getEnd()); if (!Begin.isValid()) { - CXDeclExtent extent = { { 0, 0 }, { 0, 0 } }; + CXSourceRange extent = { { 0, 0, 0 }, { 0, 0, 0 } }; return extent; } @@ -691,8 +691,9 @@ CXDeclExtent clang_getDeclExtent(CXDecl AnonDecl) { } // Package up the line/column data and return to the caller. - CXDeclExtent extent = { { StartLineNo, StartColNo }, - { EndLineNo, EndColNo } }; + const FileEntry *FEntry = SM.getFileEntryForID(SM.getFileID(Begin)); + CXSourceRange extent = { { (void *)FEntry, StartLineNo, StartColNo }, + { (void *)FEntry, EndLineNo, EndColNo } }; return extent; } diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index db95644c4cf..e3d6ad88bb8 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -74,7 +74,7 @@ static const char* GetCursorSource(CXCursor Cursor) { static const char *FileCheckPrefix = "CHECK"; static void PrintDeclExtent(CXDecl Dcl) { - CXSourceExtent extent; + CXSourceRange extent; if (!Dcl) return; extent = clang_getDeclExtent(Dcl); |

