mirror of https://gitlab.com/cppit/libclangmm
27 changed files with 189 additions and 250 deletions
@ -1,41 +1,34 @@ |
|||||||
#include "SourceLocation.h" |
#include "SourceLocation.h" |
||||||
|
#include "Utility.h" |
||||||
|
|
||||||
// // // // // // // //
|
// // // // // // // //
|
||||||
// SourceLocation //
|
// SourceLocation //
|
||||||
// // // // // // // //
|
// // // // // // // //
|
||||||
clang::SourceLocation:: |
clang::SourceLocation::SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned offset) { |
||||||
SourceLocation(CXTranslationUnit &tu, |
CXFile file = clang_getFile(tu, filepath.c_str()); |
||||||
const std::string &filename, |
cx_location = clang_getLocationForOffset(tu, file, offset); |
||||||
int line_number, |
|
||||||
int line_offset) { |
|
||||||
CXFile file = clang_getFile(tu, |
|
||||||
filename.c_str()); |
|
||||||
cx_location = clang_getLocation(tu, |
|
||||||
file, |
|
||||||
line_number, |
|
||||||
line_offset); |
|
||||||
} |
} |
||||||
|
|
||||||
clang::SourceLocation:: |
std::string clang::SourceLocation::get_path() { |
||||||
SourceLocation(CXTranslationUnit &tu, |
std::string path; |
||||||
const std::string &filepath, |
get_data(&path, NULL, NULL, NULL); |
||||||
int offset) { |
return path; |
||||||
CXFile file = clang_getFile(tu, |
} |
||||||
filepath.c_str()); |
unsigned clang::SourceLocation::get_offset() { |
||||||
cx_location = clang_getLocationForOffset(tu, |
unsigned offset; |
||||||
file, |
get_data(NULL, NULL, NULL, &offset); |
||||||
offset); |
return offset; |
||||||
} |
} |
||||||
|
|
||||||
void clang::SourceLocation:: |
void clang::SourceLocation::get_data(std::string* path, unsigned *line, unsigned *column, unsigned *offset) { |
||||||
get_location_info(std::string* path, |
if(path==nullptr) |
||||||
unsigned *line, |
clang_getExpansionLocation(cx_location, NULL, line, column, offset); |
||||||
unsigned *column, |
else { |
||||||
unsigned *offset) { |
|
||||||
CXFile file; |
CXFile file; |
||||||
clang_getExpansionLocation(cx_location, &file, line, column, offset); |
clang_getExpansionLocation(cx_location, &file, line, column, offset); |
||||||
if (path != NULL && file!=NULL) { |
if (file!=NULL) { |
||||||
path->operator=(((clang_getCString((clang_getFileName(file)))))); |
*path=clang::to_string(clang_getFileName(file)); |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,10 @@ |
|||||||
|
#include "Utility.h" |
||||||
|
|
||||||
|
std::string clang::to_string(CXString cx_string) { |
||||||
|
std::string string; |
||||||
|
if(cx_string.data!=NULL) { |
||||||
|
string=clang_getCString(cx_string); |
||||||
|
clang_disposeString(cx_string); |
||||||
|
} |
||||||
|
return string; |
||||||
|
} |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
#ifndef UTILITY_H_ |
||||||
|
#define UTILITY_H_ |
||||||
|
#include <clang-c/Index.h> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
namespace clang { |
||||||
|
std::string to_string(CXString cx_string); |
||||||
|
} |
||||||
|
|
||||||
|
#endif // UTILITY_H_
|
||||||
Loading…
Reference in new issue