summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR18793: If we try to EnterTokenStream when our current lexer is a cachingRichard Smith2014-09-231-0/+19
| | | | | | | | | lexer, add the token buffer underneath the caching lexer where possible and push the tokens directly into the caching lexer otherwise. We previously put the lexer into a corrupted state where we could not guarantee to provide the tokens in the right order and would sometimes assert. llvm-svn: 218333
* unique_ptrify Preprocessor's TokenLexerCacheDavid Blaikie2014-08-291-11/+11
| | | | llvm-svn: 216756
* Removed unused typedef for recursive_directory_iteratorBen Langmuir2014-06-301-2/+0
| | | | llvm-svn: 212047
* Make -Wincomplete-umbrella go through the VFSBen Langmuir2014-06-251-3/+5
| | | | | | | By using vfs::recursive_directory_iterator, this warning will now fire when some or all of a module's headers are from VFS mappings. llvm-svn: 211746
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-6/+4
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210780
* [C++11] Use 'nullptr'. Lex edition.Craig Topper2014-05-171-9/+9
| | | | llvm-svn: 209083
* [Preprocessor/CodeComplete] Don't add include guard macros to ↵Argyrios Kyrtzidis2014-04-091-0/+4
| | | | | | code-completion results. llvm-svn: 205917
* [Preprocessor] Only check for -Wunused-macros if the translation unit kind ↵Argyrios Kyrtzidis2014-03-081-1/+1
| | | | | | is TU_Complete. llvm-svn: 203360
* Change OwningPtr::take() to OwningPtr::release().Ahmed Charles2014-03-071-2/+2
| | | | | | This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
* [Preprocessor] Pass TranslationUnitKind to the preprocessor and if it is ↵Argyrios Kyrtzidis2014-03-071-5/+9
| | | | | | | | | | TU_Prefix avoid warning for unused macros. rdar://15034698 llvm-svn: 203213
* Track the currently-being-built submodule inside the preprocessor (rather thanRichard Smith2014-01-311-18/+14
| | | | | | | just storing a flag indicating if there was one), and include it in the 'end of module' annotation. No functionality change. llvm-svn: 200573
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-231-24/+50
| | | | | | | | | module. Use the marker to diagnose cases where we try to transition between submodules when not at the top level (most likely because a closing brace was missing at the end of a header file, but is also possible if submodule headers attempt to do something fundamentally non-modular, like our .def files). llvm-svn: 195543
* Relax header guard mismatch warning with edit distance heuristic.Ismail Pazarbasi2013-10-121-13/+26
| | | | | | If the edit distance between the two macros is more than 50%, DefinedMacro may not be header guard or can be header guard of another header file or it might be defining something completely different set by the build environment. llvm-svn: 192547
* Make Preprocessor::Lex non-recursive.Eli Friedman2013-09-191-0/+16
| | | | | | | | | | | | | | | Before this patch, Lex() would recurse whenever the current lexer changed (e.g. upon entry into a macro). This patch turns the recursion into a loop: the various lex routines now don't return a token when the current lexer changes, and at the top level Preprocessor::Lex() now loops until it finds a token. Normally, the recursion wouldn't end up being very deep, but the recursion depth can explode in edge cases like a bunch of consecutive macros which expand to nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this patch). <rdar://problem/14569770> llvm-svn: 190980
* Introducing -Wheader-guard, a warning that checks header guards actually workRichard Trieu2013-06-121-1/+22
| | | | | | | | properly. This warning checks that the #ifndef and #define directives at the beginning of a header refer to the same macro name. Includes a fix-it hint to correct the header guard. llvm-svn: 183867
* Include Path.h instead of PathV2.h.Rafael Espindola2013-06-111-1/+1
| | | | | | I am about to move PathV2.h to Path.h. llvm-svn: 183795
* Add -Wincomplete-module, which detects when a header is included from a ↵Douglas Gregor2013-05-201-1/+29
| | | | | | module but isn't itself part of a module. llvm-svn: 182263
* Use only explicit bool conversion operatorDavid Blaikie2013-05-151-1/+1
| | | | | | | | | | | | | | | | | | | The most common (non-buggy) case are where such objects are used as return expressions in bool-returning functions or as boolean function arguments. In those cases I've used (& added if necessary) a named function to provide the equivalent (or sometimes negative, depending on convenient wording) test. DiagnosticBuilder kept its implicit conversion operator owing to the prevalent use of it in return statements. One bug was found in ExprConstant.cpp involving a comparison of two PointerUnions (PointerUnion did not previously have an operator==, so instead both operands were converted to bool & then compared). A test is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix (adding operator== to PointerUnion in LLVM). llvm-svn: 181869
* Add the module name to the 'incomplete umbrella header' warning.Douglas Gregor2013-01-041-1/+1
| | | | llvm-svn: 171497
* [libclang] Fix crash when code-completing a macro invocation thatArgyrios Kyrtzidis2012-12-221-14/+29
| | | | | | reached EOF and did not expand the argument into the source context. llvm-svn: 170980
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+4
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Make preprocessor act in a GCC-compatible fashion when a macro is redefinedRichard Smith2012-08-301-3/+3
| | | | | | | | 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
* Documentation cleanup: escape # characters in Doxygen comments as needed.James Dennett2012-06-221-1/+1
| | | | llvm-svn: 158970
* From Vassil Vassilev:Axel Naumann2012-03-161-4/+6
| | | | | | | | | | | | | | Enable incremental parsing by the Preprocessor, where more code can be provided after an EOF. It mainly prevents the tearing down of the topmost lexer. To be used like this: PP.enableIncrementalProcessing(); while (getMoreSource()) { while (Parser.ParseTopLevelDecl(ADecl)) {...} } PP.enableIncrementalProcessing(false); llvm-svn: 152914
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-2/+2
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Implement support for module requirements, which indicate the languageDouglas Gregor2011-12-311-8/+11
| | | | | | | | | features needed for a particular module to be available. This allows mixed-language modules, where certain headers only work under some language variants (e.g., in C++, std.tuple might only be available in C++11 mode). llvm-svn: 147387
* Remove spurious, but now legal, typenameDouglas Gregor2011-12-231-1/+1
| | | | llvm-svn: 147208
* When building a module with an umbrella header, warn about any headersDouglas Gregor2011-12-231-0/+67
| | | | | | | | found within that umbrella directory that were not actually included by the umbrella header. They should either be referenced in the module map or included by the umbrella header. llvm-svn: 147207
* Don't mark include guard macros as implicitly private. This isn'tDouglas Gregor2011-12-121-21/+1
| | | | | | | actually a terribly good heuristic, and the world is too horrible for it to work. llvm-svn: 146393
* Argyrios says this change is required for safety under PTH.John McCall2011-10-181-1/+1
| | | | | | Me, I believe him. llvm-svn: 142327
* Fix several bugs with #pragma clang arc_cf_code_audited and macros.John McCall2011-10-181-2/+5
| | | | llvm-svn: 142324
* For modules, all macros that aren't include guards are implicitlyDouglas Gregor2011-10-171-1/+22
| | | | | | | public. Add a __private_macro__ directive to hide a macro, similar to the __module_private__ declaration specifier. llvm-svn: 142188
* For the FileChanged Preprocessor callback, when exiting a file, pass its FileID.Argyrios Kyrtzidis2011-10-111-1/+5
| | | | llvm-svn: 141681
* Add explicit attributes to mark functions as having had theirJohn McCall2011-09-301-0/+8
| | | | | | | | | | | CoreFoundation object-transfer properties audited, and add a #pragma to cause them to be automatically applied to functions in a particular span of code. This has to be implemented largely in the preprocessor because of the requirement that the region be entirely contained in a single file; that's hard to impose from the parser without registering for a ton of callbacks. llvm-svn: 140846
* Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.Argyrios Kyrtzidis2011-09-191-1/+1
| | | | | | It already works (and is useful with) macro locs as well. llvm-svn: 140057
* Optimize the preprocessor's handling of the __import_module__Douglas Gregor2011-09-071-2/+10
| | | | | | | | | | | | keyword. We now handle this keyword in HandleIdentifier, making a note for ourselves when we've seen the __import_module__ keyword so that the next lexed token can trigger a module import (if needed). This greatly simplifies Preprocessor::Lex(), and completely erases the 5.5% -Eonly slowdown Argiris noted when I originally implemented __import_module__. Big thanks to Argiris for noting that horrible regression! llvm-svn: 139265
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-1/+27
| | | | | | | | | | | | | | Previously we would cut off the source file buffer at the code-completion point; this impeded code-completion inside C++ inline methods and, recently, with buffering ObjC methods. Have the code-completion inserted into the source buffer so that it can be buffered along with a method body. When we actually hit the code-completion point the cut-off lexing or parsing. Fixes rdar://10056932&8319466 llvm-svn: 139086
* Boost the efficiency of SourceManager::getMacroArgExpandedLocation.Argyrios Kyrtzidis2011-08-211-0/+10
| | | | | | | | | | | | | | | | | | Currently getMacroArgExpandedLocation is very inefficient and for the case of a location pointing at the main file it will end up checking almost all of the SLocEntries. Make it faster: -Use a map of macro argument chunks to their expanded source location. The map is for a single source file, it's stored in the file's ContentCache and lazily computed, like the source lines cache. -In SLocEntry's FileInfo add an 'unsigned NumCreatedFIDs' field that keeps track of the number of FileIDs (files and macros) that were created during preprocessing of that particular file SLocEntry. This is useful when computing the macro argument map in skipping included files while scanning for macro arg FileIDs that lexed from a specific source file. Due to padding, the new field does not increase the size of SLocEntry. llvm-svn: 138225
* Introduce a caching mechanism for macro expanded tokens.Argyrios Kyrtzidis2011-06-291-0/+4
| | | | | | | | | | | | | | | Previously macro expanded tokens were added to Preprocessor's bump allocator and never released, even after the TokenLexer that were lexing them was finished, thus they were wasting memory. A very "useful" boost library was causing clang to eat 1 GB just for the expanded macro tokens. Introduce a special cache that works like a stack; a TokenLexer can add the macro expanded tokens in the cache, and when it finishes, the tokens are removed from the end of the cache. Now consumed memory by expanded tokens for that library is ~ 1.5 MB. Part of rdar://9327049. llvm-svn: 134105
* Rename tok::eom to tok::eod.Peter Collingbourne2011-02-281-10/+10
| | | | | | | | The previous name was inaccurate as this token in fact appears at the end of every preprocessing directive, not just macro definitions. No functionality change, except for a diagnostic tweak. llvm-svn: 126631
* Fix diagnostic pragmas.Argyrios Kyrtzidis2010-12-151-9/+5
| | | | | | | | | | | | Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state. Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect a lot of places, like C++ inline methods, template instantiations, the lexer, etc. Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location. Fixes rdar://8365684. llvm-svn: 121873
* push some source location information down through the compiler,Chris Lattner2010-04-201-8/+12
| | | | | | | | into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
* PPCallbacks: Add hook for reaching the end of the main file, and fix ↵Daniel Dunbar2010-03-231-0/+1
| | | | | | DependencyFile to not do work in its destructor. llvm-svn: 99257
* Audit all getBuffer() callers (for both the FullSourceLoc andDouglas Gregor2010-03-161-2/+4
| | | | | | | SourceManager versions), updating those callers that need to recover gracefully from failure. llvm-svn: 98665
* Use SourceManager's Diagnostic object for all file-reading errors,Douglas Gregor2010-03-161-2/+1
| | | | | | simplifying the SourceManager interfaces somewhat. llvm-svn: 98598
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-3/+3
| | | | | | | | | | | | | | SourceManager's getBuffer() (and similar) operations. This abstract can be used to force callers to cope with errors in getBuffer(), such as missing files and changed files. Fix a bunch of callers to use the new interface. Add some very basic checks for file consistency (file size, modification time) into ContentCache::getBuffer(), although these checks don't help much until we've updated the main callers (e.g., SourceManager::getSpelling()). llvm-svn: 98585
* Teach Preprocessor::macro_begin/macro_end to lazily load all macroDouglas Gregor2010-01-041-1/+2
| | | | | | | | definitions from a precompiled header. This ensures that code-completion with macro names behaves the same with or without precompiled headers. llvm-svn: 92497
* Unbreak and add test case for r90276, a situation in which getBuffer is ↵Daniel Dunbar2009-12-061-1/+1
| | | | | | | | expected to fail. Also, update SourceManager.h doxyments for getBuffer() to reflect reality. llvm-svn: 90701
* Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients ↵Daniel Dunbar2009-12-061-2/+2
| | | | | | should be forced to deal with error conditions. llvm-svn: 90700
OpenPOWER on IntegriCloud