Author: juliehockett Date: Wed May 9 15:25:47 2018 New Revision: 331932 URL: http://llvm.org/viewvc/llvm-project?rev=331932&view=rev Log: Revert "[clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective"
This reverts commit r331904 because of a memory leak. Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h cfe/trunk/include/clang/Lex/PreprocessingRecord.h cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp cfe/trunk/lib/CodeGen/MacroPPCallbacks.h cfe/trunk/lib/Frontend/DependencyFile.cpp cfe/trunk/lib/Frontend/DependencyGraph.cpp cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PreprocessingRecord.cpp cfe/trunk/tools/libclang/Indexing.cpp cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original) +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed May 9 15:25:47 2018 @@ -117,10 +117,6 @@ public: /// \param Imported The module, whenever an inclusion directive was /// automatically turned into a module import or null otherwise. /// - /// \param FileType The characteristic kind, indicates whether a file or - /// directory holds normal user code, system code, or system code which is - /// implicitly 'extern "C"' in C++ mode. - /// virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, @@ -129,8 +125,7 @@ public: const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) { + const Module *Imported) { } /// Callback invoked whenever there was an explicit module-import @@ -372,14 +367,13 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override { + const Module *Imported) override { First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, FilenameRange, File, SearchPath, RelativePath, - Imported, FileType); + Imported); Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, FilenameRange, File, SearchPath, RelativePath, - Imported, FileType); + Imported); } void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original) +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed May 9 15:25:47 2018 @@ -532,8 +532,8 @@ class Token; StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, - StringRef RelativePath, const Module *Imported, - SrcMgr::CharacteristicKind FileType) override; + StringRef RelativePath, + const Module *Imported) override; void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override; void Ifndef(SourceLocation Loc, const Token &MacroNameTok, Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original) +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Wed May 9 15:25:47 2018 @@ -178,8 +178,7 @@ void MacroPPCallbacks::FileChanged(Sourc void MacroPPCallbacks::InclusionDirective( SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, - StringRef SearchPath, StringRef RelativePath, const Module *Imported, - SrcMgr::CharacteristicKind FileType) { + StringRef SearchPath, StringRef RelativePath, const Module *Imported) { // Record the line location of the current included file. LastHashLoc = HashLoc; Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original) +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Wed May 9 15:25:47 2018 @@ -101,8 +101,7 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override; + const Module *Imported) override; /// Hook called whenever a macro definition is seen. void MacroDefined(const Token &MacroNameTok, Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/DependencyFile.cpp (original) +++ cfe/trunk/lib/Frontend/DependencyFile.cpp Wed May 9 15:25:47 2018 @@ -63,8 +63,7 @@ struct DepCollectorPPCallbacks : public StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override { + const Module *Imported) override { if (!File) DepCollector.maybeAddDependency(FileName, /*FromModule*/false, /*IsSystem*/false, /*IsModuleFile*/false, @@ -194,8 +193,7 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override; + const Module *Imported) override; void EndOfMainFile() override { OutputDependencyFile(); @@ -315,8 +313,7 @@ void DFGImpl::InclusionDirective(SourceL const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) { + const Module *Imported) { if (!File) { if (AddMissingHeaderDeps) AddFilename(FileName); Modified: cfe/trunk/lib/Frontend/DependencyGraph.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyGraph.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/DependencyGraph.cpp (original) +++ cfe/trunk/lib/Frontend/DependencyGraph.cpp Wed May 9 15:25:47 2018 @@ -50,8 +50,7 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override; + const Module *Imported) override; void EndOfMainFile() override { OutputGraphFile(); @@ -66,17 +65,15 @@ void clang::AttachDependencyGraphGen(Pre SysRoot)); } -void DependencyGraphCallback::InclusionDirective( - SourceLocation HashLoc, - const Token &IncludeTok, - StringRef FileName, - bool IsAngled, - CharSourceRange FilenameRange, - const FileEntry *File, - StringRef SearchPath, - StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) { +void DependencyGraphCallback::InclusionDirective(SourceLocation HashLoc, + const Token &IncludeTok, + StringRef FileName, + bool IsAngled, + CharSourceRange FilenameRange, + const FileEntry *File, + StringRef SearchPath, + StringRef RelativePath, + const Module *Imported) { if (!File) return; Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original) +++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Wed May 9 15:25:47 2018 @@ -50,8 +50,7 @@ struct ModuleDependencyPPCallbacks : pub StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override { + const Module *Imported) override { if (!File) return; Collector.addFile(File->getName()); Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original) +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed May 9 15:25:47 2018 @@ -130,8 +130,7 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override; + const Module *Imported) override; void Ident(SourceLocation Loc, StringRef str) override; void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str) override; @@ -321,17 +320,15 @@ void PrintPPOutputPPCallbacks::FileChang } } -void PrintPPOutputPPCallbacks::InclusionDirective( - SourceLocation HashLoc, - const Token &IncludeTok, - StringRef FileName, - bool IsAngled, - CharSourceRange FilenameRange, - const FileEntry *File, - StringRef SearchPath, - StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) { +void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc, + const Token &IncludeTok, + StringRef FileName, + bool IsAngled, + CharSourceRange FilenameRange, + const FileEntry *File, + StringRef SearchPath, + StringRef RelativePath, + const Module *Imported) { // In -dI mode, dump #include directives prior to dumping their content or // interpretation. if (DumpIncludeDirectives) { Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp (original) +++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Wed May 9 15:25:47 2018 @@ -77,8 +77,7 @@ private: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override; + const Module *Imported) override; void WriteLineInfo(StringRef Filename, int Line, SrcMgr::CharacteristicKind FileType, StringRef Extra = StringRef()); @@ -193,8 +192,7 @@ void InclusionRewriter::InclusionDirecti const FileEntry * /*File*/, StringRef /*SearchPath*/, StringRef /*RelativePath*/, - const Module *Imported, - SrcMgr::CharacteristicKind FileType){ + const Module *Imported) { if (Imported) { auto P = ModuleIncludes.insert( std::make_pair(HashLoc.getRawEncoding(), Imported)); Modified: cfe/trunk/lib/Lex/PPDirectives.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Lex/PPDirectives.cpp (original) +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed May 9 15:25:47 2018 @@ -1968,7 +1968,7 @@ void Preprocessor::HandleIncludeDirectiv HashLoc, IncludeTok, LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename, isAngled, FilenameRange, File, SearchPath, RelativePath, - ShouldEnter ? nullptr : SuggestedModule.getModule(), FileCharacter); + ShouldEnter ? nullptr : SuggestedModule.getModule()); if (SkipHeader && !SuggestedModule.getModule()) Callbacks->FileSkipped(*File, FilenameTok, FileCharacter); } Modified: cfe/trunk/lib/Lex/PreprocessingRecord.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PreprocessingRecord.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/lib/Lex/PreprocessingRecord.cpp (original) +++ cfe/trunk/lib/Lex/PreprocessingRecord.cpp Wed May 9 15:25:47 2018 @@ -471,8 +471,7 @@ void PreprocessingRecord::InclusionDirec const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) { + const Module *Imported) { InclusionDirective::InclusionKind Kind = InclusionDirective::Include; switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) { Modified: cfe/trunk/tools/libclang/Indexing.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/tools/libclang/Indexing.cpp (original) +++ cfe/trunk/tools/libclang/Indexing.cpp Wed May 9 15:25:47 2018 @@ -249,8 +249,7 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported, - SrcMgr::CharacteristicKind FileType) override { + const Module *Imported) override { bool isImport = (IncludeTok.is(tok::identifier) && IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import); DataConsumer.ppIncludedFile(HashLoc, FileName, File, isImport, IsAngled, Modified: cfe/trunk/unittests/Lex/PPCallbacksTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=331932&r1=331931&r2=331932&view=diff ============================================================================== --- cfe/trunk/unittests/Lex/PPCallbacksTest.cpp (original) +++ cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Wed May 9 15:25:47 2018 @@ -39,18 +39,16 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - 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; + 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; } SourceLocation HashLoc; @@ -62,7 +60,6 @@ public: SmallString<16> SearchPath; SmallString<16> RelativePath; const Module* Imported; - SrcMgr::CharacteristicKind FileType; }; // Stub to collect data from PragmaOpenCLExtension callbacks. @@ -141,13 +138,6 @@ 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))); @@ -178,7 +168,7 @@ protected: } // Callbacks have been executed at this point -- return filename range. - return Callbacks; + return Callbacks->FilenameRange; } PragmaOpenCLExtensionCallbacks::CallbackParameters @@ -232,15 +222,6 @@ 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"; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits