summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-30 09:46:12 +0000
committerDaniel Jasper <djasper@google.com>2013-01-30 09:46:12 +0000
commit7b038a23819c391d0ba649db8755d3da5cda9ec2 (patch)
tree371db27d782a5e14d09dccccbf4226bc193a4a39 /clang/lib/Format/Format.cpp
parent5fbfafcd8c25f40508687d367182c73d633e6b89 (diff)
downloadbcm5719-llvm-7b038a23819c391d0ba649db8755d3da5cda9ec2.tar.gz
bcm5719-llvm-7b038a23819c391d0ba649db8755d3da5cda9ec2.zip
Don't generate no-op replacements.
No functional changes. llvm-svn: 173916
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9dfde34e8b5..08ea8e97de5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -194,6 +194,11 @@ private:
/// \brief Stores \p Text as the replacement for the whitespace in front of
/// \p Tok.
void storeReplacement(const FormatToken &Tok, const std::string Text) {
+ // Don't create a replacement, if it does not change anything.
+ if (StringRef(SourceMgr.getCharacterData(Tok.WhiteSpaceStart),
+ Tok.WhiteSpaceLength) == Text)
+ return;
+
Replaces.insert(tooling::Replacement(SourceMgr, Tok.WhiteSpaceStart,
Tok.WhiteSpaceLength, Text));
}
OpenPOWER on IntegriCloud