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

Commit

Permalink
Merge pull request #21 from eidheim/master
Browse files Browse the repository at this point in the history
Most notably, added Fix-its to diagnostics.
  • Loading branch information
eidheim committed Oct 17, 2015
2 parents 7c15b12 + 83d27ab commit f1f784d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# libclangmm - An easy to use C++-wrapper for libclang #
# libclangmm - an easy to use C++-wrapper for libclang #

## About ##
Provides C++ bindings and class structure to the [libclang](http://www.llvm.org) C library.

Developed for [juCi++](https://github.com/cppit/jucipp) - a lightweight platform independent C++-IDE.

## Dependencies ##
* libclang
Expand Down
9 changes: 8 additions & 1 deletion src/Diagnostic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ clang::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnos
clang::Tokens tokens(cx_tu, SourceRange(start_location, start_location));
if(tokens.size()==1)
offsets={start_offset, tokens.begin()->offsets.second};

unsigned num_fix_its=clang_getDiagnosticNumFixIts(cx_diagnostic);
for(unsigned c=0;c<num_fix_its;c++) {
CXSourceRange fix_it_range;
auto source=clang::to_string(clang_getDiagnosticFixIt(cx_diagnostic, c, &fix_it_range));
fix_its.emplace_back(source, clang::SourceRange(fix_it_range).get_offsets());
}
}

const std::string clang::Diagnostic::get_severity_spelling(unsigned severity) {
Expand All @@ -31,4 +38,4 @@ const std::string clang::Diagnostic::get_severity_spelling(unsigned severity) {
default:
return "";
}
}
}
11 changes: 10 additions & 1 deletion src/Diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@ namespace clang {
friend class TranslationUnit;
Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic);
public:
class FixIt {
public:
FixIt(const std::string &source, const std::pair<clang::Offset, clang::Offset> &offsets):
source(source), offsets(offsets) {}
std::string source;
std::pair<clang::Offset, clang::Offset> offsets;
};

static const std::string get_severity_spelling(unsigned severity);

unsigned severity;
std::string severity_spelling;
std::string spelling;
std::string path;
std::pair<clang::Offset, clang::Offset> offsets;
std::vector<FixIt> fix_its;
};
}

#endif // DIAGNOSTIC_H_
#endif // DIAGNOSTIC_H_

0 comments on commit f1f784d

Please sign in to comment.