[clang] [Clang] Support constexpr asm at global scope. (PR #143268)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 7 07:31:25 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/Decl.h clang/include/clang/AST/RecursiveASTVisitor.h clang/lib/AST/Decl.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/CodeGenCXX/gnu-asm-constexpr.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 5c378e58c..05aac15b3 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4493,15 +4493,15 @@ class FileScopeAsmDecl : public Decl {
Expr *AsmString;
SourceLocation RParenLoc;
- FileScopeAsmDecl(DeclContext *DC, Expr *asmstring,
- SourceLocation StartL, SourceLocation EndL)
- : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
+ FileScopeAsmDecl(DeclContext *DC, Expr *asmstring, SourceLocation StartL,
+ SourceLocation EndL)
+ : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
virtual void anchor();
public:
- static FileScopeAsmDecl *Create(ASTContext &C, DeclContext *DC,
- Expr *Str, SourceLocation AsmLoc,
+ static FileScopeAsmDecl *Create(ASTContext &C, DeclContext *DC, Expr *Str,
+ SourceLocation AsmLoc,
SourceLocation RParenLoc);
static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
@@ -4519,7 +4519,6 @@ public:
std::string getAsmString() const;
-
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == FileScopeAsm; }
};
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 08d08293b..860968939 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -5713,8 +5713,7 @@ SourceRange TypeAliasDecl::getSourceRange() const {
void FileScopeAsmDecl::anchor() {}
FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC,
- Expr *Str,
- SourceLocation AsmLoc,
+ Expr *Str, SourceLocation AsmLoc,
SourceLocation RParenLoc) {
return new (C, DC) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc);
}
@@ -5726,7 +5725,7 @@ FileScopeAsmDecl *FileScopeAsmDecl::CreateDeserialized(ASTContext &C,
}
std::string FileScopeAsmDecl::getAsmString() const {
- return GCCAsmStmt::ExtractStringFromGCCAsmStmtComponent(getAsmStringExpr());
+ return GCCAsmStmt::ExtractStringFromGCCAsmStmtComponent(getAsmStringExpr());
}
void TopLevelStmtDecl::anchor() {}
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index be98b87d9..944385744 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1043,7 +1043,7 @@ void DeclPrinter::VisitParmVarDecl(ParmVarDecl *D) {
void DeclPrinter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
Out << "__asm (";
D->getAsmStringExpr()->printPretty(Out, nullptr, Policy, Indentation, "\n",
- &Context);
+ &Context);
Out << ")";
}
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1bcc0c5a4..bbd63372c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -20514,13 +20514,11 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
CheckAlignasUnderalignment(Enum);
}
-Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr,
- SourceLocation StartLoc,
+Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr, SourceLocation StartLoc,
SourceLocation EndLoc) {
- FileScopeAsmDecl *New = FileScopeAsmDecl::Create(Context, CurContext,
- expr, StartLoc,
- EndLoc);
+ FileScopeAsmDecl *New =
+ FileScopeAsmDecl::Create(Context, CurContext, expr, StartLoc, EndLoc);
CurContext->addDecl(New);
return New;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/143268
More information about the cfe-commits
mailing list