[clang][ASTImporter][NFC]: Move clang::ImportError into own header.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D124774
This commit is contained in:
phyBrackets 2022-05-02 21:22:32 +05:30
parent 733dc3e50b
commit dcb906757a
3 changed files with 52 additions and 31 deletions

View File

@ -0,0 +1,50 @@
//===- ASTImportError.h - Define errors while importing AST -----*- C++ -*-===//
//
// Part of the LLVM Project, 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
//
//===----------------------------------------------------------------------===//
//
// This file defines the ASTImportError class which basically defines the kind
// of error while importing AST .
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
#define LLVM_CLANG_AST_ASTIMPORTERROR_H
#include "llvm/Support/Error.h"
namespace clang {
class ImportError : public llvm::ErrorInfo<ImportError> {
public:
/// \brief Kind of error when importing an AST component.
enum ErrorKind {
NameConflict, /// Naming ambiguity (likely ODR violation).
UnsupportedConstruct, /// Not supported node or case.
Unknown /// Other error.
};
ErrorKind Error;
static char ID;
ImportError() : Error(Unknown) {}
ImportError(const ImportError &Other) : Error(Other.Error) {}
ImportError &operator=(const ImportError &Other) {
Error = Other.Error;
return *this;
}
ImportError(ErrorKind Error) : Error(Error) {}
std::string toString() const;
void log(llvm::raw_ostream &OS) const override;
std::error_code convertToErrorCode() const override;
};
} // namespace clang
#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H

View File

@ -14,7 +14,7 @@
#ifndef LLVM_CLANG_AST_ASTIMPORTER_H
#define LLVM_CLANG_AST_ASTIMPORTER_H
#include "clang/AST/APValue.h"
#include "clang/AST/ASTImportError.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExprCXX.h"
@ -29,7 +29,6 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Error.h"
#include <utility>
namespace clang {
@ -49,33 +48,6 @@ class TagDecl;
class TranslationUnitDecl;
class TypeSourceInfo;
class ImportError : public llvm::ErrorInfo<ImportError> {
public:
/// \brief Kind of error when importing an AST component.
enum ErrorKind {
NameConflict, /// Naming ambiguity (likely ODR violation).
UnsupportedConstruct, /// Not supported node or case.
Unknown /// Other error.
};
ErrorKind Error;
static char ID;
ImportError() : Error(Unknown) {}
ImportError(const ImportError &Other) : Error(Other.Error) {}
ImportError &operator=(const ImportError &Other) {
Error = Other.Error;
return *this;
}
ImportError(ErrorKind Error) : Error(Error) { }
std::string toString() const;
void log(raw_ostream &OS) const override;
std::error_code convertToErrorCode() const override;
};
// \brief Returns with a list of declarations started from the canonical decl
// then followed by subsequent decls in the translation unit.
// This gives a canonical list for each entry in the redecl chain.

View File

@ -14,11 +14,10 @@
#ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
#define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
#include "clang/AST/ASTImportError.h"
#include "clang/AST/ASTImporterLookupTable.h"
#include "clang/AST/Decl.h"
#include "llvm/ADT/DenseMap.h"
// FIXME We need this because of ImportError.
#include "clang/AST/ASTImporter.h"
namespace clang {