aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/ModuleBuilder.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-11-30Introduce a type-safe enum for ForDefinition.John McCall1-1/+1
llvm-svn: 288289
2016-05-18Various improvements to the public IRGen interface.John McCall1-5/+39
llvm-svn: 269880
2016-04-22Fix a bug involving deferred decl emission and PCHReid Kleckner1-2/+18
For various reasons, involving dllexport and class linkage compuations, we have to wait until after the semicolon after a class declaration to emit inline methods. These are "deferred" decls. Before this change, finishing the tag decl would trigger us to deserialize some PCH so that we could make a "pretty" IR-level type. Deserializing the PCH triggered calls to HandleTopLevelDecl, which, when done, checked the deferred decl list, and emitted some dllexported decls that weren't ready. Avoid this re-entrancy. Deferred decls should not get emitted when a tag is finished, they should only be emitted after a real top level decl in the main file. llvm-svn: 267186
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-3/+1
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool1-1/+3
This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
2016-03-30For MS ABI, emit dllexport friend functions defined inline in classStephan Bergmann1-4/+15
...as that is apparently what MSVC does. This is an updated version of r263738, which had to be reverted in r263740 due to test failures. The original version had erroneously emitted functions that are defined in class templates, too (see the updated "Handle friend functions" code in EmitDeferredDecls, lib/CodeGen/ModuleBuilder.cpp). (The updated tests needed to be split out into their own dllexport-ms-friend.cpp because of the CHECK-NOTs which would have interfered with subsequent CHECK-DAGs in dllexport.cpp.) Differential Revision: http://reviews.llvm.org/D18430 llvm-svn: 264841
2016-03-17Revert "For MS ABI, emit dllexport friend functions defined inline in class"Reid Kleckner1-14/+4
This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp llvm-svn: 263740
2016-03-17For MS ABI, emit dllexport friend functions defined inline in classReid Kleckner1-4/+14
Summary: ...as that is apparently what MSVC does Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D15267 llvm-svn: 263738
2016-03-13Remove compile time PreserveName in favor of a runtime cc1 ↵Mehdi Amini1-2/+3
-discard-value-names option Summary: This flag is enabled by default in the driver when NDEBUG is set. It is forwarded on the LLVMContext to discard all value names (but GlobalValue) for performance purpose. This an improved version of D18024 Reviewers: echristo, chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18127 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263394
2016-03-04Make TargetInfo store an actual DataLayout instead of a string.James Y Knight1-1/+1
Use it to calculate UserLabelPrefix, instead of specifying it (often incorrectly). Note that the *actual* user label prefix has always come from the DataLayout, and is handled within LLVM. The main thing clang's TargetInfo::UserLabelPrefix did was to set the #define value. Having these be different from each-other is just silly. Differential Revision: http://reviews.llvm.org/D17183 llvm-svn: 262737
2016-03-04[OPENMP 4.0] Codegen for 'declare reduction' construct.Alexey Bataev1-0/+9
Emit function for 'combiner' part of 'declare reduction' construct and 'initialilzer' part, if any. llvm-svn: 262699
2016-03-02Serialize `#pragma detect_mismatch`.Nico Weber1-5/+0
This is like r262493, but for pragma detect_mismatch instead of pragma comment. The two pragmas have similar behavior, so use the same approach for both. llvm-svn: 262506
2016-03-02Serialize `#pragma comment`.Nico Weber1-10/+2
`#pragma comment` was handled by Sema calling a function on ASTConsumer, and CodeGen then implementing this function and writing things to its output. Instead, introduce a PragmaCommentDecl AST node and hang one off the TranslationUnitDecl for every `#pragma comment` line, and then use the regular serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's eagerly deserialized.) http://reviews.llvm.org/D17799 llvm-svn: 262493
2016-01-28Check for frontend errors after releasing the Builder.Manman Ren1-3/+6
Frontend can emit errors when releaseing the Builder. If there are errors before or when releasing the Builder, we reset the module to stop here before invoking the backend. Before this commit, clang will continue to invoke the backend and backend can crash. Differential Revision: http://reviews.llvm.org/D16564 llvm-svn: 259116
2016-01-26[MS ABI] Allow a member pointers' converted type to changeDavid Majnemer1-0/+7
Member pointers in the MS ABI are tricky for a variety of reasons. The size of a member pointer is indeterminate until the program reaches a point where the representation is required to be known. However, *pointers* to member pointers may exist without knowing the pointee type's representation. In these cases, we synthesize an opaque LLVM type for the pointee type. However, we can be in a situation where the underlying member pointer's representation became known mid-way through the program. To account for this, we attempted to manicure CodeGen's type-cache so that we can replace the opaque member pointer type with the real deal while leaving the pointer types unperturbed. This, unfortunately, is a problematic approach to take as we will violate CodeGen's invariants. These violations are mostly harmless but let's do the right thing instead: invalidate the type-cache if a member pointer's LLVM representation changes. This fixes PR26313. llvm-svn: 258839
2016-01-16Introduce -fsanitize-stats flag.Peter Collingbourne1-3/+5
This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16175 llvm-svn: 257971
2015-10-08[MSVC Compat] Enable ABI impacting non-conforming behavior independently of ↵David Majnemer1-1/+1
-fms-compatibility No ABI for C++ currently makes it possible to implement the standard 100% perfectly. We wrongly hid some of our compatible behavior behind -fms-compatibility instead of tying it to the compiler ABI. llvm-svn: 249656
2015-08-05Rename DescriptionString -> DataLayoutString as it matches the actualEric Christopher1-1/+1
use of the string. llvm-svn: 244178
2015-07-24LLVM API Change: the Module always owns the DataLayoutMehdi Amini1-8/+3
From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 243115
2015-06-30Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.Adrian Prantl1-12/+21
In order to produce debug info for clang modules CGDebugInfo it needs access to macros passed on the command line and the isysroot. llvm-svn: 241035
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-1/+1
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-04-11Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko1-1/+1
Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
2015-01-17Wrap to 80 columns. No behavior change.Nico Weber1-1/+2
llvm-svn: 226364
2015-01-15Remove unused parameter, followup to r179639. No behavior change.Nico Weber1-1/+0
llvm-svn: 226128
2015-01-15Remove ASTConsumer::HandleVTable()'s bool parameter.Nico Weber1-2/+2
Sema calls HandleVTable() with a bool parameter which is then threaded through three layers. The only effect of this bool is an early return at the last layer. Instead, remove this parameter and call HandleVTable() only if the bool is true. No intended behavior change. llvm-svn: 226096
2014-12-25Initialize CodeGeneratorImpl::Ctx in constructor.Yaron Keren1-1/+1
llvm-svn: 224835
2014-12-19Tweak the assert in ModuleBuilder from r224533 (PR21989)Hans Wennborg1-2/+3
Turns out there will be left-over deferred inline methods if there have been errors, because in that case HandleTopLevelDecl bails out early. llvm-svn: 224649
2014-12-18ModuleBuilder: assert that all deferred inline method defs get handledHans Wennborg1-4/+7
While we're here, also move the declaration of DeferredInlineMethodDefinitions closer to the other member vars and make it a SmallVector. NFC. llvm-svn: 224533
2014-11-18InstrProf: Don't emit coverage for uninstantiated templatesJustin Bogner1-3/+5
We include unused functions and methods in -fcoverage-mapping so that we can differentiate between uninstrumented and unused. This can cause problems for uninstantiated templates though, since they may involve an incomplete type that can't be mangled. This shows up in things like libc++'s <unordered_map> and makes coverage unusable. Avoid the issue by skipping uninstantiated methods of a templated class. llvm-svn: 222204
2014-08-13[modules] Fix a rejects-valid resulting from emitting an inline functionRichard Smith1-1/+5
recursively within the emission of another inline function. This ultimately led to us emitting the same inline function definition twice, which we then rejected because we believed we had a mangled name conflict. llvm-svn: 215579
2014-08-04Add coverage mapping generation.Alex Lorenz1-4/+13
This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
2014-08-01Notional simplification: defer emitting deferred inline methods until we finishRichard Smith1-4/+21
emitting everything, rather than potentially doing this reentrantly. llvm-svn: 214582
2014-08-01Re-commit r214547 with tests fixed. Hopefully all the bots will be happy now.Richard Smith1-3/+5
Original message: Fix iterator invalidation issues that are breaking my modules buildbot's bootstrap. llvm-svn: 214555
2014-08-01Revert r214547 due to test breakage.Richard Smith1-6/+3
llvm-svn: 214549
2014-08-01Fix iterator invalidation issues that are breaking my modules buildbot's ↵Richard Smith1-3/+6
bootstrap. llvm-svn: 214547
2014-07-17MS compatibility: always emit dllexported in-class initialized static data ↵Hans Wennborg1-0/+13
members (PR20140) This makes us emit dllexported in-class initialized static data members (which are treated as definitions in MSVC), even when they're not referenced. It also makes their special linkage reflected in the GVA linkage instead of getting massaged in CodeGen. Differential Revision: http://reviews.llvm.org/D4563 llvm-svn: 213304
2014-06-06Defer codegen of inline method definitions to the end of current top level ↵Hans Wennborg1-6/+18
declaration We would previously fail to emit a definition of bar() for the following code: struct __declspec(dllexport) S { void foo() { t->bar(); } struct T { void bar() {} }; T *t; }; Note that foo() is an exported method, but bar() is not. However, foo() refers to bar() so we need to emit its definition. We would previously fail to realise that bar() is used. By deferring the method definitions until the end of the top level declaration, we can simply call EmitTopLevelDecl on them and rely on the usual mechanisms to decide whether the method should be emitted or not. Differential Revision: http://reviews.llvm.org/D4038 llvm-svn: 210356
2014-06-05Implement -Wframe-larger-than backend diagnosticAlp Toker1-0/+15
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-05-23Emit used/dllexport inline method definitions in nested classes (PR19743, ↵Hans Wennborg1-11/+14
PR11170) The previous code that was supposed to handle this didn't work since parsing of inline method definitions is delayed to the end of the outer class definition. Thus, when HandleTagDeclDefinition() got called for the inner class, the inline functions in that class had not been parsed yet. Richard suggested that the way to do this is by handling inline method definitions through a new ASTConsumer callback. I really wanted to call ASTContext::DeclMustBeEmitted() instead of checking for attributes, but doing that causes us to compute linkage, and then we fail with "error: unsupported: typedef changes linkage of anonymous type, but linkage was already computed" on tests like this: (from SemaCXX/undefined-internal.cpp) :-/ namespace test7 { typedef struct { void bar(); void foo() { bar(); } } A; } Differential Revision: http://reviews.llvm.org/D3809 llvm-svn: 209549
2014-03-12[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-14/+14
class. llvm-svn: 203643
2014-03-09[C++11] Replace OwningPtr include with <memory>.Ahmed Charles1-1/+1
llvm-svn: 203389
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-3/+4
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-07[C++11] Replacing DeclBase iterators decls_begin() and decls_end() with ↵Aaron Ballman1-4/+2
iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203278
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-3/+1
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
2014-03-02Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper1-1/+1
llvm-svn: 202625
2014-01-07Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth1-1/+1
encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
2013-12-09When we decide to output a deferred decl, remember the llvm GlobalValue.Rafael Espindola1-0/+2
We can reuse it to avoid a DenseMap+StringMap lookup to find if it was already emitted or not. This fixes a 2010 TODO. llvm-svn: 196785
2013-08-19PR16933: Don't try to codegen things after we've seen errors.David Blaikie1-0/+12
Refactor the underlying code a bit to remove unnecessary calls to "hasErrorOccurred" & make them consistently at all the entry points to the IRGen ASTConsumer. llvm-svn: 188707
2013-08-15DebugInfo: Unify & optimize the lazy addition of record typesDavid Blaikie1-1/+1
Rather than going through the whole getOrCreateType machinery to manifest a type, cut straight to the implementation because we know we have to do work. While the previous implementation was sufficient for the two cases (completeness and required completeness) we have already (the general machinery could inspect the type for those attributes & go down the full definition path), a pending change (to emit info for types when we emit their vtables) won't have that luxury & we'll need to force the creation rather than relying on the general purpose routine. llvm-svn: 188486