summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Put more stuff in the comdat used for variables with static init."Rafael Espindola2014-09-194-23/+0
| | | | | | | This reverts commit r218089. It looks like it was causing issues on COFF. llvm-svn: 218094
* Put more stuff in the comdat used for variables with static init.Rafael Espindola2014-09-184-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang can already handle ------------------------------------------- struct S { static const int x; }; template<typename T> struct U { static const int k; }; template<typename T> const int U<T>::k = T::x; const int S::x = 42; extern const int *f(); const int *g() { return &U<S>::k; } int main() { return *f() + U<S>::k; } const int *f() { return &U<S>::k; } ------------------------------------------- since r217264 which puts the .inint_array section in the same COMDAT as the variable. This patch allows the linker to more easily delete some dead code and data by putting the guard variable and init function in the same COMDAT. llvm-svn: 218089
* Thread Safety Analysis: add new warning flag, -Wthread-safety-reference, whichDeLesley Hutchins2014-09-182-17/+102
| | | | | | | | warns when a guarded variable is passed by reference as a function argument. This is released as a separate warning flag, because it could potentially break existing code that uses thread safety analysis. llvm-svn: 218087
* MS ABI: Don't ICE for pointers to pointers to members of incomplete classesDavid Majnemer2014-09-185-14/+31
| | | | | | | | | | | | | | | | | | | CodeGen would try to come up with an LLVM IR type for a pointer to member type on the way to forming an LLVM IR type for a pointer to pointer to member type. However, if the pointer to member representation has not been locked in yet, we would not be able to come up with a pointer to member IR type. In these cases, make the pointer to member type an incomplete type. This will make the pointer to pointer to member type a pointer to an incomplete type. If the class eventually obtains an inheritance model, we will make the pointer to member type represent the actual inheritance model. Differential Revision: http://reviews.llvm.org/D5373 llvm-svn: 218084
* [X86, inlineasm] Do not allow using constraint 'x' for a variable larger thanAkira Hatanaka2014-09-181-1/+2
| | | | | | | | 128-bit unless the target CPU supports AVX. rdar://problem/11846140 llvm-svn: 218082
* [X86, inline-asm] Allow 256-bit wide operands for the 'x' constraintsHans Wennborg2014-09-181-1/+2
| | | | | | | The 'x' constraint is for "any SSE register", and GCC seems to include the 256-bit ymm registers in that concept. llvm-svn: 218073
* [X86, inlineasm] Check that the output size is correct for the given constraint.Akira Hatanaka2014-09-182-3/+37
| | | | llvm-svn: 218064
* Patch to check at compile time for overflow whenFariborz Jahanian2014-09-182-3/+50
| | | | | | | | __builtin___memcpy_chk and similar builtins are being used. Patch by Jacques Fortier (with added clang tests). rdar://11076881 llvm-svn: 218063
* Revert r217995 and follow-ups:Hans Wennborg2014-09-187-272/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r218053: Use exceptions() instead of getNumExceptions()/getExceptionType() to avoid r218011: Work around MSVC parser bug by putting redundant braces around the body of r217997: Skip parens when detecting whether we're instantiating a function declaration. r217995: Instantiate exception specifications when instantiating function types (other The Windows build was broken for 16 hours and no one had any good ideas of how to fix it. Reverting for now to make the builders green. See the cfe-commits thread [1] for more info. This was the build error (from [2]): C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1590) : error C2668: '`anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType' : ambiguous call to overloaded function C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1313): could be 'clang::QualType `anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] c:\bb-win7\ninja-clang-i686-msc17-r\llvm-project\clang\lib\sema\TreeTransform.h(4532): or 'clang::QualType clang::TreeTransform<Derived>::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Derived=`anonymous-namespace'::TemplateInstantiator, Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] while trying to match the argument list '(clang::TypeLocBuilder, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl *, unsigned int, clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>)' 1. http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140915/115011.html 2. http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/10515/steps/build_clang_tools_1/logs/stdio llvm-svn: 218058
* Use exceptions() instead of getNumExceptions()/getExceptionType() to avoidAlexander Kornienko2014-09-181-3/+2
| | | | | | | | | accesses to incorrect exception types when getExceptionSpecType() != EST_Dynamic This fixes a crash in test/CXX/except/except.spec/template.cpp that happens in certain build configurations. llvm-svn: 218053
* Parsing/Sema of directive omp for simdAlexander Musman2014-09-1813-22/+177
| | | | llvm-svn: 218029
* Basic: use hex string for __ARM_FP macroSaleem Abdulrasool2014-09-181-1/+2
| | | | | | | The ARM ACLE describes the values as hex constants rather than numeric constants; follow suit. Address post-commit review comments from Jon Roelofs. llvm-svn: 218009
* Sema: Diagnose undefined structs used as Microsoft anonymous structsDavid Majnemer2014-09-181-5/+11
| | | | | | | | | | | | | | | Previously, we would not mark structs containing anonymous structs as invalid. Later, horrific things would occur when trying to determine the size of the parent record. Instead, require the struct to be a complete type when used as an anonymous struct. Mark both the anonymous field for the struct and the parent context as invalid (this is similar to what we do when a struct contains a field with an incomplete type.) This fixes PR11847. llvm-svn: 218006
* Skip parens when detecting whether we're instantiating a function declaration.Richard Smith2014-09-181-2/+2
| | | | llvm-svn: 217997
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-09-177-197/+272
| | | | | | | | | | than the type of a function declaration). We previously didn't instantiate these at all! This also covers the pathological case where the only mention of a parameter pack is within the exception specification; this gives us a second way (other than alias templates) to reach the horrible state where a type contains an unexpanded pack, but its canonical type does not. llvm-svn: 217995
* [X86, inline-asm] Check that the input size is correct for constraints R, q, Q,Akira Hatanaka2014-09-171-1/+26
| | | | | | | | | | | S, D, A, y, x, f, t, and u. This is a follow-up patch for r167717. rdar://problem/11846140 rdar://problem/17476970 llvm-svn: 217994
* Basic: add support for ARM ACLE 6.5.1Saleem Abdulrasool2014-09-171-12/+32
| | | | | | | | Extend ARM ACLE support (Section 6.5.1) for AArch32. Define __ARM_FP if hardware floating point support is available as per the value defined by the ACLE. llvm-svn: 217957
* Basic: use range-based for loops for ARM targetSaleem Abdulrasool2014-09-171-19/+20
| | | | | | | Tweak handleTargetFeature for the ARM(32) target to use range based for loops. NFC. llvm-svn: 217956
* Basic: whitespace fixup for ARM target infoSaleem Abdulrasool2014-09-171-2/+1
| | | | | | Fix whitespace. NFC. llvm-svn: 217955
* Don't try to devirtualize non-virtual callsReid Kleckner2014-09-161-0/+4
| | | | | | | | | | | We would end up marking the vtable of the derived class as used for no reason. Because the call itself is qualified, it is never virtual, and the vtable of the derived class isn't helpful. We would end up rejecting code that MSVC accepts for no benefit. See http://crbug.com/413478 llvm-svn: 217910
* Don't try to use C5/D5 comdats in COFF.Rafael Espindola2014-09-161-2/+6
| | | | | | This should fix the mingw bootstrap. llvm-svn: 217897
* Fix forwarding -l to MSVC's link.exeReid Kleckner2014-09-161-6/+24
| | | | | | | | | | | Translate -lfoo to -lfoo.lib while making sure that -lfoo.lib stays as -lfoo.lib. Also, these arguments were being passed twice: once explicitly via AddAllArgs, and again implicitly as linker inputs. Now they are passed once. Fixes PR20868. llvm-svn: 217895
* clang-format: Allow unbroken ::: in inline assembly.Daniel Jasper2014-09-161-0/+2
| | | | | | | | | | | | Before: asm volatile("nop" :: : "memory"); After: asm volatile("nop" ::: "memory"); Patch by Eugene Toder. Thank you. llvm-svn: 217883
* Add support for putting constructors and destructos in explicit comdats.Rafael Espindola2014-09-167-48/+149
| | | | | | | | | | | | | | | | | | There are situations when clang knows that the C1 and C2 constructors or the D1 and D2 destructors are identical. We already optimize some of these cases, but cannot optimize it when the GlobalValue is weak_odr. The problem with weak_odr is that an old TU seeing the same code will have a C1 and a C2 comdat with the corresponding symbols. We cannot suddenly start putting the C2 symbol in the C1 comdat as we cannot guarantee that the linker will not pick a .o with only C1 in it. The solution implemented by GCC is to expand the ABI to have a comdat whose name uses a C5/D5 suffix and always has both symbols. That is what this patch implements. llvm-svn: 217874
* Driver: use range based for loopSaleem Abdulrasool2014-09-161-8/+6
| | | | | | Use a couple more range based for loops. NFC. llvm-svn: 217857
* Reject a slightly-sneaky way to perform a read of mutable state from within aRichard Smith2014-09-161-0/+66
| | | | | | | | | constexpr function. Part of this fix is a tentative fix for an as-yet-unfiled core issue (we're missing a prohibition against reading mutable members from unions via a trivial constructor/assignment, since that doesn't perform an lvalue-to-rvalue conversion on the members). llvm-svn: 217852
* Unique_ptrify Preprocessor::PragmaHandlersBackupDavid Blaikie2014-09-151-2/+2
| | | | | | Follow up to r217656 llvm-svn: 217829
* Objective-C. Prevents a crash generating AST for aFariborz Jahanian2014-09-151-0/+4
| | | | | | | | | a property assignment due to numerous user errors. Cannot come up with a reasonable test case due to array of user errors before the crash point. rdar://17813651. llvm-svn: 217825
* Major rewrite of linking strategy for sanitizer runtimes on Linux.Alexey Samsonov2014-09-151-143/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | Change 1: we used to add static sanitizer runtimes at the very beginning of the linker invocation, even before crtbegin.o, which is gross and not correct in general. Fix this: now addSanitizerRuntimes() adds all sanitizer-related link flags to the end of the linker invocation being constructed. It means, that we should call this function in the correct place, namely, before AddLinkerInputs() to make sure sanitizer versions of library functions will be preferred. Change 2: Put system libraries sanitizer libraries depend on at the end of the linker invocation, where all the rest system libraries are located. Respect --nodefaultlibs and --nostdlib flags. This is another way to fix PR15823. Original fix landed in r215940 put "-lpthread" and friends immediately after static ASan runtime, before the user linker inputs. This caused significant slowdown in dynamic linker for large binaries linked against thousands of shared objects. Instead, to mark system libraries as DT_NEEDED we prepend them with "--no-as-needed" flag, discarding the "-Wl,--as-needed" flag that could be provided by the user. Otherwise, this change is a code cleanup. Instead of having a special method for each sanitizer, we introduce a function collectSanitizerRuntimes() that analyzes -fsanitize= flags and returns the set of static and shared libraries that needs to be linked. llvm-svn: 217817
* Reduce code duplication a bit more. NFC.Rafael Espindola2014-09-152-24/+2
| | | | llvm-svn: 217813
* Reduce code duplication a bit more. NFC.Rafael Espindola2014-09-154-24/+30
| | | | llvm-svn: 217811
* Simplify the code a bit, NFC.Rafael Espindola2014-09-152-21/+4
| | | | | | hasConstructorVariants is always true for MS and false for Itanium. llvm-svn: 217809
* Move emitCXXStructor to CGCXXABI.Rafael Espindola2014-09-156-83/+164
| | | | | | A followup patch will address the code duplication. llvm-svn: 217807
* Create a emitCXXStructor function and make the existing emitCXXConstructor andRafael Espindola2014-09-153-49/+58
| | | | | | | | emitCXXDestructor static helpers. A next patch will make it a helper in CGCXXABI. llvm-svn: 217804
* Use intrusive refcounted pointers to manage RopeRefCountString lifetime.Benjamin Kramer2014-09-151-9/+5
| | | | | | | | | std::shared_ptr<char []> would be even nicer, but shared_ptr doesn't work with arrays :( No functionality change. llvm-svn: 217798
* unique_ptrify ChainedDiagnosticConsumer's ctor parametersDavid Blaikie2014-09-152-9/+14
| | | | llvm-svn: 217793
* Teach Clang how to use response files when calling other toolsReid Kleckner2014-09-156-59/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Rafael Auler! This patch addresses PR15171 and teaches Clang how to call other tools with response files, when the command line exceeds system limits. This is a problem for Windows systems, whose maximum command-line length is 32kb. I introduce the concept of "response file support" for each Tool object. A given Tool may have full support for response files (e.g. MSVC's link.exe) or only support file names inside response files, but no flags (e.g. Apple's ld64, as commented in PR15171), or no support at all (the default case). Therefore, if you implement a toolchain in the clang driver and you want clang to be able to use response files in your tools, you must override a method (getReponseFileSupport()) to tell so. I designed it to support different kinds of tools and internationalisation needs: - VS response files ( UTF-16 ) - GNU tools ( uses system's current code page, windows' legacy intl. support, with escaped backslashes. On unix, fallback to UTF-8 ) - Clang itself ( UTF-16 on windows, UTF-8 on unix ) - ld64 response files ( only a limited file list, UTF-8 on unix ) With this design, I was able to test input file names with spaces and international characters for Windows. When the linker input is large enough, it creates a response file with the correct encoding. On a Mac, to test ld64, I temporarily changed Clang's behavior to always use response files regardless of the command size limit (avoiding using huge command line inputs). I tested clang with the LLVM test suite (compiling benchmarks) and it did fine. Test Plan: A LIT test that tests proper response files support. This is tricky, since, for Unix systems, we need a 2MB response file, otherwise Clang will simply use regular arguments instead of a response file. To do this, my LIT test generate the file on the fly by cloning many -DTEST parameters until we have a 2MB file. I found out that processing 2MB of arguments is pretty slow, it takes 1 minute using my notebook in a debug build, or 10s in a Release build. Therefore, I also added "REQUIRES: long_tests", so it will only run when the user wants to run long tests. In the full discussion in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130408/171463.html, Rafael Espindola discusses a proper way to test llvm::sys::argumentsFitWithinSystemLimits(), and, there, Chandler suggests to use 10 times the current system limit (20MB resp file), so we guarantee that the system will always use response file, even if a new linux comes up that can handle a few more bytes of arguments. However, by testing with a 20MB resp file, the test takes long 8 minutes just to perform a silly check to see if the driver will use a response file. I found it to be unreasonable. Thus, I discarded this approach and uses a 2MB response file, which should be enough. Reviewers: asl, rafael, silvas Reviewed By: silvas Subscribers: silvas, rnk, thakis, cfe-commits Differential Revision: http://reviews.llvm.org/D4897 llvm-svn: 217792
* Fix memory leak of raw_ostreams in LogDiagnosticPrinter handling.David Blaikie2014-09-152-18/+12
| | | | | | | | | | | | | | | This is another case of conditional ownership (in this case a raw reference, plus a boolean to indicate whether the referenced object should be deleted). While it's not ideal, I prefer to make the ownership explicit with a unique_ptr than using a boolean flag (though it does make the reference and the unique_ptr redundant in the sense that they both refer to the same memory). At some point we might write a reusable conditional ownership pointer (a stateful custom deleter for a unique_ptr may be appropriate). Based on a patch from a patch by Anton Yartsev. llvm-svn: 217791
* Add -fseh-exceptions for MinGW-w64Reid Kleckner2014-09-154-0/+15
| | | | | | | | | | | | | | This adds a flag called -fseh-exceptions that uses the native Windows .pdata and .xdata unwind mechanism to throw exceptions. The other EH possibilities are DWARF and SJLJ exceptions. Patch by Martell Malone! Reviewed By: asl, rnk Differential Revision: http://reviews.llvm.org/D3419 llvm-svn: 217790
* Pretty print attributes associated with record declarations.Aaron Ballman2014-09-151-0/+6
| | | | llvm-svn: 217784
* Objective-C SDK modernizer. Do not modernize an enum Fariborz Jahanian2014-09-151-1/+1
| | | | | | | which already has the underlying interger type specification. // rdar://1826225 llvm-svn: 217783
* Edit: Do not extend a removal to include trailing whitespace if we're at the endBenjamin Kramer2014-09-151-0/+6
| | | | | | | | | | of the file. This would run past the end of the buffer. Sadly I don't have a great way to test it, the only way to trigger the bug is having a removal fix it at the end of the file, which none of our current warnings can generate. llvm-svn: 217766
* [ARM] Add ACLE predefines: maxmin, rounding and h/w integer divisionJames Molloy2014-09-151-0/+8
| | | | | | Patch by Assad Hashmi! llvm-svn: 217760
* clang-format: Basic support for Java.Daniel Jasper2014-09-152-3/+20
| | | | llvm-svn: 217759
* clang-format: Add option to break before non-assignment operators.Daniel Jasper2014-09-152-8/+23
| | | | | | | | | This will allow: int aaaaaaaaaaaaaa = bbbbbbbbbbbbbb + ccccccccccccccc; llvm-svn: 217757
* Check delegating constructors for using uninitialized fields.Richard Trieu2014-09-121-0/+2
| | | | llvm-svn: 217716
* clang-cl: Warn when a /TC or /TP argument is unusedEhsan Akhgari2014-09-121-2/+2
| | | | | | | | | | | | Test Plan: The patch includes a test case. Reviewers: hansw Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5338 llvm-svn: 217710
* Don't print 'NULL TYPE' when dumping a delegating constructor.Richard Trieu2014-09-121-1/+5
| | | | llvm-svn: 217707
* Allow protocols to be just declared.Rafael Espindola2014-09-121-3/+3
| | | | llvm-svn: 217704
* patch to add missing warning on sizeof wrong parameterFariborz Jahanian2014-09-122-1/+5
| | | | | | | | for __builtin___strlcpy_chk/__builtin___strlcat_chk. Patch by Jacques Fortier with monir change by me and addition of test. rdar://18259539 llvm-svn: 217700
OpenPOWER on IntegriCloud