|
|
|
@ -2,6 +2,7 @@ |
|
|
|
#define SOURCELOCATION_H_ |
|
|
|
#define SOURCELOCATION_H_ |
|
|
|
#include <clang-c/Index.h> |
|
|
|
#include <clang-c/Index.h> |
|
|
|
#include <string> |
|
|
|
#include <string> |
|
|
|
|
|
|
|
#include <ostream> |
|
|
|
|
|
|
|
|
|
|
|
namespace clangmm { |
|
|
|
namespace clangmm { |
|
|
|
class Offset { |
|
|
|
class Offset { |
|
|
|
@ -15,19 +16,26 @@ namespace clangmm { |
|
|
|
|
|
|
|
|
|
|
|
class SourceLocation { |
|
|
|
class SourceLocation { |
|
|
|
friend class TranslationUnit; |
|
|
|
friend class TranslationUnit; |
|
|
|
|
|
|
|
friend class Diagnostic; |
|
|
|
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned offset); |
|
|
|
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned offset); |
|
|
|
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned line, unsigned column); |
|
|
|
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned line, unsigned column); |
|
|
|
public: |
|
|
|
public: |
|
|
|
SourceLocation(const CXSourceLocation& cx_location) : cx_location(cx_location) {} |
|
|
|
SourceLocation(const CXSourceLocation& cx_location) : cx_location(cx_location) {} |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
std::string get_path(); |
|
|
|
std::string get_path() const; |
|
|
|
clangmm::Offset get_offset(); |
|
|
|
clangmm::Offset get_offset() const; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
friend std::ostream &operator<<(std::ostream &os, const SourceLocation &location) { |
|
|
|
|
|
|
|
auto offset=location.get_offset(); |
|
|
|
|
|
|
|
os << location.get_path() << ':' << offset.line << ':' << offset.index; |
|
|
|
|
|
|
|
return os; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CXSourceLocation cx_location; |
|
|
|
CXSourceLocation cx_location; |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
void get_data(std::string *path, unsigned *line, unsigned *column, unsigned *offset); |
|
|
|
void get_data(std::string *path, unsigned *line, unsigned *column, unsigned *offset) const; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
} // namespace clangmm
|
|
|
|
} // namespace clangmm
|
|
|
|
|