[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
Tue Mar 16 07:07:02 PDT 2021


steakhal created this revision.
steakhal added reviewers: a.sidorin, shafik, martong, balazske.
Herald added subscribers: teemperor, rnkovacs.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After the import, we did not copy the `TSCSpec`.
This commit resolves that.


Repository:
  rG LLVM Github Monorepo

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
@@ -814,6 +814,12 @@
              functionDecl(hasDescendant(usingDecl())));
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier<Decl> Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+             Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 /// \brief Matches shadow declarations introduced into a scope by a
 ///        (resolved) using declaration.
 ///
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.330975.patch
Type: text/x-patch
Size: 1078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210316/b0569ca0/attachment.bin>


More information about the cfe-commits mailing list