[cfe-commits] r135574 - in /cfe/trunk: include/clang/AST/Attr.h include/clang/AST/Stmt.h include/clang/AST/Type.h include/clang/Basic/LLVM.h include/clang/Driver/Action.h include/clang/Driver/Job.h include/clang/Driver/Option.h lib/Driver/Tools.cpp

Chris Lattner sabre at nondot.org
Tue Jul 19 23:37:11 PDT 2011


Author: lattner
Date: Wed Jul 20 01:37:11 2011
New Revision: 135574

URL: http://llvm.org/viewvc/llvm-project?rev=135574&view=rev
Log:
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.

Added:
    cfe/trunk/include/clang/Basic/LLVM.h
Modified:
    cfe/trunk/include/clang/AST/Attr.h
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/Driver/Action.h
    cfe/trunk/include/clang/Driver/Job.h
    cfe/trunk/include/clang/Driver/Option.h
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Wed Jul 20 01:37:11 2011
@@ -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 @@
   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 @@
 
   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++() {

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed Jul 20 01:37:11 2011
@@ -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;

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jul 20 01:37:11 2011
@@ -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,

Added: cfe/trunk/include/clang/Basic/LLVM.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LLVM.h?rev=135574&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/LLVM.h (added)
+++ cfe/trunk/include/clang/Basic/LLVM.h Wed Jul 20 01:37:11 2011
@@ -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

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Wed Jul 20 01:37:11 2011
@@ -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 {

Modified: cfe/trunk/include/clang/Driver/Job.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Job.h (original)
+++ cfe/trunk/include/clang/Driver/Job.h Wed Jul 20 01:37:11 2011
@@ -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 {

Modified: cfe/trunk/include/clang/Driver/Option.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Wed Jul 20 01:37:11 2011
@@ -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 {

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=135574&r1=135573&r2=135574&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 20 01:37:11 2011
@@ -999,7 +999,7 @@
 
 /// \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)





More information about the cfe-commits mailing list