From: Chris Lattner Date: Wed, 20 Jul 2011 06:37:11 +0000 (+0000) Subject: introduce a centralized place to introduce and inject llvm types into the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9594675cc1eb52a054de13c4a21e466643847480;p=clang introduce a centralized place to introduce and inject llvm types into the clang namespace. There are a number of LLVM types that are used pervasively and it doesn't make sense to keep qualifying them. Start with casting operators. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135574 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 719023926b..f634cf538c 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -14,18 +14,17 @@ #ifndef LLVM_CLANG_AST_ATTR_H #define LLVM_CLANG_AST_ATTR_H -#include "llvm/Support/Casting.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/StringSwitch.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/AttrKinds.h" #include "clang/AST/Type.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/VersionTuple.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSwitch.h" #include #include #include -using llvm::dyn_cast; namespace clang { class ASTContext; @@ -159,12 +158,12 @@ class specific_attr_iterator { mutable AttrVec::const_iterator Current; void AdvanceToNext() const { - while (!llvm::isa(*Current)) + while (!isa(*Current)) ++Current; } void AdvanceToNext(AttrVec::const_iterator I) const { - while (Current != I && !llvm::isa(*Current)) + while (Current != I && !isa(*Current)) ++Current; } @@ -180,11 +179,11 @@ public: reference operator*() const { AdvanceToNext(); - return llvm::cast(*Current); + return cast(*Current); } pointer operator->() const { AdvanceToNext(); - return llvm::cast(*Current); + return cast(*Current); } specific_attr_iterator& operator++() { diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index bf5f383be5..4fb13f3125 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -14,16 +14,15 @@ #ifndef LLVM_CLANG_AST_STMT_H #define LLVM_CLANG_AST_STMT_H -#include "llvm/Support/Casting.h" -#include "llvm/Support/raw_ostream.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/AST/PrettyPrinter.h" #include "clang/AST/StmtIterator.h" #include "clang/AST/DeclGroup.h" -#include "llvm/ADT/SmallVector.h" #include "clang/AST/ASTContext.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/SmallVector.h" #include -using llvm::dyn_cast_or_null; namespace llvm { class FoldingSetNodeID; diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index ef0dbdae03..0383ec8e9c 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -22,19 +22,14 @@ #include "clang/Basic/Visibility.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/TemplateName.h" -#include "llvm/Support/Casting.h" #include "llvm/Support/type_traits.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" +#include "clang/Basic/LLVM.h" -using llvm::isa; -using llvm::cast; -using llvm::cast_or_null; -using llvm::dyn_cast; -using llvm::dyn_cast_or_null; namespace clang { enum { TypeAlignmentInBits = 4, diff --git a/include/clang/Basic/LLVM.h b/include/clang/Basic/LLVM.h new file mode 100644 index 0000000000..597fba3921 --- /dev/null +++ b/include/clang/Basic/LLVM.h @@ -0,0 +1,30 @@ +//===--- LLVM.h - Import various common LLVM datatypes ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file forward declares and imports various common LLVM datatypes that +// clang wants to use unqualified. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_BASIC_LLVM_H +#define CLANG_BASIC_LLVM_H + +// This should be the only #include. +#include "llvm/Support/Casting.h" + +namespace clang { + // Casting operators. + using llvm::isa; + using llvm::cast; + using llvm::dyn_cast; + using llvm::dyn_cast_or_null; + using llvm::cast_or_null; +} // end namespace clang. + +#endif diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h index 4b45c98313..abf58c9127 100644 --- a/include/clang/Driver/Action.h +++ b/include/clang/Driver/Action.h @@ -14,13 +14,7 @@ #include "clang/Driver/Types.h" #include "clang/Driver/Util.h" - -#include "llvm/Support/Casting.h" -using llvm::isa; -using llvm::cast; -using llvm::cast_or_null; -using llvm::dyn_cast; -using llvm::dyn_cast_or_null; +#include "clang/Basic/LLVM.h" namespace clang { namespace driver { diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h index d2767d1b87..d7a23c754b 100644 --- a/include/clang/Driver/Job.h +++ b/include/clang/Driver/Job.h @@ -12,13 +12,7 @@ #include "clang/Driver/Util.h" #include "llvm/ADT/SmallVector.h" - -#include "llvm/Support/Casting.h" -using llvm::isa; -using llvm::cast; -using llvm::cast_or_null; -using llvm::dyn_cast; -using llvm::dyn_cast_or_null; +#include "clang/Basic/LLVM.h" namespace clang { namespace driver { diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h index 9dfa461400..1d50246521 100644 --- a/include/clang/Driver/Option.h +++ b/include/clang/Driver/Option.h @@ -12,12 +12,7 @@ #include "clang/Driver/OptSpecifier.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/Casting.h" -using llvm::isa; -using llvm::cast; -using llvm::cast_or_null; -using llvm::dyn_cast; -using llvm::dyn_cast_or_null; +#include "clang/Basic/LLVM.h" namespace clang { namespace driver { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index b47a6bdf3b..c54ced2d1d 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -999,7 +999,7 @@ static bool ShouldDisableCFI(const ArgList &Args, /// \brief Check whether the given input tree contains any compilation actions. static bool ContainsCompileAction(const Action *A) { - if (isa(A)) + if (llvm::isa(A)) return true; for (Action::const_iterator it = A->begin(), ie = A->end(); it != ie; ++it)