diff --git a/src/source_clang.cc b/src/source_clang.cc index e33170c..42727d9 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -252,7 +252,8 @@ void Source::ClangViewParse::remove_include_guard(std::string &buffer) { if(!(language && (language->get_id()=="chdr" || language->get_id()=="cpphdr"))) return; - static std::regex ifndef_regex("^[ \t]*#ifndef[ \t]+([A-Za-z0-9_]+).*$"); + static std::regex ifndef_regex1("^[ \t]*#ifndef[ \t]+([A-Za-z0-9_]+).*$"); + static std::regex ifndef_regex2("^[ \t]*#if[ \t]+![ \t]*defined[ \t]*\\([ \t]*([A-Za-z0-9_]+).*$"); static std::regex define_regex("^[ \t]*#define[ \t]+([A-Za-z0-9_]+).*$"); static std::regex endif_regex("^[ \t]*#endif.*$"); std::vector> ranges; @@ -262,17 +263,16 @@ void Source::ClangViewParse::remove_include_guard(std::string &buffer) { std::string line; std::string preprocessor_identifier; for(size_t c=0;cremove_include_guard(source); g_assert_cmpstr(source.c_str(),==," \n//test\n \n \n"); + source="#if !defined(F)\n#define F\n#endif\n"; + clang_view->remove_include_guard(source); + g_assert_cmpstr(source.c_str(),==," \n \n \n"); + source="#ifndef F\ntest\n#define F\n#endif // F\n"; auto old_source=source; clang_view->remove_include_guard(source);