diff --git a/src/libclang/debug_helper.cpp b/src/libclang/debug_helper.cpp new file mode 100644 index 0000000..a60c029 --- /dev/null +++ b/src/libclang/debug_helper.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Jonathan Müller +// This file is subject to the license terms in the LICENSE file +// found in the top-level directory of this distribution. + +#include "debug_helper.hpp" + +#include +#include + +using namespace cppast; + +void detail::print_cursor_info(const CXCursor& cur) noexcept +{ + std::printf("[debug] cursor '%s' (%s)\n", cxstring(clang_getCursorDisplayName(cur)).c_str(), + cxstring(clang_getCursorKindSpelling(cur.kind)).c_str()); +} diff --git a/src/libclang/debug_helper.hpp b/src/libclang/debug_helper.hpp new file mode 100644 index 0000000..7e7a890 --- /dev/null +++ b/src/libclang/debug_helper.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Jonathan Müller +// This file is subject to the license terms in the LICENSE file +// found in the top-level directory of this distribution. + +#ifndef CPPAST_DEBUG_HELPER_HPP_INCLUDED +#define CPPAST_DEBUG_HELPER_HPP_INCLUDED + +#include "raii_wrapper.hpp" + +namespace cppast +{ + namespace detail + { + void print_cursor_info(const CXCursor& cur) noexcept; + } +} // namespace cppast::detail + +#endif // CPPAST_DEBUG_HELPER_HPP_INCLUDED diff --git a/src/libclang/raii_wrapper.hpp b/src/libclang/raii_wrapper.hpp index fd34c74..a5deda6 100644 --- a/src/libclang/raii_wrapper.hpp +++ b/src/libclang/raii_wrapper.hpp @@ -5,7 +5,9 @@ #ifndef CPPAST_RAII_WRAPPER_HPP_INCLUDED #define CPPAST_RAII_WRAPPER_HPP_INCLUDED +#include #include +#include #include @@ -87,7 +89,7 @@ namespace cppast class cxstring { public: - cxstring(CXString str) noexcept + explicit cxstring(CXString str) noexcept : str_(str), c_str_(clang_getCString(str)), length_(std::strlen(c_str_)) { }