forked from OSchip/llvm-project
Pack UsingDecl more.
88 -> 80 bytes on x86_64. llvm-svn: 147736
This commit is contained in:
parent
4b501a2ed8
commit
e78f8ee57f
|
@ -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(0, IsTypeNameArg) {
|
||||
}
|
||||
|
||||
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(); }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue