Author: Jan Korous
Date: 2020-09-04T09:41:22-07:00
New Revision: baf3c77bd9f6baf60a09ef3625fef84080642b72

URL: 
https://github.com/llvm/llvm-project/commit/baf3c77bd9f6baf60a09ef3625fef84080642b72
DIFF: 
https://github.com/llvm/llvm-project/commit/baf3c77bd9f6baf60a09ef3625fef84080642b72.diff

LOG: [libclang] Add translateCXRangeToCharRange conversion

Add new conversion with clearly specified semantics.

https://reviews.llvm.org/D86990

Added: 
    

Modified: 
    clang/tools/libclang/CIndex.cpp
    clang/tools/libclang/CXSourceLocation.h

Removed: 
    


################################################################################
diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 93f9797a965e..683b517d79fd 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -164,6 +164,12 @@ CXSourceRange cxloc::translateSourceRange(const 
SourceManager &SM,
   return Result;
 }
 
+CharSourceRange cxloc::translateCXRangeToCharRange(CXSourceRange R) {
+  return CharSourceRange::getCharRange(
+      SourceLocation::getFromRawEncoding(R.begin_int_data),
+      SourceLocation::getFromRawEncoding(R.end_int_data));
+}
+
 
//===----------------------------------------------------------------------===//
 // Cursor visitor.
 
//===----------------------------------------------------------------------===//

diff  --git a/clang/tools/libclang/CXSourceLocation.h 
b/clang/tools/libclang/CXSourceLocation.h
index 6702d0cf9791..ce3d09e1c9eb 100644
--- a/clang/tools/libclang/CXSourceLocation.h
+++ b/clang/tools/libclang/CXSourceLocation.h
@@ -71,7 +71,11 @@ static inline SourceRange 
translateCXSourceRange(CXSourceRange R) {
                      SourceLocation::getFromRawEncoding(R.end_int_data));
 }
 
-
+/// Translates CXSourceRange to CharSourceRange.
+/// The semantics of \p R are:
+/// R.begin_int_data is first character of the range.
+/// R.end_int_data is one character past the end of the range.
+CharSourceRange translateCXRangeToCharRange(CXSourceRange R);
 }} // end namespace: clang::cxloc
 
 #endif


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to