1 # Giant clang 3.6.2 patch for correcting misalignments. |
|
2 # Patch is from: http://reviews.llvm.org/D10272 |
|
3 # Adjustments were made for 3.6.2 (the original does not apply cleanly). |
|
4 --- include/llvm/Support/Compiler.h 2014-11-18 17:17:30.000000000 -0500 |
|
5 +++ include/llvm/Support/Compiler.h 2015-07-17 23:43:07.143745400 -0400 |
|
6 @@ -303,6 +303,37 @@ |
|
7 # define LLVM_ASSUME_ALIGNED(p, a) (p) |
|
8 #endif |
|
9 |
|
10 +/// \macro LLVM_ALIGNAS |
|
11 +/// \brief Used to specify a minimum alignment for a structure or variable. The |
|
12 +/// alignment must be a constant integer. Use LLVM_PTR_SIZE to compute |
|
13 +/// alignments in terms of the size of a pointer. |
|
14 +/// |
|
15 +/// Note that __declspec(align) has special quirks, it's not legal to pass a |
|
16 +/// structure with __declspec(align) as a formal parameter. |
|
17 +#ifdef _MSC_VER |
|
18 +# define LLVM_ALIGNAS(x) __declspec(align(x)) |
|
19 +#elif __GNUC__ && !__has_feature(cxx_alignas) && !LLVM_GNUC_PREREQ(4, 8, 0) |
|
20 +# define LLVM_ALIGNAS(x) __attribute__((aligned(x))) |
|
21 +#else |
|
22 +# define LLVM_ALIGNAS(x) alignas(x) |
|
23 +#endif |
|
24 + |
|
25 +/// \macro LLVM_PTR_SIZE |
|
26 +/// \brief A constant integer equivalent to the value of sizeof(void*). |
|
27 +/// Generally used in combination with LLVM_ALIGNAS or when doing computation in |
|
28 +/// the preprocessor. |
|
29 +#ifdef __SIZEOF_POINTER__ |
|
30 +# define LLVM_PTR_SIZE __SIZEOF_POINTER__ |
|
31 +#elif defined(_WIN64) |
|
32 +# define LLVM_PTR_SIZE 8 |
|
33 +#elif defined(_WIN32) |
|
34 +# define LLVM_PTR_SIZE 4 |
|
35 +#elif defined(_MSC_VER) |
|
36 +# error "could not determine LLVM_PTR_SIZE as a constant int for MSVC" |
|
37 +#else |
|
38 +# define LLVM_PTR_SIZE sizeof(void *) |
|
39 +#endif |
|
40 + |
|
41 /// \macro LLVM_FUNCTION_NAME |
|
42 /// \brief Expands to __func__ on compilers which support it. Otherwise, |
|
43 /// expands to a compiler-dependent replacement. |
|
44 --- tools/clang/include/clang/AST/Decl.h 2015-01-13 16:31:13.000000000 -0800 |
|
45 +++ tools/clang/include/clang/AST/Decl.h 2015-07-17 16:43:46.474996996 -0700 |
|
46 @@ -3658,6 +3658,9 @@ |
|
47 static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
|
48 static bool classofKind(Kind K) { return K == Import; } |
|
49 }; |
|
50 +static_assert(llvm::AlignOf<ImportDecl>::Alignment >= |
|
51 + llvm::AlignOf<SourceLocation>::Alignment, |
|
52 + "Alignment is insufficient for objects appended to ImportDecl"); |
|
53 |
|
54 /// \brief Represents an empty-declaration. |
|
55 class EmptyDecl : public Decl { |
|
56 --- tools/clang/include/clang/AST/DeclBase.h 2014-11-17 15:36:45.000000000 -0800 |
|
57 +++ tools/clang/include/clang/AST/DeclBase.h 2015-07-17 16:43:46.476997606 -0700 |
|
58 @@ -69,6 +69,9 @@ |
|
59 /// Decl - This represents one declaration (or definition), e.g. a variable, |
|
60 /// typedef, function, struct, etc. |
|
61 /// |
|
62 +/// Note: There are objects tacked on before the *beginning* of Decl |
|
63 +/// (and its subclasses) in its Decl::operator new(). Proper alignment |
|
64 +/// for all subclasses is asserted in DeclBase.cpp. |
|
65 class Decl { |
|
66 public: |
|
67 /// \brief Lists the kind of concrete classes of Decl. |
|
68 --- tools/clang/include/clang/AST/DeclCXX.h 2014-12-10 12:04:48.000000000 -0800 |
|
69 +++ tools/clang/include/clang/AST/DeclCXX.h 2015-07-17 16:43:46.479237326 -0700 |
|
70 @@ -2130,6 +2130,10 @@ |
|
71 /// \brief Get the initializer. |
|
72 Expr *getInit() const { return static_cast<Expr*>(Init); } |
|
73 }; |
|
74 +static_assert( |
|
75 + llvm::AlignOf<CXXCtorInitializer>::Alignment >= |
|
76 + llvm::AlignOf<VarDecl *>::Alignment, |
|
77 + "Alignment is insufficient for objects appended to CXXCtorInitializer"); |
|
78 |
|
79 /// \brief Represents a C++ constructor within a class. |
|
80 /// |
|
81 --- tools/clang/include/clang/AST/DeclFriend.h 2014-07-16 18:59:34.000000000 -0700 |
|
82 +++ tools/clang/include/clang/AST/DeclFriend.h 2015-07-17 16:43:46.480506828 -0700 |
|
83 @@ -172,6 +172,9 @@ |
|
84 friend class ASTDeclReader; |
|
85 friend class ASTDeclWriter; |
|
86 }; |
|
87 +static_assert(llvm::AlignOf<FriendDecl>::Alignment >= |
|
88 + llvm::AlignOf<TemplateParameterList *>::Alignment, |
|
89 + "Alignment is insufficient for objects appended to FriendDecl"); |
|
90 |
|
91 /// An iterator over the friend declarations of a class. |
|
92 class CXXRecordDecl::friend_iterator { |
|
93 --- tools/clang/include/clang/AST/DeclGroup.h 2014-05-05 23:48:52.000000000 -0700 |
|
94 +++ tools/clang/include/clang/AST/DeclGroup.h 2015-07-17 16:43:46.481808784 -0700 |
|
95 @@ -14,6 +14,7 @@ |
|
96 #ifndef LLVM_CLANG_AST_DECLGROUP_H |
|
97 #define LLVM_CLANG_AST_DECLGROUP_H |
|
98 |
|
99 +#include "llvm/Support/AlignOf.h" |
|
100 #include "llvm/Support/DataTypes.h" |
|
101 #include <cassert> |
|
102 |
|
103 @@ -51,6 +52,9 @@ |
|
104 return ((Decl* const*) (this+1))[i]; |
|
105 } |
|
106 }; |
|
107 +static_assert(llvm::AlignOf<DeclGroup>::Alignment >= |
|
108 + llvm::AlignOf<Decl *>::Alignment, |
|
109 + "Alignment is insufficient for objects appended to DeclGroup"); |
|
110 |
|
111 class DeclGroupRef { |
|
112 // Note this is not a PointerIntPair because we need the address of the |
|
113 --- tools/clang/include/clang/AST/DeclOpenMP.h 2014-11-10 20:05:39.000000000 -0800 |
|
114 +++ tools/clang/include/clang/AST/DeclOpenMP.h 2015-07-17 16:43:46.482893197 -0700 |
|
115 @@ -84,6 +84,10 @@ |
|
116 static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
|
117 static bool classofKind(Kind K) { return K == OMPThreadPrivate; } |
|
118 }; |
|
119 +static_assert( |
|
120 + llvm::AlignOf<OMPThreadPrivateDecl>::Alignment >= |
|
121 + llvm::AlignOf<Expr *>::Alignment, |
|
122 + "Alignment is insufficient for objects appended to OMPThreadPrivateDecl"); |
|
123 |
|
124 } // end namespace clang |
|
125 |
|
126 --- tools/clang/include/clang/AST/DeclTemplate.h 2014-08-30 09:55:39.000000000 -0700 |
|
127 +++ tools/clang/include/clang/AST/DeclTemplate.h 2015-07-17 16:43:46.485713092 -0700 |
|
128 @@ -43,7 +43,7 @@ |
|
129 |
|
130 /// \brief Stores a list of template parameters for a TemplateDecl and its |
|
131 /// derived classes. |
|
132 -class TemplateParameterList { |
|
133 +class LLVM_ALIGNAS(/*alignof(void*)*/ LLVM_PTR_SIZE) TemplateParameterList { |
|
134 /// The location of the 'template' keyword. |
|
135 SourceLocation TemplateLoc; |
|
136 |
|
137 @@ -131,6 +131,10 @@ |
|
138 return SourceRange(TemplateLoc, RAngleLoc); |
|
139 } |
|
140 }; |
|
141 +static_assert( |
|
142 + llvm::AlignOf<TemplateParameterList>::Alignment >= |
|
143 + llvm::AlignOf<NamedDecl *>::Alignment, |
|
144 + "Alignment is insufficient for objects appended to TemplateParameterList"); |
|
145 |
|
146 /// \brief Stores a list of template parameters for a TemplateDecl and its |
|
147 /// derived classes. Suitable for creating on the stack. |
|
148 @@ -460,27 +464,20 @@ |
|
149 /// friend void foo<>(T); |
|
150 /// }; |
|
151 /// \endcode |
|
152 -class DependentFunctionTemplateSpecializationInfo { |
|
153 - struct CA { |
|
154 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) |
|
155 + DependentFunctionTemplateSpecializationInfo { |
|
156 /// The number of potential template candidates. |
|
157 unsigned NumTemplates; |
|
158 |
|
159 /// The number of template arguments. |
|
160 unsigned NumArgs; |
|
161 - }; |
|
162 - |
|
163 - union { |
|
164 - // Force sizeof to be a multiple of sizeof(void*) so that the |
|
165 - // trailing data is aligned. |
|
166 - void *Aligner; |
|
167 - struct CA d; |
|
168 - }; |
|
169 |
|
170 /// The locations of the left and right angle brackets. |
|
171 SourceRange AngleLocs; |
|
172 |
|
173 FunctionTemplateDecl * const *getTemplates() const { |
|
174 - return reinterpret_cast<FunctionTemplateDecl*const*>(this+1); |
|
175 + return reinterpret_cast<FunctionTemplateDecl *const *>( |
|
176 + &getTemplateArgs()[NumArgs]); |
|
177 } |
|
178 |
|
179 public: |
|
180 @@ -490,9 +487,7 @@ |
|
181 |
|
182 /// \brief Returns the number of function templates that this might |
|
183 /// be a specialization of. |
|
184 - unsigned getNumTemplates() const { |
|
185 - return d.NumTemplates; |
|
186 - } |
|
187 + unsigned getNumTemplates() const { return NumTemplates; } |
|
188 |
|
189 /// \brief Returns the i'th template candidate. |
|
190 FunctionTemplateDecl *getTemplate(unsigned I) const { |
|
191 @@ -502,14 +497,11 @@ |
|
192 |
|
193 /// \brief Returns the explicit template arguments that were given. |
|
194 const TemplateArgumentLoc *getTemplateArgs() const { |
|
195 - return reinterpret_cast<const TemplateArgumentLoc*>( |
|
196 - &getTemplates()[getNumTemplates()]); |
|
197 + return reinterpret_cast<const TemplateArgumentLoc *>(this + 1); |
|
198 } |
|
199 |
|
200 /// \brief Returns the number of explicit template arguments that were given. |
|
201 - unsigned getNumTemplateArgs() const { |
|
202 - return d.NumArgs; |
|
203 - } |
|
204 + unsigned getNumTemplateArgs() const { return NumArgs; } |
|
205 |
|
206 /// \brief Returns the nth template argument. |
|
207 const TemplateArgumentLoc &getTemplateArg(unsigned I) const { |
|
208 @@ -525,6 +517,15 @@ |
|
209 return AngleLocs.getEnd(); |
|
210 } |
|
211 }; |
|
212 +static_assert( |
|
213 + llvm::AlignOf<DependentFunctionTemplateSpecializationInfo>::Alignment >= |
|
214 + llvm::AlignOf<TemplateArgumentLoc>::Alignment, |
|
215 + "Alignment is insufficient for objects appended to " |
|
216 + "DependentFunctionTemplateSpecializationInfo"); |
|
217 +static_assert(llvm::AlignOf<TemplateArgumentLoc>::Alignment >= |
|
218 + llvm::AlignOf<FunctionTemplateDecl *>::Alignment, |
|
219 + "Alignment is insufficient for objects appended to " |
|
220 + "DependentFunctionTemplateSpecializationInfo"); |
|
221 |
|
222 /// Declaration of a redeclarable template. |
|
223 class RedeclarableTemplateDecl : public TemplateDecl, |
|
224 @@ -1203,6 +1204,10 @@ |
|
225 static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
|
226 static bool classofKind(Kind K) { return K == NonTypeTemplateParm; } |
|
227 }; |
|
228 +static_assert(llvm::AlignOf<NonTypeTemplateParmDecl>::Alignment >= |
|
229 + llvm::AlignOf<void *>::Alignment, |
|
230 + "Alignment is insufficient for objects appended to " |
|
231 + "NonTypeTemplateParmDecl"); |
|
232 |
|
233 /// TemplateTemplateParmDecl - Declares a template template parameter, |
|
234 /// e.g., "T" in |
|
235 @@ -1369,6 +1374,10 @@ |
|
236 friend class ASTDeclReader; |
|
237 friend class ASTDeclWriter; |
|
238 }; |
|
239 +static_assert(llvm::AlignOf<TemplateTemplateParmDecl>::Alignment >= |
|
240 + llvm::AlignOf<TemplateParameterList *>::Alignment, |
|
241 + "Alignment is insufficient for objects appended to " |
|
242 + "TemplateTemplateParmDecl"); |
|
243 |
|
244 /// \brief Represents a class template specialization, which refers to |
|
245 /// a class template with a given set of template arguments. |
|
246 --- tools/clang/include/clang/AST/EvaluatedExprVisitor.h 2014-12-03 13:00:20.000000000 -0800 |
|
247 +++ tools/clang/include/clang/AST/EvaluatedExprVisitor.h 2015-07-17 16:43:46.487103645 -0700 |
|
248 @@ -85,7 +85,7 @@ |
|
249 |
|
250 void VisitLambdaExpr(LambdaExpr *LE) { |
|
251 // Only visit the capture initializers, and not the body. |
|
252 - for (LambdaExpr::capture_init_iterator I = LE->capture_init_begin(), |
|
253 + for (LambdaExpr::const_capture_init_iterator I = LE->capture_init_begin(), |
|
254 E = LE->capture_init_end(); |
|
255 I != E; ++I) |
|
256 if (*I) |
|
257 --- tools/clang/include/clang/AST/Expr.h 2015-01-12 02:17:46.000000000 -0800 |
|
258 +++ tools/clang/include/clang/AST/Expr.h 2015-07-17 16:43:46.491602160 -0700 |
|
259 @@ -894,7 +894,7 @@ |
|
260 /// DeclRefExprBits.RefersToEnclosingVariableOrCapture |
|
261 /// Specifies when this declaration reference expression (validly) |
|
262 /// refers to an enclosed local or a captured variable. |
|
263 -class DeclRefExpr : public Expr { |
|
264 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) DeclRefExpr : public Expr { |
|
265 /// \brief The declaration that we are referencing. |
|
266 ValueDecl *D; |
|
267 |
|
268 @@ -1048,13 +1048,17 @@ |
|
269 if (!hasTemplateKWAndArgsInfo()) |
|
270 return nullptr; |
|
271 |
|
272 - if (hasFoundDecl()) |
|
273 + if (hasFoundDecl()) { |
|
274 return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( |
|
275 - &getInternalFoundDecl() + 1); |
|
276 + llvm::alignAddr(&getInternalFoundDecl() + 1, |
|
277 + llvm::alignOf<ASTTemplateKWAndArgsInfo>())); |
|
278 + } |
|
279 |
|
280 - if (hasQualifier()) |
|
281 + if (hasQualifier()) { |
|
282 return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( |
|
283 - &getInternalQualifierLoc() + 1); |
|
284 + llvm::alignAddr(&getInternalQualifierLoc() + 1, |
|
285 + llvm::alignOf<ASTTemplateKWAndArgsInfo>())); |
|
286 + } |
|
287 |
|
288 return reinterpret_cast<ASTTemplateKWAndArgsInfo *>(this + 1); |
|
289 } |
|
290 @@ -1167,6 +1171,16 @@ |
|
291 friend class ASTStmtReader; |
|
292 friend class ASTStmtWriter; |
|
293 }; |
|
294 +static_assert(llvm::AlignOf<DeclRefExpr>::Alignment >= |
|
295 + llvm::AlignOf<NestedNameSpecifierLoc>::Alignment, |
|
296 + "Alignment is insufficient for objects appended to DeclRefExpr"); |
|
297 +static_assert(llvm::AlignOf<NestedNameSpecifierLoc>::Alignment >= |
|
298 + llvm::AlignOf<NamedDecl *>::Alignment, |
|
299 + "Alignment is insufficient for objects appended to DeclRefExpr"); |
|
300 +// Code re-aligns before ASTTemplateKWAndArgsInfo |
|
301 +static_assert(llvm::AlignOf<DeclRefExpr>::Alignment >= |
|
302 + llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment, |
|
303 + "Alignment is insufficient for objects appended to DeclRefExpr"); |
|
304 |
|
305 /// \brief [C99 6.4.2.2] - A predefined identifier such as __func__. |
|
306 class PredefinedExpr : public Expr { |
|
307 @@ -1968,6 +1982,12 @@ |
|
308 return child_range(begin, begin + NumExprs); |
|
309 } |
|
310 }; |
|
311 +static_assert(llvm::AlignOf<OffsetOfExpr>::Alignment >= |
|
312 + llvm::AlignOf<OffsetOfExpr::OffsetOfNode *>::Alignment, |
|
313 + "Alignment is insufficient for objects appended to OffsetOfExpr"); |
|
314 +static_assert(llvm::AlignOf<OffsetOfExpr::OffsetOfNode>::Alignment >= |
|
315 + llvm::AlignOf<Expr *>::Alignment, |
|
316 + "Alignment is insufficient for objects appended to OffsetOfExpr"); |
|
317 |
|
318 /// UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) |
|
319 /// expression operand. Used for sizeof/alignof (C99 6.5.3.4) and |
|
320 @@ -2309,9 +2329,10 @@ |
|
321 |
|
322 /// MemberExpr - [C99 6.5.2.3] Structure and Union Members. X->F and X.F. |
|
323 /// |
|
324 -class MemberExpr : public Expr { |
|
325 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) MemberExpr : public Expr { |
|
326 +public: |
|
327 /// Extra data stored in some member expressions. |
|
328 - struct MemberNameQualifier { |
|
329 + struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) MemberNameQualifier { |
|
330 /// \brief The nested-name-specifier that qualifies the name, including |
|
331 /// source-location information. |
|
332 NestedNameSpecifierLoc QualifierLoc; |
|
333 @@ -2321,6 +2342,7 @@ |
|
334 DeclAccessPair FoundDecl; |
|
335 }; |
|
336 |
|
337 +private: |
|
338 /// Base - the expression for the base pointer or structure references. In |
|
339 /// X.F, this is "X". |
|
340 Stmt *Base; |
|
341 @@ -2591,6 +2613,12 @@ |
|
342 friend class ASTReader; |
|
343 friend class ASTStmtWriter; |
|
344 }; |
|
345 +static_assert(llvm::AlignOf<MemberExpr>::Alignment >= |
|
346 + llvm::AlignOf<MemberExpr::MemberNameQualifier>::Alignment, |
|
347 + "Alignment is insufficient for objects appended to MemberExpr"); |
|
348 +static_assert(llvm::AlignOf<MemberExpr::MemberNameQualifier>::Alignment >= |
|
349 + llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment, |
|
350 + "Alignment is insufficient for objects appended to MemberExpr"); |
|
351 |
|
352 /// CompoundLiteralExpr - [C99 6.5.2.5] |
|
353 /// |
|
354 @@ -2747,6 +2775,11 @@ |
|
355 // Iterators |
|
356 child_range children() { return child_range(&Op, &Op+1); } |
|
357 }; |
|
358 +static_assert(llvm::AlignOf<CastExpr>::Alignment >= |
|
359 + llvm::AlignOf<CXXBaseSpecifier *>::Alignment, |
|
360 + "Alignment is insufficient for objects appended to CastExpr"); |
|
361 +// (Note that the data is actually tacked onto one of its subclasses, |
|
362 +// but they'll inherit alignment) |
|
363 |
|
364 /// ImplicitCastExpr - Allows us to explicitly represent implicit type |
|
365 /// conversions, which have no direct representation in the original |
|
366 @@ -4272,6 +4305,10 @@ |
|
367 return child_range(begin, begin + NumSubExprs); |
|
368 } |
|
369 }; |
|
370 +static_assert( |
|
371 + llvm::AlignOf<DesignatedInitExpr>::Alignment >= |
|
372 + llvm::AlignOf<Stmt *>::Alignment, |
|
373 + "Alignment is insufficient for objects appended to DesignatedInitExpr"); |
|
374 |
|
375 /// \brief Represents an implicitly-generated value initialization of |
|
376 /// an object of a given type. |
|
377 @@ -4749,6 +4786,10 @@ |
|
378 return T->getStmtClass() == PseudoObjectExprClass; |
|
379 } |
|
380 }; |
|
381 +static_assert( |
|
382 + llvm::AlignOf<PseudoObjectExpr>::Alignment >= |
|
383 + llvm::AlignOf<Expr *>::Alignment, |
|
384 + "Alignment is insufficient for objects appended to PseudoObjectExpr"); |
|
385 |
|
386 /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, |
|
387 /// __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the |
|
388 --- tools/clang/include/clang/AST/ExprCXX.h 2015-01-14 03:29:14.000000000 -0800 |
|
389 +++ tools/clang/include/clang/AST/ExprCXX.h 2015-07-18 11:25:29.503136056 -0700 |
|
390 @@ -933,6 +933,10 @@ |
|
391 friend class ASTStmtReader; |
|
392 friend class ASTStmtWriter; |
|
393 }; |
|
394 +static_assert( |
|
395 + llvm::AlignOf<CXXDefaultArgExpr>::Alignment >= |
|
396 + llvm::AlignOf<Expr *>::Alignment, |
|
397 + "Alignment is insufficient for objects appended to CXXDefaultArgExpr"); |
|
398 |
|
399 /// \brief A use of a default initializer in a constructor or in aggregate |
|
400 /// initialization. |
|
401 @@ -1395,23 +1399,38 @@ |
|
402 getStoredStmts()[NumCaptures] = nullptr; |
|
403 } |
|
404 |
|
405 - Stmt **getStoredStmts() const { |
|
406 + Stmt **getStoredStmts() { |
|
407 return reinterpret_cast<Stmt **>(const_cast<LambdaExpr *>(this) + 1); |
|
408 } |
|
409 |
|
410 + Stmt *const *getStoredStmts() const { |
|
411 + return reinterpret_cast<Stmt *const *>(this + 1); |
|
412 + } |
|
413 + |
|
414 /// \brief Retrieve the mapping from captures to the first array index |
|
415 /// variable. |
|
416 - unsigned *getArrayIndexStarts() const { |
|
417 + unsigned *getArrayIndexStarts() { |
|
418 return reinterpret_cast<unsigned *>(getStoredStmts() + NumCaptures + 1); |
|
419 } |
|
420 |
|
421 + const unsigned *getArrayIndexStarts() const { |
|
422 + return reinterpret_cast<const unsigned *>(getStoredStmts() + NumCaptures + 1); |
|
423 + } |
|
424 + |
|
425 /// \brief Retrieve the complete set of array-index variables. |
|
426 - VarDecl **getArrayIndexVars() const { |
|
427 + VarDecl **getArrayIndexVars() { |
|
428 unsigned ArrayIndexSize = |
|
429 llvm::RoundUpToAlignment(sizeof(unsigned) * (NumCaptures + 1), |
|
430 llvm::alignOf<VarDecl*>()); |
|
431 return reinterpret_cast<VarDecl **>( |
|
432 - reinterpret_cast<char*>(getArrayIndexStarts()) + ArrayIndexSize); |
|
433 + reinterpret_cast<unsigned char*>(getArrayIndexStarts()) + ArrayIndexSize); |
|
434 + } |
|
435 + |
|
436 + VarDecl *const *getArrayIndexVars() const { |
|
437 + unsigned ArrayIndexSize = llvm::RoundUpToAlignment( |
|
438 + sizeof(unsigned) * (NumCaptures + 1), llvm::alignOf<VarDecl *>()); |
|
439 + return reinterpret_cast<VarDecl *const *>( |
|
440 + reinterpret_cast<const unsigned char *>(getArrayIndexStarts()) + ArrayIndexSize); |
|
441 } |
|
442 |
|
443 public: |
|
444 @@ -1492,21 +1511,43 @@ |
|
445 /// arguments. |
|
446 typedef Expr **capture_init_iterator; |
|
447 |
|
448 + /// \brief Const iterator that walks over the capture initialization |
|
449 + /// arguments. |
|
450 + typedef Expr *const *const_capture_init_iterator; |
|
451 + |
|
452 /// \brief Retrieve the initialization expressions for this lambda's captures. |
|
453 - llvm::iterator_range<capture_init_iterator> capture_inits() const { |
|
454 + llvm::iterator_range<capture_init_iterator> capture_inits() { |
|
455 return llvm::iterator_range<capture_init_iterator>(capture_init_begin(), |
|
456 capture_init_end()); |
|
457 } |
|
458 |
|
459 + /// \brief Retrieve the initialization expressions for this lambda's captures. |
|
460 + llvm::iterator_range<const_capture_init_iterator> capture_inits() const { |
|
461 + return llvm::iterator_range<const_capture_init_iterator>( |
|
462 + capture_init_begin(), capture_init_end()); |
|
463 + } |
|
464 + |
|
465 /// \brief Retrieve the first initialization argument for this |
|
466 /// lambda expression (which initializes the first capture field). |
|
467 - capture_init_iterator capture_init_begin() const { |
|
468 + capture_init_iterator capture_init_begin() { |
|
469 return reinterpret_cast<Expr **>(getStoredStmts()); |
|
470 } |
|
471 |
|
472 + /// \brief Retrieve the first initialization argument for this |
|
473 + /// lambda expression (which initializes the first capture field). |
|
474 + const_capture_init_iterator capture_init_begin() const { |
|
475 + return reinterpret_cast<Expr *const *>(getStoredStmts()); |
|
476 + } |
|
477 + |
|
478 /// \brief Retrieve the iterator pointing one past the last |
|
479 /// initialization argument for this lambda expression. |
|
480 - capture_init_iterator capture_init_end() const { |
|
481 + capture_init_iterator capture_init_end() { |
|
482 + return capture_init_begin() + NumCaptures; |
|
483 + } |
|
484 + |
|
485 + /// \brief Retrieve the iterator pointing one past the last |
|
486 + /// initialization argument for this lambda expression. |
|
487 + const_capture_init_iterator capture_init_end() const { |
|
488 return capture_init_begin() + NumCaptures; |
|
489 } |
|
490 |
|
491 @@ -1515,7 +1556,8 @@ |
|
492 /// |
|
493 /// \param Iter The iterator that points at the capture initializer for |
|
494 /// which we are extracting the corresponding index variables. |
|
495 - ArrayRef<VarDecl *> getCaptureInitIndexVars(capture_init_iterator Iter) const; |
|
496 + ArrayRef<VarDecl *> |
|
497 + getCaptureInitIndexVars(const_capture_init_iterator Iter) const; |
|
498 |
|
499 /// \brief Retrieve the source range covering the lambda introducer, |
|
500 /// which contains the explicit capture list surrounded by square |
|
501 @@ -1570,6 +1612,16 @@ |
|
502 friend class ASTStmtReader; |
|
503 friend class ASTStmtWriter; |
|
504 }; |
|
505 +static_assert(llvm::AlignOf<LambdaExpr>::Alignment >= |
|
506 + llvm::AlignOf<Stmt *>::Alignment, |
|
507 + "Alignment is insufficient for objects appended to LambdaExpr"); |
|
508 +static_assert(llvm::AlignOf<Stmt *>::Alignment >= |
|
509 + llvm::AlignOf<unsigned>::Alignment, |
|
510 + "Alignment is insufficient for objects appended to LambdaExpr"); |
|
511 +// Code re-aligns before VarDecl *[] |
|
512 +static_assert(llvm::AlignOf<LambdaExpr>::Alignment >= |
|
513 + llvm::AlignOf<VarDecl *>::Alignment, |
|
514 + "Alignment is insufficient for objects appended to LambdaExpr"); |
|
515 |
|
516 /// An expression "T()" which creates a value-initialized rvalue of type |
|
517 /// T, which is a non-class type. See (C++98 [5.2.3p2]). |
|
518 @@ -2157,6 +2209,10 @@ |
|
519 friend class ASTStmtWriter; |
|
520 |
|
521 }; |
|
522 +static_assert( |
|
523 + llvm::AlignOf<TypeTraitExpr>::Alignment >= |
|
524 + llvm::AlignOf<TypeSourceInfo *>::Alignment, |
|
525 + "Alignment is insufficient for objects appended to TypeTraitExpr"); |
|
526 |
|
527 /// \brief An Embarcadero array type trait, as used in the implementation of |
|
528 /// __array_rank and __array_extent. |
|
529 @@ -2289,7 +2345,7 @@ |
|
530 |
|
531 /// \brief A reference to an overloaded function set, either an |
|
532 /// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr. |
|
533 -class OverloadExpr : public Expr { |
|
534 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) OverloadExpr : public Expr { |
|
535 /// \brief The common name of these declarations. |
|
536 DeclarationNameInfo NameInfo; |
|
537 |
|
538 @@ -2578,6 +2634,10 @@ |
|
539 return T->getStmtClass() == UnresolvedLookupExprClass; |
|
540 } |
|
541 }; |
|
542 +static_assert( |
|
543 + llvm::AlignOf<UnresolvedLookupExpr>::Alignment >= |
|
544 + llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment, |
|
545 + "Alignment is insufficient for objects appended to UnresolvedLookupExpr"); |
|
546 |
|
547 /// \brief A qualified reference to a name whose declaration cannot |
|
548 /// yet be resolved. |
|
549 @@ -2593,7 +2653,8 @@ |
|
550 /// qualifier (X<T>::) and the name of the entity being referenced |
|
551 /// ("value"). Such expressions will instantiate to a DeclRefExpr once the |
|
552 /// declaration can be found. |
|
553 -class DependentScopeDeclRefExpr : public Expr { |
|
554 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) DependentScopeDeclRefExpr |
|
555 + : public Expr { |
|
556 /// \brief The nested-name-specifier that qualifies this unresolved |
|
557 /// declaration name. |
|
558 NestedNameSpecifierLoc QualifierLoc; |
|
559 @@ -2739,6 +2800,10 @@ |
|
560 friend class ASTStmtReader; |
|
561 friend class ASTStmtWriter; |
|
562 }; |
|
563 +static_assert(llvm::AlignOf<DependentScopeDeclRefExpr>::Alignment >= |
|
564 + llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment, |
|
565 + "Alignment is insufficient for objects appended to " |
|
566 + "DependentScopeDeclRefExpr"); |
|
567 |
|
568 /// Represents an expression -- generally a full-expression -- that |
|
569 /// introduces cleanups to be run at the end of the sub-expression's |
|
570 @@ -2810,6 +2875,10 @@ |
|
571 // Iterators |
|
572 child_range children() { return child_range(&SubExpr, &SubExpr + 1); } |
|
573 }; |
|
574 +static_assert( |
|
575 + llvm::AlignOf<ExprWithCleanups>::Alignment >= |
|
576 + llvm::AlignOf<ExprWithCleanups::CleanupObject>::Alignment, |
|
577 + "Alignment is insufficient for objects appended to ExprWithCleanups"); |
|
578 |
|
579 /// \brief Describes an explicit type conversion that uses functional |
|
580 /// notion but could not be resolved because one or more arguments are |
|
581 @@ -2930,6 +2999,10 @@ |
|
582 return child_range(begin, begin + NumArgs); |
|
583 } |
|
584 }; |
|
585 +static_assert(llvm::AlignOf<CXXUnresolvedConstructExpr>::Alignment >= |
|
586 + llvm::AlignOf<Expr *>::Alignment, |
|
587 + "Alignment is insufficient for objects appended to " |
|
588 + "CXXUnresolvedConstructExpr"); |
|
589 |
|
590 /// \brief Represents a C++ member access expression where the actual |
|
591 /// member referenced could not be resolved because the base |
|
592 @@ -2938,7 +3011,8 @@ |
|
593 /// Like UnresolvedMemberExprs, these can be either implicit or |
|
594 /// explicit accesses. It is only possible to get one of these with |
|
595 /// an implicit access if a qualifier is provided. |
|
596 -class CXXDependentScopeMemberExpr : public Expr { |
|
597 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) CXXDependentScopeMemberExpr |
|
598 + : public Expr { |
|
599 /// \brief The expression for the base pointer or class reference, |
|
600 /// e.g., the \c x in x.f. Can be null in implicit accesses. |
|
601 Stmt *Base; |
|
602 @@ -3177,6 +3251,10 @@ |
|
603 friend class ASTStmtReader; |
|
604 friend class ASTStmtWriter; |
|
605 }; |
|
606 +static_assert(llvm::AlignOf<CXXDependentScopeMemberExpr>::Alignment >= |
|
607 + llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment, |
|
608 + "Alignment is insufficient for objects appended to " |
|
609 + "CXXDependentScopeMemberExpr"); |
|
610 |
|
611 /// \brief Represents a C++ member access expression for which lookup |
|
612 /// produced a set of overloaded functions. |
|
613 @@ -3193,7 +3271,8 @@ |
|
614 /// In the final AST, an explicit access always becomes a MemberExpr. |
|
615 /// An implicit access may become either a MemberExpr or a |
|
616 /// DeclRefExpr, depending on whether the member is static. |
|
617 -class UnresolvedMemberExpr : public OverloadExpr { |
|
618 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) UnresolvedMemberExpr |
|
619 + : public OverloadExpr { |
|
620 /// \brief Whether this member expression used the '->' operator or |
|
621 /// the '.' operator. |
|
622 bool IsArrow : 1; |
|
623 @@ -3316,6 +3395,21 @@ |
|
624 return child_range(&Base, &Base + 1); |
|
625 } |
|
626 }; |
|
627 +static_assert( |
|
628 + llvm::AlignOf<UnresolvedMemberExpr>::Alignment >= |
|
629 + llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment, |
|
630 + "Alignment is insufficient for objects appended to UnresolvedMemberExpr"); |
|
631 + |
|
632 +inline ASTTemplateKWAndArgsInfo *OverloadExpr::getTemplateKWAndArgsInfo() { |
|
633 + if (!HasTemplateKWAndArgsInfo) |
|
634 + return nullptr; |
|
635 + if (isa<UnresolvedLookupExpr>(this)) |
|
636 + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( |
|
637 + cast<UnresolvedLookupExpr>(this) + 1); |
|
638 + else |
|
639 + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( |
|
640 + cast<UnresolvedMemberExpr>(this) + 1); |
|
641 +} |
|
642 |
|
643 /// \brief Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]). |
|
644 /// |
|
645 @@ -3438,15 +3532,6 @@ |
|
646 } |
|
647 }; |
|
648 |
|
649 -inline ASTTemplateKWAndArgsInfo *OverloadExpr::getTemplateKWAndArgsInfo() { |
|
650 - if (!HasTemplateKWAndArgsInfo) return nullptr; |
|
651 - if (isa<UnresolvedLookupExpr>(this)) |
|
652 - return reinterpret_cast<ASTTemplateKWAndArgsInfo*> |
|
653 - (cast<UnresolvedLookupExpr>(this) + 1); |
|
654 - else |
|
655 - return reinterpret_cast<ASTTemplateKWAndArgsInfo*> |
|
656 - (cast<UnresolvedMemberExpr>(this) + 1); |
|
657 -} |
|
658 |
|
659 /// \brief Represents an expression that computes the length of a parameter |
|
660 /// pack. |
|
661 @@ -3709,6 +3794,10 @@ |
|
662 |
|
663 child_range children() { return child_range(); } |
|
664 }; |
|
665 +static_assert( |
|
666 + llvm::AlignOf<FunctionParmPackExpr>::Alignment >= |
|
667 + llvm::AlignOf<ParmVarDecl *>::Alignment, |
|
668 + "Alignment is insufficient for objects appended to FunctionParmPackExpr"); |
|
669 |
|
670 /// \brief Represents a prvalue temporary that is written into memory so that |
|
671 /// a reference can bind to it. |
|
672 --- tools/clang/include/clang/AST/ExprObjC.h 2014-12-18 09:13:56.000000000 -0800 |
|
673 +++ tools/clang/include/clang/AST/ExprObjC.h 2015-07-17 16:43:46.499286743 -0700 |
|
674 @@ -201,6 +201,10 @@ |
|
675 |
|
676 friend class ASTStmtReader; |
|
677 }; |
|
678 +static_assert( |
|
679 + llvm::AlignOf<ObjCArrayLiteral>::Alignment >= |
|
680 + llvm::AlignOf<Expr *>::Alignment, |
|
681 + "Alignment is insufficient for objects appended to ObjCArrayLiteral"); |
|
682 |
|
683 /// \brief An element in an Objective-C dictionary literal. |
|
684 /// |
|
685 @@ -231,6 +235,7 @@ |
|
686 /// ObjCDictionaryLiteral - AST node to represent objective-c dictionary |
|
687 /// literals; as in: @{@"name" : NSUserName(), @"date" : [NSDate date] }; |
|
688 class ObjCDictionaryLiteral : public Expr { |
|
689 +public: |
|
690 /// \brief Key/value pair used to store the key and value of a given element. |
|
691 /// |
|
692 /// Objects of this type are stored directly after the expression. |
|
693 @@ -251,6 +256,7 @@ |
|
694 unsigned NumExpansionsPlusOne; |
|
695 }; |
|
696 |
|
697 +private: |
|
698 /// \brief The number of elements in this dictionary literal. |
|
699 unsigned NumElements : 31; |
|
700 |
|
701 @@ -341,6 +347,7 @@ |
|
702 child_range children() { |
|
703 // Note: we're taking advantage of the layout of the KeyValuePair struct |
|
704 // here. If that struct changes, this code will need to change as well. |
|
705 + static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2, ""); |
|
706 return child_range(reinterpret_cast<Stmt **>(this + 1), |
|
707 reinterpret_cast<Stmt **>(this + 1) + NumElements * 2); |
|
708 } |
|
709 @@ -348,7 +355,14 @@ |
|
710 friend class ASTStmtReader; |
|
711 friend class ASTStmtWriter; |
|
712 }; |
|
713 - |
|
714 +static_assert( |
|
715 + llvm::AlignOf<ObjCDictionaryLiteral>::Alignment >= |
|
716 + llvm::AlignOf<ObjCDictionaryLiteral::KeyValuePair>::Alignment, |
|
717 + "Alignment is insufficient for objects appended to ObjCDictionaryLiteral"); |
|
718 +static_assert( |
|
719 + llvm::AlignOf<ObjCDictionaryLiteral::KeyValuePair>::Alignment >= |
|
720 + llvm::AlignOf<ObjCDictionaryLiteral::ExpansionData>::Alignment, |
|
721 + "Alignment is insufficient for objects appended to ObjCDictionaryLiteral"); |
|
722 |
|
723 /// ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same |
|
724 /// type and behavior as StringLiteral except that the string initializer is |
|
725 @@ -1394,6 +1408,17 @@ |
|
726 friend class ASTStmtReader; |
|
727 friend class ASTStmtWriter; |
|
728 }; |
|
729 +static_assert( |
|
730 + llvm::AlignOf<ObjCMessageExpr>::Alignment >= |
|
731 + llvm::AlignOf<void *>::Alignment, |
|
732 + "Alignment is insufficient for objects appended to ObjCMessageExpr"); |
|
733 +static_assert( |
|
734 + llvm::AlignOf<void *>::Alignment >= llvm::AlignOf<Expr *>::Alignment, |
|
735 + "Alignment is insufficient for objects appended to ObjCMessageExpr"); |
|
736 +static_assert( |
|
737 + llvm::AlignOf<Expr *>::Alignment >= |
|
738 + llvm::AlignOf<SourceLocation>::Alignment, |
|
739 + "Alignment is insufficient for objects appended to ObjCMessageExpr"); |
|
740 |
|
741 /// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type. |
|
742 /// (similar in spirit to MemberExpr). |
|
743 --- tools/clang/include/clang/AST/Stmt.h 2015-01-12 02:17:46.000000000 -0800 |
|
744 +++ tools/clang/include/clang/AST/Stmt.h 2015-07-17 16:43:46.502138721 -0700 |
|
745 @@ -865,7 +865,10 @@ |
|
746 return T->getStmtClass() == AttributedStmtClass; |
|
747 } |
|
748 }; |
|
749 - |
|
750 +static_assert( |
|
751 + llvm::AlignOf<AttributedStmt>::Alignment >= |
|
752 + llvm::AlignOf<Attr *>::Alignment, |
|
753 + "Alignment is insufficient for objects appended to AttributedStmt"); |
|
754 |
|
755 /// IfStmt - This represents an if/then/else. |
|
756 /// |
|
757 @@ -2070,8 +2073,10 @@ |
|
758 /// \brief Construct an empty captured statement. |
|
759 CapturedStmt(EmptyShell Empty, unsigned NumCaptures); |
|
760 |
|
761 - Stmt **getStoredStmts() const { |
|
762 - return reinterpret_cast<Stmt **>(const_cast<CapturedStmt *>(this) + 1); |
|
763 + Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); } |
|
764 + |
|
765 + Stmt *const *getStoredStmts() const { |
|
766 + return reinterpret_cast<Stmt *const *>(this + 1); |
|
767 } |
|
768 |
|
769 Capture *getStoredCaptures() const; |
|
770 @@ -2090,14 +2095,12 @@ |
|
771 |
|
772 /// \brief Retrieve the statement being captured. |
|
773 Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; } |
|
774 - const Stmt *getCapturedStmt() const { |
|
775 - return const_cast<CapturedStmt *>(this)->getCapturedStmt(); |
|
776 - } |
|
777 + const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; } |
|
778 |
|
779 /// \brief Retrieve the outlined function declaration. |
|
780 CapturedDecl *getCapturedDecl() { return CapDeclAndKind.getPointer(); } |
|
781 const CapturedDecl *getCapturedDecl() const { |
|
782 - return const_cast<CapturedStmt *>(this)->getCapturedDecl(); |
|
783 + return CapDeclAndKind.getPointer(); |
|
784 } |
|
785 |
|
786 /// \brief Set the outlined function declaration. |
|
787 @@ -2158,18 +2161,36 @@ |
|
788 typedef Expr **capture_init_iterator; |
|
789 typedef llvm::iterator_range<capture_init_iterator> capture_init_range; |
|
790 |
|
791 - capture_init_range capture_inits() const { |
|
792 + /// \brief Const iterator that walks over the capture initialization |
|
793 + /// arguments. |
|
794 + typedef Expr *const *const_capture_init_iterator; |
|
795 + typedef llvm::iterator_range<const_capture_init_iterator> |
|
796 + const_capture_init_range; |
|
797 + |
|
798 + capture_init_range capture_inits() { |
|
799 return capture_init_range(capture_init_begin(), capture_init_end()); |
|
800 } |
|
801 |
|
802 + const_capture_init_range capture_inits() const { |
|
803 + return const_capture_init_range(capture_init_begin(), capture_init_end()); |
|
804 + } |
|
805 + |
|
806 /// \brief Retrieve the first initialization argument. |
|
807 - capture_init_iterator capture_init_begin() const { |
|
808 + capture_init_iterator capture_init_begin() { |
|
809 return reinterpret_cast<Expr **>(getStoredStmts()); |
|
810 } |
|
811 |
|
812 + const_capture_init_iterator capture_init_begin() const { |
|
813 + return reinterpret_cast<Expr *const *>(getStoredStmts()); |
|
814 + } |
|
815 + |
|
816 /// \brief Retrieve the iterator pointing one past the last initialization |
|
817 /// argument. |
|
818 - capture_init_iterator capture_init_end() const { |
|
819 + capture_init_iterator capture_init_end() { |
|
820 + return capture_init_begin() + NumCaptures; |
|
821 + } |
|
822 + |
|
823 + const_capture_init_iterator capture_init_end() const { |
|
824 return capture_init_begin() + NumCaptures; |
|
825 } |
|
826 |
|
827 @@ -2191,6 +2212,13 @@ |
|
828 |
|
829 friend class ASTStmtReader; |
|
830 }; |
|
831 +static_assert(llvm::AlignOf<CapturedStmt>::Alignment >= |
|
832 + llvm::AlignOf<Stmt *>::Alignment, |
|
833 + "Alignment is insufficient for objects appended to CapturedStmt"); |
|
834 +// Code re-aligns before Capture[] |
|
835 +static_assert(llvm::AlignOf<CapturedStmt>::Alignment >= |
|
836 + llvm::AlignOf<CapturedStmt::Capture>::Alignment, |
|
837 + "Alignment is insufficient for objects appended to CapturedStmt"); |
|
838 |
|
839 } // end namespace clang |
|
840 |
|
841 --- tools/clang/include/clang/AST/StmtCXX.h 2014-05-05 23:48:52.000000000 -0700 |
|
842 +++ tools/clang/include/clang/AST/StmtCXX.h 2015-07-17 16:43:46.503758907 -0700 |
|
843 @@ -118,6 +118,9 @@ |
|
844 |
|
845 friend class ASTStmtReader; |
|
846 }; |
|
847 +static_assert(llvm::AlignOf<CXXTryStmt>::Alignment >= |
|
848 + llvm::AlignOf<Stmt *>::Alignment, |
|
849 + "Alignment is insufficient for objects appended to CXXTryStmt"); |
|
850 |
|
851 /// CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for |
|
852 /// statement, represented as 'for (range-declarator : range-expression)'. |
|
853 --- tools/clang/include/clang/AST/StmtObjC.h 2014-05-05 23:48:52.000000000 -0700 |
|
854 +++ tools/clang/include/clang/AST/StmtObjC.h 2015-07-17 16:43:46.505254168 -0700 |
|
855 @@ -249,6 +249,9 @@ |
|
856 getStmts() + 1 + NumCatchStmts + HasFinally); |
|
857 } |
|
858 }; |
|
859 +static_assert( |
|
860 + llvm::AlignOf<ObjCAtTryStmt>::Alignment >= llvm::AlignOf<Stmt *>::Alignment, |
|
861 + "Alignment is insufficient for objects appended to ObjCAtTryStmt"); |
|
862 |
|
863 /// \brief Represents Objective-C's \@synchronized statement. |
|
864 /// |
|
865 --- tools/clang/include/clang/AST/TemplateBase.h 2015-01-14 03:29:14.000000000 -0800 |
|
866 +++ tools/clang/include/clang/AST/TemplateBase.h 2015-07-17 16:43:46.506876445 -0700 |
|
867 @@ -360,6 +360,20 @@ |
|
868 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const; |
|
869 }; |
|
870 |
|
871 +static_assert(llvm::AlignOf<TemplateSpecializationType>::Alignment >= |
|
872 + llvm::AlignOf<TemplateArgument>::Alignment, |
|
873 + "Alignment is insufficient for objects appended to " |
|
874 + "TemplateSpecializationType"); |
|
875 +static_assert(llvm::AlignOf<TemplateArgument>::Alignment >= |
|
876 + llvm::AlignOf<QualType>::Alignment, |
|
877 + "Alignment is insufficient for objects appended to " |
|
878 + "TemplateSpecializationType"); |
|
879 + |
|
880 +static_assert(llvm::AlignOf<DependentTemplateSpecializationType>::Alignment >= |
|
881 + llvm::AlignOf<TemplateArgument>::Alignment, |
|
882 + "Alignment is insufficient for objects appended to " |
|
883 + "DependentTemplateSpecializationType"); |
|
884 + |
|
885 /// Location information for a TemplateArgument. |
|
886 struct TemplateArgumentLocInfo { |
|
887 private: |
|
888 @@ -604,6 +618,10 @@ |
|
889 void copyInto(TemplateArgumentListInfo &List) const; |
|
890 static std::size_t sizeFor(unsigned NumTemplateArgs); |
|
891 }; |
|
892 +static_assert(llvm::AlignOf<ASTTemplateArgumentListInfo>::Alignment >= |
|
893 + llvm::AlignOf<TemplateArgumentLoc>::Alignment, |
|
894 + "Alignment is insufficient for objects appended to " |
|
895 + "ASTTemplateArgumentListInfo"); |
|
896 |
|
897 /// \brief Extends ASTTemplateArgumentListInfo with the source location |
|
898 /// information for the template keyword; this is used as part of the |
|
899 @@ -640,6 +658,18 @@ |
|
900 |
|
901 static std::size_t sizeFor(unsigned NumTemplateArgs); |
|
902 }; |
|
903 +static_assert(llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment >= |
|
904 + llvm::AlignOf<TemplateArgumentLoc>::Alignment, |
|
905 + "Alignment is insufficient for objects appended to " |
|
906 + "ASTTemplateKWAndArgsInfo"); |
|
907 +static_assert(llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment >= |
|
908 + llvm::AlignOf<SourceLocation>::Alignment, |
|
909 + "Alignment is insufficient for objects appended to " |
|
910 + "ASTTemplateKWAndArgsInfo"); |
|
911 +static_assert(llvm::AlignOf<TemplateArgumentLoc>::Alignment >= |
|
912 + llvm::AlignOf<SourceLocation>::Alignment, |
|
913 + "Alignment is insufficient for objects appended to " |
|
914 + "ASTTemplateKWAndArgsInfo"); |
|
915 |
|
916 const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, |
|
917 const TemplateArgument &Arg); |
|
918 --- tools/clang/include/clang/AST/TemplateName.h 2014-05-10 13:57:56.000000000 -0700 |
|
919 +++ tools/clang/include/clang/AST/TemplateName.h 2015-07-17 16:43:46.508333537 -0700 |
|
920 @@ -108,6 +108,10 @@ |
|
921 iterator begin() const { return getStorage(); } |
|
922 iterator end() const { return getStorage() + size(); } |
|
923 }; |
|
924 +static_assert(llvm::AlignOf<OverloadedTemplateStorage>::Alignment >= |
|
925 + llvm::AlignOf<NamedDecl *>::Alignment, |
|
926 + "Alignment is insufficient for objects appended to " |
|
927 + "OverloadedTemplateStorage"); |
|
928 |
|
929 /// \brief A structure for storing an already-substituted template template |
|
930 /// parameter pack. |
|
931 --- tools/clang/include/clang/AST/Type.h 2015-01-14 03:29:14.000000000 -0800 |
|
932 +++ tools/clang/include/clang/AST/Type.h 2015-07-17 16:43:46.512517865 -0700 |
|
933 @@ -2991,11 +2991,13 @@ |
|
934 assert(hasAnyConsumedParams()); |
|
935 |
|
936 // Find the end of the exceptions. |
|
937 - Expr *const *eh_end = reinterpret_cast<Expr *const *>(param_type_end()); |
|
938 - if (getExceptionSpecType() != EST_ComputedNoexcept) |
|
939 - eh_end += NumExceptions; |
|
940 - else |
|
941 + Expr *const *eh_end = reinterpret_cast<Expr *const *>(exception_end()); |
|
942 + if (getExceptionSpecType() == EST_ComputedNoexcept) |
|
943 eh_end += 1; // NoexceptExpr |
|
944 + // The memory layout of these types isn't handled here, so |
|
945 + // hopefully this is never called for them? |
|
946 + assert(getExceptionSpecType() != EST_Uninstantiated && |
|
947 + getExceptionSpecType() != EST_Unevaluated); |
|
948 |
|
949 return reinterpret_cast<const bool*>(eh_end); |
|
950 } |
|
951 @@ -3167,7 +3169,29 @@ |
|
952 param_type_iterator ArgTys, unsigned NumArgs, |
|
953 const ExtProtoInfo &EPI, const ASTContext &Context); |
|
954 }; |
|
955 - |
|
956 +static_assert( |
|
957 + llvm::AlignOf<FunctionProtoType>::Alignment >= |
|
958 + llvm::AlignOf<QualType>::Alignment, |
|
959 + "Alignment is insufficient for objects appended to FunctionProtoType"); |
|
960 +// After QualType[], there can be one of 4 options: more QualType, Expr*, 2x |
|
961 +// FunctionDecl*, FunctionDecl* |
|
962 +static_assert( |
|
963 + llvm::AlignOf<QualType>::Alignment >= llvm::AlignOf<Expr *>::Alignment, |
|
964 + "Alignment is insufficient for objects appended to FunctionProtoType"); |
|
965 +static_assert( |
|
966 + llvm::AlignOf<QualType>::Alignment >= |
|
967 + llvm::AlignOf<FunctionDecl *>::Alignment, |
|
968 + "Alignment is insufficient for objects appended to FunctionProtoType"); |
|
969 +// And then, after any of those options, comes bool[] |
|
970 +static_assert( |
|
971 + llvm::AlignOf<QualType>::Alignment >= llvm::AlignOf<bool>::Alignment, |
|
972 + "Alignment is insufficient for objects appended to FunctionProtoType"); |
|
973 +static_assert( |
|
974 + llvm::AlignOf<Expr *>::Alignment >= llvm::AlignOf<bool>::Alignment, |
|
975 + "Alignment is insufficient for objects appended to FunctionProtoType"); |
|
976 +static_assert( |
|
977 + llvm::AlignOf<FunctionDecl *>::Alignment >= llvm::AlignOf<bool>::Alignment, |
|
978 + "Alignment is insufficient for objects appended to FunctionProtoType"); |
|
979 |
|
980 /// \brief Represents the dependent type named by a dependently-scoped |
|
981 /// typename using declaration, e.g. |
|
982 @@ -3777,8 +3801,9 @@ |
|
983 /// TemplateArguments, followed by a QualType representing the |
|
984 /// non-canonical aliased type when the template is a type alias |
|
985 /// template. |
|
986 -class TemplateSpecializationType |
|
987 - : public Type, public llvm::FoldingSetNode { |
|
988 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) TemplateSpecializationType |
|
989 + : public Type, |
|
990 + public llvm::FoldingSetNode { |
|
991 /// \brief The name of the template being specialized. This is |
|
992 /// either a TemplateName::Template (in which case it is a |
|
993 /// ClassTemplateDecl*, a TemplateTemplateParmDecl*, or a |
|
994 @@ -3900,6 +3925,13 @@ |
|
995 return T->getTypeClass() == TemplateSpecialization; |
|
996 } |
|
997 }; |
|
998 +// static_assert(llvm::AlignOf<TemplateSpecializationType>::Alignment >= |
|
999 +// llvm::AlignOf<TemplateArgument>::Alignment, "Alignment is insufficient for |
|
1000 +// objects appended to TemplateSpecializationType"); |
|
1001 +// static_assert(llvm::AlignOf<TemplateArgument>::Alignment >= |
|
1002 +// llvm::AlignOf<QualType>::Alignment, "Alignment is insufficient for objects |
|
1003 +// appended to TemplateSpecializationType"); |
|
1004 +// ^ Moved after class TemplateArgument, as it is is forward declared here. |
|
1005 |
|
1006 /// \brief The injected class name of a C++ class template or class |
|
1007 /// template partial specialization. Used to record that a type was |
|
1008 @@ -4175,8 +4207,9 @@ |
|
1009 /// DependentTemplateSpecializationType - Represents a template |
|
1010 /// specialization type whose template cannot be resolved, e.g. |
|
1011 /// A<T>::template B<T> |
|
1012 -class DependentTemplateSpecializationType : |
|
1013 - public TypeWithKeyword, public llvm::FoldingSetNode { |
|
1014 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) DependentTemplateSpecializationType |
|
1015 + : public TypeWithKeyword, |
|
1016 + public llvm::FoldingSetNode { |
|
1017 |
|
1018 /// \brief The nested name specifier containing the qualifier. |
|
1019 NestedNameSpecifier *NNS; |
|
1020 @@ -4241,6 +4274,10 @@ |
|
1021 return T->getTypeClass() == DependentTemplateSpecialization; |
|
1022 } |
|
1023 }; |
|
1024 +// static_assert(llvm::AlignOf<DependentTemplateSpecializationType>::Alignment |
|
1025 +// >= llvm::AlignOf<TemplateArgument>::Alignment, "Alignment is insufficient for |
|
1026 +// objects appended to DependentTemplateSpecializationType"); |
|
1027 +// ^ Moved after class TemplateArgument, as it is is forward declared here. |
|
1028 |
|
1029 /// \brief Represents a pack expansion of types. |
|
1030 /// |
|
1031 @@ -4456,6 +4493,10 @@ |
|
1032 ObjCProtocolDecl *const *protocols, |
|
1033 unsigned NumProtocols); |
|
1034 }; |
|
1035 +static_assert( |
|
1036 + llvm::AlignOf<ObjCObjectTypeImpl>::Alignment >= |
|
1037 + llvm::AlignOf<ObjCProtocolDecl *>::Alignment, |
|
1038 + "Alignment is insufficient for objects appended to ObjCObjectTypeImpl"); |
|
1039 |
|
1040 inline ObjCProtocolDecl **ObjCObjectType::getProtocolStorage() { |
|
1041 return reinterpret_cast<ObjCProtocolDecl**>( |
|
1042 --- tools/clang/include/clang/AST/TypeLoc.h 2014-10-24 06:52:55.000000000 -0700 |
|
1043 +++ tools/clang/include/clang/AST/TypeLoc.h 2015-07-17 16:43:46.514327822 -0700 |
|
1044 @@ -199,6 +199,7 @@ |
|
1045 |
|
1046 /// \brief Return the TypeLoc for a type source info. |
|
1047 inline TypeLoc TypeSourceInfo::getTypeLoc() const { |
|
1048 + // TODO: is this alignment already sufficient? |
|
1049 return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1))); |
|
1050 } |
|
1051 |
|
1052 --- tools/clang/include/clang/CodeGen/CGFunctionInfo.h 2014-12-12 15:41:25.000000000 -0800 |
|
1053 +++ tools/clang/include/clang/CodeGen/CGFunctionInfo.h 2015-07-17 16:43:46.515714903 -0700 |
|
1054 @@ -333,11 +333,13 @@ |
|
1055 /// CGFunctionInfo - Class to encapsulate the information about a |
|
1056 /// function definition. |
|
1057 class CGFunctionInfo : public llvm::FoldingSetNode { |
|
1058 +public: |
|
1059 struct ArgInfo { |
|
1060 CanQualType type; |
|
1061 ABIArgInfo info; |
|
1062 }; |
|
1063 |
|
1064 +private: |
|
1065 /// The LLVM::CallingConv to use for this function (as specified by the |
|
1066 /// user). |
|
1067 unsigned CallingConvention : 8; |
|
1068 @@ -500,6 +502,10 @@ |
|
1069 } |
|
1070 } |
|
1071 }; |
|
1072 +static_assert( |
|
1073 + llvm::AlignOf<CGFunctionInfo>::Alignment >= |
|
1074 + llvm::AlignOf<CGFunctionInfo::ArgInfo>::Alignment, |
|
1075 + "Alignment is insufficient for objects appended to CGFunctionInfo"); |
|
1076 |
|
1077 } // end namespace CodeGen |
|
1078 } // end namespace clang |
|
1079 --- tools/clang/include/clang/Lex/MacroArgs.h 2014-08-13 12:25:19.000000000 -0400 |
|
1080 +++ tools/clang/include/clang/Lex/MacroArgs.h 2015-07-17 22:23:39.000000000 -0400 |
|
1081 @@ -15,13 +15,13 @@ |
|
1082 #define LLVM_CLANG_LEX_MACROARGS_H |
|
1083 |
|
1084 #include "clang/Basic/LLVM.h" |
|
1085 +#include "clang/Lex/Token.h" |
|
1086 #include "llvm/ADT/ArrayRef.h" |
|
1087 #include <vector> |
|
1088 |
|
1089 namespace clang { |
|
1090 class MacroInfo; |
|
1091 class Preprocessor; |
|
1092 - class Token; |
|
1093 class SourceLocation; |
|
1094 |
|
1095 /// MacroArgs - An instance of this class captures information about |
|
1096 @@ -120,6 +120,9 @@ |
|
1097 /// its freelist. |
|
1098 MacroArgs *deallocate(); |
|
1099 }; |
|
1100 +static_assert(llvm::AlignOf<MacroArgs>::Alignment >= |
|
1101 + llvm::AlignOf<Token>::Alignment, |
|
1102 + "Alignment is insufficient for objects appended to MacroArgs"); |
|
1103 |
|
1104 } // end namespace clang |
|
1105 |
|
1106 --- tools/clang/include/clang/Lex/MacroInfo.h 2014-08-13 12:25:19.000000000 -0400 |
|
1107 +++ tools/clang/include/clang/Lex/MacroInfo.h 2015-07-18 01:52:39.590867365 -0400 |
|
1108 @@ -17,11 +17,15 @@ |
|
1109 |
|
1110 #include "clang/Lex/Token.h" |
|
1111 #include "llvm/ADT/ArrayRef.h" |
|
1112 +#include "llvm/ADT/FoldingSet.h" |
|
1113 +#include "llvm/ADT/PointerIntPair.h" |
|
1114 #include "llvm/ADT/SmallVector.h" |
|
1115 #include "llvm/Support/Allocator.h" |
|
1116 #include <cassert> |
|
1117 |
|
1118 namespace clang { |
|
1119 +class Module; |
|
1120 +class ModuleMacro; |
|
1121 class Preprocessor; |
|
1122 |
|
1123 /// \brief Encapsulates the data about a macro definition (e.g. its tokens). |
|
1124 @@ -294,6 +298,9 @@ |
|
1125 |
|
1126 friend class Preprocessor; |
|
1127 }; |
|
1128 +static_assert(llvm::AlignOf<MacroInfo>::Alignment >= |
|
1129 + llvm::AlignOf<unsigned>::Alignment, |
|
1130 + "Alignment is insufficient for objects appended to MacroInfo"); |
|
1131 |
|
1132 class DefMacroDirective; |
|
1133 |
|
1134 @@ -517,6 +524,75 @@ |
|
1135 static bool classof(const DefMacroDirective *) { return true; } |
|
1136 }; |
|
1137 |
|
1138 +/// \brief Represents a macro directive exported by a module. |
|
1139 +/// |
|
1140 +/// There's an instance of this class for every macro #define or #undef that is |
|
1141 +/// the final directive for a macro name within a module. These entities also |
|
1142 +/// represent the macro override graph. |
|
1143 +/// |
|
1144 +/// These are stored in a FoldingSet in the preprocessor. |
|
1145 +class ModuleMacro : public llvm::FoldingSetNode { |
|
1146 + /// The name defined by the macro. |
|
1147 + IdentifierInfo *II; |
|
1148 + /// The body of the #define, or nullptr if this is a #undef. |
|
1149 + MacroInfo *Macro; |
|
1150 + /// The module that exports this macro. |
|
1151 + Module *OwningModule; |
|
1152 + /// The number of module macros that override this one. |
|
1153 + unsigned NumOverriddenBy; |
|
1154 + /// The number of modules whose macros are directly overridden by this one. |
|
1155 + unsigned NumOverrides; |
|
1156 + // ModuleMacro *OverriddenMacros[NumOverrides]; |
|
1157 + |
|
1158 + friend class Preprocessor; |
|
1159 + |
|
1160 + ModuleMacro(Module *OwningModule, IdentifierInfo *II, MacroInfo *Macro, |
|
1161 + ArrayRef<ModuleMacro *> Overrides) |
|
1162 + : II(II), Macro(Macro), OwningModule(OwningModule), NumOverriddenBy(0), |
|
1163 + NumOverrides(Overrides.size()) { |
|
1164 + std::copy(Overrides.begin(), Overrides.end(), |
|
1165 + reinterpret_cast<ModuleMacro **>(this + 1)); |
|
1166 + } |
|
1167 + |
|
1168 +public: |
|
1169 + static ModuleMacro *create(Preprocessor &PP, Module *OwningModule, |
|
1170 + IdentifierInfo *II, MacroInfo *Macro, |
|
1171 + ArrayRef<ModuleMacro *> Overrides); |
|
1172 + |
|
1173 + void Profile(llvm::FoldingSetNodeID &ID) const { |
|
1174 + return Profile(ID, OwningModule, II); |
|
1175 + } |
|
1176 + static void Profile(llvm::FoldingSetNodeID &ID, Module *OwningModule, |
|
1177 + IdentifierInfo *II) { |
|
1178 + ID.AddPointer(OwningModule); |
|
1179 + ID.AddPointer(II); |
|
1180 + } |
|
1181 + |
|
1182 + /// Get the ID of the module that exports this macro. |
|
1183 + Module *getOwningModule() const { return OwningModule; } |
|
1184 + |
|
1185 + /// Get definition for this exported #define, or nullptr if this |
|
1186 + /// represents a #undef. |
|
1187 + MacroInfo *getMacroInfo() const { return Macro; } |
|
1188 + |
|
1189 + /// Iterators over the overridden module IDs. |
|
1190 + /// \{ |
|
1191 + typedef ModuleMacro *const *overrides_iterator; |
|
1192 + overrides_iterator overrides_begin() const { |
|
1193 + return reinterpret_cast<overrides_iterator>(this + 1); |
|
1194 + } |
|
1195 + overrides_iterator overrides_end() const { |
|
1196 + return overrides_begin() + NumOverrides; |
|
1197 + } |
|
1198 + ArrayRef<ModuleMacro *> overrides() const { |
|
1199 + return llvm::makeArrayRef(overrides_begin(), overrides_end()); |
|
1200 + } |
|
1201 + /// \} |
|
1202 + |
|
1203 + /// Get the number of macros that override this one. |
|
1204 + unsigned getNumOverridingMacros() const { return NumOverriddenBy; } |
|
1205 +}; |
|
1206 + |
|
1207 /// \brief A directive for an undefined macro. |
|
1208 class UndefMacroDirective : public MacroDirective { |
|
1209 public: |
|
1210 @@ -550,6 +626,9 @@ |
|
1211 } |
|
1212 static bool classof(const VisibilityMacroDirective *) { return true; } |
|
1213 }; |
|
1214 +static_assert(llvm::AlignOf<ModuleMacro>::Alignment >= |
|
1215 + llvm::AlignOf<ModuleMacro *>::Alignment, |
|
1216 + "Alignment is insufficient for objects appended to ModuleMacro"); |
|
1217 |
|
1218 inline unsigned *MacroDirective::getModuleDataStart() { |
|
1219 if (auto *Def = dyn_cast<DefMacroDirective>(this)) |
|
1220 --- tools/clang/include/clang/Sema/AttributeList.h 2015-01-20 11:27:49.000000000 -0800 |
|
1221 +++ tools/clang/include/clang/Sema/AttributeList.h 2015-07-17 16:43:46.520539511 -0700 |
|
1222 @@ -135,9 +135,7 @@ |
|
1223 AttributeList *NextInPool; |
|
1224 |
|
1225 /// Arguments, if any, are stored immediately following the object. |
|
1226 - ArgsUnion *getArgsBuffer() { |
|
1227 - return reinterpret_cast<ArgsUnion*>(this+1); |
|
1228 - } |
|
1229 + ArgsUnion *getArgsBuffer() { return reinterpret_cast<ArgsUnion *>(this + 1); } |
|
1230 ArgsUnion const *getArgsBuffer() const { |
|
1231 return reinterpret_cast<ArgsUnion const *>(this+1); |
|
1232 } |
|
1233 @@ -468,6 +466,26 @@ |
|
1234 /// a Spelling enumeration, the value UINT_MAX is returned. |
|
1235 unsigned getSemanticSpelling() const; |
|
1236 }; |
|
1237 +static_assert( |
|
1238 + llvm::AlignOf<AttributeList>::Alignment >= |
|
1239 + llvm::AlignOf<ArgsUnion>::Alignment, |
|
1240 + "Alignment is insufficient for objects appended to AttributeList"); |
|
1241 +static_assert( |
|
1242 + llvm::AlignOf<ArgsUnion>::Alignment >= |
|
1243 + llvm::AlignOf<AvailabilityChange>::Alignment, |
|
1244 + "Alignment is insufficient for objects appended to AttributeList"); |
|
1245 +static_assert( |
|
1246 + llvm::AlignOf<ArgsUnion>::Alignment >= |
|
1247 + llvm::AlignOf<AttributeList::TypeTagForDatatypeData>::Alignment, |
|
1248 + "Alignment is insufficient for objects appended to AttributeList"); |
|
1249 +static_assert( |
|
1250 + llvm::AlignOf<AttributeList>::Alignment >= |
|
1251 + llvm::AlignOf<ParsedType>::Alignment, |
|
1252 + "Alignment is insufficient for objects appended to AttributeList"); |
|
1253 +static_assert( |
|
1254 + llvm::AlignOf<AttributeList>::Alignment >= |
|
1255 + llvm::AlignOf<AttributeList::PropertyData>::Alignment, |
|
1256 + "Alignment is insufficient for objects appended to AttributeList"); |
|
1257 |
|
1258 /// A factory, from which one makes pools, from which one creates |
|
1259 /// individual attributes which are deallocated with the pool. |
|
1260 --- tools/clang/include/clang/Sema/CodeCompleteConsumer.h 2014-05-05 23:48:52.000000000 -0700 |
|
1261 +++ tools/clang/include/clang/Sema/CodeCompleteConsumer.h 2015-07-17 16:43:46.522097320 -0700 |
|
1262 @@ -493,6 +493,14 @@ |
|
1263 /// which is mainly useful for debugging. |
|
1264 std::string getAsString() const; |
|
1265 }; |
|
1266 +static_assert( |
|
1267 + llvm::AlignOf<CodeCompletionString>::Alignment >= |
|
1268 + llvm::AlignOf<CodeCompletionString::Chunk>::Alignment, |
|
1269 + "Alignment is insufficient for objects appended to CodeCompletionString"); |
|
1270 +static_assert( |
|
1271 + llvm::AlignOf<CodeCompletionString::Chunk>::Alignment >= |
|
1272 + llvm::AlignOf<const char *>::Alignment, |
|
1273 + "Alignment is insufficient for objects appended to CodeCompletionString"); |
|
1274 |
|
1275 /// \brief An allocator used specifically for the purpose of code completion. |
|
1276 class CodeCompletionAllocator : public llvm::BumpPtrAllocator { |
|
1277 --- tools/clang/include/clang/Sema/ParsedTemplate.h 2014-05-05 23:48:52.000000000 -0700 |
|
1278 +++ tools/clang/include/clang/Sema/ParsedTemplate.h 2015-07-17 16:43:46.523177530 -0700 |
|
1279 @@ -205,6 +205,10 @@ |
|
1280 free(this); |
|
1281 } |
|
1282 }; |
|
1283 + static_assert( |
|
1284 + llvm::AlignOf<TemplateIdAnnotation>::Alignment >= |
|
1285 + llvm::AlignOf<ParsedTemplateArgument>::Alignment, |
|
1286 + "Alignment is insufficient for objects appended to TemplateIdAnnotation"); |
|
1287 |
|
1288 /// Retrieves the range of the given template parameter lists. |
|
1289 SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, |
|
1290 --- tools/clang/lib/AST/Decl.cpp 2015-05-04 11:23:59.000000000 -0700 |
|
1291 +++ tools/clang/lib/AST/Decl.cpp 2015-07-17 16:43:46.525788978 -0700 |
|
1292 @@ -3064,8 +3064,8 @@ |
|
1293 const TemplateArgumentListInfo &TemplateArgs) { |
|
1294 assert(TemplateOrSpecialization.isNull()); |
|
1295 size_t Size = sizeof(DependentFunctionTemplateSpecializationInfo); |
|
1296 - Size += Templates.size() * sizeof(FunctionTemplateDecl*); |
|
1297 Size += TemplateArgs.size() * sizeof(TemplateArgumentLoc); |
|
1298 + Size += Templates.size() * sizeof(FunctionTemplateDecl *); |
|
1299 void *Buffer = Context.Allocate(Size); |
|
1300 DependentFunctionTemplateSpecializationInfo *Info = |
|
1301 new (Buffer) DependentFunctionTemplateSpecializationInfo(Templates, |
|
1302 @@ -3078,8 +3078,8 @@ |
|
1303 const TemplateArgumentListInfo &TArgs) |
|
1304 : AngleLocs(TArgs.getLAngleLoc(), TArgs.getRAngleLoc()) { |
|
1305 |
|
1306 - d.NumTemplates = Ts.size(); |
|
1307 - d.NumArgs = TArgs.size(); |
|
1308 + NumTemplates = Ts.size(); |
|
1309 + NumArgs = TArgs.size(); |
|
1310 |
|
1311 FunctionTemplateDecl **TsArray = |
|
1312 const_cast<FunctionTemplateDecl**>(getTemplates()); |
|
1313 --- tools/clang/lib/AST/DeclBase.cpp 2014-11-17 15:36:45.000000000 -0800 |
|
1314 +++ tools/clang/lib/AST/DeclBase.cpp 2015-07-17 17:03:06.999226816 -0700 |
|
1315 @@ -45,14 +45,28 @@ |
|
1316 getASTContext().getExternalSource()->updateOutOfDateIdentifier(II); |
|
1317 } |
|
1318 |
|
1319 +#define DECL(DERIVED, BASE) \ |
|
1320 + static_assert(llvm::AlignOf<uint64_t>::Alignment >= \ |
|
1321 + llvm::AlignOf<DERIVED##Decl>::Alignment, \ |
|
1322 + "Alignment is insufficient for objects appended to all Decl " \ |
|
1323 + "subclasses"); |
|
1324 +#define ABSTRACT_DECL(DECL) |
|
1325 +#include "clang/AST/DeclNodes.inc" |
|
1326 + |
|
1327 void *Decl::operator new(std::size_t Size, const ASTContext &Context, |
|
1328 unsigned ID, std::size_t Extra) { |
|
1329 // Allocate an extra 8 bytes worth of storage, which ensures that the |
|
1330 // resulting pointer will still be 8-byte aligned. |
|
1331 - void *Start = Context.Allocate(Size + Extra + 8); |
|
1332 - void *Result = (char*)Start + 8; |
|
1333 + static_assert(sizeof(unsigned) * 2 >= llvm::AlignOf<uint64_t>::Alignment, |
|
1334 + "sizeof(unsigned) * 2 < llvm::AlignOf<uint64_t>::Alignment!"); |
|
1335 + |
|
1336 + void *Start = Context.Allocate(Size + Extra + 8, 8U); |
|
1337 + void *Result = reinterpret_cast<void*>( |
|
1338 + reinterpret_cast<unsigned char*>( |
|
1339 + reinterpret_cast<unsigned char*>(Start) + 8)); |
|
1340 |
|
1341 - unsigned *PrefixPtr = (unsigned *)Result - 2; |
|
1342 + unsigned *PrefixPtr = |
|
1343 + reinterpret_cast<unsigned*>(reinterpret_cast<unsigned*>(Result) - 2); |
|
1344 |
|
1345 // Zero out the first 4 bytes; this is used to store the owning module ID. |
|
1346 PrefixPtr[0] = 0; |
|
1347 --- tools/clang/lib/AST/Expr.cpp 2015-01-12 02:17:46.000000000 -0800 |
|
1348 +++ tools/clang/lib/AST/Expr.cpp 2015-07-17 16:43:46.530620842 -0700 |
|
1349 @@ -399,10 +399,15 @@ |
|
1350 Size += sizeof(NestedNameSpecifierLoc); |
|
1351 if (FoundD) |
|
1352 Size += sizeof(NamedDecl *); |
|
1353 - if (TemplateArgs) |
|
1354 + if (TemplateArgs) { |
|
1355 + Size = llvm::RoundUpToAlignment(Size, |
|
1356 + llvm::alignOf<ASTTemplateKWAndArgsInfo>()); |
|
1357 Size += ASTTemplateKWAndArgsInfo::sizeFor(TemplateArgs->size()); |
|
1358 - else if (TemplateKWLoc.isValid()) |
|
1359 + } else if (TemplateKWLoc.isValid()) { |
|
1360 + Size = llvm::RoundUpToAlignment(Size, |
|
1361 + llvm::alignOf<ASTTemplateKWAndArgsInfo>()); |
|
1362 Size += ASTTemplateKWAndArgsInfo::sizeFor(0); |
|
1363 + } |
|
1364 |
|
1365 void *Mem = Context.Allocate(Size, llvm::alignOf<DeclRefExpr>()); |
|
1366 return new (Mem) DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D, |
|
1367 @@ -420,8 +425,11 @@ |
|
1368 Size += sizeof(NestedNameSpecifierLoc); |
|
1369 if (HasFoundDecl) |
|
1370 Size += sizeof(NamedDecl *); |
|
1371 - if (HasTemplateKWAndArgsInfo) |
|
1372 + if (HasTemplateKWAndArgsInfo) { |
|
1373 + Size = llvm::RoundUpToAlignment(Size, |
|
1374 + llvm::alignOf<ASTTemplateKWAndArgsInfo>()); |
|
1375 Size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); |
|
1376 + } |
|
1377 |
|
1378 void *Mem = Context.Allocate(Size, llvm::alignOf<DeclRefExpr>()); |
|
1379 return new (Mem) DeclRefExpr(EmptyShell()); |
|
1380 @@ -3871,7 +3879,8 @@ |
|
1381 SourceLocation ColonOrEqualLoc, |
|
1382 bool UsesColonSyntax, Expr *Init) { |
|
1383 void *Mem = C.Allocate(sizeof(DesignatedInitExpr) + |
|
1384 - sizeof(Stmt *) * (IndexExprs.size() + 1), 8); |
|
1385 + sizeof(Stmt *) * (IndexExprs.size() + 1), |
|
1386 + llvm::alignOf<DesignatedInitExpr>()); |
|
1387 return new (Mem) DesignatedInitExpr(C, C.VoidTy, NumDesignators, Designators, |
|
1388 ColonOrEqualLoc, UsesColonSyntax, |
|
1389 IndexExprs, Init); |
|
1390 --- tools/clang/lib/AST/ExprCXX.cpp 2014-09-25 17:28:20.000000000 -0700 |
|
1391 +++ tools/clang/lib/AST/ExprCXX.cpp 2015-07-17 16:43:46.532400798 -0700 |
|
1392 @@ -1070,14 +1070,14 @@ |
|
1393 } |
|
1394 |
|
1395 ArrayRef<VarDecl *> |
|
1396 -LambdaExpr::getCaptureInitIndexVars(capture_init_iterator Iter) const { |
|
1397 +LambdaExpr::getCaptureInitIndexVars(const_capture_init_iterator Iter) const { |
|
1398 assert(HasArrayIndexVars && "No array index-var data?"); |
|
1399 |
|
1400 unsigned Index = Iter - capture_init_begin(); |
|
1401 assert(Index < getLambdaClass()->getLambdaData().NumCaptures && |
|
1402 "Capture index out-of-range"); |
|
1403 - VarDecl **IndexVars = getArrayIndexVars(); |
|
1404 - unsigned *IndexStarts = getArrayIndexStarts(); |
|
1405 + VarDecl *const *IndexVars = getArrayIndexVars(); |
|
1406 + const unsigned *IndexStarts = getArrayIndexStarts(); |
|
1407 return llvm::makeArrayRef(IndexVars + IndexStarts[Index], |
|
1408 IndexVars + IndexStarts[Index + 1]); |
|
1409 } |
|
1410 @@ -1098,8 +1098,12 @@ |
|
1411 } |
|
1412 |
|
1413 CompoundStmt *LambdaExpr::getBody() const { |
|
1414 + // FIXME: this mutation in getBody is bogus. It should be |
|
1415 + // initialized in ASTStmtReader::VisitLambdaExpr, but for reasons I |
|
1416 + // don't understand, that doesn't work. |
|
1417 if (!getStoredStmts()[NumCaptures]) |
|
1418 - getStoredStmts()[NumCaptures] = getCallOperator()->getBody(); |
|
1419 + *const_cast<clang::Stmt **>(&getStoredStmts()[NumCaptures]) = |
|
1420 + getCallOperator()->getBody(); |
|
1421 |
|
1422 return reinterpret_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]); |
|
1423 } |
|
1424 --- tools/clang/lib/AST/Stmt.cpp 2014-12-14 23:07:06.000000000 -0800 |
|
1425 +++ tools/clang/lib/AST/Stmt.cpp 2015-07-17 16:43:46.536947418 -0700 |
|
1426 @@ -816,7 +816,7 @@ |
|
1427 CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, SourceLocation tryLoc, |
|
1428 Stmt *tryBlock, ArrayRef<Stmt*> handlers) { |
|
1429 std::size_t Size = sizeof(CXXTryStmt); |
|
1430 - Size += ((handlers.size() + 1) * sizeof(Stmt)); |
|
1431 + Size += ((handlers.size() + 1) * sizeof(Stmt *)); |
|
1432 |
|
1433 void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>()); |
|
1434 return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers); |
|
1435 @@ -825,7 +825,7 @@ |
|
1436 CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, EmptyShell Empty, |
|
1437 unsigned numHandlers) { |
|
1438 std::size_t Size = sizeof(CXXTryStmt); |
|
1439 - Size += ((numHandlers + 1) * sizeof(Stmt)); |
|
1440 + Size += ((numHandlers + 1) * sizeof(Stmt *)); |
|
1441 |
|
1442 void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>()); |
|
1443 return new (Mem) CXXTryStmt(Empty, numHandlers); |
|
1444 @@ -2027,4 +2027,3 @@ |
|
1445 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
|
1446 return new (Mem) OMPTeamsDirective(NumClauses); |
|
1447 } |
|
1448 - |
|
1449 --- tools/clang/lib/Basic/IdentifierTable.cpp 2014-12-11 04:18:08.000000000 -0800 |
|
1450 +++ tools/clang/lib/Basic/IdentifierTable.cpp 2015-07-17 16:43:46.538457921 -0700 |
|
1451 @@ -376,6 +376,11 @@ |
|
1452 Profile(ID, keyword_begin(), getNumArgs()); |
|
1453 } |
|
1454 }; |
|
1455 +static_assert( |
|
1456 + llvm::AlignOf<MultiKeywordSelector>::Alignment >= |
|
1457 + llvm::AlignOf<IdentifierInfo *>::Alignment, |
|
1458 + "Alignment is insufficient for objects appended to MultiKeywordSelector"); |
|
1459 + |
|
1460 } // end namespace clang. |
|
1461 |
|
1462 unsigned Selector::getNumArgs() const { |
|
1463 --- tools/clang/lib/CodeGen/CGCleanup.h 2014-11-18 23:49:47.000000000 -0800 |
|
1464 +++ tools/clang/lib/CodeGen/CGCleanup.h 2015-07-17 16:43:46.540112662 -0700 |
|
1465 @@ -211,9 +211,12 @@ |
|
1466 return Scope->getKind() == Catch; |
|
1467 } |
|
1468 }; |
|
1469 +static_assert(llvm::AlignOf<EHCatchScope>::Alignment >= |
|
1470 + llvm::AlignOf<EHCatchScope::Handler *>::Alignment, |
|
1471 + "Alignment is insufficient for objects appended to EHCatchScope"); |
|
1472 |
|
1473 /// A cleanup scope which generates the cleanup blocks lazily. |
|
1474 -class EHCleanupScope : public EHScope { |
|
1475 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EHCleanupScope : public EHScope { |
|
1476 /// The nearest normal cleanup scope enclosing this one. |
|
1477 EHScopeStack::stable_iterator EnclosingNormal; |
|
1478 |
|
1479 @@ -391,6 +394,13 @@ |
|
1480 return (Scope->getKind() == Cleanup); |
|
1481 } |
|
1482 }; |
|
1483 +// Assert objects tacked on the end of EHCleanupScope won't be |
|
1484 +// misaligned. NOTE: there's actually a bunch of different data |
|
1485 +// classes tacked on, so let's just ensure alignment good enough for |
|
1486 +// uint64_t bytes. |
|
1487 +static_assert(llvm::AlignOf<EHCleanupScope>::Alignment >= |
|
1488 + llvm::AlignOf<uint64_t>::Alignment, |
|
1489 + ""); |
|
1490 |
|
1491 /// An exceptions scope which filters exceptions thrown through it. |
|
1492 /// Only exceptions matching the filter types will be permitted to be |
|
1493 @@ -435,6 +445,10 @@ |
|
1494 return scope->getKind() == Filter; |
|
1495 } |
|
1496 }; |
|
1497 +static_assert( |
|
1498 + llvm::AlignOf<EHFilterScope>::Alignment >= |
|
1499 + llvm::AlignOf<llvm::Value *>::Alignment, |
|
1500 + "Alignment is insufficient for objects appended to EHFilterScope"); |
|
1501 |
|
1502 /// An exceptions scope which calls std::terminate if any exception |
|
1503 /// reaches it. |
|
1504 @@ -467,27 +481,27 @@ |
|
1505 EHScope &operator*() const { return *get(); } |
|
1506 |
|
1507 iterator &operator++() { |
|
1508 + size_t Size; |
|
1509 switch (get()->getKind()) { |
|
1510 case EHScope::Catch: |
|
1511 - Ptr += EHCatchScope::getSizeForNumHandlers( |
|
1512 + Size = EHCatchScope::getSizeForNumHandlers( |
|
1513 static_cast<const EHCatchScope*>(get())->getNumHandlers()); |
|
1514 break; |
|
1515 |
|
1516 case EHScope::Filter: |
|
1517 - Ptr += EHFilterScope::getSizeForNumFilters( |
|
1518 + Size = EHFilterScope::getSizeForNumFilters( |
|
1519 static_cast<const EHFilterScope*>(get())->getNumFilters()); |
|
1520 break; |
|
1521 |
|
1522 case EHScope::Cleanup: |
|
1523 - Ptr += static_cast<const EHCleanupScope*>(get()) |
|
1524 - ->getAllocatedSize(); |
|
1525 + Size = static_cast<const EHCleanupScope *>(get())->getAllocatedSize(); |
|
1526 break; |
|
1527 |
|
1528 case EHScope::Terminate: |
|
1529 - Ptr += EHTerminateScope::getSize(); |
|
1530 + Size = EHTerminateScope::getSize(); |
|
1531 break; |
|
1532 } |
|
1533 - |
|
1534 + Ptr += llvm::RoundUpToAlignment(Size, ScopeStackAlignment); |
|
1535 return *this; |
|
1536 } |
|
1537 |
|
1538 @@ -523,7 +537,7 @@ |
|
1539 |
|
1540 EHCatchScope &scope = cast<EHCatchScope>(*begin()); |
|
1541 InnermostEHScope = scope.getEnclosingEHScope(); |
|
1542 - StartOfData += EHCatchScope::getSizeForNumHandlers(scope.getNumHandlers()); |
|
1543 + unallocate(EHCatchScope::getSizeForNumHandlers(scope.getNumHandlers())); |
|
1544 } |
|
1545 |
|
1546 inline void EHScopeStack::popTerminate() { |
|
1547 @@ -531,7 +545,7 @@ |
|
1548 |
|
1549 EHTerminateScope &scope = cast<EHTerminateScope>(*begin()); |
|
1550 InnermostEHScope = scope.getEnclosingEHScope(); |
|
1551 - StartOfData += EHTerminateScope::getSize(); |
|
1552 + unallocate(EHTerminateScope::getSize()); |
|
1553 } |
|
1554 |
|
1555 inline EHScopeStack::iterator EHScopeStack::find(stable_iterator sp) const { |
|
1556 --- tools/clang/lib/CodeGen/CGCleanup.cpp 2015-01-13 23:38:27.000000000 -0800 |
|
1557 +++ tools/clang/lib/CodeGen/CGCleanup.cpp 2015-07-17 17:08:23.853121118 -0700 |
|
1558 @@ -94,6 +94,7 @@ |
|
1559 |
|
1560 /// Push an entry of the given size onto this protected-scope stack. |
|
1561 char *EHScopeStack::allocate(size_t Size) { |
|
1562 + Size = llvm::RoundUpToAlignment(Size, ScopeStackAlignment); |
|
1563 if (!StartOfBuffer) { |
|
1564 unsigned Capacity = 1024; |
|
1565 while (Capacity < Size) Capacity *= 2; |
|
1566 @@ -123,6 +124,10 @@ |
|
1567 return StartOfData; |
|
1568 } |
|
1569 |
|
1570 +void EHScopeStack::unallocate(size_t Size) { |
|
1571 + StartOfData += llvm::RoundUpToAlignment(Size, ScopeStackAlignment); |
|
1572 +} |
|
1573 + |
|
1574 EHScopeStack::stable_iterator |
|
1575 EHScopeStack::getInnermostActiveNormalCleanup() const { |
|
1576 for (stable_iterator si = getInnermostNormalCleanup(), se = stable_end(); |
|
1577 @@ -153,7 +158,6 @@ |
|
1578 |
|
1579 |
|
1580 void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) { |
|
1581 - assert(((Size % sizeof(void*)) == 0) && "cleanup type is misaligned"); |
|
1582 char *Buffer = allocate(EHCleanupScope::getSizeForCleanupSize(Size)); |
|
1583 bool IsNormalCleanup = Kind & NormalCleanup; |
|
1584 bool IsEHCleanup = Kind & EHCleanup; |
|
1585 @@ -181,7 +185,7 @@ |
|
1586 EHCleanupScope &Cleanup = cast<EHCleanupScope>(*begin()); |
|
1587 InnermostNormalCleanup = Cleanup.getEnclosingNormalCleanup(); |
|
1588 InnermostEHScope = Cleanup.getEnclosingEHScope(); |
|
1589 - StartOfData += Cleanup.getAllocatedSize(); |
|
1590 + unallocate(Cleanup.getAllocatedSize()); |
|
1591 |
|
1592 // Destroy the cleanup. |
|
1593 Cleanup.Destroy(); |
|
1594 @@ -211,7 +215,7 @@ |
|
1595 assert(!empty() && "popping exception stack when not empty"); |
|
1596 |
|
1597 EHFilterScope &filter = cast<EHFilterScope>(*begin()); |
|
1598 - StartOfData += EHFilterScope::getSizeForNumFilters(filter.getNumFilters()); |
|
1599 + unallocate(EHFilterScope::getSizeForNumFilters(filter.getNumFilters())); |
|
1600 |
|
1601 InnermostEHScope = filter.getEnclosingEHScope(); |
|
1602 } |
|
1603 --- tools/clang/lib/CodeGen/CGExprCXX.cpp 2015-01-13 23:38:27.000000000 -0800 |
|
1604 +++ tools/clang/lib/CodeGen/CGExprCXX.cpp 2015-07-17 16:43:46.544527492 -0700 |
|
1605 @@ -1129,6 +1129,10 @@ |
|
1606 EmitNewDeleteCall(CGF, OperatorDelete, FPT, DeleteArgs); |
|
1607 } |
|
1608 }; |
|
1609 + static_assert( |
|
1610 + llvm::AlignOf<CallDeleteDuringNew>::Alignment >= |
|
1611 + llvm::AlignOf<RValue>::Alignment, |
|
1612 + "Alignment is insufficient for objects appended to CallDeleteDuringNew"); |
|
1613 |
|
1614 /// A cleanup to call the given 'operator delete' function upon |
|
1615 /// abnormal exit from a new expression when the new expression is |
|
1616 @@ -1188,6 +1192,10 @@ |
|
1617 EmitNewDeleteCall(CGF, OperatorDelete, FPT, DeleteArgs); |
|
1618 } |
|
1619 }; |
|
1620 + static_assert( |
|
1621 + llvm::AlignOf<CallDeleteDuringConditionalNew>::Alignment >= |
|
1622 + llvm::AlignOf<DominatingValue<RValue>::saved_type>::Alignment, |
|
1623 + "Alignment is insufficient for objects appended to CallDeleteDuringNew"); |
|
1624 } |
|
1625 |
|
1626 /// Enter a cleanup to call 'operator delete' if the initializer in a |
|
1627 @@ -1819,7 +1827,7 @@ |
|
1628 MakeAddrLValue(Slot.getAddr(), E->getType(), Slot.getAlignment()); |
|
1629 |
|
1630 CXXRecordDecl::field_iterator CurField = E->getLambdaClass()->field_begin(); |
|
1631 - for (LambdaExpr::capture_init_iterator i = E->capture_init_begin(), |
|
1632 + for (LambdaExpr::const_capture_init_iterator i = E->capture_init_begin(), |
|
1633 e = E->capture_init_end(); |
|
1634 i != e; ++i, ++CurField) { |
|
1635 // Emit initialization |
|
1636 --- tools/clang/lib/CodeGen/CGStmt.cpp 2015-01-13 23:38:27.000000000 -0800 |
|
1637 +++ tools/clang/lib/CodeGen/CGStmt.cpp 2015-07-17 16:43:46.546244580 -0700 |
|
1638 @@ -2122,7 +2122,7 @@ |
|
1639 CreateMemTemp(RecordTy, "agg.captured"), RecordTy); |
|
1640 |
|
1641 RecordDecl::field_iterator CurField = RD->field_begin(); |
|
1642 - for (CapturedStmt::capture_init_iterator I = S.capture_init_begin(), |
|
1643 + for (CapturedStmt::const_capture_init_iterator I = S.capture_init_begin(), |
|
1644 E = S.capture_init_end(); |
|
1645 I != E; ++I, ++CurField) { |
|
1646 LValue LV = EmitLValueForFieldInitialization(SlotLV, *CurField); |
|
1647 --- tools/clang/lib/CodeGen/EHScopeStack.h 2014-10-31 19:33:56.000000000 -0400 |
|
1648 +++ tools/clang/lib/CodeGen/EHScopeStack.h 2015-07-18 01:53:43.588447919 -0400 |
|
1649 @@ -89,6 +89,8 @@ |
|
1650 /// and catch blocks. |
|
1651 class EHScopeStack { |
|
1652 public: |
|
1653 + enum { ScopeStackAlignment = llvm::AlignOf<uint64_t>::Alignment }; |
|
1654 + |
|
1655 /// A saved depth on the scope stack. This is necessary because |
|
1656 /// pushing scopes onto the stack invalidates iterators. |
|
1657 class stable_iterator { |
|
1658 @@ -297,6 +299,7 @@ |
|
1659 SmallVector<BranchFixup, 8> BranchFixups; |
|
1660 |
|
1661 char *allocate(size_t Size); |
|
1662 + void unallocate(size_t Size); |
|
1663 |
|
1664 void *pushCleanup(CleanupKind K, size_t DataSize); |
|
1665 |
|
1666 @@ -311,6 +314,8 @@ |
|
1667 /// Push a lazily-created cleanup on the stack. |
|
1668 template <class T> |
|
1669 void pushCleanup(CleanupKind Kind) { |
|
1670 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1671 + "Insufficient Alignment!"); |
|
1672 void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1673 Cleanup *Obj = new(Buffer) T(); |
|
1674 (void) Obj; |
|
1675 @@ -319,6 +324,8 @@ |
|
1676 /// Push a lazily-created cleanup on the stack. |
|
1677 template <class T, class A0> |
|
1678 void pushCleanup(CleanupKind Kind, A0 a0) { |
|
1679 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1680 + "Insufficient Alignment!"); |
|
1681 void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1682 Cleanup *Obj = new(Buffer) T(a0); |
|
1683 (void) Obj; |
|
1684 @@ -327,6 +334,8 @@ |
|
1685 /// Push a lazily-created cleanup on the stack. |
|
1686 template <class T, class A0, class A1> |
|
1687 void pushCleanup(CleanupKind Kind, A0 a0, A1 a1) { |
|
1688 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1689 + "Insufficient Alignment!"); |
|
1690 void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1691 Cleanup *Obj = new(Buffer) T(a0, a1); |
|
1692 (void) Obj; |
|
1693 @@ -335,6 +344,8 @@ |
|
1694 /// Push a lazily-created cleanup on the stack. |
|
1695 template <class T, class A0, class A1, class A2> |
|
1696 void pushCleanup(CleanupKind Kind, A0 a0, A1 a1, A2 a2) { |
|
1697 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1698 + "Insufficient Alignment!"); |
|
1699 void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1700 Cleanup *Obj = new(Buffer) T(a0, a1, a2); |
|
1701 (void) Obj; |
|
1702 @@ -343,6 +354,8 @@ |
|
1703 /// Push a lazily-created cleanup on the stack. |
|
1704 template <class T, class A0, class A1, class A2, class A3> |
|
1705 void pushCleanup(CleanupKind Kind, A0 a0, A1 a1, A2 a2, A3 a3) { |
|
1706 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1707 + "Insufficient Alignment!"); |
|
1708 void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1709 Cleanup *Obj = new(Buffer) T(a0, a1, a2, a3); |
|
1710 (void) Obj; |
|
1711 @@ -351,11 +364,24 @@ |
|
1712 /// Push a lazily-created cleanup on the stack. |
|
1713 template <class T, class A0, class A1, class A2, class A3, class A4> |
|
1714 void pushCleanup(CleanupKind Kind, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
|
1715 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1716 + "Insufficient Alignment!"); |
|
1717 void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1718 Cleanup *Obj = new(Buffer) T(a0, a1, a2, a3, a4); |
|
1719 (void) Obj; |
|
1720 } |
|
1721 |
|
1722 + /// Push a lazily-created cleanup on the stack. Tuple version. |
|
1723 + template <class T, class... As> |
|
1724 + void pushCleanupTuple(CleanupKind Kind, std::tuple<As...> A) { |
|
1725 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1726 + "Insufficient Alignment!"); |
|
1727 + void *Buffer = pushCleanup(Kind, sizeof(T)); |
|
1728 + Cleanup *Obj = new (Buffer) T(std::move(A)); |
|
1729 + (void) Obj; |
|
1730 + } |
|
1731 + |
|
1732 + |
|
1733 // Feel free to add more variants of the following: |
|
1734 |
|
1735 /// Push a cleanup with non-constant storage requirements on the |
|
1736 @@ -371,6 +397,8 @@ |
|
1737 /// stack is modified. |
|
1738 template <class T, class A0, class A1, class A2> |
|
1739 T *pushCleanupWithExtra(CleanupKind Kind, size_t N, A0 a0, A1 a1, A2 a2) { |
|
1740 + static_assert(llvm::AlignOf<T>::Alignment <= ScopeStackAlignment, |
|
1741 + "Insufficient Alignment!"); |
|
1742 void *Buffer = pushCleanup(Kind, sizeof(T) + T::getExtraSize(N)); |
|
1743 return new (Buffer) T(N, a0, a1, a2); |
|
1744 } |
|
1745 --- tools/clang/lib/Lex/PPDirectives.cpp 2014-12-27 23:42:49.000000000 -0800 |
|
1746 +++ tools/clang/lib/Lex/PPDirectives.cpp 2015-07-17 16:43:46.550148988 -0700 |
|
1747 @@ -48,8 +48,6 @@ |
|
1748 |
|
1749 MacroInfo *Preprocessor::AllocateDeserializedMacroInfo(SourceLocation L, |
|
1750 unsigned SubModuleID) { |
|
1751 - static_assert(llvm::AlignOf<MacroInfo>::Alignment >= sizeof(SubModuleID), |
|
1752 - "alignment for MacroInfo is less than the ID"); |
|
1753 DeserializedMacroInfoChain *MIChain = |
|
1754 BP.Allocate<DeserializedMacroInfoChain>(); |
|
1755 MIChain->Next = DeserialMIChainHead; |
|
1756 --- tools/clang/lib/Sema/SemaExceptionSpec.cpp 2014-11-21 19:09:05.000000000 -0800 |
|
1757 +++ tools/clang/lib/Sema/SemaExceptionSpec.cpp 2015-07-17 16:43:46.552022232 -0700 |
|
1758 @@ -971,7 +971,8 @@ |
|
1759 case Expr::LambdaExprClass: { |
|
1760 const LambdaExpr *Lambda = cast<LambdaExpr>(E); |
|
1761 CanThrowResult CT = CT_Cannot; |
|
1762 - for (LambdaExpr::capture_init_iterator Cap = Lambda->capture_init_begin(), |
|
1763 + for (LambdaExpr::const_capture_init_iterator |
|
1764 + Cap = Lambda->capture_init_begin(), |
|
1765 CapEnd = Lambda->capture_init_end(); |
|
1766 Cap != CapEnd; ++Cap) |
|
1767 CT = mergeCanThrow(CT, canThrow(*Cap)); |
|