[PATCH] D58920: [Modules][PR39287] Consolidate multiple std's
Brian Gesiak via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 18:20:25 PDT 2019
modocache updated this revision to Diff 199709.
modocache added a comment.
Oops, sent the patch from the wrong repository.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58920/new/
https://reviews.llvm.org/D58920
Files:
lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
test/Modules/Inputs/mod-virtual-destructor-bug/a.h
test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
test/Modules/mod-virtual-destructor-bug-two.cpp
test/Modules/mod-virtual-destructor-bug.cpp
Index: test/Modules/mod-virtual-destructor-bug.cpp
===================================================================
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug %s -verify
+
+class A {
+ virtual ~A() {}
+};
+
+#include "a.h"
+
+namespace std { class type_info; }
+
+void foo() {
+ typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/mod-virtual-destructor-bug-two.cpp
===================================================================
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug-two.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug-two %s -verify
+
+class A {
+ virtual ~A() {}
+};
+
+#include "a.h"
+
+void foo() {
+ typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
@@ -0,0 +1,3 @@
+module "a.h" {
+ header "a.h"
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/a.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug/a.h
@@ -0,0 +1 @@
+namespace std {}
Index: test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
@@ -0,0 +1,3 @@
+module "a.h" {
+ header "a.h"
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
@@ -0,0 +1 @@
+namespace std { class type_info; }
Index: lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -47,6 +47,7 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Sema/IdentifierResolver.h"
+#include "clang/Sema/Sema.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ContinuousRangeMap.h"
@@ -3401,6 +3402,14 @@
return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
TypedefNameForLinkage);
}
+ if (isa<NamespaceDecl>(D) && D->getName() == "std") {
+ auto StdPtr = Reader.getSema()->StdNamespace;
+ if (StdPtr.isValid() && !StdPtr.isOffset())
+ if (auto *Std = cast_or_null<NamespaceDecl>(StdPtr.get(nullptr)))
+ if (isSameEntity(Std, D))
+ return FindExistingResult(Reader, D, Std, AnonymousDeclNumber,
+ TypedefNameForLinkage);
+ }
} else {
// Not in a mergeable context.
return FindExistingResult(Reader);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58920.199709.patch
Type: text/x-patch
Size: 3253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190516/bfc9a2ac/attachment.bin>
More information about the cfe-commits
mailing list