Skip to content

Commit fc04ba6

Browse files
klemens-morgensternvinniefalco
authored andcommitted
refactor method of calling getPtr
1 parent ec68ed2 commit fc04ba6

File tree

4 files changed

+39
-106
lines changed

4 files changed

+39
-106
lines changed

include/mrdox/Errors.hpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifndef MRDOX_ERRORS_HPP
1313
#define MRDOX_ERRORS_HPP
1414

15-
#include <mrdox/detail/access.hpp>
15+
#include <mrdox/detail/Errors.hpp>
1616
#include <llvm/Support/Error.h>
1717
#include <llvm/Support/raw_ostream.h>
1818
#include <cassert>
@@ -24,13 +24,6 @@
2424
namespace clang {
2525
namespace mrdox {
2626

27-
//------------------------------------------------
28-
29-
// VFALCO CLEAN UP THIS HACK!
30-
namespace detail {
31-
CONST_FUNCTION_ACCESS(callGetPtr, llvm::Error, getPtr, llvm::ErrorInfoBase*);
32-
} // detail
33-
3427
//------------------------------------------------
3528
//
3629
// ErrorCode
@@ -48,7 +41,7 @@ class ErrorCode
4841
llvm::ErrorInfoBase const*
4942
getPtr(llvm::Error const& e) noexcept
5043
{
51-
return access::callFunction<detail::callGetPtr>(e);
44+
return llvm::Expected<llvm::ErrorCodeAccess>::getPtr(e);
5245
}
5346

5447
static
@@ -218,7 +211,7 @@ class Result
218211

219212
/** Constructor.
220213
*/
221-
template<class T>
214+
//template<class T>
222215
Result(llvm::Expected<T>&& ex)
223216
{
224217
construct(std::move(ex));

include/mrdox/detail/Errors.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_DETAIL_ERRORS_HPP
13+
#define MRDOX_DETAIL_ERRORS_HPP
14+
15+
#include <llvm/Support/Error.h>
16+
17+
namespace llvm {
18+
19+
struct ErrorCodeAccess;
20+
21+
template<>
22+
struct llvm::Expected<ErrorCodeAccess>
23+
{
24+
static
25+
llvm::ErrorInfoBase const*
26+
getPtr(llvm::Error const& e)
27+
{
28+
return e.getPtr();
29+
}
30+
};
31+
32+
} // clang
33+
34+
#endif

include/mrdox/detail/access.hpp

Lines changed: 0 additions & 94 deletions
This file was deleted.

source/lib/jad/Symbol.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "jad/Info.hpp"
1616
#include "jad/Location.hpp"
17-
#include <optional>
17+
#include "llvm/ADT/Optional.h"
1818

1919
namespace clang {
2020
namespace mrdox {
@@ -35,7 +35,7 @@ struct SymbolInfo
3535

3636
void merge(SymbolInfo&& I);
3737

38-
std::optional<Location> DefLoc; // Location where this decl is defined.
38+
llvm::Optional<Location> DefLoc; // Location where this decl is defined.
3939
llvm::SmallVector<Location, 2> Loc; // Locations where this decl is declared.
4040
};
4141

0 commit comments

Comments
 (0)