Add debug_helper.hpp
This commit is contained in:
parent
f66fa70b1f
commit
958100d3e3
3 changed files with 37 additions and 1 deletions
16
src/libclang/debug_helper.cpp
Normal file
16
src/libclang/debug_helper.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// 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 <cstdio>
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
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());
|
||||
}
|
||||
18
src/libclang/debug_helper.hpp
Normal file
18
src/libclang/debug_helper.hpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// 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
|
||||
|
|
@ -5,7 +5,9 @@
|
|||
#ifndef CPPAST_RAII_WRAPPER_HPP_INCLUDED
|
||||
#define CPPAST_RAII_WRAPPER_HPP_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
|
|
@ -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_))
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue