summaryrefslogtreecommitdiffstats
path: root/unittests/Lex
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
committerdim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
commitc72c57c9e9b69944e3e009cd5e209634839581d3 (patch)
tree4fc2f184c499d106f29a386c452b49e5197bf63d /unittests/Lex
parent5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff)
downloadFreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip
FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'unittests/Lex')
-rw-r--r--unittests/Lex/CMakeLists.txt2
-rw-r--r--unittests/Lex/LexerTest.cpp28
-rw-r--r--unittests/Lex/PPCallbacksTest.cpp22
-rw-r--r--unittests/Lex/PPConditionalDirectiveRecordTest.cpp (renamed from unittests/Lex/PreprocessingRecordTest.cpp)70
4 files changed, 69 insertions, 53 deletions
diff --git a/unittests/Lex/CMakeLists.txt b/unittests/Lex/CMakeLists.txt
index 03c8cd5..78838c0 100644
--- a/unittests/Lex/CMakeLists.txt
+++ b/unittests/Lex/CMakeLists.txt
@@ -1,7 +1,7 @@
add_clang_unittest(LexTests
LexerTest.cpp
- PreprocessingRecordTest.cpp
PPCallbacksTest.cpp
+ PPConditionalDirectiveRecordTest.cpp
)
target_link_libraries(LexTests
diff --git a/unittests/Lex/LexerTest.cpp b/unittests/Lex/LexerTest.cpp
index e95cd02..c9b1840 100644
--- a/unittests/Lex/LexerTest.cpp
+++ b/unittests/Lex/LexerTest.cpp
@@ -1,4 +1,4 @@
-//===- unittests/Basic/LexerTest.cpp ------ Lexer tests -------------------===//
+//===- unittests/Lex/LexerTest.cpp ------ Lexer tests ---------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,20 +7,20 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/FileManager.h"
+#include "clang/Lex/Lexer.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetOptions.h"
+#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
-#include "clang/Lex/ModuleLoader.h"
+#include "clang/Basic/TargetOptions.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/Config/config.h"
-
#include "gtest/gtest.h"
using namespace llvm;
@@ -39,7 +39,7 @@ protected:
TargetOpts(new TargetOptions)
{
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
- Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
+ Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts);
}
FileSystemOptions FileMgrOpts;
@@ -53,11 +53,17 @@ protected:
};
class VoidModuleLoader : public ModuleLoader {
- virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
- Module::NameVisibilityKind Visibility,
- bool IsInclusionDirective) {
- return 0;
+ virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
+ ModuleIdPath Path,
+ Module::NameVisibilityKind Visibility,
+ bool IsInclusionDirective) {
+ return ModuleLoadResult();
}
+
+ virtual void makeModuleVisible(Module *Mod,
+ Module::NameVisibilityKind Visibility,
+ SourceLocation ImportLoc,
+ bool Complain) { }
};
TEST_F(LexerTest, LexAPI) {
diff --git a/unittests/Lex/PPCallbacksTest.cpp b/unittests/Lex/PPCallbacksTest.cpp
index 6e7efa9..36bd5f9 100644
--- a/unittests/Lex/PPCallbacksTest.cpp
+++ b/unittests/Lex/PPCallbacksTest.cpp
@@ -7,6 +7,7 @@
//
//===--------------------------------------------------------------===//
+#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LangOptions.h"
@@ -16,12 +17,9 @@
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/ModuleLoader.h"
-#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
-
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/PathV2.h"
-
#include "gtest/gtest.h"
using namespace llvm;
@@ -32,11 +30,17 @@ namespace {
// Stub out module loading.
class VoidModuleLoader : public ModuleLoader {
- virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
- Module::NameVisibilityKind Visibility,
- bool IsInclusionDirective) {
- return 0;
+ virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
+ ModuleIdPath Path,
+ Module::NameVisibilityKind Visibility,
+ bool IsInclusionDirective) {
+ return ModuleLoadResult();
}
+
+ virtual void makeModuleVisible(Module *Mod,
+ Module::NameVisibilityKind Visibility,
+ SourceLocation ImportLoc,
+ bool Complain) { }
};
// Stub to collect data from InclusionDirective callbacks.
@@ -84,7 +88,7 @@ protected:
SourceMgr(Diags, FileMgr) {
TargetOpts = new TargetOptions();
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
- Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
+ Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts);
}
FileSystemOptions FileMgrOpts;
@@ -107,7 +111,7 @@ protected:
// Add header's parent path to search path.
StringRef SearchPath = path::parent_path(HeaderPath);
const DirectoryEntry *DE = FileMgr.getDirectory(SearchPath);
- DirectoryLookup DL(DE, SrcMgr::C_User, true, false);
+ DirectoryLookup DL(DE, SrcMgr::C_User, false);
HeaderInfo.AddSearchPath(DL, IsSystemHeader);
}
diff --git a/unittests/Lex/PreprocessingRecordTest.cpp b/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
index 815081a..082eced 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
//
@@ -7,21 +7,20 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/FileManager.h"
+#include "clang/Lex/PPConditionalDirectiveRecord.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetOptions.h"
+#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
-#include "clang/Lex/ModuleLoader.h"
+#include "clang/Basic/TargetOptions.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
-#include "clang/Lex/PreprocessingRecord.h"
#include "llvm/Config/config.h"
-
#include "gtest/gtest.h"
using namespace llvm;
@@ -30,9 +29,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()),
@@ -40,7 +39,7 @@ protected:
TargetOpts(new TargetOptions)
{
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
- Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
+ Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts);
}
FileSystemOptions FileMgrOpts;
@@ -54,14 +53,20 @@ protected:
};
class VoidModuleLoader : public ModuleLoader {
- virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
- Module::NameVisibilityKind Visibility,
- bool IsInclusionDirective) {
- return 0;
+ virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
+ ModuleIdPath Path,
+ Module::NameVisibilityKind Visibility,
+ bool IsInclusionDirective) {
+ return ModuleLoadResult();
}
+
+ virtual void makeModuleVisible(Module *Mod,
+ Module::NameVisibilityKind Visibility,
+ SourceLocation ImportLoc,
+ bool Complain) { }
};
-TEST_F(PreprocessingRecordTest, PPRecAPI) {
+TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {
const char *source =
"0 1\n"
"#if 1\n"
@@ -92,7 +97,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;
@@ -107,37 +114,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()));
}
OpenPOWER on IntegriCloud