]> granicus.if.org Git - clang/commitdiff
Fix r165005: The lexical DeclContext is not the right place to make a decision about...
authorAxel Naumann <Axel.Naumann@cern.ch>
Thu, 4 Oct 2012 07:34:43 +0000 (07:34 +0000)
committerAxel Naumann <Axel.Naumann@cern.ch>
Thu, 4 Oct 2012 07:34:43 +0000 (07:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165215 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReaderDecl.cpp

index d9243f62e5ae027edf2bd08592b36d909ff4b9bb..762ad01b51e39e1f35fd909991d2ae7f239e59de 100644 (file)
@@ -1781,11 +1781,13 @@ ASTDeclReader::FindExistingResult::~FindExistingResult() {
   if (!AddResult || Existing)
     return;
   
-  DeclContext *DC = New->getLexicalDeclContext();
-  if (DC->isTranslationUnit() && Reader.SemaObj) {
+  if (New->getDeclContext()->getRedeclContext()->isTranslationUnit()
+      && Reader.SemaObj) {
     Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName());
-  } else if (DC->isNamespace()) {
-    DC->addDecl(New);
+  } else {
+    DeclContext *DC = New->getLexicalDeclContext();
+    if (DC->isNamespace())
+      DC->addDecl(New);
   }
 }