diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/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); diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -814,6 +814,12 @@ functionDecl(hasDescendant(usingDecl()))); } +TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) { + MatchVerifier 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. ///