[llvm-branch-commits] [cfe-branch] r155111 - in /cfe/branches/tooling: include/clang/Tooling/Refactoring.h lib/Tooling/Refactoring.cpp tools/fix-llvm-style/FixLLVMStyle.cpp tools/remove-cstr-calls/RemoveCStrCalls.cpp unittests/CMakeLists.txt unittests/Tooling/RefactoringTest.cpp

Manuel Klimek klimek at google.com
Thu Apr 19 02:37:34 PDT 2012


Author: klimek
Date: Thu Apr 19 04:37:33 2012
New Revision: 155111

URL: http://llvm.org/viewvc/llvm-project?rev=155111&view=rev
Log:
Result of running fix-llvm-style over the refactoring related sources.


Modified:
    cfe/branches/tooling/include/clang/Tooling/Refactoring.h
    cfe/branches/tooling/lib/Tooling/Refactoring.cpp
    cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp
    cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp
    cfe/branches/tooling/unittests/CMakeLists.txt
    cfe/branches/tooling/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/branches/tooling/include/clang/Tooling/Refactoring.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Tooling/Refactoring.h?rev=155111&r1=155110&r2=155111&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Tooling/Refactoring.h (original)
+++ cfe/branches/tooling/include/clang/Tooling/Refactoring.h Thu Apr 19 04:37:33 2012
@@ -64,17 +64,17 @@
   /// \brief Returns whether this replacement can be applied to a file.
   ///
   /// Only replacements that are in a valid file can be applied.
-  bool IsApplicable() const;
+  bool isApplicable() const;
 
   /// \brief Accessors.
   /// @{
-  std::string GetFilePath() const { return FilePath; }
-  unsigned GetOffset() const { return Offset; }
-  unsigned GetLength() const { return Length; }
+  std::string getFilePath() const { return FilePath; }
+  unsigned getOffset() const { return Offset; }
+  unsigned getLength() const { return Length; }
   /// @}
 
   /// \brief Applies the replacement on the Rewriter.
-  bool Apply(Rewriter &Rewrite) const;
+  bool apply(Rewriter &Rewrite) const;
 
   /// \brief Comparator to be able to use Replacement in std::set for uniquing.
   class Less {
@@ -83,9 +83,9 @@
   };
 
  private:
-  void SetFromSourceLocation(SourceManager &Sources, SourceLocation Start, 
+  void setFromSourceLocation(SourceManager &Sources, SourceLocation Start, 
                              unsigned Length, llvm::StringRef ReplacementText);
-  void SetFromSourceRange(SourceManager &Sources, const CharSourceRange &Range,
+  void setFromSourceRange(SourceManager &Sources, const CharSourceRange &Range,
                           llvm::StringRef ReplacementText);
 
   std::string FilePath;
@@ -103,13 +103,13 @@
 /// If at least one Apply returns false, ApplyAll returns false. Every
 /// Apply will be executed independently of the result of the result of
 /// other Apply operations.
-bool ApplyAllReplacements(Replacements &Replaces, Rewriter &Rewrite);
+bool applyAllReplacements(Replacements &Replaces, Rewriter &Rewrite);
 
 /// \brief Saves all changed files in the Rewriter to disk.
 ///
 /// \returns True On Success.
 /// FIXME: Put into Rewriter.
-bool SaveRewrittenFiles(Rewriter &Rewrite);
+bool saveRewrittenFiles(Rewriter &Rewrite);
 
 /// \brief A tool to run refactorings.
 ///
@@ -127,10 +127,10 @@
   /// \brief Returns a set of replacements. All replacements added during the
   /// run of the tool will be applied after all translation units have been
   /// processed.
-  Replacements &GetReplacements();
+  Replacements &getReplacements();
 
   /// \see ClangTool::Run.
-  int Run(FrontendActionFactory *ActionFactory);
+  int run(FrontendActionFactory *ActionFactory);
 
 private:
   ClangTool Tool;
@@ -147,7 +147,7 @@
                          llvm::StringRef ReplacementText) {
   const CharSourceRange Range =
       CharSourceRange::getTokenRange(NodeToReplace->getSourceRange());
-  SetFromSourceRange(Sources, Range, ReplacementText);
+  setFromSourceRange(Sources, Range, ReplacementText);
 }
 
 } // end namespace tooling

Modified: cfe/branches/tooling/lib/Tooling/Refactoring.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Tooling/Refactoring.cpp?rev=155111&r1=155110&r2=155111&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Tooling/Refactoring.cpp (original)
+++ cfe/branches/tooling/lib/Tooling/Refactoring.cpp Thu Apr 19 04:37:33 2012
@@ -35,19 +35,19 @@
 
 Replacement::Replacement(SourceManager &Sources, SourceLocation Start,
                          unsigned Length, llvm::StringRef ReplacementText) {
-  SetFromSourceLocation(Sources, Start, Length, ReplacementText);
+  setFromSourceLocation(Sources, Start, Length, ReplacementText);
 }
 
 Replacement::Replacement(SourceManager &Sources, const CharSourceRange &Range,
                          llvm::StringRef ReplacementText) {
-  SetFromSourceRange(Sources, Range, ReplacementText);
+  setFromSourceRange(Sources, Range, ReplacementText);
 }
 
-bool Replacement::IsApplicable() const {
+bool Replacement::isApplicable() const {
   return FilePath != InvalidLocation;
 }
 
-bool Replacement::Apply(Rewriter &Rewrite) const {
+bool Replacement::apply(Rewriter &Rewrite) const {
   SourceManager &SM = Rewrite.getSourceMgr();
   const FileEntry *Entry = SM.getFileManager().getFile(FilePath);
   if (Entry == NULL)
@@ -79,7 +79,7 @@
   return R1.ReplacementText < R2.ReplacementText;
 }
 
-void Replacement::SetFromSourceLocation(SourceManager &Sources,
+void Replacement::setFromSourceLocation(SourceManager &Sources,
                                         SourceLocation Start, unsigned Length,
                                         llvm::StringRef ReplacementText) {
   const std::pair<FileID, unsigned> DecomposedLocation =
@@ -91,20 +91,20 @@
   this->ReplacementText = ReplacementText;
 }
 
-void Replacement::SetFromSourceRange(SourceManager &Sources,
+void Replacement::setFromSourceRange(SourceManager &Sources,
                                      const CharSourceRange &Range,
                                      llvm::StringRef ReplacementText) {
-  SetFromSourceLocation(Sources, Sources.getSpellingLoc(Range.getBegin()),
+  setFromSourceLocation(Sources, Sources.getSpellingLoc(Range.getBegin()),
                         getRangeSize(Sources, Range), ReplacementText);
 }
 
-bool ApplyAllReplacements(Replacements &Replaces, Rewriter &Rewrite) {
+bool applyAllReplacements(Replacements &Replaces, Rewriter &Rewrite) {
   bool Result = true;
   for (Replacements::const_iterator I = Replaces.begin(),
                                     E = Replaces.end();
        I != E; ++I) {
-    if (I->IsApplicable()) {
-      Result = I->Apply(Rewrite) && Result;
+    if (I->isApplicable()) {
+      Result = I->apply(Rewrite) && Result;
     } else {
       Result = false;
     }
@@ -112,7 +112,7 @@
   return Result;
 }
 
-bool SaveRewrittenFiles(Rewriter &Rewrite) {
+bool saveRewrittenFiles(Rewriter &Rewrite) {
   for (Rewriter::buffer_iterator I = Rewrite.buffer_begin(),
                                  E = Rewrite.buffer_end();
        I != E; ++I) {
@@ -149,9 +149,9 @@
                                  ArrayRef<std::string> SourcePaths)
   : Tool(Compilations, SourcePaths) {}
 
-Replacements &RefactoringTool::GetReplacements() { return Replace; }
+Replacements &RefactoringTool::getReplacements() { return Replace; }
 
-int RefactoringTool::Run(FrontendActionFactory *ActionFactory) {
+int RefactoringTool::run(FrontendActionFactory *ActionFactory) {
   int Result = Tool.run(ActionFactory);
   LangOptions DefaultLangOptions;
   DiagnosticOptions DefaultDiagnosticOptions;
@@ -162,10 +162,10 @@
       &DiagnosticPrinter, false);
   SourceManager Sources(Diagnostics, Tool.getFiles());
   Rewriter Rewrite(Sources, DefaultLangOptions);
-  if (!ApplyAllReplacements(Replace, Rewrite)) {
+  if (!applyAllReplacements(Replace, Rewrite)) {
     llvm::errs() << "Skipped some replacements.\n";
   }
-  if (!SaveRewrittenFiles(Rewrite)) {
+  if (!saveRewrittenFiles(Rewrite)) {
     llvm::errs() << "Could not save rewritten files.\n";
     return 1;
   }

Modified: cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp?rev=155111&r1=155110&r2=155111&view=diff
==============================================================================
--- cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp (original)
+++ cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp Thu Apr 19 04:37:33 2012
@@ -121,7 +121,7 @@
 class FixLLVMStyle: public ast_matchers::MatchFinder::MatchCallback {
  public:
   FixLLVMStyle(tooling::Replacements *Replace)
-      : Replace(Replace), EditFilesExpression(".*ASTMatchers/.*|.*tools/clang/tools/.*") {}
+      : Replace(Replace), EditFilesExpression(".*/Refactoring.*|.*tools/clang/tools/.*") {}
 
   virtual void run(const ast_matchers::MatchFinder::MatchResult &Result) {
     if (const CallExpr *Call = Result.Nodes.getStmtAs<CallExpr>("call")) {
@@ -178,16 +178,16 @@
             NameInfo = Using->getNameInfo();
           }
           ReplaceText = Replacement(*Result.SourceManager, &NameInfo, Name);
-          if (!ReplaceText.IsApplicable()) {
+          if (!ReplaceText.isApplicable()) {
    //         llvm::errs() << "Not applicable: " << Name << "\n";
           }
         }
       }
     }
-    if (EditFilesExpression.match(ReplaceText.GetFilePath())) {
+    if (EditFilesExpression.match(ReplaceText.getFilePath())) {
       //llvm::errs() << GetPosition(*Result.Nodes.GetDeclAs<NamedDecl>("declaration"), *Result.SourceManager) << "\n";
       //llvm::errs
-      llvm::errs() << ReplaceText.GetFilePath() << ":" << ReplaceText.GetOffset() << ", " << ReplaceText.GetLength() << ": s/" << OldName << "/" << Name << "/g;\n";
+      llvm::errs() << ReplaceText.getFilePath() << ":" << ReplaceText.getOffset() << ", " << ReplaceText.getLength() << ": s/" << OldName << "/" << Name << "/g;\n";
       Replace->insert(ReplaceText);
     } else {
 //     llvm::errs() << ReplaceText.GetFilePath() << ":" << ReplaceText.GetOffset() << ", " << ReplaceText.GetLength() << ": s/" << OldName << "/" << Name << "/g;\n";
@@ -293,7 +293,7 @@
                 HasName("internal::PolymorphicMatcherWithParam2")
         )))));
 
-  FixLLVMStyle Callback(&Tool.GetReplacements());
+  FixLLVMStyle Callback(&Tool.getReplacements());
   Finder.addMatcher(StatementMatcher(AnyOf(
       StatementMatcher(Id("ref", DeclarationReference(To(Id("declaration", FunctionMatch))))),
       Call(Callee(Id("declaration", FunctionMatch)),
@@ -308,6 +308,6 @@
           Not(Constructor())))
         ),
       &Callback);
-  return Tool.Run(newFrontendActionFactory(&Finder));
+  return Tool.run(newFrontendActionFactory(&Finder));
 }
 

Modified: cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp?rev=155111&r1=155110&r2=155111&view=diff
==============================================================================
--- cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp (original)
+++ cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp Thu Apr 19 04:37:33 2012
@@ -185,7 +185,7 @@
     llvm::report_fatal_error(ErrorMessage);
   tooling::RefactoringTool Tool(*Compilations, SourcePaths);
   ast_matchers::MatchFinder Finder;
-  FixCStrCall Callback(&Tool.GetReplacements());
+  FixCStrCall Callback(&Tool.getReplacements());
   Finder.addMatcher(
       ConstructorCall(
           HasDeclaration(Method(HasName(StringConstructor))),
@@ -228,6 +228,6 @@
                   Callee(Method(HasName(StringCStrMethod))),
                   On(Id("arg", Expression())))))),
       &Callback);
-  return Tool.Run(newFrontendActionFactory(&Finder));
+  return Tool.run(newFrontendActionFactory(&Finder));
 }
 

Modified: cfe/branches/tooling/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/CMakeLists.txt?rev=155111&r1=155110&r2=155111&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/CMakeLists.txt (original)
+++ cfe/branches/tooling/unittests/CMakeLists.txt Thu Apr 19 04:37:33 2012
@@ -75,6 +75,7 @@
   Tooling/CompilationDatabaseTest.cpp
   Tooling/ToolingTest.cpp
   Tooling/RecursiveASTVisitorTest.cpp
+  Tooling/RefactoringTest.cpp
   USED_LIBS gtest gtest_main clangAST clangTooling
  )
 

Modified: cfe/branches/tooling/unittests/Tooling/RefactoringTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/Tooling/RefactoringTest.cpp?rev=155111&r1=155110&r2=155111&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/branches/tooling/unittests/Tooling/RefactoringTest.cpp Thu Apr 19 04:37:33 2012
@@ -41,7 +41,7 @@
     Diagnostics.setClient(&DiagnosticPrinter, false);
   }
 
-  FileID CreateInMemoryFile(llvm::StringRef Name, llvm::StringRef Content) {
+  FileID createInMemoryFile(llvm::StringRef Name, llvm::StringRef Content) {
     const llvm::MemoryBuffer *Source =
       llvm::MemoryBuffer::getMemBuffer(Content);
     const FileEntry *Entry =
@@ -51,21 +51,21 @@
     return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
   }
 
-  SourceLocation GetLocation(FileID ID, unsigned Line, unsigned Column) {
+  SourceLocation getLocation(FileID ID, unsigned Line, unsigned Column) {
     SourceLocation Result = Sources.translateFileLineCol(
         Sources.getFileEntryForID(ID), Line, Column);
     assert(Result.isValid());
     return Result;
   }
 
-  std::string GetRewrittenText(FileID ID) {
+  std::string getRewrittenText(FileID ID) {
     std::string Result;
     llvm::raw_string_ostream OS(Result);
     Rewrite.getEditBuffer(ID).write(OS);
     return Result;
   }
 
-  Replacement CreateReplacement(SourceLocation Start, unsigned Length,
+  Replacement createReplacement(SourceLocation Start, unsigned Length,
                                 llvm::StringRef ReplacementText) {
     return Replacement(Sources, Start, Length, ReplacementText);
   }
@@ -84,113 +84,113 @@
 };
 
 TEST_F(ReplacementTest, CanDeleteAllText) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp", "text");
-  SourceLocation Location = Context.GetLocation(ID, 1, 1);
-  Replacement Replace(Context.CreateReplacement(Location, 4, ""));
-  EXPECT_TRUE(Replace.Apply(Context.Rewrite));
-  EXPECT_EQ("", Context.GetRewrittenText(ID));
+  FileID ID = Context.createInMemoryFile("input.cpp", "text");
+  SourceLocation Location = Context.getLocation(ID, 1, 1);
+  Replacement Replace(Context.createReplacement(Location, 4, ""));
+  EXPECT_TRUE(Replace.apply(Context.Rewrite));
+  EXPECT_EQ("", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, CanDeleteAllTextInTextWithNewlines) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp", "line1\nline2\nline3");
-  SourceLocation Location = Context.GetLocation(ID, 1, 1);
-  Replacement Replace(Context.CreateReplacement(Location, 17, ""));
-  EXPECT_TRUE(Replace.Apply(Context.Rewrite));
-  EXPECT_EQ("", Context.GetRewrittenText(ID));
+  FileID ID = Context.createInMemoryFile("input.cpp", "line1\nline2\nline3");
+  SourceLocation Location = Context.getLocation(ID, 1, 1);
+  Replacement Replace(Context.createReplacement(Location, 17, ""));
+  EXPECT_TRUE(Replace.apply(Context.Rewrite));
+  EXPECT_EQ("", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, CanAddText) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp", "");
-  SourceLocation Location = Context.GetLocation(ID, 1, 1);
-  Replacement Replace(Context.CreateReplacement(Location, 0, "result"));
-  EXPECT_TRUE(Replace.Apply(Context.Rewrite));
-  EXPECT_EQ("result", Context.GetRewrittenText(ID));
+  FileID ID = Context.createInMemoryFile("input.cpp", "");
+  SourceLocation Location = Context.getLocation(ID, 1, 1);
+  Replacement Replace(Context.createReplacement(Location, 0, "result"));
+  EXPECT_TRUE(Replace.apply(Context.Rewrite));
+  EXPECT_EQ("result", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, CanReplaceTextAtPosition) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp",
+  FileID ID = Context.createInMemoryFile("input.cpp",
                                          "line1\nline2\nline3\nline4");
-  SourceLocation Location = Context.GetLocation(ID, 2, 3);
-  Replacement Replace(Context.CreateReplacement(Location, 12, "x"));
-  EXPECT_TRUE(Replace.Apply(Context.Rewrite));
-  EXPECT_EQ("line1\nlixne4", Context.GetRewrittenText(ID));
+  SourceLocation Location = Context.getLocation(ID, 2, 3);
+  Replacement Replace(Context.createReplacement(Location, 12, "x"));
+  EXPECT_TRUE(Replace.apply(Context.Rewrite));
+  EXPECT_EQ("line1\nlixne4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, CanReplaceTextAtPositionMultipleTimes) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp",
+  FileID ID = Context.createInMemoryFile("input.cpp",
                                          "line1\nline2\nline3\nline4");
-  SourceLocation Location1 = Context.GetLocation(ID, 2, 3);
-  Replacement Replace1(Context.CreateReplacement(Location1, 12, "x\ny\n"));
-  EXPECT_TRUE(Replace1.Apply(Context.Rewrite));
-  EXPECT_EQ("line1\nlix\ny\nne4", Context.GetRewrittenText(ID));
+  SourceLocation Location1 = Context.getLocation(ID, 2, 3);
+  Replacement Replace1(Context.createReplacement(Location1, 12, "x\ny\n"));
+  EXPECT_TRUE(Replace1.apply(Context.Rewrite));
+  EXPECT_EQ("line1\nlix\ny\nne4", Context.getRewrittenText(ID));
 
   // Since the original source has not been modified, the (4, 4) points to the
   // 'e' in the original content.
-  SourceLocation Location2 = Context.GetLocation(ID, 4, 4);
-  Replacement Replace2(Context.CreateReplacement(Location2, 1, "f"));
-  EXPECT_TRUE(Replace2.Apply(Context.Rewrite));
-  EXPECT_EQ("line1\nlix\ny\nnf4", Context.GetRewrittenText(ID));
+  SourceLocation Location2 = Context.getLocation(ID, 4, 4);
+  Replacement Replace2(Context.createReplacement(Location2, 1, "f"));
+  EXPECT_TRUE(Replace2.apply(Context.Rewrite));
+  EXPECT_EQ("line1\nlix\ny\nnf4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, ApplyFailsForNonExistentLocation) {
   Replacement Replace("nonexistent-file.cpp", 0, 1, "");
-  EXPECT_FALSE(Replace.Apply(Context.Rewrite));
+  EXPECT_FALSE(Replace.apply(Context.Rewrite));
 }
 
 TEST_F(ReplacementTest, CanRetrivePath) {
   Replacement Replace("/path/to/file.cpp", 0, 1, "");
-  EXPECT_EQ("/path/to/file.cpp", Replace.GetFilePath());
+  EXPECT_EQ("/path/to/file.cpp", Replace.getFilePath());
 }
 
 TEST_F(ReplacementTest, ReturnsInvalidPath) {
   Replacement Replace1(Context.Sources, SourceLocation(), 0, "");
-  EXPECT_EQ("invalid-location", Replace1.GetFilePath());
+  EXPECT_EQ("invalid-location", Replace1.getFilePath());
 
   Replacement Replace2;
-  EXPECT_EQ("invalid-location", Replace2.GetFilePath());
+  EXPECT_EQ("invalid-location", Replace2.getFilePath());
 }
 
 TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp",
+  FileID ID = Context.createInMemoryFile("input.cpp",
                                          "line1\nline2\nline3\nline4");
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(ID, 2, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
                               5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(ID, 3, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 1),
                               5, "other"));
-  EXPECT_TRUE(ApplyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("line1\nreplaced\nother\nline4", Context.GetRewrittenText(ID));
+  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, SkipsDuplicateReplacements) {
-  FileID ID = Context.CreateInMemoryFile("input.cpp",
+  FileID ID = Context.createInMemoryFile("input.cpp",
                                          "line1\nline2\nline3\nline4");
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(ID, 2, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
                               5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(ID, 2, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
                               5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(ID, 2, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
                               5, "replaced"));
-  EXPECT_TRUE(ApplyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("line1\nreplaced\nline3\nline4", Context.GetRewrittenText(ID));
+  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ("line1\nreplaced\nline3\nline4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, ApplyAllFailsIfOneApplyFails) {
   // This test depends on the value of the file name of an invalid source
   // location being in the range ]a, z[.
-  FileID IDa = Context.CreateInMemoryFile("a.cpp", "text");
-  FileID IDz = Context.CreateInMemoryFile("z.cpp", "text");
+  FileID IDa = Context.createInMemoryFile("a.cpp", "text");
+  FileID IDz = Context.createInMemoryFile("z.cpp", "text");
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(IDa, 1, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(IDa, 1, 1),
                               4, "a"));
   Replaces.insert(Replacement(Context.Sources, SourceLocation(),
                               5, "2"));
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(IDz, 1, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(IDz, 1, 1),
                               4, "z"));
-  EXPECT_FALSE(ApplyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("a", Context.GetRewrittenText(IDa));
-  EXPECT_EQ("z", Context.GetRewrittenText(IDz));
+  EXPECT_FALSE(applyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ("a", Context.getRewrittenText(IDa));
+  EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
 class FlushRewrittenFilesTest : public ::testing::Test {
@@ -207,7 +207,7 @@
     assert(ErrorInfo.empty());
   }
 
-  FileID CreateFile(llvm::StringRef Name, llvm::StringRef Content) {
+  FileID createFile(llvm::StringRef Name, llvm::StringRef Content) {
     llvm::SmallString<1024> Path(TemporaryDirectory.str());
     llvm::sys::path::append(Path, Name);
     std::string ErrorInfo;
@@ -221,7 +221,7 @@
     return Context.Sources.createFileID(File, SourceLocation(), SrcMgr::C_User);
   }
 
-  std::string GetFileContentFromDisk(llvm::StringRef Name) {
+  std::string getFileContentFromDisk(llvm::StringRef Name) {
     llvm::SmallString<1024> Path(TemporaryDirectory.str());
     llvm::sys::path::append(Path, Name);
     // We need to read directly from the FileManager without relaying through
@@ -237,14 +237,14 @@
 };
 
 TEST_F(FlushRewrittenFilesTest, StoresChangesOnDisk) {
-  FileID ID = CreateFile("input.cpp", "line1\nline2\nline3\nline4");
+  FileID ID = createFile("input.cpp", "line1\nline2\nline3\nline4");
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.GetLocation(ID, 2, 1),
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
                               5, "replaced"));
-  EXPECT_TRUE(ApplyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_TRUE(SaveRewrittenFiles(Context.Rewrite));
+  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_TRUE(saveRewrittenFiles(Context.Rewrite));
   EXPECT_EQ("line1\nreplaced\nline3\nline4",
-            GetFileContentFromDisk("input.cpp"));
+            getFileContentFromDisk("input.cpp"));
 }
 
 namespace {
@@ -290,10 +290,10 @@
 
 void expectReplacementAt(const Replacement &Replace,
                          StringRef File, unsigned Offset, unsigned Length) {
-  ASSERT_TRUE(Replace.IsApplicable());
-  EXPECT_EQ(File, Replace.GetFilePath());
-  EXPECT_EQ(Offset, Replace.GetOffset());
-  EXPECT_EQ(Length, Replace.GetLength());
+  ASSERT_TRUE(Replace.isApplicable());
+  EXPECT_EQ(File, Replace.getFilePath());
+  EXPECT_EQ(Offset, Replace.getOffset());
+  EXPECT_EQ(Length, Replace.getLength());
 }
 
 class ClassDeclXVisitor : public TestVisitor<ClassDeclXVisitor> {





More information about the llvm-branch-commits mailing list