Improve "[cling] DefinitionShadower: allow shadowing of non-user-defined declarations (#6571)"
The patch applies a patch to remove duplicated entries from the StoredDeclsList. Apparently, reading a yet-to-be-determined PCM file adds the same `Decl *` to the lookup table. Trying to remove it using `StoredDeclsList::remove()` makes an internal assertion to fail, as it expects the Decl to disappear from the lookup table after being removed. So far, `darwin.pcm` seems like one of the possible causes of this problem, but more investigation is needed.
This commit is contained in:
parent
74e4407225
commit
fedeedc2cd
@ -19,6 +19,8 @@
|
|||||||
#include "clang/Sema/Lookup.h"
|
#include "clang/Sema/Lookup.h"
|
||||||
#include "clang/Sema/Sema.h"
|
#include "clang/Sema/Sema.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
namespace cling {
|
namespace cling {
|
||||||
@ -77,8 +79,15 @@ namespace cling {
|
|||||||
m_Sema->IdResolver.RemoveDecl(D);
|
m_Sema->IdResolver.RemoveDecl(D);
|
||||||
}
|
}
|
||||||
clang::StoredDeclsList &SDL = (*m_TU->getLookupPtr())[D->getDeclName()];
|
clang::StoredDeclsList &SDL = (*m_TU->getLookupPtr())[D->getDeclName()];
|
||||||
if (SDL.getAsVector() || SDL.getAsDecl() == D)
|
if (SDL.getAsDecl() == D) {
|
||||||
SDL.remove(D);
|
SDL.setOnlyValue(nullptr);
|
||||||
|
}
|
||||||
|
if (auto Vec = SDL.getAsVector()) {
|
||||||
|
// FIXME: investigate why StoredDeclList has duplicated entries coming from PCM.
|
||||||
|
Vec->erase(std::remove_if(Vec->begin(), Vec->end(),
|
||||||
|
[D](Decl *Other) { return cast<Decl>(D) == Other; }),
|
||||||
|
Vec->end());
|
||||||
|
}
|
||||||
|
|
||||||
if (InterpreterCallbacks *IC = m_Interp.getCallbacks())
|
if (InterpreterCallbacks *IC = m_Interp.getCallbacks())
|
||||||
IC->DefinitionShadowed(D);
|
IC->DefinitionShadowed(D);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user