diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-04 07:27:05 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-04 07:27:05 +0000 |
commit | 37ed12720a35b7bfa1c4de73ad6f1c6c1c88ee17 (patch) | |
tree | bba1cb7716cd13f295e22172dd4ca239d62fae54 /unittests/Lex | |
parent | df1059cac42d613547d86b4e44c5e364bfc03073 (diff) |
Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord.
Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord
without needing a PreprocessingRecord.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Lex')
-rw-r--r-- | unittests/Lex/PPConditionalDirectiveRecordTest.cpp (renamed from unittests/Lex/PreprocessingRecordTest.cpp) | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/unittests/Lex/PreprocessingRecordTest.cpp b/unittests/Lex/PPConditionalDirectiveRecordTest.cpp index 2bf00483c0..21271f9b2f 100644 --- a/unittests/Lex/PreprocessingRecordTest.cpp +++ b/unittests/Lex/PPConditionalDirectiveRecordTest.cpp @@ -1,4 +1,4 @@ -//===- unittests/Lex/PreprocessingRecordTest.cpp - PreprocessingRecord tests =// +//===- unittests/Lex/PPConditionalDirectiveRecordTest.cpp-PP directive tests =// // // The LLVM Compiler Infrastructure // @@ -19,7 +19,7 @@ #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" -#include "clang/Lex/PreprocessingRecord.h" +#include "clang/Lex/PPConditionalDirectiveRecord.h" #include "llvm/Config/config.h" #include "gtest/gtest.h" @@ -30,9 +30,9 @@ using namespace clang; namespace { // The test fixture. -class PreprocessingRecordTest : public ::testing::Test { +class PPConditionalDirectiveRecordTest : public ::testing::Test { protected: - PreprocessingRecordTest() + PPConditionalDirectiveRecordTest() : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()), Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()), @@ -62,7 +62,7 @@ class VoidModuleLoader : public ModuleLoader { } }; -TEST_F(PreprocessingRecordTest, PPRecAPI) { +TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) { const char *source = "0 1\n" "#if 1\n" @@ -93,7 +93,9 @@ TEST_F(PreprocessingRecordTest, PPRecAPI) { /*IILookup =*/ 0, /*OwnsHeaderSearch =*/false, /*DelayInitialization =*/ false); - PP.createPreprocessingRecord(true); + PPConditionalDirectiveRecord * + PPRec = new PPConditionalDirectiveRecord(SourceMgr); + PP.addPPCallbacks(PPRec); PP.EnterMainSourceFile(); std::vector<Token> toks; @@ -108,37 +110,36 @@ TEST_F(PreprocessingRecordTest, PPRecAPI) { // Make sure we got the tokens that we expected. ASSERT_EQ(10U, toks.size()); - PreprocessingRecord &PPRec = *PP.getPreprocessingRecord(); - EXPECT_FALSE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_FALSE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[0].getLocation(), toks[1].getLocation()))); - EXPECT_TRUE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_TRUE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[0].getLocation(), toks[2].getLocation()))); - EXPECT_FALSE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_FALSE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[3].getLocation(), toks[4].getLocation()))); - EXPECT_TRUE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_TRUE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[1].getLocation(), toks[5].getLocation()))); - EXPECT_TRUE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_TRUE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[2].getLocation(), toks[6].getLocation()))); - EXPECT_FALSE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_FALSE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[2].getLocation(), toks[5].getLocation()))); - EXPECT_FALSE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_FALSE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[0].getLocation(), toks[6].getLocation()))); - EXPECT_TRUE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_TRUE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[2].getLocation(), toks[8].getLocation()))); - EXPECT_FALSE(PPRec.rangeIntersectsConditionalDirective( + EXPECT_FALSE(PPRec->rangeIntersectsConditionalDirective( SourceRange(toks[0].getLocation(), toks[9].getLocation()))); - EXPECT_TRUE(PPRec.areInDifferentConditionalDirectiveRegion( + EXPECT_TRUE(PPRec->areInDifferentConditionalDirectiveRegion( toks[0].getLocation(), toks[2].getLocation())); - EXPECT_FALSE(PPRec.areInDifferentConditionalDirectiveRegion( + EXPECT_FALSE(PPRec->areInDifferentConditionalDirectiveRegion( toks[3].getLocation(), toks[4].getLocation())); - EXPECT_TRUE(PPRec.areInDifferentConditionalDirectiveRegion( + EXPECT_TRUE(PPRec->areInDifferentConditionalDirectiveRegion( toks[1].getLocation(), toks[5].getLocation())); - EXPECT_TRUE(PPRec.areInDifferentConditionalDirectiveRegion( + EXPECT_TRUE(PPRec->areInDifferentConditionalDirectiveRegion( toks[2].getLocation(), toks[0].getLocation())); - EXPECT_FALSE(PPRec.areInDifferentConditionalDirectiveRegion( + EXPECT_FALSE(PPRec->areInDifferentConditionalDirectiveRegion( toks[4].getLocation(), toks[3].getLocation())); - EXPECT_TRUE(PPRec.areInDifferentConditionalDirectiveRegion( + EXPECT_TRUE(PPRec->areInDifferentConditionalDirectiveRegion( toks[5].getLocation(), toks[1].getLocation())); } |