Skip to content

Commit

Permalink
Bootstrap a nullable return value.
Browse files Browse the repository at this point in the history
  • Loading branch information
pgoodman committed Sep 13, 2024
1 parent 0251b26 commit a2dc4f0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 4 additions & 0 deletions bin/BootstrapTypes/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,10 @@ std::map<std::pair<std::string, std::string>, std::string> kConditionalNullptr{
" if (!self.isAlignmentExpr()) {\n"
" return std::nullopt;\n"
" }\n"},
{{"AlignedAttr", "Alignment"},
" if (!self.isAlignmentExpr()) {\n"
" return std::nullopt;\n"
" }\n"},
{{"CXXPseudoDestructorExpr", "ScopeType"},
" if (!self.getScopeTypeInfo()) {\n"
" return std::nullopt;\n"
Expand Down
2 changes: 1 addition & 1 deletion include/pasta/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5446,7 +5446,7 @@ class AlignedAttr : public InheritableAttr {
PASTA_DECLARE_DEFAULT_CONSTRUCTORS(AlignedAttr)
PASTA_DECLARE_BASE_OPERATORS(Attr, AlignedAttr)
PASTA_DECLARE_BASE_OPERATORS(InheritableAttr, AlignedAttr)
uint32_t Alignment(void) const;
std::optional<uint32_t> Alignment(void) const;
std::optional<::pasta::Expr> AlignmentExpression(void) const;
std::optional<::pasta::Type> AlignmentType(void) const;
std::optional<unsigned> CachedAlignmentValue(void) const;
Expand Down
5 changes: 4 additions & 1 deletion lib/AST/Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8703,8 +8703,11 @@ AlignedAttr::AlignedAttr(
PASTA_DEFINE_BASE_OPERATORS(Attr, AlignedAttr)
PASTA_DEFINE_BASE_OPERATORS(InheritableAttr, AlignedAttr)
// 1: AlignedAttr::Clone
uint32_t AlignedAttr::Alignment(void) const {
std::optional<uint32_t> AlignedAttr::Alignment(void) const {
auto &self = *(u.AlignedAttr);
if (!self.isAlignmentExpr()) {
return std::nullopt;
}
decltype(auto) val = self.getAlignment(ast->ci->getASTContext());
return val;
}
Expand Down
8 changes: 1 addition & 7 deletions lib/Compile/Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ Result<AST, std::string> CompileJob::Run(void) const {
const ArgumentVector &argv = Arguments();
llvm::ArrayRef<const char *> argv_arr(argv.Argv(), argv.Size());

#ifdef PASTA_LLVM_18
clang::LangOptions &lang_opts = invocation.getLangOpts();
#else
clang::LangOptions &lang_opts = *invocation.getLangOpts();
#endif

// NOTE(pag): Don't default enable `HasLegalHalfType`, as some local variables
// might be named `half`.
Expand Down Expand Up @@ -322,7 +318,7 @@ Result<AST, std::string> CompileJob::Run(void) const {
// converting them into annotation attributes.
lang_opts.UnknownAttrAnnotate = true;

// This is a path that makes attributed types store their attributes.
// This is a patch that makes attributed types store their attributes.
lang_opts.AttrTypesHaveAttrs = true;

// Don't try to produce recovery expressions or types.
Expand All @@ -333,8 +329,6 @@ Result<AST, std::string> CompileJob::Run(void) const {
// Objective-C mode, e.g. parsing module imports.
lang_opts.DebuggerSupport = true;

// TODO(pag): Should pragmas be ignored?

// Enable C++-style comments, even in C code. If we don't do this, then we
// can observe two tokens for something like `// foo` in C code, one is a
// `slash`, the second is a `comment`.
Expand Down

0 comments on commit a2dc4f0

Please sign in to comment.