CIndex: Stop hiding magic end bit in CXSourceRange locations where clients can't
see it. Instead, translate the locations up-front when we create a
CXSourceRange.
- This is part of a move to make CXSourceRange a pure half-open range, which is
a more natural API for clients to deal with. More cleanups to follow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96144 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CXSourceLocation.h b/tools/CIndex/CXSourceLocation.h
index e1dc7ed..95b774b 100644
--- a/tools/CIndex/CXSourceLocation.h
+++ b/tools/CIndex/CXSourceLocation.h
@@ -1,4 +1,4 @@
-//===- CXSourceLocation.h - Routines for manipulating CXSourceLocations ---===//
+//===- CXSourceLocation.h - CXSourceLocations Utilities ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -49,14 +49,14 @@
}
/// \brief Translate a Clang source range into a CIndex source range.
-static inline CXSourceRange translateSourceRange(const SourceManager &SM,
- const LangOptions &LangOpts,
- SourceRange R) {
- CXSourceRange Result = { { (void *)&SM, (void *)&LangOpts },
- R.getBegin().getRawEncoding(),
- R.getEnd().getRawEncoding() };
- return Result;
-}
+///
+/// Clang internally represents ranges where the end location points to the
+/// start of the token at the end. However, for external clients it is more
+/// useful to have a CXSourceRange be a proper half-open interval. This routine
+/// does the appropriate translation.
+CXSourceRange translateSourceRange(const SourceManager &SM,
+ const LangOptions &LangOpts,
+ SourceRange R);
/// \brief Translate a Clang source range into a CIndex source range.
static inline CXSourceRange translateSourceRange(ASTContext &Context,