]> granicus.if.org Git - clang/commitdiff
Map from local decl IDs to global decl IDs when lazily deserializing friend decl...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 30 Aug 2013 00:23:29 +0000 (00:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 30 Aug 2013 00:23:29 +0000 (00:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189629 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/cxx-decls-imported.h
test/Modules/Inputs/dummy.h [new file with mode: 0644]
test/Modules/Inputs/module.map
test/Modules/cxx-decls.cpp

index a224aefa8faa178e0728d7a6507468f343accdac..67ca94bbf8e2daede3c39f0daeb485249559bfcc 100644 (file)
@@ -1186,8 +1186,8 @@ void ASTDeclReader::ReadCXXDefinitionData(
   Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
   Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
   assert(Data.Definition && "Data.Definition should be already set!");
-  Data.FirstFriend = Record[Idx++];
-  
+  Data.FirstFriend = ReadDeclID(Record, Idx);
+
   if (Data.IsLambda) {
     typedef LambdaExpr::Capture Capture;
     CXXRecordDecl::LambdaDefinitionData &Lambda
@@ -1339,7 +1339,7 @@ void ASTDeclReader::VisitFriendDecl(FriendDecl *D) {
     D->Friend = GetTypeSourceInfo(Record, Idx);
   for (unsigned i = 0; i != D->NumTPLists; ++i)
     D->getTPLists()[i] = Reader.ReadTemplateParameterList(F, Record, Idx);
-  D->NextFriend = Record[Idx++];
+  D->NextFriend = ReadDeclID(Record, Idx);
   D->UnsupportedFriend = (Record[Idx++] != 0);
   D->FriendLoc = ReadSourceLocation(Record, Idx);
 }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b94368614dfb1e067a93d37aa511d91791547b9b 100644 (file)
@@ -0,0 +1,5 @@
+class HasFriends {
+  friend void friend_1(HasFriends);
+  friend void friend_2(HasFriends);
+  void private_thing();
+};
diff --git a/test/Modules/Inputs/dummy.h b/test/Modules/Inputs/dummy.h
new file mode 100644 (file)
index 0000000..6e1ac74
--- /dev/null
@@ -0,0 +1,3 @@
+// This module only exists to make local decl IDs and global decl IDs different.
+
+struct Dummy {} extern *dummy1, *dummy2, *dummy3;
index 7be8b797a1a3fb2ef7f6d74d3cd54ac692654ba6..ac3543b6440c43cd4e7963eb9a5dd6bcdc2a6790 100644 (file)
@@ -222,6 +222,10 @@ module diag_pragma {
   header "diag_pragma.h"
 }
 
+module dummy {
+  header "dummy.h"
+}
+
 module builtin {
   header "builtin.h"
   explicit module sub {
index 733e3f90bc76e3cb237cf6bcbc1bd77b463fba13..ba3281aaec7a587383736b96a3da41b812d90996 100644 (file)
@@ -3,6 +3,7 @@
 
 // expected-no-diagnostics
 
+@import dummy;
 @import cxx_decls.imported;
 
 void test_delete(int *p) {
@@ -10,3 +11,11 @@ void test_delete(int *p) {
   // ever been explicitly declared in an unimported submodule.
   delete p;
 }
+
+void friend_1(HasFriends s) {
+  s.private_thing();
+}
+void test_friends(HasFriends s) {
+  friend_1(s);
+  friend_2(s);
+}