Author: ioeric Date: Mon Dec 19 04:41:05 2016 New Revision: 290093 URL: http://llvm.org/viewvc/llvm-project?rev=290093&view=rev Log: [clang-format] revert an unintended change in r288493 and add a test case.
Modified: cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=290093&r1=290092&r2=290093&view=diff ============================================================================== --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Mon Dec 19 04:41:05 2016 @@ -1545,7 +1545,7 @@ bool checkAndConsumeDirectiveWithName(Le 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; Modified: cfe/trunk/unittests/Format/CleanupTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=290093&r1=290092&r2=290093&view=diff ============================================================================== --- cfe/trunk/unittests/Format/CleanupTest.cpp (original) +++ cfe/trunk/unittests/Format/CleanupTest.cpp Mon Dec 19 04:41:05 2016 @@ -714,6 +714,19 @@ TEST_F(CleanUpReplacementsTest, IfNDefWi 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 <vector>\n" + "#ifndef X\n" + "#define 1\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include <vector>")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + TEST_F(CleanUpReplacementsTest, HeaderGuardWithComment) { std::string Code = "// comment \n" "#ifndef X // comment\n" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits