Commit Graph

2030 Commits

Author SHA1 Message Date
Evan Cheng 7b15d1885f cc1 must initialize MC subtarget infos for inline asm parsing. Re-enable asm-errors.c
llvm-svn: 134811
2011-07-09 07:32:07 +00:00
Evan Cheng dec3187e7f createAsmParser API change.
llvm-svn: 134797
2011-07-09 06:04:17 +00:00
Chandler Carruth 961995dc9a Update the creation of the TargetAsmParser based on API change in r134678.
llvm-svn: 134680
2011-07-08 03:15:48 +00:00
Joerg Sonnenberger 39ec119132 Slightly improve the code to derive target from program name to not
fault if no arguments are given.

llvm-svn: 134618
2011-07-07 16:57:26 +00:00
Douglas Gregor 2132584d36 Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with
information about the context in which code completion has occurred
and what kinds of entities make sense as completions at that
point. Patch by Connor Wakamo!

llvm-svn: 134615
2011-07-07 16:03:39 +00:00
Francois Pichet abcfbecf39 MSVC doesn't like mixing declarations and statements in a C file.
llvm-svn: 134550
2011-07-06 22:09:44 +00:00
Evan Cheng 299b36fa72 createMCInstPrinter doesn't need TargetMachine anymore.
llvm-svn: 134526
2011-07-06 19:45:57 +00:00
Douglas Gregor 30c80fa3eb libclang: Allow callers of clang_saveTranslationUnit() to distinguish
between different classes of errors. Addresses most of
<rdar://problem/9660328>.

llvm-svn: 134495
2011-07-06 16:43:36 +00:00
Douglas Gregor a98034a25e Improve the Python bindings for libclang in a few ways, from Eli
Bendersky. Specifically: 

* Implemented a new function in libclang: clang_isAttribute

* Fixing TranslationUnit.get_includes to only go through the argument
* buffer when it contains something. This fixed a crash on Windows 

* clang_getFileName returns CXString, not char*. Made appropriate
* fixes in cindex.py - now the relevant tests pass and we can see the
* full locations correctly again (previously there was garbage in
* place of the file name) 
* Exposed clang_getCursorDisplayName to the python bindings

llvm-svn: 134460
2011-07-06 03:00:34 +00:00
John McCall d9dfe3a1f8 Preserve that a TemplateName was arrived at by substituting
for a template template parameter.

Uses to follow.

I've also made the uniquing of SubstTemplateTemplateParmPacks
use a ContextualFoldingSet as a minor space efficiency.

llvm-svn: 134137
2011-06-30 08:33:18 +00:00
Evan Cheng adc7959851 createTargetMachine now takes a CPU string.
llvm-svn: 134128
2011-06-30 02:06:32 +00:00
Argyrios Kyrtzidis 8bb2ecf32d [libclang] Introduce cxcursor::getCursorParentDecl(CXCursor Cursor) and use it at the appropriate place in CIndex.cpp
No functionality change.

llvm-svn: 134104
2011-06-29 22:20:07 +00:00
Argyrios Kyrtzidis e379ee31c0 Introduce Preprocessor::getTotalMemory() and use it in CIndex.cpp, no functionality change.
llvm-svn: 134103
2011-06-29 22:20:04 +00:00
Eli Friedman 03aff72eff Revert unintentional commit.
llvm-svn: 133971
2011-06-28 00:03:31 +00:00
Eli Friedman 5f3ab2248c Merge some calls to FoldingSetNodeID::AddInteger; assuming my measurements aren't completely off, roughly a 1% speedup on SingleSource/UnitTests/ObjC/trivial-interface.m .
llvm-svn: 133968
2011-06-27 23:58:21 +00:00
Argyrios Kyrtzidis d289104e29 [libclang] Avoid having the cursor of an expression replace the declaration cursor
when the expression source range overlaps the declaration range.

This can happen for C++ constructor expressions whose range generally
include the variable declaration, e.g.:

  MyCXXClass foo; // Make sure pointing at 'foo' returns a VarDecl cursor.

rdar://9124499.

llvm-svn: 133930
2011-06-27 19:42:23 +00:00
Argyrios Kyrtzidis 66cd1dacbc [libclang] Avoid having the cursor of an expression "overwrite" the annotation of the
variable declaration that it belongs to.

This can happen for C++ constructor expressions whose range generally
include the variable declaration, e.g.:

  MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.

rdar://9124499.

llvm-svn: 133929
2011-06-27 19:42:20 +00:00
Douglas Gregor fe31481f68 Introduce a new AST node describing reference binding to temporaries.
MaterializeTemporaryExpr captures a reference binding to a temporary
value, making explicit that the temporary value (a prvalue) needs to
be materialized into memory so that its address can be used. The
intended AST invariant here is that a reference will always bind to a
glvalue, and MaterializeTemporaryExpr will be used to convert prvalues
into glvalues for that binding to happen. For example, given

  const int& r = 1.0;

The initializer of "r" will be a MaterializeTemporaryExpr whose
subexpression is an implicit conversion from the double literal "1.0"
to an integer value. 

IR generation benefits most from this new node, since it was
previously guessing (badly) when to materialize temporaries for the
purposes of reference binding. There are likely more refactoring and
cleanups we could perform there, but the introduction of
MaterializeTemporaryExpr fixes PR9565, a case where IR generation
would effectively bind a const reference directly to a bitfield in a
struct. Addresses <rdar://problem/9552231>.

llvm-svn: 133521
2011-06-21 17:03:29 +00:00
Chandler Carruth 54a2c06cf2 Remove more unnecessary dependencies now that the Frontend -> ARCMigrate
edge has been broken.

llvm-svn: 133343
2011-06-18 09:07:35 +00:00
NAKAMURA Takumi 16484a6bc8 tools/arcmt-test: Don't attempt to link redundant libclang (clang-c).
llvm-svn: 133342
2011-06-18 08:52:27 +00:00
Argyrios Kyrtzidis 90b6a2a6a7 [arcmt] Fix the ARC migrator. -arcmt-modify requires running before the initialization of SourceManager
because it is going to modify the input file.

llvm-svn: 133323
2011-06-18 00:53:41 +00:00
Chandler Carruth 5dea0dc575 Remove ARCMigrate from more builds that it isn't needed in now that the
layering problem has been addressed.

llvm-svn: 133217
2011-06-16 23:53:28 +00:00
John McCall 32e02a431b c-index-test also depends on ARCMigrate, oh boy
llvm-svn: 133147
2011-06-16 05:29:03 +00:00
John McCall 2af9866fc9 ARCMigrate depends on libAnalysis, and on unhelpful linkers must appear
before it on the link line.

llvm-svn: 133145
2011-06-16 04:30:11 +00:00
John McCall e70c8987d3 Grr. Of course libARCMigrate depends on libRewrite. This is a lot to be
linking unnecessarily into libclang.

llvm-svn: 133129
2011-06-16 01:29:56 +00:00
Argyrios Kyrtzidis 6e4ef20baf [arcmt] Make arcmt-test accept cc1 options to make it more portable and hopefully fix MSVC failures.
llvm-svn: 133119
2011-06-16 00:53:46 +00:00
John McCall 0a6ba2684f libFrontend depends on ARCMigrate, so link it into libclang.
llvm-svn: 133116
2011-06-16 00:38:00 +00:00
John McCall d70fb9812a The ARC Migration Tool. All the credit goes to Argyrios and Fariborz
for this.

llvm-svn: 133104
2011-06-15 23:25:17 +00:00
John McCall 31168b077c Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

llvm-svn: 133103
2011-06-15 23:02:42 +00:00
Tanya Lattner 55808c1026 Add support for builtin astype:
__builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types.
Added test case.

llvm-svn: 132612
2011-06-04 00:47:47 +00:00
Douglas Gregor 4cd65962dc Expose @synthesize and @dynamic via their own cursor kinds in
libclang. Fixes <rdar://problem/9537904>.

llvm-svn: 132603
2011-06-03 23:08:58 +00:00
Douglas Gregor a9d8493310 Objective-C doesn't consider the use of incomplete types as method
parameter types to be ill-formed. However, it relies on the
completeness of method parameter types when producing metadata, e.g.,
for a protocol, leading IR generating to crash in such cases.

Since there's no real way to tighten down the semantics of Objective-C
here without breaking existing code, do something safe but lame:
suppress the generation of metadata when this happens.

Fixes <rdar://problem/9123036>.

llvm-svn: 132171
2011-05-27 01:19:52 +00:00
Argyrios Kyrtzidis 0e37afa15e A StringRef-ication of the DiagnosticIDs API and internals.
Patch by Matthieu Monrocq with tweaks by me to avoid StringRefs in the static
diagnostic data structures, which resulted in a huge global-var-init function.

Depends on llvm commit r132046.

llvm-svn: 132047
2011-05-25 05:05:01 +00:00
Alexis Hunt e852b100e2 Implement a new type node, UnaryTransformType, designed to represent a
type that turns one type into another. This is used as the basis to
implement __underlying_type properly - with TypeSourceInfo and proper
behavior in the face of templates.

llvm-svn: 132017
2011-05-24 22:41:36 +00:00
Joerg Sonnenberger b487d2d815 Support -fatal-warnings for the assembler frontend
llvm-svn: 131662
2011-05-19 18:42:29 +00:00
Argyrios Kyrtzidis f15eac1110 Do some safety checks.
llvm-svn: 131491
2011-05-17 22:09:53 +00:00
Douglas Gregor a8d0c774da Add c-index-test printing and tests for static and virtual method
query functions, from Erik Verbruggen!

llvm-svn: 131295
2011-05-13 15:54:42 +00:00
Douglas Gregor 9519d92ef6 Add clang_CXXMethod_isVirtual() to libclang, from Erik Verbruggen!
llvm-svn: 131230
2011-05-12 15:17:24 +00:00
Alexis Hunt 4a8ea1092a Modify some deleted function methods to better reflect reality:
- New isDefined() function checks for deletedness
 - isThisDeclarationADefinition checks for deletedness
 - New doesThisDeclarationHaveABody() does what
   isThisDeclarationADefinition() used to do
 - The IsDeleted bit is not propagated across redeclarations
 - isDeleted() now checks the canoncial declaration
 - New isDeletedAsWritten() does what it says on the tin.
 - isUserProvided() now correct (thanks Richard!)

This fixes the bug that we weren't catching

void foo() = delete;
void foo() {}

as being a redefinition.

llvm-svn: 131013
2011-05-06 20:44:56 +00:00
Douglas Gregor 998caead70 Introduce a new libclang parsing flag,
CXTranslationUnit_NestedMacroInstantiations, which indicates whether
we want to see "nested" macro instantiations (e.g., those that occur
inside other macro instantiations) within the detailed preprocessing
record. Many clients (e.g., those that only care about visible tokens)
don't care about this information, and in code that uses preprocessor
metaprogramming, this information can have a very high cost.

Addresses <rdar://problem/9389320>.

llvm-svn: 130990
2011-05-06 16:33:08 +00:00
Richard Smith 3f1b5d077b Implement support for C++0x alias templates.
llvm-svn: 130953
2011-05-05 21:57:07 +00:00
Douglas Gregor af44c781a7 When the environment variable LIBCLANG_RESOURCE_USAGE is set, teach
libclang to emit information about resource usage after parsing, code
completion, etc.

llvm-svn: 130946
2011-05-05 20:27:22 +00:00
Ted Kremenek 2160a0d3d7 Enhance clang_getCXTUResourceUsage() to return the amount of memory used by the Preprocessor's bump allocator as well as those from the PreprocessingRecord.
llvm-svn: 130823
2011-05-04 01:38:46 +00:00
Douglas Gregor 37aa4938c8 Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.

llvm-svn: 130808
2011-05-04 00:14:37 +00:00
Ted Kremenek 9c10d0a3ce Use the canonical decl when generating the locations for USRs.
llvm-svn: 130748
2011-05-03 01:33:35 +00:00
Chandler Carruth 73aa8f7027 Based on the new information in the AST provided by r130628, write
3 lines of code and improve a bunch of information in the libclang view
of the code.

Updates the two tests that exercise this with the new data, checking
that each new source location actually points back to the declared
template parameter.

llvm-svn: 130656
2011-05-01 09:53:37 +00:00
Rafael Espindola 26cdfa71ef Update API.
llvm-svn: 130588
2011-04-30 03:46:18 +00:00
Ted Kremenek 491da68ef9 Guard in USRGenerator::GenLoc() against null Decl* from invalid code.
llvm-svn: 130541
2011-04-29 21:35:23 +00:00
Ted Kremenek 5e1ed7b8dd Enhance clang_getCXTUResourceUsage() to report the sizes of the memory buffers used by PCH.
llvm-svn: 130460
2011-04-28 23:46:20 +00:00
Ted Kremenek 8d58790019 Enhance clang_getCXTUResourceUsage() to report how much memory is used by SourceManager's memory buffers.
llvm-svn: 130433
2011-04-28 20:36:42 +00:00
Ted Kremenek f5df0ce949 Enhance clang_getCXTUResourceUsage() to report the amount of memory used by ASTContext's side tables.
llvm-svn: 130383
2011-04-28 04:53:38 +00:00
Ted Kremenek 21735e608d Enhance clang_getCXTUResourceUsage() to report the amount of memory used by SourceManager's content cache allocator.
llvm-svn: 130380
2011-04-28 04:10:31 +00:00
John Wiegley 1c0675e155 Parsing/AST support for Structured Exception Handling
Patch authored by Sohail Somani.

Provide parsing and AST support for Windows structured exception handling.

llvm-svn: 130366
2011-04-28 01:08:34 +00:00
John Wiegley 6242b6a688 Implementation of Embarcadero array type traits
Patch authored by John Wiegley.

These are array type traits used for parsing code that employs certain
features of the Embarcadero C++ compiler: __array_rank(T) and
__array_extent(T, Dim).

llvm-svn: 130351
2011-04-28 00:16:57 +00:00
Ted Kremenek 04f93b9cf1 Update regex in scan-build for parsing statistics.
llvm-svn: 130347
2011-04-27 23:43:27 +00:00
Ted Kremenek f26109664e Update scan-build to '-analyzer-checker debug.Stats' instead of the old '-analyzer-stats' -cc1 argument.
llvm-svn: 130320
2011-04-27 18:53:08 +00:00
John McCall 0009fcc39e Make yet another placeholder type, this one marking that an expression is a bound
member function, i.e. something of the form 'x.f' where 'f' is a non-static
member function.  Diagnose this in the general case.  Some of the new diagnostics
are probably worse than the old ones, but we now get this right much more
universally, and there's certainly room for improvement in the diagnostics.

llvm-svn: 130239
2011-04-26 20:42:42 +00:00
John Wiegley f9f6584e95 t/clang/expr-traits
Patch authored by David Abrahams.

These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for
parsing code that employs certain features of the Embarcadero C++ compiler.

llvm-svn: 130122
2011-04-25 06:54:41 +00:00
Douglas Gregor 0ff2b2eda3 Teach libclang to be more careful around BlockDecls, and don't assume
that a TypeSourceInfo is always available, like we do everywhere else
in libclang. Fixes <rdar://problem/9311140>.

llvm-svn: 130034
2011-04-22 23:49:24 +00:00
Francois Pichet 1c229c0472 Add -fdelayed-template-parsing option. Using this option all templated function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup.
Using this flag is necessary for compatibility with Microsoft template code.
This also provides some parsing speed improvement.

llvm-svn: 130022
2011-04-22 22:18:13 +00:00
Nick Lewycky 207bce31e1 Wire up the -ftest-coverage and -fprofile-arcs flags to .gcno file emission (at
compile time) and .gcda emission (at runtime). --coverage enables both.

This does not yet add the profile_rt library to the link step if -fprofile-arcs
is enabled when linking.

llvm-svn: 129956
2011-04-21 23:44:07 +00:00
Douglas Gregor 07542c5b2d When translating a Clang source range into a libclang source range,
adjust the a ending macro location to the end of the instantiation
location before adjusting it to the end of the token. Fixes
<rdar://problem/9021561>.

llvm-svn: 129872
2011-04-20 21:16:21 +00:00
Ted Kremenek 23324124e4 Rename 'CXTUMemoryUsage…' to 'CXTUResourceUsage…'.
llvm-svn: 129857
2011-04-20 16:41:07 +00:00
Douglas Gregor 49f754f423 Teach SourceManager::getSLocEntry() that it can fail due to problems
during deserialization from  a precompiled header, and update all of
its callers to note when this problem occurs and recover (more)
gracefully. Fixes <rdar://problem/9119249>.

llvm-svn: 129839
2011-04-20 00:21:03 +00:00
Ted Kremenek fd07f85605 Add missing break statements.
llvm-svn: 129750
2011-04-19 04:36:17 +00:00
Ted Kremenek 11d1a42e84 Report memory usage for global code completion results in CXTUMemoryUsage.
llvm-svn: 129733
2011-04-18 23:42:53 +00:00
Francois Pichet 45cc546271 Unbreak the MSVC build: Don't mix variable declarations and statements in a .c file.
llvm-svn: 129732
2011-04-18 23:33:22 +00:00
Ted Kremenek 83f642e54a Add libclang API to query how much memory is used by a CXTranslationUnit. This is a WIP. Currently we report
the amount used for expressions, types, identifiers, and selectors.

llvm-svn: 129730
2011-04-18 22:47:10 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
Peter Collingbourne 9114759641 C1X: implement generic selections
As an extension, generic selection support has been added for all
supported languages.  The syntax is the same as for C1X.

llvm-svn: 129554
2011-04-15 00:35:48 +00:00
Richard Smith 02e85f3bc5 Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
llvm-svn: 129541
2011-04-14 22:09:26 +00:00
Douglas Gregor 7df2126000 Harden Clang's cursor visitation logic against NULL declaration,
statement, and expression pointers. While these shouldn't happen, it's
better to be safe in libclang.

llvm-svn: 129539
2011-04-14 21:41:34 +00:00
Ted Kremenek 13b5a2c2f8 Add Objective-C++ files to those accepted by ccc-analyzer.
llvm-svn: 129475
2011-04-13 21:52:05 +00:00
Ted Kremenek f62a279e4c Provide options to explicitly enable/disable checkers in scan-build.
llvm-svn: 129393
2011-04-12 21:47:00 +00:00
Ted Kremenek 79c4c2baa9 Enable C++ static analysis support in ccc-analyzer.
llvm-svn: 129392
2011-04-12 21:46:57 +00:00
Oscar Fuentes 87eb515aba libclang output name is now libclang. This solves a name collision
when building with Visual Studio. `clang.dll' and `clang.exe' would
have the same `clang.ilk' and `clang.pdb'. On a serial build those
files would be overwritten as clang.exe/clang.dll are created. On a
parallel build there is a risk of both files being written at the same
time. On that case VS fails.

llvm-svn: 129239
2011-04-10 02:29:27 +00:00
Daniel Dunbar 529c03bc1e Driver: Sketch driver support for a CC_LOG_DIAGNOSTICS options, similar to the
existing CC_PRINT_OPTIONS and CC_PRINT_HEADERS, which can be used to
transparently capture the compiler diagnostics from a build.

llvm-svn: 129082
2011-04-07 18:01:20 +00:00
John McCall 319963434c Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use.  I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.

llvm-svn: 129065
2011-04-07 08:22:57 +00:00
Ted Kremenek 75bb01b47d Filter our experimental checks in scan-build's checker listing.
llvm-svn: 128865
2011-04-05 00:21:49 +00:00
Ted Kremenek c8e6f5110c Don't store reports when scan-build's build command matches /autogen/ (same as configure).
llvm-svn: 128723
2011-04-01 18:47:06 +00:00
Daniel Dunbar 9cf7bc7a6c Frontend/cc1as: Add support for -L.
llvm-svn: 128432
2011-03-28 22:49:24 +00:00
Chris Lattner ce6c42f65f switch a few Driver APIs to use llvm::ArrayRef, cleaning up code.
llvm-svn: 128142
2011-03-23 04:04:01 +00:00
Ted Kremenek 1ba9bbc149 Fix crash in clang_getInstantiationLoc() when SourceManager::getInstantiationLoc() can return a SourceLocatin with an invalid
FileID on invalid code.  Fixes <rdar://problem/9164623>.

llvm-svn: 128139
2011-03-23 02:16:44 +00:00
Douglas Gregor 20b2ebd785 Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

  void foo()
  __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

  - If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
    will result in a deprecation warning, as if we had placed
    attribute((deprecated)) on it (but with a better diagnostic)
  - If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
    will result in an "unavailable" warning (in C)/error (in C++), as
    if we had placed attribute((unavailable)) on it
  - If we choose a deployment target prior to 10.2, foo() is
    weak-imported (if it is a kind of entity that can be weak
    imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.

llvm-svn: 128127
2011-03-23 00:50:03 +00:00
Ted Kremenek 600b54c1e7 Hopefully fix VS build by not using std::vector::data().
llvm-svn: 128105
2011-03-22 20:16:19 +00:00
Ted Kremenek 022a4904fa Rework crash recovery cleanup in ASTUnit and CIndex to recover more memory during a Sema crash (we have just a handful of leaks left)
and to use the simplified cleanup registration API.

llvm-svn: 128059
2011-03-22 01:15:24 +00:00
Ted Kremenek 9acb346375 scan-build: only display analyzer intra-file progress when in "Verbose" mode.
llvm-svn: 128015
2011-03-21 20:12:21 +00:00
Ted Kremenek 5e14d39a88 Improve crash recovery cleanup to recovery CompilerInstances during crash recovery. This was a huge resource "root" during crashes.
This change requires making a bunch of fundamental Clang structures (optionally) reference counted to allow correct
ownership semantics of these objects (e.g., ASTContext) to play out between an active ASTUnit and CompilerInstance
object.

llvm-svn: 128011
2011-03-21 18:40:17 +00:00
Bill Wendling a8da50d011 Pass in the TargetMachine parameter to the inst printer.
llvm-svn: 127987
2011-03-21 05:02:03 +00:00
Argyrios Kyrtzidis e762020bb9 In clang_parseTranslationUnit_Impl,p ut the source file after command_line_args otherwise
if '-x' flag is present it will be unused.

llvm-svn: 127971
2011-03-20 18:17:52 +00:00
Ted Kremenek 1ec7b33079 Add libclang hook 'clang_toggleCrashRecovery()', which provides a mechanism for a client to enable/disable CrashRecovery within libclang function calls.
llvm-svn: 127920
2011-03-18 23:05:39 +00:00
Ted Kremenek 21c7e6e298 Run all functional logic of clang_annotateTokens() within a CrashRecoveryContext. Fixes <rdar://problem/9121698>.
llvm-svn: 127919
2011-03-18 22:51:30 +00:00
Anders Carlsson c30dcecb5c Correctly store and keep track of the FileSystemOptions in ASTUnit and in clang_codeCompleteAt.
llvm-svn: 127890
2011-03-18 18:22:40 +00:00
Douglas Gregor c2b97994ea When libclang visits a translation unit via clang_visitChildren(),
walk the preprocessing record *before* walking the declarations, so
they we pretend that we actually respect the phases of translation.

We still walk the preprocessing record after the declarations when
performing token annotation or finding the cursor at a location, since
those routines depend on those semantics.

Fixes <rdar://problem/9137195>.

llvm-svn: 127776
2011-03-16 23:23:30 +00:00
Ted Kremenek d4bcb4ffc1 Compress argument processing in ccc-analyzer. No functionality change.
llvm-svn: 127758
2011-03-16 21:10:42 +00:00
Joerg Sonnenberger f6ce2fb1b3 Refactor program name logic. Extend it to infer the target triple from
the program name, if it includes it as proper prefix. This makes calling
clang with -ccc-host-triple x86_64-linux the same as calling it with the
name x86_64-linux-clang.

llvm-svn: 127753
2011-03-16 20:15:43 +00:00
Ted Kremenek 6f7008dcb6 c-index-test shouldn't crash when a goto has no matching label. Fixes <rdar://problem/9123493>.
llvm-svn: 127711
2011-03-15 23:47:49 +00:00
Oscar Fuentes a29f7b2591 Fix LIBCLANG_LINK_FLAGS for Darwin.
The previous syntax created a list with the usual semicolon as
separator, which breaks the link command.

llvm-svn: 127579
2011-03-14 14:32:16 +00:00
Oscar Fuentes 7221610543 Build libclang as a static library too. Now tested on Windows!
On Windows only the shared library is created. The reason for this is
that clang.lib the static library would clash with clang.lib the
export library of the dll.

llvm-svn: 127566
2011-03-13 15:10:24 +00:00
Oscar Fuentes 89b17a43e7 Reverting "Build libclang as a static library too."
This reverts commit r127556. It breaks the build for MSVC.

llvm-svn: 127564
2011-03-13 04:28:29 +00:00
Oscar Fuentes 89374ea270 Build libclang as a static library too.
llvm-svn: 127556
2011-03-12 22:01:58 +00:00
Abramo Bagnara 6b6f051e5e Renamed OffsetOfNode::getRange to getSourceRange for uniformity.
llvm-svn: 127534
2011-03-12 09:45:03 +00:00
Peter Collingbourne e190dee7a5 Add support for the OpenCL vec_step operator, by generalising and
extending the existing support for sizeof and alignof.  Original
patch by Guy Benyei.

llvm-svn: 127475
2011-03-11 19:24:49 +00:00
Ted Kremenek 339f7c3c58 Tweak ccc-analyzer's 'Analyze' function to not mutate the original arguments list.
llvm-svn: 127428
2011-03-10 21:10:08 +00:00
NAKAMURA Takumi d3cc220d97 c-index-test.c: Fix cygwin warning not to pass signed char to islower(c).
Cygwin's ctype.h says;
/* These macros are intentionally written in a manner that will trigger
   a gcc -Wall warning if the user mistakenly passes a 'char' instead
   of an int containing an 'unsigned char'.
   (snip) */

llvm-svn: 127308
2011-03-09 03:02:28 +00:00
Argyrios Kyrtzidis 97d3a38c3e Add 'OverridenFilesKeepOriginalName' field in SourceManager which if true the SourceManager
should report the original file name for contents of files that were overriden by other files,
otherwise it should report the name of the new file. Default is true.

Also add similar field in PreprocessorOptions and pass similar parameter in ASTUnit::LoadFromCommandLine.

llvm-svn: 127289
2011-03-08 23:35:24 +00:00
NAKAMURA Takumi d24228afeb libclang/CIndexer.cpp: Apply a new API for Cygwin-1.7, instead of deprecated one.
llvm-svn: 127283
2011-03-08 22:17:33 +00:00
Douglas Gregor f2f0806f71 Teach libclang's token-annotation logic about context-sensitive
keywords for Objective-C+ and C++0x. 

llvm-svn: 127253
2011-03-08 17:10:18 +00:00
Joerg Sonnenberger b86f5f4106 If called as *cpp or *cpp-[^-]*, run only the preprocessor. If no
input is specified, use stdin implicitly. Based on a patch from
Roman Divacky.

llvm-svn: 127137
2011-03-06 23:31:01 +00:00
Douglas Gregor c81a7a2591 Rename the type argument for the iboutletcollection attribute to not
conflict with MinGW headers, from Kirk Beitz!

llvm-svn: 127127
2011-03-06 18:55:32 +00:00
Argyrios Kyrtzidis 11e6f0a6c3 Currently we can only remap a file by creating a MemoryBuffer and replacing the file contents with it.
Allow remapping a file by specifying another filename whose contents should be loaded if the original
file gets loaded. This allows to override files without having to create & load buffers in advance.

llvm-svn: 127052
2011-03-05 01:03:53 +00:00
Douglas Gregor 25b7e05b72 Fix the source range for a member access expression that includes a
nested-name-specifier and improve the detection of implicit 'this'
bases. Fixes <rdar://problem/8750392>.

llvm-svn: 126880
2011-03-02 21:06:53 +00:00
Douglas Gregor 64f38ae7ee Teach libclang how to visit the children of a C++ base-class specifier
(i.e., the TypeLoc describing the base class type).

llvm-svn: 126861
2011-03-02 19:17:03 +00:00
Douglas Gregor 9d80212115 Push nested-name-specifier source location information into template
template arguments. I believe that this is the last place in the AST
where we were storing a source range for a nested-name-specifier
rather than a proper nested-name-specifier location structure. (Yay!)

There is still a lot of cleanup to do in the TreeTransform, which
doesn't take advantage of nested-name-specifiers with source-location
information everywhere it could.

llvm-svn: 126844
2011-03-02 17:09:35 +00:00
Douglas Gregor a7a795bed1 Push nested-name-specifier source-location information into dependent
template specialization types. There are still a few rough edges to
clean up with some of the parser actions dropping
nested-name-specifiers too early.

llvm-svn: 126776
2011-03-01 20:11:18 +00:00
Douglas Gregor 844cb50266 Reinstate the introduction of source-location information for
nested-name-speciciers within elaborated type names, e.g.,
 
  enum clang::NestedNameSpecifier::SpecifierKind

Fixes in this iteration include:

  (1) Compute the type-source range properly for a dependent template
  specialization type that starts with "template template-id ::", as
  in a member access expression

    dep->template f<T>::f()

  This is a latent bug I triggered with this change (because now we're
  checking the computed source ranges for dependent template
  specialization types). But the real problem was...

  (2) Make sure to set the qualifier range on a dependent template
  specialization type appropriately. This will go away once we push
  nested-name-specifier locations into dependent template
  specialization types, but it was the source of the
  valgrind errors on the buildbots.
  

llvm-svn: 126765
2011-03-01 18:12:44 +00:00
Douglas Gregor b3a58b08e0 Revert r126748, my second attempt at nested-name-specifier source
location information for elaborated types. *sigh*

llvm-svn: 126753
2011-03-01 17:25:47 +00:00
Douglas Gregor bf5fe47b12 Reinstate r126737, extending the generation of type-source location
information for qualifier type names throughout the parser to address
several problems.

The commit message from r126737:

Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of
nested-name-specifiers.

llvm-svn: 126748
2011-03-01 16:31:39 +00:00
Douglas Gregor 62a60c50f4 Revert r126737, the most recent nested-name-specifier location change, for buildbot breakage.
llvm-svn: 126746
2011-03-01 15:34:37 +00:00
Douglas Gregor 9720642c68 Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of
nested-name-specifiers.

llvm-svn: 126737
2011-03-01 03:11:17 +00:00
Douglas Gregor 3d0da5f5dd Push nested-name-specifier source location information into
DependentNameTypeLoc. Teach the recursive AST visitor and libclang how to
walk DependentNameTypeLoc nodes.

Also, teach libclang about TypedefDecl source ranges, so that we get
those. The massive churn in test/Index/recursive-cxx-member-calls.cpp
is a good thing: we're annotating a lot more of this test correctly
now.

llvm-svn: 126729
2011-03-01 01:34:45 +00:00
Douglas Gregor ea972d3faa Push nested-name-specifier location information into DeclRefExpr and
MemberExpr, the last of the expressions with qualifiers!

llvm-svn: 126688
2011-02-28 21:54:11 +00:00
Douglas Gregor 0da1d43e16 Push nested-name-specifier source location information into
UnresolvedLookupExpr and UnresolvedMemberExpr.

Also, improve the computation that checks whether the base of a member
expression (either unresolved or dependent-scoped) is implicit. The
previous check didn't cover all of the cases we use in our
representation, which threw off source-location information for these
expressions (which, in turn, caused some breakage in libclang's token
annotation). 

llvm-svn: 126681
2011-02-28 20:01:57 +00:00
Douglas Gregor e16af53619 Push nested-name-specifier source location information into
CXXDependentScopeMemberExpr, and clean up instantiation of
nested-name-specifiers with dependent template specialization types in
the process.

llvm-svn: 126663
2011-02-28 18:50:33 +00:00
NAKAMURA Takumi 8fbf64f420 [PR9321] "make install" does not need install c-index-test. It is used for testing.
llvm-svn: 126634
2011-02-28 05:21:34 +00:00
Benjamin Kramer 6e152156d5 Fix an obvious typo.
GCC -Waddress warns about this but clang doesn't (PR9043).

llvm-svn: 126577
2011-02-27 18:07:41 +00:00
Daniel Dunbar 160fc36896 cc1: Fix stats printing by default when using -mllvm -stats.
llvm-svn: 126559
2011-02-26 23:17:25 +00:00
Ted Kremenek 27fdf0feda Enhance scan-build to print out available analyses using new checker registration model.
This isn't totally complete.  Right now scan-build uses some heuristics to determine
which checkers are enabled by default, but it cannot always tell which checkers
are not enabled.

llvm-svn: 126521
2011-02-25 22:00:40 +00:00
Douglas Gregor 3a43fd645d Push nested-name-specifier source location information into
DependentScopeDeclRefExpr. Plus, give NestedNameSpecifierLoc == and !=
operators, since we're going to need 'em elsewhere.

llvm-svn: 126508
2011-02-25 20:49:16 +00:00
Douglas Gregor be8705bd3f CMake: add version information into the clang executable and libclang
shared library.

llvm-svn: 126502
2011-02-25 19:24:02 +00:00
Douglas Gregor a6ce608b97 Push nested-name-specifier source-location information into
pseudo-destructor expressions. Also, clean up some
template-instantiation and type-checking issues with
pseudo-destructors.

llvm-svn: 126498
2011-02-25 18:19:59 +00:00
Douglas Gregor c05ba2ef12 Push nested-name-specifier source location information into namespace
aliases.

llvm-svn: 126496
2011-02-25 17:08:07 +00:00
Douglas Gregor 12441b3bc5 Push nested-name-specifier source location information into using directives.
llvm-svn: 126489
2011-02-25 16:33:46 +00:00
Douglas Gregor 144548072d Use NestedNameSpecifierLoc within out-of-line variables, function, and
tag definitions. Also, add support for template instantiation of
NestedNameSpecifierLocs.

llvm-svn: 126470
2011-02-25 02:25:35 +00:00
Douglas Gregor a9d87bc6ac Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the
extremely-lossy NestedNameSpecifier/SourceRange pair it used to use,
improving source-location information.

Various infrastructure updates to support NestedNameSpecifierLoc:
  - AST/PCH (de-)serialization
  - Recursive AST visitor
  - libclang traversal (including the first tests of this
    functionality)

llvm-svn: 126459
2011-02-25 00:36:19 +00:00
Douglas Gregor 7b26ff912f Teach NestedNameSpecifier to keep track of namespace aliases the same
way it keeps track of namespaces. Previously, we would map from the
namespace alias to its underlying namespace when building a
nested-name-specifier, losing source information in the process.

llvm-svn: 126358
2011-02-24 02:36:08 +00:00
Ted Kremenek c49211c79a Add null check in CursorVisitor::RunVisitorWorkList() when visiting LabelDecls. Fixes <rdar://problem/9040579>.
llvm-svn: 126304
2011-02-23 04:54:51 +00:00
Oscar Fuentes e16dc2a6e7 CMAKE_EXECUTABLE_SUFFIX is undefined when a cmake script is executed
with cmake -P ... so we need to deduce the correct executable prefix.

Fixes PR9286.

llvm-svn: 126219
2011-02-22 13:05:15 +00:00
Ted Kremenek bda17491c4 Fix call to send_error() in scan-view. An int error code is expected but a string was being sent. Patch by Andrew Price!
llvm-svn: 126138
2011-02-21 19:26:48 +00:00
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
Douglas Gregor db9fb5a427 Don't add -fno-spell-checking in libclang if a spell-checking-related argument is already in the command-line arguments
llvm-svn: 115420
2010-10-02 20:06:51 +00:00
Douglas Gregor 3478c75b71 Provide proper source location and range information for C++ base
specifier cursors in libclang. FIXME -=2, fixes the rest of
<rdar://problem/8274883>.

llvm-svn: 115419
2010-10-02 19:51:13 +00:00
Douglas Gregor e6712983d2 Teach clang_getCursorReferenced() about Objective-C property reference
and protocol expressions. Fixes <rdar://problem/7833565>.

llvm-svn: 115346
2010-10-01 21:11:22 +00:00
Douglas Gregor 99a26afd49 Extend libclang with an API that determines, given a C++ virtual
member function or an Objective-C method, which other member
functions/methods it overrides.

llvm-svn: 115338
2010-10-01 20:25:15 +00:00
Dawn Perchik 0d3d0b7489 perform_code_completion(): fix type declaration for TU.
llvm-svn: 115224
2010-09-30 22:26:05 +00:00
Daniel Dunbar 08b33d0791 c-index-test: Run inside a separate thread iff we have pthread support, to
ensure we at least get some minimal testing of running in a multithreaded
environment (for example, having a reduced stack size).

llvm-svn: 115200
2010-09-30 20:39:47 +00:00
Tom Care ea7c48ccf7 Updated scan-build:
- Idempotent operations are on by default, to match --analyze in the driver.
- Integrated stats calculation based on parsing warnings emitted with the -analyzer-stats flag. The new -stats flag enables this.
- New -maxloop flag to pass down a maxloop value to the analyzer.

llvm-svn: 115123
2010-09-30 01:12:05 +00:00
Tom Care a5f13c866c Modified the ccc-analyzer script to print the compiler command when log level verbosity is enabled. This is handy for debugging.
llvm-svn: 115109
2010-09-29 23:48:31 +00:00
Douglas Gregor 176d286c96 Enable caching of global code completion results in the suggested
libclang options for editing a translation unit.

llvm-svn: 114810
2010-09-27 05:49:58 +00:00
Douglas Gregor 2c84482abd Teach libclang to enable multithreading in LLVM, since libclang clients are likely to be multithreaded. Also move the printing of timers to somewhere better for multithreaded libclang clients
llvm-svn: 114760
2010-09-24 21:18:36 +00:00
Douglas Gregor ca5b053920 Add some missing concurrency checks into libclang
llvm-svn: 114682
2010-09-23 18:47:53 +00:00