Skip to content

Commit

Permalink
Add flag
Browse files Browse the repository at this point in the history
  • Loading branch information
zebullon committed Jan 5, 2025
1 parent 85fbac6 commit 926717e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticFrontendKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def err_fe_reflection_incompatible_with_blocks : Error<
def err_fe_parameter_reflection_without_reflection : Error<
"cannot specify '-fparameter-reflection' without '-freflection'">,
DefaultFatal;
def err_fe_attribute_reflection_without_reflection : Error<
"cannot specify '-fattribute-reflection' without '-freflection'">,
DefaultFatal;
def err_fe_dependency_file_requires_MT : Error<
"-dependency-file requires at least one -MT or -MQ option">;
def err_fe_invalid_plugin_name : Error<
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVT
FEATURE(reflection, LangOpts.Reflection)
FEATURE(reflection_new_syntax, LangOpts.ReflectionNewSyntax)
FEATURE(parameter_reflection, LangOpts.ParameterReflection)
FEATURE(attribute_reflection, LangOpts.AttributeReflection)
FEATURE(expansion_statements, LangOpts.ExpansionStatements)
FEATURE(annotation_attributes, LangOpts.AnnotationAttributes)
FEATURE(consteval_blocks, LangOpts.ConstevalBlocks)
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ LANGOPT(OpenACC , 1, 0, "OpenACC Enabled")
LANGOPT(Reflection , 1, 0, "Experimental C++26 Reflection")
LANGOPT(ReflectionNewSyntax , 1, 0, "New syntax for C++26 Reflection")
LANGOPT(ParameterReflection , 1, 0, "Augments C++26 Reflection with function parameter reflection")
LANGOPT(AttributeReflection , 1, 0, "Augments C++26 Reflection with standard attribute reflection")
LANGOPT(ExpansionStatements , 1, 0, "Experimental C++26 Expansion Statements")
LANGOPT(AnnotationAttributes, 1, 0, "Experimental C++26 support for annotations")
LANGOPT(ConstevalBlocks, 1, 0, "Experimental C++26 support for consteval blocks")
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3504,6 +3504,11 @@ defm parameter_reflection : BoolFOption<"parameter-reflection",
PosFlag<SetTrue, [], [ClangOption, CC1Option],
"Enable proposed parameter reflection as described by P3096">,
NegFlag<SetFalse>>;
defm attribute_reflection : BoolFOption<"attribute-reflection",
LangOpts<"AttributeReflection">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption, CC1Option],
"Enable proposed parameter reflection as described by P3385">,
NegFlag<SetFalse>>;
defm expansion_statements : BoolFOption<"expansion-statements",
LangOpts<"ExpansionStatements">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption, CC1Option],
Expand Down
8 changes: 6 additions & 2 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,12 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
if (LangOpts.Reflection) {
if (LangOpts.Blocks && !LangOpts.ReflectionNewSyntax)
Diags.Report(diag::err_fe_reflection_incompatible_with_blocks);
} else if (LangOpts.ParameterReflection) {
Diags.Report(diag::err_fe_parameter_reflection_without_reflection);
} else {
if (LangOpts.ParameterReflection) {
Diags.Report(diag::err_fe_parameter_reflection_without_reflection);
} else if (LangOpts.AttributeReflection) {
Diags.Report(diag::err_fe_attribute_reflection_without_reflection);
}
}

// The -f[no-]raw-string-literals option is only valid in C and in C++
Expand Down
11 changes: 9 additions & 2 deletions clang/lib/Parse/ParseDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5088,11 +5088,18 @@ bool Parser::tryParseSpliceAttrSpecifier(ParsedAttributes &Attrs,
if (!Tok.is(tok::l_splice)) {
return true;
}
if(!getLangOpts().AttributeReflection) {
Diag(Tok.getLocation(), diag::p3385_err_attribute_splicing_error)
<< "attribute splicing is gated behind -fattribute-reflection";
SkipUntil(tok::r_splice);
ExpectAndConsume(tok::r_splice);
}

if (ParseCXXSpliceSpecifier()) {
// FIXME diagnostic is terrible...
Diag(Tok.getLocation(), diag::p3385_err_attribute_splicing_error)
<< "invalid expression in attribute splicing";
return true; // yea...Dont know what kind of convention that is
return true;
}
if (!Tok.is(tok::annot_splice)) {
return true;
Expand All @@ -5106,7 +5113,7 @@ bool Parser::tryParseSpliceAttrSpecifier(ParsedAttributes &Attrs,
ExprResult Result = getExprAnnotation(Tok);
ConsumeAnnotationToken();

// TODO export to ActOnBlablabla() is the `iDiOmAtIc WaY`
// TODO offload to ActOnBlablabla() is the `iDiOmAtIc WaY`
//
auto *SpliceExpr = cast<CXXSpliceSpecifierExpr>(Result.get());
Expr::EvalResult ER;
Expand Down

0 comments on commit 926717e

Please sign in to comment.