appendMacroDirective vs appendDefMacroDirective

What is the difference between these two functions in the Preprocessor? which should be favored?

They are related, but quite different. appendMacroDirective adds ALL 3 kinds of macro directives (define, undefine, and visibility).

appendDefMacroDirective is for adding a define macro directive, and does so by allocating a new DefMacroDirective and calling appendMacroDirective. So if you need to add a DefMacroDirective, and haven’t allocated it yet, you should use appendDefMacroDirective instead.

1 Like

Hey Erich, just so I’m clear, this will append a new definition to the body of a macro’s IdentifierInfo, right?

so the next time an expansion occurs, the new definition will be used, right?

It appears so? It at least does the same as RegisterBuiltinMacro : clang: lib/Lex/PPMacroExpansion.cpp Source File

1 Like