-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1b0340
commit 668e4e9
Showing
5 changed files
with
78 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2023 Vinnie Falco ([email protected]) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdox | ||
// | ||
|
||
#ifndef MRDOX_TOOL_AST_DIAGNOSTICS_HPP | ||
#define MRDOX_TOOL_AST_DIAGNOSTICS_HPP | ||
|
||
#include <mrdox/Support/Error.hpp> | ||
#include <llvm/Support/raw_ostream.h> | ||
#include <string> | ||
#include <unordered_set> | ||
|
||
namespace clang { | ||
namespace mrdox { | ||
|
||
/** Diagnostic information accumulated during visitation. | ||
*/ | ||
class Diagnostics | ||
{ | ||
std::size_t errorCount_ = 0; | ||
std::unordered_set<std::string> messages_; | ||
|
||
public: | ||
void reportError(std::string s) | ||
{ | ||
auto result = | ||
messages_.emplace(std::move(s)); | ||
if(result.second) | ||
++errorCount_; | ||
} | ||
|
||
void reportWarning(std::string s) | ||
{ | ||
auto result = | ||
messages_.emplace(std::move(s)); | ||
if(result.second) | ||
++errorCount_; | ||
} | ||
|
||
void | ||
merge( | ||
Diagnostics&& other, | ||
llvm::raw_ostream* os = nullptr) | ||
{ | ||
for(auto&& s : other.messages_) | ||
{ | ||
auto result = messages_.emplace(std::move(s)); | ||
if(os && result.second) | ||
*os << *result.first; | ||
} | ||
other.messages_.clear(); | ||
} | ||
}; | ||
|
||
} // mrdox | ||
} // clang | ||
|
||
#endif |