Commit Graph

65 Commits

Author SHA1 Message Date
Dmitri Gribenko ab458a13b0 Use cstdio instead of stdio.h
llvm-svn: 188678
2013-08-19 16:14:33 +00:00
Dmitri Gribenko 96933de7f5 libclang: cleanup unused includes in public header
llvm-svn: 188625
2013-08-18 07:57:43 +00:00
Alexey Samsonov c04b5cdbca Assume UniqueID is zero for invalid PPRegion to fix uninitialized reads reported by MSan
llvm-svn: 187647
2013-08-02 09:06:39 +00:00
Rafael Espindola f8f91b8976 Use llvm::sys::fs::UniqueID for windows and unix.
This unifies the unix and windows versions of FileManager::UniqueDirContainer
and FileManager::UniqueFileContainer by using UniqueID.

We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we
want to be able to construct fake ones, and file_status has different members
on unix and windows.

What the patch does is:

* Record only the information that clang is actually using.
* Use llvm::sys::fs::status instead of stat and fstat.
* Use llvm::sys::fs::UniqueID
* Delete the old windows versions of UniqueDirContainer and
UniqueFileContainer since the "unix" one now works on windows too.

llvm-svn: 187619
2013-08-01 21:42:11 +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
Argyrios Kyrtzidis 37e48ff547 [Preprocessor] For the MacroExpands preprocessor callback, also pass the MacroArgs object that provides information about
the argument tokens for a function macro.

llvm-svn: 181065
2013-05-03 22:31:32 +00:00
Argyrios Kyrtzidis 828f4d4b9f [libclang] If libclang logging is enabled, print all compiler diagnostics to stderr instead of capturing them.
llvm-svn: 178373
2013-03-29 21:51:44 +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 7489521eec libclang: remove 'using namespace cxstring'
llvm-svn: 174285
2013-02-03 13:52:47 +00:00
Evgeniy Stepanov 8660623576 Attempt to fix Windows build breakage.
llvm-svn: 174060
2013-01-31 14:27:38 +00:00
Dmitri Gribenko 183436e5b6 libclang: type safety for CXTranslationUnitImpl::CIdx
llvm-svn: 173590
2013-01-26 21:49:50 +00:00
Dmitri Gribenko c22ea1ce88 libclang: factor out the frequent pattern static_cast<ASTUnit *>(TU->TUData)
into a getter cxtu::getASTUnit(TU)

llvm-svn: 173585
2013-01-26 18:53:38 +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
Chandler Carruth 4b41745e05 Re-sort all the headers. Lots of regressions have crept in here.
Manually fix the order of UnwrappedLineParser.cpp as that one didn't
have its associated header as the first header.

This also uncovered a subtle inclusion order dependency as CLog.h didn't
include LLVM.h to pick up using declarations it relied upon.

llvm-svn: 172892
2013-01-19 08:09:44 +00:00
Argyrios Kyrtzidis ea47435861 [libclang] Enhance logging capabilities of libclang.
-provide a "raw_ostream'ish" class to make it convenient to output logging info.
-use macros to automate a bit the logging functionality inside libclang functions
-when logging, print a stack trace if "LIBCLANG_LOGGING=2" environment is set.
-add logging to more functions.

llvm-svn: 172089
2013-01-10 18:54:52 +00:00
Chandler Carruth 44eb4f66f4 Re-sort #include lines using the llvm/utils/sort_includes.py script.
Removes a duplicate #include as well as cleaning up some sort order
regressions since I last ran the script over Clang.

llvm-svn: 171364
2013-01-02 10:28:36 +00:00
Argyrios Kyrtzidis 8b71bc7d6b [libclang] Introduce a new indexing mode where we skip function bodies
that were already parsed in the same "indexing session".

An indexing session is defined as using the same CXIndexAction object
for multiple clang_indexSourceFile calls.
Passing CXIndexOpt_SkipParsedBodiesInSession as an indexing option will
enable the mode where we try to skip bodies that were already parsed in
another translation unit.

If a function's body was skipped, the "flags" field in the CXIdxDeclInfo
structure will have "CXIdxDeclFlag_Skipped" bit was set.

llvm-svn: 169539
2012-12-06 19:41:16 +00:00
Chandler Carruth cc0694c8a4 Sort #include lines for tools/...
Completely automated with sort_includes.py

llvm-svn: 169240
2012-12-04 09:25:21 +00:00
Douglas Gregor 811db4eac4 Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.

llvm-svn: 166508
2012-10-23 22:26:28 +00:00
Argyrios Kyrtzidis 5e2ec486bb [libclang] Invoke a ppIncludedFile callback when indexing implicit module imports.
llvm-svn: 166161
2012-10-18 00:17:05 +00:00
Argyrios Kyrtzidis 15f6b8ebe8 Disable the preprocessing record when indexing a source file
and modules are not enabled.

llvm-svn: 165593
2012-10-10 02:12:50 +00:00
Argyrios Kyrtzidis e445c7236e When indexing a module file, for the ppIncludedFile callback give
an invalid location if the location points to the synthetic buffer
for the module input.

llvm-svn: 165592
2012-10-10 02:12:47 +00:00
Argyrios Kyrtzidis 6a80e7564f [libclang] Don't disable the preprocessing record while indexing so as
to not mess up with module building.

It was not worth trying to combine indexing without preprocessing record
and building modules with one because:

-just importing a module/PCH that was built with a pp record, enables it anyway
-the performance gain of indexing without the preprocessing record is insignificant.

llvm-svn: 165352
2012-10-06 01:18:35 +00:00
Argyrios Kyrtzidis f484b139db [libclang] When indexing, invoke the importedASTFile for PCH files as well.
llvm-svn: 165161
2012-10-03 21:05:51 +00:00
Argyrios Kyrtzidis 184b14428e [libclang] Simplify indexing of module imports by handling implicit
imports via ImportDecls.

llvm-svn: 165160
2012-10-03 21:05:44 +00:00
Argyrios Kyrtzidis e514b200aa Some renames to use the 'visitor' nomenclature, no functionality change.
llvm-svn: 165083
2012-10-03 01:58:28 +00:00
Argyrios Kyrtzidis 10e7846abf [libclang] When indexing an AST file, only deserialize the file level
declarations of the current primary module.

llvm-svn: 165046
2012-10-02 21:09:13 +00:00
Argyrios Kyrtzidis d4fcf58070 [libclang] When indexing an AST file, only deserialize the preprocessing record
entities of the current primary module.

llvm-svn: 165023
2012-10-02 16:10:51 +00:00
Argyrios Kyrtzidis f590e094ad Add info in the preprocessing record whether an inclusion directive
resulted in an automatic module import.

llvm-svn: 165022
2012-10-02 16:10:46 +00:00
Argyrios Kyrtzidis b36ee5c592 [libclang] Even though we disable the preprocessing record during indexing,
make sure that it gets enabled for when a module needs to be created.

llvm-svn: 165021
2012-10-02 16:10:41 +00:00
Argyrios Kyrtzidis 472eda06b0 [libclang] Implement the importedASTFile indexing callback to provide
info about imported modules.

llvm-svn: 165020
2012-10-02 16:10:38 +00:00
Argyrios Kyrtzidis 19d78b743f For PPCallbacks::InclusionDirective() add a parameter for the module, whenever
an inclusion directive was automatically turned into a module import, and
PPCallbacks::moduleImport() for an explicit module import.

llvm-svn: 164874
2012-09-29 01:06:10 +00:00
Argyrios Kyrtzidis 4fcd2885de Per discussion in http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120917/064551.html
have PPCallbacks::InclusionDirective pass the character range for the filename quotes or brackets.

rdar://11113134 & http://llvm.org/PR13880

llvm-svn: 164743
2012-09-27 01:42:07 +00:00
Argyrios Kyrtzidis 341de09dcd [libclang] Do a AST concurrency check in clang_indexTranslationUnit_Impl.
llvm-svn: 164626
2012-09-25 19:29:50 +00:00
Argyrios Kyrtzidis 6d7833f1b6 Introduce a flag in SourceManager to treat non-system source files
as "volatile", meaning there's a high enough chance that they may
change while we are trying to use them.

This flag is only enabled by libclang.
Currently "volatile" source files will be stat'ed immediately
before opening them, because the file size stat info
may not be accurate since when we got it (e.g. from the PCH).
This avoids crashes when trying to reference mmap'ed memory
from a file whose size is not what we expect.

Note that there's still a window for a racing issue to occur
but the window for it should be way smaller than before.
We can consider later on to avoid mmap completely on such files.

rdar://11612916

llvm-svn: 160074
2012-07-11 20:59:04 +00:00
Argyrios Kyrtzidis 30a2432682 [libclang] Don't bind a StringRef to a temporary std::string object.
It may end up pointing at garbage.

Fixes the MSVC debug build. rdar://11703319

llvm-svn: 159377
2012-06-28 21:03:08 +00:00
Argyrios Kyrtzidis ac1cc934b3 [libclang] If displayDiagnostics is set (when calling clang_createIndex), make sure to
output the errors that occurred even if we did not get an AST (e.g. because the
PCH failed to load).

Also honor displayDiagnostics in clang_indexSourceFile().

rdar://11203489

llvm-svn: 154472
2012-04-11 02:11:16 +00:00
Argyrios Kyrtzidis 58d5f3fdad [libclang] Rename setBackGroundPriority -> setThreadBackgroundPriority.
llvm-svn: 153566
2012-03-28 02:49:54 +00:00
Argyrios Kyrtzidis 7317a5cbfc [libclang] Introduce options to control the priority for the threads
that libclang creates.

-Introduce CXGlobalOptFlags enum for the new options that can be
 set on the CXIndex object.

-CXGlobalOpt_ThreadBackgroundPriorityForIndexing affects:
  clang_indexSourceFile
  clang_indexTranslationUnit
  clang_parseTranslationUnit
  clang_saveTranslationUnit

-CXGlobalOpt_ThreadBackgroundPriorityForEditing affects:
  clang_reparseTranslationUnit
  clang_codeCompleteAt
  clang_annotateTokens

rdar://9075282

llvm-svn: 153562
2012-03-28 02:18:05 +00:00
Argyrios Kyrtzidis 6c9ed7d804 [libclang] Introduce indexing option CXIndexOpt_SuppressWarnings, which
disables all compiler warnings.

rdar://11059556

llvm-svn: 153539
2012-03-27 21:38:03 +00:00
Argyrios Kyrtzidis 4a280ff48f [PCH] Mark a PCH file with a flag to indicate if the serialized AST had
compiler errors or not.

-Control whether ASTReader should reject such a PCH by a boolean flag at ASTReader's creation time.
By default, such a PCH file will be rejected with an error when trying to load it.

[libclang] Allow clang_saveTranslationUnit to create a PCH file even if compiler errors
occurred.
-Have libclang API calls accept a PCH that had compiler errors.

The general idea is that we want libclang to stay functional even if a PCH had a compiler error.
rdar://10976363.

llvm-svn: 152192
2012-03-07 01:51:17 +00:00
Argyrios Kyrtzidis 93db2923da [libclang] When indexing an objc property, also provide information about
the getter/setter objc method entities that the property is associated with.

rdar://10244558

llvm-svn: 151634
2012-02-28 17:50:33 +00:00
Argyrios Kyrtzidis 335c5a42e9 Don't record nested macro expansions in the preprocessing record,
it can only bring pain when dealing with preprocessor abuse (see: boost).

rdar://10898986

llvm-svn: 151427
2012-02-25 02:41:16 +00:00
Dylan Noblesmith c95d81924d Basic: import IntrusiveRefCntPtr<> into clang namespace
The class name is long enough without the llvm:: added.
Also bring in RefCountedBase and RefCountedBaseVPTR.

llvm-svn: 150958
2012-02-20 14:00:23 +00:00
Argyrios Kyrtzidis 7e747957cd [libclang] Indexing: only index implicit template instantiations via an opt-in indexing option.
llvm-svn: 150517
2012-02-14 22:23:11 +00:00
Dylan Noblesmith 1cd1069b68 drop more llvm:: prefixes on OwningPtr<>
More cleanup after r149798.

llvm-svn: 150379
2012-02-13 12:32:21 +00:00
Argyrios Kyrtzidis e5dc5b31f2 [libclang] Indexing API: Fully index implict template instantiations.
llvm-svn: 150267
2012-02-10 20:10:44 +00:00
Douglas Gregor 32fbe31246 Extract the (InputKind, std::string) pair used to describe inputs to
the front end into its own class, FrontendInputFile, to make it easier
to introduce new per-input data. No functionality change.

llvm-svn: 148546
2012-01-20 16:28:04 +00:00
Argyrios Kyrtzidis da6e05476d [libclang] Make sure Preprocessor is set in ASTUnit during indexing.
llvm-svn: 148319
2012-01-17 18:48:07 +00:00
Argyrios Kyrtzidis 9b9f7a9f7a [libclang] Indexing API: Provide the protocols list for objc categories as well.
rdar://10573361

llvm-svn: 146498
2011-12-13 18:47:45 +00:00