mirror of https://gitlab.com/cppit/libclangmm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
32 lines
1.0 KiB
|
6 years ago
|
#include "clangmm.hpp"
|
||
|
8 years ago
|
#include <cassert>
|
||
|
8 years ago
|
#include <fstream>
|
||
|
|
#include <iostream>
|
||
|
8 years ago
|
#include <regex>
|
||
|
8 years ago
|
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
int main() {
|
||
|
8 years ago
|
std::string tests_path = LIBCLANGMM_TESTS_PATH;
|
||
|
|
std::string path(tests_path + "/case/main_error.cpp");
|
||
|
8 years ago
|
|
||
|
7 years ago
|
auto index = std::make_shared<clangmm::Index>(0, 0);
|
||
|
8 years ago
|
|
||
|
8 years ago
|
std::vector<std::string> arguments;
|
||
|
8 years ago
|
auto clang_version_string = clangmm::to_string(clang_getClangVersion());
|
||
|
8 years ago
|
const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$");
|
||
|
|
std::smatch sm;
|
||
|
|
if(std::regex_match(clang_version_string, sm, clang_version_regex)) {
|
||
|
8 years ago
|
auto clang_version = sm[1].str();
|
||
|
|
arguments.emplace_back("-I/usr/lib/clang/" + clang_version + "/include");
|
||
|
|
arguments.emplace_back("-I/usr/lib64/clang/" + clang_version + "/include"); // For Fedora
|
||
|
8 years ago
|
}
|
||
|
|
|
||
|
|
clangmm::TranslationUnit tu(index, path, arguments);
|
||
|
8 years ago
|
|
||
|
|
auto diagnostics = tu.get_diagnostics();
|
||
|
|
assert(diagnostics.size() > 0);
|
||
|
8 years ago
|
assert(!diagnostics[0].spelling.empty());
|
||
|
8 years ago
|
assert(diagnostics[0].severity == clangmm::Diagnostic::Severity::Error);
|
||
|
8 years ago
|
}
|