r204568 - When we inject a declaration into a namespace, add the primary DeclContext to
Richard Smith
richard-llvm at metafoo.co.uk
Sun Mar 23 12:45:26 PDT 2014
Author: rsmith
Date: Sun Mar 23 14:45:26 2014
New Revision: 204568
URL: http://llvm.org/viewvc/llvm-project?rev=204568&view=rev
Log:
When we inject a declaration into a namespace, add the primary DeclContext to
the update set rather than the current DeclContext. Add test for the local
extern case too.
Modified:
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/Inputs/cxx-templates-b.h
cfe/trunk/test/Modules/Inputs/cxx-templates-common.h
cfe/trunk/test/Modules/cxx-templates.cpp
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sun Mar 23 14:45:26 2014
@@ -185,8 +185,9 @@ void ASTDeclWriter::VisitDecl(Decl *D) {
// function with a local extern declaration, for instance.
if (D->isOutOfLine()) {
auto *NS = dyn_cast<NamespaceDecl>(D->getDeclContext()->getRedeclContext());
+ // FIXME: Also update surrounding inline namespaces.
if (NS && NS->isFromASTFile())
- Writer.AddUpdatedDeclContext(NS);
+ Writer.AddUpdatedDeclContext(NS->getPrimaryContext());
}
}
Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-b.h?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-b.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-b.h Sun Mar 23 14:45:26 2014
@@ -66,4 +66,5 @@ template<typename T> void UseDefinedInBI
void TriggerInstantiation() {
UseDefinedInBImpl<void>();
+ Std::f<int>();
}
Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-common.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-common.h?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-common.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-common.h Sun Mar 23 14:45:26 2014
@@ -15,3 +15,9 @@ namespace Std {
friend bool operator!=(const WithFriend &A, const WithFriend &B) { return false; }
};
}
+
+namespace Std {
+ template<typename T> void f() {
+ extern T g();
+ }
+}
Modified: cfe/trunk/test/Modules/cxx-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-templates.cpp?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cxx-templates.cpp (original)
+++ cfe/trunk/test/Modules/cxx-templates.cpp Sun Mar 23 14:45:26 2014
@@ -121,6 +121,11 @@ bool testFriendInClassTemplate(Std::With
return wfi != wfi;
}
+namespace Std {
+ void g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+ // expected-note at cxx-templates-common.h:21 {{previous}}
+}
+
// CHECK-GLOBAL: DeclarationName 'f'
// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
// CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f'
More information about the cfe-commits
mailing list