@@ -1892,7 +1892,7 @@ class PatternBindingEntry {
1892
1892
// / Whether the contents of this initializer were subsumed by
1893
1893
// / some other initialization, e.g., a lazy property's initializer
1894
1894
// / gets subsumed by the getter body.
1895
- Subsumed = 1 << 2 ,
1895
+ Subsumed = 1 << 2 ,
1896
1896
};
1897
1897
llvm::PointerIntPair<Pattern *, 3 , OptionSet<Flags>> PatternAndFlags;
1898
1898
@@ -1918,8 +1918,13 @@ class PatternBindingEntry {
1918
1918
StringRef InitStringRepresentation;
1919
1919
};
1920
1920
1921
+ enum class PatternFlags {
1922
+ IsText = 1 << 0 ,
1923
+ IsFullyValidated = 1 << 1 ,
1924
+ };
1921
1925
// / The initializer context used for this pattern binding entry.
1922
- llvm::PointerIntPair<DeclContext *, 1 , bool > InitContextAndIsText;
1926
+ llvm::PointerIntPair<DeclContext *, 2 , OptionSet<PatternFlags>>
1927
+ InitContextAndFlags;
1923
1928
1924
1929
// / Values captured by this initializer.
1925
1930
CaptureInfo Captures;
@@ -1931,22 +1936,21 @@ class PatternBindingEntry {
1931
1936
// Flags::Checked.
1932
1937
friend class PatternBindingEntryRequest ;
1933
1938
1934
- bool IsFullyValidated = false ;
1935
-
1936
1939
bool isFullyValidated () const {
1937
- return IsFullyValidated;
1940
+ return InitContextAndFlags.getInt ().contains (
1941
+ PatternFlags::IsFullyValidated);
1938
1942
}
1939
1943
void setFullyValidated () {
1940
- IsFullyValidated = true ;
1944
+ InitContextAndFlags.setInt (InitContextAndFlags.getInt () |
1945
+ PatternFlags::IsFullyValidated);
1941
1946
}
1942
1947
1943
1948
public:
1944
1949
// / \p E is the initializer as parsed.
1945
1950
PatternBindingEntry (Pattern *P, SourceLoc EqualLoc, Expr *E,
1946
1951
DeclContext *InitContext)
1947
- : PatternAndFlags(P, {}), InitExpr({E, E, EqualLoc}),
1948
- InitContextAndIsText ({InitContext, false }) {
1949
- }
1952
+ : PatternAndFlags(P, {}), InitExpr({E, E, EqualLoc}),
1953
+ InitContextAndFlags ({InitContext, None}) {}
1950
1954
1951
1955
Pattern *getPattern () const { return PatternAndFlags.getPointer (); }
1952
1956
void setPattern (Pattern *P) { PatternAndFlags.setPointer (P); }
@@ -1956,7 +1960,7 @@ class PatternBindingEntry {
1956
1960
1957
1961
Expr *getInit () const {
1958
1962
if (PatternAndFlags.getInt ().contains (Flags::Removed) ||
1959
- InitContextAndIsText .getInt ())
1963
+ InitContextAndFlags .getInt (). contains (PatternFlags::IsText ))
1960
1964
return nullptr ;
1961
1965
return InitExpr.initAfterSynthesis ;
1962
1966
}
@@ -1976,7 +1980,8 @@ class PatternBindingEntry {
1976
1980
// / deserialized from a partial module.
1977
1981
void setInitStringRepresentation (StringRef str) {
1978
1982
InitStringRepresentation = str;
1979
- InitContextAndIsText.setInt (true );
1983
+ InitContextAndFlags.setInt (InitContextAndFlags.getInt () |
1984
+ PatternFlags::IsText);
1980
1985
}
1981
1986
1982
1987
// / Whether this pattern entry can generate a string representation of its
@@ -1985,12 +1990,14 @@ class PatternBindingEntry {
1985
1990
1986
1991
// / Retrieve the location of the equal '=' token.
1987
1992
SourceLoc getEqualLoc () const {
1988
- return InitContextAndIsText.getInt () ? SourceLoc () : InitExpr.EqualLoc ;
1993
+ return InitContextAndFlags.getInt ().contains (PatternFlags::IsText)
1994
+ ? SourceLoc ()
1995
+ : InitExpr.EqualLoc ;
1989
1996
}
1990
1997
1991
1998
// / Set the location of the equal '=' token.
1992
1999
void setEqualLoc (SourceLoc equalLoc) {
1993
- assert (!InitContextAndIsText .getInt () &&
2000
+ assert (!InitContextAndFlags .getInt (). contains (PatternFlags::IsText ) &&
1994
2001
" cannot set equal loc for textual initializer" );
1995
2002
InitExpr.EqualLoc = equalLoc;
1996
2003
}
@@ -2021,13 +2028,11 @@ class PatternBindingEntry {
2021
2028
2022
2029
// Retrieve the declaration context for the initializer.
2023
2030
DeclContext *getInitContext () const {
2024
- return InitContextAndIsText .getPointer ();
2031
+ return InitContextAndFlags .getPointer ();
2025
2032
}
2026
2033
2027
2034
// / Override the initializer context.
2028
- void setInitContext (DeclContext *dc) {
2029
- InitContextAndIsText.setPointer (dc);
2030
- }
2035
+ void setInitContext (DeclContext *dc) { InitContextAndFlags.setPointer (dc); }
2031
2036
2032
2037
SourceLoc getStartLoc () const ;
2033
2038
0 commit comments