Endless loop in Sema::ArgumentDependentLookup
Alexander Potapenko
glider at google.com
Fri Jul 12 04:59:38 PDT 2013
See http://llvm.org/bugs/show_bug.cgi?id=16597
The fix proposed by Richard is below, however yours looks more
correct, as D is never changed in that loop.
Index: lib/Sema/SemaLookup.cpp
===================================================================
--- lib/Sema/SemaLookup.cpp (revision 186060)
+++ lib/Sema/SemaLookup.cpp (working copy)
@@ -2751,6 +2751,7 @@
// namespaces even if they are not visible during an ordinary
// lookup (11.4).
DeclContext::lookup_result R = (*NS)->lookup(Name);
+ llvm::SmallPtrSet<Decl*, 8> VisitedFriendDecls;
for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E;
++I) {
NamedDecl *D = *I;
@@ -2759,6 +2760,8 @@
if (D->getIdentifierNamespace() == Decl::IDNS_OrdinaryFriend) {
bool DeclaredInAssociatedClass = false;
for (Decl *DI = D; DI; DI = D->getPreviousDecl()) {
+ if (!VisitedFriendDecls.insert(DI))
+ break;
DeclContext *LexDC = DI->getLexicalDeclContext();
if (AssociatedClasses.count(cast<CXXRecordDecl>(LexDC))) {
DeclaredInAssociatedClass = true;
On Fri, Jul 12, 2013 at 3:38 PM, Stephan Bergmann <sbergman at redhat.com> wrote:
> Looks like trunk r186040 introduced a typo in lib/Sema/SemaLookup.cpp that
> can cause endless loops, fix would apparently be:
>
>> Index: lib/Sema/SemaLookup.cpp
>> ===================================================================
>> --- lib/Sema/SemaLookup.cpp (revision 186153)
>> +++ lib/Sema/SemaLookup.cpp (working copy)
>> @@ -2758,7 +2758,7 @@
>> // it only if it was declared in an associated classes.
>> if (D->getIdentifierNamespace() == Decl::IDNS_OrdinaryFriend) {
>> bool DeclaredInAssociatedClass = false;
>> - for (Decl *DI = D; DI; DI = D->getPreviousDecl()) {
>> + for (Decl *DI = D; DI; DI = DI->getPreviousDecl()) {
>> DeclContext *LexDC = DI->getLexicalDeclContext();
>> if (AssociatedClasses.count(cast<CXXRecordDecl>(LexDC))) {
>> DeclaredInAssociatedClass = true;
>
>
> Stephan
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
--
Alexander Potapenko
Software Engineer
Google Moscow
More information about the cfe-commits
mailing list