summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-1/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Remove Diagnostic.h include from Preprocessor.h.Benjamin Kramer2012-02-041-0/+15
| | | | | | | - Move the offending methods out of line and fix transitive includers. - This required changing an enum in the PPCallback API into an unsigned. llvm-svn: 149782
* Thread a TargetInfo through to the module map; we'll need it forDouglas Gregor2012-01-301-1/+3
| | | | | | target-specific module requirements. llvm-svn: 149224
* Rework HeaderSearch's interface for getting a module from a name andDouglas Gregor2012-01-291-1/+1
| | | | | | | | | for getting the name of the module file, unifying the code for searching for a module with a given name (into lookupModule()) and separating out the mapping to a module file (into getModuleFileName()). No functionality change. llvm-svn: 149197
* When loading an AST file, set SourceManager::MainFileID to the main file of ↵Argyrios Kyrtzidis2012-01-051-12/+16
| | | | | | | | the AST file, as suggested by Tom Honermann. llvm-svn: 147612
* Don't treat 'import' as a contextual keyword when we're in a caching lexer, ↵Douglas Gregor2012-01-041-9/+18
| | | | | | or when modules are disabled. llvm-svn: 147524
* Eliminate the uglified keyword __import_module__ for importingDouglas Gregor2012-01-031-12/+6
| | | | | | | | | | | | | modules. This leaves us without an explicit syntax for importing modules in C/C++, because such a syntax needs to be discussed first. In Objective-C/Objective-C++, the @import syntax is used to import modules. Note that, under -fmodules, C/C++ programs can import modules via the #include mechanism when a module map is in place for that header. This allows us to work with modules in C/C++ without committing to a syntax. llvm-svn: 147467
* Introduce a non-uglified syntax for module imports in Objective-C:Douglas Gregor2012-01-031-5/+11
| | | | | | @import identifier [. identifier]* ; llvm-svn: 147452
* Add a "Modules" language option, which subsumes the previousDouglas Gregor2012-01-031-1/+0
| | | | | | "AutoModuleImport" preprocessor option and is tied to -fmodules. llvm-svn: 147448
* Added -Wdisabled-macro-expansion warning.Abramo Bagnara2012-01-011-2/+5
| | | | llvm-svn: 147418
* When we treat an #include or #import as a module import, create anDouglas Gregor2011-12-021-1/+2
| | | | | | | implicit ImportDecl in the translation unit to record the presence of the import. llvm-svn: 145727
* Implementing parsing and resolution of module export declarationsDouglas Gregor2011-12-021-1/+6
| | | | | | | | within module maps, which will (eventually) be used to re-export a module from another module. There are still some pieces missing, however. llvm-svn: 145665
* Introduce the notion of name visibility into modules. For a givenDouglas Gregor2011-12-011-1/+2
| | | | | | | | | | | | | | (sub)module, all of the names may be hidden, just the macro names may be exposed (for example, after the preprocessor has seen the import of the module but the parser has not), or all of the names may be exposed. Importing a module makes its names, and the names in any of its non-explicit submodules, visible to name lookup (transitively). This commit only introduces the notion of name visible and marks modules and submodules as visible when they are imported. The actual name-hiding logic in the AST reader will follow (along with test cases). llvm-svn: 145586
* Teach the preprocessor how to handle module import declarations thatDouglas Gregor2011-11-301-9/+23
| | | | | | | involve submodules (e.g., importing std.vector), rather than always importing the top-level module. llvm-svn: 145478
* Switch the module-loading interfaces and parser from a simpleDouglas Gregor2011-11-301-3/+5
| | | | | | | top-level module name to a module path (e.g., std.vector). We're still missing a number of pieces for this actually to do something. llvm-svn: 145462
* Remove an assertion that is not valid if we cancel parsing.Argyrios Kyrtzidis2011-11-231-3/+0
| | | | llvm-svn: 145108
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AST file more lazy, so that we don't eagerly load that information for all known identifiers each time a new AST file is loaded. The eager reloading made some sense in the context of precompiled headers, since very few identifiers were defined before PCH load time. With modules, however, a huge amount of code can get parsed before we see an @import, so laziness becomes important here. The approach taken to make this information lazy is fairly simple: when we load a new AST file, we mark all of the existing identifiers as being out-of-date. Whenever we want to access information that may come from an AST (e.g., whether the identifier has a macro definition, or what top-level declarations have that name), we check the out-of-date bit and, if it's set, ask the AST reader to update the IdentifierInfo from the AST files. The update is a merge, and we now take care to merge declarations before/after imports with declarations from multiple imports. The results of this optimization are fairly dramatic. On a small application that brings in 14 non-trivial modules, this takes modules from being > 3x slower than a "perfect" PCH file down to 30% slower for a full rebuild. A partial rebuild (where the PCH file or modules can be re-used) is down to 7% slower. Making the PCH file just a little imperfect (e.g., adding two smallish modules used by a bunch of .m files that aren't in the PCH file) tips the scales in favor of the modules approach, with 24% faster partial rebuilds. This is just a first step; the lazy scheme could possibly be improved by adding versioning, so we don't search into modules we already searched. Moreover, we'll need similar lazy schemes for all of the other lookup data structures, such as DeclContexts. llvm-svn: 143100
* Add a -Wc++0x-compat warning for C++11 keywords used as identifiers when inRichard Smith2011-10-111-0/+11
| | | | | | C++98 mode. Only the first occurrence of each keyword will produce a warning. llvm-svn: 141700
* Fixed exapnsion range for # and ##.Abramo Bagnara2011-10-031-3/+5
| | | | llvm-svn: 141012
* Properly initialize Preprocessor::CurLexerKind to avoid use of uninitialized ↵Zhongxing Xu2011-09-261-2/+2
| | | | | | variable. llvm-svn: 140514
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-1/+1
| | | | llvm-svn: 140478
* Introduce PreprocessingRecord::getPreprocessedEntitiesInRange()Argyrios Kyrtzidis2011-09-191-1/+2
| | | | | | | | | | which will do a binary search and return a pair of iterators for preprocessed entities in the given source range. Source ranges of preprocessed entities are stored twice currently in the PCH/Module file but this will be fixed in a subsequent commit. llvm-svn: 140058
* Add an experimental flag -fauto-module-import that automatically turnsDouglas Gregor2011-09-151-0/+1
| | | | | | | #include or #import direcctives of framework headers into module imports of the corresponding framework module. llvm-svn: 139860
* Optimize the preprocessor's handling of the __import_module__Douglas Gregor2011-09-071-15/+30
| | | | | | | | | | | | 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
* Use const_cast to avoid warnings.Benjamin Kramer2011-09-041-1/+1
| | | | llvm-svn: 139104
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-26/+25
| | | | | | | | | | | | | | 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
* Allow the preprocessor to be constructed without performing target-Douglas Gregor2011-09-011-53/+69
| | | | | | | | and language-specific initialization. Use this to allow ASTUnit to create a preprocessor object *before* loading the AST file. No actual functionality change. llvm-svn: 138983
* Teach ASTContext and Preprocessor to hold on to references to the sameDouglas Gregor2011-09-011-1/+1
| | | | | | | | | LangOptions, rather than making distinct copies of LangOptions. Granted, LangOptions doesn't actually get modified, but this will eventually make it easier to construct ASTContext and Preprocessor before we know all of the LangOptions. llvm-svn: 138959
* Make sure to initialize field. Hopefully this will fix some test failures ↵Eli Friedman2011-08-311-0/+1
| | | | | | on Windows. llvm-svn: 138880
* Switch __import__ over to __import_module__, so we don't conflict withDouglas Gregor2011-08-311-5/+5
| | | | | | | | existing practice with Python extension modules. Not that Python extension modules should be using a double-underscored identifier anyway, but... llvm-svn: 138870
* Take an entirely different approach to handling the "parsing" ofDouglas Gregor2011-08-271-7/+3
| | | | | | | | | __import__ within the preprocessor, since the prior one foolishly assumed that Preprocessor::Lex() was re-entrant. We now handle __import__ at the top level (only), after macro expansion. This should fix the buildbot failures. llvm-svn: 138704
* Introduce support for a simple module import declaration, whichDouglas Gregor2011-08-261-4/+34
| | | | | | | | | | | | | | | | | | | | | | loads the named module. The syntax itself is intentionally hideous and will be replaced at some later point with something more palatable. For now, we're focusing on the semantics: - Module imports are handled first by the preprocessor (to get macro definitions) and then the same tokens are also handled by the parser (to get declarations). If both happen (as in normal compilation), the second one is redundant, because we currently have no way to hide macros or declarations when loading a module. Chris gets credit for this mad-but-workable scheme. - The Preprocessor now holds on to a reference to a module loader, which is responsible for loading named modules. CompilerInstance is the only important module loader: it now knows how to create and wire up an AST reader on demand to actually perform the module load. - We search for modules in the include path, using the module name with the suffix ".pcm" (precompiled module) for the file name. This is a temporary hack; we hope to improve the situation in the future. llvm-svn: 138679
* Change Preprocessor::getTotalMemory() to use llvm::capacity_in_bytes().Ted Kremenek2011-07-271-5/+6
| | | | llvm-svn: 136239
* Report more memory using in Preprocessor::getTotalMemory() and ↵Ted Kremenek2011-07-261-1/+7
| | | | | | | | | | PreprocessingRecord::getTotalMemory(). Most of the memory was already reported; but now we report more memory from side data structures. Fixes <rdar://problem/9379717>. llvm-svn: 136150
* Rename create(MacroArg)InstantiationLoc to create(MacroArg)ExpansionLoc.Chandler Carruth2011-07-261-2/+1
| | | | llvm-svn: 136054
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-8/+8
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Move the rest of the preprocessor terminology from 'instantiate' andChandler Carruth2011-07-141-6/+6
| | | | | | | | | | | | | variants to 'expand'. This changed a couple of public APIs, including one public type "MacroInstantiation" which is now "MacroExpansion". The rest of the codebase was updated to reflect this, especially the libclang code. Two of the C++ (and thus easily changed) libclang APIs were updated as well because they pertained directly to the old MacroInstantiation class. No functionality changed. llvm-svn: 135139
* Introduce a caching mechanism for macro expanded tokens.Argyrios Kyrtzidis2011-06-291-1/+3
| | | | | | | | | | | | | | | 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
* Introduce Preprocessor::getTotalMemory() and use it in CIndex.cpp, no ↵Argyrios Kyrtzidis2011-06-291-0/+4
| | | | | | functionality change. llvm-svn: 134103
* Introduce a new libclang parsing flag,Douglas Gregor2011-05-061-2/+3
| | | | | | | | | | | | | CXTranslationUnit_NestedMacroInstantiations, which indicates whether we want to see "nested" macro instantiations (e.g., those that occur inside other macro instantiations) within the detailed preprocessing record. Many clients (e.g., those that only care about visible tokens) don't care about this information, and in code that uses preprocessor metaprogramming, this information can have a very high cost. Addresses <rdar://problem/9389320>. llvm-svn: 130990
* Parsing/AST support for Structured Exception HandlingJohn Wiegley2011-04-281-4/+47
| | | | | | | | Patch authored by Sohail Somani. Provide parsing and AST support for Windows structured exception handling. llvm-svn: 130366
* Fix my earlier commit to work with escaped newlines and leave breadcrumbsJohn McCall2011-03-081-11/+0
| | | | | | | in case we want to make a world where we can check intermediate instantiations for this kind of breadcrumb. llvm-svn: 127221
* Add an API call to retrieve the spelling data of a token from its ↵John McCall2011-03-081-0/+10
| | | | | | SourceLocation. llvm-svn: 127216
* Introduced raw_identifier token kind.Abramo Bagnara2010-12-221-13/+22
| | | | llvm-svn: 122394
* now the FileManager has a FileSystemOpts ivar, stop threadingChris Lattner2010-11-231-1/+1
| | | | | | | | | FileSystemOpts through a ton of apis, simplifying a lot of code. This also fixes a latent bug in ASTUnit where it would invoke methods on FileManager without creating one in some code paths in cindextext. llvm-svn: 120010
* move getSpelling from Preprocessor to Lexer, which it is more conceptually ↵Chris Lattner2010-11-171-110/+0
| | | | | | related to. llvm-svn: 119479
* move AdvanceToTokenCharacter and getLocForEndOfToken fromChris Lattner2010-11-171-62/+0
| | | | | | Preprocessor to Lexer where they make more sense. llvm-svn: 119474
* add a static version of PP::AdvanceToTokenCharacter.Chris Lattner2010-11-171-5/+8
| | | | llvm-svn: 119472
* add a static form of the efficient PP::getSpelling method.Chris Lattner2010-11-171-2/+4
| | | | llvm-svn: 119469
* Implement -working-directory.Argyrios Kyrtzidis2010-11-031-1/+2
| | | | | | | | | | | | | | | | | | | When -working-directory is passed in command line, file paths are resolved relative to the specified directory. This helps both when using libclang (where we can't require the user to actually change the working directory) and to help reproduce test cases when the reproduction work comes along. --FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains the working directory value if set). --FileSystemOptions are passed around to various interfaces that perform file operations. --Opening & reading the content of files should be done only through FileManager. This is useful in general since file operations will be abstracted in the future for the reproduction mechanism. FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same FileManager but with different FileSystemOptions. Addresses rdar://8583824. llvm-svn: 118203
OpenPOWER on IntegriCloud