Commit Graph

2030 Commits

Author SHA1 Message Date
Ted Kremenek fbcce6fba3 clang_getCXTUResourceUsage: report memory used by HeaderSearch.
This required converting the StringMaps to use a BumpPtrAllocator.  I measured the
compile time and saw no observable regression.

llvm-svn: 136190
2011-07-26 23:46:11 +00:00
Ted Kremenek 120992ad81 clang_getCXTUResourceUsage: Report memory used by data structures in SourceManager.
llvm-svn: 136189
2011-07-26 23:46:06 +00:00
Benjamin Kramer 632500cb85 Eliminate a bunch of temporary strings.
llvm-svn: 136092
2011-07-26 16:59:25 +00:00
Douglas Gregor ea777403f9 Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code
completion. From Connor Wakamo!

llvm-svn: 136084
2011-07-26 15:24:30 +00:00
Evan Cheng 5a7a4ea505 Assembler really doesn't need to create TargetMachine anymore.
llvm-svn: 136045
2011-07-26 01:49:26 +00:00
Evan Cheng 9568f27950 Rename createCodeEmitter to createMCCodeEmitter; createObjectStreamer to createMCObjectStreamer.
llvm-svn: 136032
2011-07-26 00:42:40 +00:00
Evan Cheng 939f809ce9 Rename createAsmParser to createMCAsmParser.
llvm-svn: 136029
2011-07-26 00:24:45 +00:00
Evan Cheng 4b89983662 Rename TargetAsmBackend to MCAsmBackend; rename createAsmBackend to createMCAsmBackend.
llvm-svn: 136011
2011-07-25 23:25:09 +00:00
Francois Pichet ece689f336 Fix the MSVC build. 2 problems:
- buildPieces was return a C++ object from inside an extern "C". (MSVC didn't like that)
   - clang_getCursorReferenceNameRange was missing a CINDEX_LINKAGE causing a link error.

llvm-svn: 135983
2011-07-25 22:00:44 +00:00
Chandler Carruth d48db2115a Rename getInstantiationLineNumber to getExpansionLineNumber in both
SourceManager and FullSourceLoc.

llvm-svn: 135969
2011-07-25 21:09:52 +00:00
Chandler Carruth 42f35f9cd2 Rename getInstantiationColumnNumber to getExpansionColumnNumber in both
SourceManager and FullSourceLoc.

llvm-svn: 135965
2011-07-25 20:57:57 +00:00
Evan Cheng c2d8c6be92 Assembler doesn't need to initialize TargetMachine's anymore.
llvm-svn: 135964
2011-07-25 20:53:26 +00:00
Chandler Carruth c7ca5218b6 Rename getDecomposedInstantiationLoc to getDecomposedExpansionLoc.
llvm-svn: 135962
2011-07-25 20:52:32 +00:00
Douglas Gregor c1679ecf3b Added clang_getCursorReferenceNameRange to libclang to to retrieve parts of
a cursor reference, from Erik Verbruggen!

llvm-svn: 135920
2011-07-25 17:48:11 +00:00
Chandler Carruth 6d28d7f2a3 Rename SourceManager::getInstantiationRange to getExpansionRange.
llvm-svn: 135915
2011-07-25 16:56:02 +00:00
Chandler Carruth 35f5320d8e Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.

llvm-svn: 135914
2011-07-25 16:49:02 +00:00
Douglas Gregor 757e38b47e Extend libclang with clang_equalRanges, from Erik Verbruggen!
llvm-svn: 135860
2011-07-23 19:35:14 +00:00
Chris Lattner 54b1677d23 Move ArrayRef to LLVM.h and eliminate now-redundant qualifiers, patch by Jon Mulder!
llvm-svn: 135855
2011-07-23 17:14:25 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Evan Cheng 06e70d33fc Move TargetAsmParser.h TargetAsmBackend.h and TargetAsmLexer.h to MC where they belong.
llvm-svn: 135834
2011-07-23 00:45:53 +00:00
Evan Cheng c391a58b2b Match LLVM API change.
llvm-svn: 135813
2011-07-22 21:59:11 +00:00
Douglas Gregor 63745d5935 New libclang API to expose container type for code completion, from
Connor Wakamo!

llvm-svn: 135651
2011-07-21 01:05:26 +00:00
Douglas Gregor 4a9c39a2f6 Rework the detailed preprocessing record to separate preprocessing
entities generated directly by the preprocessor from those loaded from
the external source (e.g., the ASTReader). By separating these two
sets of entities into different vectors, we allow both to grow
independently, and eliminate the need for preallocating all of the
loaded preprocessing entities. This is similar to the way the recent
SourceManager refactoring treats FileIDs and the source location
address space.

As part of this, switch over to building a continuous range map to
track preprocessing entities.

llvm-svn: 135646
2011-07-21 00:47:40 +00:00
Chad Rosier 1988642124 Temporarily revert r135614 while I fix the cmake build.
llvm-svn: 135621
2011-07-20 21:16:17 +00:00
Chad Rosier e3805fc118 When the compiler crashes, the compiler driver now produces diagnostic information
including the fully preprocessed source file(s) and command line arguments.  The 
developer is asked to attach this diagnostic information to a bug report.

llvm-svn: 135614
2011-07-20 20:26:32 +00:00
Evan Cheng b5517a4d8c Match MCContext change.
llvm-svn: 135612
2011-07-20 19:53:19 +00:00
Chris Lattner 01cf8db38b now that we have a centralized place to do so, add some using declarations for
some common llvm types: stringref and smallvector.  This cleans up the codebase
quite a bit.

llvm-svn: 135576
2011-07-20 06:58:45 +00:00
Evan Cheng 347033fd8b Match LLVM API change.
llvm-svn: 135570
2011-07-20 06:22:27 +00:00
Douglas Gregor 925296b4c2 Revamp the SourceManager to separate the representation of parsed
source locations from source locations loaded from an AST/PCH file.

Previously, loading an AST/PCH file involved carefully pre-allocating
space at the beginning of the source manager for the source locations
and FileIDs that correspond to the prefix, and then appending the
source locations/FileIDs used for parsing the remaining translation
unit. This design forced us into loading PCH files early, as a prefix,
whic has become a rather significant limitation.

This patch splits the SourceManager space into two parts: for source
location "addresses", the lower values (growing upward) are used to
describe parsed code, while upper values (growing downward) are used
for source locations loaded from AST/PCH files. Similarly, positive
FileIDs are used to describe parsed code while negative FileIDs are
used to file/macro locations loaded from AST/PCH files. As a result,
we can load PCH/AST files even during parsing, making various
improvemnts in the future possible, e.g., teaching #include <foo.h> to
look for and load <foo.h.gch> if it happens to be already available.

This patch was originally written by Sebastian Redl, then brought
forward to the modern age by Jonathan Turner, and finally
polished/finished by me to be committed.

llvm-svn: 135484
2011-07-19 16:10:42 +00:00
Evan Cheng 3f37dd065b Match createTargetMachine API change.
llvm-svn: 135469
2011-07-19 06:37:41 +00:00
Evan Cheng b505ace101 MCContext now takes MCRegisterInfo.
llvm-svn: 135425
2011-07-18 20:57:51 +00:00
Argyrios Kyrtzidis e6cd072517 [libclang] Map canonical decl of a category implementation to the category decl.
llvm-svn: 135316
2011-07-15 22:37:58 +00:00
Argyrios Kyrtzidis 238ea53793 Revert r135304 and apply fix in clang_getCanonicalCursor per Doug's, Fariborz's comments.
llvm-svn: 135314
2011-07-15 22:27:18 +00:00
John McCall 7c454bb8ce Create a new expression node, SubstNonTypeTemplateParmExpr,
to represent a fully-substituted non-type template parameter.
This should improve source fidelity, as well as being generically
useful for diagnostics and such.

llvm-svn: 135243
2011-07-15 05:09:51 +00:00
Evan Cheng 6d188f5f1c Match llvm API change.
llvm-svn: 135220
2011-07-14 23:50:56 +00:00
Chandler Carruth 65c9c9bd69 Clean up two lingering comments that mention 'instantiation' w.r.t.
macros in libclang.

llvm-svn: 135148
2011-07-14 16:07:57 +00:00
Chandler Carruth de81fc8557 NestedMacroInstantiations -> NestedMacroExpansions
This is switches all the interfaces points (and most of the commenst
/ local variables I saw on my way through) regarding the
NestedMacroInstantiations bit.

The libclang enums corresponding to this state were renamed, but
a legacy enum was added with the old name, and the same value to keep
existing clients working. I've added a documentation blurb for it, but
let me know if there is a canonical way to document legacy elemenst of
the libclang interface.

No functionality changed here, even in tests.

llvm-svn: 135141
2011-07-14 09:02:10 +00:00
Chandler Carruth 9e4704ab07 Update all of the libclang code corresponding to the preprocessor
MacroInstantiation -> MacroExpansion rename. Internally, everything is
switched.

Introduce a new cursor kind enum with the new name, but retain the old
name as an alias so that we don't break backwards compatibility.

Also update the debug printing routine to use 'macro expansions' as its
explicitly not guaranteed to be stable, and mechanically switch the test
cases over to that.

llvm-svn: 135140
2011-07-14 08:41:15 +00:00
Chandler Carruth a88a221855 Move the rest of the preprocessor terminology from 'instantiate' and
variants to 'expand'. This changed a couple of public APIs, including
one public type "MacroInstantiation" which is now "MacroExpansion". The
rest of the codebase was updated to reflect this, especially the
libclang code. Two of the C++ (and thus easily changed) libclang APIs
were updated as well because they pertained directly to the old
MacroInstantiation class.

No functionality changed.

llvm-svn: 135139
2011-07-14 08:20:46 +00:00
Argyrios Kyrtzidis a59dbea017 Fix CMake.
llvm-svn: 134918
2011-07-11 20:28:59 +00:00
Argyrios Kyrtzidis f89cc69eac [arcmt] Move the remapping functions to clang-c/Index.h and change 'arcmt_' prefix to 'clang_'.
llvm-svn: 134916
2011-07-11 20:15:00 +00:00
Evan Cheng 279f2907ed Match createCodeEmitter change.
llvm-svn: 134885
2011-07-11 04:24:19 +00:00
Francois Pichet 9a22177c3e Fix ARCMT/migrate.m on MSVC.
Solution is to set output stdout to binary mode to prevent newline conversion (\n => \r\n).

llvm-svn: 134879
2011-07-10 19:48:34 +00:00
Joerg Sonnenberger e3531fcf88 Unbreak -cc1as mode after MC subtarget changes
llvm-svn: 134877
2011-07-10 19:16:25 +00:00
NAKAMURA Takumi e65e4778f2 tools/c-arcmt-test/Makefile: Add clangARCMigrate.a clangRewrite.a to USEDLIBS to satisfy linking on cygming.
FIXME: tools/c-*.exe should be linked to clang.dll on cygming. llvm/Makefile.rules is not aware of bin/clang.dll.
llvm-svn: 134871
2011-07-10 15:50:19 +00:00
NAKAMURA Takumi 3310effb24 c-arcmt-test.c: MSVCRT does not have setenv. Use putenv instead.
llvm-svn: 134859
2011-07-10 03:10:43 +00:00
Argyrios Kyrtzidis dd76300464 Fix linker problem in buildbot.
llvm-svn: 134849
2011-07-09 22:35:06 +00:00
Argyrios Kyrtzidis 347bf910b9 Ugh, fix CMake.
llvm-svn: 134848
2011-07-09 22:05:50 +00:00
Argyrios Kyrtzidis 27019be903 [libclang] Fix linker error in buildbots.
llvm-svn: 134847
2011-07-09 21:35:58 +00:00
Argyrios Kyrtzidis 7fbd97f641 [arcmt] Introduce new '-ccc-arcmt-migrate <path>' ARC migration driver option.
This is a new mode of migration, where we avoid modifying the original files but
we emit temporary files instead.

<path> will be used to keep migration process metadata. Currently the temporary files
that are produced are put in the system's temp directory but we can put them
in the <path> if is necessary.

Also introduce new ARC migration functions in libclang whose only purpose,
currently, is to accept <path> and provide pairs of original file/transformed file
to map from the originals to the files after transformations are applied.

Finally introduce the c-arcmt-test utility that exercises the new libclang functions,
update arcmt-test, and add tests for the whole process.

rdar://9735086.

llvm-svn: 134844
2011-07-09 20:00:58 +00:00
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