summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
...
* Clang support for __is_assignable intrinsicDavid Majnemer2016-05-231-0/+1
| | | | | | | | | | | | | | | | | | | MSVC now supports the __is_assignable type trait intrinsic, to enable easier and more efficient implementation of the Standard Library's is_assignable trait. As of Visual Studio 2015 Update 3, the VC Standard Library implementation uses the new intrinsic unconditionally. The implementation is pretty straightforward due to the previously existing is_nothrow_assignable and is_trivially_assignable. We handle __is_assignable via the same code as the other two except that we skip the extra checks for nothrow or triviality. Patch by Dave Bartolomeo! Differential Revision: http://reviews.llvm.org/D20492 llvm-svn: 270458
* [Lexer] Don't merge macro args from different macro filesVedant Kumar2016-05-191-0/+3
| | | | | | | | | | | | | | | | | | The lexer sets the end location of macro arguments incorrectly *if*, while merging consecutive args to fit into a single SLocEntry, it finds args which come from different macro files. Fix the issue by using separate SLocEntries in this situation. This fixes a code coverage crasher (rdar://problem/26181005). Because the lexer reported end locations for certain macro args incorrectly, we would generate bogus coverage mappings with negative line offsets. Reviewed-by: akyrtzi Differential Revision: http://reviews.llvm.org/D20401 llvm-svn: 270160
* NFC: simplify logic.Manman Ren2016-05-171-2/+2
| | | | llvm-svn: 269794
* Modules: set SystemHeader to true if we are building a system module.Manman Ren2016-05-172-6/+10
| | | | | | | | | | | | If we are processing a #include from a module build, we should treat it as a system header if we're building a system module. Passing an optional flag to HeaderSearch::LookupFile. Before this, the testing case will crash when accessing a freed FileEntry. rdar://26214027 llvm-svn: 269730
* [Lex] inferModuleFromLocation should do no work if there are no modulesDavid Majnemer2016-05-161-0/+3
| | | | | | | | | | | | getModuleContainingLocation ends up on the hot-path for typical C code which can lead to calls to getFileIDSlow. To speed this up, short circuit inferModuleFromLocation when there aren't any modules, implicit or otherwise. This shaves 4-5% build time when building the linux kernel. llvm-svn: 269687
* [Modules] Use vfs for (recursive) directory iterationBruno Cardoso Lopes2016-05-162-15/+22
| | | | | | | | | | | | | | | | Clang performs directory walk while searching headers inside modules by using the ::sys::fs instead of ::vfs. This prevents any code that uses the VFS (e.g, reproducer scripts) to actually find such headers, since the VFS will never be searched for those. Change these places to use vfs::recursive_directory_iterator and vfs::directory_iterator instead. Differential Revision: http://reviews.llvm.org/D20266 rdar://problem/25880368 llvm-svn: 269661
* [ModuleMap][CrashReproducer] Collect headers from inner frameworksBruno Cardoso Lopes2016-05-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (1) Collect headers under inner frameworks (frameworks inside other other frameworks). (2) Make sure we also collect the right header files inside them. More info on (2): Consider a dummy framework module B, with header Frameworks/B/B.h. Now consider that another framework A, with header Frameworks/A/A.h, has a layout with a inner framework Frameworks/A/Frameworks/B/B.h, where the "B/B.h" part is a symlink for Frameworks/B/B.h. Also assume that Frameworks/A/A.h includes <B/B.h>. When parsing header Frameworks/A/A.h, framework module lookup is performed in search for B, and it happens that "Frameworks/A/Frameworks/B/B.h" path is registered in the module instead of real "Frameworks/B/B.h". This occurs because "Frameworks/A/Frameworks/B/B.h" is scanned first by the FileManager, when looking for inner framework modules under Frameworks/A/Frameworks. This makes Frameworks/A/Frameworks/B/B.h the default cached named inside the FileManager for the B.h file UID. This leads to modules being built without consistent paths to underlying header files. This is usually not a problem in regular compilation flow, but it's an issue when running the crash reproducer. The issue is that clangs collect "Frameworks/A/Frameworks/B/B.h" but not "Frameworks/B/B.h" into the VFS, leading to err_mmap_umbrella_clash. So make sure we also collect the original header. Differential Revision: http://reviews.llvm.org/D20194 rdar://problem/25880368 llvm-svn: 269502
* Enable support for __float128 in Clang and enable it on pertinent platformsNemanja Ivanovic2016-05-091-2/+11
| | | | | | | | | | | | | | | | | | This patch corresponds to reviews: http://reviews.llvm.org/D15120 http://reviews.llvm.org/D19125 It adds support for the __float128 keyword, literals and target feature to enable it. Based on the latter of the two aforementioned reviews, this feature is enabled on Linux on i386/X86 as well as SystemZ. This is also the second attempt in commiting this feature. The first attempt did not enable it on required platforms which caused failures when compiling type_traits with -std=gnu++11. If you see failures with compiling this header on your platform after this commit, it is likely that your platform needs to have this feature enabled. llvm-svn: 268898
* [CrashReproducer] Change module map callback signature. NFCBruno Cardoso Lopes2016-05-061-1/+1
| | | | | | | | Use a StringRef instead of a FileEntry in the moduleMapAddHeader callback to allow more flexibility on what to collect on further patches. This changes the interface I introduced in r264971. llvm-svn: 268819
* Remove unused LangOpts private variable in HeaderSearch.Samuel Antao2016-04-271-2/+1
| | | | | | Was causing warnings during the build. llvm-svn: 267805
* [modules] When diagnosing a missing module import, suggest adding a #include ifRichard Smith2016-04-273-12/+114
| | | | | | | the current language doesn't have an import syntax and we can figure out a suitable file to include. llvm-svn: 267802
* [esan] EfficiencySanitizer driver flagsDerek Bruening2016-04-211-0/+2
| | | | | | | | | | | | | | | | Summary: Adds a framework to enable the instrumentation pass for the new EfficiencySanitizer ("esan") family of tools. Adds a flag for esan's cache fragmentation tool via -fsanitize=efficiency-cache-frag. Adds appropriate tests for the new flag. Reviewers: eugenis, vitalybuka, aizatsky, filcab Subscribers: filcab, kubabrecka, llvm-commits, zhaoqin, kcc Differential Revision: http://reviews.llvm.org/D19169 llvm-svn: 267059
* [modules] Make the tweak to avoid circular inclusion of emmintrin.h andRichard Smith2016-04-211-11/+4
| | | | | | | | | xmmintrin.h a bit more directed. If for whatever reason modules are enabled but we textually include one of these headers, don't deploy the special case for modules. To make this work cleanly, extend __building_module to be defined even when modules is disabled. llvm-svn: 266945
* Improve diagnostic for the case when a non-defined function-like macro is usedRichard Smith2016-04-161-4/+26
| | | | | | in a preprocessor constant expression. llvm-svn: 266495
* Revert 266186 as it breaks anything that includes type_traits on some platformsNemanja Ivanovic2016-04-151-11/+2
| | | | | | | | | | Since this patch provided support for the __float128 type but disabled it on all platforms by default, some platforms can't compile type_traits with -std=gnu++11 since there is a specialization with __float128. This reverts the patch until D19125 is approved (i.e. we know which platforms need this support enabled). llvm-svn: 266460
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-131-2/+11
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* [modules] Extend r266113 to cope with submodules.Richard Smith2016-04-121-1/+3
| | | | llvm-svn: 266116
* [modules] When an incompatible module file is explicitly provided for a module,Richard Smith2016-04-121-1/+4
| | | | | | | | and we fall back to textual inclusion, don't require the module as a whole to be marked available; it's OK if some other file in the same module is missing, just as it would be if the header were explicitly marked textual. llvm-svn: 266113
* Consolidate and improve the handling of built-in feature-like macrosAndy Gibbs2016-04-051-161/+208
| | | | | | | | | | | | | | | | | | Summary: The parsing logic has been separated out from the macro implementation logic, leading to a number of improvements: * Gracefully handle unexpected/invalid tokens, too few, too many and nested parameters * Provide consistent behaviour between all built-in feature-like macros * Simplify the implementation of macro logic * Fix __is_identifier to correctly return '0' for non-identifiers Reviewers: doug.gregor, rsmith Subscribers: rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D17149 llvm-svn: 265381
* AnnotateFunctions: Tweak for mingw.NAKAMURA Takumi2016-04-041-0/+2
| | | | | | | - Externalize the registry. - Update libdeps. llvm-svn: 265301
* Add a PragmaHandler Registry for plugins to add PragmaHandlers toJohn Brawn2016-04-041-0/+7
| | | | | | | | | | This allows plugins which add AST passes to also define pragmas to do things like only enable certain behaviour of the AST pass in files where a certain pragma is used. Differential Revision: http://reviews.llvm.org/D18319 llvm-svn: 265295
* Diagnose missing macro argument following charize operator.Andy Gibbs2016-04-011-2/+3
| | | | | | | For completeness, add a test-case for the equivalent stringize operator diagnostic too. llvm-svn: 265177
* [Lexer] Let the compiler infer string lengths. No functionality change intended.Benjamin Kramer2016-04-011-2/+2
| | | | llvm-svn: 265126
* [Lexer] Don't read out of bounds if a conflict marker is at the end of a fileBenjamin Kramer2016-04-011-1/+1
| | | | | | | | | | This can happen as we look for '<<<<' while scanning tokens but then expect '<<<<\n' to tell apart perforce from diff3 conflict markers. Just harden the pointer arithmetic. Found by libfuzzer + asan! llvm-svn: 265125
* [CrashReproducer] Add a module map callback for added headersBruno Cardoso Lopes2016-03-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current ModuleDependencyCollector has a AST listener to collect header files present in loaded modules, but this isn't enough to collect all headers needed in the crash reproducer. One of the reasons is that the AST writer doesn't write symbolic link header paths in the pcm modules, this makes the listeners on the reader only able to collect the real files. Since the module maps could contain submodules that use headers which are symbolic links, not collecting those forbid the reproducer scripts to regen the modules. For instance: usr/include/module.map: ... module pthread { header "pthread.h" export * module impl { header "pthread_impl.h" export * } } ... usr/include/pthread/pthread_impl.h usr/include/pthread_impl.h -> pthread/pthread_impl.h The AST dump for the module above: <SUBMODULE_HEADER abbrevid=6/> blob data = 'pthread_impl.h' <SUBMODULE_TOPHEADER abbrevid=7/> blob data = '/<path_to_sdk>/usr/include/pthread/pthread_impl.h' Note that we don't have "usr/include/pthread_impl.h" which is requested by the module.map in case we want to reconstruct the module in the reproducer. The reason the original symbolic link path isn't used is because the headers are kept by name and requested through the FileManager, which unique files and returns the real path only. To fix that, add a callback to be invoked everytime a header is added while parsing module maps and hook that up to the module dependecy collector. This callback is only registered when generating the reproducer. Differential Revision: http://reviews.llvm.org/D18585 rdar://problem/24499339 llvm-svn: 264971
* Add replacement = "xxx" to AvailabilityAttr.Manman Ren2016-03-211-0/+1
| | | | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This was commited in r263687 and reverted in 263752 due to misaligned access. rdar://20588929 llvm-svn: 263958
* Revert r263687 for ubsan bot failure.Manman Ren2016-03-171-1/+0
| | | | llvm-svn: 263752
* Add an optional named argument (replacement = "xxx") to AvailabilityAttr.Manman Ren2016-03-171-0/+1
| | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This enables the compiler to provide Fix-Its for deprecated declarations. rdar://20588929 llvm-svn: 263687
* Add an optional string argument to DeprecatedAttr for Fix-It.Manman Ren2016-03-161-0/+1
| | | | | | | | We only add this to __attribute__((deprecated)). Differential Revision: http://reviews.llvm.org/D17865 llvm-svn: 263652
* [modules] Don't diagnose non-modular includes from modular files that areRichard Smith2016-03-142-4/+9
| | | | | | implementation units of modules rather than interface units. llvm-svn: 263449
* Add has_feature objc_class_property.Manman Ren2016-03-101-0/+1
| | | | | | rdar://23891898 llvm-svn: 263171
* [Modules] Add stdatomic to the list of builtin headersBen Langmuir2016-03-091-0/+1
| | | | | | | | | | | | | Since it's provided by the compiler. This allows a system module map file to declare a module for it. No test change for cstd.m, since stdatomic.h doesn't function without a relatively complete stdint.h and stddef.h, which tests using this module don't provide. rdar://problem/24931246 llvm-svn: 263076
* [Modules] Modernize, use range-based loops.Davide Italiano2016-03-081-5/+2
| | | | llvm-svn: 262969
* [Modules] Don't swallow errors when parsing optional attributes.Davide Italiano2016-03-061-3/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D17787 llvm-svn: 262789
* Update diagnostics now that hexadecimal literals look likely to be part of ↵Richard Smith2016-03-042-6/+13
| | | | | | C++17. llvm-svn: 262753
* SemaCXX: Support templates in availability attributesDuncan P. N. Exon Smith2016-02-261-0/+1
| | | | | | | | | | | | | | | | | | | If the availability context is `FunctionTemplateDecl`, we should look through it to the `FunctionDecl`. This prevents a diagnostic in the following case: class C __attribute__((unavailable)); template <class T> void foo(C&) __attribute__((unavailable)); This adds tests for availability in templates in many other cases, but that was the only case that failed before this patch. I added a feature `__has_feature(attribute_availability_in_templates)` so users can test for this. rdar://problem/24561029 llvm-svn: 262050
* Revert "Don't convert a char to a const char *"David Majnemer2016-02-241-1/+1
| | | | | | | | This reverts commit r261780. It turns out the original code was just fine. An overload for ltrim which takes char was added but the Doxygen docs haven't seemed to pick it up. llvm-svn: 261784
* Don't convert a char to a const char *David Majnemer2016-02-241-1/+1
| | | | | | This fixes PR26728. llvm-svn: 261780
* PR24667: fix quadratic runtime if textually-included modular headers define ↵Richard Smith2016-02-232-22/+52
| | | | | | large numbers of macros. llvm-svn: 261705
* Lex: Return "" when HeaderMap::lookupFilename failsDuncan P. N. Exon Smith2016-02-231-13/+24
| | | | | | | | | | | | Change getString() to return Optional<StringRef>, and change lookupFilename() to return an empty string if either one of the prefix and suffix can't be found. This is a more robust follow-up to r261461, but it's still not entirely satisfactory. Ideally we'd report that the header map is corrupt; perhaps something for a follow-up. llvm-svn: 261596
* Lex: Check for 0 buckets on header map constructionDuncan P. N. Exon Smith2016-02-221-5/+5
| | | | | | | | Switch to using `isPowerOf2_32()` to check whether the buckets are a power of two, and as a side benefit reject loading a header map with no buckets. This is a follow-up to r261448. llvm-svn: 261585
* Add has_feature attribute_availability_with_strict.Manman Ren2016-02-221-0/+1
| | | | | | rdar://23791325 llvm-svn: 261548
* Lex: Never overflow the file in HeaderMap::lookupFilename()Duncan P. N. Exon Smith2016-02-211-5/+11
| | | | | | | | | | | | | | | | If a header map file is corrupt, the strings in the string table may not be null-terminated. The logic here previously relied on `MemoryBuffer` always being null-terminated, but this isn't actually guaranteed by the class AFAICT. Moreover, we're seeing a lot of crash traces at calls to `strlen()` inside of `lookupFilename()`, so something is going wrong there. Instead, use `strnlen()` to get the length, and check for corruption. Also remove code paths that could call `StringRef(nullptr)`. r261459 made these rather obvious (although they'd been there all along). llvm-svn: 261461
* Lex: Change HeaderMapImpl::getString() to return StringRef, NFCDuncan P. N. Exon Smith2016-02-201-4/+4
| | | | llvm-svn: 261459
* Lex: Use dbgs() instead of fprintf() in HeaderMap::dump()Duncan P. N. Exon Smith2016-02-201-5/+5
| | | | | | | | | | This way it's easy to change HeaderMapImpl::getString() to return a StringRef. There's a slight change here, because I used `errs()` instead of `dbgs()`. But `dbgs()` is more appropriate for a dump method. llvm-svn: 261456
* Lex: Check whether the header map buffer has space for the bucketsDuncan P. N. Exon Smith2016-02-201-10/+10
| | | | | | | | | | | | | Check up front whether the header map buffer has space for all of its declared buckets. There was already a check in `getBucket()`, but it had UB (comparing pointers that were outside of objects in the error path) and was insufficient (only checking for a single byte of the relevant bucket). I fixed the check, moved it to `checkHeader()`, and left a fixed version behind as an assertion. llvm-svn: 261449
* Lex: Check buckets on header map constructionDuncan P. N. Exon Smith2016-02-201-4/+12
| | | | | | | | If the number of buckets is not a power of two, immediately recognize the header map as corrupt, rather than waiting for the first lookup. I converted the later check to an assert. llvm-svn: 261448
* Lex: Add some unit tests for corrupt header mapsDuncan P. N. Exon Smith2016-02-201-48/+28
| | | | | | | | | | | | Split the implementation of `HeaderMap` into `HeaderMapImpl` so that we can write unit tests that don't depend on the `FileManager`, and then write a few tests that cover the types of corrupt header maps already detected. This also moves type and constant definitions from HeaderMap.cpp to HeaderMapTypes.h so that the test can access them. llvm-svn: 261446
* [modules] Do less scanning of macro definition chains when computing the set ofRichard Smith2016-02-191-5/+20
| | | | | | | exported module macros outside local submodule visibility mode. Related to PR24667. llvm-svn: 261373
* [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a singleRichard Smith2016-02-194-41/+32
| | | | | | | | | | | | option. Previously these options could both be used to specify that you were compiling the implementation file of a module, with a different set of minor bugs in each case. This change removes -fmodule-implementation-of, and instead tracks a flag to determine whether we're currently building a module. -fmodule-name now behaves the same way that -fmodule-implementation-of previously did. llvm-svn: 261372
OpenPOWER on IntegriCloud