Commit Graph

1741 Commits

Author SHA1 Message Date
Oscar Fuentes 15fe190027 Put targets on folders, if the IDE supports the feature.
Requires CMake 2.8.3 or newer.

llvm-svn: 126094
2011-02-20 22:06:44 +00:00
Richard Smith 30482bc786 Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.

llvm-svn: 126069
2011-02-20 03:19:35 +00:00
Peter Collingbourne 8f5cf74c77 Re-instate r125819 and r125820 with no functionality change
llvm-svn: 126060
2011-02-19 23:03:58 +00:00
Rafael Espindola a6d2bff0c5 Revert 125820 and 125819 to fix PR9266.
llvm-svn: 126050
2011-02-19 21:39:31 +00:00
Peter Collingbourne 14a552b2d7 Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction
This removes the final dependency edge from any lib outside of CodeGen
to core.  As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.

llvm-svn: 125820
2011-02-18 02:25:12 +00:00
John McCall c07a0c7e48 Change the representation of GNU ?: expressions to use a different expression
class and to bind the shared value using OpaqueValueExpr.  This fixes an
unnoticed problem with deserialization of these expressions where the
deserialized form would lose the vital pointer-equality trait;  or rather,
it fixes it because this patch also does the right thing for deserializing
OVEs.

Change OVEs to not be a "temporary object" in the sense that copy elision is
permitted.

This new representation is not totally unawkward to work with, but I think
that's really part and parcel with the semantics we're modelling here.  In
particular, it's much easier to fix things like the copy elision bug and to
make the CFG look right.

I've tried to update the analyzer to deal with this in at least some          
obvious cases, and I think we get a much better CFG out, but the printing
of OpaqueValueExprs probably needs some work.

llvm-svn: 125744
2011-02-17 10:25:35 +00:00
Chris Lattner c8e630e4db Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.

llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Ted Kremenek 42ec914ff8 Begin overhaul of scan-build/ccc-analyzer's handling of checker options.
We now rely on 'clang --analyze' to provide the default set of checkers.  We're
still working on the new '-analyzer-checker <checker>' interface, and once
that's ready we'll wire it up to scan-build.

llvm-svn: 125712
2011-02-17 02:28:30 +00:00
Douglas Gregor 162b712d38 Teach the CXCodeCompleteResults results structure, which stores
code-completion results accessed via libclang, to extend the lifetime
of the allocator used for cached global code-completion results at
least until these completion results are destroyed. Fixes
<rdar://problem/8997369>.

llvm-svn: 125678
2011-02-16 19:08:06 +00:00
Argyrios Kyrtzidis ecd3334dac [analyzer] Introduce libclangStaticAnalyzerFrontend and move Checkers/AnalysisConsumer.cpp into Frontend lib.
llvm-svn: 125499
2011-02-14 18:13:01 +00:00
John McCall 8322c3a197 Give some convenient idiomatic accessors to Stmt::child_range and
Stmt::const_child_range, then make a bunch of places use them instead
of the individual iterator accessors.

llvm-svn: 125450
2011-02-13 04:07:26 +00:00
Jeffrey Yasskin c498878e6d Add CMake dependencies so that LLVM_USED_LIBS order doesn't matter.
I also sorted the tools/driver dependencies since their order no
longer matters.

llvm-svn: 125417
2011-02-11 23:46:38 +00:00
NAKAMURA Takumi 98dd73d66c CMake: LLVM_NO_RTTI must be obsolete now!
llvm-svn: 125275
2011-02-10 09:15:32 +00:00
Peter Collingbourne 41f8546233 AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actions
llvm-svn: 125217
2011-02-09 21:07:24 +00:00
John McCall bd06678921 Remove vtables from the Stmt hierarchy; this was pretty easy as
there were only three virtual methods of any significance.

The primary way to grab child iterators now is with
  Stmt::child_range children();
  Stmt::const_child_range children() const;
where a child_range is just a std::pair of iterators suitable for
being llvm::tie'd to some locals.  I've left the old child_begin()
and child_end() accessors in place, but it's probably a substantial
penalty to grab the iterators individually now, since the
switch-based dispatch is kindof inherently slower than vtable
dispatch.  Grabbing them together is probably a slight win over the
status quo, although of course we could've achieved that with vtables, too.

I also reclassified SwitchCase (correctly) as an abstract Stmt
class, which (as the first such class that wasn't an Expr subclass)
required some fiddling in a few places.

There are somewhat gross metaprogramming hooks in place to ensure
that new statements/expressions continue to implement
getSourceRange() and children().  I had to work around a recent clang
bug;  dgregor actually fixed it already, but I didn't want to
introduce a selfhosting dependency on ToT.

llvm-svn: 125183
2011-02-09 08:16:59 +00:00
Ted Kremenek fffba74477 No longer pass deprecated '-nodistribute' flag to xcodebuild.
llvm-svn: 125131
2011-02-08 22:54:30 +00:00
Oscar Fuentes ced8836182 CLANG_BINARY_DIR is not the same thing as LLVM_BINARY_DIR when Clang
is built as part of LLVM.

llvm-svn: 124982
2011-02-06 15:33:08 +00:00
Oscar Fuentes 1b6a38e3c6 Remove the clang++ symlink with `make clean'.
llvm-svn: 124974
2011-02-05 21:37:37 +00:00
Oscar Fuentes c9fe3b94a5 CMake: libclang shall be named libclang.so, not liblibclang.so.
It is not possible to simply change that target name to `clang'
because we already have one.

llvm-svn: 124972
2011-02-05 20:00:13 +00:00
Ted Kremenek 359c4a1369 Don't crash when generating USRs for ObjC methods in protocols.
llvm-svn: 124920
2011-02-05 01:10:26 +00:00
Ted Kremenek 05edf944c0 USRs for Objective-C methods use the USR of the @interface as their base, not the USR of the class category or extension.
llvm-svn: 124859
2011-02-04 07:13:40 +00:00
Douglas Gregor 149239651d If any Fix-Its attached to a diagnostic have invalid source locations
or source locations that refer into a macro instantiation, delete all
of the Fix-Its on that diagnostic.

llvm-svn: 124833
2011-02-03 23:41:12 +00:00
Douglas Gregor e664276bcf Teach SourceManager::getLocation() how to cope with a source file
whose inode has changed since the file was first created and that is
being seen through a different path name (e.g., due to symlinks or
relative path elements), such that its FileEntry pointer doesn't match
a known FileEntry pointer. Since this requires a system call (to
stat()), we only perform this deeper checking if we can't find the
file by comparing FileEntry pointers.

Also, add a micro-optimization where we don't bother to compute line
numbers when given the location (1, 1). This improves the
efficiency of clang_getLocationForOffset().
 

llvm-svn: 124800
2011-02-03 17:17:35 +00:00
Daniel Dunbar ac540b3859 clang: Add support for a CC_PRINT_HEADERS environment variable, which mirrors
CC_PRINT_OPTIONS and can be used to get some out-of-band information on header
usage from a build.

llvm-svn: 124751
2011-02-02 21:11:35 +00:00
Douglas Gregor 6c7cb188e9 Fix name lookup issue
llvm-svn: 124700
2011-02-01 23:14:23 +00:00
Douglas Gregor bcbf46c7b7 Create a special allocator class for code completion, so that all of
the string copying goes through a single place that can have
associated state.

llvm-svn: 124698
2011-02-01 22:57:45 +00:00
Ted Kremenek 1dd5646da0 Enable the self-init checker in scan-build.
llvm-svn: 124696
2011-02-01 22:36:11 +00:00
Douglas Gregor b278aafbfb Allocate CodeCompletionString and all of its components in a
BumpPtrAllocator, rather than manually new/delete'ing them. This
optimization also allows us to avoid allocating memory for and copying
constant strings (e.g., "return", "class").

This also required embedding the priority and availability of results
within the code completion string, to avoid extra memory allocation
within libclang.

llvm-svn: 124673
2011-02-01 19:23:04 +00:00
Douglas Gregor 7a964ad4ce Teach Diagnostic::setClient() to free the existing, owned
client. Fixes a libclang leak.

llvm-svn: 124614
2011-01-31 22:04:05 +00:00
Douglas Gregor ffd6dc432e Teach ASTUnit to save the specified target features, since
TargetInfo::CreateTargetInfo() mangles the target options in a way
that is not idempotent. Fixes <rdar://problem/8807535>.

llvm-svn: 124382
2011-01-27 18:02:58 +00:00
Douglas Gregor 56a6380cb7 Add libclang functions to determine the const/volatile/restrict
qualifiers on a CXType. Patch from Stefan Seefeld, test by me.

llvm-svn: 124377
2011-01-27 16:27:11 +00:00
Douglas Gregor 62c3134629 Eliminate the use of getTypeForDecl from clang_getCursorType() and
clang_getDeclObjCTypeEncoding(); use ASTContext's methods instead,
which will (lazily) create the type as needed. Otherwise, we can end
up with null QualTypes.

llvm-svn: 124133
2011-01-24 18:44:28 +00:00
Rafael Espindola 148141c98f Add support for the --noexecstack option. Fixes PR8762.
llvm-svn: 124078
2011-01-23 17:58:26 +00:00
Douglas Gregor 54bce44895 Teach libclang to generate USRs containing parameter packs and pack expansions.
llvm-svn: 123848
2011-01-19 20:50:07 +00:00
Douglas Gregor 557f05c2d2 Teach libclang about SizeOfPackExpr.
llvm-svn: 123846
2011-01-19 20:34:17 +00:00
John McCall 424cec97bd Change QualType::getTypePtr() to return a const pointer, then change a
thousand other things which were (generally inadvertantly) relying on that.

llvm-svn: 123814
2011-01-19 06:33:43 +00:00
Douglas Gregor 345c1bcb80 Don't silently drop warning flags passed in to
clang_createTranslationUnitFromSourceFile().

llvm-svn: 123793
2011-01-19 01:02:47 +00:00
Jeffrey Yasskin 8dfa5f1776 Fix warnings found by gcc-4.6, from -Wunused-but-set-variable and
-Wint-to-pointer-cast.

llvm-svn: 123719
2011-01-18 02:00:16 +00:00
Douglas Gregor a09c6cca72 Add missing <cctype> include, from Joerg Sonnenberger
llvm-svn: 123668
2011-01-17 19:15:43 +00:00
Douglas Gregor 5590be0491 Introduce a new kind of TemplateName that captures a substituted
template template parameter pack that cannot be fully expanded because
its enclosing pack expansion could not be expanded. This form of
TemplateName plays the same role as SubstTemplateTypeParmPackType and
SubstNonTypeTemplateParmPackExpr do for template type parameter packs
and non-type template parameter packs, respectively.

We should now handle these multi-level pack expansion substitutions
anywhere. The largest remaining gap in our variadic-templates support
is that we cannot cope with non-type template parameter packs whose
type is a pack expansion.

llvm-svn: 123521
2011-01-15 06:45:20 +00:00
Douglas Gregor cdbc539aee Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,
that captures the substitution of a non-type template argument pack
for a non-type template parameter pack within a pack expansion that
cannot be fully expanded. This follows the approach taken by
SubstTemplateTypeParmPackType.

llvm-svn: 123506
2011-01-15 01:15:58 +00:00
Zhongxing Xu 40c9d8a4c5 Revert r123160. There are linking dependency problems.
llvm-svn: 123166
2011-01-10 09:23:01 +00:00
Alexis Hunt 1d7926502f Renamed CXXBaseOrMemberInitializer to CXXCtorInitializer. This is both shorter,
more accurate, and makes it make sense for it to hold a delegating constructor
call.

llvm-svn: 123084
2011-01-08 20:30:50 +00:00
Douglas Gregor e4ff4b56fe Replace the representation of template template argument pack
expansions with something that is easier to use correctly: a new
template argment kind, rather than a bit on an existing kind. Update
all of the switch statements that deal with template arguments, fixing
a few latent bugs in the process. I"m happy with this representation,
now.

And, oh look! Template instantiation and deduction work for template
template argument pack expansions.

llvm-svn: 122896
2011-01-05 18:58:31 +00:00
Douglas Gregor 820ba7ba43 Implement the sizeof...(pack) expression to compute the length of a
parameter pack.

Note that we're missing proper libclang support for the new
SizeOfPackExpr expression node.

llvm-svn: 122813
2011-01-04 17:33:58 +00:00
Douglas Gregor e8e9dd624c Implement support for pack expansions whose pattern is a non-type
template argument (described by an expression, of course). For
example:

  template<int...> struct int_tuple { };

  template<int ...Values>
  struct square {
    typedef int_tuple<(Values*Values)...> type;
  };

It also lays the foundation for pack expansions in an initializer-list.
  

llvm-svn: 122751
2011-01-03 17:17:50 +00:00
David Chisnall 50e4ebaeb8 Expose Objective-C type encodings of declarations to libclang users. This also adds a method in ASTContext which encodes FunctionDecls using the same encoding format that is used for Objective-C methods.
llvm-svn: 122639
2010-12-30 14:05:53 +00:00
Chris Lattner ad3467ee89 The -fshort-wchar option causes wchar_t to become unsigned, in addition to being
16-bits in size.  Implement this by splitting WChar into two enums, like we have
for char.  This fixes a miscompmilation of XULRunner, PR8856.

llvm-svn: 122558
2010-12-25 23:25:43 +00:00
Ted Kremenek d99bd55a5e Chris Lattner has strong opinions about directory
layout.  :)

Rename the 'EntoSA' directories to 'StaticAnalyzer'.

Internally we will still use the 'ento' namespace
for the analyzer engine (unless there are further
sabre rattlings...).

llvm-svn: 122514
2010-12-23 19:38:26 +00:00
Ted Kremenek ef33f0996c Rename headers: 'clang/GR' 'clang/EntoSA' and
update Makefile.

llvm-svn: 122493
2010-12-23 07:22:02 +00:00
Argyrios Kyrtzidis a700e976b6 [analyzer] Refactoring: Move checkers into lib/GR/Checkers and their own library, libclangGRCheckers
llvm-svn: 122422
2010-12-22 18:52:56 +00:00
Argyrios Kyrtzidis 2ff5ab1516 [analyzer] Refactoring: lib/Checker -> lib/GR and libclangChecker -> libclangGRCore
llvm-svn: 122421
2010-12-22 18:52:29 +00:00
Abramo Bagnara ea4f7c7761 Introduced raw_identifier token kind.
llvm-svn: 122394
2010-12-22 08:23:18 +00:00
Douglas Gregor fd4da71343 When determining which preprocessed entities to traverse in libclang,
take into account the region of interest. Otherwise, we may fail to
traverse some important preprocessed entity cursors. 
Fixes <rdar://problem/8554072>.

llvm-svn: 122350
2010-12-21 19:07:48 +00:00
Michael J. Spencer 740857fa10 Replace all uses of PathV1::makeAbsolute with PathV2::fs::make_absolute.
llvm-svn: 122340
2010-12-21 16:45:57 +00:00
Douglas Gregor 7ecd19ecde Teach clang_getCursorSemanticParent() and
clang_getCursorLexicalParent() to cope with class and function
templates, along with the parent of the translation unit. Fixes PR8761
and PR8766.

llvm-svn: 122324
2010-12-21 07:55:45 +00:00
Douglas Gregor 0192c234d5 Clean up the handling of template argument packs, especially in the
area of printing template arguments. The functionality changes here
are limited to cases of variadic templates that aren't yet enabled.

llvm-svn: 122250
2010-12-20 16:52:59 +00:00
Douglas Gregor d2fa766ad0 Introduce a new type, PackExpansionType, to capture types that are
pack expansions, e.g. given

  template<typename... Types> struct tuple;

  template<typename... Types>
  struct tuple_of_refs {
    typedef tuple<Types&...> types;
  };

the type of the "types" typedef is a PackExpansionType whose pattern
is Types&. 

This commit introduces support for creating pack expansions for
template type arguments, as above, but not for any other kind of pack
expansion, nor for any form of instantiation.

llvm-svn: 122223
2010-12-20 02:24:11 +00:00
Michael J. Spencer e47230f9b5 Replace all uses of PathV1::get{Basename,Dirname,Suffix} with their PathV2 equivalents.
llvm-svn: 122140
2010-12-18 04:13:32 +00:00
Michael J. Spencer e169675474 Replace all uses of PathV1::getLast with PathV2::filename.
llvm-svn: 122117
2010-12-18 00:19:12 +00:00
Michael J. Spencer d9da7a1f16 MemoryBuffer API update.
llvm-svn: 121956
2010-12-16 03:28:14 +00:00
Daniel Dunbar 8f514a8826 Update for LLVM API change.
llvm-svn: 121950
2010-12-16 03:06:05 +00:00
Abramo Bagnara 6d8106386c Added missing IgnoreParens().
llvm-svn: 121795
2010-12-14 22:11:44 +00:00
Douglas Gregor 0cdc832077 Eliminate the branching in QualType::getTypePtr() by providing a
common base for ExtQuals and Type that stores the underlying type
pointer. This results in a 2% performance win for -emit-llvm on a
typical C file, with 1% memory growth in the AST.

Note that there is an API change in this optimization:
QualType::getTypePtr() can no longer be invoked on a NULL
QualType. If the QualType might be NULL, use
QualType::getTypePtrOrNull(). I've audited all uses of getTypePtr() in
the code base and changed the appropriate uses over to
getTypePtrOrNull(). 

A future optimization opportunity would be to distinguish between
cast/dyn_cast and cast_or_null/dyn_cast_or_null; for the former, we
could use getTypePtr() rather than getTypePtrOrNull(), to take another
branch out of the cast/dyn_cast implementation.

llvm-svn: 121489
2010-12-10 17:03:06 +00:00
Abramo Bagnara 924a8f3573 Added ParenType type node.
llvm-svn: 121488
2010-12-10 16:29:40 +00:00
Rafael Espindola 86f2c57c8d Fixed version of 121435.
llvm-svn: 121472
2010-12-10 07:40:14 +00:00
Douglas Gregor 3046b4d72f In clang_getCursor(), don't override a preprocessing cursor within
another preprocessing cursor, since we want the outermost one.

llvm-svn: 121470
2010-12-10 07:23:11 +00:00
Rafael Espindola 33f793892f Revert my previous patch to make the valgrind bots happy.
llvm-svn: 121460
2010-12-10 04:01:05 +00:00
Douglas Gregor 4a5bd5fec4 Extend libclang debugging output for clang_getCursor() to show the definition we found
llvm-svn: 121451
2010-12-10 01:45:00 +00:00
Rafael Espindola 40fa9b6765 Update clang for the API changes in the cfi patch.
llvm-svn: 121435
2010-12-09 23:48:34 +00:00
Michael J. Spencer f25faaaffb Use error_code instead of std::string* for MemoryBuffer.
llvm-svn: 121378
2010-12-09 17:36:38 +00:00
Anders Carlsson 2f9a124f54 Fix build.
llvm-svn: 121341
2010-12-09 01:00:12 +00:00
Ted Kremenek 69c819cd42 Remove extra namespace specifier.
llvm-svn: 121334
2010-12-09 00:33:41 +00:00
Ted Kremenek bbf91a8975 DenseMapInfo is a 'struct', not a 'class'.
llvm-svn: 121321
2010-12-09 00:01:52 +00:00
Ted Kremenek bbedd062c9 Add new libclang hooks for CXCursorSet, a
DenseMap-backed hashtable for doing client-side
management of CXCursors within a set.

llvm-svn: 121318
2010-12-08 23:43:14 +00:00
Francois Pichet 34b2113250 Remove the TypesCompatibleExprClass AST node. Merge its functionality into BinaryTypeTraitExpr.
llvm-svn: 121298
2010-12-08 22:35:30 +00:00
Francois Pichet cf7731b40b Fix bug where annotate tokens was not working for BinaryTypeTraitExpr.
CIndex's EnqueueVisitor must visit elements backward apparently.

llvm-svn: 121247
2010-12-08 09:11:05 +00:00
Francois Pichet 9dfa3ce94f Type traits intrinsic implementation: __is_base_of(T, U)
New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics.

llvm-svn: 121074
2010-12-07 00:08:36 +00:00
Douglas Gregor 9aeaa4d650 Use atomic operations for libclang's object count tracking.
llvm-svn: 121073
2010-12-07 00:05:48 +00:00
John McCall 5d41378146 Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoretical
reason this is limited to C++, and it's certainly not limited to temporaries.

llvm-svn: 120996
2010-12-06 08:20:24 +00:00
Francois Pichet d583da04d0 More anonymous struct/union redesign. This one deals with anonymous field used in a constructor initializer list:
struct X {
  X() : au_i1(123) {}
  union {
    int au_i1;
    float au_f1;
  };
};

clang will now deal with au_i1 explicitly as an IndirectFieldDecl.

llvm-svn: 120900
2010-12-04 09:14:42 +00:00
John McCall b7bd14fa08 Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ObjCPropertyRefExpr
into the latter.

llvm-svn: 120643
2010-12-02 01:19:52 +00:00
Douglas Gregor f88e35ba0b When using a precompiled preamble with detailed preprocessing records,
trap the serialized preprocessing records (macro definitions, macro
instantiations, macro definitions) from the generation of the
precompiled preamble, then replay those when walking the list of
preprocessed entities. This eliminates a bug where clang_getCursor()
wasn't able to find preprocessed-entity cursors in the preamble.

llvm-svn: 120396
2010-11-30 06:16:57 +00:00
Douglas Gregor b42f34b652 De-C99-ify for loop
llvm-svn: 120395
2010-11-30 06:04:54 +00:00
Douglas Gregor 2f6358b100 Teach c-index-test to reparse the source file a few times when testing
clang_getCursor() via -cursor-at=??? and CINDEXTEST_EDITING is set in
the environment. This mirrors how we test code completion and
source-loading in the presence of this environment variable.

llvm-svn: 120392
2010-11-30 05:52:55 +00:00
Michael J. Spencer 8aaf49959c Merge System into Support.
llvm-svn: 120297
2010-11-29 18:12:39 +00:00
Chris Lattner 5159f6162e now the FileManager has a FileSystemOpts ivar, stop threading
FileSystemOpts through a ton of apis, simplifying a lot of code.
This also fixes a latent bug in ASTUnit where it would invoke
methods on FileManager without creating one in some code paths
in cindextext.

llvm-svn: 120010
2010-11-23 08:35:12 +00:00
Chris Lattner 3f5a9efb2d give FileManager a 'FileSystemOptions' ivar, which will be used
to simplify a bunch of code in it.  It should ultimately get inlined
into FileManager.

llvm-svn: 120007
2010-11-23 07:51:02 +00:00
Benjamin Kramer 3959370c92 Fix a bunch of IndirectFieldDecl-related warnings.
- Negative ChainingSize doesn't make sense, make it unsigned.

llvm-svn: 119943
2010-11-21 14:11:41 +00:00
Chris Lattner 8afa6deb1d remove old compatibility APIs, use StringRef versions instead.
llvm-svn: 119935
2010-11-21 09:55:08 +00:00
Douglas Gregor 06a3f30be9 Implement a simple hash function for libclang cursors
llvm-svn: 119876
2010-11-20 00:09:34 +00:00
Douglas Gregor fec4dc9418 Implement clang_getCanonicalCursor() in libclang, which does the obvious thing.
llvm-svn: 119874
2010-11-19 23:44:15 +00:00
Douglas Gregor a750e8e6d8 Extend the libclang diagnostic API to provide information about the
option name, category ID, and category name corresponding to a diagnostic.

llvm-svn: 119802
2010-11-19 16:18:16 +00:00
Argyrios Kyrtzidis 5c26cda273 getNumErrors() -> hasErrorOccurred()
llvm-svn: 119765
2010-11-19 00:19:18 +00:00
Argyrios Kyrtzidis 8d5038c1b3 Get the number of errors reported from the diagnostic client, in clang_parseTranslationUnit_Impl.
llvm-svn: 119745
2010-11-18 21:47:04 +00:00
Argyrios Kyrtzidis d004064864 Refactoring of Diagnostic class.
-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
   SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

llvm-svn: 119730
2010-11-18 20:06:41 +00:00
Ted Kremenek 5d304a34c6 CursorVisitor: switch remaining expressions over
to the data-recursion algorithm.  CursorVisitor
now no longer subclasses StmtVisitor.

llvm-svn: 119596
2010-11-18 00:42:18 +00:00
Ted Kremenek 8390027a99 CursorVisitor: migrate handling of
'DependentScopeDeclRefExpr' and
'CXXDependentScopeMemberExpr' to the
data-recursion algorithm.

llvm-svn: 119591
2010-11-18 00:02:32 +00:00
Ted Kremenek 7df92ae92b Make definition of CXTranslationUnitImpl private
to libclang.

llvm-svn: 119585
2010-11-17 23:24:11 +00:00
Douglas Gregor 30313cbb80 When libclang is walking a member access expression, don't walk into
an implicit "this"; it causes clang_getCursor() to find the implicit
"this" expression (which isn't written in the source!) rather than the
actual member.

llvm-svn: 119516
2010-11-17 17:15:08 +00:00
Douglas Gregor 29ee422861 When comparing the source range of a declaration against the region of
interest (e.g., as used by clang_getCursor()), count the
decl-specifier-seq as part of the source range, as we do for
clang_annotateTokens(). Makes clang_getCursor() work properly for the
result types of functions, for example.

llvm-svn: 119514
2010-11-17 17:14:07 +00:00
Ted Kremenek 9f49b37f25 CursorVisitor: Migrate handling of
'SizeOfAlignOfExpr' and 'CXXSCalarValueInitExpr'
to data-recursion algorithm.

llvm-svn: 119452
2010-11-17 02:18:35 +00:00
Douglas Gregor b1b71e50a0 For an Objective-C @synthesize statement, e.g.,
@synthesize foo = _foo;

keep track of the location of the ivar ("_foo"). Teach libclang to
visit the ivar as a member reference.

llvm-svn: 119447
2010-11-17 01:03:52 +00:00
Ted Kremenek 7003a50b77 CursorVisitor: migrate handling of CXXUuidofExpr to
data-recursion algorithm.

llvm-svn: 119444
2010-11-17 00:50:52 +00:00
Ted Kremenek 513cd579b6 CursorVisitor: migrate handling of UnaryTypeTraitExpr
to data-recursion algorithm.

llvm-svn: 119443
2010-11-17 00:50:50 +00:00
Ted Kremenek 8eaa165c7e CursorVisitor: refactor visitation of
explicit template args within data-recursion
algorithm.

llvm-svn: 119442
2010-11-17 00:50:47 +00:00
Ted Kremenek e48db8dfae CursorVisitor: migrate handling of
AddrLabelExpr to data-recursion algorithm, and
unify that reasoning with GotoStmt.

llvm-svn: 119441
2010-11-17 00:50:45 +00:00
Ted Kremenek c1c30cd329 CursorVisitor: migrate handling of
VAArgExpr to data-recursion algorithm.

llvm-svn: 119440
2010-11-17 00:50:43 +00:00
Ted Kremenek a51cc43261 CursorVisitor: migrate handling of
CXXTypeidExpr to data-recursion algorithm.

llvm-svn: 119439
2010-11-17 00:50:41 +00:00
Ted Kremenek dd0d4b4192 CursorVisitor: migrate handling of
TypesCompatibleExpr to data-recursion algorithm.

llvm-svn: 119438
2010-11-17 00:50:39 +00:00
Ted Kremenek 79ddc67caa CursorVisitor: Migrate CXXUnresolvedConstructExpr over to data-recursive algorithm.
llvm-svn: 119437
2010-11-17 00:50:36 +00:00
Douglas Gregor 68dbaead7b Fix source-range information for Objective-C properties. Previously,
we were just getting a range covering only the property name, which is
certainly not correct (and broke token annotation, among other
things). 

Also, teach libclang about the relationship between
@synthesize/@dynamic and @property, so we get property name and
cursor-reference information for @synthesize and @dynamic.

llvm-svn: 119409
2010-11-17 00:13:31 +00:00
Benjamin Kramer d1fb1f49a2 MSVC doesn't like the noinline attribute at the end of a declaration. Try the other side.
llvm-svn: 119349
2010-11-16 15:45:46 +00:00
Ted Kremenek 4ff4654893 Rework USR generation from CXCursors to use CXStringBufs
for the backing of generated USRs.  This optmizes
for the case when a client generates a sequence
of USRs in sequence, disposing of them soon
after generating them.  By using a string buffer,
we recycle malloc'ed memory instead of constantly
malloc'ing and copying strings.

llvm-svn: 119338
2010-11-16 08:15:38 +00:00
Ted Kremenek 915542850b Change CXTranslationUnit to not directly cast to an ASTUnit*,
but to wrap both an ASTUnit and a "string pool"
that will be used for fast USR generation.

This requires a bunch of mechanical changes, as
there was a ton of code that assumed that CXTranslationUnit
and ASTUnit* were the same.

Along with this change, introduce CXStringBuf,
which provides an llvm::SmallVector<char> backing
for repeatedly generating CXStrings without a huge
amount of malloc() traffic.  This requires making
some changes to the representation of CXString
by renaming a few fields (but keeping the size
of the object the same).

llvm-svn: 119337
2010-11-16 08:15:36 +00:00
Ted Kremenek 64dddfb39c Add CXString.cpp and CXString.h
llvm-svn: 119322
2010-11-16 02:03:55 +00:00
Ted Kremenek 4b4f36990d Move CXString creation/management routines into
their own .cpp file and make the interpretation
of its flags private.

llvm-svn: 119319
2010-11-16 01:56:27 +00:00
Ted Kremenek a4c27ec73b CursorVisitor: cache worklists created for data-recursion to reduce malloc() traffic.
llvm-svn: 119290
2010-11-15 23:31:32 +00:00
John McCall 8d69a2160e Add a new expression kind, OpaqueValueExpr, which is useful for
certain internal type-checking procedures as well as for representing
certain implicitly-generated operations.  Uses to follow.

llvm-svn: 119289
2010-11-15 23:31:06 +00:00
Ted Kremenek acd03f6fa3 Use LLVM_ATTRIBUTE_NOINLINE instead of attribute((noinline)).
llvm-svn: 119287
2010-11-15 23:11:54 +00:00
Douglas Gregor c65929299d Tweak libclang's heuristics for building precompiled preambles and
caching global code-completion results. In particular, don't perform
either operation the first time we parse, but do both after the first
reparse. 

llvm-svn: 119285
2010-11-15 23:00:34 +00:00
Ted Kremenek e6f030467c Cast pointers instead of returning a new value within RunVisitorWorkList().
llvm-svn: 119282
2010-11-15 22:23:26 +00:00
Ted Kremenek 51df4d5596 Annotate CursorVisitor::VisitDataRecursive() with attribute 'noinline'.
Clang currently uses a ridiculous amount of stack space when inlining
this function, which can lead to premature stack overflows.

llvm-svn: 119281
2010-11-15 22:23:24 +00:00
Ted Kremenek ca817a3c0c "Fix" some unintentional fallout from converting
the Stmt* visitation in CursorVisitor to be
data-recursive.

Since AnnotationTokensWorker explicitly calls
CursorVisitor::VisitChildren(), it essentially
transforms the data-recursive algorithm in
CursorVisitor back into a non-data recursive one.
This is particularly bad because the data-recursive
algorithm uses more stack space per stack frame,
which can cause us to blow the stack in some cases.

"Fix" this by making the stack that AnnotationTokensWorker
runs in really huge.  The real fix is to modify
AnnotationTokensWorker not to do the explicit
recursive call.

llvm-svn: 119047
2010-11-14 17:47:35 +00:00
Ted Kremenek d57f43eb3a CursorVisitor: make data-recursion algorithm the default except for the few remaining Exprs still
covered by the normal recursive visitation.

llvm-svn: 119030
2010-11-14 05:45:47 +00:00
Ted Kremenek d34c65d8a2 Remove stale #include.
llvm-svn: 119028
2010-11-14 05:28:43 +00:00
Ted Kremenek bc8b378848 Rewrite reverse iteration loop in a more natural countdown manner.
llvm-svn: 118990
2010-11-13 05:55:56 +00:00
Ted Kremenek 89bad8a6e7 CursorVisitor: migrate CXXNewExpr and CXXDefaultArgExpr over to data-recursive algorithm.
llvm-svn: 118989
2010-11-13 05:55:53 +00:00
Ted Kremenek fdc5237b5e CursorVisitor: special-case CompoundStmt in data-recursion algorithm so we don't have to enqueue
its children and then reverse them.

llvm-svn: 118986
2010-11-13 05:38:03 +00:00
Ted Kremenek 809c6fc93c CursorVisitor: Migrate BlockExpr, CXXTemporaryOBjectExpr, and ObjCEncodeExpr to data-recursive algorithm.
llvm-svn: 118964
2010-11-13 01:09:29 +00:00
Ted Kremenek 573411b539 CursorVisitor: Migrate DeclRefExpr over to data-recursion algorithm.
llvm-svn: 118961
2010-11-13 00:58:18 +00:00
Ted Kremenek 03b8602490 CursorVisitor: migrate GotoStmt to data-recursive algorithm.
llvm-svn: 118960
2010-11-13 00:58:15 +00:00
Ted Kremenek 072e637671 CursorVisitor: migrate DeclStmt over to data-recursive algorithm.
llvm-svn: 118957
2010-11-13 00:36:50 +00:00
Ted Kremenek acff73c3bf CursorVisitor: Convert logic for populating data-recursion worklist from a switch statement to a StmtVisitor. No functionality change.
llvm-svn: 118956
2010-11-13 00:36:47 +00:00
Nick Lewycky 214a0ad0c7 Use dyn_cast result instead of re-casting. Fixes -Werror build with:
/llvm/tools/clang/tools/libclang/CIndex.cpp:1823: error: unused variable 'E' [-Wunused-variable]

llvm-svn: 118947
2010-11-12 23:52:43 +00:00
Ted Kremenek e0f9382d64 CursorVisitor: Pull ObjCMessageExpr and explicit casts into data-recursion algorithm.
llvm-svn: 118934
2010-11-12 22:24:57 +00:00
Ted Kremenek 0d693a161c CursorVisitor: migrate ObjCMessageExpr over to data-recursion algorithm.
llvm-svn: 118933
2010-11-12 22:24:55 +00:00
Ted Kremenek cfbbeda7dc CursorVisitor: migrate UnresolvedMemberExpr and UnresolvedLookupExpr over to data-recursion algorithm.
llvm-svn: 118929
2010-11-12 21:34:16 +00:00
Ted Kremenek e12bcf5717 CursorVisitor: migrate CompoundLiteralExpr over to data-recursion algorithm.
llvm-svn: 118928
2010-11-12 21:34:12 +00:00
Ted Kremenek 6a5df579e6 CursorVisitor: add data-recursion support for InitListExprs.
llvm-svn: 118927
2010-11-12 21:34:09 +00:00
Ted Kremenek cb035359e8 CursorVisitor: migrate 'DoStmt', 'ForStmt', and 'WhileStmt' over to data-recursion algorithm.
llvm-svn: 118912
2010-11-12 18:27:04 +00:00
Ted Kremenek b50e311bad CursorVisitor: use 'WLAddStmt' and 'WLAddDecl' for adding to data-recursion worklist.
llvm-svn: 118911
2010-11-12 18:27:01 +00:00
Ted Kremenek 3b19144e24 CursorVisitor: migrate 'IfStmt' over to data-recursive algorithm.
llvm-svn: 118910
2010-11-12 18:26:58 +00:00
Ted Kremenek 73227d792b CursorVisitor: migrate handling of SwitchStmt and CaseStmt over to general data-recursion algorithm.
llvm-svn: 118909
2010-11-12 18:26:56 +00:00
Douglas Gregor 453b012513 Make sure to always check the result of
SourceManager::getPresumedLoc(), so that we don't try to make use of
an invalid presumed location. Doing so can cause crashes.

llvm-svn: 118885
2010-11-12 07:15:47 +00:00
Ted Kremenek 7716cd62b3 Modify CursorVisitor to also walks CXXOperatorCallExprs using data-recursion. Fixes <rdar://problem/8659019>.
llvm-svn: 118853
2010-11-11 23:11:43 +00:00
Ted Kremenek c7a5bae597 Annotate tokens in a separate thread to avoid blowing out stack space. While the CursorVisitor
is gradually becoming more data recursive, AnnotateTokensVisitor does its own recursive call
within the visitor that can still blow out the stack.  This can potentially be reworked to avoid this,
but for now just do token annotation on a separate thread.

llvm-svn: 118783
2010-11-11 08:05:23 +00:00
Ted Kremenek 92209a45b9 Generalize data-recursive visitation in CursorVisitor to also handle MemberExprs
and CXXCallMemberExprs.  This scheme is hopefully general enough to extend to the
rest of the visitor if necessary.

llvm-svn: 118782
2010-11-11 08:05:18 +00:00
Douglas Gregor 44c6ee7729 Improve ASTUnit's capture of diagnostics so that the
diagnostic-capturing client lives as long as the ASTUnit itself
does. Otherwise, we can end up with crashes when we get a diagnostic
outside of parsing/code completion. The circumstances under which this
happen are really hard to reproduce, because a file needs to change
from under us.

llvm-svn: 118751
2010-11-11 00:39:14 +00:00
Argyrios Kyrtzidis 2703bebc58 Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to avoid leaking memory.
Fixes rdar://8649963.

llvm-svn: 118674
2010-11-10 05:40:41 +00:00
Douglas Gregor 229bebdeb5 ntroduce clang_getSpellingLocation() into libclang, to provide the
location where we're spelling a token even within a
macro. clang_getInstantiationLocation() tells where we instantiated
the macro.

I'm still not thrilled with the CXSourceLocation/CXSourceRange APIs,
since they gloss over macro-instantiation information.

Take 2: this time, adjusted tests appropriately and used a "simple"
approach to the spelling location.

llvm-svn: 118495
2010-11-09 06:24:54 +00:00
Douglas Gregor 12a610d1fa Revert r118492, which didn't update all of its tests accordingly
llvm-svn: 118494
2010-11-09 05:52:02 +00:00
Douglas Gregor d1ea3f0d29 Introduce clang_getSpellingLocation() into libclang, to provide the
location where we're spelling a token even within a
macro. clang_getInstantiationLocation() tells where we instantiated
the macro.

I'm still not thrilled with the CXSourceLocation/CXSourceRange APIs,
since they gloss over macro-instantiation information.

llvm-svn: 118492
2010-11-09 05:28:47 +00:00
NAKAMURA Takumi c6b53ca514 libclang and c-index-test can be built on Cygming.
llvm-svn: 118480
2010-11-09 03:25:21 +00:00
NAKAMURA Takumi aa63fdf3b5 c-index-test: Be available on Cygwin by using Win32's logic.
llvm-svn: 118479
2010-11-09 03:25:16 +00:00
Ted Kremenek 15c1e368bb Add CursorVisitor::VisitBinaryOperator() to explicitly handle the case where we can blow out the stack due
to deeply nested BinaryOperators.  This is done by turning the explicit recursion into being data recursive.

Fixes: <rdar://problem/8289205>
llvm-svn: 118444
2010-11-08 21:14:15 +00:00
Douglas Gregor 1ccc8416a0 Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.

But don't get too excited about that happening now.

llvm-svn: 118385
2010-11-07 23:05:16 +00:00
Douglas Gregor 16443fdd31 Teach clang_getCursorReferenced() that a
CXXConstructorExpr/CXXTemporaryObjectExpr references the constructor
it calls. Then, tweak clang_getCursor() to prefer such a call over a
type reference to the type being called.

llvm-svn: 118297
2010-11-05 21:11:19 +00:00
Daniel Dunbar 087c3a321f libclang: Enable requesting a larger stack for several libclang entry points
using "safety" threads.

llvm-svn: 118278
2010-11-05 17:21:46 +00:00
Daniel Dunbar b7383e6d80 libclang: Add some support for running certain entry points in a "safety"
thread, primarily to get a larger stack.
 - Yes, I feel dirty.

llvm-svn: 118274
2010-11-05 07:19:31 +00:00
Daniel Dunbar 9aff85e41e Fix 80-col violas.
llvm-svn: 118273
2010-11-05 07:19:21 +00:00
Benjamin Kramer 112fc6cdfb Adjust return type of thread_runner.
llvm-svn: 118259
2010-11-04 19:11:31 +00:00
Daniel Dunbar 23397c3dd6 c-index-test: Switch to using clang_executeOnThread instead of mucking about
with system specific stuff.

llvm-svn: 118224
2010-11-04 01:26:31 +00:00
Daniel Dunbar 234206554b libclang: Add clang_executeOnThread, for use in c-index-test (and only there,
preferably). Good thing c-index-test is written in C!!!!

llvm-svn: 118223
2010-11-04 01:26:29 +00:00
Argyrios Kyrtzidis 71731d6b05 Implement -working-directory.
When -working-directory is passed in command line, file paths are resolved relative to the specified directory.
This helps both when using libclang (where we can't require the user to actually change the working directory)
and to help reproduce test cases when the reproduction work comes along.

--FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains
 the working directory value if set).
--FileSystemOptions are passed around to various interfaces that perform file operations.
--Opening & reading the content of files should be done only through FileManager. This is useful in general since
 file operations will be abstracted in the future for the reproduction mechanism.

FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same
FileManager but with different FileSystemOptions.

Addresses rdar://8583824.

llvm-svn: 118203
2010-11-03 22:45:23 +00:00
David Chisnall b2aa0ef310 Added cursor visitor that takes a block as an argument. Tested compiling
libclang with both clang -fblocks and gcc (no blocks support).  Only exposed in
the header to compilers that do have blocks support.

llvm-svn: 118170
2010-11-03 14:12:26 +00:00
Douglas Gregor 15417cfa56 Improve source-location information for CXXConstructExpr nodes, by
ensuring that they cover all of their child nodes. There's still a
clang_getCursor()-related issue with CXXFunctionalCastExprs with
CXXConstructExprs as children (see FIXME in the test case); I'll look
at that separately.

llvm-svn: 118132
2010-11-03 00:35:38 +00:00
Ted Kremenek 4bd4d75b9a Don't add Decls with an invalid location to DeclsInContainer.
llvm-svn: 118111
2010-11-02 23:17:51 +00:00
Ted Kremenek d40a439067 Hack to workaround deficiency in ObjC ASTs. Functions and variables may be declared
within an @implementation, but we have no way to record that information in the AST.
This may cause CursorVisitor to miss these Decls when doing a AST walk.

Fixes <rdar://problem/8595462>.

llvm-svn: 118109
2010-11-02 23:10:24 +00:00
Ted Kremenek 818e5c1839 Encapsulate within CXCursor the notion of whether a VarDecl* is the first Decl in a DeclGroup. We use this
to recover some context that is currently not modeled directly in the AST.  Currently VarDecl's cannot
properly determine their source range because they have no context on whether or not they appear in a DeclGroup.
For the meantime, this bandaid suffices in libclang since that is where the correct SourceRange is directly needed.

Fixes <rdar://problem/8595749>.

llvm-svn: 117973
2010-11-01 23:26:51 +00:00
Douglas Gregor 9aaf7f66fc Do not compare invalid source locations
llvm-svn: 117946
2010-11-01 20:13:04 +00:00
Benjamin Kramer 4ab36ba726 Turns out that we may end up calling dladdr on GetExecutablePath, give it external linkage to make sure the lookup works on all platforms.
llvm-svn: 117813
2010-10-30 17:32:40 +00:00
Benjamin Kramer c482735d89 This function doesn't need external linkage either.
llvm-svn: 117786
2010-10-30 14:28:41 +00:00
Ted Kremenek 55ccf4e81f Remove old CrashTracer cruft from CIndex.
llvm-svn: 117634
2010-10-29 01:06:50 +00:00
Douglas Gregor f5a1854655 Introduce libclang-level options for C++ precompiled preambles,
separating out chaining precompiled preambles from non-chaining ones.

llvm-svn: 117457
2010-10-27 17:24:53 +00:00
Douglas Gregor f428bf80e1 Add an environment variable that allows us to turn off threading in c-index-test
llvm-svn: 117449
2010-10-27 16:00:01 +00:00
Douglas Gregor 263803a6cd Teach clang_getCursorReferenced() and friends about BlockDeclRefExprs.
llvm-svn: 117167
2010-10-22 22:24:08 +00:00
Douglas Gregor adfdccf1f3 Improve the implementation of libclang's token-annotation logic for
entities in the preprocessing record. Previously, we would only end up
getting the first token of a preprocessing record annotated
correctly. For example, given

  #include "foo.h"

we would only get the '#' annotated as an inclusion directive; the
'include' and '"foo.h"' tokens would be given the general 'processing
directive' annotation.

Now, we get proper annotations for entities in the preprocessing
record.

llvm-svn: 117001
2010-10-21 06:10:04 +00:00
Douglas Gregor 796d76a663 Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.

llvm-svn: 116952
2010-10-20 22:00:55 +00:00
Ted Kremenek 983fb5de5f Call clang_disposeTokens() when we are done with the set of tokens.
llvm-svn: 116946
2010-10-20 21:22:15 +00:00
Douglas Gregor 8e3e8743fb Introduce code completion results for Objective-C methods, both when
declaring methods and when sending messages to them, by bringing all
of the selector into TypedCheck chunks in the completion result. This
way, we can improve the sorting of these results to account for the
full selector name rather than just the first chunk.

llvm-svn: 116746
2010-10-18 21:05:04 +00:00
Oscar Fuentes 16d73f9216 Do not use absolute path on the clang++ symlink.
Based on a patch by Ryuta Suzuki!

llvm-svn: 116695
2010-10-18 02:25:54 +00:00
Oscar Fuentes 95b6f045f1 Use a script for creating the clang++ executable.
The previous method used the DESTDIR environment variable at configure
time, but sometimes it is only available at install time. See PR8397.

llvm-svn: 116689
2010-10-17 16:10:32 +00:00
Ted Kremenek 51651089ab Tweak scan-build to work with naked clang commands.
llvm-svn: 116651
2010-10-16 00:29:16 +00:00
David Chisnall 2e16ac52e1 Add clang_getLocationForOffset() to libclang, for gives a source location from a character index into a file.
llvm-svn: 116587
2010-10-15 17:07:39 +00:00
Fariborz Jahanian 681c0754d9 Eliminate usage of ObjCSuperExpr used for
'super' as receiver of property or a setter/getter
methods. //rdar: //8525788

llvm-svn: 116483
2010-10-14 16:04:05 +00:00
David Chisnall 1822d1f0a8 Don't claim that things that are Objective-C keywords if preceded by an @ are keywords unless they are preceded by an @.
For example, don't claim that end is a keyword in:

unsigned end;

llvm-svn: 116439
2010-10-13 21:44:48 +00:00
Rafael Espindola 85111907bb Call InitSections when assembling. This makes clang's output match that of
llvm-mc.

llvm-svn: 116405
2010-10-13 14:53:57 +00:00
Francois Pichet 85e6da1f19 This patch remove the Win32 XFAIL from remap-complete.c
The problem was that text files were open in text mode and Microsoft implementation of fread and write will try to do nasty line-feed conversion which make the line position no longer valid. The fix is to read and write files in binary mode.

llvm-svn: 116286
2010-10-12 01:01:43 +00:00
Douglas Gregor 7bb8af613c When we load an ASTUnit from command-line arguments, hold on to the
diagnostics produced by the driver itself. Previously, we were
allowing these to either be dropped or to slip through to stderr.

Fixes <rdar://problem/7595339>.

llvm-svn: 116285
2010-10-12 00:50:20 +00:00
Douglas Gregor bd82998e35 Eliminate CIndexer::getClangPath(), since libclang no longer depends
on the presence of a 'clang' executable. Simplify
CIndexer::getClangResourcesPath() a bit.

Patch up the CMake makefiles to install headers into two locations in
the build tree, for those silly cases where 'clang' will end up
looking into the wrong build directory for headers.

llvm-svn: 116260
2010-10-11 23:17:59 +00:00
Douglas Gregor 4e0f15a4a2 Eliminate -fdiagnostics-binary and all of the infrastructure for
emitting diagnostics in a binary form to be consumed by libclang,
since libclang no longer does any of its work out-of-process, making
this code dead. Besides, this stuff never worked at 100% anyway.

llvm-svn: 116250
2010-10-11 22:02:06 +00:00
Douglas Gregor 6a95802893 Eliminate clang_codeComplete(). libclang clients should be using the
faster, in-process, more-configurable clang_codeCompleteAt(). 

llvm-svn: 116245
2010-10-11 21:51:20 +00:00
Douglas Gregor 36e3b5c79e Switch c-index-test from clang_codeComplete() over to
clang_codeCompleteAt(). This uncovered a few issues with the latter:

  - ASTUnit wasn't saving/restoring diagnostic state appropriately between
    reparses and code completions.
  - "Overload" completions weren't being passed through to the client

llvm-svn: 116241
2010-10-11 21:37:58 +00:00
Douglas Gregor 7845f1e80e Eliminate clang_setUseExternalASTGeneration() from libclang. Between
improvements to the compiler and the introduction of crash recovery,
it no longer makes sense to allow this mode. Moreover, this eliminates
one use of the "clang" executable from within libclang; we'd like them
all to go away.

llvm-svn: 116207
2010-10-11 16:52:23 +00:00
Douglas Gregor 8ed5b77008 Fix the mapping of vertical-space cursor kinds to produce a newline,
rather than a space.

llvm-svn: 116097
2010-10-08 20:39:29 +00:00
Daniel Dunbar a5af410dc5 libclang: Disable LLVM pretty stack trace functionality, which inadvertently
sets up signal handlers it shouldn't when we are being used a shared library.

llvm-svn: 116084
2010-10-08 19:30:33 +00:00
Douglas Gregor 9b3932c0bc Fix a marvelous chained AST writing bug, where we end up with the
following amusing sequence:
  - AST writing schedules writing a type X* that it had never seen
  before
  - AST writing starts writing another declaration, ends up
  deserializing X* from a prior AST file. Now we have two type IDs for
  the same type!
  - AST writer tries to write X*. It only has the lower-numbered ID
  from the the prior AST file, so references to the higher-numbered ID
  that was scheduled for writing go off into lalaland.

To fix this, keep the higher-numbered ID so we end up writing the type
twice. Since this issue occurs so rarely, and type records are
generally rather small, I deemed this better than the alternative: to
keep a separate mapping from the higher-numbered IDs to the
lower-numbered IDs, which we would end up having to check whenever we
want to deserialize any type.

Fixes <rdar://problem/8511624>, I think.

llvm-svn: 115647
2010-10-05 18:37:06 +00:00
Douglas Gregor 97c7571ef3 Introduce a new libclang function, clang_getCursorDisplayName(), which
produces a simple "display" name that captures the
arguments/parameters for a function, function template, class
template, or class template specialization.

llvm-svn: 115428
2010-10-02 22:49:11 +00:00
Douglas Gregor 4e3918c06b Teach clang_getCursorType() about base specifiers and other references
to types. 

Also, teach clang_getTypeDeclaration() about template specializations,
injected-class-names, and elaborated types.

Fixes <rdar://problem/8506460>.

llvm-svn: 115425
2010-10-02 21:57:58 +00:00