summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-02-07 18:49:23 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-02-07 18:49:23 +0000
commit37fea69391468fac9ba32ac6c717c25eb0f670d1 (patch)
tree082165da14787089bf25b06dd5d0943b1c496126
parent0749262a1148a73d110885602b4d9e9017a3f04d (diff)
downloadbcm5719-llvm-37fea69391468fac9ba32ac6c717c25eb0f670d1.tar.gz
bcm5719-llvm-37fea69391468fac9ba32ac6c717c25eb0f670d1.zip
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@intel.com> Reviewers: gribozavr, klimek llvm-svn: 174643
-rw-r--r--clang-tools-extra/cpp11-migrate/LoopConvert/LoopConvert.cpp2
-rw-r--r--clang-tools-extra/cpp11-migrate/Transform.h14
-rw-r--r--clang-tools-extra/cpp11-migrate/UseNullptr/UseNullptr.cpp2
-rw-r--r--clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp1
4 files changed, 14 insertions, 5 deletions
diff --git a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopConvert.cpp b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopConvert.cpp
index 19be2413cf9..0af322602bd 100644
--- a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopConvert.cpp
+++ b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopConvert.cpp
@@ -69,7 +69,7 @@ int LoopConvertTransform::apply(const FileContentsByPath &InputStates,
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());
diff --git a/clang-tools-extra/cpp11-migrate/Transform.h b/clang-tools-extra/cpp11-migrate/Transform.h
index 3aae93fac69..3de989c2593 100644
--- a/clang-tools-extra/cpp11-migrate/Transform.h
+++ b/clang-tools-extra/cpp11-migrate/Transform.h
@@ -71,14 +71,24 @@ void collectResults(clang::Rewriter &Rewrite, FileContentsByPath &Results);
/// 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; }
diff --git a/clang-tools-extra/cpp11-migrate/UseNullptr/UseNullptr.cpp b/clang-tools-extra/cpp11-migrate/UseNullptr/UseNullptr.cpp
index aaf5bf1a3f0..d4ade1cf79a 100644
--- a/clang-tools-extra/cpp11-migrate/UseNullptr/UseNullptr.cpp
+++ b/clang-tools-extra/cpp11-migrate/UseNullptr/UseNullptr.cpp
@@ -53,7 +53,7 @@ int UseNullptrTransform::apply(const FileContentsByPath &InputStates,
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());
diff --git a/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp b/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp
index 48f3be8b1aa..cd3e174c2c9 100644
--- a/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp
@@ -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
OpenPOWER on IntegriCloud