summaryrefslogtreecommitdiffstats
path: root/unittests/Basic/SourceManagerTest.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerdim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit173a4f43a911175643bda81ee675e8d9269056ea (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /unittests/Basic/SourceManagerTest.cpp
parent88f7a7d5251a2d813460274c92decc143a11569b (diff)
downloadFreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip
FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'unittests/Basic/SourceManagerTest.cpp')
-rw-r--r--unittests/Basic/SourceManagerTest.cpp70
1 files changed, 39 insertions, 31 deletions
diff --git a/unittests/Basic/SourceManagerTest.cpp b/unittests/Basic/SourceManagerTest.cpp
index d94cfe9..9ea093c 100644
--- a/unittests/Basic/SourceManagerTest.cpp
+++ b/unittests/Basic/SourceManagerTest.cpp
@@ -20,7 +20,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -38,7 +38,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;
@@ -47,22 +47,27 @@ protected:
DiagnosticsEngine Diags;
SourceManager SourceMgr;
LangOptions LangOpts;
- IntrusiveRefCntPtr<TargetOptions> TargetOpts;
+ std::shared_ptr<TargetOptions> TargetOpts;
IntrusiveRefCntPtr<TargetInfo> Target;
};
class VoidModuleLoader : public ModuleLoader {
- virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
- ModuleIdPath Path,
- Module::NameVisibilityKind Visibility,
- bool IsInclusionDirective) {
+ ModuleLoadResult loadModule(SourceLocation ImportLoc,
+ ModuleIdPath Path,
+ Module::NameVisibilityKind Visibility,
+ bool IsInclusionDirective) override {
return ModuleLoadResult();
}
- virtual void makeModuleVisible(Module *Mod,
- Module::NameVisibilityKind Visibility,
- SourceLocation ImportLoc,
- bool Complain) { }
+ void makeModuleVisible(Module *Mod,
+ Module::NameVisibilityKind Visibility,
+ SourceLocation ImportLoc,
+ bool Complain) override { }
+
+ GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override
+ { return nullptr; }
+ bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override
+ { return 0; };
};
TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
@@ -70,16 +75,17 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
"#define M(x) [x]\n"
"M(foo)";
MemoryBuffer *buf = MemoryBuffer::getMemBuffer(source);
- FileID mainFileID = SourceMgr.createMainFileIDForMemBuffer(buf);
+ FileID mainFileID = SourceMgr.createFileID(buf);
+ SourceMgr.setMainFileID(mainFileID);
VoidModuleLoader ModLoader;
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
&*Target);
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/ 0,
- /*OwnsHeaderSearch =*/false,
- /*DelayInitialization =*/ false);
+ Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
+ HeaderInfo, ModLoader,
+ /*IILookup =*/nullptr,
+ /*OwnsHeaderSearch =*/false);
+ PP.Initialize(*Target);
PP.EnterMainSourceFile();
std::vector<Token> toks;
@@ -122,7 +128,8 @@ TEST_F(SourceManagerTest, getColumnNumber) {
"int y;";
MemoryBuffer *Buf = MemoryBuffer::getMemBuffer(Source);
- FileID MainFileID = SourceMgr.createMainFileIDForMemBuffer(Buf);
+ FileID MainFileID = SourceMgr.createFileID(Buf);
+ SourceMgr.setMainFileID(MainFileID);
bool Invalid;
@@ -161,7 +168,7 @@ TEST_F(SourceManagerTest, getColumnNumber) {
EXPECT_TRUE(Invalid);
// Test with no invalid flag.
- EXPECT_EQ(1U, SourceMgr.getColumnNumber(MainFileID, 0, NULL));
+ EXPECT_EQ(1U, SourceMgr.getColumnNumber(MainFileID, 0, nullptr));
}
#if defined(LLVM_ON_UNIX)
@@ -181,7 +188,8 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
MemoryBuffer *headerBuf = MemoryBuffer::getMemBuffer(header);
MemoryBuffer *mainBuf = MemoryBuffer::getMemBuffer(main);
- FileID mainFileID = SourceMgr.createMainFileIDForMemBuffer(mainBuf);
+ FileID mainFileID = SourceMgr.createFileID(mainBuf);
+ SourceMgr.setMainFileID(mainFileID);
const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h",
headerBuf->getBufferSize(), 0);
@@ -190,11 +198,11 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
VoidModuleLoader ModLoader;
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
&*Target);
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/ 0,
- /*OwnsHeaderSearch =*/false,
- /*DelayInitialization =*/ false);
+ Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
+ HeaderInfo, ModLoader,
+ /*IILookup =*/nullptr,
+ /*OwnsHeaderSearch =*/false);
+ PP.Initialize(*Target);
PP.EnterMainSourceFile();
std::vector<Token> toks;
@@ -279,7 +287,7 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) {
MemoryBuffer *headerBuf = MemoryBuffer::getMemBuffer(header);
MemoryBuffer *mainBuf = MemoryBuffer::getMemBuffer(main);
- SourceMgr.createMainFileIDForMemBuffer(mainBuf);
+ SourceMgr.setMainFileID(SourceMgr.createFileID(mainBuf));
const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h",
headerBuf->getBufferSize(), 0);
@@ -288,11 +296,11 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) {
VoidModuleLoader ModLoader;
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
&*Target);
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/ 0,
- /*OwnsHeaderSearch =*/false,
- /*DelayInitialization =*/ false);
+ Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
+ HeaderInfo, ModLoader,
+ /*IILookup =*/nullptr,
+ /*OwnsHeaderSearch =*/false);
+ PP.Initialize(*Target);
std::vector<MacroAction> Macros;
PP.addPPCallbacks(new MacroTracker(Macros));
OpenPOWER on IntegriCloud