Commit Graph

1966 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 173e911394 [libclang] Add defensive checks to make sure we don't try to dereference
a null pointer after getCursorDecl() is called. rdar://10298421.

llvm-svn: 146312
2011-12-10 02:36:25 +00:00
Ted Kremenek b4a8b056f8 Add clang_getDiagnosticSetFromTU() to libclang. Fixes <rdar://problem/10553081>.
llvm-svn: 146287
2011-12-09 22:28:32 +00:00
Ted Kremenek 2d6d886d73 Sort exports list.
llvm-svn: 146286
2011-12-09 22:28:29 +00:00
Argyrios Kyrtzidis 4996f5fba2 Save category name loc in ObjCCategoryImplDecl, patch by Jason Haslam!
llvm-svn: 146213
2011-12-09 00:31:40 +00:00
Argyrios Kyrtzidis fa469d0efd [libclang] Make sure we don't try to handle a CXCursor_NoDeclFound
passed to clang_findReferencesInFile.

llvm-svn: 146211
2011-12-09 00:17:49 +00:00
Eli Friedman 83de51301a Misc Minix-specific changes to clang:
. move compiler-rt to a separate directory so the -L argument only includes compiler-rt (thanks joerg)
. build all clang subdirs
. switches the Minix platform to ELF
. normalizes toolchain invocation

Patch by Ben Gras.

llvm-svn: 146206
2011-12-08 23:54:21 +00:00
Argyrios Kyrtzidis 831411f42b [libclang] When doing clang_findReferencesInFile, make sure we don't crash
if we come up against a null Decl.

No test case unfortunately. rdar://10457799.

llvm-svn: 146127
2011-12-08 01:56:07 +00:00
Argyrios Kyrtzidis bf1d884d9e [libclang] Remove IndexingContext's getScopedContext(), it's not useful
now that client containers can be set via function calls.

llvm-svn: 146117
2011-12-08 00:54:07 +00:00
Argyrios Kyrtzidis 663c8ecda1 [libclang] Indexing API: provide both the semantic and the lexical container.
They are generally the same except in C++ cases like out-of-line member functions.

llvm-svn: 146069
2011-12-07 20:44:19 +00:00
Argyrios Kyrtzidis b3c16bad20 [libclang] Fix indexing of C++ bases in a C++ class.
llvm-svn: 146068
2011-12-07 20:44:15 +00:00
Argyrios Kyrtzidis 520028802c [libclang] Introduce CXIdxEntityLanguage that indicates the language
of an indexed entity.

llvm-svn: 146067
2011-12-07 20:44:12 +00:00
Argyrios Kyrtzidis 2b0b43cf56 [libclang] Index C++ namespaces.
llvm-svn: 146019
2011-12-07 05:52:06 +00:00
Ted Kremenek 9c9e81085f Tweak serialized diagnostics to support errors with no categories. Fixes <rdar://problem/10538300>.
llvm-svn: 146011
2011-12-07 02:08:00 +00:00
Argyrios Kyrtzidis 66f433a746 [libclang] API enhancements by Joe Groff!
- Exposes a CXType_Vector type kind for vector types.
- Adds generalized versions of the clang_getArrayElementType and clang_getArraySize functions, named clang_getElementType and clang_getNumElements, which work on array, vector, or complex types.
- Adds additional functions for querying function types. clang_isFunctionTypeVariadic returns true if a function type is variadic. clang_getFunctionCallingConv returns an enumeration value indicating the calling convention of the function type. clang_getNumArgTypes returns the number of static argument types, and clang_getArgType gets the type of an argument.
- Adds a clang_getTypedefDeclUnderlyingType function to get the underlying type from a TypedefDecl cursor.
- Adds a clang_getEnumDeclIntegerType function to get the integer type from an EnumDecl cursor.
- Adds clang_getEnumConstantDeclValue and clang_getEnumConstantDeclUnsignedValue functions to get the value of an EnumConstantDecl as a signed or unsigned long long, respectively.
- Exposes a CXCursor_AsmLabelAttr cursor kind for __asm__("label") attributes.
- Alters clang_getCursorSpelling to return the label value for AsmLabelAttr-kind cursors.

llvm-svn: 145972
2011-12-06 22:05:01 +00:00
Argyrios Kyrtzidis 1a10f29b2f [libclang] When indexing a field in a C++ class, return an entity
of kind CXIdxEntity_CXXInstanceVariable. rdar://10522503.

llvm-svn: 145859
2011-12-05 22:05:28 +00:00
Argyrios Kyrtzidis 0042b6f925 [libclang] Fix infinite loop when doing visitation of an OpaqueValueExpr.
llvm-svn: 145751
2011-12-03 03:49:47 +00:00
Argyrios Kyrtzidis 0fd8fae0a6 [libclang] Allow indexing/get-cursor/etc. for the exception variable in a C++ catch.
llvm-svn: 145750
2011-12-03 03:49:44 +00:00
Douglas Gregor ba34552e79 Introduce a module import declaration, so that we properly represent, e.g.,
__import_module__ std.vector;

in the AST.

llvm-svn: 145725
2011-12-02 23:23:56 +00:00
Argyrios Kyrtzidis f2d99b0d38 [libclang] Create a diagnostic set to pass at the end of indexing.
llvm-svn: 145557
2011-12-01 02:42:50 +00:00
Argyrios Kyrtzidis ebbb20628a [libclang] Do the ConcurrencyCheck at the beginning of clang_findReferencesInFile.
llvm-svn: 145455
2011-11-29 23:21:50 +00:00
Benjamin Kramer 7f107eeea5 Preserve constness.
llvm-svn: 145397
2011-11-29 12:31:20 +00:00
Benjamin Kramer 696894a35b Silence GCC warnings, RefCountedBase is meant to be default-initialized here.
llvm-svn: 145396
2011-11-29 11:31:35 +00:00
Argyrios Kyrtzidis 6e210232ab [libclang] Fix leak in clang_indexSourceFile_Impl
llvm-svn: 145393
2011-11-29 08:14:50 +00:00
Argyrios Kyrtzidis 1ddb97ec86 [libclang] Make clang_findReferencesInFile also work on macros (find all expansions/definition
of a macro in a file).

As a bonus, also make searching for declarations more efficient by ignoring
preprocessing entities when we know that we are looking for a declaration.

Fixes rdar://10427411.

llvm-svn: 145369
2011-11-29 03:14:11 +00:00
Ted Kremenek 6cdff0a82b Fix serialized diagnostics to handle FixIts that only remove text. Fixes <rdar://problem/10473903>.
llvm-svn: 145339
2011-11-29 00:30:52 +00:00
Argyrios Kyrtzidis a3ec8e82c8 [libclang] Protect against the declaration's SourceRange being invalid
before passing to RangeCompare.

Though no idea how this can occur with the decls returned from
findFileRegionDecls().

llvm-svn: 145301
2011-11-28 22:38:07 +00:00
Bob Wilson bd0fbe86c5 Install c-index-test and clang-c/Index.h as internal files. rdar://10217046
Specify that these files should be installed to the optional internal
install location as specified by configure's --with-internal-prefix.
If that option is not used, they'll be installed to the default prefix
as before.

llvm-svn: 145235
2011-11-28 08:03:54 +00:00
Argyrios Kyrtzidis b11f5a4cbb [libclang] Indexing API: If the client requested to get a CXTranslationUnit after
indexing, honor all the TU options.

llvm-svn: 145229
2011-11-28 04:56:00 +00:00
Argyrios Kyrtzidis 67aa7db0a4 [libclang] Indexing API: Capture diagnostics during indexing.
llvm-svn: 145228
2011-11-28 04:55:55 +00:00
Argyrios Kyrtzidis 8ad3bab505 [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.

When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.

Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.

llvm-svn: 145109
2011-11-23 20:27:36 +00:00
Argyrios Kyrtzidis 41fc05cad8 [libclang] Indexing API: Fix issues, mostly C++ related.
llvm-svn: 145107
2011-11-23 20:27:26 +00:00
Argyrios Kyrtzidis 4c910b1475 [libclang] Indexing API: Support C++ symbols.
llvm-svn: 145058
2011-11-22 07:24:51 +00:00
Peter Collingbourne 17a7bbbc9f Create the clang++ symlink as a POST_BUILD custom command on clang.
This saves us from re-creating the symlink on every build even if we
didn't rebuild clang.

llvm-svn: 145017
2011-11-21 00:00:48 +00:00
NAKAMURA Takumi 2a4859aeff c-index-test.c: Fix syntax according to C.
llvm-svn: 144947
2011-11-18 00:51:03 +00:00
Argyrios Kyrtzidis 841dd8861a Change ASTConsumer::HandleTopLevelDecl to return true for the parser to continue
parsing or false to abort parsing.

llvm-svn: 144943
2011-11-18 00:26:59 +00:00
Argyrios Kyrtzidis effdbf55ac [libclang] Indexing API:
-For indexDeclaration, also pass the declaration attributes as an array of cursors.
-Rename CXIndexOpt_OneRefPerFile -> CXIndexOpt_SuppressRedundantRefs, and only pass
  a reference if a declaration/definition does not exist in the file.
-Other fixes.

llvm-svn: 144942
2011-11-18 00:26:51 +00:00
Argyrios Kyrtzidis 1cff795e51 [libclang] Indexing API: make sure we don't pass declarations/references without USR or location.
llvm-svn: 144941
2011-11-18 00:26:46 +00:00
Ted Kremenek 8cf47df72f Make 'LangOptions' in CompilerInvocation a heap-allocated, reference counted object. I discovered that llvm::RefCountedBase<T> has
a bug where the reference count is copied in the copy constructor, which means that there were cases when the CompilerInvocation
objects created by ASTUnit were actually leaked.  When I fixed that bug locally, it showed that a whole bunch of code assumed
that the LangOptions object that was part of CompilerInvocation was still alive.  By making it heap-allocated and reference counted,
we can keep it around after the CompilerInvocation object goes away.

As part of this change, change CompilerInvocation:getLangOptions() to return a pointer, acting as another clue that this
object may outlive the CompilerInvocation object.

This commit doesn't fix the CompilerInvocation leak itself.  That will come when I commit the fix to llvm::RefCountedBase<T> to
mainline LLVM.

llvm-svn: 144930
2011-11-17 23:01:24 +00:00
Argyrios Kyrtzidis 7ae5d9c4c0 [libclang] Add a comment in lazyCreateDiags to explain why the check and reset of
diagnostic set is necessary.

llvm-svn: 144793
2011-11-16 08:59:00 +00:00
Argyrios Kyrtzidis 463741a5a2 [libclang] Make clang_annotateTokens use "file-targeted" deserialization and avoid
unnecessary deserializations.

llvm-svn: 144792
2011-11-16 08:58:57 +00:00
Argyrios Kyrtzidis c504eb3448 [libclang] Make clang_findReferencesInFile use "file-targeted" deserialization and avoid
unnecessary deserializations.

llvm-svn: 144791
2011-11-16 08:58:54 +00:00
Ted Kremenek 0e9843b328 Teach ccc-analyzer about -fobjc-arc.
llvm-svn: 144778
2011-11-16 05:14:42 +00:00
Argyrios Kyrtzidis df15c20979 [libclang] Indexing API: fill the objc category info for a category implementation and
do not crash if no client container is registered for a declaration context.

llvm-svn: 144765
2011-11-16 02:35:05 +00:00
Argyrios Kyrtzidis d7b8790003 [libclang] Indexing API: make sure we do not try to index local declarations.
llvm-svn: 144764
2011-11-16 02:35:01 +00:00
Argyrios Kyrtzidis e4acd23f0b [libclang] Indexing API: if the CXIndexOpt_OneRefPerFile option is set, only report one reference
per file.

llvm-svn: 144763
2011-11-16 02:34:59 +00:00
Argyrios Kyrtzidis f03e734876 [libclang] In lazyCreateDiags, recreate the diagnostic set if the number of diagnostics
in the ASTUnit changed.

llvm-svn: 144762
2011-11-16 02:34:55 +00:00
Argyrios Kyrtzidis 233f12d9e2 [libclang] Indexing API: Pass an implicit ObjCInterfaceDecl (@implementation without @interface)
in a separate indexing callback than its implementation.

llvm-svn: 144625
2011-11-15 06:20:24 +00:00
Argyrios Kyrtzidis d992e14394 [libclang] Introduce a new function to apply the indexing callbacks on an existing
CXTranslationUnit, mainly to be used for indexing a PCH.

llvm-svn: 144623
2011-11-15 06:20:16 +00:00
Ted Kremenek ec9b50d961 Fix potential memory leak for clients of clang_getOverriddenCursors(). If the number of overriden cursors is 0, do not allocate an array of CXCursors. This fixes a memory leak in c-index-test, and clients who use this API in a similar way.
llvm-svn: 144595
2011-11-14 23:51:37 +00:00
Argyrios Kyrtzidis 86acd72bd2 [libclang] Slight changes to the indexing API and bigger internal changes for it.
llvm-svn: 144577
2011-11-14 22:39:19 +00:00