Bob Wilson [Mon, 19 Aug 2013 20:23:37 +0000 (20:23 +0000)]
Bump the value of the __APPLE_CC__ predefined macro up to 6000.
The previous value was set to match some ancient version of Apple's GCC.
The value should be higher than anything used by Apple's GCC, but we don't
intend for this value to be updated in the future. We have other macros to
identify compiler versions. <rdar://problem/14749599>
Jordan Rose [Mon, 19 Aug 2013 16:27:28 +0000 (16:27 +0000)]
Omit arguments of __builtin_object_size from the CFG.
This builtin does not actually evaluate its arguments for side effects,
so we shouldn't include them in the CFG. In the analyzer, rely on the
constant expression evaluator to get the proper semantics, at least for
now. (In the future, we could get ambitious and try to provide path-
sensitive size values.)
In theory, this does pose a problem for liveness analysis: a variable can
be used within the __builtin_object_size argument expression but not show
up as live. However, it is very unlikely that such a value would be used
to compute the object size and not used to access the object in some way.
Pavel Labath [Mon, 19 Aug 2013 15:23:34 +0000 (15:23 +0000)]
[analyzer] Fix inefficiency in dead symbol removal
Summary:
ScanReachableSymbols uses a "visited" set to avoid scanning the same object
twice. However, it did not use the optimization for LazyCompoundVal objects,
which resulted in exponential complexity for long chains of temporary objects.
Adding this resulted in a decrease of analysis time from >3h to 3 seconds for
some files.
Alexey Samsonov [Mon, 19 Aug 2013 09:14:21 +0000 (09:14 +0000)]
Move SanitizerArgs to the clang Driver
Summary:
This change turns SanitizerArgs into high-level options
stored in the Driver, which are parsed lazily. This fixes an issue of multiple copies of the same diagnostic message produced by sanitizer arguments parser.
Dmitri Gribenko [Mon, 19 Aug 2013 07:13:02 +0000 (07:13 +0000)]
Comment parsing tests: move tests where they belong
Move C++-specific tests that were checking if we attach a base class comment to
a derived class to an existing test comment-to-html-xml-conversion.cpp. Note
that the original testing approach was not actually testing the class--comment
relationship. It only checked that we attached the comment *somewhere*.
The rest of subclass-comment.mm should be also moved elsewhere.
Dmitri Gribenko [Mon, 19 Aug 2013 07:10:13 +0000 (07:10 +0000)]
Comment parsing tests: move tests where they belong
comment-misc-tags.m is mostly about miscellaneous Doxygen tags. Move out tests
that check if the comment is attached to an ObjC decl. Because the exitsting
test for this is in C++ (annotate-comments.cpp), create a new test --
annotate-comments-objc.m.
The rest of comment-misc-tags.m should be also moved elsewhere.
Craig Topper [Mon, 19 Aug 2013 03:11:34 +0000 (03:11 +0000)]
Make the version of Stmt::operator new that takes ASTContext* call the ASTContext& version in Stmt inline instead of having two out of line functions that both call to the global versions.
David Blaikie [Sun, 18 Aug 2013 17:59:12 +0000 (17:59 +0000)]
Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class""
This reverts commit r188600.
r188640/r188639 fixed the root cause of the crash-on-valid that r188600
originally introduced. This now appears to bootstrap debug clang
successfully to the best of my testing.
David Blaikie [Sun, 18 Aug 2013 17:36:19 +0000 (17:36 +0000)]
DebugInfo: Avoid duplicating types that may be created during the process of creating their context
A partner to r188639, this is a somewhat heavy-handed fix to the general
issue, since even after that prior change the issue does still
unavoidably arise with template parameters (see test case).
There are other ways we could consider addressing this (see FIXME).
Possible minor reduction in debug info & avoid some cases where creating
a context chain could lead to the type the context chain is being
created for, being created. (this is still possible with template
parameters - tests/fixes/improvements to follow)
Chandler Carruth [Sun, 18 Aug 2013 07:20:52 +0000 (07:20 +0000)]
Fix a use-after-free found in libclang when doing code completion. The
loop processing the candidates can cause new declerations to be added to
the context, invalidating lookup_result. To avoid that, make a copy of
the list of declarations to iterate over.
I don't have a way to check in a test case for this as it involves
a giant pile of source code and a generated PCH file used to accelerate
code completion, all of this running under ASan.
David Blaikie [Sun, 18 Aug 2013 04:50:23 +0000 (04:50 +0000)]
DebugInfo: don't require full definitions for friend classes
Fixes a crash-on-valid introduced by r188486 (which should've occurred
earlier but for a blatant bug where calling createFwdDecl from the
requireCompleteType callback was useless under -flimit-debug-info and we
were just getting lucky with other later callbacks requiring the type
anyway).
Richard Smith [Sat, 17 Aug 2013 00:46:16 +0000 (00:46 +0000)]
Refactor all diagnosing of TypoCorrections through a common function, in
preparation for teaching this function how to diagnose a correction that
includes importing a module.
Per feedback from Chandler, it's better to have libraries with more specific functionality.
LibIndex will contain the indexing functionality of libclang, which includes USR generation.
David Blaikie [Fri, 16 Aug 2013 22:52:07 +0000 (22:52 +0000)]
DebugInfo: Canonicalize namespaces to avoid emitting multiple namespaces with the same name but different lines
Updated test case to not rely on line numbers in more cases (it's hard
to use the @ check syntax for debug info test cases (due to the
interesting ordering of metadata) and this case in particular (given the
hash-line directive)) - left a few in there to cover the line number
information for these.
Libclang has a lot of functionality that is inaccessible.
The purpose of clangIDE is to move most of the functionality of libclang to it so we
can expose it and have libclang be more of a thin C wrapper over clangIDE.
Start by moving the USR generation functionality into clangIDE.
Samuel Benzaquen [Fri, 16 Aug 2013 16:19:42 +0000 (16:19 +0000)]
Refactor ArgumentAdaptativeMatcher matchers to remove the template from their declaration.
Summary:
Refactor ArgumentAdaptativeMatcher matchers to remove the template from their declaration.
This facilitates dynamic registration. Change the registry code to use the regular overload resolution mechanism for adaptative matchers.
Edwin Vane [Fri, 16 Aug 2013 12:18:53 +0000 (12:18 +0000)]
Tweak Replacement comparisons
* Introduce operator< to replace Replacement::Less
* Make operator== and operator< on Replacements non-member functions
* Change order of comparisons in operator< to do string comparisons last
Hans Wennborg [Fri, 16 Aug 2013 03:15:10 +0000 (03:15 +0000)]
Windows ToolChain: add VS bin dir to PogramPaths
We have a lot of fancy logic to find Visual Studio, which is currently used
to set the system header include paths.
Use the same code to set the ProgramPaths, which is used for finding programs
such as link.exe. Previously, Clang would just search PATH for link.exe,
but now it should find it if it's able to find Visual Studio.
Jordan Rose [Fri, 16 Aug 2013 01:06:30 +0000 (01:06 +0000)]
[analyzer] Merge TextPathDiagnostics and ClangDiagPathDiagConsumer.
This once again restores notes to following their associated warnings
in -analyzer-output=text mode. (This is still only intended for use as a
debugging aid.)
One twist is that the warning locations in "regular" analysis output modes
(plist, multi-file-plist, html, and plist-html) are reported at a different
location on the command line than in the output file, since the command
line has no path context. This commit makes -analyzer-output=text behave
like a normal output format, which means that the *command line output
will be different* in -analyzer-text mode. Again, since -analyzer-text is
a debugging aid and lo-fi stand-in for a regular output mode, this change
makes sense.
Along the way, remove a few pieces of stale code related to the path
diagnostic consumers.
Eli Friedman [Thu, 15 Aug 2013 23:59:20 +0000 (23:59 +0000)]
Fix for dependent contexts in alias templates.
When we are parsing a type for an alias template, we are not entering
the context, so we can't look into dependent classes. Make sure the
parser handles this correctly.
Eli Friedman [Thu, 15 Aug 2013 22:02:56 +0000 (22:02 +0000)]
Properly track l-paren of a CXXFucntionalCastExpr.
In addition to storing more useful information in the AST, this
fixes a semantic check in template instantiation which checks whether
the l-paren location is valid.
David Blaikie [Thu, 15 Aug 2013 20:49:17 +0000 (20:49 +0000)]
DebugInfo: Unify & optimize the lazy addition of record types
Rather than going through the whole getOrCreateType machinery to
manifest a type, cut straight to the implementation because we know we
have to do work.
While the previous implementation was sufficient for the two cases
(completeness and required completeness) we have already (the general
machinery could inspect the type for those attributes & go down the full
definition path), a pending change (to emit info for types when we emit
their vtables) won't have that luxury & we'll need to force the creation
rather than relying on the general purpose routine.
David Majnemer [Thu, 15 Aug 2013 19:59:14 +0000 (19:59 +0000)]
CodeGen: __uuidof should work even with an incomplete _GUID type
Summary:
We would crash in CodeGen::CodeGenModule::EmitUuidofInitializer
because our attempt to enter CodeGen::CodeGenModule::EmitConstantValue
will be foiled: the type of the constant value is incomplete.
Instead, create an unnamed type with the proper layout on all platforms.
Punt the problem of wrongly defined struct _GUID types to the user.
(It's impossible because the TU may never get to see the type and thus
we can't verify that it is suitable.)
[autotools->cmake] Added CMake support for the preprocessor variable CLANG_REPOSITORY_STRING.
This is a patch in a longer series of patches to add
capabilities/definitions that are present in the Autotools build chain
and not in the CMake build chain to the CMake build chain.
*NOTE* I am hacking on this in my free time. I will annotate each commit
with the [autotools->cmake] header.
Jordan Rose [Thu, 15 Aug 2013 17:22:06 +0000 (17:22 +0000)]
[analyzer] If realloc fails on an escaped region, that region doesn't leak.
When a region is realloc()ed, MallocChecker records whether it was known
to be allocated or not. If it is, and the reallocation fails, the original
region has to be freed. Previously, when an allocated region escaped,
MallocChecker completely stopped tracking it, so a failed reallocation
still (correctly) wouldn't require freeing the original region. Recently,
however, MallocChecker started tracking escaped symbols, so that if it were
freed we could check that the deallocator matched the allocator. This
broke the reallocation model for whether or not a symbol was allocated.
Now, MallocChecker will actually check if a symbol is owned, and only
require freeing after a failed reallocation if it was owned before.