File tree 5 files changed +78
-43
lines changed
5 files changed +78
-43
lines changed Original file line number Diff line number Diff line change @@ -42,9 +42,9 @@ does not vary based on the platform.
42
42
43
43
== Exceptions
44
44
45
- In functions which cannot return an error, such as work submitted to a thread
46
- pool or in a constructor, the implementation usually throws `Error`. These
47
- are caught and reported, and the process exits gracefully. If any exception
48
- is thrown which is not derived from `Error`, then it should not be caught.
49
- The uncaught exception handler should print a stack trace and exit the process
50
- immediately.
45
+ Errors thrown by the program should always have type `Exception`. Objects
46
+ of this type are capable of transporting an `Error` object. This is important
47
+ for the scripting to work; exceptions are used to propagate errors from
48
+ library code to scripts and back to the invoking code. For exceptional cases,
49
+ these thrown exceptions should be uncaught. The tool installs an uncaught exception
50
+ handler that prints a stack trace and exits the process immediately.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ ASTVisitor(
48
48
clang::CompilerInstance& compiler) noexcept
49
49
: ex_(ex)
50
50
, config_(config)
51
- , IsFileInRootDir_(true )
52
51
, compiler_(compiler)
52
+ , IsFileInRootDir_(true )
53
53
{
54
54
}
55
55
Original file line number Diff line number Diff line change 13
13
#ifndef MRDOX_TOOL_AST_ASTVISITOR_HPP
14
14
#define MRDOX_TOOL_AST_ASTVISITOR_HPP
15
15
16
+ #include " Diagnostics.hpp"
16
17
#include " Tool/ConfigImpl.hpp"
17
18
#include < mrdox/MetadataFwd.hpp>
18
19
#include < clang/Sema/SemaConsumer.h>
@@ -47,6 +48,12 @@ class ASTVisitor
47
48
48
49
tooling::ExecutionContext& ex_;
49
50
ConfigImpl const & config_;
51
+ clang::CompilerInstance& compiler_;
52
+ Diagnostics diags_;
53
+
54
+ ASTContext* astContext_ = nullptr ;
55
+ SourceManager* sourceManager_ = nullptr ;
56
+ Sema* sema_ = nullptr ;
50
57
51
58
llvm::SmallString<512 > File_;
52
59
bool IsFileInRootDir_;
@@ -57,12 +64,6 @@ class ASTVisitor
57
64
clang::SourceLocation::UIntTy,
58
65
FileFilter> fileFilter_;
59
66
60
- clang::CompilerInstance& compiler_;
61
-
62
- ASTContext* astContext_ = nullptr ;
63
- SourceManager* sourceManager_ = nullptr ;
64
- Sema* sema_ = nullptr ;
65
-
66
67
public:
67
68
ASTVisitor (
68
69
tooling::ExecutionContext& ex,
Original file line number Diff line number Diff line change
1
+ //
2
+ // Licensed under the Apache License v2.0 with LLVM Exceptions.
3
+ // See https://llvm.org/LICENSE.txt for license information.
4
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
+ //
6
+ // Copyright (c) 2023 Vinnie Falco ([email protected] )
7
+ //
8
+ // Official repository: https://github.com/cppalliance/mrdox
9
+ //
10
+
11
+ #ifndef MRDOX_TOOL_AST_DIAGNOSTICS_HPP
12
+ #define MRDOX_TOOL_AST_DIAGNOSTICS_HPP
13
+
14
+ #include < mrdox/Support/Error.hpp>
15
+ #include < llvm/Support/raw_ostream.h>
16
+ #include < string>
17
+ #include < unordered_set>
18
+
19
+ namespace clang {
20
+ namespace mrdox {
21
+
22
+ /* * Diagnostic information accumulated during visitation.
23
+ */
24
+ class Diagnostics
25
+ {
26
+ std::size_t errorCount_ = 0 ;
27
+ std::unordered_set<std::string> messages_;
28
+
29
+ public:
30
+ void reportError (std::string s)
31
+ {
32
+ auto result =
33
+ messages_.emplace (std::move (s));
34
+ if (result.second )
35
+ ++errorCount_;
36
+ }
37
+
38
+ void reportWarning (std::string s)
39
+ {
40
+ auto result =
41
+ messages_.emplace (std::move (s));
42
+ if (result.second )
43
+ ++errorCount_;
44
+ }
45
+
46
+ void
47
+ merge (
48
+ Diagnostics&& other,
49
+ llvm::raw_ostream* os = nullptr )
50
+ {
51
+ for (auto && s : other.messages_ )
52
+ {
53
+ auto result = messages_.emplace (std::move (s));
54
+ if (os && result.second )
55
+ *os << *result.first ;
56
+ }
57
+ other.messages_ .clear ();
58
+ }
59
+ };
60
+
61
+ } // mrdox
62
+ } // clang
63
+
64
+ #endif
You can’t perform that action at this time.
0 commit comments