Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit f1f784d

Browse files
committed
Merge pull request #21 from eidheim/master
Most notably, added Fix-its to diagnostics.
2 parents 7c15b12 + 83d27ab commit f1f784d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# libclangmm - An easy to use C++-wrapper for libclang #
1+
# libclangmm - an easy to use C++-wrapper for libclang #
22

33
## About ##
44
Provides C++ bindings and class structure to the [libclang](http://www.llvm.org) C library.
5+
6+
Developed for [juCi++](https://github.com/cppit/jucipp) - a lightweight platform independent C++-IDE.
57

68
## Dependencies ##
79
* libclang

src/Diagnostic.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ clang::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnos
1414
clang::Tokens tokens(cx_tu, SourceRange(start_location, start_location));
1515
if(tokens.size()==1)
1616
offsets={start_offset, tokens.begin()->offsets.second};
17+
18+
unsigned num_fix_its=clang_getDiagnosticNumFixIts(cx_diagnostic);
19+
for(unsigned c=0;c<num_fix_its;c++) {
20+
CXSourceRange fix_it_range;
21+
auto source=clang::to_string(clang_getDiagnosticFixIt(cx_diagnostic, c, &fix_it_range));
22+
fix_its.emplace_back(source, clang::SourceRange(fix_it_range).get_offsets());
23+
}
1724
}
1825

1926
const std::string clang::Diagnostic::get_severity_spelling(unsigned severity) {
@@ -31,4 +38,4 @@ const std::string clang::Diagnostic::get_severity_spelling(unsigned severity) {
3138
default:
3239
return "";
3340
}
34-
}
41+
}

src/Diagnostic.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,23 @@ namespace clang {
1010
friend class TranslationUnit;
1111
Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic);
1212
public:
13+
class FixIt {
14+
public:
15+
FixIt(const std::string &source, const std::pair<clang::Offset, clang::Offset> &offsets):
16+
source(source), offsets(offsets) {}
17+
std::string source;
18+
std::pair<clang::Offset, clang::Offset> offsets;
19+
};
20+
1321
static const std::string get_severity_spelling(unsigned severity);
1422

1523
unsigned severity;
1624
std::string severity_spelling;
1725
std::string spelling;
1826
std::string path;
1927
std::pair<clang::Offset, clang::Offset> offsets;
28+
std::vector<FixIt> fix_its;
2029
};
2130
}
2231

23-
#endif // DIAGNOSTIC_H_
32+
#endif // DIAGNOSTIC_H_

0 commit comments

Comments
 (0)