summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't crash when a selectany symbol would get common linkageNico Weber2015-04-151-3/+3
| | | | | | | | | | | | | | | | Things can't both be in comdats and have common linkage, so never give things in comdats common linkage. Common linkage is only used in .c files, and the only thing that can trigger a comdat in c is selectany from what I can tell. Fixes PR23243. Also address an over-the-shoulder review comment from rnk by moving the hasAttr<SelectAnyAttr>() in Decl.cpp around a bit. It only makes a minor difference for selectany on global variables, so it goes well with the rest of this patch. http://reviews.llvm.org/D9042 llvm-svn: 235053
* clang-format a line containing nothing but a "{". No behavior change.Nico Weber2015-04-151-3/+2
| | | | llvm-svn: 235047
* Make __declspec(selectany) turn variable declartions into definitions.Nico Weber2015-04-151-2/+2
| | | | | | Fixes PR23242. llvm-svn: 235046
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-091-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation would copy the attribute from the class to functions that have the class as their return type when the functions are first declared. This proved to have two flaws: 1) if the class is forward-declared without the attribute and a function or method with the class as a its return type is declared, and afterward the class is defined with warn_unused_result, the function or method would never inherit the attribute, and 2) the check simply failed for functions and methods that are part of a template instantiation, regardless of whether the class with warn_unused_result is part of a specific instantiation or part of the template itself (presumably because those function/method declaration does not hit the same code path as a non-template one and so never inherits the attribute). The new approach is to instead modify the two places where a function or method call is checked for the warn_unused_result attribute on the decl by extending the checks to also look for the attribute on the decl's return type. Additionally, the check for return types that have the warn_unused_result now excludes pointers and references to such types, as such return types do not necessarily imply a transfer of ownership for the underlying object being referred to by the return value. This does not change the behavior of functions that are directly given the warn_unused_result attribute. llvm-svn: 234526
* Replace copy loop with std::copy.Benjamin Kramer2015-04-051-2/+1
| | | | | | No functional change intended. llvm-svn: 234123
* Partially revert "Replace custom alignment enforcement with LLVM_ALIGNAS."Benjamin Kramer2015-04-021-2/+4
| | | | | | | | | MSVC 2013 can't even parse __declspec(align(sizeof(foo))). We'll have to wait until MSVC 2015 for this. This partially reverts commit r233911. llvm-svn: 233912
* Replace custom alignment enforcement with LLVM_ALIGNAS.Benjamin Kramer2015-04-021-4/+4
| | | | | | | | | | This isn't perfect as it still assumes sizeof(void*) == alignof(void*), but we can fix that when compiler support gets better. Shrinks some Stmts that happen to inherit from Stmt and have a SourceLocation as the first member (64 bit archs only). llvm-svn: 233911
* [modules] Handle defining a tag with a typedef name for linkage purposes on ↵Richard Smith2015-03-271-0/+8
| | | | | | top of an existing imported-but-not-visible definition. llvm-svn: 233345
* C++14: Disable sized deallocation by default due to ABI breakageReid Kleckner2015-03-201-33/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are no widely deployed standard libraries providing sized deallocation functions, so we have to punt and ask the user if they want us to use sized deallocation. In the future, when such libraries are deployed, we can teach the driver to detect them and enable this feature. N3536 claimed that a weak thunk from sized to unsized deallocation could be emitted to avoid breaking backwards compatibility with standard libraries not providing sized deallocation. However, this approach and other variations don't work in practice. With the weak function approach, the thunk has to have default visibility in order to ensure that it is overridden by other DSOs providing sized deallocation. Weak, default visibility symbols are particularly expensive on MachO, so John McCall was considering disabling this feature by default on Darwin. It also changes behavior ELF linking behavior, causing certain otherwise unreferenced object files from an archive to be pulled into the link. Our second approach was to use an extern_weak function declaration and do an inline conditional branch at the deletion call site. This doesn't work because extern_weak only works on MachO if you have some archive providing the default value of the extern_weak symbol. Arranging to provide such an archive has the same challenges as providing the symbol in the standard library. Not to mention that extern_weak doesn't really work on COFF. Reviewers: rsmith, rjmccall Differential Revision: http://reviews.llvm.org/D8467 llvm-svn: 232788
* Don't crash-on-valid when an inline function is friend of class templateDavid Majnemer2015-03-201-1/+2
| | | | | | | | | We assumed that the most recent declaration of an inline function would also be inline. However, a more recent declaration can come from a friend declaration in a class template that is instantiated at the definition of the function. llvm-svn: 232786
* MS ABI: Implement __GetExceptionInfo for std::make_exception_ptrDavid Majnemer2015-03-131-1/+8
| | | | | | | | | std::make_exception_ptr calls std::__GetExceptionInfo in order to figure out how to properly copy the exception object. Differential Revision: http://reviews.llvm.org/D8280 llvm-svn: 232188
* Replace Sema's map of locally-scoped extern "C" declarations with a DeclContextRichard Smith2015-03-071-0/+7
| | | | | | | | | | of extern "C" declarations. This is simpler and vastly more efficient for modules builds (we no longer need to load *all* extern "C" declarations to determine if we have a redeclaration). No functionality change intended. llvm-svn: 231538
* [modules] Rework merging of redeclaration chains on module import.Richard Smith2015-03-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | We used to save out and eagerly load a (potentially huge) table of merged formerly-canonical declarations when we loaded each module. This was extremely inefficient in the presence of large amounts of merging, and didn't actually save any merging lookup work, because we still needed to perform name lookup to check that our merged declaration lists were complete. This also resulted in a loss of laziness -- even if we only needed an early declaration of an entity, we would eagerly pull in all declarations that had been merged into it regardless. We now store the relevant fragments of the table within the declarations themselves. In detail: * The first declaration of each entity within a module stores a list of first declarations from imported modules that are merged into it. * Loading that declaration pre-loads those other entities, so that they appear earlier within the redeclaration chain. * The name lookup tables list the most recent local lookup result, if there is one, or all directly-imported lookup results if not. llvm-svn: 231424
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-2/+2
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* [modules] When determining whether a name from a module replaces a name weRichard Smith2015-02-101-51/+99
| | | | | | | | | already have, check whether the name from the module is actually newer than the existing declaration. If it isn't, we might (say) replace a visible declaration with an injected friend, and thus make it invisible (or lose a default argument or an array bound). llvm-svn: 228661
* Generalize r228066 to give all implicit global allocation functions default ↵Larisse Voufo2015-02-041-6/+1
| | | | | | visibility. llvm-svn: 228107
* PR22419: Give implicit sized deallocation functions default visibilityLarisse Voufo2015-02-031-1/+6
| | | | llvm-svn: 228066
* The prefix 'Ms-' should be 'MS-'David Majnemer2015-02-021-1/+1
| | | | | | | Clang is otherwise consistent that Microsoft be abbreviated as MS, not Ms. llvm-svn: 227842
* AST: Fix the linkage of static vars in fn template specializationsDavid Majnemer2014-12-161-1/+1
| | | | | | | | | | | | We that static variables in function template specializations were externally visible. The manglers assumed that externally visible static variables were numbered in Sema. We would end up mangling static variables in the same specialization with the same mangling number which would give all of them the same name. This fixes PR21904. llvm-svn: 224316
* Fix the issue of mangling of local anonymous unions (Itanium C++ ABI):Evgeny Astigeevich2014-12-121-0/+16
| | | | | | | | | | | | | | | | | | | | | | A discriminator is used for the first occurrence of a name. inline int f1 () { static union { int a; long int b; }; static union { int c; double d; }; return a+c; } The name of the second union is mangled as _ZZ2f1vE1c_0 instead of _ZZ2f1vE1c. Differential Revision: http://reviews.llvm.org/D6295 llvm-svn: 224131
* AST: Properly calculate the linkage of a IndirectFieldDeclDavid Majnemer2014-12-101-2/+5
| | | | | | | | | | | getLVForNamespaceScopeDecl believed that it wasn't possible for it to ever see an IndirectFieldDecl. However, this can occur when determining whether or not something is a redeclaration of a member of an anonymous static union. This fixes PR21858. llvm-svn: 223975
* [Sanitizer] Refactor sanitizer options in LangOptions.Alexey Samsonov2014-11-111-1/+1
| | | | | | | | | | | | | | | | | | Get rid of ugly SanitizerOptions class thrust into LangOptions: * Make SanitizeAddressFieldPadding a regular language option, and rely on default behavior to initialize/reset it. * Make SanitizerBlacklistFile a regular member LangOptions. * Introduce the helper class "SanitizerSet" to represent the set of enabled sanitizers and make it a member of LangOptions. It is exactly the entity we want to cache and modify in CodeGenFunction, for instance. We'd also be able to reuse SanitizerSet in CodeGenOptions for storing the set of recoverable sanitizers, and in the Driver to represent the set of sanitizers turned on/off by the commandline flags. No functionality change. llvm-svn: 221653
* Introduce a SanitizerKind enum to LangOptions.Alexey Samsonov2014-11-071-1/+1
| | | | | | | | | | | | | Use the bitmask to store the set of enabled sanitizers instead of a bitfield. On the negative side, it makes syntax for querying the set of enabled sanitizers a bit more clunky. On the positive side, we will be able to use SanitizerKind to eventually implement the new semantics for -fsanitize-recover= flag, that would allow us to make some sanitizers recoverable, and some non-recoverable. No functionality change. llvm-svn: 221558
* Fix the buildDavid Blaikie2014-10-311-1/+1
| | | | llvm-svn: 220974
* Fix unused-function warning differently from r220853David Blaikie2014-10-311-8/+1
| | | | | | | | | | Rather than executing this code only needed for an assertion even in a non-asserts build, just roll the function into the assert. The assertion text literally describes the two cases so it doesn't seem like this benefits much from having a separate function (& have to hassle about ifndef NDEBUG it out, etc) llvm-svn: 220970
* clang/lib/AST/Decl.cpp: Tweak isVLATypeCapturingAllowed() for -Asserts. ↵NAKAMURA Takumi2014-10-291-1/+3
| | | | | | [-Wunused-function] llvm-svn: 220853
* Improved capturing variable-length array types in CapturedStmt.Alexey Bataev2014-10-291-1/+15
| | | | | | | | An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas. This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP. Differential Revision: http://reviews.llvm.org/D5099 llvm-svn: 220850
* Teach SanitizerBlacklist to blacklist by SourceLocation. NFC.Alexey Samsonov2014-10-161-3/+2
| | | | llvm-svn: 219993
* Insert poisoned paddings between fields in C++ classes so that ↵Kostya Serebryany2014-10-161-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | AddressSanitizer can find intra-object-overflow bugs Summary: The general approach is to add extra paddings after every field in AST/RecordLayoutBuilder.cpp, then add code to CTORs/DTORs that poisons the paddings (CodeGen/CGClass.cpp). Everything is done under the flag -fsanitize-address-field-padding. The blacklist file (-fsanitize-blacklist) allows to avoid the transformation for given classes or source files. See also https://code.google.com/p/address-sanitizer/wiki/IntraObjectOverflow Test Plan: run SPEC2006 and some of the Chromium tests with -fsanitize-address-field-padding Reviewers: samsonov, rnk, rsmith Reviewed By: rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D5687 llvm-svn: 219961
* Change how we distinguish bitfield widths, in-classJohn McCall2014-10-101-32/+17
| | | | | | | | initializers, and captured VLA types so that we can answer questions like "is this a bit-field" without looking at the enclosing DeclContext. NFC. llvm-svn: 219522
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-221-0/+7
| | | | | | | | | | | | | | | | Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
* patch to add missing warning on sizeof wrong parameterFariborz Jahanian2014-09-121-0/+3
| | | | | | | | 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
* Objective-C. Under a special flag, -Wcstring-format-directive,Fariborz Jahanian2014-09-091-0/+13
| | | | | | | | off by default, issue a warning if %s directive is used in certain CF/NS formatting APIs, to assist user in deprecating use of such %s in these APIs. rdar://18182443 llvm-svn: 217467
* [modules] Use DeclContext::equals rather than == on DeclContext* whenRichard Smith2014-09-031-0/+5
| | | | | | | | | | determining whether a declaration is out of line, instead of assuming that the semantic and lexical DeclContext will be the same declaration whenever they're the same entity. This fixes behavior of declarations within merged classes and enums. llvm-svn: 217008
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-4/+32
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-3/+3
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* Range'ify some for loops over RecordDecl::fields()Hans Wennborg2014-08-211-3/+4
| | | | | | No functionality change. llvm-svn: 216183
* Add some FIXMEs.Richard Smith2014-08-111-0/+2
| | | | llvm-svn: 215375
* Fix linkage bug that miscompiled variable templates instantiated from ↵Larisse Voufo2014-07-021-0/+64
| | | | | | | | | | | similarly named local types. In essence, this bug ensures that the x<Foo> specialization in function foo() defined as follows differs between two distinct translation units. static int &foo() { struct Foo { }; return x<Foo>; } llvm-svn: 212233
* Make FunctionDecl::getReturnTypeSourceRange() support non-builtin typesAlp Toker2014-07-021-8/+11
| | | | | | | Also document that the function is a "best-effort" facility to extract source ranges from limited AST type location info. llvm-svn: 212174
* Introduce a FunctionDecl::getReturnTypeSourceRange() utilityAlp Toker2014-07-021-0/+17
| | | | | | | | | | This source range is useful for all kinds of diagnostic QOI and refactoring work, so let's make it more discoverable. This commit also makes use of the new function to enhance various diagnostics relating to return types and resolves an old FIXME. llvm-svn: 212154
* Fix treatment of types defined in function prototypeSerge Pavlov2014-06-251-0/+12
| | | | | | | | | | | | Types defined in function prototype are diagnosed earlier in C++ compilation. They are put into declaration context where the prototype is introduced. Later on, when FunctionDecl object is created, these types are moved into the function context. This patch fixes PR19018 and PR18963. Differential Revision: http://reviews.llvm.org/D4145 llvm-svn: 211718
* Fix crash declaring global allocation function with zero parameters. Fixes ↵Nick Lewycky2014-06-071-1/+1
| | | | | | PR19968! llvm-svn: 210388
* Rename utility function templatesAlp Toker2014-05-311-6/+6
| | | | | | | isExternCTemplate() and getLanguageLinkageTemplate() have nothing to do with templates despite the dubious naming scheme. llvm-svn: 209969
* Take PrintingPolicy::SuppressUnwrittenScope into account when printing theRichard Smith2014-05-301-0/+3
| | | | | | qualified name of a NamedDecl. Patch by Volodymyr Sapsai! llvm-svn: 209924
* Move the logic for testing for namespace std into one location. This check canRichard Trieu2014-05-281-8/+1
| | | | | | be performed by using Decl::isInStdNamespace or DeclContext::isStdNamespace llvm-svn: 209708
* Avoid allocating extra memory to handle the lazy definition data pointer forRichard Smith2014-05-221-1/+1
| | | | | | CXXRecordDecls when modules is enabled. llvm-svn: 209482
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-161-36/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. llvm-svn: 209046
* Allow dllimport/dllexport on inline functions and adjust the linkage.Hans Wennborg2014-05-151-1/+1
| | | | | | | | This is a step towards handling these attributes on classes (PR11170). Differential Revision: http://reviews.llvm.org/D3772 llvm-svn: 208925
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-72/+82
| | | | llvm-svn: 208517
OpenPOWER on IntegriCloud