Skip to content

Commit

Permalink
Stash interim splice
Browse files Browse the repository at this point in the history
  • Loading branch information
zebullon committed Oct 27, 2024
1 parent a3cbe57 commit 9c0c904
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 76 deletions.
2 changes: 0 additions & 2 deletions clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "clang/Basic/OperatorPrecedence.h"
#include "clang/Lex/CodeCompletionHandler.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Ownership.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
Expand Down Expand Up @@ -3972,7 +3971,6 @@ class Parser : public CodeCompletionHandler {
bool ParseCXXSpliceSpecifier(SourceLocation TemplateKWLoc = {});

TypeResult ParseCXXSpliceAsType(bool AllowDependent, bool Complain);
DeclResult ParseCXXSpliceAsAttributes();
ExprResult ParseCXXSpliceAsExpr(bool AllowMemberReference);
DeclResult ParseCXXSpliceAsNamespace();
TemplateTy ParseCXXSpliceAsTemplate(); // TODO(P2996): Do we use this?
Expand Down
6 changes: 0 additions & 6 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -15199,9 +15199,6 @@ class Sema final : public SemaBase {
DeclResult ActOnCXXSpliceExpectingNamespace(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice);
DeclResult ActOnCXXSpliceExpectingAttributes(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice);
TemplateTy ActOnCXXSpliceExpectingTemplate(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice,
Expand Down Expand Up @@ -15265,9 +15262,6 @@ class Sema final : public SemaBase {
DeclResult BuildReflectionSpliceNamespace(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice);
DeclResult BuildReflectionSpliceAttributes(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice);
TemplateTy BuildReflectionSpliceTemplate(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice,
Expand Down
52 changes: 6 additions & 46 deletions clang/lib/Parse/ParseDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
//===----------------------------------------------------------------------===//

#include "clang/AST/ASTContext.h"
#include "clang/AST/Attrs.inc"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/PrettyDeclStackTrace.h"
#include "clang/Basic/AttributeCommonInfo.h"
#include "clang/Basic/Attributes.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TokenKinds.h"
Expand Down Expand Up @@ -5064,8 +5062,8 @@ bool Parser::tryParseSpliceAttrSpecifier(ParsedAttributes &Attrs,
CXXSpliceSpecifierExpr *SpliceExpr =
dyn_cast<CXXSpliceSpecifierExpr>(Result.get());
Diag(SpliceExpr->getExprLoc(), diag::p3385_trace_execution_checkpoint)
<< "parsed splice expression in attribute";
<< "successfully parsed splice expression in attribute";

// Finish with consuming close ']' ']'
SourceLocation CloseLoc = Tok.getLocation();
if (ExpectAndConsume(tok::r_square))
Expand All @@ -5085,7 +5083,7 @@ bool Parser::tryParseSpliceAttrSpecifier(ParsedAttributes &Attrs,
// }
}
return true;
}
}

/// Parse a C++11 or C23 attribute-specifier.
///
Expand Down Expand Up @@ -5126,8 +5124,6 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
return;
}

Diag(Tok.getLocation(), diag::p3385_trace_execution_checkpoint) << "1";

if (Tok.isRegularKeywordAttribute()) {
SourceLocation Loc = Tok.getLocation();
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
Expand Down Expand Up @@ -5200,48 +5196,12 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
SourceLocation ScopeLoc, AttrLoc;
IdentifierInfo *ScopeName = nullptr, *AttrName = nullptr;

// Try parsing a `[: :]` expression
if (!tryParseSpliceAttrSpecifier(Attrs, EndLoc)) {
// I'll forget in 10 minutes but... in clang convention, we end up here
// when we actually did succeed... so we quit parsing attributes here.
return;
}
// // TODO externalize this into a dedicated function
// // Try parsing a [: meta-info :] immediately following '[' '['
// if (Tok.is(tok::l_splice)) {
// if (ParseCXXSpliceSpecifier()) {
// // FIXME diagnostic is terrible...
// Diag(Tok.getLocation(), diag::p3385_err_attribute_splicing_error)
// << "invalid expression in attribute splicing";
// return;
// }
// if (Tok.is(tok::annot_splice)) {
// ExprResult Result = getExprAnnotation(Tok);
// ConsumeAnnotationToken();


// CXXSpliceSpecifierExpr *SpliceExpr =
// dyn_cast<CXXSpliceSpecifierExpr>(Result.get());
// Diag(SpliceExpr->getExprLoc(), diag::p3385_trace_execution_checkpoint)
// << "parsed splice expression in attribute";

// // Finish with consuming close ']' ']'
// SourceLocation CloseLoc = Tok.getLocation();
// if (ExpectAndConsume(tok::r_square))
// SkipUntil(tok::r_square);
// else if (Tok.is(tok::r_square))
// checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
// if (EndLoc)
// *EndLoc = Tok.getLocation();
// if (ExpectAndConsume(tok::r_square))
// SkipUntil(tok::r_square);

// return;
// // if (Actions.ActOnCXXNestedNameSpecifierReflectionSplice(SS, SpliceExpr,
// // CCLoc)) {
// // SS.SetInvalid(SourceRange(SpliceExpr->getExprLoc(), CCLoc));
// // return true;
// // }
// }
// return;
// }

if (Tok.is(tok::equal) && getLangOpts().AnnotationAttributes) {
// This is a C++2c annotation.
Expand Down
7 changes: 0 additions & 7 deletions clang/lib/Parse/ParseReflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,6 @@ DeclResult Parser::ParseCXXSpliceAsNamespace() {
return Result;
}


DeclResult Parser::ParseCXXSpliceAsAttributes()
{
assert(Tok.is(tok::l_splice()) && "expected splice");
return DeclResult{};
}

Parser::TemplateTy Parser::ParseCXXSpliceAsTemplate() {
assert(Tok.is(tok::annot_splice) && "expected annot_splice");

Expand Down
15 changes: 0 additions & 15 deletions clang/lib/Sema/SemaReflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,13 +883,6 @@ DeclResult Sema::ActOnCXXSpliceExpectingNamespace(SourceLocation LSpliceLoc,
return BuildReflectionSpliceNamespace(LSpliceLoc, Operand, RSpliceLoc);
}

DeclResult Sema::ActOnCXXSpliceExpectingAttributes(SourceLocation LSpliceLoc,
Expr *Operand,
SourceLocation RSpliceLoc) {
// TODO P3385 : build here
return DeclResult{};
}

Sema::TemplateTy Sema::ActOnCXXSpliceExpectingTemplate(
SourceLocation LSpliceLoc, Expr *Operand, SourceLocation RSpliceLoc,
bool Complain) {
Expand Down Expand Up @@ -1521,14 +1514,6 @@ ExprResult Sema::BuildReflectionSpliceExpr(
TArgs, AllowMemberReference);
}

DeclResult Sema::BuildReflectionSpliceAttributes(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice)
{
// TODO P3385
return DeclResult{};
}

DeclResult Sema::BuildReflectionSpliceNamespace(SourceLocation LSplice,
Expr *Operand,
SourceLocation RSplice) {
Expand Down

0 comments on commit 9c0c904

Please sign in to comment.