diff options
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 5 |
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)); } |