[cfe-commits] r154668 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendActions.h include/clang/Frontend/FrontendOptions.h lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp test/Misc/pubnames.c

Douglas Gregor dgregor at apple.com
Fri Apr 13 09:03:00 PDT 2012


Author: dgregor
Date: Fri Apr 13 11:03:00 2012
New Revision: 154668

URL: http://llvm.org/viewvc/llvm-project?rev=154668&view=rev
Log:
Remove the -cc1-level option "-pubnames-dump". Such things should stay
out of the tree and use the tooling infrastructure.

Removed:
    cfe/trunk/test/Misc/pubnames.c
Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Frontend/FrontendActions.h
    cfe/trunk/include/clang/Frontend/FrontendOptions.h
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/lib/Frontend/FrontendActions.cpp
    cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=154668&r1=154667&r2=154668&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Apr 13 11:03:00 2012
@@ -428,9 +428,6 @@
   HelpText<"Build ASTs and view them with GraphViz">;
 def print_decl_contexts : Flag<"-print-decl-contexts">,
   HelpText<"Print DeclContexts and their Decls">;
-def pubnames_dump : Flag<"-pubnames-dump">, 
-  HelpText<"Print all of the public (global) names in the source, e.g., the "
-           "names of all global declarations and macros">;
 def emit_module : Flag<"-emit-module">,
   HelpText<"Generate pre-compiled module file from a module map">;
 def emit_pth : Flag<"-emit-pth">,

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=154668&r1=154667&r2=154668&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Fri Apr 13 11:03:00 2012
@@ -173,15 +173,6 @@
   virtual bool usesPreprocessorOnly() const { return true; }
 };
   
-class PubnamesDumpAction : public ASTFrontendAction {
-protected:
-  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
-                                         StringRef InFile);
-  
-public:
-  virtual bool hasCodeCompletionSupport() const { return false; }
-};
-
 //===----------------------------------------------------------------------===//
 // Preprocessor Actions
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=154668&r1=154667&r2=154668&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Fri Apr 13 11:03:00 2012
@@ -42,7 +42,6 @@
     PrintDeclContext,       ///< Print DeclContext and their Decls.
     PrintPreamble,          ///< Print the "preamble" of the input file
     PrintPreprocessedInput, ///< -E mode.
-    PubnamesDump,           ///< Print all of the "public" names in the source.
     RewriteMacros,          ///< Expand macros but not #includes.
     RewriteObjC,            ///< ObjC->C Rewriter.
     RewriteTest,            ///< Rewriter playground

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=154668&r1=154667&r2=154668&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Apr 13 11:03:00 2012
@@ -429,7 +429,6 @@
   case frontend::PrintDeclContext:       return "-print-decl-contexts";
   case frontend::PrintPreamble:          return "-print-preamble";
   case frontend::PrintPreprocessedInput: return "-E";
-  case frontend::PubnamesDump:           return "-pubnames-dump";
   case frontend::RewriteMacros:          return "-rewrite-macros";
   case frontend::RewriteObjC:            return "-rewrite-objc";
   case frontend::RewriteTest:            return "-rewrite-test";
@@ -1369,8 +1368,6 @@
       Opts.ProgramAction = frontend::PrintPreamble; break;
     case OPT_E:
       Opts.ProgramAction = frontend::PrintPreprocessedInput; break;
-    case OPT_pubnames_dump:
-      Opts.ProgramAction = frontend::PubnamesDump; break;
     case OPT_rewrite_macros:
       Opts.ProgramAction = frontend::RewriteMacros; break;
     case OPT_rewrite_objc:

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=154668&r1=154667&r2=154668&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Apr 13 11:03:00 2012
@@ -25,7 +25,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
-#include <set>
 
 using namespace clang;
 
@@ -355,77 +354,6 @@
   return new ASTConsumer();
 }
 
-namespace {
-  class PubnamesDumpConsumer : public ASTConsumer {
-    Preprocessor &PP;
-    
-    /// \brief Determine whether the given identifier provides a 'public' name.
-    bool isPublicName(IdentifierInfo *II) {
-      // If there are any top-level declarations associated with this
-      // identifier, it is a public name.
-      if (II->getFETokenInfo<void>())
-        return true;
-
-      // If this identifier is the name of a non-builtin macro that isn't
-      // defined on the command line or implicitly by the front end, it is a
-      // public name.
-      if (II->hasMacroDefinition()) {
-        if (MacroInfo *M = PP.getMacroInfo(II))
-          if (!M->isBuiltinMacro()) {
-            SourceLocation Loc = M->getDefinitionLoc();
-            FileID File = PP.getSourceManager().getFileID(Loc);
-            if (PP.getSourceManager().getFileEntryForID(File))
-              return true;
-          }
-      }
-      
-      return false;
-    }
-      
-  public:
-    PubnamesDumpConsumer(Preprocessor &PP) : PP(PP) { }
-        
-    virtual void HandleTranslationUnit(ASTContext &Ctx) {
-      std::set<StringRef> Pubnames;
-      
-      // Add the names of any non-builtin macros.
-      for (IdentifierTable::iterator I = Ctx.Idents.begin(),
-                                  IEnd = Ctx.Idents.end();
-           I != IEnd; ++I) {
-        if (isPublicName(I->second))
-          Pubnames.insert(I->first());
-      }
-      
-      // If there is an external identifier lookup source, consider those
-      // identifiers as well.
-      if (IdentifierInfoLookup *External
-            = Ctx.Idents.getExternalIdentifierLookup()) {
-        OwningPtr<IdentifierIterator> Iter(External->getIdentifiers());
-        do {
-          StringRef Name = Iter->Next();
-          if (Name.empty())
-            break;
-          
-          if (isPublicName(PP.getIdentifierInfo(Name)))
-            Pubnames.insert(Name);
-        } while (true);
-      }
-
-      // Print the names, in lexicographical order.
-      for (std::set<StringRef>::iterator N = Pubnames.begin(),
-                                      NEnd = Pubnames.end();
-           N != NEnd; ++N) {
-        llvm::outs() << *N << '\n';
-      }
-    }
-  };
-}
-
-ASTConsumer *PubnamesDumpAction::CreateASTConsumer(CompilerInstance &CI,
-                                                   StringRef InFile) {
-  return new PubnamesDumpConsumer(CI.getPreprocessor());
-}
-
 //===----------------------------------------------------------------------===//
 // Preprocessor Actions
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=154668&r1=154667&r2=154668&view=diff
==============================================================================
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Fri Apr 13 11:03:00 2012
@@ -72,7 +72,6 @@
   case PrintDeclContext:       return new DeclContextPrintAction();
   case PrintPreamble:          return new PrintPreambleAction();
   case PrintPreprocessedInput: return new PrintPreprocessedAction();
-  case PubnamesDump:           return new PubnamesDumpAction();
   case RewriteMacros:          return new RewriteMacrosAction();
   case RewriteObjC:            return new RewriteObjCAction();
   case RewriteTest:            return new RewriteTestAction();

Removed: cfe/trunk/test/Misc/pubnames.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pubnames.c?rev=154667&view=auto
==============================================================================
--- cfe/trunk/test/Misc/pubnames.c (original)
+++ cfe/trunk/test/Misc/pubnames.c (removed)
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -pubnames-dump %s | FileCheck %s
-#define FOO
-#define BAR
-#undef FOO
-#define WIBBLE
-
-int foo();
-int bar(float);
-int wibble;
-
-// CHECK: BAR
-// CHECK-NOT: FOO
-// CHECK: WIBBLE
-// CHECK-NOT: __clang_major__
-// CHECK: bar
-// CHECK: foo
-// CHECK: wibble
-
-





More information about the cfe-commits mailing list