summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
...
* Move HeaderSearchOptions into the Lex library, make it intrusivelyDouglas Gregor2012-10-241-2/+4
| | | | | | reference-counted, and hold a reference to it in HeaderSearch. llvm-svn: 166583
* Removed an extra blank line.Mahesha S2012-10-241-1/+0
| | | | llvm-svn: 166571
* Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor2012-10-231-1/+2
| | | | | | | the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
* Fix for PR13334. This prevents crashes that result from badly formedRichard Trieu2012-10-221-12/+27
| | | | | | expressions involving __has_include llvm-svn: 166438
* Teach TargetInfo to hold on to the TargetOptions with which it wasDouglas Gregor2012-10-151-11/+9
| | | | | | created. llvm-svn: 165943
* Introduce the notion of excluded headers into the module mapDouglas Gregor2012-10-151-30/+46
| | | | | | | | description. Previously, one could emulate this behavior by placing the header in an always-unavailable submodule, but Argyrios guilted me into expressing this idea properly. llvm-svn: 165921
* Sanitize the names of modules determined based on the names of headersDouglas Gregor2012-10-121-6/+67
| | | | | | | or directories, to make sure that they are identifiers that are not keywords in any dialect. Fixes <rdar://problem/12489495>. llvm-svn: 165821
* Track which particular submodule #undef's a macro, so that the actualDouglas Gregor2012-10-121-6/+12
| | | | | | #undef only occurs if that submodule is imported. llvm-svn: 165773
* Diagnose the expansion of ambiguous macro definitions. This can happenDouglas Gregor2012-10-112-7/+35
| | | | | | | only with modules, when two disjoint modules #define the same identifier to different token sequences. llvm-svn: 165746
* Introduce a simple "hint" scheme to eliminate the quadratic behaviorDouglas Gregor2012-10-111-3/+3
| | | | | | associated with deserializing macro history for an identifier. llvm-svn: 165729
* Remove an unused bit from the serialized IdentifierInfoDouglas Gregor2012-10-111-1/+1
| | | | llvm-svn: 165683
* Deserialize macro history when we deserialize an identifier that hasDouglas Gregor2012-10-112-14/+93
| | | | | | | | | | | | | | | | | | | | | | | | macro history. When deserializing macro history, we arrange history such that the macros that have definitions (that haven't been #undef'd) and are visible come at the beginning of the list, which is what the preprocessor and other clients of Preprocessor::getMacroInfo() expect. If additional macro definitions become visible later, they'll be moved toward the front of the list. Note that it's possible to have ambiguities, but we don't diagnose them yet. There is a partially-implemented design decision here that, if a particular identifier has been defined or #undef'd within the translation unit, that definition (or #undef) hides any macro definitions that come from imported modules. There's still a little work to do to ensure that the right #undef'ing happens. Additionally, we'll need to scope the update records for #undefs, so they only kick in when the submodule containing that update record becomes visible. llvm-svn: 165682
* Rework the (de-)serialization of macros, as stored inDouglas Gregor2012-10-093-5/+19
| | | | | | | | | | | | | | | | MacroInfo*. Instead of simply dumping an offset into the current file, give each macro definition a proper ID with all of the standard modules-remapping facilities. Additionally, when a macro is modified in a subsequent AST file (e.g., #undef'ing a macro loaded from another module or from a precompiled header), provide a macro update record rather than rewriting the entire macro definition. This gives us greater consistency with the way we handle declarations, and ties together macro definitions much more cleanly. Note that we're still not actually deserializing macro history (we never were), but it's far easy to do properly now. llvm-svn: 165560
* [Modules] Introduce Module::TopHeaders which is a set of top-level headersArgyrios Kyrtzidis2012-10-051-0/+1
| | | | | | that are associated with a (sub)module. llvm-svn: 165279
* [preprocessing record] Have PPEntityID be independent of the size of theArgyrios Kyrtzidis2012-10-051-14/+18
| | | | | | | loaded entities vector, otherwise its meaning will change when a module is imported and the vector size changes. llvm-svn: 165278
* Add info in the preprocessing record whether an inclusion directiveArgyrios Kyrtzidis2012-10-021-3/+5
| | | | | | resulted in an automatic module import. llvm-svn: 165022
* Move the 'find macro by spelling' infrastructure to the Preprocessor class andDmitri Gribenko2012-09-291-0/+33
| | | | | | | use it to suggest appropriate macro for __attribute__((deprecated)) in -Wdocumentation-deprecated-sync. llvm-svn: 164892
* For PPCallbacks::InclusionDirective() add a parameter for the module, wheneverArgyrios Kyrtzidis2012-09-293-10/+36
| | | | | | | an inclusion directive was automatically turned into a module import, and PPCallbacks::moduleImport() for an explicit module import. llvm-svn: 164874
* Add an assertion to make sure the implicitly imported moduleArgyrios Kyrtzidis2012-09-291-0/+2
| | | | | | is the same as the suggested one when looking up the include filename. llvm-svn: 164872
* Compatibility macro detection for the -Wimplicit-fallthrough diagnostic.Alexander Kornienko2012-09-281-0/+12
| | | | | | | | | | | | | | | | | | | Summary: When issuing a diagnostic message for the -Wimplicit-fallthrough diagnostics, always try to find the latest macro, defined at the point of fallthrough, which is immediately expanded to "[[clang::fallthrough]]", and use it's name instead of the actual sequence. Known issues: * uses PP.getSpelling() to compare macro definition with a string (anyone can suggest a convenient way to fill a token array, or maybe lex it in runtime?); * this can be generalized and used in other similar cases, any ideas where it should reside then? Reviewers: doug.gregor, rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D50 llvm-svn: 164858
* Following up on r164620, cope with symlinking from an embeddedDouglas Gregor2012-09-271-1/+30
| | | | | | | framework location out to a top-level framework. Such frameworks are not really embedded at all. llvm-svn: 164774
* Per discussion in ↵Argyrios Kyrtzidis2012-09-272-7/+14
| | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120917/064551.html have PPCallbacks::InclusionDirective pass the character range for the filename quotes or brackets. rdar://11113134 & http://llvm.org/PR13880 llvm-svn: 164743
* Revert r163022, it caused PR13924.Nico Weber2012-09-262-11/+1
| | | | | | | Add a test for PR13924. Do not revert the test added in r163022, it surprisingly still passes even after reverting the code changes. llvm-svn: 164672
* Rename CanFitInto64Bits to alwaysFitsInto64Bits per discussion on IRC.Jordan Rose2012-09-251-2/+2
| | | | | | | | | | | | | This makes the behavior clearer concerning literals with the maximum number of digits. For a 32-bit example, 4,000,000,000 is a valid uint32_t, but 5,000,000,000 is not, so we'd have to count 10-digit decimal numbers as "unsafe" (meaning we have to check for overflow when parsing them, just as we would for numbers with 11 digits or higher). This is the same, only with 64 bits to play with. No functionality change. llvm-svn: 164639
* Optimize NumericLiteralParser::GetIntegerValue().Dmitri Gribenko2012-09-251-9/+21
| | | | | | | It does a conservative estimate on the size of numbers that can fit into uint64_t. This bound is improved. llvm-svn: 164624
* Under certain terrible circumstances (<rdar://problem/10805775>),Douglas Gregor2012-09-251-0/+13
| | | | | | | | | top-level frameworks can actually be symlinked over to embedded frameworks, and accessed via the top-level framework's headers. In this case, we need to determine that the framework was *actually* an embedded framework, so we can load the appropriate top-level module. llvm-svn: 164620
* Macro history (de-)serialization. Deserialization currently reads only the ↵Alexander Kornienko2012-09-251-4/+5
| | | | | | | | | | | | | | | | latest macro definition. Needs more work. Summary: Passes all tests (+ the new one with code completion), but needs a thorough review in part related to modules. Reviewers: doug.gregor Reviewed By: alexfh CC: cfe-commits, rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D41 llvm-svn: 164610
* Introduce builtin macros to determine whether we're building aDouglas Gregor2012-09-251-0/+67
| | | | | | | | | | specific module (__building_module(modulename)) and to get the name of the current module as an identifier (__MODULE__). Used to help headers behave differently when they're being included as part of building a module. Oh, the irony. llvm-svn: 164605
* StringRef'ize Preprocessor::CreateString().Dmitri Gribenko2012-09-246-15/+12
| | | | llvm-svn: 164555
* Replace raw call to snprintf() by llvm streams.Dmitri Gribenko2012-09-241-21/+24
| | | | llvm-svn: 164554
* Change the wording of the extension warning fromDmitri Gribenko2012-09-241-4/+9
| | | | | | | | | > 'long long' is an extension when C99 mode is not enabled to > 'long long' is a C++11 extension while compiling in C++98 mode. llvm-svn: 164545
* Small cleanup of literal semantic analysis: hiding 'char *' pointers behindDmitri Gribenko2012-09-242-13/+12
| | | | | | | StringRef makes code cleaner. Also, make the temporary buffer smaller: 512 characters is unreasonably large for integer literals. llvm-svn: 164484
* The keywords "true" and "false" shouldn't warn under -Wundef.Eli Friedman2012-09-201-1/+3
| | | | llvm-svn: 164279
* Remove an unused private field exposed by the recent LLVM_DELETED_FUNCTION ↵Craig Topper2012-09-181-1/+1
| | | | | | changes. llvm-svn: 164103
* Fix dead store found by static analyzer.Ted Kremenek2012-09-161-5/+2
| | | | llvm-svn: 163994
* [libclang] Fix getting a cursor inside an angled #include directive.Argyrios Kyrtzidis2012-09-111-0/+3
| | | | | | | | | Fixed by pointing the end location of the preprocessed entity for the #include at the closing '>', instead of the start of '<'. rdar://11113134 llvm-svn: 163588
* When a bad UTF-8 encoding or bogus escape sequence is encountered in aRichard Smith2012-09-081-60/+101
| | | | | | | string literal, produce a diagnostic pointing at the erroneous character range, not at the start of the literal. llvm-svn: 163459
* Dont cast away const needlessly. Found by gcc48 -Wcast-qual.Roman Divacky2012-09-063-4/+5
| | | | llvm-svn: 163325
* Normalize line endings of r163022.Joao Matos2012-08-311-1177/+1177
| | | | llvm-svn: 163023
* Emulate MSVC's preprocessor macro argument separator behavior by not ↵Joao Matos2012-08-312-1173/+1183
| | | | | | considering commas from nested macro expansions as argument separators. Fixes parsing of VS 2012 headers. llvm-svn: 163022
* Make a bunch of methods on Lexer private.Eli Friedman2012-08-311-1/+1
| | | | llvm-svn: 162970
* Extend the "__is_pod" hack, which demotes various type trait keywordsDouglas Gregor2012-08-301-12/+2
| | | | | | | | | (__is_pod, __is_signed, etc.) to normal identifiers if they are encountered in certain places in the grammar where we know that prior versions of libstdc++ or libc++ use them, to still allow the use of these keywords as type traits. Fixes <rdar://problem/9836262> and PR10184. llvm-svn: 162937
* Make preprocessor act in a GCC-compatible fashion when a macro is redefinedRichard Smith2012-08-303-6/+7
| | | | | | | | within its own argument list. The original definition is used for the immediate expansion, but the new definition is used for any subsequent occurences within the argument list or after the expansion. llvm-svn: 162906
* Fixed a problem with #pragma push_macro/pop_macro implementation.Alexander Kornienko2012-08-293-6/+17
| | | | | | | | | | | | | | | | | | | | Summary: The problem was with the following sequence: #pragma push_macro("long") #undef long #pragma pop_macro("long") in case when "long" didn't represent a macro. Fixed crash and removed code duplication for #undef/pop_macro case. Added regression tests. Reviewers: doug.gregor, klimek Reviewed By: doug.gregor CC: cfe-commits, chapuni Differential Revision: http://llvm-reviews.chandlerc.com/D31 llvm-svn: 162845
* Keep history of macro definitions and #undefsAlexander Kornienko2012-08-294-59/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros> I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux. Stats before this patch: *** Preprocessor Stats: 73222 directives found: 19171 #define. 4345 #undef. #include/#include_next/#import: 5233 source files entered. 27 max include stack depth 19210 #if/#ifndef/#ifdef. 2384 #else/#elif. 6891 #endif. 408 #pragma. 14466 #if/#ifndef#ifdef regions skipped 80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path. 127145 token paste (##) operations performed, 11008 on the fast path. Preprocessor Memory: 5874615B total BumpPtr: 4399104 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 Stats with this patch: ... Preprocessor Memory: 7541687B total BumpPtr: 6066176 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation. As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time. Reviewers: doug.gregor, klimek, rsmith, djasper Reviewed By: doug.gregor CC: cfe-commits, chandlerc Differential Revision: http://llvm-reviews.chandlerc.com/D28 llvm-svn: 162810
* Use LLVM_BUILTIN_TRAP instead of lame volatile int traps.David Blaikie2012-08-211-1/+1
| | | | | | (from a todo mentioned in r159469 & originally suggested by Chandler Carruth) llvm-svn: 162302
* Screw around with ObjCRuntime some more, changing theJohn McCall2012-08-211-2/+1
| | | | | | | | diagnostics for bad deployment targets and adding a few more predicates. Includes a patch by Jonathan Schleifer to enable ARC for ObjFW. llvm-svn: 162252
* Switch PTH format from a 7 byte magic number to an 8 byte one, to avoidRichard Smith2012-08-171-3/+3
| | | | | | misaligned reads throughout the file. Bump PTH format version to 10. llvm-svn: 162076
* c: small refactoring of checking for __attribute__(const))Fariborz Jahanian2012-08-131-8/+1
| | | | | | per Richard's comment. llvm-svn: 161786
* c: make __has_attribute(const) work for constFariborz Jahanian2012-08-131-0/+7
| | | | | | function attribute. // rdar://10253857 llvm-svn: 161767
OpenPOWER on IntegriCloud