[clang-tools-extra] r331905 - [tools] Updating PPCallbacks::InclusionDirective calls

Julie Hockett via cfe-commits cfe-commits at lists.llvm.org
Wed May 9 15:30:05 PDT 2018


Reverted, found the memory leak and will put up a patch to fix it & reland
in a bit. Thanks!

On Wed, May 9, 2018 at 3:13 PM Evgenii Stepanov <eugeni.stepanov at gmail.com>
wrote:

> HI,
>
> ASan says there is a use-after-free after this change:
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/5410/steps/check-clang%20asan/logs/stdio
>
> MSan also sees a problem, but ASan's is likely closer to the root cause:
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/4529/steps/check-clang%20msan/logs/stdio
>
> On Wed, May 9, 2018 at 11:27 AM, Julie Hockett via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: juliehockett
>> Date: Wed May  9 11:27:37 2018
>> New Revision: 331905
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=331905&view=rev
>> Log:
>> [tools] Updating PPCallbacks::InclusionDirective calls
>>
>> [revision] added SrcMgr::CharacteristicKind to the InclusionDirective
>> callback, this revision updates instances of it in clang-tools-extra.
>>
>> Differential Revision: https://reviews.llvm.org/D46615
>>
>> Modified:
>>     clang-tools-extra/trunk/clang-move/ClangMove.cpp
>>     clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
>>
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>>     clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
>>     clang-tools-extra/trunk/clangd/ClangdUnit.cpp
>>     clang-tools-extra/trunk/clangd/Headers.cpp
>>     clang-tools-extra/trunk/modularize/CoverageChecker.cpp
>>     clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
>>     clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
>>     clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
>>
>> Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
>> +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed May  9 11:27:37
>> 2018
>> @@ -131,7 +131,8 @@ public:
>>                            clang::CharSourceRange FilenameRange,
>>                            const clang::FileEntry * /*File*/,
>>                            StringRef SearchPath, StringRef
>> /*RelativePath*/,
>> -                          const clang::Module * /*Imported*/) override {
>> +                          const clang::Module * /*Imported*/,
>> +                          SrcMgr::CharacteristicKind /*FileType*/)
>> override {
>>      if (const auto *FileEntry =
>> SM.getFileEntryForID(SM.getFileID(HashLoc)))
>>        MoveTool->addIncludes(FileName, IsAngled, SearchPath,
>>                              FileEntry->getName(), FilenameRange, SM);
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp Wed
>> May  9 11:27:37 2018
>> @@ -28,7 +28,8 @@ public:
>>                            StringRef FileName, bool IsAngled,
>>                            CharSourceRange FilenameRange, const FileEntry
>> *File,
>>                            StringRef SearchPath, StringRef RelativePath,
>> -                          const Module *Imported) override;
>> +                          const Module *Imported,
>> +                          SrcMgr::CharacteristicKind FileType) override;
>>    void EndOfMainFile() override;
>>
>>  private:
>> @@ -76,7 +77,8 @@ static int getPriority(StringRef Filenam
>>  void IncludeOrderPPCallbacks::InclusionDirective(
>>      SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
>>      bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
>> -    StringRef SearchPath, StringRef RelativePath, const Module
>> *Imported) {
>> +    StringRef SearchPath, StringRef RelativePath, const Module *Imported,
>> +    SrcMgr::CharacteristicKind FileType) {
>>    // We recognize the first include as a special main module header and
>> want
>>    // to leave it in the top position.
>>    IncludeDirective ID = {HashLoc, FilenameRange, FileName, IsAngled,
>> false};
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> ---
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed
>> May  9 11:27:37 2018
>> @@ -30,7 +30,8 @@ public:
>>                            StringRef FileName, bool IsAngled,
>>                            CharSourceRange FilenameRange, const FileEntry
>> *File,
>>                            StringRef SearchPath, StringRef RelativePath,
>> -                          const Module *Imported) override;
>> +                          const Module *Imported,
>> +                          SrcMgr::CharacteristicKind FileType) override;
>>
>>  private:
>>    ClangTidyCheck &Check;
>> @@ -94,7 +95,8 @@ IncludeModernizePPCallbacks::IncludeMode
>>  void IncludeModernizePPCallbacks::InclusionDirective(
>>      SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
>>      bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
>> -    StringRef SearchPath, StringRef RelativePath, const Module
>> *Imported) {
>> +    StringRef SearchPath, StringRef RelativePath, const Module *Imported,
>> +    SrcMgr::CharacteristicKind FileType) {
>>    // FIXME: Take care of library symbols from the global namespace.
>>    //
>>    // Reasonable options for the check:
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp Wed May
>> 9 11:27:37 2018
>> @@ -25,7 +25,8 @@ public:
>>                            bool IsAngled, CharSourceRange FileNameRange,
>>                            const FileEntry * /*IncludedFile*/,
>>                            StringRef /*SearchPath*/, StringRef
>> /*RelativePath*/,
>> -                          const Module * /*ImportedModule*/) override {
>> +                          const Module * /*ImportedModule*/,
>> +                          SrcMgr::CharacteristicKind /*FileType*/)
>> override {
>>      Inserter->AddInclude(FileNameRef, IsAngled, HashLocation,
>>                           IncludeToken.getEndLoc());
>>    }
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed May  9 11:27:37 2018
>> @@ -93,7 +93,8 @@ public:
>>                            StringRef FileName, bool IsAngled,
>>                            CharSourceRange FilenameRange, const FileEntry
>> *File,
>>                            StringRef SearchPath, StringRef RelativePath,
>> -                          const Module *Imported) override {
>> +                          const Module *Imported,
>> +                          SrcMgr::CharacteristicKind FileType) override {
>>      auto SR = FilenameRange.getAsRange();
>>      if (SR.isInvalid() || !File || File->tryGetRealPathName().empty())
>>        return;
>>
>> Modified: clang-tools-extra/trunk/clangd/Headers.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clangd/Headers.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/Headers.cpp Wed May  9 11:27:37 2018
>> @@ -34,7 +34,8 @@ public:
>>                            CharSourceRange /*FilenameRange*/,
>>                            const FileEntry *File, llvm::StringRef
>> /*SearchPath*/,
>>                            llvm::StringRef /*RelativePath*/,
>> -                          const Module * /*Imported*/) override {
>> +                          const Module * /*Imported*/,
>> +                          SrcMgr::CharacteristicKind /*FileType*/)
>> override {
>>      WrittenHeaders.insert(
>>          (IsAngled ? "<" + FileName + ">" : "\"" + FileName +
>> "\"").str());
>>      if (File != nullptr && !File->tryGetRealPathName().empty())
>>
>> Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
>> +++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Wed May  9
>> 11:27:37 2018
>> @@ -90,7 +90,8 @@ public:
>>                            StringRef FileName, bool IsAngled,
>>                            CharSourceRange FilenameRange, const FileEntry
>> *File,
>>                            StringRef SearchPath, StringRef RelativePath,
>> -                          const Module *Imported) override {
>> +                          const Module *Imported,
>> +                          SrcMgr::CharacteristicKind FileType) override {
>>      Checker.collectUmbrellaHeaderHeader(File->getName());
>>    }
>>
>>
>> Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
>> +++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Wed May  9
>> 11:27:37 2018
>> @@ -750,7 +750,8 @@ public:
>>                            const clang::FileEntry *File,
>>                            llvm::StringRef SearchPath,
>>                            llvm::StringRef RelativePath,
>> -                          const clang::Module *Imported) override;
>> +                          const clang::Module *Imported,
>> +                          clang::SrcMgr::CharacteristicKind FileType)
>> override;
>>    void FileChanged(clang::SourceLocation Loc,
>>                     clang::PPCallbacks::FileChangeReason Reason,
>>                     clang::SrcMgr::CharacteristicKind FileType,
>> @@ -1289,7 +1290,7 @@ void PreprocessorCallbacks::InclusionDir
>>      llvm::StringRef FileName, bool IsAngled,
>>      clang::CharSourceRange FilenameRange, const clang::FileEntry *File,
>>      llvm::StringRef SearchPath, llvm::StringRef RelativePath,
>> -    const clang::Module *Imported) {
>> +    const clang::Module *Imported, clang::SrcMgr::CharacteristicKind
>> FileType) {
>>    int DirectiveLine, DirectiveColumn;
>>    std::string HeaderPath = getSourceLocationFile(PP, HashLoc);
>>    getSourceLocationLineAndColumn(PP, HashLoc, DirectiveLine,
>> DirectiveColumn);
>>
>> Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
>> +++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Wed May  9
>> 11:27:37 2018
>> @@ -139,7 +139,7 @@ void PPCallbacksTracker::InclusionDirect
>>      llvm::StringRef FileName, bool IsAngled,
>>      clang::CharSourceRange FilenameRange, const clang::FileEntry *File,
>>      llvm::StringRef SearchPath, llvm::StringRef RelativePath,
>> -    const clang::Module *Imported) {
>> +    const clang::Module *Imported, clang::SrcMgr::CharacteristicKind
>> FileType) {
>>    beginCallback("InclusionDirective");
>>    appendArgument("IncludeTok", IncludeTok);
>>    appendFilePathArgument("FileName", FileName);
>>
>> Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h?rev=331905&r1=331904&r2=331905&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h (original)
>> +++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Wed May  9
>> 11:27:37 2018
>> @@ -102,7 +102,8 @@ public:
>>                            const clang::FileEntry *File,
>>                            llvm::StringRef SearchPath,
>>                            llvm::StringRef RelativePath,
>> -                          const clang::Module *Imported) override;
>> +                          const clang::Module *Imported,
>> +                          clang::SrcMgr::CharacteristicKind FileType)
>> override;
>>    void moduleImport(clang::SourceLocation ImportLoc, clang::ModuleIdPath
>> Path,
>>                      const clang::Module *Imported) override;
>>    void EndOfMainFile() override;
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180509/4509f942/attachment-0001.html>


More information about the cfe-commits mailing list