aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDecl.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-07-18Revert "Emit lifetime.start / lifetime.end markers for unnamed temporary ↵Arnaud A. de Grandmaison1-16/+24
objects." This reverts commit dbf785a6432f78a8ec229665876647c4cc610d3d, while I qm investigating a buildbot failure. llvm-svn: 213380
2014-07-18Emit lifetime.start / lifetime.end markers for unnamed temporary objects.Arnaud A. de Grandmaison1-24/+16
This will give more information to the optimizers so that they can reuse stack slots. llvm-svn: 213379
2014-07-12[ASan] Collect unmangled names of global variables in Clang to print them in ↵Alexey Samsonov1-1/+1
error reports. Currently ASan instrumentation pass creates a string with global name for each instrumented global (to include global names in the error report). Global name is already mangled at this point, and we may not be able to demangle it at runtime (e.g. there is no __cxa_demangle on Android). Instead, create a string with fully qualified global name in Clang, and pass it to ASan instrumentation pass in llvm.asan.globals metadata. If there is no metadata for some global, ASan will use the original algorithm. This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=264. llvm-svn: 212872
2014-07-02[ASan] Print exact source location of global variables in error reports.Alexey Samsonov1-0/+2
See https://code.google.com/p/address-sanitizer/issues/detail?id=299 for the original feature request. Introduce llvm.asan.globals metadata, which Clang (or any other frontend) may use to report extra information about global variables to ASan instrumentation pass in the backend. This metadata replaces llvm.asan.dynamically_initialized_globals that was used to detect init-order bugs. llvm.asan.globals contains the following data for each global: 1) source location (file/line/column info); 2) whether it is dynamically initialized; 3) whether it is blacklisted (shouldn't be instrumented). Source location data is then emitted in the binary and can be picked up by ASan runtime in case it needs to print error report involving some global. For example: 0x... is located 4 bytes to the right of global variable 'C::array' defined in '/path/to/file:17:8' (0x...) of size 40 These source locations are printed even if the binary doesn't have any debug info. This is an ABI-breaking change. ASan initialization is renamed to __asan_init_v4(). Pre-built libraries compiled with older Clang will not work with the fresh runtime. llvm-svn: 212188
2014-06-18Inherit dll attributes to static localsHans Wennborg1-0/+7
This makes us handle static locals in exported/imported functions correctly. Differential Revision: http://reviews.llvm.org/D4136 llvm-svn: 211173
2014-06-13Remove top-level Clang -fsanitize= flags for optional ASan features.Alexey Samsonov1-3/+0
Init-order and use-after-return modes can currently be enabled by runtime flags. use-after-scope mode is not really working at the moment. The only problem I see is that users won't be able to disable extra instrumentation for init-order and use-after-scope by a top-level Clang flag. But this instrumentation was implicitly enabled for quite a while and we didn't hear from users hurt by it. llvm-svn: 210924
2014-06-05Implement -Wframe-larger-than backend diagnosticAlp Toker1-10/+8
Add driver and frontend support for the GCC -Wframe-larger-than=bytes warning. This is the first GCC-compatible backend diagnostic built around LLVM's reporting feature. This commit adds infrastructure to perform reverse lookup from mangled names emitted after LLVM IR generation. We use that to resolve precise locations and originating AST functions, lambdas or block declarations to produce seamless codegen-guided diagnostics. An associated change, StringMap now maintains unique mangled name strings instead of allocating copies. This is a net memory saving in C++ and a small hit for C where we no longer reuse IdentifierInfo storage, pending further optimisation. llvm-svn: 210293
2014-06-03Eliminate redundant MangleBuffer classAlp Toker1-5/+2
The only remaining user didn't actually use the non-dynamic storage facility this class provides. The std::string is transitional and likely to be StringRefized shortly. llvm-svn: 210058
2014-05-21[C++11] Use 'nullptr'. CodeGen edition.Craig Topper1-10/+10
llvm-svn: 209272
2014-04-28CodeGen: Fix linkage of reference temporariesDavid Majnemer1-10/+4
Summary: A reference temporary should inherit the linkage of the variable it initializes. Otherwise, we may hit cases where a reference temporary wouldn't have the same value in all translation units. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3515 llvm-svn: 207451
2014-04-02Fix type mismatch assertion related to inalloca and PR19287Reid Kleckner1-2/+5
Augment the test case from r205217 to catch this related bug. Fixes the Windows self-host which was failing on VariantValue.cpp. llvm-svn: 205378
2014-03-24Proper handling of static local variables with address space qualifiers.Eli Bendersky1-8/+14
Similar to the implementation for globals in r157167. Patch by Jingyue Wu. llvm-svn: 204677
2014-03-17[C++11] Replacing CompoundStmt iterators body_begin() and body_end() with ↵Aaron Ballman1-4/+3
iterator_range body(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 204040
2014-03-14[C++11] Replacing BlockDecl iterators capture_begin() and capture_end() with ↵Aaron Ballman1-6/+4
iterator_range captures(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203958
2014-03-14[C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with ↵Aaron Ballman1-4/+3
iterator_range decls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203947
2014-03-14Objective-C++ IRGen. Due to change to AST for initialization of c++11’s Fariborz Jahanian1-1/+4
data members by addition of CXXDefaultInitExpr node to the initializer expression, it has broken treatment of arc code for such initializations. Reviewed by John McCall. // rdar://16299964 llvm-svn: 203935
2014-03-12[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-9/+9
class. llvm-svn: 203643
2014-03-06Use llvm.compiler.used instead of llvm.used for objc symbols.Rafael Espindola1-1/+1
LLVM currently has a hack (shouldEmitUsedDirectiveFor) that causes it to not print no_dead_strip for symbols starting with 'l' or 'L'. These are exactly the ones that the clang's objc codegen is producing. The net result, is that it is equivalent to llvm.compiler.used. The need for putting the private symbol in llvm.compiler.used should be clear (the objc runtime uses them). The reason for also putting the weak symbols in it is for LTO: ld64 will not ask us to preserve the it. llvm-svn: 203172
2014-03-02[C++11] Replace llvm::tie with std::tie.Benjamin Kramer1-1/+1
llvm-svn: 202639
2014-02-01[ms-cxxabi] Use inalloca on win32 when passing non-trivial C++ objectsReid Kleckner1-20/+26
When a non-trivial parameter is present, clang now gathers up all the parameters that lack inreg and puts them into a packed struct. MSVC always aligns each parameter to 4 bytes and no more, so this is a pretty simple struct to lay out. On win64, non-trivial records are passed indirectly. Prior to this change, clang was incorrectly using byval on win64. I'm able to self-host a working clang with this change and additional LLVM patches. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2636 llvm-svn: 200597
2013-12-05Fix a tranche of comment, test and doc typosAlp Toker1-1/+1
llvm-svn: 196510
2013-12-04[ms-cxxabi] Construct and destroy call arguments in the correct orderReid Kleckner1-1/+1
Summary: MSVC destroys arguments in the callee from left to right. Because C++ objects have to be destroyed in the reverse order of construction, Clang has to construct arguments from right to left and destroy arguments from left to right. This patch fixes the ordering by reversing the order of evaluation of all call arguments under the MS C++ ABI. Fixes PR18035. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2275 llvm-svn: 196402
2013-10-30Add CodeGenABITypes.h for use in LLDB.Mark Lacey1-0/+1
CodeGenABITypes is a wrapper built on top of CodeGenModule that exposes some of the functionality of CodeGenTypes (held by CodeGenModule), specifically methods that determine the LLVM types appropriate for function argument and return values. I addition to CodeGenABITypes.h, CGFunctionInfo.h is introduced, and the definitions of ABIArgInfo, RequiredArgs, and CGFunctionInfo are moved into this new header from the private headers ABIInfo.h and CGCall.h. Exposing this functionality is one part of making it possible for LLDB to determine the actual ABI locations of function arguments and return values, making it possible for it to determine this for any supported target without hard-coding ABI knowledge in the LLDB code. llvm-svn: 193717
2013-10-02Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky1-3/+4
when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
2013-08-06Started implementing variable templates. Top level declarations should be ↵Larisse Voufo1-0/+3
fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
2013-07-01Simplify linkage code for static local vars.Eli Friedman1-49/+3
The key insight here is that weak linkage for a static local variable should always mean linkonce_odr, because every file that needs it will generate a definition. We don't actually care about the precise linkage of the parent context. I feel a bit silly that I didn't realize this before. llvm-svn: 185381
2013-07-01Fix mangling for block literals.Eli Friedman1-8/+39
Blocks, like lambdas, can be written in contexts which are required to be treated as the same under ODR. Unlike lambdas, it isn't possible to actually take the address of a block, so the mangling of the block itself doesn't matter. However, objects like static variables inside a block do need to be mangled in a consistent way. There are basically three components here. One, block literals need a consistent numbering. Two, objects/types inside a block literal need to be mangled using it. Three, objects/types inside a block literal need to have their linkage computed correctly. llvm-svn: 185372
2013-06-21[ms-cxxabi] Destroy temporary record arguments in the calleeReid Kleckner1-2/+10
Itanium destroys them in the caller at the end of the full expression, but MSVC destroys them in the callee. This is further complicated by the need to emit EH-only destructor cleanups in the caller. This should help clang compile MSVC's debug iterators more correctly. There is still an outstanding issue in PR5064 of a memcpy emitted by the LLVM backend, which is not correct for C++ records. Fixes PR16226. Reviewers: rjmccall Differential Revision: http://llvm-reviews.chandlerc.com/D929 llvm-svn: 184543
2013-06-17Compute the visibility of static local variables consistently. Fixes PR16208.Eli Friedman1-2/+1
llvm-svn: 184137
2013-06-17Cleanup linkage computation for static locals.Rafael Espindola1-5/+3
With this patch we assign VisibleNoLinkage to static locals in inline functions. This lets us simplify CodeGen a bit. llvm-svn: 184114
2013-06-13Fix the linkage of static locals inside a CapturedStmt. (Found in theEli Friedman1-3/+21
process of trying to fix the related issue for block literals.) llvm-svn: 183951
2013-06-12Simplify: we don't need any special-case lifetime extension when initializingRichard Smith1-1/+1
declarations of reference type; they're handled by the general case handling of MaterializeTemporaryExpr. llvm-svn: 183875
2013-06-12PR12086, PR15117Richard Smith1-1/+0
Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
2013-06-12Reapply r183721, reverted in r183776, with a fix for a bug in the former (weRichard Smith1-0/+20
were lacking ExprWithCleanups nodes in some cases where the new approach to lifetime extension needed them). Original commit message: Rework IR emission for lifetime-extended temporaries. Instead of trying to walk into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183859
2013-06-11Revert r183721. It caused cleanups to be delayed too long in some cases.Richard Smith1-20/+0
Testcase to follow. llvm-svn: 183776
2013-06-11Rework IR emission for lifetime-extended temporaries. Instead of trying to walkRichard Smith1-0/+20
into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183721
2013-06-02PR12848: When emitting a local variable declared 'constexpr', always ↵Richard Smith1-8/+15
initialize it with a store or a memcpy, not by emitting the initializer expression. This is not required for correctness, but more closely aligns with people's expectations, and is cheap (since we've already evaluated the initializer). llvm-svn: 183082
2013-05-20PR14606: Debug Info for namespace aliases/DW_TAG_imported_moduleDavid Blaikie1-1/+4
This resolves the last of the PR14606 failures in the GDB 7.5 test suite. (but there are still unresolved issues in the imported_decl case - we need to implement optional/lazy decls for functions & variables like we already do for types) llvm-svn: 182329
2013-05-20Revert "Revert "Debug Info: Using declarations/DW_TAG_imported_declaration ↵David Blaikie1-2/+5
of variables, types, and functions."" This reverts commit r181947 (git d2990ce56a16050cac0d7937ec9919ff54c6df62 ) This addresses one of the two issues identified in r181947, ensuring that types imported via using declarations only result in a declaration being emitted for the type, not a definition. The second issue (emitting using declarations that are unused) is hopefully an acceptable increase as the real fix for this would be a bit difficult (probably at best we could record which using directives were involved in lookups - but may not have been the result of the lookup). This also ensures that DW_TAG_imported_declarations (& directives) are not emitted in line-tables-only mode as well as ensuring that typedefs only require/emit declarations (rather than definitions) for referenced types. llvm-svn: 182231
2013-05-16Let CodeGenFunction::EmitVarDecl query the semantic storage class info.Enea Zaffanella1-11/+7
Added testcase corresponding to PR15991. llvm-svn: 181998
2013-05-15Revert "Debug Info: Using declarations/DW_TAG_imported_declaration of ↵David Blaikie1-5/+2
variables, types, and functions." This reverts commit r181393 (git 3923d6a87fe7b2c91cc4a7dbd90c4ec7e2316bcd). This seems to be emitting too much extra debug info for two (known) reasons: * full class definitions are emitted when only declarations are expected * unused using declarations still produce DW_TAG_imported_declarations llvm-svn: 181947
2013-05-08Debug Info: Using declarations/DW_TAG_imported_declaration of variables, ↵David Blaikie1-2/+5
types, and functions. Basic support is implemented here - it still doesn't account for declared-but-not-defined variables or functions. It cannot handle out of order (declared, 'using', then defined) cases for variables, but can handle that for functions (& can handle declared, 'using'd, and not defined at all cases for types). llvm-svn: 181393
2013-04-22Revert "Revert "PR14606: Debug info for using ↵David Blaikie1-1/+4
directives/DW_TAG_imported_module"" This reverts commit 179839 now that the corresponding LLVM patch has been fixed. llvm-svn: 179997
2013-04-19Revert "PR14606: Debug info for using directives/DW_TAG_imported_module"Eric Christopher1-4/+1
This reverts commit r179837 as it seems to be causing test failures. llvm-svn: 179839
2013-04-19PR14606: Debug info for using directives/DW_TAG_imported_moduleDavid Blaikie1-1/+4
More changes later for using declarations/DW_TAG_imported_declaration. llvm-svn: 179837
2013-04-16Standardize accesses to the TargetInfo in IR-gen.John McCall1-1/+1
Patch by Stephen Lin! llvm-svn: 179638
2013-04-16Sema for Captured StatementsTareq A. Siraj1-0/+1
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 llvm-svn: 179618
2013-04-16Basic support for Microsoft property declarations andJohn McCall1-0/+1
references thereto. Patch by Tong Shen! llvm-svn: 179585
2013-04-13Annotate flavor of TLS variable (statically or dynamically initialized) onto ↵Richard Smith1-1/+1
the AST. llvm-svn: 179447
2013-04-03Add 178663 back.Rafael Espindola1-1/+1
http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green before it processed the reverted 178663, so it could not have been the culprit. Revert "Revert 178663." This reverts commit 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41. llvm-svn: 178682