Do not randomly add to lookup results during EvaluateT().
This commit is contained in:
parent
1330bd1fe4
commit
187cbaf257
@ -308,7 +308,11 @@ namespace test {
|
||||
SymbolResolverCallback::~SymbolResolverCallback() { }
|
||||
|
||||
bool SymbolResolverCallback::LookupObject(LookupResult& R, Scope* S) {
|
||||
if (!ShouldResolveAtRuntime(R, S))
|
||||
return false;
|
||||
|
||||
if (m_IsRuntime) {
|
||||
// We are currently parsing an EvaluateT() expression
|
||||
if (!m_Resolve)
|
||||
return false;
|
||||
|
||||
@ -324,32 +328,30 @@ namespace test {
|
||||
return true; // Tell clang to continue.
|
||||
}
|
||||
|
||||
if (ShouldResolveAtRuntime(R, S)) {
|
||||
ASTContext& C = R.getSema().getASTContext();
|
||||
DeclContext* DC = 0;
|
||||
// For DeclContext-less scopes like if (dyn_expr) {}
|
||||
while (!DC) {
|
||||
DC = static_cast<DeclContext*>(S->getEntity());
|
||||
S = S->getParent();
|
||||
}
|
||||
DeclarationName Name = R.getLookupName();
|
||||
IdentifierInfo* II = Name.getAsIdentifierInfo();
|
||||
SourceLocation Loc = R.getNameLoc();
|
||||
VarDecl* Res = VarDecl::Create(C, DC, Loc, Loc, II, C.DependentTy,
|
||||
/*TypeSourceInfo*/0, SC_None);
|
||||
|
||||
// Annotate the decl to give a hint in cling. FIXME: Current implementation
|
||||
// is a gross hack, because TClingCallbacks shouldn't know about
|
||||
// EvaluateTSynthesizer at all!
|
||||
SourceRange invalidRange;
|
||||
Res->addAttr(new (C) AnnotateAttr(invalidRange, C, "__ResolveAtRuntime", 0));
|
||||
R.addDecl(Res);
|
||||
DC->addDecl(Res);
|
||||
// Say that we can handle the situation. Clang should try to recover
|
||||
return true;
|
||||
// We are currently NOT parsing an EvaluateT() expression.
|
||||
// Escape the expression into an EvaluateT() expression.
|
||||
ASTContext& C = R.getSema().getASTContext();
|
||||
DeclContext* DC = 0;
|
||||
// For DeclContext-less scopes like if (dyn_expr) {}
|
||||
while (!DC) {
|
||||
DC = static_cast<DeclContext*>(S->getEntity());
|
||||
S = S->getParent();
|
||||
}
|
||||
DeclarationName Name = R.getLookupName();
|
||||
IdentifierInfo* II = Name.getAsIdentifierInfo();
|
||||
SourceLocation Loc = R.getNameLoc();
|
||||
VarDecl* Res = VarDecl::Create(C, DC, Loc, Loc, II, C.DependentTy,
|
||||
/*TypeSourceInfo*/0, SC_None);
|
||||
|
||||
return false;
|
||||
// Annotate the decl to give a hint in cling. FIXME: Current implementation
|
||||
// is a gross hack, because TClingCallbacks shouldn't know about
|
||||
// EvaluateTSynthesizer at all!
|
||||
SourceRange invalidRange;
|
||||
Res->addAttr(new (C) AnnotateAttr(invalidRange, C, "__ResolveAtRuntime", 0));
|
||||
R.addDecl(Res);
|
||||
DC->addDecl(Res);
|
||||
// Say that we can handle the situation. Clang should try to recover
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolResolverCallback::ShouldResolveAtRuntime(LookupResult& R,
|
||||
|
Loading…
x
Reference in New Issue
Block a user