aboutsummaryrefslogtreecommitdiff
path: root/clang/tools
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-09-13 18:32:52 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-09-13 18:32:52 +0000
commit0a4e61f81c0f4de860e26e03d7395f78bc4564db (patch)
tree8cae194817cc46591a4193d11973b294647de77a /clang/tools
parent3c6b0561860f46d4de5416dbaae096c95da9753f (diff)
downloadllvm-0a4e61f81c0f4de860e26e03d7395f78bc4564db.zip
llvm-0a4e61f81c0f4de860e26e03d7395f78bc4564db.tar.gz
llvm-0a4e61f81c0f4de860e26e03d7395f78bc4564db.tar.bz2
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/tools')
-rw-r--r--clang/tools/libclang/CIndex.cpp1
-rw-r--r--clang/tools/libclang/CIndexCodeCompletion.cpp1
-rw-r--r--clang/tools/libclang/CXComment.cpp1
-rw-r--r--clang/tools/libclang/CXCursor.cpp1
-rw-r--r--clang/tools/libclang/IndexingContext.cpp1
5 files changed, 5 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 15e2828..0fc36b2 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 8face65..865bb58 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 ad131a5..4658856 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 df39504..b80ea4e 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 5356176..609d25b 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"