diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2019-01-15 17:20:05 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2019-01-15 17:20:05 +0000 |
commit | 7c400363af5d53be336f3ff078036dfc3387d512 (patch) | |
tree | 345b58bc546235d82632e72f4dfb912a71ab5b51 /unittests/Lex | |
parent | 1fe2cedf079a9f98ed2f20cccfef071c8daff41c (diff) | |
download | clang-7c400363af5d53be336f3ff078036dfc3387d512.tar.gz |
Revert "Correct the source range returned from preprocessor callbacks."
This reverts commit r350891. Also add a test case that would return an
empty string with r350891.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351209 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Lex')
-rw-r--r-- | unittests/Lex/PPCallbacksTest.cpp | 58 |
1 files changed, 8 insertions, 50 deletions
diff --git a/unittests/Lex/PPCallbacksTest.cpp b/unittests/Lex/PPCallbacksTest.cpp index 940328842d..838e033e3d 100644 --- a/unittests/Lex/PPCallbacksTest.cpp +++ b/unittests/Lex/PPCallbacksTest.cpp @@ -431,58 +431,16 @@ TEST_F(PPCallbacksTest, OpenCLExtensionPragmaDisabled) { } TEST_F(PPCallbacksTest, DirectiveExprRanges) { - const auto &Results1 = DirectiveExprRange("#if FLUZZY_FLOOF\n#endif\n"); - EXPECT_EQ(Results1.size(), 1U); + const auto &Results8 = + DirectiveExprRange("#define FLOOFY 0\n#if __FILE__ > FLOOFY\n#endif\n"); + EXPECT_EQ(Results8.size(), 1U); EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results1[0].ConditionRange, false)), - "FLUZZY_FLOOF"); - - const auto &Results2 = DirectiveExprRange("#if 1 + 4 < 7\n#endif\n"); - EXPECT_EQ(Results2.size(), 1U); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results2[0].ConditionRange, false)), - "1 + 4 < 7"); - - const auto &Results3 = DirectiveExprRange("#if 1 + \\\n 2\n#endif\n"); - EXPECT_EQ(Results3.size(), 1U); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results3[0].ConditionRange, false)), - "1 + \\\n 2"); - - const auto &Results4 = DirectiveExprRange("#if 0\n#elif FLOOFY\n#endif\n"); - EXPECT_EQ(Results4.size(), 2U); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results4[0].ConditionRange, false)), - "0"); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results4[1].ConditionRange, false)), - "FLOOFY"); - - const auto &Results5 = DirectiveExprRange("#if 1\n#elif FLOOFY\n#endif\n"); - EXPECT_EQ(Results5.size(), 2U); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results5[0].ConditionRange, false)), - "1"); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results5[1].ConditionRange, false)), - "FLOOFY"); - - const auto &Results6 = - DirectiveExprRange("#if defined(FLUZZY_FLOOF)\n#endif\n"); - EXPECT_EQ(Results6.size(), 1U); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results6[0].ConditionRange, false)), - "defined(FLUZZY_FLOOF)"); - - const auto &Results7 = - DirectiveExprRange("#if 1\n#elif defined(FLOOFY)\n#endif\n"); - EXPECT_EQ(Results7.size(), 2U); - EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results7[0].ConditionRange, false)), - "1"); + GetSourceStringToEnd(CharSourceRange(Results8[0].ConditionRange, false)), + " __FILE__ > FLOOFY\n#"); EXPECT_EQ( - GetSourceStringToEnd(CharSourceRange(Results7[1].ConditionRange, false)), - "defined(FLOOFY)"); + Lexer::getSourceText(CharSourceRange(Results8[0].ConditionRange, false), + SourceMgr, LangOpts), + " __FILE__ > FLOOFY\n"); } } // namespace |