Rafael Espindola [Sat, 14 Jan 2012 00:30:36 +0000 (00:30 +0000)]
Remember if a type has its visibility set explicitly or implicitly.
With that, centralize the way we merge visibility, always preferring explicit over
implicit and then picking the most restrictive one.
Fixes pr10113 and pr11690.
Douglas Gregor [Fri, 13 Jan 2012 23:49:34 +0000 (23:49 +0000)]
(Implicit) parameters deserialized as part of a function type must not
get added to the identifier chains as part of deserialization, because
they should not be visible to name lookup.
Eli Friedman [Fri, 13 Jan 2012 23:41:25 +0000 (23:41 +0000)]
Progress towards making isUsed() reflect whether a declaration is odr-used; don't set isUsed for local variables which are referenced in unevaluated contexts. Make other code use isReferenced() (which basically indicates that a declaration isn't dead) where appropriate.
I was forced to change test/SemaCXX/linkage.cpp because we aren't actually modeling extern "C" in the AST the way that testcase expects; we were not printing a warning only because we skipped the relevant check. Someone who actually understands the semantics here should fix that.
Kaelyn Uhrain [Fri, 13 Jan 2012 23:10:36 +0000 (23:10 +0000)]
Convert SemaTemplate*.cpp to pass a callback object to CorrectTypo.
The change to SemaTemplateVariadic.cpp improves the typo correction
results in certain situations, while the change to SemaTemplate.cpp
does not change existing behavior.
Douglas Gregor [Fri, 13 Jan 2012 23:06:53 +0000 (23:06 +0000)]
Make sure to consider non-DeclContext scopes properly when finding
multiple name lookup results in C/Objective-C. Fixes a regression a
caused in r147533, found by Enea Zaffanella!
Douglas Gregor [Fri, 13 Jan 2012 22:31:52 +0000 (22:31 +0000)]
When inferring a module for a framework, first determine whether that
framework is actually a subframework within a top-level framework. If
so, only infer a module for the top-level framework and then dig out
the appropriate submodule.
This helps us cope with an amusing subframeworks anti-pattern, where
one uses -F <framework>/Frameworks to get direct include access to the
subframeworks of a framework (which otherwise would not be
permitted).
Anna Zaks [Fri, 13 Jan 2012 21:52:01 +0000 (21:52 +0000)]
Move identification of memory setting and copying functions (memset,
memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic
could be reused in the analyzer.
Sebastian Pop [Fri, 13 Jan 2012 20:37:10 +0000 (20:37 +0000)]
remove assertions in the Hexagon backend specific clang driver
Patch from Jyotsna Verma:
I have made the changes to remove assertions in the Hexagon backend
specific clang driver. Instead of asserting on invalid arch name, it has
been modified to use the default value.
I have changed the implementation of the CPU flag validation for the
Hexagon backend. Earlier, the clang driver performed the check and
asserted on invalid inputs. In the new implementation, the driver passes
the last CPU flag (or sets to "v4" if not specified) to the compiler (and
also to the assembler and linker which perform their own check) instead of
asserting on incorrect values. This patch changes the setCPU function for
the Hexagon backend in clang/lib/Basic/Targets.cpp which causes the
compiler to error out on incorrect CPU flag values.
Eli Friedman [Fri, 13 Jan 2012 02:20:01 +0000 (02:20 +0000)]
A few minor improvements to error recovery trying to access member of a function. In particular, this restores the cool error recovery for the example from http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html , which regressed a few months back.
Kaelyn Uhrain [Fri, 13 Jan 2012 01:32:50 +0000 (01:32 +0000)]
Fix up the calls to CorrectTypo in Sema*ObjC.cpp to use callback
objects, and add a basic CorrectionCandidateCallback template class
to simplify the fixups.
Douglas Gregor [Fri, 13 Jan 2012 01:20:43 +0000 (01:20 +0000)]
When inferring a module map for a framework, add the 'private'
requirement to headers under PrivateHeaders. We don't want to build
them as part of the module (yet).
Richard Smith [Thu, 12 Jan 2012 23:53:29 +0000 (23:53 +0000)]
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
Ted Kremenek [Thu, 12 Jan 2012 19:25:46 +0000 (19:25 +0000)]
[analyzer] fix inlining's handling of mapping actual to formal arguments and limit the call stack depth. The analyzer can now accurately simulate factorial for limited depths.
Richard Smith [Thu, 12 Jan 2012 18:54:33 +0000 (18:54 +0000)]
constexpr: initialization of a union from an empty initializer-list should
zero-initialize the first union member. Also fix a bug where initializing an
array of types compatible with wchar_t from a wide string literal failed in C,
and fortify the C++ tests in this area. This part can't be tested without a code
change to enable array evaluation in C (where an existing test fails).
Douglas Gregor [Thu, 12 Jan 2012 16:11:24 +0000 (16:11 +0000)]
In Objective-C++, actually compute the base type of a member access
expression for an Objective-C object or pointer type, so that we don't
attempt to treat the member name as a template. Fixes
<rdar://problem/10672501>.
Add IsImplicit field in ObjCMessageExpr that is true when the message
was constructed, e.g. for a property access.
This allows the selector identifier locations machinery for ObjCMessageExpr
to function correctly, in that there are not real locations to handle/report for
such a message.
[arcmt] The migrator tests for the buildbot in http://lab.llvm.org:8011/builders/clang-native-mingw32-win7/
are messed up, XFAIL does not help. Waiting until DISABLE is supported..
Anna Zaks [Thu, 12 Jan 2012 02:22:34 +0000 (02:22 +0000)]
[analyzer] Add taint transfer by strcpy & others (part 1).
To simplify the process:
Refactor taint generation checker to simplify passing the
information on which arguments need to be tainted from pre to post
visit.
Todo: We need to factor out the code that sema is using to identify the
string and memcpy functions and use it here and in the CString checker.
Kaelyn Uhrain [Wed, 11 Jan 2012 21:17:51 +0000 (21:17 +0000)]
Fix the caching in CorrectTypo so that other non-keyword identifiers
are still added if the cached correction fails validation.
Also fix a copy-and-paste error in a comment from my previous commit.
Finally, add an example of the benefit the typo correction callback adds
to TryNamespaceTypoCorrection--which happens to also tickle the above
caching problem, as the only way a non-namespace Decl would be added to
the possible corrections is if it was cached as the correction for a
previous instance of the same typo where the typo was corrected to a
non-namespace via a different code path.
Kaelyn Uhrain [Wed, 11 Jan 2012 19:37:46 +0000 (19:37 +0000)]
Add initial callback object support to Sema::CorrectTypo.
Also includes two examples of the callback: a wrapper/replacement for
the CorrectTypoContext enum, and a conversion of the two calls to
CorrectTypo in SemaDeclCXX.cpp (one of which provides verifiable
improvement to the typo correction, as demonstrated in the added test).
Evgeniy Stepanov [Wed, 11 Jan 2012 11:21:31 +0000 (11:21 +0000)]
Fix -mfpu parsing on ARM.
- Support gcc-compatible vfpv3 name in addition to vfp3.
- Support vfpv3-d16.
- Disable neon feature for -mfpu=vfp* (yes, we were emitting Neon instructions
for those!).
Ted Kremenek [Wed, 11 Jan 2012 08:13:21 +0000 (08:13 +0000)]
"This change adds alloca/valloc checks to UnixAPIChecker. It includes a small refactoring for
the common *alloc functions as well as a few tiny wibbles (adds a note
to CWE/CERT advisory numbers in the bug output, and fixes a couple
80-column-wide violations.)"
Douglas Gregor [Wed, 11 Jan 2012 04:25:01 +0000 (04:25 +0000)]
C11 allows typedefs to be redefined. Implement this in C11 mode, and
downgrade the default-error warning to an ExtWarn in
C90/99. <rdar://problem/10668057>
Ted Kremenek [Wed, 11 Jan 2012 01:06:27 +0000 (01:06 +0000)]
Remove '#if 0' from ExprEngine::InlineCall(), and start fresh by wiring up inlining for straight C calls.
My hope is to reimplement this from first principles based on the simplifications of removing unneeded node builders
and re-evaluating how C++ calls are handled in the CFG. The hope is to turn inlining "on-by-default" as soon as possible
with a core set of things working well, and then expand over time.