Commit Graph

2108 Commits

Author SHA1 Message Date
Erik Verbruggen 6e92251f9b Added a flag to the parser to skip method bodies.
llvm-svn: 154584
2012-04-12 10:11:59 +00:00
Ted Kremenek 26a6d498ee Implement clang_getDiagnosticCategoryText() to provide a way for a client of libclang to accurately
get the diagnostic category name from a serialized diagnostic when the version of libclang used
to read the diagnostic file is newer than the clang that emitted the diagnostic file.

llvm-svn: 154567
2012-04-12 00:03:31 +00:00
Argyrios Kyrtzidis 088041721f [libclang] Apparently it's important to build in C89, sigh..
llvm-svn: 154525
2012-04-11 19:54:09 +00:00
Argyrios Kyrtzidis 0c27e4b36b [libclang] Introduce a couple of functions to make it convenient
to get at the parameters (and their types) of a function or objc method cursor.

int clang_Cursor_getNumArguments(CXCursor C);
CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);

rdar://11201527

llvm-svn: 154523
2012-04-11 19:32:19 +00:00
Argyrios Kyrtzidis 408403c4b5 [libclang] In cxloc::translateSourceRange make sure to handle locations in macro arguments
correctly. clang diagnostics can provide fixits inside a macro argument now.

rdar://11014346

llvm-svn: 154517
2012-04-11 18:15:01 +00:00
Argyrios Kyrtzidis 7a9c91c407 [libclang] Fix "error: conflicts with new declaration with ‘C’ linkage" that gcc
emits but not clang.

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

Also honor displayDiagnostics in clang_indexSourceFile().

rdar://11203489

llvm-svn: 154472
2012-04-11 02:11:16 +00:00
Argyrios Kyrtzidis c238f06a2c [libclang] For clang_getOverriddenCursors make sure to report overridden objc methods
for methods in categories of super classes. rdar://11220358

llvm-svn: 154436
2012-04-10 21:01:03 +00:00
Argyrios Kyrtzidis 9d7c0fef65 [code-complete] Introduce CodeCompletionTUInfo which will be used for caching
code-completion related strings specific to a translation unit (ASTContext and related data)

CodeCompletionAllocator does such limited caching, by caching the name assigned
to a DeclContext*, but that is not the appropriate place since that object has
a lifetime that can extend beyond that of an ASTContext.

Introduce CodeCompletionTUInfo which will be always tied to a translation unit
to do this kind of caching and move the caching of CodeCompletionAllocator into this
object, and propagate it to all the places where it will be needed.

The plan is to extend the caching where appropriate, using CodeCompletionTUInfo,
to avoid re-calculating code-completion strings.

Part of rdar://10796159.

llvm-svn: 154408
2012-04-10 17:23:48 +00:00
NAKAMURA Takumi a7d49883bb [Cygwin] Work around to flush stdout in a thread, or stdout in threads won't be flushed at exit.
llvm-svn: 154254
2012-04-07 06:59:28 +00:00
Benjamin Kramer 74875e6719 clangFrontend depends on clangEdit.
llvm-svn: 154010
2012-04-04 12:25:11 +00:00
Manuel Klimek 47c245a537 Adds a tooling library.
Provides an API to run clang tools (FrontendActions) as standalone tools,
or repeatedly in-memory in a process. This is useful for unit-testing,
map-reduce style applications, source transformation daemons or command line
tools.

The ability to run over multiple translation units with different command
line arguments enables building up refactoring tools that need to apply
transformations across translation unit boundaries.

See tools/clang-check/ClangCheck.cpp for an example.

llvm-svn: 154008
2012-04-04 12:07:46 +00:00
Ted Kremenek 34b4546c06 Fix dead store warning.
llvm-svn: 153988
2012-04-04 00:55:33 +00:00
Bill Wendling f4ec97d9b0 Fix build by passing in the needed variable after r153860.
llvm-svn: 153861
2012-04-02 06:17:37 +00:00
Benjamin Kramer a61516d324 Remove unused but set variable.
llvm-svn: 153800
2012-03-31 10:23:28 +00:00
Argyrios Kyrtzidis 0dbe9b6015 [libclang] Fix use-after-free bug when handling attributes indexing info.
When indexing a property with a getter/setter with attributes, the allocated memory
for AttrListInfo could get released before its destructor is run.

Fixes rdar://11113442.

llvm-svn: 153792
2012-03-31 01:14:06 +00:00
Argyrios Kyrtzidis 210f29f44b [libclang] Introduce clang_Cursor_getObjCSelectorIndex() function.
After getting a cursor with clang_getCursor for a particular source location,
allows querying the cursor in order to find out if the location points to a
selector identifier in an objc method or message expression, and which selector index it is.

rdar://11158946

llvm-svn: 153781
2012-03-30 22:15:48 +00:00
Argyrios Kyrtzidis 191a6a86ad [libclang] Introduce clang_Cursor_getSpellingNameRange().
It retrieves a source range for a piece that forms the cursors spelling name.
Most of the times there is only one range for the complete spelling but for
objc methods and objc message expressions, there are multiple pieces for each
selector identifier.

Part of rdar://11113120

llvm-svn: 153775
2012-03-30 20:58:35 +00:00
Argyrios Kyrtzidis ab468b0381 Add info to ObjCPropertyRefExpr to indicate whether the dot syntax property
reference is going to message the setter, the getter, or both.

Having this info on the ObjCPropertyRefExpr node makes it easier for AST
clients (like libclang) to reason about the meaning of the property reference.

[AST/Sema]
-Use 2 bits (with a PointerIntPair) in ObjCPropertyRefExpr to record the above info
-Have ObjCPropertyOpBuilder set the info appropriately.

[libclang]
-When there is an implicit property reference (property syntax using methods)
have clang_getCursorReferenced return a cursor for the method. If the property
reference is going to result in messaging both the getter and the setter choose
to return a cursor for the setter because it is less obvious from source inspection
that the setter is getting called.

The general idea has the seal of approval by John.

rdar://11151621

llvm-svn: 153709
2012-03-30 00:19:18 +00:00
Argyrios Kyrtzidis c9754d6d9c [libclang] A MemberRefExpr cursor for a property dot syntax should have as
its location the location of the property.

Part of rdar://11113120

llvm-svn: 153708
2012-03-30 00:19:13 +00:00
Argyrios Kyrtzidis 7aa274fff3 [libclang] Have c-index-test output more information about a cursor with -cursor-at:
-the location of the cursor
-its extent
-its spelling

Part of radar://11113120

llvm-svn: 153707
2012-03-30 00:19:05 +00:00
Argyrios Kyrtzidis e26ba14fcd [libclang] Fix CIndexer::isOptEnabled(); not sure what I was thinking there.
llvm-svn: 153594
2012-03-28 20:42:59 +00:00
Argyrios Kyrtzidis 58d5f3fdad [libclang] Rename setBackGroundPriority -> setThreadBackgroundPriority.
llvm-svn: 153566
2012-03-28 02:49:54 +00:00
Argyrios Kyrtzidis 5710913c25 [libclang] Fix gcc error.
llvm-svn: 153565
2012-03-28 02:49:50 +00:00
Argyrios Kyrtzidis 7317a5cbfc [libclang] Introduce options to control the priority for the threads
that libclang creates.

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

-CXGlobalOpt_ThreadBackgroundPriorityForIndexing affects:
  clang_indexSourceFile
  clang_indexTranslationUnit
  clang_parseTranslationUnit
  clang_saveTranslationUnit

-CXGlobalOpt_ThreadBackgroundPriorityForEditing affects:
  clang_reparseTranslationUnit
  clang_codeCompleteAt
  clang_annotateTokens

rdar://9075282

llvm-svn: 153562
2012-03-28 02:18:05 +00:00
Argyrios Kyrtzidis c557bada5a [libclang] Put the CIndexer class in the clang namespace instead of having
it at global namespace.

llvm-svn: 153561
2012-03-28 02:18:02 +00:00
Argyrios Kyrtzidis 9d3ffffec0 [libclang] For clang_saveTranslationUnit, if the AST to save has invalid nodes
due to compiler errors, use a crash recovery thread to do the AST writing for
protection.

llvm-svn: 153560
2012-03-28 02:17:59 +00:00
Douglas Gregor 78254c8880 Introduce a new libclang API to determine the parent context of a code
completion item. For example, if the code completion itself represents
a declaration in a namespace (say, std::vector), then this API
retrieves the cursor kind and name of the namespace (std). Implements
<rdar://problem/11121951>.

llvm-svn: 153545
2012-03-27 23:34:16 +00:00
Argyrios Kyrtzidis 6c9ed7d804 [libclang] Introduce indexing option CXIndexOpt_SuppressWarnings, which
disables all compiler warnings.

rdar://11059556

llvm-svn: 153539
2012-03-27 21:38:03 +00:00
Argyrios Kyrtzidis aaf9743f56 [libclang] Make sure we don't crash when trying to index code that
managed to insert an @interface as top level decl contained by another
@interface.

A commit to also not allow this as valid code will be coming.

rdar://11105114.

llvm-svn: 153354
2012-03-23 23:24:18 +00:00
Argyrios Kyrtzidis a754a03550 [libclang] For a CXCursor_ObjCInstanceMethodDecl/CXCursor_ObjCClassMethodDecl cursor,
return from clang_getCursorLocation the start location of the method name.

rdar://11105223

llvm-svn: 153303
2012-03-23 03:33:19 +00:00
Ted Kremenek 4a64230ee7 Don't include FixIts with a null replacement range. Fixes <rdar://problem/11040133>.
llvm-svn: 153122
2012-03-20 20:49:45 +00:00
Argyrios Kyrtzidis 77f5619b8c [libclang] Have clang_getCursorExtent() return the range of the main file when
the passed cursor is the translation unit cursor.

Patch by Clint Caywood!

llvm-svn: 153062
2012-03-19 23:17:58 +00:00
Argyrios Kyrtzidis a15f816e3a [c-index-test] Make it C90 compliant.
llvm-svn: 152823
2012-03-15 18:48:52 +00:00
Argyrios Kyrtzidis 0abc5eb018 [libclang] A couple of enhancements to c-index-test.
-When printing location avoid printing the filename if it is
same as the main file, not just if it has '.h' extension.
-Make sure we allocate enough bytes for storing as string a
huge line number.

llvm-svn: 152821
2012-03-15 18:07:22 +00:00
Chad Rosier d6f716ab2a [driver] Parse diagnostic args in the driver.
Previously, only diagnostics thrown by the cc1 process were
actually honoring the diagnostic options given on the command line,
like -Werror.

Reuse the existing code in Frontend currently used for cc1,
adjusting it to not interpret -Wl, linker flags as warnings.

Also fix a faulty test exposed by this change.
It wasn't actually testing anything, and was giving this warning:

clang-3: warning: argument unused during compilation: '-verify'

Which -Werror didn't turn into an error because it was output
by the driver, not the cc1 process, and diagnostic options
weren't parsed by the driver. And you couldn't see the warning
when running the test suite.

Fixes PR12181.
Patch by Dylan Noblesmith <nobled@dreamwidth.org>.

llvm-svn: 152660
2012-03-13 20:09:56 +00:00
NAKAMURA Takumi 354589a663 Update library dependencies to add clangEdit on c-index-test and c-arcmt-test.
To link with -static -lclang, linker tries to seek not libclang.so, clang.dll nor libclang.dll.a, but libclang.a. USEDLIBS should have correct dependencies for -static.
(In contrast, USEDLIBS=libclang.so might be enough w/o -static)

FYI, cygwin build (in buildbot) is using -static, due to avoiding weirdness of extremely slower startup lag of clang.exe.

llvm-svn: 152539
2012-03-11 08:04:40 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
John McCall 113bee0536 Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr to
track whether the referenced declaration comes from an enclosing
local context.  I'm amenable to suggestions about the exact meaning
of this bit.

llvm-svn: 152491
2012-03-10 09:33:50 +00:00
Daniel Dunbar 62ee6417ac [AST/Sema/libclang] Replace getSourceRange().getBegin() with getLocStart().
- getSourceRange().getBegin() is about as awesome a pattern as .copy().size().

I already killed the hot paths so this doesn't seem to impact performance on my
tests-of-the-day, but it is a much more sensible (and shorter) pattern.

llvm-svn: 152419
2012-03-09 18:35:03 +00:00
Argyrios Kyrtzidis bfb2425c71 [libclang] Enhance clang_getOverriddenCursors.
Basically the current design is:
-for an implementation method, show as overridden the interface method.
  This is not useful, and is inconsistent with the C++ side
-for an interface method, show as overridden the protocols methods (this is desirable)
  and the methods from the categories; methods from categories are not useful
  since they are considered the same method (same USR).
-If there is a protocol method or category method reported, it does not check the
  super class for overridden methods. This is really problematic since
  overridden methods from super class is what we want to give back.

Change clang_getOverriddenCursors to show as overridden any method in the class's
base class, its protocols, or its categories' protocols, that has the same
selector and is of the same kind (class or instance).
If no such method exists, the search continues to the class's superclass,
its protocols, and its categories, and so on. A method from an Objective-C
implementation is considered to override the same methods as its
corresponding method in the interface.

rdar://10967206

llvm-svn: 152270
2012-03-08 00:20:03 +00:00
Richard Smith c67fdd4eb9 AST representation for user-defined literals, plus just enough of semantic
analysis to make the AST representation testable. They are represented by a
new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic
properties, including full CodeGen support, are achieved for free by this
representation.

UserDefinedLiterals can never be dependent, so no custom instantiation
behavior is required. They are mangled as if they were direct calls to the
underlying literal operator. This matches g++'s apparent behavior (but not its
actual mangling, which is broken for literal-operator-ids).

User-defined *string* literals are now fully-operational, but the semantic
analysis is quite hacky and needs more work. No other forms of user-defined
literal are created yet, but the AST support for them is present.

This patch committed after midnight because we had already hit the quota for
new kinds of literal yesterday.

llvm-svn: 152211
2012-03-07 08:35:16 +00:00
Argyrios Kyrtzidis 4a280ff48f [PCH] Mark a PCH file with a flag to indicate if the serialized AST had
compiler errors or not.

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

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

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

llvm-svn: 152192
2012-03-07 01:51:17 +00:00
Ted Kremenek f7639e1b4a Add new code migrator support for migrating existing Objective-C code to use
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax.

This introduces a new library, libEdit, which provides a new way to support
migration of code that improves on the original ARC migrator.  We now believe
that most of its functionality can be refactored into the existing libraries,
and thus this new library may shortly disappear.

llvm-svn: 152141
2012-03-06 20:06:33 +00:00
Ted Kremenek 415287d943 Add static analyzer support for new NSArray/NSDictionary/NSNumber literals.
llvm-svn: 152139
2012-03-06 20:06:12 +00:00
Ted Kremenek 77006f6875 And libclang cursor/indexing support for new Objective-C NSArray/NSDictionary/NSNumber literals.
llvm-svn: 152138
2012-03-06 20:06:06 +00:00
Jim Grosbach 6c258a891f Add MCRegisterInfo to the MCInstPrinter factory function interface.
llvm-svn: 152046
2012-03-05 19:33:41 +00:00
Argyrios Kyrtzidis 981a961d03 Move llvm/ADT/SaveAndRestore.h -> llvm/Support/SaveAndRestore.h.
Needs llvm update.

llvm-svn: 151829
2012-03-01 19:45:56 +00:00
Daniel Dunbar 0b4b32433c Remove stray semi-colon.
llvm-svn: 151682
2012-02-29 00:20:42 +00:00
Argyrios Kyrtzidis 3460880674 [AST] When we @synthesize a property with a user-defined ivar name,
make sure to record the source location of the ivar name.
[libclang] When indexing @synthesized objc methods, report the @implementation
as the lexical container.

Fixes rdar://10905472

llvm-svn: 151635
2012-02-28 17:50:39 +00:00