CXSourceLocation.h [plain text]
#ifndef LLVM_CLANG_CXSOURCELOCATION_H
#define LLVM_CLANG_CXSOURCELOCATION_H
#include "clang-c/Index.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/LangOptions.h"
#include "clang/AST/ASTContext.h"
namespace clang {
class SourceManager;
namespace cxloc {
static inline CXSourceLocation
translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
SourceLocation Loc) {
if (Loc.isInvalid())
clang_getNullLocation();
CXSourceLocation Result = { { (void*) &SM, (void*) &LangOpts, },
Loc.getRawEncoding() };
return Result;
}
static inline CXSourceLocation translateSourceLocation(ASTContext &Context,
SourceLocation Loc) {
return translateSourceLocation(Context.getSourceManager(),
Context.getLangOpts(),
Loc);
}
CXSourceRange translateSourceRange(const SourceManager &SM,
const LangOptions &LangOpts,
const CharSourceRange &R);
static inline CXSourceRange translateSourceRange(ASTContext &Context,
SourceRange R) {
return translateSourceRange(Context.getSourceManager(),
Context.getLangOpts(),
CharSourceRange::getTokenRange(R));
}
static inline SourceLocation translateSourceLocation(CXSourceLocation L) {
return SourceLocation::getFromRawEncoding(L.int_data);
}
static inline SourceRange translateCXSourceRange(CXSourceRange R) {
return SourceRange(SourceLocation::getFromRawEncoding(R.begin_int_data),
SourceLocation::getFromRawEncoding(R.end_int_data));
}
}}
#endif