summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-05-01 21:29:53 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-05-01 21:29:53 +0000
commit0e439960b816e1721fecf32bca8a1c8f9e1f2b0b (patch)
tree479492832400601c939d734949481b0d44f5bb6f /clang/lib
parent56b579a3735c944580b3adca99b52d907cccfc9b (diff)
downloadbcm5719-llvm-0e439960b816e1721fecf32bca8a1c8f9e1f2b0b.tar.gz
bcm5719-llvm-0e439960b816e1721fecf32bca8a1c8f9e1f2b0b.zip
Move the state bits in DeclRefExpr out of the pointer union and into
a bitfield in the base class. DREs weren't using any bits here past the normal Expr bits, so we have plenty of room. This makes the common case of getting a Decl out of a DRE no longer need to do any masking etc. Also, while here, clean up code to use the accessor methods rather than directly poking these bits, and provide a nice comment for DREs that includes the information previously attached to the bits going into the pointer union. No functionality changed here, but DREs should be a tad faster now. llvm-svn: 130666
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp20
-rw-r--r--clang/lib/Serialization/ASTReaderStmt.cpp14
2 files changed, 15 insertions, 19 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 2a5917c4594..cd5a63aab51 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -279,17 +279,18 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
const TemplateArgumentListInfo *TemplateArgs,
QualType T, ExprValueKind VK)
: Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false),
- DecoratedD(D,
- (QualifierLoc? HasQualifierFlag : 0) |
- (TemplateArgs ? HasExplicitTemplateArgumentListFlag : 0)),
- Loc(NameLoc) {
+ D(D), Loc(NameLoc) {
+ DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
if (QualifierLoc) {
+ DeclRefExprBits.HasQualifier = 1;
NameQualifier *NQ = getNameQualifier();
NQ->QualifierLoc = QualifierLoc;
}
-
- if (TemplateArgs)
+
+ DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0;
+ if (TemplateArgs) {
getExplicitTemplateArgs().initializeFrom(*TemplateArgs);
+ }
computeDependence();
}
@@ -299,15 +300,14 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
const TemplateArgumentListInfo *TemplateArgs,
QualType T, ExprValueKind VK)
: Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false),
- DecoratedD(D,
- (QualifierLoc? HasQualifierFlag : 0) |
- (TemplateArgs ? HasExplicitTemplateArgumentListFlag : 0)),
- Loc(NameInfo.getLoc()), DNLoc(NameInfo.getInfo()) {
+ D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.getInfo()) {
+ DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
if (QualifierLoc) {
NameQualifier *NQ = getNameQualifier();
NQ->QualifierLoc = QualifierLoc;
}
+ DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0;
if (TemplateArgs)
getExplicitTemplateArgs().initializeFrom(*TemplateArgs);
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 83b3907f581..f0b5abaf3bf 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -425,21 +425,17 @@ void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
VisitExpr(E);
- bool HasQualifier = Record[Idx++];
- bool HasExplicitTemplateArgs = Record[Idx++];
+ E->DeclRefExprBits.HasQualifier = Record[Idx++];
+ E->DeclRefExprBits.HasExplicitTemplateArgs = Record[Idx++];
unsigned NumTemplateArgs = 0;
- if (HasExplicitTemplateArgs)
+ if (E->hasExplicitTemplateArgs())
NumTemplateArgs = Record[Idx++];
- E->DecoratedD.setInt((HasQualifier? DeclRefExpr::HasQualifierFlag : 0) |
- (HasExplicitTemplateArgs
- ? DeclRefExpr::HasExplicitTemplateArgumentListFlag : 0));
-
- if (HasQualifier)
+ if (E->hasQualifier())
E->getNameQualifier()->QualifierLoc
= Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- if (HasExplicitTemplateArgs)
+ if (E->hasExplicitTemplateArgs())
ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
NumTemplateArgs);
OpenPOWER on IntegriCloud