summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
...
* [modules] Fix a corner case in the macro override rules: properly handle ↵Richard Smith2015-09-161-2/+6
| | | | | | overridden leaf module macros. llvm-svn: 247765
* Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1Adrian Prantl2015-08-271-1/+1
| | | | | | | | | | | | | to enable the use of external type references in the debug info (a.k.a. module debugging). The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs" and passes that to cc1. All this does at the moment is set a flag codegenopts. http://reviews.llvm.org/D11958 llvm-svn: 246192
* [modules] Remove unnecessary deserialization of fully-external ↵Richard Smith2015-08-242-30/+63
| | | | | | HeaderFileInfos for all files we've seen in this compilation. llvm-svn: 245881
* [modules] Fix HeaderFileInfo serialization to store all the known owning ↵Richard Smith2015-08-182-47/+71
| | | | | | modules for a header, not just the current favourite. llvm-svn: 245390
* [modules] PR20507: Avoid silent textual inclusion.Sean Silva2015-08-172-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a module was unavailable (either a missing requirement on the module being imported, or a missing file anywhere in the top-level module (and not dominated by an unsatisfied `requires`)), we would silently treat inclusions as textual. This would cause all manner of crazy and confusing errors (and would also silently "work" sometimes, making the problem difficult to track down). I'm really not a fan of the `M->isAvailable(getLangOpts(), getTargetInfo(), Requirement, MissingHeader)` function; it seems to do too many things at once, but for now I've done things in a sort of awkward way. The changes to test/Modules/Inputs/declare-use/module.map were necessitated because the thing that was meant to be tested there (introduced in r197805) was predicated on silently falling back to textual inclusion, which we no longer do. The changes to test/Modules/Inputs/macro-reexport/module.modulemap are just an overlooked missing header that seems to have been missing since this code was committed (r213922), which is now caught. Reviewers: rsmith, benlangmuir, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10423 llvm-svn: 245228
* [modules] Stop dropping 'module.timestamp' files into the current directoryRichard Smith2015-08-151-2/+2
| | | | | | when building with implicit modules disabled. llvm-svn: 245136
* Turn off __has_feature(cxx_rtti) when -fno-rtti-data is presentReid Kleckner2015-08-131-1/+1
| | | | | | | | | | | -fno-rtti-data makes it so that vtables emitted in the current TU lack RTTI data. This means that dynamic_cast usually fails at runtime. Users of the existing cxx_rtti feature expect all of RTTI to work, not just some of it. Chromium bug for context: http://crbug.com/518191 llvm-svn: 244922
* Attempt to fix build after r244912Ben Langmuir2015-08-131-4/+7
| | | | | | | Some compilers were less happy about converting a lambda to a comparator function for array_pod_sort. llvm-svn: 244917
* [Modules] Add Darwin-specific compatibility module map parsing hacksBen Langmuir2015-08-131-7/+91
| | | | | | | | | | | | | | | | This preserves backwards compatibility for two hacks in the Darwin system module map files: 1. The use of 'requires excluded' to make headers non-modular, which should really be mapped to 'textual' now that we have this feature. 2. Silently removes a bogus cplusplus requirement from IOKit.avc. Once we start diagnosing missing requirements and headers on auto-imports these would have broken compatibility with existing Darwin SDKs. llvm-svn: 244912
* [modules] When building a dependency file, include module maps parsed in theRichard Smith2015-08-091-0/+5
| | | | | | current compilation, not just those from imported modules. llvm-svn: 244413
* Rename the non-coding style conformant functions in namespace BuiltinsEric Christopher2015-08-061-1/+1
| | | | | | to match the rest of their brethren and reformat the bits that need it. llvm-svn: 244186
* Improved error recovery for _PragmaHubert Tong2015-07-301-1/+5
| | | | | | | | | | | | | | | | | | | | | Summary: Currently, if the argument to _Pragma is not a parenthesised string literal, the bad token will be consumed, as well as the ')', if present. If additional bad tokens are passed to the _Pragma, this results in extra error messages which may distract from the true problem. The proposed patch causes all tokens to be consumed until the closing ')' or a new line, whichever is reached first. Reviewers: hfinkel, rsmith Subscribers: hubert.reinterpretcast, fraggamuffin, rnk, cfe-commits Differential Revision: http://reviews.llvm.org/D8308 Patch by Rachel Craik! llvm-svn: 243692
* [MS Extensions] Remove support for the i128 integer literal suffixDavid Majnemer2015-07-261-4/+1
| | | | | | | | | | | | | There is currently no support in MSVC for using i128 as an integer literal suffix. In fact, there appears to be no evidence that they have ever supported this feature in any of their compilers. This was an over generalization of their actual feature and is a nasty source of bugs. Why is it a source of bugs? Because most code in clang expects that evaluation of an integer constant expression won't give them something that 'long long' can't represent. Instead of providing a meaningful feature, i128 gives us cute ways of exploding the compiler. llvm-svn: 243243
* [modules] Produce an error if -cc1 wants to implicitly build a module and noRichard Smith2015-07-211-2/+3
| | | | | | | module cache has been provided, rather than creating one in the current directory. llvm-svn: 242819
* Ignore the "novtable" declspec when not using the Microsoft C++ ABI.Bob Wilson2015-07-201-3/+3
| | | | | | | | | | | | | | Clang used to silently ignore __declspec(novtable). It is implemented now, but leaving the vtable uninitialized does not work when using the Itanium ABI, where the class layout for complex class hierarchies is stored in the vtable. It might be possible to honor the novtable attribute in some simple cases and either report an error or ignore it in more complex situations, but it’s not clear if that would be worthwhile. There is also value in having a simple and predictable behavior, so this changes clang to simply ignore novtable when not using the Microsoft C++ ABI. llvm-svn: 242730
* Make the clang module container format selectable from the command line.Adrian Prantl2015-07-171-1/+3
| | | | | | | | | | | | | - introduces a new cc1 option -fmodule-format=[raw,obj] with 'raw' being the default - supports arbitrary module container formats that libclang is agnostic to - adds the format to the module hash to avoid collisions - splits the old PCHContainerOperations into PCHContainerWriter and a PCHContainerReader. Thanks to Richard Smith for reviewing this patch! llvm-svn: 242499
* Add __has_feature(attribute_availability_with_version_underscores).Jordan Rose2015-07-161-0/+1
| | | | | | | | This goes with r218884 from, um, last autumn. rdar://problem/21754114 llvm-svn: 242480
* [modules] When diagnosing errors in module map files found by 'extern ↵Richard Smith2015-07-141-4/+5
| | | | | | module' declarations, show how we got to that module map file. llvm-svn: 242105
* [modules] When checking the include guard for a header, check whether it'sRichard Smith2015-07-101-8/+10
| | | | | | | | | | visible in the module we're considering entering. Previously we assumed that if we knew the include guard for a modular header, we'd already parsed it, but that need not be the case if a header is present in the current module and one of its dependencies; the result of getting this wrong was that the current module's submodule for the header would end up empty. llvm-svn: 241953
* [modules] Fix "prefer own module over others" rule when selecting a module ↵Richard Smith2015-07-101-1/+1
| | | | | | for a header to work in the presence of module hierarchy. llvm-svn: 241936
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-0/+1
| | | | | | | | | | | | | | | Introduce co- and contra-variance for Objective-C type parameters, which allows us to express that (for example) an NSArray is covariant in its type parameter. This means that NSArray<NSMutableString *> * is a subtype of NSArray<NSString *> *, which is expected of the immutable Foundation collections. Type parameters can be annotated with __covariant or __contravariant to make them co- or contra-variant, respectively. This feature can be detected by __has_feature(objc_generics_variance). Implements rdar://problem/20217490. llvm-svn: 241549
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-071-0/+1
| | | | | | | | | | The __kindof type qualifier can be applied to Objective-C object (pointer) types to indicate id-like behavior, which includes implicit "downcasting" of __kindof types to subclasses and id-like message-send behavior. __kindof types provide better type bounds for substitutions into unspecified generic types, which preserves more type information. llvm-svn: 241548
* C++ support for Objective-C lightweight generics.Douglas Gregor2015-07-071-0/+1
| | | | | | | | | | | | | | | | | | | Teach C++'s tentative parsing to handle specializations of Objective-C class types (e.g., NSArray<NSString *>) as well as Objective-C protocol qualifiers (id<NSCopying>) by extending type-annotation tokens to handle this case. As part of this, remove Objective-C protocol qualifiers from the declaration specifiers, which never really made sense: instead, provide Sema entry points to make them part of the type annotation token. Among other things, this properly diagnoses bogus types such as "<NSCopying> id" which should have been written as "id <NSCopying>". Implements template instantiation support for, e.g., NSArray<T>* in C++. Note that parameterized classes are not templates in the C++ sense, so that cannot (for example) be used as a template argument for a template template parameter. Part of rdar://problem/6294649. llvm-svn: 241545
* [Modules] Be consistent about finding a module for framework headersBen Langmuir2015-07-022-36/+30
| | | | | | | | | | | | | | | | We use findModuleForHeader() in several places, but in header search we were not calling it when a framework module didn't show up with the expected name, which would then lead to unexpected non-modular includes. Now we will find the module unconditionally for frameworks. For regular frameworks, we use the spelling of the module name from the module map file, and for inferred ones we use the canonical directory name. In the future we might want to lock down framework modules sufficiently that these name mismatches cannot happen. rdar://problem/20465870 llvm-svn: 241258
* [modules] Before checking whether the controlling macro of a header is defined,Richard Smith2015-07-011-2/+7
| | | | | | | | | | | update the identifier in case we've imported a definition of the macro (and thus the contents of the header) from a module. Also fold ExternalIdentifierLookup into ExternalPreprocessorSource; it no longer makes sense to keep these separate now that the only user of the former also needs the latter. llvm-svn: 241137
* [modules] Make the include guard optimization fire a bit more when consideringRichard Smith2015-07-012-3/+8
| | | | | | | | | | | re-entering a modular header. When we do the include guard check, we're in the visibility state for the file with the #include; the include guard may not be visible there, but we don't actually need it to be: if we've already parsed the submodule we're considering entering, it's always safe to skip it. llvm-svn: 241135
* [modules] Make sure macros get made visible in the top-level file if we've gotRichard Smith2015-06-301-2/+15
| | | | | | | local submodule visibility enabled; that top-level file might not actually be the module includes buffer if use of prebuilt modules is disabled. llvm-svn: 241120
* Make __has_feature(nullability) and __has_extension(nullability) always true.Douglas Gregor2015-06-291-4/+2
| | | | | | | These are _Underbar_capital-prefixed additions to the language that shouldn't depend on language standard. llvm-svn: 240976
* Make __has_extension(assume_nonnull) always true.Douglas Gregor2015-06-291-0/+1
| | | | llvm-svn: 240969
* [ObjC] Add NSValue support for objc_boxed_expressionsAlex Denisov2015-06-261-0/+1
| | | | | | | | | | | | | Patch extends ObjCBoxedExpr to accept records (structs and unions): typedef struct __attribute__((objc_boxable)) _Color { int r, g, b; } Color; Color color; NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)]; llvm-svn: 240761
* [Preprocessor] Iterating over all macros should include those from modules.Jordan Rose2015-06-241-0/+4
| | | | | | | | | | | | So, iterate over the list of macros mentioned in modules, and make sure those are in the master table. This isn't particularly efficient, but hopefully it's something that isn't done too often. PR23929 and rdar://problem/21480635 llvm-svn: 240571
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-225-6/+6
| | | | llvm-svn: 240353
* [modules] When building a module, if there are multiple matches for a headerRichard Smith2015-06-221-0/+3
| | | | | | | file in the loaded module maps and one of them is from the current module, that's the right match. llvm-svn: 240350
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-225-6/+6
| | | | | | | | | | | | 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
* Allow the cf_returns_[not_]retained attributes to appear on out-parameters.Douglas Gregor2015-06-191-0/+1
| | | | | | | | | | | | | | | | Includes a simple static analyzer check and not much else, but we'll also be able to take advantage of this in Swift. This feature can be tested for using __has_feature(cf_returns_on_parameters). This commit also contains two fixes: - Look through non-typedef sugar when deciding whether something is a CF type. - When (cf|ns)_returns(_not)?_retained is applied to invalid properties, refer to "property" instead of "method" in the error message. rdar://problem/18742441 llvm-svn: 240185
* Introduced pragmas for audited nullability regions.Douglas Gregor2015-06-194-0/+76
| | | | | | | | | | | | | | | | | Introduce the clang pragmas "assume_nonnull begin" and "assume_nonnull end" in which we make default assumptions about the nullability of many unannotated pointers: - Single-level pointers are inferred to __nonnull - NSError** in a (function or method) parameter list is inferred to NSError * __nullable * __nullable. - CFErrorRef * in a (function or method) parameter list is inferred to CFErrorRef __nullable * __nullable. - Other multi-level pointers are never inferred to anything. Implements rdar://problem/19191042. llvm-svn: 240156
* Introduce type nullability specifiers for C/C++.Douglas Gregor2015-06-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Introduces the type specifiers __nonnull, __nullable, and __null_unspecified that describe the nullability of the pointer type to which the specifier appertains. Nullability type specifiers improve on the existing nonnull attributes in a few ways: - They apply to types, so one can represent a pointer to a non-null pointer, use them in function pointer types, etc. - As type specifiers, they are syntactically more lightweight than __attribute__s or [[attribute]]s. - They can express both the notion of 'should never be null' and also 'it makes sense for this to be null', and therefore can more easily catch errors of omission where one forgot to annotate the nullability of a particular pointer (this will come in a subsequent patch). Nullability type specifiers are maintained as type sugar, and therefore have no effect on mangling, encoding, overloading, etc. Nonetheless, they will be used for warnings about, e.g., passing 'null' to a method that does not accept it. This is the C/C++ part of rdar://problem/18868820. llvm-svn: 240146
* [ASan] Initial support for Kernel AddressSanitizerAlexander Potapenko2015-06-191-1/+3
| | | | | | | | | 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
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-184-17/+17
| | | | | | is(). llvm-svn: 240008
* [modules] Simplify -cc1 interface for enabling implicit module maps.Richard Smith2015-06-163-14/+15
| | | | | | | | | | | | | We used to have a flag to enable module maps, and two more flags to enable implicit module maps. This is all redundant; we don't need any flag for enabling module maps in the abstract, and we don't usually have -fno- flags for -cc1. We now have just a single flag, -fimplicit-module-maps, that enables implicitly searching the file system for module map files and loading them. The driver interface is unchanged for now. We should probably rename -fmodule-maps to -fimplicit-module-maps at some point. llvm-svn: 239789
* Protection against stack-based memory corruption errors using SafeStack: ↵Peter Collingbourne2015-06-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Clang command line option and function attribute This patch adds the -fsanitize=safe-stack command line argument for clang, which enables the Safe Stack protection (see http://reviews.llvm.org/D6094 for the detailed description of the Safe Stack). This patch is our implementation of the safe stack on top of Clang. The patches make the following changes: - Add -fsanitize=safe-stack and -fno-sanitize=safe-stack options to clang to control safe stack usage (the safe stack is disabled by default). - Add __attribute__((no_sanitize("safe-stack"))) attribute to clang that can be used to disable the safe stack for individual functions even when enabled globally. Original patch by Volodymyr Kuznetsov and others at the Dependable Systems Lab at EPFL; updates and upstreaming by myself. Differential Revision: http://reviews.llvm.org/D6095 llvm-svn: 239762
* [cleanup] Remove unused default argument and tidy up.Sean Silva2015-06-101-24/+6
| | | | | | | | | The RequestingModule argument was unused and always its default value of nullptr. Also move a declaration closer to its use, and range-for'ify. llvm-svn: 239453
* Remove unused defaulted argument `IncludeTextualHeaders`.Sean Silva2015-06-041-3/+2
| | | | llvm-svn: 239123
* Replace a few std::string& with StringRef. NFC.Rafael Espindola2015-06-012-3/+2
| | | | | | Patch by Косов Евгений! llvm-svn: 238774
* Refactor MacroInfo so macro arguments can be iterated with range-based for ↵Daniel Marjamaki2015-05-291-5/+1
| | | | | | | | | | loops. No functional change intended. Patch by Sebastian Edman! llvm-svn: 238547
* Bug fix for PR23577 (https://llvm.org/bugs/show_bug.cgi?id=23577#c0).Alexander Musman2015-05-251-14/+28
| | | | | | | | | | | | "1-4" specifiers are returned as numeric constants, not identifiers, and should be treated as such. Currently pragma handler incorrectly assumes that they are returned as identifiers. Patch by Andrey Bokhanko. Differential Revision: http://reviews.llvm.org/D9856 llvm-svn: 238129
* Avoid using a C++11 library feature not present in libstdc++4.7.Richard Smith2015-05-211-2/+1
| | | | llvm-svn: 237872
* [modules] If we re-enter a submodule from within itself (when submoduleRichard Smith2015-05-213-63/+76
| | | | | | | | | | visibility is enabled) or leave and re-enter it, restore the macro and module visibility state from last time we were in that submodule. This allows mutually-#including header files to stand a chance at being modularized with local visibility enabled. llvm-svn: 237871
* Revert r237609 for now.Richard Smith2015-05-191-4/+5
| | | | | | | | | | | | glibc's headers use __need_* macros to selectively export parts of themselves to each other. This requires us to enter those files repeatedly when building a glibc module. This can be unreverted once we have a better mechanism to deal with that non-modular aspect of glibc (possibly some way to mark a header as "textual if this macro is defined"). llvm-svn: 237718
* [modules] When a file is listed as a non-textual header in a module map, don'tRichard Smith2015-05-181-5/+4
| | | | | | | | | | enter it more than once, even if it doesn't have #include guards -- we already know that it is intended to have the same effect every time it's included, and it's already had that effect. This particularly helps with local submodule visibility builds, where the include guard macro may not be visible in the includer, but will become visible the moment we enter the included file. llvm-svn: 237609
OpenPOWER on IntegriCloud