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.

llvm-svn: 135574
This commit is contained in:
Chris Lattner 2011-07-20 06:37:11 +00:00
parent e3063f022b
commit dba38736a5
8 changed files with 46 additions and 40 deletions

View File

@ -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 <cassert>
#include <cstring>
#include <algorithm>
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<SpecificAttr>(*Current))
while (!isa<SpecificAttr>(*Current))
++Current;
}
void AdvanceToNext(AttrVec::const_iterator I) const {
while (Current != I && !llvm::isa<SpecificAttr>(*Current))
while (Current != I && !isa<SpecificAttr>(*Current))
++Current;
}
@ -180,11 +179,11 @@ public:
reference operator*() const {
AdvanceToNext();
return llvm::cast<SpecificAttr>(*Current);
return cast<SpecificAttr>(*Current);
}
pointer operator->() const {
AdvanceToNext();
return llvm::cast<SpecificAttr>(*Current);
return cast<SpecificAttr>(*Current);
}
specific_attr_iterator& operator++() {

View File

@ -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 <string>
using llvm::dyn_cast_or_null;
namespace llvm {
class FoldingSetNodeID;

View File

@ -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,

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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<CompileJobAction>(A))
if (llvm::isa<CompileJobAction>(A))
return true;
for (Action::const_iterator it = A->begin(), ie = A->end(); it != ie; ++it)