]> granicus.if.org Git - clang/commitdiff
Pack UsingDecl more.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 7 Jan 2012 19:09:05 +0000 (19:09 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 7 Jan 2012 19:09:05 +0000 (19:09 +0000)
88 -> 80 bytes on x86_64.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147736 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp

index 588b1993d93b2b0748d6016f4d87ab71269c8bfe..17c82ca3ef2a233e1953edaadb124cb8c457be40 100644 (file)
@@ -19,6 +19,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/UnresolvedSet.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallPtrSet.h"
 
 namespace clang {
@@ -2472,18 +2473,16 @@ class UsingDecl : public NamedDecl {
   DeclarationNameLoc DNLoc;
 
   /// \brief The first shadow declaration of the shadow decl chain associated
-  /// with this using declaration.
-  UsingShadowDecl *FirstUsingShadow;
-
-  // \brief Has 'typename' keyword.
-  bool IsTypeName;
+  /// with this using declaration. The bool member of the pair store whether
+  /// this decl has the 'typename' keyword.
+  llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
 
   UsingDecl(DeclContext *DC, SourceLocation UL,
             NestedNameSpecifierLoc QualifierLoc,
             const DeclarationNameInfo &NameInfo, bool IsTypeNameArg)
     : NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
       UsingLocation(UL), QualifierLoc(QualifierLoc),
-      DNLoc(NameInfo.getInfo()), FirstUsingShadow(0),IsTypeName(IsTypeNameArg) {
+      DNLoc(NameInfo.getInfo()), FirstUsingShadow(0IsTypeNameArg) {
   }
 
 public:
@@ -2507,10 +2506,10 @@ public:
   }
 
   /// \brief Return true if the using declaration has 'typename'.
-  bool isTypeName() const { return IsTypeName; }
+  bool isTypeName() const { return FirstUsingShadow.getInt(); }
 
   /// \brief Sets whether the using declaration has 'typename'.
-  void setTypeName(bool TN) { IsTypeName = TN; }
+  void setTypeName(bool TN) { FirstUsingShadow.setInt(TN); }
 
   /// \brief Iterates through the using shadow declarations assosiated with
   /// this using declaration.
@@ -2551,7 +2550,7 @@ public:
   };
 
   shadow_iterator shadow_begin() const {
-    return shadow_iterator(FirstUsingShadow);
+    return shadow_iterator(FirstUsingShadow.getPointer());
   }
   shadow_iterator shadow_end() const { return shadow_iterator(); }
 
index f820e9b57ffdfe8f56861f5c352517dcaf33e9ab..f56d4655beff3f6c026f3f55d1cc02b85197e85d 100644 (file)
@@ -1839,9 +1839,9 @@ void UsingDecl::addShadowDecl(UsingShadowDecl *S) {
          "declaration already in set");
   assert(S->getUsingDecl() == this);
 
-  if (FirstUsingShadow)
-    S->UsingOrNextShadow = FirstUsingShadow;
-  FirstUsingShadow = S;
+  if (FirstUsingShadow.getPointer())
+    S->UsingOrNextShadow = FirstUsingShadow.getPointer();
+  FirstUsingShadow.setPointer(S);
 }
 
 void UsingDecl::removeShadowDecl(UsingShadowDecl *S) {
@@ -1851,13 +1851,14 @@ void UsingDecl::removeShadowDecl(UsingShadowDecl *S) {
 
   // Remove S from the shadow decl chain. This is O(n) but hopefully rare.
 
-  if (FirstUsingShadow == S) {
-    FirstUsingShadow = dyn_cast<UsingShadowDecl>(S->UsingOrNextShadow);
+  if (FirstUsingShadow.getPointer() == S) {
+    FirstUsingShadow.setPointer(
+      dyn_cast<UsingShadowDecl>(S->UsingOrNextShadow));
     S->UsingOrNextShadow = this;
     return;
   }
 
-  UsingShadowDecl *Prev = FirstUsingShadow;
+  UsingShadowDecl *Prev = FirstUsingShadow.getPointer();
   while (Prev->UsingOrNextShadow != S)
     Prev = cast<UsingShadowDecl>(Prev->UsingOrNextShadow);
   Prev->UsingOrNextShadow = S->UsingOrNextShadow;
index 6e73388da1628278f2e6070e48e3c9839fba72fe..56e2d085e383366e63b7a381c4e8138140838b59 100644 (file)
@@ -998,7 +998,7 @@ void ASTDeclReader::VisitUsingDecl(UsingDecl *D) {
   D->setUsingLocation(ReadSourceLocation(Record, Idx));
   D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
   ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx);
-  D->FirstUsingShadow = ReadDeclAs<UsingShadowDecl>(Record, Idx);
+  D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>(Record, Idx));
   D->setTypeName(Record[Idx++]);
   if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx))
     Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
index 45ce7799fa345e058983e20354fc35240442a90f..46e251b80fc4dc30e079eca1d170a2a439fb3e34 100644 (file)
@@ -862,7 +862,7 @@ void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) {
   Writer.AddSourceLocation(D->getUsingLocation(), Record);
   Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
   Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
-  Writer.AddDeclRef(D->FirstUsingShadow, Record);
+  Writer.AddDeclRef(D->FirstUsingShadow.getPointer(), Record);
   Record.push_back(D->isTypeName());
   Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);
   Code = serialization::DECL_USING;