|
@@ -39,16 +39,18 @@ public:
|
|
StringRef FileName, bool IsAngled,
|
|
StringRef FileName, bool IsAngled,
|
|
CharSourceRange FilenameRange, const FileEntry *File,
|
|
CharSourceRange FilenameRange, const FileEntry *File,
|
|
StringRef SearchPath, StringRef RelativePath,
|
|
StringRef SearchPath, StringRef RelativePath,
|
|
- const Module *Imported) override {
|
|
|
|
- this->HashLoc = HashLoc;
|
|
|
|
- this->IncludeTok = IncludeTok;
|
|
|
|
- this->FileName = FileName.str();
|
|
|
|
- this->IsAngled = IsAngled;
|
|
|
|
- this->FilenameRange = FilenameRange;
|
|
|
|
- this->File = File;
|
|
|
|
- this->SearchPath = SearchPath.str();
|
|
|
|
- this->RelativePath = RelativePath.str();
|
|
|
|
- this->Imported = Imported;
|
|
|
|
|
|
+ const Module *Imported,
|
|
|
|
+ SrcMgr::CharacteristicKind FileType) override {
|
|
|
|
+ this->HashLoc = HashLoc;
|
|
|
|
+ this->IncludeTok = IncludeTok;
|
|
|
|
+ this->FileName = FileName.str();
|
|
|
|
+ this->IsAngled = IsAngled;
|
|
|
|
+ this->FilenameRange = FilenameRange;
|
|
|
|
+ this->File = File;
|
|
|
|
+ this->SearchPath = SearchPath.str();
|
|
|
|
+ this->RelativePath = RelativePath.str();
|
|
|
|
+ this->Imported = Imported;
|
|
|
|
+ this->FileType = FileType;
|
|
}
|
|
}
|
|
|
|
|
|
SourceLocation HashLoc;
|
|
SourceLocation HashLoc;
|
|
@@ -60,6 +62,7 @@ public:
|
|
SmallString<16> SearchPath;
|
|
SmallString<16> SearchPath;
|
|
SmallString<16> RelativePath;
|
|
SmallString<16> RelativePath;
|
|
const Module* Imported;
|
|
const Module* Imported;
|
|
|
|
+ SrcMgr::CharacteristicKind FileType;
|
|
};
|
|
};
|
|
|
|
|
|
// Stub to collect data from PragmaOpenCLExtension callbacks.
|
|
// Stub to collect data from PragmaOpenCLExtension callbacks.
|
|
@@ -138,6 +141,13 @@ protected:
|
|
// the InclusionDirective callback.
|
|
// the InclusionDirective callback.
|
|
CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText,
|
|
CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText,
|
|
const char* HeaderPath, bool SystemHeader) {
|
|
const char* HeaderPath, bool SystemHeader) {
|
|
|
|
+ return InclusionDirectiveCallback(SourceText, HeaderPath, SystemHeader)
|
|
|
|
+ ->FilenameRange;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ InclusionDirectiveCallbacks *
|
|
|
|
+ InclusionDirectiveCallback(const char *SourceText, const char *HeaderPath,
|
|
|
|
+ bool SystemHeader) {
|
|
std::unique_ptr<llvm::MemoryBuffer> Buf =
|
|
std::unique_ptr<llvm::MemoryBuffer> Buf =
|
|
llvm::MemoryBuffer::getMemBuffer(SourceText);
|
|
llvm::MemoryBuffer::getMemBuffer(SourceText);
|
|
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
|
|
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
|
|
@@ -168,7 +178,7 @@ protected:
|
|
}
|
|
}
|
|
|
|
|
|
// Callbacks have been executed at this point -- return filename range.
|
|
// Callbacks have been executed at this point -- return filename range.
|
|
- return Callbacks->FilenameRange;
|
|
|
|
|
|
+ return Callbacks;
|
|
}
|
|
}
|
|
|
|
|
|
PragmaOpenCLExtensionCallbacks::CallbackParameters
|
|
PragmaOpenCLExtensionCallbacks::CallbackParameters
|
|
@@ -222,6 +232,15 @@ protected:
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+TEST_F(PPCallbacksTest, UserFileCharacteristics) {
|
|
|
|
+ const char *Source = "#include \"quoted.h\"\n";
|
|
|
|
+
|
|
|
|
+ SrcMgr::CharacteristicKind Kind =
|
|
|
|
+ InclusionDirectiveCallback(Source, "/quoted.h", false)->FileType;
|
|
|
|
+
|
|
|
|
+ ASSERT_EQ(SrcMgr::CharacteristicKind::C_User, Kind);
|
|
|
|
+}
|
|
|
|
+
|
|
TEST_F(PPCallbacksTest, QuotedFilename) {
|
|
TEST_F(PPCallbacksTest, QuotedFilename) {
|
|
const char* Source =
|
|
const char* Source =
|
|
"#include \"quoted.h\"\n";
|
|
"#include \"quoted.h\"\n";
|