summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [AST] Keep track of the left brace source location of a tag decl.Argyrios Kyrtzidis2016-07-151-0/+1
| | | | | | This is useful for source modification tools. There will be a follow-up commit using it. llvm-svn: 275590
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-071-5/+3
| | | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274732
* AvailabilityAttr: we accept "macos" as the platform name.Manman Ren2016-06-281-1/+1
| | | | | | | | | | | | | | We continue accepting "macosx" but canonicalize it to "macos", When emitting diagnostics, we use "macOS" instead of "OS X". The PlatformName in TargetInfo is changed from "macosx" to "macos" so we can directly compare the Platform in AvailabilityAttr with the PlatformName in TargetInfo. rdar://26795172 rdar://26800775 llvm-svn: 274064
* Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith2016-06-251-17/+13
| | | | | | | variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
* Use more ArrayRefsDavid Majnemer2016-06-241-8/+9
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Use ranges to concisely express iterationDavid Majnemer2016-06-231-8/+7
| | | | | | | No functional change is intended, this should just clean things up a little. llvm-svn: 273522
* [modules] Enforce the rules that an explicit or partial specialization must beRichard Smith2016-05-051-0/+15
| | | | | | | | declared before it is used. Because we don't use normal name lookup to find these, the normal code to filter out non-visible names from name lookup results does not apply. llvm-svn: 268585
* [GCC] Attribute ifunc support in clangDmitry Polukhin2016-04-111-2/+2
| | | | | | | | | | | This patch add support for GCC attribute((ifunc("resolver"))) for targets that use ELF as object file format. In general ifunc is a special kind of function alias with type @gnu_indirect_function. LLVM patch http://reviews.llvm.org/D15525 Differential Revision: http://reviews.llvm.org/D15524 llvm-svn: 265917
* Implement support for [[nodiscard]] in C++1z that is based off existing ↵Aaron Ballman2016-03-071-5/+11
| | | | | | support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class. llvm-svn: 262872
* [OPENMP 4.0] Initial support for 'omp declare reduction' construct.Alexey Bataev2016-03-031-0/+1
| | | | | | | | | | | | | | | | | Add parsing, sema analysis and serialization/deserialization for 'declare reduction' construct. User-defined reductions are defined as #pragma omp declare reduction( reduction-identifier : typename-list : combiner ) [initializer ( initializer-expr )] These custom reductions may be used in 'reduction' clauses of OpenMP constructs. The combiner specifies how partial results can be combined into a single value. The combiner can use the special variable identifiers omp_in and omp_out that are of the type of the variables being reduced with this reduction-identifier. Each of them will denote one of the values to be combined before executing the combiner. It is assumed that the special omp_out identifier will refer to the storage that holds the resulting combined value after executing the combiner. As the initializer-expr value of a user-defined reduction is not known a priori the initializer-clause can be used to specify one. Then the contents of the initializer-clause will be used as the initializer for private copies of reduction list items where the omp_priv identifier will refer to the storage to be initialized. The special identifier omp_orig can also appear in the initializer-clause and it will refer to the storage of the original variable to be reduced. Differential Revision: http://reviews.llvm.org/D11182 llvm-svn: 262582
* Serialize `#pragma detect_mismatch`.Nico Weber2016-03-021-0/+24
| | | | | | | 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
* Serialize `#pragma comment`.Nico Weber2016-03-021-0/+23
| | | | | | | | | | | | | | `#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
* [OpenCL] Disable C99 standard lib functionsAnastasia Stulova2016-02-121-0/+6
| | | | | | | | | | | | | | The library functions defined in the C99 standard headers are not available (OpenCL v1.2 s6.9.f). This change stops treating OpenCL builtin functions as standard C lib functions to eliminate warning messages about printf format string. Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16812 llvm-svn: 260671
* [MS Compat] Don't crash if __GetExceptionInfo is in global scopeDavid Majnemer2016-01-261-2/+1
| | | | | | | | | | | __GetExceptionInfo triggered Sema::LazilyCreateBuiltin which tries to create a non-templated function decl. This is unnecessary and ill-advised, there is no need for us to create a declaration for such a builtin. This fixes PR26298. llvm-svn: 258762
* Fix infinite recursion for invalid declaration, by Dmitry PolukhinAlexey Bataev2016-01-121-1/+1
| | | | | | | Fix for a case found by fuzzing PR23057 (comment #25 https://llvm.org/bugs/show_bug.cgi?id=23057#c25). Differential Revision: http://reviews.llvm.org/D16065 llvm-svn: 257461
* PR26048, PR26050: put non-type template parameters and indirect field declsRichard Smith2016-01-061-2/+12
| | | | | | | | into IDNS_Tag in C++, because they conflict with redeclarations of tags. (This doesn't affect elaborated-type-specifier lookup, which looks for IDNS_Type in C++). llvm-svn: 256985
* [ptr-traits] Move methods manipulating PointerUnions, DenseMap pointerChandler Carruth2015-12-301-0/+34
| | | | | | | | | | | | | | | keys, and PointerIntPairs where the pointee types are incomplete out-of-line to where we have the complete type. This is the standard pattern used throughout the AST library to address the inherently mutually cross referenced nature of the AST. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. llvm-svn: 256612
* [ptr-traits] Stop using two bogus types as stand-ins for flagsChandler Carruth2015-12-301-6/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | indicating the nature of the default argument in a ParmVarDecl. Instead, this adds a proper enum stored exclusively in the ParmVarDecl bits (which we have plenty of) for this. This even allows us to track a previously unrepresented state in Clang when we parse a function declaration with a default argument on a parameter but we cannot even form an invalid expression node (for example, it is an invalid token). Now, we can model this state in the AST at least, and potentially improve recovery in this area in the future. I've also cleaned up the functions managing both variable initializer expressions and parameter default argument expresssions as much as possible. I've left some comments about further improvements based on a discussion with Richard Smith. Lots of credit to him for walking me through exactly which of the *many* tradeoffs here he felt was the best fit. Should be NFC for now. I've tried my best to preserve existing behavior. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. llvm-svn: 256609
* Model NamespaceAliasDecls as having their nominated namespace as an underlyingRichard Smith2015-12-291-0/+3
| | | | | | | | | | | | | declaration. This fixes an issue where we would reject (due to a claimed ambiguity) a case where lookup finds multiple NamespaceAliasDecls from different scopes that nominate the same namespace. The C++ standard doesn't make it clear that such a case is in fact valid (which I'm working on fixing), but there are no relevant rules that distinguish using declarations and namespace alias declarations here, so it makes sense to treat them the same way. llvm-svn: 256601
* Print qualified display names when emitting CodeViewReid Kleckner2015-12-161-2/+4
| | | | | | This is what debuggers expect. Words towards fixing PR21528. llvm-svn: 255744
* [modules] Allow "redefinition" of typedef of anon tag from unimported submoduleBen Langmuir2015-11-141-1/+2
| | | | | | | | | r233345 started being stricter about typedef names for linkage purposes in non-visible modules, but broke languages without the ODR. rdar://23527954 llvm-svn: 253123
* [modules] Follow the C++ standard's rule for linkage of enumerators: they haveRichard Smith2015-11-131-1/+4
| | | | | | | | | the linkage of the enumeration. For enumerators of unnamed enumerations, extend the -Wmodules-ambiguous-internal-linkage extension to allow selecting an arbitrary enumerator (but only if they all have the same value, otherwise it's ambiguous). llvm-svn: 253010
* [modules] Simplify and generalize the existing rule for finding hiddenRichard Smith2015-11-121-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | declarations in redeclaration lookup. A declaration is now visible to lookup if: * It is visible (not in a module, or in an imported module), or * We're doing redeclaration lookup and it's externally-visible, or * We're doing typo correction and looking for unimported decls. We now support multiple modules having different internal-linkage or no-linkage definitions of the same name for all entities, not just for functions, variables, and some typedefs. As previously, if multiple such entities are visible, any attempt to use them will result in an ambiguity error. This patch fixes the linkage calculation for a number of entities where we previously didn't need to get it right (using-declarations, namespace aliases, and so on). It also classifies enumerators as always having no linkage, which is a slight deviation from the C++ standard's definition, but not an observable change outside modules (this change is being discussed on the -core reflector currently). This also removes the prior special case for tag lookup, which made some cases of this work, but also led to bizarre, bogus "must use 'struct' to refer to type 'Foo' in this scope" diagnostics in C++. llvm-svn: 252960
* Implement __attribute__((internal_linkage)).Evgeniy Stepanov2015-11-101-0/+8
| | | | | | | | | | | | | | The attrubite is applicable to functions and variables and changes the linkage of the subject to internal. This is the same functionality as C-style "static", but applicable to class methods; and the same as anonymouns namespaces, but can apply to individual methods of a class. Following the proposal in http://lists.llvm.org/pipermail/cfe-dev/2015-October/045580.html llvm-svn: 252648
* Use "auto" when the type name is redundantAlexander Kornienko2015-11-091-91/+79
| | | | | | | | | | | | Summary: Use "auto" when the type name is redundant Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14501 llvm-svn: 252494
* Adjust printQualifiedName to handle unscoped enums in a way similar to ↵Alexander Kornienko2015-11-091-0/+9
| | | | | | | | | | anonymous namespaces. Patch by Sterling Augustine! Differential revision: http://reviews.llvm.org/D14459 llvm-svn: 252488
* [modules] Rationalize the behavior of Decl::declarationReplaces, and inRichard Smith2015-11-031-54/+30
| | | | | | | | | particular don't assume that two declarations of the same kind in the same context are declaring the same entity. That's not true when the same name is declared multiple times as internal-linkage symbols within a module. (getCanonicalDecl is cheap now, so we can just use it here.) llvm-svn: 251898
* [MSVC Compat] Enable ABI impacting non-conforming behavior independently of ↵David Majnemer2015-10-081-1/+2
| | | | | | | | | | -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
* [OpenCL 2.0] Enable program scope variables, Section 6.5.1.Anastasia Stulova2015-09-301-1/+0
| | | | | | | | | | | | | | | | | | - Remove virtual SC_OpenCLWorkGroupLocal storage type specifier as it conflicts with static local variables now and prevents diagnosing static local address space variables correctly. - Allow static local and global variables (OpenCL2.0 s6.8 and s6.5.1). - Improve diagnostics of allowed ASes for variables in different scopes: (i) Global or static local variables have to be in global or constant ASes (OpenCL1.2 s6.5, OpenCL2.0 s6.5.1); (ii) Non-kernel function variables can't be declared in local or constant ASes (OpenCL1.1 s6.5.2 and s6.5.3). http://reviews.llvm.org/D13105 llvm-svn: 248906
* [MS ABI] Correctly mangle classes without names for linkage purposesDavid Majnemer2015-08-311-4/+4
| | | | | | | | | | | | | | | | A class without a name for linkage purposes gets a name along the lines of <unnamed-type-foo> where foo is either the name of a declarator which defined it (like a variable or field) or a typedef-name (like a typedef or alias-declaration). We handled the declarator case correctly but it would fall down during template instantiation if the declarator didn't share the tag's type. We failed to handle the typedef-name case at all. Instead, keep track of the association between the two and keep it up to date in the face of template instantiation. llvm-svn: 246469
* Convert a few classes over to use the new TrailingObjects helper.James Y Knight2015-08-061-28/+28
| | | | | | | | | | This initial commit serves as an example -- the remainder of the classes using pointer arithmetic for trailing objects will be converted in subsequent changes. Differential Revision: http://reviews.llvm.org/D11298 llvm-svn: 244262
* function_ref-ize ExternalASTSource::FindExternalLexicalDecl and remove itsRichard Smith2015-08-051-14/+4
| | | | | | | | useless return value. Switch to using it directly when completing the redeclaration chain for an anonymous declaration, and reduce the set of declarations that we load in the process to just those of the right kind. llvm-svn: 244161
* [AST] ArrayRefize template param list info setters. No functionality change ↵Benjamin Kramer2015-08-051-22/+14
| | | | | | intended. llvm-svn: 244028
* [AST] ArrayRefize BlockDecl::setCaptures. No functionality change intended.Benjamin Kramer2015-08-051-17/+8
| | | | llvm-svn: 244027
* Fix alignment issues in Clang.James Y Knight2015-07-171-3/+3
| | | | | | | | | | | | | | | | | Some const-correctness changes snuck in here too, since they were in the area of code I was modifying. This seems to make Clang actually work without Bus Error on 32bit-sparc. Follow-up patches will factor out a trailing-object helper class, to make classes using the idiom of appending objects to other objects easier to understand, and to ensure (with static_assert) that required alignment guarantees continue to hold. Differential Revision: http://reviews.llvm.org/D10272 llvm-svn: 242554
* [OpenMP] Add TLS-based implementation for threadprivate directive.Samuel Antao2015-07-131-4/+8
| | | | llvm-svn: 242080
* [MS ABI] Don't generates code for unreferenced inline definitions of library ↵David Majnemer2015-07-101-2/+2
| | | | | | | | | | | builtins We should only consider declarations which were written, implicit declarations shouldn't be considered. This fixes PR24084. llvm-svn: 241941
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-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
* [ASan] Initial support for Kernel AddressSanitizerAlexander Potapenko2015-06-191-1/+2
| | | | | | | | | This patch adds initial support for the -fsanitize=kernel-address flag to Clang. Right now it's quite restricted: only out-of-line instrumentation is supported, globals are not instrumented, some GCC kasan flags are not supported. Using this patch I am able to build and boot the KASan tree with LLVMLinux patches from github.com/ramosian-glider/kasan/tree/kasan_llvmlinux. To disable KASan instrumentation for a certain function attribute((no_sanitize("kernel-address"))) can be used. llvm-svn: 240131
* [AST] Put VarDeclBitfields on a dietDavid Majnemer2015-05-191-0/+2
| | | | | | | | VarDeclBitfields contained bits which are never present in parameters. Split these out so that ParmVarDeclBitfields wouldn't grow past 32-bits if another field was added. llvm-svn: 237648
* [modules] Add local submodule visibility support for declarations.Richard Smith2015-05-151-3/+16
| | | | | | | | | | | | With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
* [MS ABI] __declspec(thread) behaves like thread_local in MSVC 2015David Majnemer2015-05-141-3/+6
| | | | | | | MSVC 2015 changed __declspec(thread) to make it behave like C++11's thread_local keyword instead of acting similarly to __thread. llvm-svn: 237337
* [AST] hasAttr followed by getAttr isn't efficientDavid Majnemer2015-05-141-2/+5
| | | | | | Just use getAttr because we are interested in the attribute's contents. llvm-svn: 237336
* De-virtualize some const versions of getCanonicalDecl by redirecting to the ↵Craig Topper2015-05-101-4/+0
| | | | | | non-const version. Most of the Decl hierarchy already did it this way this just makes the rest consistent. llvm-svn: 236959
* Wrap to 80 columns, fix typo in comment. No behavior change.Nico Weber2015-04-221-7/+7
| | | | llvm-svn: 235470
* Follow-up to r235046: selectany only causes a definition if it's not inherited.Nico Weber2015-04-171-1/+2
| | | | | | | | (For example needed to parse system header inputscope.h, which first has an extern "C" selectany IID and then later an extern "C" declaration of that same IID.) llvm-svn: 235174
* 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
OpenPOWER on IntegriCloud