<div dir="ltr">I've reverted this commit in r354812, it was causing MSan failures like <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio</a> Though these error reports don't clearly implicate this change, from your change it seems like the failure is occurring because you changed static (zero-initialized) variables to member (uninitialized) variables that were then never initialized before being used. The build recovered after the revert landed in <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894</a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: alexfh<br>
Date: Mon Feb 25 08:08:46 2019<br>
New Revision: 354795<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=354795&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=354795&view=rev</a><br>
Log:<br>
Make static counters in ASTContext non-static.<br>
<br>
Summary:<br>
Fixes a data race and makes it possible to run clang-based tools in<br>
multithreaded environment with TSan.<br>
<br>
Reviewers: ilya-biryukov, riccibruno<br>
<br>
Reviewed By: riccibruno<br>
<br>
Subscribers: riccibruno, jfb, cfe-commits<br>
<br>
Tags: #clang<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D58612" rel="noreferrer" target="_blank">https://reviews.llvm.org/D58612</a><br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/ASTContext.h<br>
    cfe/trunk/lib/AST/ASTContext.cpp<br>
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/ASTContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795&r1=354794&r2=354795&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795&r1=354794&r2=354795&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/ASTContext.h (original)<br>
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019<br>
@@ -2809,46 +2809,46 @@ public:<br>
   //===--------------------------------------------------------------------===//<br>
<br>
   /// The number of implicitly-declared default constructors.<br>
-  static unsigned NumImplicitDefaultConstructors;<br>
+  unsigned NumImplicitDefaultConstructors;<br>
<br>
   /// The number of implicitly-declared default constructors for<br>
   /// which declarations were built.<br>
-  static unsigned NumImplicitDefaultConstructorsDeclared;<br>
+  unsigned NumImplicitDefaultConstructorsDeclared;<br>
<br>
   /// The number of implicitly-declared copy constructors.<br>
-  static unsigned NumImplicitCopyConstructors;<br>
+  unsigned NumImplicitCopyConstructors;<br>
<br>
   /// The number of implicitly-declared copy constructors for<br>
   /// which declarations were built.<br>
-  static unsigned NumImplicitCopyConstructorsDeclared;<br>
+  unsigned NumImplicitCopyConstructorsDeclared;<br>
<br>
   /// The number of implicitly-declared move constructors.<br>
-  static unsigned NumImplicitMoveConstructors;<br>
+  unsigned NumImplicitMoveConstructors;<br>
<br>
   /// The number of implicitly-declared move constructors for<br>
   /// which declarations were built.<br>
-  static unsigned NumImplicitMoveConstructorsDeclared;<br>
+  unsigned NumImplicitMoveConstructorsDeclared;<br>
<br>
   /// The number of implicitly-declared copy assignment operators.<br>
-  static unsigned NumImplicitCopyAssignmentOperators;<br>
+  unsigned NumImplicitCopyAssignmentOperators;<br>
<br>
   /// The number of implicitly-declared copy assignment operators for<br>
   /// which declarations were built.<br>
-  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;<br>
+  unsigned NumImplicitCopyAssignmentOperatorsDeclared;<br>
<br>
   /// The number of implicitly-declared move assignment operators.<br>
-  static unsigned NumImplicitMoveAssignmentOperators;<br>
+  unsigned NumImplicitMoveAssignmentOperators;<br>
<br>
   /// The number of implicitly-declared move assignment operators for<br>
   /// which declarations were built.<br>
-  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;<br>
+  unsigned NumImplicitMoveAssignmentOperatorsDeclared;<br>
<br>
   /// The number of implicitly-declared destructors.<br>
-  static unsigned NumImplicitDestructors;<br>
+  unsigned NumImplicitDestructors;<br>
<br>
   /// The number of implicitly-declared destructors for which<br>
   /// declarations were built.<br>
-  static unsigned NumImplicitDestructorsDeclared;<br>
+  unsigned NumImplicitDestructorsDeclared;<br>
<br>
 public:<br>
   /// Initialize built-in types.<br>
<br>
Modified: cfe/trunk/lib/AST/ASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795&r1=354794&r2=354795&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795&r1=354794&r2=354795&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ASTContext.cpp (original)<br>
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 08:08:46 2019<br>
@@ -94,19 +94,6 @@<br>
<br>
 using namespace clang;<br>
<br>
-unsigned ASTContext::NumImplicitDefaultConstructors;<br>
-unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;<br>
-unsigned ASTContext::NumImplicitCopyConstructors;<br>
-unsigned ASTContext::NumImplicitCopyConstructorsDeclared;<br>
-unsigned ASTContext::NumImplicitMoveConstructors;<br>
-unsigned ASTContext::NumImplicitMoveConstructorsDeclared;<br>
-unsigned ASTContext::NumImplicitCopyAssignmentOperators;<br>
-unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;<br>
-unsigned ASTContext::NumImplicitMoveAssignmentOperators;<br>
-unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;<br>
-unsigned ASTContext::NumImplicitDestructors;<br>
-unsigned ASTContext::NumImplicitDestructorsDeclared;<br>
-<br>
 enum FloatingRank {<br>
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank<br>
 };<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354795&r1=354794&r2=354795&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354795&r1=354794&r2=354795&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Feb 25 08:08:46 2019<br>
@@ -7971,14 +7971,14 @@ void Sema::ActOnFinishCXXMemberSpecifica<br>
 /// definition of the class is complete.<br>
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {<br>
   if (ClassDecl->needsImplicitDefaultConstructor()) {<br>
-    ++ASTContext::NumImplicitDefaultConstructors;<br>
+    ++getASTContext().NumImplicitDefaultConstructors;<br>
<br>
     if (ClassDecl->hasInheritedConstructor())<br>
       DeclareImplicitDefaultConstructor(ClassDecl);<br>
   }<br>
<br>
   if (ClassDecl->needsImplicitCopyConstructor()) {<br>
-    ++ASTContext::NumImplicitCopyConstructors;<br>
+    ++getASTContext().NumImplicitCopyConstructors;<br>
<br>
     // If the properties or semantics of the copy constructor couldn't be<br>
     // determined while the class was being declared, force a declaration<br>
@@ -8000,7 +8000,7 @@ void Sema::AddImplicitlyDeclaredMembersT<br>
   }<br>
<br>
   if (getLangOpts().CPlusPlus11 && ClassDecl->needsImplicitMoveConstructor()) {<br>
-    ++ASTContext::NumImplicitMoveConstructors;<br>
+    ++getASTContext().NumImplicitMoveConstructors;<br>
<br>
     if (ClassDecl->needsOverloadResolutionForMoveConstructor() ||<br>
         ClassDecl->hasInheritedConstructor())<br>
@@ -8008,7 +8008,7 @@ void Sema::AddImplicitlyDeclaredMembersT<br>
   }<br>
<br>
   if (ClassDecl->needsImplicitCopyAssignment()) {<br>
-    ++ASTContext::NumImplicitCopyAssignmentOperators;<br>
+    ++getASTContext().NumImplicitCopyAssignmentOperators;<br>
<br>
     // If we have a dynamic class, then the copy assignment operator may be<br>
     // virtual, so we have to declare it immediately. This ensures that, e.g.,<br>
@@ -8021,7 +8021,7 @@ void Sema::AddImplicitlyDeclaredMembersT<br>
   }<br>
<br>
   if (getLangOpts().CPlusPlus11 && ClassDecl->needsImplicitMoveAssignment()) {<br>
-    ++ASTContext::NumImplicitMoveAssignmentOperators;<br>
+    ++getASTContext().NumImplicitMoveAssignmentOperators;<br>
<br>
     // Likewise for the move assignment operator.<br>
     if (ClassDecl->isDynamicClass() ||<br>
@@ -8031,7 +8031,7 @@ void Sema::AddImplicitlyDeclaredMembersT<br>
   }<br>
<br>
   if (ClassDecl->needsImplicitDestructor()) {<br>
-    ++ASTContext::NumImplicitDestructors;<br>
+    ++getASTContext().NumImplicitDestructors;<br>
<br>
     // If we have a dynamic class, then the destructor may be virtual, so we<br>
     // have to declare the destructor immediately. This ensures that, e.g., it<br>
@@ -11013,7 +11013,7 @@ CXXConstructorDecl *Sema::DeclareImplici<br>
   DefaultCon->setTrivial(ClassDecl->hasTrivialDefaultConstructor());<br>
<br>
   // Note that we have declared this constructor.<br>
-  ++ASTContext::NumImplicitDefaultConstructorsDeclared;<br>
+  ++getASTContext().NumImplicitDefaultConstructorsDeclared;<br>
<br>
   Scope *S = getScopeForContext(ClassDecl);<br>
   CheckImplicitSpecialMemberDeclaration(S, DefaultCon);<br>
@@ -11286,7 +11286,7 @@ CXXDestructorDecl *Sema::DeclareImplicit<br>
                                 ClassDecl->hasTrivialDestructorForCall());<br>
<br>
   // Note that we have declared this destructor.<br>
-  ++ASTContext::NumImplicitDestructorsDeclared;<br>
+  ++getASTContext().NumImplicitDestructorsDeclared;<br>
<br>
   Scope *S = getScopeForContext(ClassDecl);<br>
   CheckImplicitSpecialMemberDeclaration(S, Destructor);<br>
@@ -11896,7 +11896,7 @@ CXXMethodDecl *Sema::DeclareImplicitCopy<br>
       : ClassDecl->hasTrivialCopyAssignment());<br>
<br>
   // Note that we have added this copy-assignment operator.<br>
-  ++ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;<br>
+  ++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;<br>
<br>
   Scope *S = getScopeForContext(ClassDecl);<br>
   CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);<br>
@@ -12219,7 +12219,7 @@ CXXMethodDecl *Sema::DeclareImplicitMove<br>
       : ClassDecl->hasTrivialMoveAssignment());<br>
<br>
   // Note that we have added this copy-assignment operator.<br>
-  ++ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;<br>
+  ++getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;<br>
<br>
   Scope *S = getScopeForContext(ClassDecl);<br>
   CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);<br>
@@ -12602,7 +12602,7 @@ CXXConstructorDecl *Sema::DeclareImplici<br>
            : ClassDecl->hasTrivialCopyConstructorForCall()));<br>
<br>
   // Note that we have declared this constructor.<br>
-  ++ASTContext::NumImplicitCopyConstructorsDeclared;<br>
+  ++getASTContext().NumImplicitCopyConstructorsDeclared;<br>
<br>
   Scope *S = getScopeForContext(ClassDecl);<br>
   CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);<br>
@@ -12732,7 +12732,7 @@ CXXConstructorDecl *Sema::DeclareImplici<br>
            : ClassDecl->hasTrivialMoveConstructorForCall()));<br>
<br>
   // Note that we have declared this constructor.<br>
-  ++ASTContext::NumImplicitMoveConstructorsDeclared;<br>
+  ++getASTContext().NumImplicitMoveConstructorsDeclared;<br>
<br>
   Scope *S = getScopeForContext(ClassDecl);<br>
   CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>