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.
Bill Wendling [Tue, 10 Jan 2012 08:46:39 +0000 (08:46 +0000)]
The `-fwritable-strings' flag doesn't make the backing store strings of all
CFStrings writable.
The strings (both Unicode and ASCII) should reside in a read-only section. E.g.,
__TEXT,__cstring instead of __DATA,__data. This is done by making the global
variable created for the strings constant despite the value of that flag.
<rdar://problem/10657500>
Eli Friedman [Tue, 10 Jan 2012 04:58:17 +0000 (04:58 +0000)]
Implement the missing pieces of Evaluate for _Complex types. With that complete, remove some code from CGExprConstant which is no longer necessary. While I'm here, a couple minor tweaks to _Complex-in-C++. (Specifically, make _Complex types literal types, and don't warn for _Complex int.)
Richard Smith [Tue, 10 Jan 2012 04:32:03 +0000 (04:32 +0000)]
PR11724: Implement evaluation for constexpr defaulted trivial union copy/move
constructors. These are a special case whose behavior cannot be modeled as a
user-written constructor.
Eli Friedman [Tue, 10 Jan 2012 03:38:46 +0000 (03:38 +0000)]
Per John's comment, it makes sense to ask isLambda on any CXXRecordDecl; make sure that's safe. Get rid of a check which is now unnecessary in Sema::getFunctionLevelDeclContext().
Richard Smith [Tue, 10 Jan 2012 01:33:14 +0000 (01:33 +0000)]
Update C++11 scoped enumeration support to match the final proposal:
- reject definitions of enums within friend declarations
- require 'enum', not 'enum class', for non-declaring references to scoped
enumerations
objc++: patch for IRgen for atomic properties of
c++ objects with non-trivial assignment/copy functions.
Also, one additional sema check. // rdar://6137845
Akira Hatanaka [Mon, 9 Jan 2012 19:08:06 +0000 (19:08 +0000)]
Move the piece of code up that skips the padding argument. Without this change,
padding insertion will not work if the coerced type is not a structure.
Douglas Gregor [Mon, 9 Jan 2012 18:07:24 +0000 (18:07 +0000)]
When deserializing an anonymous namespace from a module, do not attach
the anonymous namespace to its parent. Semantically, this means that
the anonymous namespaces defined in one module are distinct from the
anonymous namespaces defined in another module.
Douglas Gregor [Mon, 9 Jan 2012 17:30:44 +0000 (17:30 +0000)]
Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the
merged DeclContexts as well as the (now-primary) DeclContext. This
supports the common case where two different modules put something
into the same namespace.
Douglas Gregor [Mon, 9 Jan 2012 15:36:04 +0000 (15:36 +0000)]
Always allow redefinition of typedefs when modules are enabled. This
is important because it's fairly common for headers (especially system
headers) to want to provide only those typedefs needed for that
particular header, based on some guard macro, e.g.,
#ifndef _SIZE_T
#define _SIZE_T
typedef long size_t;
#endif
which is repeated in a number of headers. The guard macro protects
against duplicate definitions. However, this means that only the first
occurrence of this pattern actually defines size_t, so the submodule
corresponding to this header has the only visible definition. If a
user then imports a different submodule from the same module, size_t
will be known but not visible, and therefore cannot be used.
By allowing redefinition of typedefs, each header that wants to define
size_t can do so independently, so it will be available in the
corresponding submodules.
Anna Zaks [Sat, 7 Jan 2012 16:49:46 +0000 (16:49 +0000)]
[analyzer] Fix use-after-free in HandleTranslationUnit.
A patch by Dmitri Gribenko!
The attached patch fixes a use-after-free in AnalysisConsumer::HandleTranslationUnit. The problem is that
BugReporter's destructor runs after AnalysisManager has been already
deleted. The fix introduces a scope to force correct destruction
order.
A crash happens only when reports have been added in AnalysisConsumer::HandleTranslationUnit's BugReporter. We don't have such checkers in clang so no test.
Douglas Gregor [Sat, 7 Jan 2012 09:11:48 +0000 (09:11 +0000)]
Switch NamespaceDecl from its own hand-rolled redeclaration chain over
to Redeclarable<NamespaceDecl>, so that we benefit from the improveed
redeclaration deserialization and merging logic provided by
Redeclarable<T>. Otherwise, no functionality change.
As a drive-by fix, collapse the "inline" bit into the low bit of the
original namespace/anonymous namespace, saving 8 bytes per
NamespaceDecl on x86_64.
Eli Friedman [Sat, 7 Jan 2012 04:59:52 +0000 (04:59 +0000)]
More lambda work: semantic analysis of capturing 'this'. It's a bit complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.)
Anna Zaks [Sat, 7 Jan 2012 02:33:10 +0000 (02:33 +0000)]
[analyzer] Add basic format string vulnerability checking.
We already have a more conservative check in the compiler (if the
format string is not a literal, we warn). Still adding it here for
completeness and since this check is stronger - only triggered if the
format string is tainted.
Akira Hatanaka [Sat, 7 Jan 2012 00:25:33 +0000 (00:25 +0000)]
Add field PaddingType to ABIArgInfo which specifies the type of padding that
is inserted before the real argument. Padding is needed to ensure the backend
reads from or writes to the correct argument slots when the original alignment
of a byval structure is unavailable due to flattening.
objc++: more code gen stuff for atomic property api,
currently turned off. // rdar://6137845
Also, fixes a test case which should be nonatomic under
new API.
Ted Kremenek [Fri, 6 Jan 2012 22:09:28 +0000 (22:09 +0000)]
[analyzer] Make the entries in 'Environment' context-sensitive by making entries map from
(Stmt*,LocationContext*) pairs to SVals instead of Stmt* to SVals.
This is needed to support basic IPA via inlining. Without this, we cannot tell
if a Stmt* binding is part of the current analysis scope (StackFrameContext) or
part of a parent context.
This change introduces an uglification of the use of getSVal(), and thus takes
two steps forward and one step back. There are also potential performance implications
of enlarging the Environment. Both can be addressed going forward by refactoring the
APIs and optimizing the internal representation of Environment. This patch
mainly introduces the functionality upon when we want to build upon (and clean up).
Douglas Gregor [Fri, 6 Jan 2012 22:05:37 +0000 (22:05 +0000)]
During name lookup, use redecl_iterator to walk over the redeclaration
chain to determine whether any declaration of the given entity is
visible, eliminating the redundant (and less efficient)
getPreviousDeclaration() implementation.
This tweak uncovered an omission in the handling of
RedeclarableTemplateDecl, where we weren't making sure to search for
additional redeclarations of a template in other module files. Things
would be cleaner if RedeclarableTemplateDecl actually used Redeclarable.
Douglas Gregor [Fri, 6 Jan 2012 17:19:32 +0000 (17:19 +0000)]
When inferring a submodule ID during module creation, look up the
include stack to find the first file that is known to be part of the
module. This copes with situations where the module map doesn't
completely specify all of the headers that are involved in the module,
which can come up when there are very strange #include_next chains
(e.g., with weird compiler/stdlib headers like stdarg.h or float.h).
Douglas Gregor [Fri, 6 Jan 2012 16:59:53 +0000 (16:59 +0000)]
Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bits
into the two unused lower bits of the NextDeclInContext link, dropping
the number of bits in Decl down to 32, and saving 8 bytes per
declaration on x86-64.
Richard Smith [Fri, 6 Jan 2012 16:39:00 +0000 (16:39 +0000)]
C++11 generalized constant expressions: implement checking and diagnostics for
pointer-arithmetic-related undefined behavior and unspecified results. We
continue to fold such values, but now notice they aren't constant expressions.
Douglas Gregor [Fri, 6 Jan 2012 16:22:39 +0000 (16:22 +0000)]
Introduce a "Hidden" bit into Decl, to track whether that declaration
is hidden from name lookup. The previous hack of tweaking the
ModulePrivate bit when loading a declaration from a hidden submodule
was brittle.
Note that we now have 34 bits in Decl. I'll fix that next.
Improvements to the uninitialized variable warning: Check if the constructor
call is elidable or if the constructor is trivial instead of checking if it
is user declared.