summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This failsArgyrios Kyrtzidis2011-09-011-1/+0
| | | | | | in the face of buffering C++/ObjC method bodies. llvm-svn: 138972
* 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
* Modules hide macro definitions by default, so that silly things likeDouglas Gregor2011-09-012-0/+36
| | | | | | | | | | | include guards don't show up as macro definitions in every translation unit that imports a module. Macro definitions can, however, be exported with the intentionally-ugly #__export_macro__ directive. Implement this feature by not even bothering to serialize non-exported macros to a module, because clients of that module need not (should not) know that these macros even exist. llvm-svn: 138943
* 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
* Change err_pp_file_not_found back to an Error; when it's a Warning, we ↵Eli Friedman2011-08-302-2/+4
| | | | | | | | suppress it in system headers. And it is not a good idea to suppress it in system headers. (This was originally changed in r134996 to implement -MG.) Fixes <rdar://10041960>. And also brings down the number of warnings without a flag by one :) llvm-svn: 138842
* Allow C99 hexfloats in C++0x mode. This change resolves the standardsDouglas Gregor2011-08-301-4/+2
| | | | | | | | | collision between C99 hexfloats and C++0x user-defined literals by giving C99 hexfloats precedence. Also, warning about user-defined literals that conflict with hexfloats and those that have names that are reserved by the implementation. Fixes <rdar://problem/9940194>. llvm-svn: 138839
* Add and document __has_feature values for the remaining C++0xDouglas Gregor2011-08-291-0/+11
| | | | | | | features, so clients can check for the availability of these features even before we get around to implementing them. llvm-svn: 138741
* 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-262-4/+35
| | | | | | | | | | | | | | | | | | | | | | 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
* Make Lexer::ComputePreamble accept a LangOptions parameter, otherwise it may beArgyrios Kyrtzidis2011-08-251-3/+3
| | | | | | out-of-sync how a file is compiled. Patch by Matthias Kleine! llvm-svn: 138580
* Silence 'may be used uninitialized' warnings.Argyrios Kyrtzidis2011-08-241-2/+2
| | | | llvm-svn: 138475
* Amend r138129 (reduction of SLocEntries) which introduced performance ↵Argyrios Kyrtzidis2011-08-231-18/+46
| | | | | | | | | | | | | | | | | | | | | | regression due to increased calls to SourceManager::getFileID. (rdar://9992664) Use a slightly different approach that is more efficient both in terms of speed (no extra getFileID calls) and in SLocEntries reduction. Comparing pre-r138129 and this patch we get: For compiling SemaExpr.cpp reduction of SLocEntries by 26%. For the boost enum library: -SLocEntries -34% (note that this was -5% for r138129) -Memory consumption -50% -PCH size -31% Reduced SLocEntries also benefit the hot function SourceManager::getFileID, evident by the reduced "FileID scans". llvm-svn: 138380
* Introduce SourceManager::isInSLocAddrSpace and use it in TokenLexer instead ↵Argyrios Kyrtzidis2011-08-231-12/+9
| | | | | | | | of isInFileID since it is a bit more efficient. llvm-svn: 138379
* Rename SourceManager::isBeforeInSourceLocationOffset -> isBeforeInSLocAddrSpace.Argyrios Kyrtzidis2011-08-231-2/+1
| | | | llvm-svn: 138378
* TokenLexer::getExpansionLocForMacroDefLoc doesn't need to return an invalid ↵Argyrios Kyrtzidis2011-08-231-29/+16
| | | | | | SourceLocation. llvm-svn: 138377
* In Lexer::isAtEndOfMacroExpansion use SourceManager::isInFileID and avoidArgyrios Kyrtzidis2011-08-231-5/+3
| | | | | | the extra SourceManager::getFileID call. llvm-svn: 138376
* Don't warn on varaidic macros in C++0x mode.Eli Friedman2011-08-221-2/+2
| | | | llvm-svn: 138257
* Boost the efficiency of SourceManager::getMacroArgExpandedLocation.Argyrios Kyrtzidis2011-08-212-0/+18
| | | | | | | | | | | | | | | | | | 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
* For assigning SourceLocations to macro arg tokens, reserve a single SLocEntryArgyrios Kyrtzidis2011-08-191-22/+69
| | | | | | | | | | | | | | for tokens that are lexed consecutively from the same FileID, instead of creating a SLocEntry for each token. e.g for assert(foo == bar); there will be a single SLocEntry for the "foo == bar" chunk and locations for the 'foo', '==', 'bar' tokens will point inside that chunk. For parsing SemaExpr.cpp, this reduced the number of SLocEntries by 25%. llvm-svn: 138129
* Rename TokenLexer::getMacroExpansionLocation -> ↵Argyrios Kyrtzidis2011-08-191-8/+10
| | | | | | getExpansionLocForMacroDefLoc, no functionality change. llvm-svn: 138128
* Warn about and truncate UCNs that are too big for their character literal type.Craig Topper2011-08-191-5/+5
| | | | llvm-svn: 138031
* [libclang] Support code-completion inside macro arguments.Argyrios Kyrtzidis2011-08-181-1/+17
| | | | llvm-svn: 137973
* For the MacroExpands preprocessor callback, also pass the SourceRangeArgyrios Kyrtzidis2011-08-182-7/+10
| | | | | | of expansion (for function macros it includes the right paren). llvm-svn: 137909
* Make Lexer::GetBeginningOfToken able to handle macro arg expansion locations.Argyrios Kyrtzidis2011-08-171-3/+23
| | | | llvm-svn: 137795
* De-Unicode-ify.NAKAMURA Takumi2011-08-121-2/+2
| | | | llvm-svn: 137430
* Raw string followup. Pass a couple StringRefs by value.Craig Topper2011-08-112-2/+2
| | | | llvm-svn: 137301
* Add support for C++0x raw string literals.Craig Topper2011-08-113-110/+335
| | | | llvm-svn: 137298
* Fix comment (test commit)Craig Topper2011-08-081-1/+1
| | | | llvm-svn: 137039
* Add a __has_feature macro for generalized initializers, turned offAlexis Hunt2011-08-071-0/+1
| | | | | | because we don't support them yet. llvm-svn: 137027
* Comment the weird behavior of __has_feature(is_empty) and __has_feature(is_pod)Douglas Gregor2011-08-031-0/+8
| | | | llvm-svn: 136788
* A couple fixes for preprocessor expressions:Eli Friedman2011-08-031-9/+13
| | | | | | | | | | | 1. Be more tolerant of comments in -CC (comment-preserving) mode. We were missing a few cases. 2. Make sure to expand the second FOO in "#if defined FOO FOO". (See also r97253, which addressed the case of "#if defined(FOO FOO".) Fixes PR10286. llvm-svn: 136748
* Fix a thinko in my __is_empty/__is_pod commit.Douglas Gregor2011-07-301-2/+6
| | | | llvm-svn: 136561
* Turn off __has_feature(is_empty) and __has_feature(is_pod) if theDouglas Gregor2011-07-301-2/+4
| | | | | | | libstdc++ hack has reverted these type traits to keywords. Icky, but fixes <rdar://problem/9836262>. llvm-svn: 136560
* Use the "Bar.h" -> <Foo/Bar.h> remapping for index header maps only asDouglas Gregor2011-07-301-16/+23
| | | | | | | a fallback, if normal header search fails. Another attempt at <rdar://problem/9824020>. llvm-svn: 136557
* Introduce the "-index-header-map" option, to give special semanticsDouglas Gregor2011-07-281-3/+35
| | | | | | | for quoted header lookup when dealing with not-yet-installed frameworks. Fixes <rdar://problem/9824020>. llvm-svn: 136331
* Add a utility function to the Lexer, which makes it easier to find a token ↵Anna Zaks2011-07-271-0/+59
| | | | | | after the given location. (It is a generalized version of trans::findLocationAfterSemi from ArcMigrate, which will be changed to use the Lexer utility). llvm-svn: 136268
* Change Preprocessor::getTotalMemory() to use llvm::capacity_in_bytes().Ted Kremenek2011-07-271-5/+6
| | | | llvm-svn: 136239
* Change PreprocessingRecord::getTotalMemory() to use llvm::capacity_in_bytes().Ted Kremenek2011-07-271-3/+4
| | | | llvm-svn: 136238
* Change HeaderSearch::getTotalMemory() to use llvm::capacity_in_bytes().Ted Kremenek2011-07-271-2/+3
| | | | llvm-svn: 136237
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-277-123/+209
| | | | llvm-svn: 136210
* clang_getCXTUResourceUsage: report memory used by HeaderSearch.Ted Kremenek2011-07-261-1/+7
| | | | | | | This required converting the StringMaps to use a BumpPtrAllocator. I measured the compile time and saw no observable regression. llvm-svn: 136190
* Report more memory using in Preprocessor::getTotalMemory() and ↵Ted Kremenek2011-07-262-1/+14
| | | | | | | | | | 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
* Migrate 'Instantiation' data and API bits of SLocEntry to 'Expansion'Chandler Carruth2011-07-261-3/+2
| | | | | | | | etc. With this I think essentially all of the SourceManager APIs are converted. Comments and random other bits of cleanup should be all thats left. llvm-svn: 136057
* Convert InstantiationInfo and much of the related code to ExpansionInfoChandler Carruth2011-07-261-2/+2
| | | | | | | | | and various other 'expansion' based terms. I've tried to reformat where appropriate and catch as many references in comments but I'm going to do several more passes. Also I've tried to expand parameter names to be more clear where appropriate. llvm-svn: 136056
* Rename create(MacroArg)InstantiationLoc to create(MacroArg)ExpansionLoc.Chandler Carruth2011-07-264-34/+32
| | | | llvm-svn: 136054
* Rename getDecomposedInstantiationLoc to getDecomposedExpansionLoc.Chandler Carruth2011-07-252-4/+4
| | | | llvm-svn: 135962
* Rename SourceManager::getImmediateInstantiationRange toChandler Carruth2011-07-251-1/+1
| | | | | | getImmediateExpansionRange. llvm-svn: 135960
* Rename SourceManager::getInstantiationRange to getExpansionRange.Chandler Carruth2011-07-252-2/+2
| | | | llvm-svn: 135915
OpenPOWER on IntegriCloud