[cfe-dev] [PATCH] clang: Style changes to ParseAST.[cpp,h].

Thiago Farina tfransosi at gmail.com
Sat Apr 2 22:46:19 PDT 2011


- makes all function parameter names start with a lower case letter
  for consistency and distinction from member variables.

Signed-off-by: Thiago Farina <tfarina at chromium.org>
---
 include/clang/Parse/ParseAST.h |   18 ++++++-----
 lib/Parse/ParseAST.cpp         |   64 ++++++++++++++++++++-------------------
 2 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/include/clang/Parse/ParseAST.h b/include/clang/Parse/ParseAST.h
index 0d37e21..bf818b0 100644
--- a/include/clang/Parse/ParseAST.h
+++ b/include/clang/Parse/ParseAST.h
@@ -33,15 +33,17 @@ namespace clang {
   ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
-  void ParseAST(Preprocessor &pp, ASTConsumer *C,
-                ASTContext &Ctx, bool PrintStats = false,
-                bool CompleteTranslationUnit = true,
-                CodeCompleteConsumer *CompletionConsumer = 0);
+  void ParseAST(Preprocessor &pre_processor,
+                ASTConsumer *consumer,
+                ASTContext &context,
+                bool print_stats = false,
+                bool complete_translation_unit = true,
+                CodeCompleteConsumer *completion_consumer = 0);
 
-  /// \brief Parse the main file known to the preprocessor, producing an 
+  /// \brief Parse the main file known to the preprocessor, producing an
   /// abstract syntax tree.
-  void ParseAST(Sema &S, bool PrintStats = false);
-  
+  void ParseAST(Sema &s, bool print_stats = false);
+
 }  // end namespace clang
 
-#endif
+#endif  // LLVM_CLANG_PARSE_PARSEAST_H
diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp
index 21917b2..c95bda5 100644
--- a/lib/Parse/ParseAST.cpp
+++ b/lib/Parse/ParseAST.cpp
@@ -23,43 +23,43 @@
 #include "clang/Parse/Parser.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Support/CrashRecoveryContext.h"
-#include <cstdio>
-
-using namespace clang;
 
 //===----------------------------------------------------------------------===//
 // Public interface to the file
 //===----------------------------------------------------------------------===//
 
+namespace clang {
+
 /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
 /// the file is parsed.  This inserts the parsed decls into the translation unit
 /// held by Ctx.
 ///
-void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
-                     ASTContext &Ctx, bool PrintStats,
-                     bool CompleteTranslationUnit,
-                     CodeCompleteConsumer *CompletionConsumer) {
-
-  llvm::OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer,
-                                   CompleteTranslationUnit,
-                                   CompletionConsumer));
+void ParseAST(Preprocessor &pre_processor,
+              ASTConsumer *consumer,
+              ASTContext &context,
+              bool print_stats,
+              bool complete_translation_unit,
+              CodeCompleteConsumer *completion_consumer) {
+  llvm::OwningPtr<Sema> S(new Sema(pre_processor, context, *consumer,
+                                   complete_translation_unit,
+                                   completion_consumer));
 
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleaupSema(S.get());
-  
-  ParseAST(*S.get(), PrintStats);
+
+  ParseAST(*S.get(), print_stats);
 }
 
-void clang::ParseAST(Sema &S, bool PrintStats) {
+void ParseAST(Sema &s, bool print_stats) {
   // Collect global stats on Decls/Stmts (until we have a module streamer).
-  if (PrintStats) {
+  if (print_stats) {
     Decl::CollectingStats(true);
     Stmt::CollectingStats(true);
   }
 
-  ASTConsumer *Consumer = &S.getASTConsumer();
+  ASTConsumer *Consumer = &s.getASTConsumer();
 
-  llvm::OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S));
+  llvm::OwningPtr<Parser> ParseOP(new Parser(s.getPreprocessor(), s));
   Parser &P = *ParseOP.get();
 
   PrettyStackTraceParserEntry CrashInfo(P);
@@ -68,15 +68,15 @@ void clang::ParseAST(Sema &S, bool PrintStats) {
   llvm::CrashRecoveryContextCleanupRegistrar<Parser>
     CleaupParser(ParseOP.get());
 
-  S.getPreprocessor().EnterMainSourceFile();
+  s.getPreprocessor().EnterMainSourceFile();
   P.Initialize();
-  S.Initialize();
-  
-  if (ExternalASTSource *External = S.getASTContext().getExternalSource())
+  s.Initialize();
+
+  if (ExternalASTSource *External = s.getASTContext().getExternalSource())
     External->StartTranslationUnit(Consumer);
-  
+
   Parser::DeclGroupPtrTy ADecl;
-  
+
   while (!P.ParseTopLevelDecl(ADecl)) {  // Not end of file.
     // If we got a null return and something *was* parsed, ignore it.  This
     // is due to a top-level semicolon, an action override, or a parse error
@@ -87,21 +87,23 @@ void clang::ParseAST(Sema &S, bool PrintStats) {
   // Check for any pending objective-c implementation decl.
   while ((ADecl = P.FinishPendingObjCActions()))
     Consumer->HandleTopLevelDecl(ADecl.get());
-  
+
   // Process any TopLevelDecls generated by #pragma weak.
   for (llvm::SmallVector<Decl*,2>::iterator
-       I = S.WeakTopLevelDecls().begin(),
-       E = S.WeakTopLevelDecls().end(); I != E; ++I)
+       I = s.WeakTopLevelDecls().begin(),
+       E = s.WeakTopLevelDecls().end(); I != E; ++I)
     Consumer->HandleTopLevelDecl(DeclGroupRef(*I));
-  
-  Consumer->HandleTranslationUnit(S.getASTContext());
-  
-  if (PrintStats) {
+
+  Consumer->HandleTranslationUnit(s.getASTContext());
+
+  if (print_stats) {
     fprintf(stderr, "\nSTATISTICS:\n");
     P.getActions().PrintStats();
-    S.getASTContext().PrintStats();
+    s.getASTContext().PrintStats();
     Decl::PrintStats();
     Stmt::PrintStats();
     Consumer->PrintStats();
   }
 }
+
+}  // namespace clang
-- 
1.7.3.2.343.g7d43d




More information about the cfe-dev mailing list