Skip to content

Commit 0d61cd2

Browse files
committed
Verify that clang's max alignment is <= LLVM's max alignment
Reviewers: lebedev.ri Reviewed By: lebedev.ri Subscribers: cfe-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D73363
1 parent b535aa4 commit 0d61cd2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,17 @@ class Sema final {
372372
QualType ResultTy,
373373
ArrayRef<QualType> Args);
374374

375+
public:
375376
/// The maximum alignment, same as in llvm::Value. We duplicate them here
376377
/// because that allows us not to duplicate the constants in clang code,
377378
/// which we must to since we can't directly use the llvm constants.
379+
/// The value is verified against llvm here: lib/CodeGen/CGValue.h
378380
///
379381
/// This is the greatest alignment value supported by load, store, and alloca
380382
/// instructions, and global values.
381383
static const unsigned MaxAlignmentExponent = 29;
382384
static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent;
383385

384-
public:
385386
typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
386387
typedef OpaquePtr<TemplateName> TemplateTy;
387388
typedef OpaquePtr<QualType> TypeTy;

clang/lib/CodeGen/CGValue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
#define LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
1616

1717
#include "clang/AST/ASTContext.h"
18+
#include "clang/Sema/Sema.h"
1819
#include "clang/AST/Type.h"
1920
#include "llvm/IR/Value.h"
2021
#include "llvm/IR/Type.h"
2122
#include "Address.h"
2223
#include "CodeGenTBAA.h"
2324

25+
static_assert(clang::Sema::MaximumAlignment <= llvm::Value::MaximumAlignment,
26+
"Clang max alignment greater than what LLVM supports?");
27+
2428
namespace llvm {
2529
class Constant;
2630
class MDNode;

0 commit comments

Comments
 (0)