diff options
author | Julie Hockett <juliehockett@google.com> | 2018-05-09 18:27:33 +0000 |
---|---|---|
committer | Julie Hockett <juliehockett@google.com> | 2018-05-09 18:27:33 +0000 |
commit | 36d94ab8f0123022c460980e31d4ad331ca7eb78 (patch) | |
tree | 401dbcdd497fe057f6c6b7b2278ba22e993a4c30 /clang/unittests/Lex | |
parent | 518b6c9882101bb8914c171b24998093afbc7ecb (diff) | |
download | bcm5719-llvm-36d94ab8f0123022c460980e31d4ad331ca7eb78.tar.gz bcm5719-llvm-36d94ab8f0123022c460980e31d4ad331ca7eb78.zip |
[clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
Adding a SrcMgr::CharacteristicKind parameter to the InclusionDirective
in PPCallbacks, and updating calls to that function. This will be useful
in https://reviews.llvm.org/D43778 to determine which includes are system
headers.
Differential Revision: https://reviews.llvm.org/D46614
llvm-svn: 331904
Diffstat (limited to 'clang/unittests/Lex')
-rw-r--r-- | clang/unittests/Lex/PPCallbacksTest.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index 67b56a601c7..4f528712aef 100644 --- a/clang/unittests/Lex/PPCallbacksTest.cpp +++ b/clang/unittests/Lex/PPCallbacksTest.cpp @@ -39,16 +39,18 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, 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; @@ -60,6 +62,7 @@ public: SmallString<16> SearchPath; SmallString<16> RelativePath; const Module* Imported; + SrcMgr::CharacteristicKind FileType; }; // Stub to collect data from PragmaOpenCLExtension callbacks. @@ -138,6 +141,13 @@ protected: // the InclusionDirective callback. CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText, 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 = llvm::MemoryBuffer::getMemBuffer(SourceText); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); @@ -168,7 +178,7 @@ protected: } // Callbacks have been executed at this point -- return filename range. - return Callbacks->FilenameRange; + return Callbacks; } 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) { const char* Source = "#include \"quoted.h\"\n"; |