[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 10:06:20 PDT 2021


steakhal updated this revision to Diff 331302.
steakhal added a comment.

Revert to the previous version and move to line 738 just before "ImportRecordTypeInFunc".


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
@@ -735,6 +735,12 @@
                  has(declStmt(hasSingleDecl(varDecl(hasName("d")))))))));
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier<Decl> Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+             Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) {
   Decl *FromTU = getTuDecl("int declToImport() { "
                            "  struct data_t {int a;int b;};"
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.331302.patch
Type: text/x-patch
Size: 1163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210317/c65465a0/attachment.bin>


More information about the cfe-commits mailing list