[PATCH] D98707: [clang][ASTImporter] Fix import of VarDecl regarding thread local storage spec
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 17 02:41:52 PDT 2021
steakhal updated this revision to Diff 331191.
steakhal added a comment.
Moved to line 3481, changed the test logic accordingly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98707/new/
https://reviews.llvm.org/D98707
Files:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3480,6 +3480,20 @@
struct ImportVariables : ASTImporterOptionSpecificTestBase {};
+TEST_P(ImportVariables, ImportedVarDeclPreservesThreadLocalStorage) {
+ Decl *FromTU =
+ getTuDecl("thread_local int declToImport;", Lang_CXX11, "input1.cc");
+
+ auto *FromDWithTLS = FirstDeclMatcher<VarDecl>().match(
+ FromTU, varDecl(hasThreadStorageDuration()));
+ ASSERT_TRUE(FromDWithTLS);
+ ASSERT_EQ(SD_Thread, FromDWithTLS->getStorageDuration());
+
+ const auto *ToD = Import(FromDWithTLS, Lang_CXX11);
+ ASSERT_TRUE(ToD);
+ EXPECT_EQ(SD_Thread, ToD->getStorageDuration());
+}
+
TEST_P(ImportVariables, ImportOfOneDeclBringsInTheWholeChain) {
Decl *FromTU = getTuDecl(
R"(
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4018,6 +4018,7 @@
D->getStorageClass()))
return ToVar;
+ ToVar->setTSCSpec(D->getTSCSpec());
ToVar->setQualifierInfo(ToQualifierLoc);
ToVar->setAccess(D->getAccess());
ToVar->setLexicalDeclContext(LexicalDC);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98707.331191.patch
Type: text/x-patch
Size: 1339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210317/6691f481/attachment.bin>
More information about the cfe-commits
mailing list