r283766 - [Sema] Use unique_ptr instead of raw pointers in the late-parsed templates map.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 10 14:20:51 PDT 2016


Galina, I've already reverted the offending changes in iterator.h.

The MSVC build is now broken due to a different change.

Sorry for the noise (but not really sorry, MSVC shouldn't crash :).

On Mon, Oct 10, 2016 at 2:15 PM, Galina Kistanova <gkistanova at gmail.com> wrote:
> Hello Justin,
>
> Some of your resent commits broke the next builder:
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/12710
>
> Please have a look at it?
>
> Thanks
>
> Galina
>
>
>
> On Mon, Oct 10, 2016 at 9:26 AM, Justin Lebar via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
>>
>> Author: jlebar
>> Date: Mon Oct 10 11:26:08 2016
>> New Revision: 283766
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=283766&view=rev
>> Log:
>> [Sema] Use unique_ptr instead of raw pointers in the late-parsed templates
>> map.
>>
>> Summary:
>> This is possible now that MapVector supports move-only values.
>>
>> Depends on D25404.
>>
>> Reviewers: timshen
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D25405
>>
>> Modified:
>>     cfe/trunk/include/clang/Sema/ExternalSemaSource.h
>>     cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
>>     cfe/trunk/include/clang/Sema/Sema.h
>>     cfe/trunk/include/clang/Serialization/ASTReader.h
>>     cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
>>     cfe/trunk/lib/Sema/Sema.cpp
>>     cfe/trunk/lib/Sema/SemaTemplate.cpp
>>     cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>>     cfe/trunk/lib/Serialization/ASTReader.cpp
>>     cfe/trunk/lib/Serialization/ASTWriter.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/ExternalSemaSource.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ExternalSemaSource.h?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/ExternalSemaSource.h (original)
>> +++ cfe/trunk/include/clang/Sema/ExternalSemaSource.h Mon Oct 10 11:26:08
>> 2016
>> @@ -190,7 +190,8 @@ public:
>>    /// external source should take care not to introduce the same map
>> entries
>>    /// repeatedly.
>>    virtual void ReadLateParsedTemplates(
>> -      llvm::MapVector<const FunctionDecl *, LateParsedTemplate *>
>> &LPTMap) {}
>> +      llvm::MapVector<const FunctionDecl *,
>> std::unique_ptr<LateParsedTemplate>>
>> +          &LPTMap) {}
>>
>>    /// \copydoc Sema::CorrectTypo
>>    /// \note LookupKind must correspond to a valid Sema::LookupNameKind
>>
>> Modified: cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h (original)
>> +++ cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h Mon Oct 10
>> 11:26:08 2016
>> @@ -322,8 +322,8 @@ public:
>>    /// external source should take care not to introduce the same map
>> entries
>>    /// repeatedly.
>>    void ReadLateParsedTemplates(
>> -      llvm::MapVector<const FunctionDecl *, LateParsedTemplate *>
>> &LPTMap)
>> -      override;
>> +      llvm::MapVector<const FunctionDecl *,
>> std::unique_ptr<LateParsedTemplate>>
>> +          &LPTMap) override;
>>
>>    /// \copydoc ExternalSemaSource::CorrectTypo
>>    /// \note Returns the first nonempty correction.
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 10 11:26:08 2016
>> @@ -551,7 +551,8 @@ public:
>>    SmallVector<std::pair<CXXMethodDecl*, const FunctionProtoType*>, 2>
>>      DelayedDefaultedMemberExceptionSpecs;
>>
>> -  typedef llvm::MapVector<const FunctionDecl *, LateParsedTemplate *>
>> +  typedef llvm::MapVector<const FunctionDecl *,
>> +                          std::unique_ptr<LateParsedTemplate>>
>>        LateParsedTemplateMapT;
>>    LateParsedTemplateMapT LateParsedTemplateMap;
>>
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Oct 10 11:26:08
>> 2016
>> @@ -1877,8 +1877,8 @@ public:
>>                                             SourceLocation> > &Pending)
>> override;
>>
>>    void ReadLateParsedTemplates(
>> -      llvm::MapVector<const FunctionDecl *, LateParsedTemplate *>
>> &LPTMap)
>> -      override;
>> +      llvm::MapVector<const FunctionDecl *,
>> std::unique_ptr<LateParsedTemplate>>
>> +          &LPTMap) override;
>>
>>    /// \brief Load a selector from disk, registering its ID if it exists.
>>    void LoadSelector(Selector Sel);
>>
>> Modified: cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp (original)
>> +++ cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp Mon Oct 10 11:26:08
>> 2016
>> @@ -285,7 +285,8 @@ void MultiplexExternalSemaSource::ReadPe
>>  }
>>
>>  void MultiplexExternalSemaSource::ReadLateParsedTemplates(
>> -    llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap)
>> {
>> +    llvm::MapVector<const FunctionDecl *,
>> std::unique_ptr<LateParsedTemplate>>
>> +        &LPTMap) {
>>    for (size_t i = 0; i < Sources.size(); ++i)
>>      Sources[i]->ReadLateParsedTemplates(LPTMap);
>>  }
>>
>> Modified: cfe/trunk/lib/Sema/Sema.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/Sema.cpp (original)
>> +++ cfe/trunk/lib/Sema/Sema.cpp Mon Oct 10 11:26:08 2016
>> @@ -259,7 +259,6 @@ void Sema::Initialize() {
>>  }
>>
>>  Sema::~Sema() {
>> -  llvm::DeleteContainerSeconds(LateParsedTemplateMap);
>>    if (VisContext) FreeVisContext();
>>    // Kill all the active scopes.
>>    for (unsigned I = 1, E = FunctionScopes.size(); I != E; ++I)
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Oct 10 11:26:08 2016
>> @@ -8668,12 +8668,12 @@ void Sema::MarkAsLateParsedTemplate(Func
>>    if (!FD)
>>      return;
>>
>> -  LateParsedTemplate *LPT = new LateParsedTemplate;
>> +  auto LPT = llvm::make_unique<LateParsedTemplate>();
>>
>>    // Take tokens to avoid allocations
>>    LPT->Toks.swap(Toks);
>>    LPT->D = FnD;
>> -  LateParsedTemplateMap.insert(std::make_pair(FD, LPT));
>> +  LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
>>
>>    FD->setLateTemplateParsed(true);
>>  }
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Oct 10 11:26:08
>> 2016
>> @@ -3622,9 +3622,10 @@ void Sema::InstantiateFunctionDefinition
>>      if (PatternDecl->isFromASTFile())
>>        ExternalSource->ReadLateParsedTemplates(LateParsedTemplateMap);
>>
>> -    LateParsedTemplate *LPT = LateParsedTemplateMap.lookup(PatternDecl);
>> -    assert(LPT && "missing LateParsedTemplate");
>> -    LateTemplateParser(OpaqueParser, *LPT);
>> +    auto LPTIter = LateParsedTemplateMap.find(PatternDecl);
>> +    assert(LPTIter != LateParsedTemplateMap.end() &&
>> +           "missing LateParsedTemplate");
>> +    LateTemplateParser(OpaqueParser, *LPTIter->second);
>>      Pattern = PatternDecl->getBody(PatternDecl);
>>    }
>>
>>
>> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Oct 10 11:26:08 2016
>> @@ -7556,12 +7556,13 @@ void ASTReader::ReadPendingInstantiation
>>  }
>>
>>  void ASTReader::ReadLateParsedTemplates(
>> -    llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap)
>> {
>> +    llvm::MapVector<const FunctionDecl *,
>> std::unique_ptr<LateParsedTemplate>>
>> +        &LPTMap) {
>>    for (unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
>>         /* In loop */) {
>>      FunctionDecl *FD =
>> cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
>>
>> -    LateParsedTemplate *LT = new LateParsedTemplate;
>> +    auto LT = llvm::make_unique<LateParsedTemplate>();
>>      LT->D = GetDecl(LateParsedTemplates[Idx++]);
>>
>>      ModuleFile *F = getOwningModuleFile(LT->D);
>> @@ -7572,7 +7573,7 @@ void ASTReader::ReadLateParsedTemplates(
>>      for (unsigned T = 0; T < TokN; ++T)
>>        LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
>>
>> -    LPTMap.insert(std::make_pair(FD, LT));
>> +    LPTMap.insert(std::make_pair(FD, std::move(LT)));
>>    }
>>
>>    LateParsedTemplates.clear();
>>
>> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=283766&r1=283765&r2=283766&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Oct 10 11:26:08 2016
>> @@ -4009,14 +4009,14 @@ void ASTWriter::WriteLateParsedTemplates
>>      return;
>>
>>    RecordData Record;
>> -  for (auto LPTMapEntry : LPTMap) {
>> +  for (auto &LPTMapEntry : LPTMap) {
>>      const FunctionDecl *FD = LPTMapEntry.first;
>> -    LateParsedTemplate *LPT = LPTMapEntry.second;
>> +    LateParsedTemplate &LPT = *LPTMapEntry.second;
>>      AddDeclRef(FD, Record);
>> -    AddDeclRef(LPT->D, Record);
>> -    Record.push_back(LPT->Toks.size());
>> +    AddDeclRef(LPT.D, Record);
>> +    Record.push_back(LPT.Toks.size());
>>
>> -    for (const auto &Tok : LPT->Toks) {
>> +    for (const auto &Tok : LPT.Toks) {
>>        AddToken(Tok, Record);
>>      }
>>    }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


More information about the cfe-commits mailing list