r176606 - Add a hasExternalStorageAsWritten helper. No functionality change.

Rafael Espindola rafael.espindola at gmail.com
Wed Mar 6 17:42:44 PST 2013


Author: rafael
Date: Wed Mar  6 19:42:44 2013
New Revision: 176606

URL: http://llvm.org/viewvc/llvm-project?rev=176606&view=rev
Log:
Add a hasExternalStorageAsWritten helper. No functionality change.

It is possible that some of the current uses of
"getStorageClassAsWritten() == SC_Extern" should use this but I don't know
enough about SC_PrivateExtern to change and test them.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=176606&r1=176605&r2=176606&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Mar  6 19:42:44 2013
@@ -800,6 +800,13 @@ public:
            getStorageClass() == SC_PrivateExtern;
   }
 
+  /// hasExternalStorageAsWritten - Returns true if a variable was written
+  /// with extern or __private_extern__ storage.
+  bool hasExternalStorageAsWritten() const {
+    return getStorageClassAsWritten() == SC_Extern ||
+           getStorageClassAsWritten() == SC_PrivateExtern;
+  }
+
   /// hasGlobalStorage - Returns true for all variables that do not
   ///  have local storage.  This includs all global variables as well
   ///  as static variables declared within a function.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=176606&r1=176605&r2=176606&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Mar  6 19:42:44 2013
@@ -1049,8 +1049,7 @@ static LinkageInfo getLVForLocalDecl(con
   }
 
   if (const VarDecl *Var = dyn_cast<VarDecl>(D)) {
-    if (Var->getStorageClassAsWritten() == SC_Extern ||
-        Var->getStorageClassAsWritten() == SC_PrivateExtern) {
+    if (Var->hasExternalStorageAsWritten()) {
       if (Var->isInAnonymousNamespace() &&
           !Var->getDeclContext()->isExternCContext())
         return LinkageInfo::uniqueExternal();
@@ -1600,9 +1599,8 @@ VarDecl::DefinitionKind VarDecl::isThisD
   // AST for 'extern "C" int foo;' is annotated with 'extern'.
   if (hasExternalStorage())
     return DeclarationOnly;
-  
-  if (getStorageClassAsWritten() == SC_Extern ||
-       getStorageClassAsWritten() == SC_PrivateExtern) {
+
+  if (hasExternalStorageAsWritten()) {
     for (const VarDecl *PrevVar = getPreviousDecl();
          PrevVar; PrevVar = PrevVar->getPreviousDecl()) {
       if (PrevVar->getLinkage() == InternalLinkage)





More information about the cfe-commits mailing list