diff --git a/clang/include/clang/AST/ASTImportError.h b/clang/include/clang/AST/ASTImportError.h new file mode 100644 --- /dev/null +++ b/clang/include/clang/AST/ASTImportError.h @@ -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 { +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 diff --git a/clang/include/clang/AST/ASTImporter.h b/clang/include/clang/AST/ASTImporter.h --- a/clang/include/clang/AST/ASTImporter.h +++ b/clang/include/clang/AST/ASTImporter.h @@ -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 namespace clang { @@ -49,33 +48,6 @@ class TranslationUnitDecl; class TypeSourceInfo; - class ImportError : public llvm::ErrorInfo { - 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. diff --git a/clang/include/clang/AST/ASTImporterSharedState.h b/clang/include/clang/AST/ASTImporterSharedState.h --- a/clang/include/clang/AST/ASTImporterSharedState.h +++ b/clang/include/clang/AST/ASTImporterSharedState.h @@ -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 {