Skip to content

Commit dcb9067

Browse files
committed
[clang][ASTImporter][NFC]: Move clang::ImportError into own header.
Reviewed By: martong Differential Revision: https://reviews.llvm.org/D124774
1 parent 733dc3e commit dcb9067

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//===- ASTImportError.h - Define errors while importing AST -----*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, 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+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file defines the ASTImportError class which basically defines the kind
10+
// of error while importing AST .
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
15+
#define LLVM_CLANG_AST_ASTIMPORTERROR_H
16+
17+
#include "llvm/Support/Error.h"
18+
19+
namespace clang {
20+
21+
class ImportError : public llvm::ErrorInfo<ImportError> {
22+
public:
23+
/// \brief Kind of error when importing an AST component.
24+
enum ErrorKind {
25+
NameConflict, /// Naming ambiguity (likely ODR violation).
26+
UnsupportedConstruct, /// Not supported node or case.
27+
Unknown /// Other error.
28+
};
29+
30+
ErrorKind Error;
31+
32+
static char ID;
33+
34+
ImportError() : Error(Unknown) {}
35+
ImportError(const ImportError &Other) : Error(Other.Error) {}
36+
ImportError &operator=(const ImportError &Other) {
37+
Error = Other.Error;
38+
return *this;
39+
}
40+
ImportError(ErrorKind Error) : Error(Error) {}
41+
42+
std::string toString() const;
43+
44+
void log(llvm::raw_ostream &OS) const override;
45+
std::error_code convertToErrorCode() const override;
46+
};
47+
48+
} // namespace clang
49+
50+
#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H

clang/include/clang/AST/ASTImporter.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef LLVM_CLANG_AST_ASTIMPORTER_H
1515
#define LLVM_CLANG_AST_ASTIMPORTER_H
1616

17-
#include "clang/AST/APValue.h"
17+
#include "clang/AST/ASTImportError.h"
1818
#include "clang/AST/DeclBase.h"
1919
#include "clang/AST/DeclarationName.h"
2020
#include "clang/AST/ExprCXX.h"
@@ -29,7 +29,6 @@
2929
#include "llvm/ADT/DenseSet.h"
3030
#include "llvm/ADT/Optional.h"
3131
#include "llvm/ADT/SmallVector.h"
32-
#include "llvm/Support/Error.h"
3332
#include <utility>
3433

3534
namespace clang {
@@ -49,33 +48,6 @@ class TagDecl;
4948
class TranslationUnitDecl;
5049
class TypeSourceInfo;
5150

52-
class ImportError : public llvm::ErrorInfo<ImportError> {
53-
public:
54-
/// \brief Kind of error when importing an AST component.
55-
enum ErrorKind {
56-
NameConflict, /// Naming ambiguity (likely ODR violation).
57-
UnsupportedConstruct, /// Not supported node or case.
58-
Unknown /// Other error.
59-
};
60-
61-
ErrorKind Error;
62-
63-
static char ID;
64-
65-
ImportError() : Error(Unknown) {}
66-
ImportError(const ImportError &Other) : Error(Other.Error) {}
67-
ImportError &operator=(const ImportError &Other) {
68-
Error = Other.Error;
69-
return *this;
70-
}
71-
ImportError(ErrorKind Error) : Error(Error) { }
72-
73-
std::string toString() const;
74-
75-
void log(raw_ostream &OS) const override;
76-
std::error_code convertToErrorCode() const override;
77-
};
78-
7951
// \brief Returns with a list of declarations started from the canonical decl
8052
// then followed by subsequent decls in the translation unit.
8153
// This gives a canonical list for each entry in the redecl chain.

clang/include/clang/AST/ASTImporterSharedState.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
#ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
1515
#define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
1616

17+
#include "clang/AST/ASTImportError.h"
1718
#include "clang/AST/ASTImporterLookupTable.h"
1819
#include "clang/AST/Decl.h"
1920
#include "llvm/ADT/DenseMap.h"
20-
// FIXME We need this because of ImportError.
21-
#include "clang/AST/ASTImporter.h"
2221

2322
namespace clang {
2423

0 commit comments

Comments
 (0)