r204955 - Reverting r204952, while I figure out what's going on with the makefile build.

Aaron Ballman aaron at aaronballman.com
Thu Mar 27 13:36:32 PDT 2014


Author: aaronballman
Date: Thu Mar 27 15:36:32 2014
New Revision: 204955

URL: http://llvm.org/viewvc/llvm-project?rev=204955&view=rev
Log:
Reverting r204952, while I figure out what's going on with the makefile build.

Added:
    cfe/trunk/include/clang/Lex/CMakeLists.txt
      - copied unchanged from r204951, cfe/trunk/include/clang/Lex/CMakeLists.txt
    cfe/trunk/include/clang/Lex/Makefile
      - copied unchanged from r204951, cfe/trunk/include/clang/Lex/Makefile
Removed:
    cfe/trunk/include/clang/Basic/Attributes.h
    cfe/trunk/lib/Basic/Attributes.cpp
Modified:
    cfe/trunk/include/clang/Basic/CMakeLists.txt
    cfe/trunk/include/clang/Basic/Makefile
    cfe/trunk/include/clang/CMakeLists.txt
    cfe/trunk/include/clang/Makefile
    cfe/trunk/lib/Basic/CMakeLists.txt
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
    cfe/trunk/utils/TableGen/TableGen.cpp
    cfe/trunk/utils/TableGen/TableGenBackends.h

Removed: cfe/trunk/include/clang/Basic/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attributes.h?rev=204954&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/Attributes.h (original)
+++ cfe/trunk/include/clang/Basic/Attributes.h (removed)
@@ -1,39 +0,0 @@
-//===--- Attributes.h - Attributes header -----------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_BASIC_ATTRIBUTES_H
-#define LLVM_CLANG_BASIC_ATTRIBUTES_H
-
-#include "llvm/ADT/Triple.h"
-#include "clang/Basic/LangOptions.h"
-
-namespace clang {
-
-class IdentifierInfo;
-
-enum class AttrSyntax {
-  /// Is the attribute identifier generally known for any syntax?
-  Generic,
-  /// Is the identifier known as a GNU-style attribute?
-  GNU,
-  /// Is the identifier known as a __declspec-style attribute?
-  Declspec,
-  // Is the identifier known as a C++-style attribute?
-  CXX
-};
-
-/// \brief Return true if we recognize and implement the attribute specified by
-/// the given information.
-bool HasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
-                  const IdentifierInfo *Attr, const llvm::Triple &T,
-                  const LangOptions &LangOpts);
-
-} // end namespace clang
-
-#endif // LLVM_CLANG_BASIC_ATTRIBUTES_H

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Thu Mar 27 15:36:32 2014
@@ -28,12 +28,6 @@ clang_tablegen(AttrList.inc -gen-clang-a
   SOURCE Attr.td
   TARGET ClangAttrList)
 
-clang_tablegen(AttrHasAttributeImpl.inc -gen-clang-attr-has-attribute-impl
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-  SOURCE Attr.td
-  TARGET ClangAttrHasAttributeImpl
-  )
-
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
   SOURCE arm_neon.td

Modified: cfe/trunk/include/clang/Basic/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Makefile?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Makefile (original)
+++ cfe/trunk/include/clang/Basic/Makefile Thu Mar 27 15:36:32 2014
@@ -6,7 +6,6 @@ BUILT_SOURCES = \
 	DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \
 	DiagnosticParseKinds.inc DiagnosticSemaKinds.inc \
 	DiagnosticSerializationKinds.inc \
-	AttrHasAttributeImpl.inc \
 	DiagnosticIndexName.inc DiagnosticGroups.inc AttrList.inc arm_neon.inc \
 	Version.inc
 
@@ -49,12 +48,6 @@ $(ObjDir)/AttrList.inc.tmp : Attr.td $(C
 	$(Verb) $(ClangTableGen) -gen-clang-attr-list -o $(call SYSPATH, $@) \
 	  -I $(PROJ_SRC_DIR)/../.. $<
 
-$(ObjDir)/AttrHasAttributeImpl.inc.tmp : Attr.td $(CLANG_TBLGEN) \
-                                  $(ObjDir)/.dir
-	$(Echo) "Building Clang __has_attribute implementation with tblgen"
-	$(Verb) $(ClangTableGen) -gen-clang-attr-has-attribute-impl -o $(call SYSPATH, $@) \
-		-I $(PROJ_SRC_DIR)/../../ $<
-
 $(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(CLANG_TBLGEN) $(ObjDir)/.dir
 	$(Echo) "Building Clang arm_neon.inc with tblgen"
 	$(Verb) $(ClangTableGen) -gen-arm-neon-sema -o $(call SYSPATH, $@) $<

Modified: cfe/trunk/include/clang/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CMakeLists.txt?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/include/clang/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/CMakeLists.txt Thu Mar 27 15:36:32 2014
@@ -1,6 +1,7 @@
 add_subdirectory(AST)
 add_subdirectory(Basic)
 add_subdirectory(Driver)
+add_subdirectory(Lex)
 add_subdirectory(Parse)
 add_subdirectory(Sema)
 add_subdirectory(Serialization)

Modified: cfe/trunk/include/clang/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Makefile?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/include/clang/Makefile (original)
+++ cfe/trunk/include/clang/Makefile Thu Mar 27 15:36:32 2014
@@ -1,5 +1,5 @@
 CLANG_LEVEL := ../..
-DIRS := AST Basic Driver Parse Sema Serialization
+DIRS := AST Basic Driver Lex Parse Sema Serialization
 
 include $(CLANG_LEVEL)/Makefile
 

Removed: cfe/trunk/lib/Basic/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Attributes.cpp?rev=204954&view=auto
==============================================================================
--- cfe/trunk/lib/Basic/Attributes.cpp (original)
+++ cfe/trunk/lib/Basic/Attributes.cpp (removed)
@@ -1,20 +0,0 @@
-#include "clang/Basic/Attributes.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "llvm/ADT/StringSwitch.h"
-
-namespace clang {
-
-bool HasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
-                         const IdentifierInfo *Attr, const llvm::Triple &T,
-                         const LangOptions &LangOpts) {
-  StringRef Name = Attr->getName();
-  // Normalize the attribute name, __foo__ becomes foo.
-  if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
-    Name = Name.substr(2, Name.size() - 4);
-
-#include "clang/Basic/AttrHasAttributeImpl.inc"
-
-  return false;
-}
-
-} // end namespace clang

Modified: cfe/trunk/lib/Basic/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/CMakeLists.txt (original)
+++ cfe/trunk/lib/Basic/CMakeLists.txt Thu Mar 27 15:36:32 2014
@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_clang_library(clangBasic
-  Attributes.cpp
   Builtins.cpp
   CharInfo.cpp
   Diagnostic.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Mar 27 15:36:32 2014
@@ -13,7 +13,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Lex/Preprocessor.h"
-#include "clang/Basic/Attributes.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
@@ -1048,6 +1047,20 @@ static bool HasExtension(const Preproces
            .Default(false);
 }
 
+/// HasAttribute -  Return true if we recognize and implement the attribute
+/// specified by the given identifier.
+static bool HasAttribute(const IdentifierInfo *II, const llvm::Triple &T) {
+  StringRef Name = II->getName();
+  // Normalize the attribute name, __foo__ becomes foo.
+  if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
+    Name = Name.substr(2, Name.size() - 4);
+
+  // FIXME: Do we need to handle namespaces here?
+  return llvm::StringSwitch<bool>(Name)
+#include "clang/Lex/AttrSpellings.inc"
+        .Default(false);
+}
+
 /// EvaluateHasIncludeCommon - Process a '__has_include("path")'
 /// or '__has_include_next("path")' expression.
 /// Returns true if successful.
@@ -1386,8 +1399,7 @@ void Preprocessor::ExpandBuiltinMacro(To
       // Check for a builtin is trivial.
       Value = FeatureII->getBuiltinID() != 0;
     } else if (II == Ident__has_attribute)
-      Value = HasAttribute(AttrSyntax::Generic, nullptr, FeatureII,
-                           getTargetInfo().getTriple(), getLangOpts());
+      Value = HasAttribute(FeatureII, getTargetInfo().getTriple());
     else if (II == Ident__has_extension)
       Value = HasExtension(*this, FeatureII);
     else {

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Thu Mar 27 15:36:32 2014
@@ -1720,16 +1720,22 @@ void EmitClangAttrPCHWrite(RecordKeeper
   OS << "  }\n";
 }
 
-static void GenerateHasAttrSpellingStringSwitch(
-    const std::vector<Record *> &Attrs, raw_ostream &OS,
-    const std::string &Variety = "", const std::string &Scope = "") {
-  for (const auto *Attr : Attrs) {
+// Emits the list of spellings for attributes.
+void EmitClangAttrSpellingList(RecordKeeper &Records, raw_ostream &OS) {
+  emitSourceFileHeader("llvm::StringSwitch code to match attributes based on "
+                       "the target triple, T", OS);
+
+  std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
+  
+  for (auto I : Attrs) {
+    Record &Attr = *I;
+
     // It is assumed that there will be an llvm::Triple object named T within
     // scope that can be used to determine whether the attribute exists in
     // a given target.
     std::string Test;
-    if (Attr->isSubClassOf("TargetSpecificAttr")) {
-      const Record *R = Attr->getValueAsDef("Target");
+    if (Attr.isSubClassOf("TargetSpecificAttr")) {
+      const Record *R = Attr.getValueAsDef("Target");
       std::vector<std::string> Arches = R->getValueAsListOfStrings("Arches");
 
       Test += "(";
@@ -1754,79 +1760,13 @@ static void GenerateHasAttrSpellingStrin
         }
         Test += ")";
       }
-      
-      // If this is the C++11 variety, also add in the LangOpts test.
-      if (Variety == "CXX11")
-        Test += " && LangOpts.CPlusPlus11";      
-    } else if (Variety == "CXX11")
-      // C++11 mode should be checked against LangOpts, which is presumed to be
-      // present in the caller.
-      Test = "LangOpts.CPlusPlus11";
-    else
+    } else
       Test = "true";
 
-    std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*Attr);
+    std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(Attr);
     for (const auto &S : Spellings)
-      if (Variety.empty() || (Variety == S.variety() &&
-                              (Scope.empty() || Scope == S.nameSpace())))
-        OS << "    .Case(\"" << S.name() << "\", " << Test << ")\n";
-  }
-  OS << "    .Default(false);\n";
-}
-
-// Emits the list of spellings for attributes.
-void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
-  emitSourceFileHeader("Code to implement the __has_attribute logic", OS);
-
-  // Separate all of the attributes out into four group: generic, C++11, GNU,
-  // and declspecs. Then generate a big switch statement for each of them.
-  std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
-  std::vector<Record *> Declspec, GNU;
-  std::map<std::string, std::vector<Record *>> CXX;
-
-  // Walk over the list of all attributes, and split them out based on the
-  // spelling variety.
-  for (auto *R : Attrs) {
-    std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
-    for (const auto &SI : Spellings) {
-      std::string Variety = SI.variety();
-      if (Variety == "GNU")
-        GNU.push_back(R);
-      else if (Variety == "Declspec")
-        Declspec.push_back(R);
-      else if (Variety == "CXX11") {
-        CXX[SI.nameSpace()].push_back(R);
-      }
-    }
-  }
-
-  OS << "switch (Syntax) {\n";
-  OS << "case AttrSyntax::Generic:\n";
-  OS << "  return llvm::StringSwitch<bool>(Name)\n";
-  GenerateHasAttrSpellingStringSwitch(Attrs, OS);
-  OS << "case AttrSyntax::GNU:\n";
-  OS << "  return llvm::StringSwitch<bool>(Name)\n";
-  GenerateHasAttrSpellingStringSwitch(GNU, OS, "GNU");
-  OS << "case AttrSyntax::Declspec:\n";
-  OS << "  return llvm::StringSwitch<bool>(Name)\n";
-  GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec");
-  OS << "case AttrSyntax::CXX: {\n";
-  // C++11-style attributes are further split out based on the Scope.
-  for (std::map<std::string, std::vector<Record *>>::iterator I = CXX.begin(),
-                                                              E = CXX.end();
-       I != E; ++I) {
-    if (I != CXX.begin())
-      OS << " else ";
-    if (I->first.empty())
-      OS << "if (!Scope || Scope->getName() == \"\") {\n";
-    else
-      OS << "if (Scope->getName() == \"" << I->first << "\") {\n";
-    OS << "  return llvm::StringSwitch<bool>(Name)\n";
-    GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first);
-    OS << "}";
+      OS << ".Case(\"" << S.name() << "\", " << Test << ")\n";
   }
-  OS << "\n}\n";
-  OS << "}\n";
 }
 
 void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) {

Modified: cfe/trunk/utils/TableGen/TableGen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/TableGen.cpp?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/TableGen.cpp (original)
+++ cfe/trunk/utils/TableGen/TableGen.cpp Thu Mar 27 15:36:32 2014
@@ -29,7 +29,7 @@ enum ActionType {
   GenClangAttrList,
   GenClangAttrPCHRead,
   GenClangAttrPCHWrite,
-  GenClangAttrHasAttributeImpl,
+  GenClangAttrSpellingList,
   GenClangAttrSpellingListIndex,
   GenClangAttrASTVisitor,
   GenClangAttrTemplateInstantiate,
@@ -72,8 +72,7 @@ cl::opt<ActionType> Action(
                    "Generate clang PCH attribute reader"),
         clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
                    "Generate clang PCH attribute writer"),
-        clEnumValN(GenClangAttrHasAttributeImpl,
-                   "gen-clang-attr-has-attribute-impl",
+        clEnumValN(GenClangAttrSpellingList, "gen-clang-attr-spelling-list",
                    "Generate a clang attribute spelling list"),
         clEnumValN(GenClangAttrSpellingListIndex,
                    "gen-clang-attr-spelling-index",
@@ -160,8 +159,8 @@ bool ClangTableGenMain(raw_ostream &OS,
   case GenClangAttrPCHWrite:
     EmitClangAttrPCHWrite(Records, OS);
     break;
-  case GenClangAttrHasAttributeImpl:
-    EmitClangAttrHasAttrImpl(Records, OS);
+  case GenClangAttrSpellingList:
+    EmitClangAttrSpellingList(Records, OS);
     break;
   case GenClangAttrSpellingListIndex:
     EmitClangAttrSpellingListIndex(Records, OS);

Modified: cfe/trunk/utils/TableGen/TableGenBackends.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/TableGenBackends.h?rev=204955&r1=204954&r2=204955&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/TableGenBackends.h (original)
+++ cfe/trunk/utils/TableGen/TableGenBackends.h Thu Mar 27 15:36:32 2014
@@ -35,7 +35,7 @@ void EmitClangAttrImpl(RecordKeeper &Rec
 void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS);
 void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS);
 void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS);
-void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS);
+void EmitClangAttrSpellingList(RecordKeeper &Records, raw_ostream &OS);
 void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS);
 void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS);
 void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS);





More information about the cfe-commits mailing list