From: Eric Liu Date: Mon, 19 Dec 2016 10:41:05 +0000 (+0000) Subject: [clang-format] revert an unintended change in r288493 and add a test case. X-Git-Tag: llvmorg-4.0.0-rc1~1715 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93459d3142e78bec125075c6b455b734fb7dfc5a;p=platform%2Fupstream%2Fllvm.git [clang-format] revert an unintended change in r288493 and add a test case. llvm-svn: 290093 --- diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index bd19b48..ffe41c2 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1545,7 +1545,7 @@ bool checkAndConsumeDirectiveWithName(Lexer &Lex, StringRef Name, Token &Tok) { bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) && Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) && - tok::raw_identifier; + Tok.is(tok::raw_identifier); if (Matched) Lex.LexFromRawLexer(Tok); return Matched; diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp index dbf3f07..6ac5f69 100644 --- a/clang/unittests/Format/CleanupTest.cpp +++ b/clang/unittests/Format/CleanupTest.cpp @@ -714,6 +714,19 @@ TEST_F(CleanUpReplacementsTest, IfNDefWithNoDefine) { EXPECT_EQ(Expected, apply(Code, Replaces)); } +TEST_F(CleanUpReplacementsTest, FakeHeaderGuard) { + std::string Code = "// comment \n" + "#ifndef X\n" + "#define 1\n"; + std::string Expected = "// comment \n" + "#include \n" + "#ifndef X\n" + "#define 1\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include ")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + TEST_F(CleanUpReplacementsTest, HeaderGuardWithComment) { std::string Code = "// comment \n" "#ifndef X // comment\n"