Commit Graph

367 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis ca5c7be088 [libclang] For an unscoped enum include the enumerators in the top-level code-completion hash since they enter the top-level namespace.
rdar://14703327

llvm-svn: 192720
2013-10-15 17:37:55 +00:00
David Blaikie 0a4e61f81c 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
2013-09-13 18:32:52 +00:00
Benjamin Kramer 45025c0cf1 This wasn't headers, just missing namespaces.
/me bows head in shame.

llvm-svn: 189172
2013-08-24 13:22:59 +00:00
Benjamin Kramer e3e855bb89 Replace compLocDecl with less_first.
llvm-svn: 189170
2013-08-24 13:12:34 +00:00
Argyrios Kyrtzidis acfbbd77f8 [PCH] Fix a PCH serialization crash, with invalid code related to forward enum references.
The problem was that an enum without closing semicolon could be associated as a forward enum
in an erroneous declaration, leading to the identifier being associated with the enum decl but
without a declaration actually referencing it.
This resulted in not having it serialized before serializing the identifier that is associated with.

Also prevent the ASTUnit from querying the serialized DeclID for an invalid top-level decl; it may not
have been serialized.

rdar://14539667

llvm-svn: 187914
2013-08-07 21:17:33 +00:00
Rafael Espindola 073ff10138 Update for llvm api change.
llvm-svn: 187379
2013-07-29 21:26:52 +00:00
Rafael Espindola e4777f4638 Convert a use of stat with sys::fs::status.
llvm-svn: 187364
2013-07-29 18:22:23 +00:00
Manuel Klimek be0474c047 Fix crash in libclang if code completion is used with unknown flags.
Use CaptureDroppedDiagnostics to make sure that there is a diagnostic
client installed when warning flags are parsed.

llvm-svn: 186582
2013-07-18 14:23:12 +00:00
Rafael Espindola 18627115f4 Use llvm::sys::fs::createUniqueFile.
Include a test that clang now produces output files with permissions matching
the umask.

llvm-svn: 185727
2013-07-05 21:13:58 +00:00
Rafael Espindola a36e78ef5d Use llvm::sys::fs::createTemporaryFile.
llvm-svn: 185717
2013-07-05 20:00:06 +00:00
Rafael Espindola f5e5bc4703 Don't use PathV1.h in ASTUnit.cpp.
llvm-svn: 184912
2013-06-26 04:26:38 +00:00
Rafael Espindola a96bd562c2 Remove the last use of PathWithStatus.
llvm-svn: 184909
2013-06-26 04:12:57 +00:00
Rafael Espindola bc4aa5547e Use llvm::sys::fs::unique_file.
llvm-svn: 184908
2013-06-26 04:02:37 +00:00
Rafael Espindola bc7d949b32 Remove some uses of llvm::sys::Path.
llvm-svn: 184907
2013-06-26 03:52:38 +00:00
Argyrios Kyrtzidis 48d88de2af [libclang/codecompletion] Make sure the top-level decl hash takes into account ImportDecls.
The top-level hash is used to determine if we need to update the global code-completion results.
ImportDecls did not affect the hash so a newly introduced ImportDecl would not trigger an update of the global results.

rdar://14202797

llvm-svn: 184782
2013-06-24 21:19:12 +00:00
Rafael Espindola be3b12b004 Use the new name of getUniqueID.
llvm-svn: 184432
2013-06-20 15:12:38 +00:00
Rafael Espindola f9e9bb8858 Use llvm::sys::fs::GetUniqueID.
llvm-svn: 184218
2013-06-18 19:40:07 +00:00
Rafael Espindola be5138885d Include PathV1.h in files that use it.
This is preparation for replacing Path.h with PathV2.h.

llvm-svn: 183781
2013-06-11 19:59:07 +00:00
Argyrios Kyrtzidis d6f57221c8 Modify a comment to reflect changes of r183717.
llvm-svn: 183751
2013-06-11 16:42:34 +00:00
Benjamin Kramer 65745dc0b1 ASTUnit: Invert the dependency of PrecompilePreambleAction on PrecompilePreambleConsumer.
Actions outlive consumers. PR16295. Found by AddressSanitizer.

llvm-svn: 183741
2013-06-11 13:07:19 +00:00
Argyrios Kyrtzidis f0168de936 [libclang] Allow building a precompiled preamble with compiler errors
A while ago we allowed libclang to build a PCH that had compiler errors; this was to retain the performance
afforded by a PCH even if the user's code is in an intermediate state.

Extend this for the precompiled preamble as well.

rdar://14109828

llvm-svn: 183717
2013-06-11 00:36:55 +00:00
Argyrios Kyrtzidis dc9fdaf217 [modules] If we hit a failure while loading a PCH/module, abort parsing instead of trying to continue in an invalid state.
Also don't let libclang create a PCH with such an error.

Fixes rdar://13953768

llvm-svn: 182629
2013-05-24 05:44:08 +00:00
Argyrios Kyrtzidis 1c7455f42f [libclang] When parsing with CXTranslationUnit_ForSerialization, make sure to install the ASTWriter that we create as an ASTMutationListener.
Fixes rdar://13833268

llvm-svn: 181575
2013-05-10 01:28:51 +00:00
Argyrios Kyrtzidis 1054bbf08d [PCH] Remove the ASTReaderListener::ReadHeaderFileInfo callback.
This made sense in pre-module era, before merging of HeaderFileInfos was introduced.

Final part of rdar://13840148.

llvm-svn: 181490
2013-05-08 23:46:55 +00:00
Benjamin Kramer 1ce5d80066 Use remove_if to erase parts of a vector. Avoids O(n^2) worst cases.
llvm-svn: 181150
2013-05-05 12:39:28 +00:00
Douglas Gregor 30071cead9 Remove DiagnosticConsumer::clone(), a bad idea that is now unused.
llvm-svn: 181070
2013-05-03 23:07:45 +00:00
Douglas Gregor 6b930967e8 When building a module, forward diagnostics to the outer diagnostic consumer.
Previously, we would clone the current diagnostic consumer to produce
a new diagnostic consumer to use when building a module. The problem
here is that we end up losing diagnostics for important diagnostic
consumers, such as serialized diagnostics (where we'd end up with two
diagnostic consumers writing the same output file). With forwarding,
the diagnostics from all of the different modules being built get
forwarded to the one serialized-diagnostic consumer and are emitted in
a sane way.

Fixes <rdar://problem/13663996>.

llvm-svn: 181067
2013-05-03 22:58:43 +00:00
Douglas Gregor 7029ce1a0c <rdar://problem/13363214> Eliminate race condition between module rebuild and the global module index.
The global module index was querying the file manager for each of the
module files it knows about at load time, to prune out any out-of-date
information. The file manager would then cache the results of the
stat() falls used to find that module file.

Later, the same translation unit could end up trying to import one of the
module files that had previously been ignored by the module cache, but
after some other Clang instance rebuilt the module file to bring it
up-to-date. The stale stat() results in the file manager would
trigger a second rebuild of the already-up-to-date module, causing
failures down the line.

The global module index now lazily resolves its module file references
to actual AST reader module files only after the module file has been
loaded, eliminating the stat-caching race. Moreover, the AST reader
can communicate to its caller that a module file is missing (rather
than simply being out-of-date), allowing us to simplify the
module-loading logic and allowing the compiler to recover if a
dependent module file ends up getting deleted.

llvm-svn: 177367
2013-03-19 00:28:20 +00:00
Argyrios Kyrtzidis 37f2ab4824 [libclang] When logging a CXTranslationUnit that came from an AST file, print out the filename.
llvm-svn: 176511
2013-03-05 20:21:14 +00:00
Argyrios Kyrtzidis fead64be9b [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the
full information about the macro (e.g if it was imported and where).

llvm-svn: 175978
2013-02-24 00:05:14 +00:00
Dmitri Gribenko acf2e786d2 Comment parsing: add CommentOptions to allow specifying custom comment block commands
Add an ability to specify custom documentation block comment commands via a new
class CommentOptions.  The intention is that this class will hold future
customizations for comment parsing, including defining documentation comments
with specific numbers of parameters, etc.

CommentOptions instance is a member of LangOptions.

CommentOptions is controlled by a new command-line parameter
-fcomment-block-commands=Foo,Bar,Baz.

llvm-svn: 175892
2013-02-22 14:21:27 +00:00
Dmitri Gribenko fe0483dbea Use 'const Decl *' throughout code completion in Sema
llvm-svn: 173277
2013-01-23 17:21:11 +00:00
Argyrios Kyrtzidis 3ad52ede46 [ASTUnit] Unlike LoadFromCommandLine, LoadFromCompilerInvocation causes a crash if Precompilepreamble
is set to true because there is no FileManager at that point.

Patch by Hurcan Solter!

llvm-svn: 173071
2013-01-21 18:45:42 +00:00
Sean Silva f1b49e237f Nuke SetUpBuildDumpLog.
Also, it was the only reason that `argc` and `argv` were being passed
into createDiagnostics, so remove those parameters and clean up callers.

llvm-svn: 172945
2013-01-20 01:58:28 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Argyrios Kyrtzidis 928e1fdecc [libclang] In ASTUnit::getMainFileName() Invocation may be null because the ASTUnit
came from loading a PCH/module.

llvm-svn: 172259
2013-01-11 22:11:14 +00:00
Richard Smith 2bf7fdb723 s/CPlusPlus0x/CPlusPlus11/g
llvm-svn: 171367
2013-01-02 11:42:31 +00:00
Argyrios Kyrtzidis 430a938fde [libclang] Don't try to translate diagnostics from the precompiled preamble to the
code-completion results, the SourceManager state may be slightly
different when code-completing.

And we don't even care for diagnostics when code-completing, anyway.

llvm-svn: 170979
2012-12-22 04:48:08 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Douglas Gregor f8715de599 Since CreateTargetInfo is taking ownership of the target options, pass
it as a pointer. 

llvm-svn: 168136
2012-11-16 04:24:59 +00:00
Argyrios Kyrtzidis 2bafa0076d [libclang] When caching code-completion results, pass the CachedCompletionAllocator
to the CodeCompletionTUInfo that is going to be used to get the results.

Previously we would use ASTUnit's CodeCompletionTUInfo which has its own allocator
that will go away when we reparse. That could result in a use-after-free bug when
getting the parent context name from a CodeCompletionString.

Addresses rdar://12568377.

llvm-svn: 168133
2012-11-16 03:34:57 +00:00
Argyrios Kyrtzidis 2ec2936778 [modules] Setup the import location of a module file and use it
as the include location of the main file of an imported module.

llvm-svn: 168061
2012-11-15 18:57:22 +00:00
Dmitri Gribenko b2aa9234b6 Use empty parens for empty function parameter list instead of '(void)'.
llvm-svn: 168041
2012-11-15 14:28:07 +00:00
Argyrios Kyrtzidis 873c8583e0 Turn FrontendInputFile into an immutable class and have it also accept
a memory buffer instead of only a filename.

llvm-svn: 167627
2012-11-09 19:40:39 +00:00
Argyrios Kyrtzidis 870704f6ef When code-completing don't disable the preprocessing record if modules are enabled.
llvm-svn: 167325
2012-11-02 22:18:44 +00:00
Argyrios Kyrtzidis d7c16b2543 [PCH] Remove the stat cache from the PCH file.
The stat cache became essentially useless ever since we started
validating all file entries in the PCH.
But the motivating reason for removing it now is that it also affected
correctness in this situation:

-You have a header without include guards (using "#pragma once" or #import)
-When creating the PCH:
  -The same header is referenced in an #include with different filename cases.
  -In the PCH, of course, we record only one file entry for the header file
  -But we cache in the PCH file the stat info for both filename cases

-Then the source files are updated and the header file is updated in a way that
 its size and modification time are the same but its inode changes

-When using the PCH:
  -We validate the headers, we check that header file and we create a file entry with its current inode
  -There's another #include with a filename with different case than the previously created file entry
  -In order to get its stat info we go through the cached stat info of the PCH and we receive the old inode
  -because of the different inodes, we think they are different files so we go ahead and include its contents.

Removing the stat cache will potentially break clients that are attempting to use the stat cache
as a way of avoiding having the actual input files available. If that use case is important, patches are welcome
to bring it back in a way that will actually work correctly (i.e., emit a PCH that is self-contained, coping with
literal strings, line/column computations, etc.).

This fixes rdar://5502805

llvm-svn: 167172
2012-10-31 20:59:50 +00:00
Argyrios Kyrtzidis 3a6c8141f9 Decouple code-completion for the SkipFunctionBodies frontend option and
add a test to make sure code-completion skips bodies.

llvm-svn: 167141
2012-10-31 17:29:22 +00:00
Rafael Espindola e878343c12 Move getOriginalSourceFileName inline. Patch by Laszlo Nagy.
llvm-svn: 166981
2012-10-29 23:26:40 +00:00
Douglas Gregor d02437c902 ASTUnit doesn't actually care about the predefines; don't record them.
llvm-svn: 166650
2012-10-25 00:09:28 +00:00
Douglas Gregor 1452ff155b Teach the preprocessor to hold onto the preprocessor options.
llvm-svn: 166599
2012-10-24 17:46:57 +00:00