I didn't see this stated clearly (I did see it touched upon by one or two answers, but it didn't seem very clear)
Generating code (as you said, as though it was data) is not a problem--it's a way to reuse a compiler for a secondary purpose.
Editing generated code is one of the most insidious, evil, horrific anti-patterns you will ever come across. Do not do this.
At best, editing generated code pulls a bunch of poor code into your project (the ENTIRE set of code is now truly SOURCE CODE--no longer data). At worst the code pulled into your program is highly redundant, poorly named garbage that is nearly completely unmaintainable.
I suppose a third category is code you use once (gui generator?) then edit to help you get started/learn. This is a little of each--it CAN be a good way to start but your GUI generator will be targeted at using "Generatable" code that won't be a great start for you as a programmer--In addition, you might be tempted to use it again for a second GUI which means pulling redundant SOURCE code into your system.
If your tooling is smart enough to disallow any edits whatsoever of generated code, go for it. If not, I'd call it one of the worst anti-patterns out there.