diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-09-13 18:32:52 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-09-13 18:32:52 +0000 |
commit | 0a4e61f81c0f4de860e26e03d7395f78bc4564db (patch) | |
tree | 8cae194817cc46591a4193d11973b294647de77a /clang | |
parent | 3c6b0561860f46d4de5416dbaae096c95da9753f (diff) | |
download | bcm5719-llvm-0a4e61f81c0f4de860e26e03d7395f78bc4564db.tar.gz bcm5719-llvm-0a4e61f81c0f4de860e26e03d7395f78bc4564db.zip |
Remove unnecessary inclusion of Sema.h
Let me tell you a tale...
Within some twisted maze of debug info I've ended up implementing an
insane man's Include What You Use device. When the debugger emits debug
info it really shouldn't, I find out why & then realize the code could
be improved too.
In this instance CIndexDiagnostics.cpp had a lot more debug info with
Clang than GCC. Upon inspection a major culprit was all the debug info
describing clang::Sema. This was emitted because clang::Sema is
befriended by DiagnosticEngine which was rightly required, but GCC
doesn't emit debug info for friends so it never emitted anything for
Clang. Clang does emit debug info for friends (will be fixed/changed to
reduce debug info size).
But why didn't Clang just emit a declaration of Sema if this entire TU
didn't require a definition?
1) Diagnostic.h did the right thing, only using a declaration of Sema
and not including Sema.h at all.
2) Some other dependency of CIndexDiagnostics.cpp didn't do the right
thing. ASTUnit.h, only needing a declaration, still included Sema.h
(hence this commit which removes that include and adds the necessary
includes to the cpp files that were relying on this)
3) -flimit-debug-info didn't save us because of
EnterExpressionEvaluationContext, defined inline in Sema.h which fires
the "requiresCompleteType" check/flag (since it uses nested types from
Sema and calls Sema member functions) and thus, if debug info is ever
emitted for the type, the whole type is emitted and not just a
declaration.
Improving -flimit-debug-info to account for this would be... hard.
Modifying the code so that's not 'required to be complete' might be
possible, but probably only by moving EnterExpressionEvaluationContext
either into Sema, or out of Sema.h. That might be a bit too much of a
contortion to be bothered with.
Also, this is only one of the cases where emitting debug info for
friends caused us to emit a lot more debug info (this change reduces
Clang's DWO size by 0.93%, dropping friends entirely reduces debug info
by 3.2%) - I haven't hunted down the other cases, but I assume they
might be similar (Sema or something like it). IWYU or a similar tool
might help us reduce build times a bit, but analyzing debug info to find
these differences isn't worthwhile. I'll take the 3.2% win, provide this
small improvement to the code itself, and move on.
llvm-svn: 190715
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Frontend/ASTUnit.h | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 1 | ||||
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 1 | ||||
-rw-r--r-- | clang/tools/libclang/CIndexCodeCompletion.cpp | 1 | ||||
-rw-r--r-- | clang/tools/libclang/CXComment.cpp | 1 | ||||
-rw-r--r-- | clang/tools/libclang/CXCursor.cpp | 1 | ||||
-rw-r--r-- | clang/tools/libclang/IndexingContext.cpp | 1 |
7 files changed, 7 insertions, 1 deletions
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index 52f7f098d68..166f1a26aed 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -25,7 +25,6 @@ #include "clang/Lex/ModuleLoader.h" #include "clang/Lex/PreprocessingRecord.h" #include "clang/Sema/CodeCompleteConsumer.h" -#include "clang/Sema/Sema.h" #include "clang/Serialization/ASTBitCodes.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/OwningPtr.h" @@ -44,6 +43,7 @@ namespace llvm { } namespace clang { +class Sema; class ASTContext; class ASTReader; class CodeCompleteConsumer; diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 531adcdb50b..e2641ccec4a 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -29,6 +29,7 @@ #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" +#include "clang/Sema/Sema.h" #include "clang/Serialization/ASTReader.h" #include "clang/Serialization/ASTWriter.h" #include "llvm/ADT/ArrayRef.h" diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 15e282882b9..0fc36b2f02c 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -23,6 +23,7 @@ #include "CXType.h" #include "CursorVisitor.h" #include "SimpleFormatContext.h" +#include "clang/AST/Attr.h" #include "clang/AST/StmtVisitor.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/Version.h" diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp index 8face6580ac..865bb585b54 100644 --- a/clang/tools/libclang/CIndexCodeCompletion.cpp +++ b/clang/tools/libclang/CIndexCodeCompletion.cpp @@ -27,6 +27,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Sema/CodeCompleteConsumer.h" +#include "clang/Sema/Sema.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Atomic.h" diff --git a/clang/tools/libclang/CXComment.cpp b/clang/tools/libclang/CXComment.cpp index ad131a5221d..46588568dc6 100644 --- a/clang/tools/libclang/CXComment.cpp +++ b/clang/tools/libclang/CXComment.cpp @@ -16,6 +16,7 @@ #include "CXCursor.h" #include "CXString.h" #include "SimpleFormatContext.h" +#include "clang/AST/Attr.h" #include "clang/AST/CommentCommandTraits.h" #include "clang/AST/CommentVisitor.h" #include "clang/AST/Decl.h" diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp index df395047879..b80ea4ee4ff 100644 --- a/clang/tools/libclang/CXCursor.cpp +++ b/clang/tools/libclang/CXCursor.cpp @@ -18,6 +18,7 @@ #include "CXString.h" #include "CXType.h" #include "clang-c/Index.h" +#include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" diff --git a/clang/tools/libclang/IndexingContext.cpp b/clang/tools/libclang/IndexingContext.cpp index 53561764991..609d25b9ee7 100644 --- a/clang/tools/libclang/IndexingContext.cpp +++ b/clang/tools/libclang/IndexingContext.cpp @@ -10,6 +10,7 @@ #include "IndexingContext.h" #include "CIndexDiagnostic.h" #include "CXTranslationUnit.h" +#include "clang/AST/Attr.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" #include "clang/Frontend/ASTUnit.h" |