summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Introduce the notion of name visibility into modules. For a givenDouglas Gregor2011-12-011-2/+4
| | | | | | | | | | | | | | (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
* Promote ModuleMap::Module to a namespace-scope class in the BasicDouglas Gregor2011-11-301-3/+3
| | | | | | | | | library, since modules cut across all of the libraries. Rename serialization::Module to serialization::ModuleFile to side-step the annoying naming conflict. Prune a bunch of ModuleMap.h includes that are no longer needed (most files only needed the Module type). llvm-svn: 145538
* Note that we'll need to handle __include_macros specially in the module loaderDouglas Gregor2011-11-301-0/+1
| | | | llvm-svn: 145514
* Move the module auto-import logic after the logic that allows aDouglas Gregor2011-11-301-29/+29
| | | | | | | | | | callback client to suggest an alternative search path and after we complain when the included file can't be found. The former can't be tested in isolation, the latter doesn't actually matter (because we won't make a module suggestion if no header is available). However, the flow is better this way. llvm-svn: 145502
* Trivial indentation fix for the code I just committedDouglas Gregor2011-11-301-3/+3
| | | | llvm-svn: 145501
* Introduce an opt-in warning indicating when the compiler is treatingDouglas Gregor2011-11-301-0/+42
| | | | | | an #include/#import as a module import. llvm-svn: 145500
* Switch the module-loading interfaces and parser from a simpleDouglas Gregor2011-11-301-7/+11
| | | | | | | 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
* Allow preprocessor callbacks to recover from a "file not found" error,Douglas Gregor2011-11-201-4/+23
| | | | | | from Jason Haslam! llvm-svn: 145012
* When making a suggestion regarding which module to load rather thanDouglas Gregor2011-11-171-4/+8
| | | | | | | preprocess/parse a header, report back with an actual module (which may be a submodule) rather than just the name of the module. llvm-svn: 144925
* For modules, all macros that aren't include guards are implicitlyDouglas Gregor2011-10-171-2/+35
| | | | | | | public. Add a __private_macro__ directive to hide a macro, similar to the __module_private__ declaration specifier. llvm-svn: 142188
* -Wc++98-compat warnings for the lexer.Richard Smith2011-10-151-2/+6
| | | | | | | | This also adds a -Wc++98-compat-pedantic for warning on constructs which would be diagnosed by -std=c++98 -pedantic (that is, it warns even on C++11 features which we enable by default, with no warning, in C++98 mode). llvm-svn: 142034
* A couple random preprocessor changes that got ported from C99 to C++11.Eli Friedman2011-10-101-2/+4
| | | | llvm-svn: 141596
* Add explicit attributes to mark functions as having had theirJohn McCall2011-09-301-0/+9
| | | | | | | | | | | 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
* Introduce a callback to PPCallbacks for lines skipped by the preprocessor.Argyrios Kyrtzidis2011-09-271-3/+10
| | | | | | Patch by Jason Haslam! llvm-svn: 140612
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-1/+1
| | | | llvm-svn: 140478
* Add an experimental flag -fauto-module-import that automatically turnsDouglas Gregor2011-09-151-4/+18
| | | | | | | #include or #import direcctives of framework headers into module imports of the corresponding framework module. llvm-svn: 139860
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-2/+5
| | | | | | | | | | | | | | 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
* Modules hide macro definitions by default, so that silly things likeDouglas Gregor2011-09-011-0/+34
| | | | | | | | | | | 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
* Change err_pp_file_not_found back to an Error; when it's a Warning, we ↵Eli Friedman2011-08-301-1/+2
| | | | | | | | 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
* Don't warn on varaidic macros in C++0x mode.Eli Friedman2011-08-221-2/+2
| | | | llvm-svn: 138257
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-2/+2
| | | | llvm-svn: 136210
* Rename getDecomposedInstantiationLoc to getDecomposedExpansionLoc.Chandler Carruth2011-07-251-2/+2
| | | | llvm-svn: 135962
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-15/+15
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Implement -MG. Fixes PR9613Peter Collingbourne2011-07-121-4/+5
| | | | llvm-svn: 134996
* Don't warn for unused macro when undef'ing it, if it comes from an included ↵Argyrios Kyrtzidis2011-07-111-1/+1
| | | | | | file. rdar://9745065 llvm-svn: 134919
* Replace an unreachable error path with an assertPeter Collingbourne2011-06-301-4/+1
| | | | | | | (SourceManager::createFileID cannot return an invalid file ID). Also update a comment to reflect this. llvm-svn: 134168
* Make more use of llvm::StringRef in various APIs. In particular, don'tJay Foad2011-06-211-4/+2
| | | | | | use the deprecated forms of llvm::StringMap::GetOrCreateValue(). llvm-svn: 133515
* Only ignore extra tokens after #else if we skip it, otherwise warn. Fixes ↵Argyrios Kyrtzidis2011-05-211-1/+3
| | | | | | rdar://9475098. llvm-svn: 131788
* To be able to replay compilations we need to accurately remodel howManuel Klimek2011-04-261-8/+12
| | | | | | | | | includes get resolved, especially when they are found relatively to another include file. We also try to get it working for framework includes, but that part of the code is untested, as I don't have a code base that uses it. llvm-svn: 130246
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* Add a 'RawPath' parameter to the PPCallbacks interface. This allowsChandler Carruth2011-03-161-12/+20
| | | | | | | | | | | | | | | clients to observe the exact path through which an #included file was located. This is very useful when trying to record and replay inclusion operations without it beind influenced by the aggressive caching done inside the FileManager to avoid redundant system calls and filesystem operations. The work to compute and return this is only done in the presence of callbacks, so it should have no effect on normal compilation. Patch by Manuel Klimek. llvm-svn: 127742
* Rename tok::eom to tok::eod.Peter Collingbourne2011-02-281-45/+45
| | | | | | | | 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
* Reimplement __pragma support using a TokenLexerPeter Collingbourne2011-02-221-0/+1
| | | | llvm-svn: 126221
* Make TokenLexer capable of storing preprocessor directive tokensPeter Collingbourne2011-02-221-3/+5
| | | | llvm-svn: 126220
* When redefining a macro don't warn twice if it's not used and don't warn for ↵Argyrios Kyrtzidis2011-01-181-1/+3
| | | | | | | | duplicate definition by command line options. Fixes rdar://8875916. llvm-svn: 123767
* fix rdar://8823139, a crash on a comment in a preprocessed .s fileChris Lattner2011-01-061-0/+6
| | | | | | that contains the ## operator. llvm-svn: 122946
* Fix PR8654, ensuring each branch of an #if, #elif, #else, ... chainChandler Carruth2011-01-031-1/+12
| | | | | | | | receives a PPCallback. Patch by Richard Smith. llvm-svn: 122755
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-231-2/+2
| | | | | | | | | new gcc warning that complains on self-assignments and self-initializations. Fix one bug found by the warning, in which one clang::OverloadCandidate constructor failed to initialize its FunctionTemplate member. llvm-svn: 122459
* Introduced raw_identifier token kind.Abramo Bagnara2010-12-221-7/+3
| | | | llvm-svn: 122394
* Fix diagnostic pragmas.Argyrios Kyrtzidis2010-12-151-6/+14
| | | | | | | | | | | | 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
* Don't crash when code-completing after "#include <". It would be farDouglas Gregor2010-12-091-0/+6
| | | | | | | better to actually produce a decent set of completions by checking the system include paths, but not today. Fixes PR8744. llvm-svn: 121431
* Several PPCallbacks take an SourceLocation + IdentifierInfo, ratherCraig Silverstein2010-11-191-5/+4
| | | | | | | | | | | than a Token that holds the same information all in one easy-to-use package. There's no technical reason to prefer the former -- the information comes from a Token originally -- and it's clumsier to use, so I've changed the code to use tokens everywhere. Approved by clattner llvm-svn: 119845
* Make sure to always check the result ofDouglas Gregor2010-11-121-1/+3
| | | | | | | SourceManager::getPresumedLoc(), so that we don't try to make use of an invalid presumed location. Doing so can cause crashes. llvm-svn: 118885
* Add PPCallbacks for #if/#ifdef/etc.Craig Silverstein2010-11-061-14/+37
| | | | | | | | | | | The callback info for #if/#elif is not great -- ideally it would give us a list of tokens in the #if, or even better, a little parse tree. But that's a lot more work. Instead, clients can retokenize using Lexer::LexFromRawLexer(). Reviewed by nlewycky. llvm-svn: 118318
* Extend the preprocessing record and libclang with support forDouglas Gregor2010-10-201-14/+30
| | | | | | | | | inclusion directives, keeping track of every #include, #import, etc. in the translation unit. We keep track of the source location and kind of the inclusion, how the file name was spelled, and the underlying file to which the inclusion resolved. llvm-svn: 116952
* Really^2 fix <rdar://problem/8361834>, this time without crashing.Ted Kremenek2010-10-191-13/+31
| | | | | | | | | Now MICache is a linked list (per the FIXME), where we tradeoff between MacroInfo objects being in MICache and MIChainHead. MacroInfo objects in the MICache chain are already "Destroy()'ed", so they can be reused. When inserting into MICache, we need to remove them from the regular linked list so that they aren't destroyed more than once. llvm-svn: 116869
* Revert most of r116862. It isn't quite the right fix for a memory leak in ↵Ted Kremenek2010-10-191-5/+1
| | | | | | Preprocessor. llvm-svn: 116864
* Really fix: <rdar://problem/8361834> MacroInfo::AddTokenToBody() leaks memoryTed Kremenek2010-10-191-2/+6
| | | | | | | | | The problem was not the management of MacroInfo objects, but that when we recycle them via the MICache the memory of the underlying SmallVector (within MacroInfo) was not getting released. This is because objects stashed into MICache simply are reused with a placement new, and never have their destructor called. llvm-svn: 116862
* Simplify lifetime management of MacroInfo objects in Preprocessor by having ↵Ted Kremenek2010-10-191-2/+6
| | | | | | | | | | | | the Preprocessor maintain them in a linked list of allocated MacroInfos. This requires only 1 extra pointer per MacroInfo object, and allows us to blow them away in one place. This fixes an elusive memory leak with MacroInfos (whose exact location I couldn't still figure out despite substantial digging). Fixes <rdar://problem/8361834>. llvm-svn: 116842
OpenPOWER on IntegriCloud