llvm-project/clang/lib/Frontend
Douglas Gregor e9fc377a44 Extend the ExternalASTSource interface to allow the AST source to
provide the layout of records, rather than letting Clang compute
the layout itself. LLDB provides the motivation for this feature:
because various layout-altering attributes (packed, aligned, etc.)
don't get reliably get placed into DWARF, the record layouts computed
by LLDB from the reconstructed records differ from the actual layouts,
and badness occurs. This interface lets the DWARF data drive layout,
so we don't need the attributes preserved to get the answer write.

The testing methodology for this change is fun. I've introduced a
variant of -fdump-record-layouts called -fdump-record-layouts-simple
that always has the simple C format and provides size/alignment/field
offsets. There is also a -cc1 option -foverride-record-layout=<file>
to take the output of -fdump-record-layouts-simple and parse it to
produce a set of overridden layouts, which is introduced into the AST
via a testing-only ExternalASTSource (called
LayoutOverrideSource). Each test contains a number of records to lay
out, which use various layout-changing attributes, and then dumps the
layouts. We then run the test again, using the preprocessor to
eliminate the layout-changing attributes entirely (which would give us
different layouts for the records), but supplying the
previously-computed record layouts. Finally, we diff the layouts
produced from the two runs to be sure that they are identical.

Note that this code makes the assumption that we don't *have* to
provide the offsets of bases or virtual bases to get the layout right,
because the alignment attributes don't affect it. I believe this
assumption holds, but if it does not, we can extend
LayoutOverrideSource to also provide base offset information.

Fixes the Clang side of <rdar://problem/10169539>.

llvm-svn: 149055
2012-01-26 07:55:45 +00:00
..
ASTConsumers.cpp Change ASTConsumer::HandleTopLevelDecl to return true for the parser to continue 2011-11-18 00:26:59 +00:00
ASTMerge.cpp Extract the (InputKind, std::string) pair used to describe inputs to 2012-01-20 16:28:04 +00:00
ASTUnit.cpp Extract the (InputKind, std::string) pair used to describe inputs to 2012-01-20 16:28:04 +00:00
CMakeLists.txt Extend the ExternalASTSource interface to allow the AST source to 2012-01-26 07:55:45 +00:00
CacheTokens.cpp remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports 2011-07-23 10:55:15 +00:00
ChainedDiagnosticConsumer.cpp Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch 2011-12-20 02:48:34 +00:00
ChainedIncludesSource.cpp Rework the external Sema source's ReadMethodPool() so that it doesn't 2012-01-25 00:49:42 +00:00
CompilerInstance.cpp Extract the (InputKind, std::string) pair used to describe inputs to 2012-01-20 16:28:04 +00:00
CompilerInvocation.cpp Extend the ExternalASTSource interface to allow the AST source to 2012-01-26 07:55:45 +00:00
CreateInvocationFromCommandLine.cpp Let CompilerInvocation initialization indicate failure 2011-12-23 03:05:38 +00:00
DependencyFile.cpp Delete the depfile if we could not open a header file. We cannot 2011-11-21 00:01:14 +00:00
DiagnosticRenderer.cpp Fix -fmacro-backtrace-limit=0 to show the entire macro backtrace. 2012-01-25 06:07:15 +00:00
FrontendAction.cpp Extend the ExternalASTSource interface to allow the AST source to 2012-01-26 07:55:45 +00:00
FrontendActions.cpp Extract the (InputKind, std::string) pair used to describe inputs to 2012-01-20 16:28:04 +00:00
FrontendOptions.cpp remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports 2011-07-23 10:55:15 +00:00
HeaderIncludeGen.cpp For the FileChanged Preprocessor callback, when exiting a file, pass its FileID. 2011-10-11 17:29:44 +00:00
InitHeaderSearch.cpp lib/Frontend/InitHeaderSearch.cpp: [Cygwin] Add 4.5.3. 2012-01-21 14:46:07 +00:00
InitPreprocessor.cpp Some improvements to the handling of C11 atomic types: 2012-01-16 17:27:18 +00:00
LangStandards.cpp Remove unnecessary default cases in switches over enums. 2012-01-17 02:30:50 +00:00
LayoutOverrideSource.cpp Extend the ExternalASTSource interface to allow the AST source to 2012-01-26 07:55:45 +00:00
LogDiagnosticPrinter.cpp Remove unnecessary default cases in switches over enums. 2012-01-17 02:30:50 +00:00
Makefile BUILD_ARCHIVE is the default for libraries, no need to set it. 2010-07-18 00:14:47 +00:00
MultiplexConsumer.cpp [libclang] Indexing API: If the client requested to get a CXTranslationUnit after 2011-11-28 04:56:00 +00:00
PrintPreprocessedOutput.cpp Remove unnecessary default cases in switches over enums. 2012-01-17 02:30:50 +00:00
SerializedDiagnosticPrinter.cpp Refactor SerializeDiagnosticsPrinter to using DiagnosticRenderer. This gives us comparative diagnostics 2011-12-17 05:26:11 +00:00
TextDiagnostic.cpp Refactor 'TextDiagnostic' to have a parent class 'DiagnosticRenderer' which handles 2011-12-17 05:26:04 +00:00
TextDiagnosticBuffer.cpp Introduce a pure virtual clone() method to DiagnosticConsumer, so that 2011-09-29 00:38:00 +00:00
TextDiagnosticPrinter.cpp Persist the TextDiagnostic object across multiple diagnostics as long as 2011-10-16 02:57:39 +00:00
VerifyDiagnosticConsumer.cpp Extract the (InputKind, std::string) pair used to describe inputs to 2012-01-20 16:28:04 +00:00
Warnings.cpp Treat -Wformat=0 as an alias for -Wformat. 2012-01-17 09:30:38 +00:00