[clang-tools-extra] r174643 - Fix for combined loop and nullptr convert tests
Edwin Vane
edwin.vane at intel.com
Thu Feb 7 10:49:24 PST 2013
Author: revane
Date: Thu Feb 7 12:49:23 2013
New Revision: 174643
URL: http://llvm.org/viewvc/llvm-project?rev=174643&view=rev
Log:
Fix for combined loop and nullptr convert tests
The rewriter was previously reading the content buffer from the file itself.
Since we are now keeping the content in memory and writing to the file only
once, the rewriter's buffer (from the file) was not in sync with the
RefactoringTool's buffer. Adding an overrideFileContents call (similar to how
Clang-format handles for this) will resolve this issue.
Author: Jack Yang <jack.yang at intel.com>
Reviewers: gribozavr, klimek
Modified:
clang-tools-extra/trunk/cpp11-migrate/LoopConvert/LoopConvert.cpp
clang-tools-extra/trunk/cpp11-migrate/Transform.h
clang-tools-extra/trunk/cpp11-migrate/UseNullptr/UseNullptr.cpp
clang-tools-extra/trunk/test/cpp11-migrate/Combined/combined.cpp
Modified: clang-tools-extra/trunk/cpp11-migrate/LoopConvert/LoopConvert.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/LoopConvert/LoopConvert.cpp?rev=174643&r1=174642&r2=174643&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/LoopConvert/LoopConvert.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/LoopConvert/LoopConvert.cpp Thu Feb 7 12:49:23 2013
@@ -69,7 +69,7 @@ int LoopConvertTransform::apply(const Fi
return result;
}
- RewriterContainer Rewrite(LoopTool.getFiles());
+ RewriterContainer Rewrite(LoopTool.getFiles(), InputStates);
// FIXME: Do something if some replacements didn't get applied?
LoopTool.applyAllReplacements(Rewrite.getRewriter());
Modified: clang-tools-extra/trunk/cpp11-migrate/Transform.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Transform.h?rev=174643&r1=174642&r2=174643&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Transform.h (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Transform.h Thu Feb 7 12:49:23 2013
@@ -71,14 +71,24 @@ void collectResults(clang::Rewriter &Rew
/// of being recreated for every Transform subclass, especially diagnostics.
class RewriterContainer {
public:
- RewriterContainer(clang::FileManager &Files)
+ RewriterContainer(clang::FileManager &Files,
+ const FileContentsByPath &InputStates)
: DiagOpts(new clang::DiagnosticOptions()),
DiagnosticPrinter(llvm::errs(), DiagOpts.getPtr()),
Diagnostics(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>(
new clang::DiagnosticIDs()),
DiagOpts.getPtr(), &DiagnosticPrinter, false),
Sources(Diagnostics, Files),
- Rewrite(Sources, DefaultLangOptions) {}
+ Rewrite(Sources, DefaultLangOptions) {
+
+ // Overwrite source manager's file contents with data from InputStates
+ for (FileContentsByPath::const_iterator I = InputStates.begin(),
+ E = InputStates.end();
+ I != E; ++I) {
+ Sources.overrideFileContents(Files.getFile(I->first),
+ llvm::MemoryBuffer::getMemBuffer(I->second));
+ }
+ }
clang::Rewriter &getRewriter() { return Rewrite; }
Modified: clang-tools-extra/trunk/cpp11-migrate/UseNullptr/UseNullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/UseNullptr/UseNullptr.cpp?rev=174643&r1=174642&r2=174643&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/UseNullptr/UseNullptr.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/UseNullptr/UseNullptr.cpp Thu Feb 7 12:49:23 2013
@@ -53,7 +53,7 @@ int UseNullptrTransform::apply(const Fil
return result;
}
- RewriterContainer Rewrite(UseNullptrTool.getFiles());
+ RewriterContainer Rewrite(UseNullptrTool.getFiles(), InputStates);
// FIXME: Do something if some replacements didn't get applied?
UseNullptrTool.applyAllReplacements(Rewrite.getRewriter());
Modified: clang-tools-extra/trunk/test/cpp11-migrate/Combined/combined.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11-migrate/Combined/combined.cpp?rev=174643&r1=174642&r2=174643&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/cpp11-migrate/Combined/combined.cpp (original)
+++ clang-tools-extra/trunk/test/cpp11-migrate/Combined/combined.cpp Thu Feb 7 12:49:23 2013
@@ -4,7 +4,6 @@
// RUN: FileCheck -input-file=%t.cpp %s
// RUN: cpp11-migrate -loop-convert -use-nullptr -risk=risky %t_risky.cpp --
// RUN: FileCheck -check-prefix=RISKY -input-file=%t_risky.cpp %s
-// XFAIL: *
#define NULL 0
More information about the cfe-commits
mailing list