diff --git a/bin/BootstrapTypes/Globals.cpp b/bin/BootstrapTypes/Globals.cpp index d2b5f919..6e960ae4 100644 --- a/bin/BootstrapTypes/Globals.cpp +++ b/bin/BootstrapTypes/Globals.cpp @@ -1276,6 +1276,10 @@ std::map, 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" diff --git a/include/pasta/AST/Attr.h b/include/pasta/AST/Attr.h index e10cc78f..6cb833e7 100644 --- a/include/pasta/AST/Attr.h +++ b/include/pasta/AST/Attr.h @@ -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 Alignment(void) const; std::optional<::pasta::Expr> AlignmentExpression(void) const; std::optional<::pasta::Type> AlignmentType(void) const; std::optional CachedAlignmentValue(void) const; diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp index c24d49ff..222466dc 100644 --- a/lib/AST/Attr.cpp +++ b/lib/AST/Attr.cpp @@ -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 AlignedAttr::Alignment(void) const { auto &self = *(u.AlignedAttr); + if (!self.isAlignmentExpr()) { + return std::nullopt; + } decltype(auto) val = self.getAlignment(ast->ci->getASTContext()); return val; } diff --git a/lib/Compile/Run.cpp b/lib/Compile/Run.cpp index c2fcdfc2..4fcec752 100644 --- a/lib/Compile/Run.cpp +++ b/lib/Compile/Run.cpp @@ -142,11 +142,7 @@ Result CompileJob::Run(void) const { const ArgumentVector &argv = Arguments(); llvm::ArrayRef 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`. @@ -322,7 +318,7 @@ Result 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. @@ -333,8 +329,6 @@ Result 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`.