Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 1242:f1877b6be63d
Merge with rev [1221]
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 17 Apr 2009 01:19:03 +0200 |
parents | 1e699a4e9759 f41ff8ccc249 |
children | 04c36605feb9 |
comparison
equal
deleted
inserted
replaced
1241:fc579f389f9a | 1242:f1877b6be63d |
---|---|
303 else | 303 else |
304 { | 304 { |
305 assert(0 && "not global/function"); | 305 assert(0 && "not global/function"); |
306 } | 306 } |
307 | 307 |
308 // The following breaks for nested naked functions, so check for that. | |
309 bool skipNestedCheck = false; | |
310 if (FuncDeclaration* fd = sym->isFuncDeclaration()) | |
311 skipNestedCheck = (fd->naked != 0); | |
312 | |
308 // Any symbol nested in a function can't be referenced directly from | 313 // Any symbol nested in a function can't be referenced directly from |
309 // outside that function, so we can give such symbols internal linkage. | 314 // outside that function, so we can give such symbols internal linkage. |
310 // This holds even if nested indirectly, such as member functions of | 315 // This holds even if nested indirectly, such as member functions of |
311 // aggregates nested in functions. | 316 // aggregates nested in functions. |
312 // | 317 // |
316 // --- | 321 // --- |
317 // int counter(T)() { static int i; return i++; }" | 322 // int counter(T)() { static int i; return i++; }" |
318 // --- | 323 // --- |
319 // if instances get emitted in multiple object files because they'd use | 324 // if instances get emitted in multiple object files because they'd use |
320 // different instances of 'i'. | 325 // different instances of 'i'. |
321 for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) { | 326 if (!skipNestedCheck) |
322 if (parent->isFuncDeclaration()) | 327 for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) { |
323 return llvm::GlobalValue::InternalLinkage; | 328 if (parent->isFuncDeclaration()) |
324 } | 329 return llvm::GlobalValue::InternalLinkage; |
330 } | |
325 | 331 |
326 // default to external linkage | 332 // default to external linkage |
327 return llvm::GlobalValue::ExternalLinkage; | 333 return llvm::GlobalValue::ExternalLinkage; |
328 } | 334 } |
329 | 335 |