Jordan Rose [Wed, 17 Apr 2013 00:57:39 +0000 (00:57 +0000)]
[analyzer] Merge C++ status page into Open Projects.
Also, add a few random extra open projects.
Most of C++ support is done; we don't need the status page anymore. We're
hoping that the C++-related open projects are the only major pieces of
functionality we don't model at this point.
Use the extra info in global method pool to speed up looking for ObjC overridden methods.
When we are in a implementation, we check the global method pool whether there were category
methods with the same selector. If there were none (common case) we don't need to do lookups for
overridden methods again.
Note that for an interface method (if we don't encounter its implementation), it is considered that
it overrides methods that were declared before it, not for category methods introduced after it.
This is tradeoff in favor of performance, since it is expensive to do lookups in case there was a
category, and moving the global method pool to ASTContext (so we can check it) would increase complexity.
Enhance the ObjC global method pool to record whether there were 0, 1, or >= 2 methods (with a particular selector) inside categories.
This is done by extending ObjCMethodList (which is only used by the global method pool) to have 2 extra bits of information.
We will later take advantage of this info in global method pool for the overridden methods calculation.
This is an opt-in tweak for leak diagnostics to reference the allocation
site if the diagnostic consumer only wants a pithy amount of information,
and not the entire path.
This is a strawman enhancement that I expect to see some experimentation
with over the next week, and can go away if we don't want it.
Currently it is only used by RetainCountChecker, but could be used
by MallocChecker if and when we decide this should stay in.
John McCall [Tue, 16 Apr 2013 21:29:40 +0000 (21:29 +0000)]
objc_autoreleasePoolPop() can throw if a -dealloc does.
Model it as throwing so that the exception can be caught.
This is generally not expected to have significant code-size
impact because the contents of the @autoreleasepool block
are very likely to contain a call, very likely at the same
cleanup level as the @autoreleasepool itself.
This patch causes OpInst records to be silently identified with their Non-Op
inst counterparts so that the same test generation infrastructure can be used to
generate tests.
Factor CheckerManager to be able to pass AnalyzerOptions to checkers
during checker registration. There are no immediate clients of this,
but this provides a way for checkers to query the options table
at startup instead.
Remove unused "getConfig()" method. A new way is to have high-level
APIs that access the configuration table without clients reasoning
about the string table. The string table is an implementation
detail.
Changes necessary to arm_neon.td for the generation of Neon tests.
This is the first of six patches to add to the arm neon tablegen
generator the capability of generating tests to verify that the various
ARM intrinsics are implemented properly.
The changes include such items as:
1. Adding attributes to the Inst record so that additional metadata that is only
needed for the tests can be specified in TableGen.
2. Adding wrapper classes for operator (i.e. ``Op'') intrinsics which before
were simply notates as Inst. This allows us to classify what sort of test
to generate for said intrinsic and further since the classes do not effect
the behavior of the Inst base class, allow for normal functioning.
Benjamin Kramer [Tue, 16 Apr 2013 19:08:41 +0000 (19:08 +0000)]
rewrite-includes: Rewrite __has_include(_next) to get rid of a host dependency.
This broke e.g. compiling a crash report from a glibc system on Darwin. Sadly,
the implementation had to game the lexer a lot as we're not using a real
preprocessor here. It also doesn't handle special cases like arbitrary macros in
__has_include, but since this macro isn't common outside of clang's headers we
can get away with that.
This patch implements parsing ‘#pragma clang __debug’ as a first step for
implementing captured statements. Captured statements are a mechanism for
doing outlining in the AST.
see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.
Daniel Dunbar [Tue, 16 Apr 2013 18:21:19 +0000 (18:21 +0000)]
[Modules] Convert module specific -fno-modules-autolink into -fno-autolink.
- There is no reason to have a modules specific flag for disabling
autolinking. Instead, convert the existing flag into -fno-autolink (which
should cover other autolinking code generation paths like #pragmas if and
when we support them).
Objective-C IRGen. Use llvm::WeakVH
for caching couple of global symbols used
for generation of CF/NS string meta-data
so they are not released prematuely in certain
corner cases. // rdar:// 13598026.
Reviewed by John M.
Anna Zaks [Mon, 15 Apr 2013 22:38:07 +0000 (22:38 +0000)]
[analyzer] Do not crash when processing binary "?:" in C++
When computing the value of ?: expression, we rely on the last expression in
the previous basic block to be the resulting value of the expression. This is
not the case for binary "?:" operator (GNU extension) in C++. As the last
basic block has the expression for the condition subexpression, which is an
R-value, whereas the true subexpression is the L-value.
Note the operator evaluation just happens to work in C since the true
subexpression is an R-value (like the condition subexpression). CFG is the
same in C and C++ case, but the AST nodes are different, which the LValue to
Rvalue conversion happening after the BinaryConditionalOperator evaluation.
Changed the logic to only use the last expression from the predecessor only
if it matches either true or false subexpression. Note, the logic needed
fortification anyway: L and R were passed but not even used by the function.
Also, change the conjureSymbolVal to correctly compute the type, when the
expression is an LG-value.
Jordan Rose [Mon, 15 Apr 2013 22:03:38 +0000 (22:03 +0000)]
[analyzer] Don't assert on a temporary of pointer-to-member type.
While we don't do anything intelligent with pointers-to-members today,
it's perfectly legal to need a temporary of pointer-to-member type to, say,
pass by const reference. Tweak an assertion to allow this.
Jordan Rose [Mon, 15 Apr 2013 20:39:45 +0000 (20:39 +0000)]
[analyzer] Re-enable using global regions as a symbolic base.
Now that we're invalidating global regions properly, we want to continue
taking advantage of a particular optimization: if all global regions are
invalidated together, we can represent the bindings of each region with
a "derived region value" symbol. Essentially, this lazily links each
global region with a single symbol created at invalidation time, rather
than binding each region with a new symbolic value.
We used to do this, but haven't been for a while; the previous commit
re-enabled this code path, and this handles the fallout.
Jordan Rose [Mon, 15 Apr 2013 20:39:37 +0000 (20:39 +0000)]
[analyzer] Tests: move system functions into system header simulator files.
Some checkers ascribe different behavior to functions declared in system
headers, so when working with standard library functions it's probably best
to always have them in a standard location.
Test change only (no functionality change), but necessary for the next commit.
[PCH/test] Make test/PCH/cxx-typeid.cpp self-contained by including the relevant standard library declarations
instead of depending on a system header inclusion.
Unified token breaking logic for strings and block comments.
Summary:
Both strings and block comments are broken into lines in
breakProtrudingToken. Logic specific for strings or block comments is abstracted
in implementations of the BreakToken interface. Among other goodness, this
change fixes placement of backslashes after a block comment inside a
preprocessor directive (see removed FIXMEs in unit tests).
The code is far from being polished, and some parts of it will be changed for
line comments support.
Rafael Espindola [Mon, 15 Apr 2013 12:49:13 +0000 (12:49 +0000)]
Remove hasExternalLinkageUncached.
It was being used correctly, but it is a very dangerous API to have around.
Instead, move the logic from the filtering to when we are deciding if we should
link two decls.
Rafael Espindola [Mon, 15 Apr 2013 12:38:20 +0000 (12:38 +0000)]
Fix the storage class of method instantiations.
We keep the "as written" storage class, but that is a fuzzy concept for
instantiations. With this patch instantiations of methods of class templates
now get a storage class that is based on the semantics of isStatic(). With this
can simplify isStatic() itself.
Richard Smith [Sun, 14 Apr 2013 23:01:42 +0000 (23:01 +0000)]
CodeGen support for function-local static thread_local variables with
non-constant constructors or non-trivial destructors. Plus bugfixes for
thread_local references bound to temporaries (the temporaries themselves are
lifetime-extended to become thread_local), and the corresponding case for
std::initializer_list.
John McCall [Sun, 14 Apr 2013 08:50:55 +0000 (08:50 +0000)]
Handle incompatible redeclarations of library builtins better.
Invalid redeclarations of valid explicit declarations shouldn't
take the same path as redeclarations of implicit declarations,
and invalid local extern declarations shouldn't foul things up
for everybody else.
Simon Atanasyan [Sun, 14 Apr 2013 08:37:15 +0000 (08:37 +0000)]
[Mips] Remove "single" from the list of valid MIPS float ABI names. Add
two new options –msingle-float and –mdouble-float. These options can be
used simultaneously with float ABI selection options (-mfloat-abi,
-mhard-float, -msoft-float). They mark whether a floating-point
coprocessor supports double-precision operations.
Use an newly introduce ASTContext::getBaseObjCCategoriesAfterInterface() which caches its
results instead of re-calculating the categories multiple times.
Introduce SourceManager::getDecomposedIncludedLoc, that returns the "included/expanded in" decomposed location of the given FileID.
The main benefit is to speed-up SourceManager::isBeforeInTranslationUnit which is common to query
the included/expanded location of the same FileID multiple times.
John McCall [Sat, 13 Apr 2013 00:20:21 +0000 (00:20 +0000)]
Don't replace an existing decl in the scope chains with its
local-extern redeclaration; type refinements, default arguments,
etc. must all be locally scoped.
Richard Smith [Fri, 12 Apr 2013 22:11:07 +0000 (22:11 +0000)]
tl;dr: Teach Clang to work around g++ changing its workaround to glibc's
implementation of C99's attempt to control the C++ standard. *sigh*
The C99 standard says that certain macros in <stdint.h>, such as SIZE_MAX,
should not be defined when the header is included in C++ mode, unless
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined. The C++11 standard
says "Thanks, but no thanks" and C11 removed this rule, but various C library
implementations (such as glibc) follow C99 anyway.
g++ prior to 4.8 worked around the C99 / glibc behavior by defining
__STDC_*_MACROS in <cstdint>, which was incorrect, because <stdint.h> is
supposed to provide these macros too. g++ 4.8 works around it by defining
__STDC_*_MACROS in its builtin <stdint.h> header.
This change makes Clang act like g++ 4.8 in this regard: our <stdint.h> now
countermands any attempt by the C library to implement the undesired C99 rules,
by defining the __STDC_*_MACROS first. Unlike g++, we do this even in C++98
mode, since that was the intent of the C++ committee, matches the behavior
required in C11, and matches our built-in implementation of <stdint.h>.
Bob Wilson [Fri, 12 Apr 2013 20:17:20 +0000 (20:17 +0000)]
Define Neon intrinsics as "static inline" to avoid warning. rdar://13108414
We had been defining Neon intrinsics as "static" with always_inline attributes.
If you use them from an extern inline function, you get a warning, e.g.:
static function 'vadd_u8' is used in an inline function with external linkage
This change simply adds the inline keyword to avoid that warning.
Anna Zaks [Fri, 12 Apr 2013 18:40:27 +0000 (18:40 +0000)]
[analyzer] Print a diagnostic note even if the region cannot be printed.
There are few cases where we can track the region, but cannot print the note,
which makes the testing limited. (Though, I’ve tested this manually by making
all regions non-printable.) Even though the applicability is limited now, the enhancement
will be more relevant as we start tracking more regions.