Text of clang.llvm.org › doxygen › Stmt_8h_source.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

clang: include/clang/AST/Stmt.h Source File

clang 24.0.0git include clang AST Stmt.h Go to the documentation of this file. 1 //===- Stmt.h - Classes for representing statements -------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the Stmt interface and subclasses.

10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_CLANG_AST_STMT_H 14 #define LLVM_CLANG_AST_STMT_H 15 16 #include " clang/AST/APValue.h " 17 #include " clang/AST/DeclGroup.h " 18 #include " clang/AST/DependenceFlags.h " 19 #include " clang/AST/OperationKinds.h " 20 #include " clang/AST/StmtIterator.h " 21 #include " clang/Basic/BuiltinTraits.h " 22 #include " clang/Basic/CapturedStmt.h " 23 #include " clang/Basic/IdentifierTable.h " 24 #include " clang/Basic/LLVM.h " 25 #include " clang/Basic/Lambda.h " 26 #include " clang/Basic/LangOptions.h " 27 #include " clang/Basic/OperatorKinds.h " 28 #include " clang/Basic/SourceLocation.h " 29 #include " clang/Basic/Specifiers.h " 30 #include "llvm/ADT/APFloat.h" 31 #include "llvm/ADT/ArrayRef.h" 32 #include "llvm/ADT/BitmaskEnum.h" 33 #include "llvm/ADT/PointerIntPair.h" 34 #include "llvm/ADT/STLFunctionalExtras.h" 35 #include "llvm/ADT/StringRef.h" 36 #include "llvm/ADT/iterator.h" 37 #include "llvm/ADT/iterator_range.h" 38 #include "llvm/Support/Casting.h" 39 #include "llvm/Support/Compiler.h" 40 #include "llvm/Support/ErrorHandling.h" 41 #include <algorithm> 42 #include <cassert> 43 #include <cstddef> 44 #include <iterator> 45 #include <optional> 46 #include <string> 47 48 namespace llvm { 49 50 class FoldingSetNodeID; 51 52 } // namespace llvm 53 54 namespace clang { 55 56 class ASTContext ; 57 class Attr ; 58 class CapturedDecl ; 59 class Decl ; 60 class Expr ; 61 class AddrLabelExpr ; 62 class LabelDecl ; 63 class ODRHash ; 64 class PrinterHelper ; 65 struct PrintingPolicy ; 66 class RecordDecl ; 67 class SourceManager ; 68 class StringLiteral ; 69 class Token ; 70 class VarDecl ; 71 enum class CharacterLiteralKind ; 72 enum class ConstantResultStorageKind ; 73 enum class CXXConstructionKind ; 74 enum class CXXNewInitializationStyle ; 75 enum class PredefinedIdentKind ; 76 enum class SourceLocIdentKind ; 77 enum class StringLiteralKind ; 78 79 //===----------------------------------------------------------------------===// 80 // AST classes for statements.

81 //===----------------------------------------------------------------------===// 82 83 /// Stmt - This represents one statement. 84 /// 85 class alignas (void *) Stmt { 86 public : 87 enum StmtClass { 88 NoStmtClass = 0, 89 #define STMT(CLASS, PARENT) CLASS##Class, 90 #define STMT_RANGE(BASE, FIRST, LAST) \ 91 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class, 92 #define LAST_STMT_RANGE(BASE, FIRST, LAST) \ 93 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class 94 #define ABSTRACT_STMT(STMT) 95 #include "clang/AST/StmtNodes.inc" 96 }; 97 98 // Make vanilla 'new' and 'delete' illegal for Stmts.

99 protected : 100 friend class ASTStmtReader ; 101 friend class ASTStmtWriter ; 102 103 void * operator new ( size_t bytes ) noexcept { 104 llvm_unreachable( "Stmts cannot be allocated with regular 'new'." ); 105 } 106 107 void operator delete ( void *data) noexcept { 108 llvm_unreachable( "Stmts cannot be released with regular 'delete'." ); 109 } 110 111 //===--- Statement bitfields classes ---===// 112 113 #define NumStmtBits 9 114 115 class StmtBitfields { 116 friend class ASTStmtReader ; 117 friend class ASTStmtWriter ; 118 friend class Stmt ; 119 120 /// The statement class.

121 LLVM_PREFERRED_TYPE( StmtClass ) 122 unsigned sClass : NumStmtBits ; 123 }; 124 125 class NullStmtBitfields { 126 friend class ASTStmtReader ; 127 friend class ASTStmtWriter ; 128 friend class NullStmt ; 129 130 LLVM_PREFERRED_TYPE( StmtBitfields ) 131 unsigned : NumStmtBits ; 132 133 /// True if the null statement was preceded by an empty macro, e.g: 134 /// @code 135 /// #define CALL(x) 136 /// CALL(0); 137 /// @endcode 138 LLVM_PREFERRED_TYPE( bool ) 139 unsigned HasLeadingEmptyMacro : 1; 140 141 /// The location of the semi-colon.

142 SourceLocation SemiLoc; 143 }; 144 145 class CompoundStmtBitfields { 146 friend class ASTStmtReader ; 147 friend class CompoundStmt ; 148 149 LLVM_PREFERRED_TYPE( StmtBitfields ) 150 unsigned : NumStmtBits ; 151 152 /// True if the compound statement has one or more pragmas that set some 153 /// floating-point features. 154 LLVM_PREFERRED_TYPE( bool ) 155 unsigned HasFPFeatures : 1; 156 157 unsigned NumStmts; 158 }; 159 160 class LabelStmtBitfields { 161 friend class LabelStmt ; 162 163 LLVM_PREFERRED_TYPE( StmtBitfields ) 164 unsigned : NumStmtBits ; 165 166 SourceLocation IdentLoc; 167 }; 168 169 class AttributedStmtBitfields { 170 friend class ASTStmtReader ; 171 friend class AttributedStmt ; 172 173 LLVM_PREFERRED_TYPE( StmtBitfields ) 174 unsigned : NumStmtBits ; 175 176 /// Number of attributes.

177 unsigned NumAttrs : 32 - NumStmtBits ; 178 179 /// The location of the attribute. 180 SourceLocation AttrLoc; 181 }; 182 183 class IfStmtBitfields { 184 friend class ASTStmtReader ; 185 friend class IfStmt ; 186 187 LLVM_PREFERRED_TYPE( StmtBitfields ) 188 unsigned : NumStmtBits ; 189 190 /// Whether this is a constexpr if, or a consteval if, or neither. 191 LLVM_PREFERRED_TYPE( IfStatementKind ) 192 unsigned Kind : 3; 193 194 /// True if this if statement has storage for an else statement.

195 LLVM_PREFERRED_TYPE( bool ) 196 unsigned HasElse : 1; 197 198 /// True if this if statement has storage for a variable declaration. 199 LLVM_PREFERRED_TYPE( bool ) 200 unsigned HasVar : 1; 201 202 /// True if this if statement has storage for an init statement. 203 LLVM_PREFERRED_TYPE( bool ) 204 unsigned HasInit : 1; 205 206 /// The location of the "if". 207 SourceLocation IfLoc; 208 }; 209 210 class SwitchStmtBitfields { 211 friend class SwitchStmt ; 212 213 LLVM_PREFERRED_TYPE( StmtBitfields ) 214 unsigned : NumStmtBits ; 215 216 /// True if the SwitchStmt has storage for an init statement.

217 LLVM_PREFERRED_TYPE( bool ) 218 unsigned HasInit : 1; 219 220 /// True if the SwitchStmt has storage for a condition variable. 221 LLVM_PREFERRED_TYPE( bool ) 222 unsigned HasVar : 1; 223 224 /// If the SwitchStmt is a switch on an enum value, records whether all 225 /// the enum values were covered by CaseStmts. The coverage information 226 /// value is meant to be a hint for possible clients. 227 LLVM_PREFERRED_TYPE( bool ) 228 unsigned AllEnumCasesCovered : 1; 229 230 /// The location of the "switch".

231 SourceLocation SwitchLoc; 232 }; 233 234 class WhileStmtBitfields { 235 friend class ASTStmtReader ; 236 friend class WhileStmt ; 237 238 LLVM_PREFERRED_TYPE( StmtBitfields ) 239 unsigned : NumStmtBits ; 240 241 /// True if the WhileStmt has storage for a condition variable. 242 LLVM_PREFERRED_TYPE( bool ) 243 unsigned HasVar : 1; 244 245 /// The location of the "while". 246 SourceLocation WhileLoc; 247 }; 248 249 class DoStmtBitfields { 250 friend class DoStmt ; 251 252 LLVM_PREFERRED_TYPE( StmtBitfields ) 253 unsigned : NumStmtBits ; 254 255 /// The location of the "do".

256 SourceLocation DoLoc; 257 }; 258 259 class ForStmtBitfields { 260 friend class ForStmt ; 261 262 LLVM_PREFERRED_TYPE( StmtBitfields ) 263 unsigned : NumStmtBits ; 264 265 /// The location of the "for". 266 SourceLocation ForLoc; 267 }; 268 269 class GotoStmtBitfields { 270 friend class GotoStmt ; 271 friend class IndirectGotoStmt ; 272 273 LLVM_PREFERRED_TYPE( StmtBitfields ) 274 unsigned : NumStmtBits ; 275 276 /// The location of the "goto".

277 SourceLocation GotoLoc; 278 }; 279 280 class LoopControlStmtBitfields { 281 friend class LoopControlStmt ; 282 283 LLVM_PREFER

The rest of this page is on the live site.