@@ -1855,29 +1855,52 @@ class Sema {
1855
1855
/// Describes the result of the name lookup and resolution performed
1856
1856
/// by \c ClassifyName().
1857
1857
enum NameClassificationKind {
1858
+ /// This name is not a type or template in this context, but might be
1859
+ /// something else.
1858
1860
NC_Unknown,
1861
+ /// Classification failed; an error has been produced.
1859
1862
NC_Error,
1863
+ /// The name has been typo-corrected to a keyword.
1860
1864
NC_Keyword,
1865
+ /// The name was classified as a type.
1861
1866
NC_Type,
1862
- NC_Expression,
1863
- NC_NestedNameSpecifier,
1867
+ /// The name was classified as a specific non-type, non-template
1868
+ /// declaration. ActOnNameClassifiedAsNonType should be called to
1869
+ /// convert the declaration to an expression.
1870
+ NC_NonType,
1871
+ /// The name was classified as an ADL-only function name.
1872
+ /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
1873
+ /// result to an expression.
1874
+ NC_UndeclaredNonType,
1875
+ /// The name denotes a member of a dependent type that could not be
1876
+ /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
1877
+ /// convert the result to an expression.
1878
+ NC_DependentNonType,
1879
+ /// The name was classified as a non-type, and an expression representing
1880
+ /// that name has been formed.
1881
+ NC_ContextIndependentExpr,
1882
+ /// The name was classified as a template whose specializations are types.
1864
1883
NC_TypeTemplate,
1884
+ /// The name was classified as a variable template name.
1865
1885
NC_VarTemplate,
1886
+ /// The name was classified as a function template name.
1866
1887
NC_FunctionTemplate,
1888
+ /// The name was classified as an ADL-only function template name.
1867
1889
NC_UndeclaredTemplate,
1868
1890
};
1869
1891
1870
1892
class NameClassification {
1871
1893
NameClassificationKind Kind;
1872
- ExprResult Expr;
1873
- TemplateName Template;
1874
- ParsedType Type;
1894
+ union {
1895
+ ExprResult Expr;
1896
+ NamedDecl *NonTypeDecl;
1897
+ TemplateName Template;
1898
+ ParsedType Type;
1899
+ };
1875
1900
1876
1901
explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
1877
1902
1878
1903
public:
1879
- NameClassification(ExprResult Expr) : Kind(NC_Expression), Expr(Expr) {}
1880
-
1881
1904
NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
1882
1905
1883
1906
NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
@@ -1890,8 +1913,24 @@ class Sema {
1890
1913
return NameClassification(NC_Unknown);
1891
1914
}
1892
1915
1893
- static NameClassification NestedNameSpecifier() {
1894
- return NameClassification(NC_NestedNameSpecifier);
1916
+ static NameClassification ContextIndependentExpr(ExprResult E) {
1917
+ NameClassification Result(NC_ContextIndependentExpr);
1918
+ Result.Expr = E;
1919
+ return Result;
1920
+ }
1921
+
1922
+ static NameClassification NonType(NamedDecl *D) {
1923
+ NameClassification Result(NC_NonType);
1924
+ Result.NonTypeDecl = D;
1925
+ return Result;
1926
+ }
1927
+
1928
+ static NameClassification UndeclaredNonType() {
1929
+ return NameClassification(NC_UndeclaredNonType);
1930
+ }
1931
+
1932
+ static NameClassification DependentNonType() {
1933
+ return NameClassification(NC_DependentNonType);
1895
1934
}
1896
1935
1897
1936
static NameClassification TypeTemplate(TemplateName Name) {
@@ -1920,14 +1959,19 @@ class Sema {
1920
1959
1921
1960
NameClassificationKind getKind() const { return Kind; }
1922
1961
1962
+ ExprResult getExpression() const {
1963
+ assert(Kind == NC_ContextIndependentExpr);
1964
+ return Expr;
1965
+ }
1966
+
1923
1967
ParsedType getType() const {
1924
1968
assert(Kind == NC_Type);
1925
1969
return Type;
1926
1970
}
1927
1971
1928
- ExprResult getExpression () const {
1929
- assert(Kind == NC_Expression );
1930
- return Expr ;
1972
+ NamedDecl *getNonTypeDecl () const {
1973
+ assert(Kind == NC_NonType );
1974
+ return NonTypeDecl ;
1931
1975
}
1932
1976
1933
1977
TemplateName getTemplateName() const {
@@ -1971,17 +2015,29 @@ class Sema {
1971
2015
/// \param NextToken The token following the identifier. Used to help
1972
2016
/// disambiguate the name.
1973
2017
///
1974
- /// \param IsAddressOfOperand True if this name is the operand of a unary
1975
- /// address of ('&') expression, assuming it is classified as an
1976
- /// expression.
1977
- ///
1978
2018
/// \param CCC The correction callback, if typo correction is desired.
1979
2019
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
1980
2020
IdentifierInfo *&Name, SourceLocation NameLoc,
1981
2021
const Token &NextToken,
1982
- bool IsAddressOfOperand,
1983
2022
CorrectionCandidateCallback *CCC = nullptr);
1984
2023
2024
+ /// Act on the result of classifying a name as an undeclared (ADL-only)
2025
+ /// non-type declaration.
2026
+ ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name,
2027
+ SourceLocation NameLoc);
2028
+ /// Act on the result of classifying a name as an undeclared member of a
2029
+ /// dependent base class.
2030
+ ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS,
2031
+ IdentifierInfo *Name,
2032
+ SourceLocation NameLoc,
2033
+ bool IsAddressOfOperand);
2034
+ /// Act on the result of classifying a name as a specific non-type
2035
+ /// declaration.
2036
+ ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS,
2037
+ NamedDecl *Found,
2038
+ SourceLocation NameLoc,
2039
+ const Token &NextToken);
2040
+
1985
2041
/// Describes the detailed kind of a template name. Used in diagnostics.
1986
2042
enum class TemplateNameKindForDiagnostics {
1987
2043
ClassTemplate,
@@ -3407,6 +3463,7 @@ class Sema {
3407
3463
LookupNameKind NameKind,
3408
3464
RedeclarationKind Redecl
3409
3465
= NotForRedeclaration);
3466
+ bool LookupBuiltin(LookupResult &R);
3410
3467
bool LookupName(LookupResult &R, Scope *S,
3411
3468
bool AllowBuiltinCreation = false);
3412
3469
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
@@ -4389,6 +4446,10 @@ class Sema {
4389
4446
TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
4390
4447
ArrayRef<Expr *> Args = None, TypoExpr **Out = nullptr);
4391
4448
4449
+ DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S,
4450
+ IdentifierInfo *II);
4451
+ ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV);
4452
+
4392
4453
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S,
4393
4454
IdentifierInfo *II,
4394
4455
bool AllowBuiltinCreation=false);
0 commit comments