Skip to content

Commit e3aabb4

Browse files
committed
use makeError
1 parent 037b692 commit e3aabb4

File tree

6 files changed

+171
-97
lines changed

6 files changed

+171
-97
lines changed

include/mrdox/Error.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// This is a derivative work. originally part of the LLVM Project.
3+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
// Copyright (c) 2023 Vinnie Falco ([email protected])
8+
//
9+
// Official repository: https://github.com/cppalliance/mrdox
10+
//
11+
12+
#ifndef MRDOX_ERROR_HPP
13+
#define MRDOX_ERROR_HPP
14+
15+
#include <llvm/ADT/StringRef.h>
16+
#include <llvm/Support/Error.h>
17+
#include <source_location>
18+
19+
namespace clang {
20+
namespace mrdox {
21+
22+
/** Return an Error for the given text and source location.
23+
*/
24+
[[nodiscard]]
25+
llvm::Error
26+
makeError(
27+
llvm::StringRef what,
28+
std::source_location loc =
29+
std::source_location::current());
30+
31+
} // mrdox
32+
} // clang
33+
34+
#endif

include/mrdox/Reporter.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ struct Reporter
4646
return EXIT_FAILURE;
4747
}
4848

49+
/** Report a non-successful Error
50+
*/
51+
void
52+
failed(llvm::Error&& err);
53+
4954
/** Report the failure of an action.
5055
5156
@param action The operation which failed.
@@ -102,6 +107,11 @@ struct Reporter
102107
llvm::errs() << s << '\n';
103108
}
104109

110+
static
111+
llvm::StringRef
112+
makeString(
113+
std::source_location const& loc);
114+
105115
private:
106116
/** Return a string formatted from arguments.
107117
@@ -186,10 +196,6 @@ struct Reporter
186196
os << makeString(loc);
187197
}
188198

189-
llvm::StringRef
190-
makeString(
191-
std::source_location const& loc) const;
192-
193199
private:
194200
llvm::sys::Mutex mutable m_;
195201
bool failed_ = false;

0 commit comments

Comments
 (0)