[preprocessor] Split the MacroInfo class into two separate concepts, MacroInfo class
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 20 Feb 2013 00:54:57 +0000 (00:54 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 20 Feb 2013 00:54:57 +0000 (00:54 +0000)
commit09c9e811de7696df87535d8a1d3e6c83e5316ee8
tree0ff56079768b1ff1cdf038bf7892d36e5817197b
parentcab3dfb65042d4abd552d14246e2778ffb66b02d
[preprocessor] Split the MacroInfo class into two separate concepts, 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.

llvm-svn: 175585
17 files changed:
clang/include/clang/Lex/MacroInfo.h
clang/include/clang/Lex/PPMutationListener.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Serialization/ASTDeserializationListener.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/lib/Lex/MacroInfo.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/Pragma.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp