aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPMacroExpansion.cpp
AgeCommit message (Collapse)Author
2013-05-21Merging r181342:Bill Wendling
------------------------------------------------------------------------ r181342 | rsmith | 2013-05-07 12:32:56 -0700 (Tue, 07 May 2013) | 4 lines C++1y: Update __cplusplus to temporary value 201305L to allow detection of provisional C++1y support. Add __has_feature and __has_extension checks for C++1y features (based on the provisional names from the C++ features study group), and update documentation to match. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_33@182340 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03[Preprocessor] For the MacroExpands preprocessor callback, also pass the ↵Argyrios Kyrtzidis
MacroArgs object that provides information about the argument tokens for a function macro. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181065 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-02Only evaluate __has_feature(c_thread_local) and ↵Douglas Gregor
__has_feature(cxx_thread_local) true when the target supports thread-local storage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180909 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-19C++11 support is now feature-complete.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179861 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-27[modules] Re-enable the "ambiguous expansion of macro" warning.Argyrios Kyrtzidis
Also update "test/Modules/macros.c" to test modified semantics: -When there is an ambiguous macro, expand using the latest introduced version, not the first one. -#undefs in submodules cause the macro to not be exported by that submodule, it doesn't cause undefining of macros in the translation unit that imported that submodule. This reduces macro namespace interference across modules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178105 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-26[Preprocessor/Modules] Separate the macro directives kinds into their own ↵Argyrios Kyrtzidis
MacroDirective's subclasses. For each macro directive (define, undefine, visibility) have a separate object that gets chained to the macro directive history. This has several benefits: -No need to mutate a MacroDirective when there is a undefine/visibility directive. Stuff like PPMutationListener become unnecessary. -No need to keep extra source locations for the undef/visibility locations for the define directive object (which is the majority of the directives) -Much easier to hide/unhide a section in the macro directive history. -Easier to track the effects of the directives across different submodules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178037 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-22[PCH/Modules] De/Serialize MacroInfos separately than MacroDirectives.Argyrios Kyrtzidis
-Serialize the macro directives history into its own section -Get rid of the macro updates section -When de/serializing an identifier from a module, associate only one macro per submodule that defined+exported it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177761 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-24[preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis
available the full information about the macro (e.g if it was imported and where). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175978 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-22[libclang] Fix assertion hit when code-completing inside a function macro ↵Argyrios Kyrtzidis
with more arguments than it should accept. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175925 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20[preprocessor] Split the MacroInfo class into two separate concepts, ↵Argyrios Kyrtzidis
MacroInfo class for the data specific to a macro definition (e.g. what the tokens are), and MacroDirective class which encapsulates the changes to the "macro namespace" (e.g. the location where the macro name became active, the location where it was undefined, etc.) (A MacroDirective always points to a MacroInfo object.) Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but splitting the concepts allows us to better model the effect of modules to the macro namespace (also as a bonus it allows better modeling of push_macro/pop_macro #pragmas). Modules can have their own macro history, separate from the local (current translation unit) macro history; MacroDirectives will be used to model the macro history (changes to macro namespace). For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created to indicate that "FOO" became active at the import location. Module "A" itself will contain another MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives will point to the same MacroInfo object. Introducing the separation of macro concepts is the first part towards better modeling of module macros. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175585 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30Reinstate r173952, this time limiting it to exactly the formDouglas Gregor
#define X X for which there is no point warning, ever. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173991 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30Revert "[preprocessor] Don't warn about "disabled expansion of recursive macro""Argyrios Kyrtzidis
This reverts commit r173952 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173970 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30[preprocessor] Don't warn about "disabled expansion of recursive macro"Argyrios Kyrtzidis
for "#define X X". This is a pattern that, for example, stdbool.h uses. rdar://12435773 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173952 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-23[PCH] Temporarily disable the "ambiguous macro" warning that is currently ↵Argyrios Kyrtzidis
bogus with a PCH that redefined a macro without undef'ing it first. Proper reconstruction of the macro info history from modules will properly fix this in subsequent commits. rdar://13016031 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173281 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19[PCH/Modules] Revert r172843, it caused a module to fail building.Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172884 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18[PCH/Modules] Re-apply r172620 and r172629, now with 100% less infinite loops!Argyrios Kyrtzidis
Makes sure that a deserialized macro is only added to the preprocessor macro definitions only once. Unfortunately I couldn't get a reduced test case. rdar://13016031 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172843 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18[ubsan] Add support for -fsanitize-blacklistWill Dietz
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172808 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18Revert Clang r172620 and r172629, which caused a hang when buildingDouglas Gregor
complicated modules (<rdar://problem/13038265>). Unfortunately, this un-fixes <rdar://problem/13016031>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172783 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16No longer crashing with an assert when __has_include or __has_include_next ↵Aaron Ballman
is used outside of a preprocessor directive. This fixes PR14837. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172639 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16[PCH/Modules] Change how macro [re]definitions are de/serialized.Argyrios Kyrtzidis
Previously we would serialize the macro redefinitions as a list, part of the identifier, and try to chain them together across modules individually without having the info that they were already chained at definition time. Change this by serializing the macro redefinition chain and then try to synthesize the chain parts across modules. This allows us to correctly pinpoint when 2 different definitions are ambiguous because they came from unrelated modules. Fixes bogus "ambiguous expansion of macro" warning when a macro in a PCH is redefined without undef'ing it first. rdar://13016031 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172620 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-15Typo correction; no functional change.Aaron Ballman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172555 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14Constify argument of Preprocessor::getMacroInfoHistory and propagate toDmitri Gribenko
callers, removing unneeded const_cast git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172372 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko
brought into 'clang' namespace by clang/Basic/LLVM.h git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-09Make __has_include a bit more resilient in the presence of macros. ↵Eli Friedman
<rdar://problem/12748859>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171939 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-04Add __has_feature support to detect if clang supports the explicit "atomic" ↵Ted Kremenek
keyword for ObjC properties. Fixes <rdar://problem/12953378>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171504 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02s/CPlusPlus0x/CPlusPlus11/gRichard Smith
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171367 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-22[libclang] Fix crash when code-completing a macro invocation thatArgyrios Kyrtzidis
reached EOF and did not expand the argument into the source context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170980 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21[libclang] Follow-up to r170824, provide the correct number of arguments forArgyrios Kyrtzidis
a not-fully-formed macro invocation during code-completion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170833 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21[libclang] Make sure we can code-complete inside a macro argument even thoughArgyrios Kyrtzidis
the macro invocation is not fully formed. rdar://11290992 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170824 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-20Add __has_feature(memory_sanitizer).Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170686 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-17tsan: add __has_feature(thread_sanitizer)Dmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170314 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-14[preprocessor] For errors at a function macro invocation, also includeArgyrios Kyrtzidis
a note about where the macro is defined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170228 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-28Remove obsolete comment missed by r162937Andy Gibbs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168778 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17Clean up code according to coding standardsAndy Gibbs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168274 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17Prevent premature macro expansion in __has_builtin, __has_feature,Andy Gibbs
__has_attribute, __has_extension, making them behave more akin to conventional macros. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168268 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17Made the "expected string literal" diagnostic more expressiveAndy Gibbs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168267 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17Refactored duplicate string literal lexing code within Preprocessor, into aAndy Gibbs
common LexStringLiteral function. In doing so, some consistency problems have been ironed out (e.g. where the first token in the string literal was lexed with macro expansion, but subsequent ones were not) and also an erroneous diagnostic has been corrected. LexStringLiteral is complemented by a FinishLexStringLiteral function which can be used in the situation where the first token of the string literal has already been lexed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168266 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17Fix handling of invalid uses of the __has_warning builtin macroAndy Gibbs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168265 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14Suppress elided variadic macro argument extension diagnostic for macros usingEli Friedman
the related comma pasting extension. In certain cases, we used to get two diagnostics for what is essentially one extension. This change suppresses the first diagnostic in certain cases where we know we're going to print the second diagnostic. The diagnostic is redundant, and it can't be suppressed in the definition of the macro because it points at the use of the macro, so we want to avoid printing it if possible. The implementation works by detecting constructs which look like comma pasting at the time of the definition of the macro; this information is then used when the macro is used. (We can't actually detect whether we're using the comma pasting extension until the macro is actually used, but we can detecting constructs which will be comma pasting if the varargs argument is elided.) <rdar://problem/12292192> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167907 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-05Rename LangOptions members for address sanitizer and thread sanitizer fromRichard Smith
*Sanitizer to Sanitize* in preparation for later patches. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167405 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22Fix for PR13334. This prevents crashes that result from badly formedRichard Trieu
expressions involving __has_include git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166438 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12Track which particular submodule #undef's a macro, so that the actualDouglas Gregor
#undef only occurs if that submodule is imported. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165773 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11Diagnose the expansion of ambiguous macro definitions. This can happenDouglas Gregor
only with modules, when two disjoint modules #define the same identifier to different token sequences. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11Introduce a simple "hint" scheme to eliminate the quadratic behaviorDouglas Gregor
associated with deserializing macro history for an identifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165729 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11Remove an unused bit from the serialized IdentifierInfoDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165683 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11Deserialize macro history when we deserialize an identifier that hasDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165682 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-26Revert r163022, it caused PR13924.Nico Weber
Add a test for PR13924. Do not revert the test added in r163022, it surprisingly still passes even after reverting the code changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164672 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-25Macro history (de-)serialization. Deserialization currently reads only the ↵Alexander Kornienko
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164610 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-25Introduce builtin macros to determine whether we're building aDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164605 91177308-0d34-0410-b5e6-96231b3b80d8