[cfe-commits] r102224 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/CodeGen/CGDebugInfo.cpp lib/Frontend/PCHReaderDecl.cpp lib/Sema/Lookup.h lib/Sema/SemaDecl.cpp lib/Sema/SemaLookup.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp

Devang Patel dpatel at apple.com
Fri Apr 23 17:40:36 PDT 2010


Author: dpatel
Date: Fri Apr 23 19:40:35 2010
New Revision: 102224

URL: http://llvm.org/viewvc/llvm-project?rev=102224&view=rev
Log:
Revert r102215. This causes clang crash while compiling a test case from gdb testsuite.

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
    cfe/trunk/lib/Sema/Lookup.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Apr 23 19:40:35 2010
@@ -132,12 +132,7 @@
     /// *introduces* a number of other declarations into the current
     /// scope, and those declarations use the IDNS of their targets,
     /// but the actual using declarations go in this namespace.
-    IDNS_Using               = 0x0200,
-
-    /// This declaration is a C++ operator declared in a non-class
-    /// context.  All such operators are also in IDNS_Ordinary.
-    /// C++ lexical operator lookup looks for these.
-    IDNS_NonMemberOperator   = 0x0400
+    IDNS_Using               = 0x0200
   };
 
   /// ObjCDeclQualifier - Qualifier used on types in method declarations
@@ -538,14 +533,6 @@
               FOK_Declared : FOK_Undeclared);
   }
 
-  /// Specifies that this declaration is a C++ overloaded non-member.
-  void setNonMemberOperator() {
-    assert(getKind() == Function || getKind() == FunctionTemplate);
-    assert((IdentifierNamespace & IDNS_Ordinary) &&
-           "visible non-member operators should be in ordinary namespace");
-    IdentifierNamespace |= IDNS_NonMemberOperator;
-  }
-
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *) { return true; }
   static bool classofKind(Kind K) { return true; }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 23 19:40:35 2010
@@ -1333,9 +1333,21 @@
 
   llvm::StringRef Name;
   MangleBuffer LinkageName;
+  // It is expected that CurLoc is set before using EmitFunctionStart.
+  // Usually, CurLoc points to the left bracket location of compound
+  // statement representing function body.
+  llvm::DIFile Unit = getOrCreateFile(CurLoc);
+  llvm::DIDescriptor Context(Unit.getNode());
 
   const Decl *D = GD.getDecl();
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+    if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+      if (MD->isStatic()) {
+        QualType RTy = CGM.getContext().getTypeDeclType(MD->getParent());
+        Context = CreateType(RTy->getAs<RecordType>(), getOrCreateFile(CurLoc));
+      }
+    }
+
     // If there is a DISubprogram for  this function available then use it.
     llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
       FI = SPCache.find(FD);
@@ -1360,15 +1372,11 @@
       Name = Name.substr(1);
   }
 
-  // It is expected that CurLoc is set before using EmitFunctionStart.
-  // Usually, CurLoc points to the left bracket location of compound
-  // statement representing function body.
-  llvm::DIFile Unit = getOrCreateFile(CurLoc);
   SourceManager &SM = CGM.getContext().getSourceManager();
   unsigned LineNo = SM.getPresumedLoc(CurLoc).getLine();
 
   llvm::DISubprogram SP =
-    DebugFactory.CreateSubprogram(Unit, Name, Name, LinkageName, Unit, LineNo,
+    DebugFactory.CreateSubprogram(Context, Name, Name, LinkageName, Unit, LineNo,
                                   getOrCreateType(FnType, Unit),
                                   Fn->hasInternalLinkage(), true/*definition*/);
 

Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Fri Apr 23 19:40:35 2010
@@ -197,11 +197,6 @@
   for (unsigned I = 0; I != NumParams; ++I)
     Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
   FD->setParams(Params.data(), NumParams);
-
-  // FIXME: order this properly w.r.t. friendness
-  // FIXME: this same thing needs to happen for function templates
-  if (FD->isOverloadedOperator() && !FD->getDeclContext()->isRecord())
-    FD->setNonMemberOperator();
 }
 
 void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {

Modified: cfe/trunk/lib/Sema/Lookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Lookup.h?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Lookup.h (original)
+++ cfe/trunk/lib/Sema/Lookup.h Fri Apr 23 19:40:35 2010
@@ -124,6 +124,7 @@
   };
 
   typedef UnresolvedSetImpl::iterator iterator;
+  typedef bool (*ResultFilter)(NamedDecl*, unsigned IDNS);
 
   LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc,
                Sema::LookupNameKind LookupKind,
@@ -135,6 +136,7 @@
       Name(Name),
       NameLoc(NameLoc),
       LookupKind(LookupKind),
+      IsAcceptableFn(0),
       IDNS(0),
       Redecl(Redecl != Sema::NotForRedeclaration),
       HideTags(true),
@@ -154,6 +156,7 @@
       Name(Other.Name),
       NameLoc(Other.NameLoc),
       LookupKind(Other.LookupKind),
+      IsAcceptableFn(Other.IsAcceptableFn),
       IDNS(Other.IDNS),
       Redecl(Other.Redecl),
       HideTags(Other.HideTags),
@@ -239,7 +242,8 @@
 
   /// \brief Tests whether the given declaration is acceptable.
   bool isAcceptableDecl(NamedDecl *D) const {
-    return D->isInIdentifierNamespace(IDNS);
+    assert(IsAcceptableFn);
+    return IsAcceptableFn(D, IDNS);
   }
 
   /// \brief Returns the identifier namespace mask for this lookup.
@@ -571,6 +575,7 @@
   SourceLocation NameLoc;
   SourceRange NameContextRange;
   Sema::LookupNameKind LookupKind;
+  ResultFilter IsAcceptableFn; // set by configure()
   unsigned IDNS; // set by configure()
 
   bool Redecl;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr 23 19:40:35 2010
@@ -3269,12 +3269,6 @@
     NewFD->setAccess(Access);
   }
 
-  if (NewFD->isOverloadedOperator() && !DC->isRecord() &&
-      NewFD->isInIdentifierNamespace(Decl::IDNS_Ordinary)) {
-    NewFD->setNonMemberOperator();
-    if (FunctionTemplate) FunctionTemplate->setNonMemberOperator();
-  }
-
   // If we have a function template, check the template parameter
   // list. This will check and merge default template arguments.
   if (FunctionTemplate) {

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Apr 23 19:40:35 2010
@@ -193,6 +193,37 @@
   };
 }
 
+static bool IsAcceptableIDNS(NamedDecl *D, unsigned IDNS) {
+  return D->isInIdentifierNamespace(IDNS);
+}
+
+static bool IsAcceptableOperatorName(NamedDecl *D, unsigned IDNS) {
+  return D->isInIdentifierNamespace(IDNS) &&
+    !D->getDeclContext()->isRecord();
+}
+
+/// Gets the default result filter for the given lookup.
+static inline
+LookupResult::ResultFilter getResultFilter(Sema::LookupNameKind NameKind) {
+  switch (NameKind) {
+  case Sema::LookupOrdinaryName:
+  case Sema::LookupTagName:
+  case Sema::LookupMemberName:
+  case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping
+  case Sema::LookupUsingDeclName:
+  case Sema::LookupObjCProtocolName:
+  case Sema::LookupNestedNameSpecifierName:
+  case Sema::LookupNamespaceName:
+    return &IsAcceptableIDNS;
+
+  case Sema::LookupOperatorName:
+    return &IsAcceptableOperatorName;
+  }
+
+  llvm_unreachable("unkknown lookup kind");
+  return 0;
+}
+
 // Retrieve the set of identifier namespaces that correspond to a
 // specific kind of name lookup.
 static inline unsigned getIDNS(Sema::LookupNameKind NameKind,
@@ -201,6 +232,7 @@
   unsigned IDNS = 0;
   switch (NameKind) {
   case Sema::LookupOrdinaryName:
+  case Sema::LookupOperatorName:
   case Sema::LookupRedeclarationWithLinkage:
     IDNS = Decl::IDNS_Ordinary;
     if (CPlusPlus) {
@@ -209,13 +241,6 @@
     }
     break;
 
-  case Sema::LookupOperatorName:
-    // Operator lookup is its own crazy thing;  it is not the same
-    // as (e.g.) looking up an operator name for redeclaration.
-    assert(!Redeclaration && "cannot do redeclaration operator lookup");
-    IDNS = Decl::IDNS_NonMemberOperator;
-    break;
-
   case Sema::LookupTagName:
     if (CPlusPlus) {
       IDNS = Decl::IDNS_Type;
@@ -262,6 +287,7 @@
   IDNS = getIDNS(LookupKind,
                  SemaRef.getLangOptions().CPlusPlus,
                  isForRedeclaration());
+  IsAcceptableFn = getResultFilter(LookupKind);
 
   // If we're looking for one of the allocation or deallocation
   // operators, make sure that the implicitly-declared new and delete

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=102224&r1=102223&r2=102224&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Apr 23 19:40:35 2010
@@ -1140,12 +1140,6 @@
     DC->makeDeclVisibleInContext(ToFriendD, /*Recoverable=*/ false);
   }
 
-  if (Function->isOverloadedOperator() && !DC->isRecord() &&
-      Function->isInIdentifierNamespace(Decl::IDNS_Ordinary)) {
-    Function->setNonMemberOperator();
-    if (FunctionTemplate) FunctionTemplate->setNonMemberOperator();
-  }
-
   return Function;
 }
 





More information about the cfe-commits mailing list