Chris Lattner [Mon, 28 Feb 2011 00:22:07 +0000 (00:22 +0000)]
First tiny step to implementing PR9322: build infrastructure for only emitting the
live case of a switch statement when switching on a constant. This is terribly
limited, but enough to handle the trivial example included. Before we would
emit:
This improves -O0 compile time (less IR to generate and shove through the code
generator) and the clever linux kernel people found a way to fail to build if we
don't do this optimization. This step isn't enough to handle the kernel case
though.
Douglas Gregor [Mon, 28 Feb 2011 00:04:36 +0000 (00:04 +0000)]
When we encounter a dependent template name within a
nested-name-specifier, e.g.,
T::template apply<U>::
represent the dependent template name specialization as a
DependentTemplateSpecializationType, rather than a
TemplateSpecializationType with a dependent TemplateName.
Douglas Gregor [Sun, 27 Feb 2011 22:46:49 +0000 (22:46 +0000)]
Eliminate a silly little Parse/Sema dance when parsing typename
specifiers such as
typename T::template apply<U>
Previously, we would turn T::template apply<U> into a
TemplateSpecializationType. Then, we'd reprocess that
TemplateSpecializationType and turn it into either a
TemplateSpecializationType wrapped in an ElaboratedType (when we could
resolve "apply" to a template declaration) or a
DependentTemplateSpecializationType. We now produce the same ASTs but
without generating the intermediate TemplateSpecializationType.
The end goal here is to avoid generating TemplateSpecializationTypes
with dependent template-names, ever. We're not there yet.
Sean Hunt [Sat, 26 Feb 2011 19:13:13 +0000 (19:13 +0000)]
Implement delegating constructors partially.
This successfully performs constructor lookup and verifies that a
delegating initializer is the only initializer present.
This does not perform loop detection in the initialization, but it also
doesn't codegen delegating constructors at all, so this won't cause
runtime infinite loops yet.
John McCall [Sat, 26 Feb 2011 08:07:02 +0000 (08:07 +0000)]
Pretty up the emission of field l-values and use volatile and TBAA when
loading references as part of that. Use 'char' TBAA when accessing
(immediate!) fields of a may_alias struct; fixes PR9307.
John McCall [Sat, 26 Feb 2011 05:39:39 +0000 (05:39 +0000)]
Provide a bit saying that a builtin undergoes custom type-checking, then
don't let calls to such functions go down the normal type-checking path.
Test this out with __builtin_classify_type and __builtin_constant_p.
Ted Kremenek [Fri, 25 Feb 2011 22:00:40 +0000 (22:00 +0000)]
Enhance scan-build to print out available analyses using new checker registration model.
This isn't totally complete. Right now scan-build uses some heuristics to determine
which checkers are enabled by default, but it cannot always tell which checkers
are not enabled.
Douglas Gregor [Fri, 25 Feb 2011 20:49:16 +0000 (20:49 +0000)]
Push nested-name-specifier source location information into
DependentScopeDeclRefExpr. Plus, give NestedNameSpecifierLoc == and !=
operators, since we're going to need 'em elsewhere.
Chandler Carruth [Fri, 25 Feb 2011 19:41:05 +0000 (19:41 +0000)]
Remove the FIXME I introduced last night, and pull the logic for
marking selected overloads into the callers. This allows a few callers
to skip it altogether (they would have anyways because they weren't
interested in successful overloads) or defer until after further checks
take place much like the check required for PR9323 to avoid marking
unused copy constructors.
Douglas Gregor [Fri, 25 Feb 2011 18:19:59 +0000 (18:19 +0000)]
Push nested-name-specifier source-location information into
pseudo-destructor expressions. Also, clean up some
template-instantiation and type-checking issues with
pseudo-destructors.
Chandler Carruth [Fri, 25 Feb 2011 08:52:25 +0000 (08:52 +0000)]
Rough fix for PR9323 that prevents Clang from marking copy constructor
declarations as referenced when in fact we're not going to even form
a call in the AST. This is significant because we attempt to allow as an
extension classes with intentionally private and undefined copy
constructors to have temporaries bound to references, and so shouldn't
warn about the lack of definition for that copy constructor when the
class is internal.
Doug, John wasn't really satisfied with the presence of overloading at
all. This is a stop-gap and there may be a better solution. If you can
give me some hints for how you'd prefer to see this solved, I'll happily
switch things over.
John McCall [Fri, 25 Feb 2011 04:19:13 +0000 (04:19 +0000)]
Tame an assert; the scope depth of a jump destination does not
necessarily enclose the innermost normal cleanup depth, because
the top of the jump scope stack might be an EH cleanup or EH scope.
Fixes PR9303.
Douglas Gregor [Fri, 25 Feb 2011 02:25:35 +0000 (02:25 +0000)]
Use NestedNameSpecifierLoc within out-of-line variables, function, and
tag definitions. Also, add support for template instantiation of
NestedNameSpecifierLocs.
Douglas Gregor [Fri, 25 Feb 2011 00:36:19 +0000 (00:36 +0000)]
Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the
extremely-lossy NestedNameSpecifier/SourceRange pair it used to use,
improving source-location information.
Various infrastructure updates to support NestedNameSpecifierLoc:
- AST/PCH (de-)serialization
- Recursive AST visitor
- libclang traversal (including the first tests of this
functionality)
Chandler Carruth [Fri, 25 Feb 2011 00:05:02 +0000 (00:05 +0000)]
Fix the rest of PR9316 along with some other bugs spotted by inspection.
I tried to add test cases for these, but I can't because variables
aren't warned on the way functions are and the codegen layer appears to
use different logic for determining that 'a' and 'g' in the test case
should receive C mangling. I've included the test so that if we ever
switch the codegen layer to use these functions, we won't regress due to
latent bugs.
[analyzer] Allow a checker to be hidden even if its package is hidden & enabled.
For example, if 'core.experimental.UnreachableCode' is hidden, it should not be enabled with 'core.experimental'.
Note that this requires llvm commit r126436.
Douglas Gregor [Thu, 24 Feb 2011 17:54:50 +0000 (17:54 +0000)]
Retain complete source-location information for C++
nested-name-specifiers throughout the parser, and provide a new class
(NestedNameSpecifierLoc) that contains a nested-name-specifier along
with its type-source information.
Right now, this information is completely useless, because we don't
actually store the source-location information anywhere in the
AST. Call this Step 1/N.
Axel Naumann [Thu, 24 Feb 2011 16:47:47 +0000 (16:47 +0000)]
From Vassil Vassilev:
Add an interface for last resort, unqualified lookup. It can provide results for unqualified lookup when Sema fails to find anything itself.
Chris Lattner [Thu, 24 Feb 2011 07:31:28 +0000 (07:31 +0000)]
compute the integer width, not the memory width here. We want to know that
_Bool is 1 bit, not 8. This fixes an assertion on the testcase, which is
PR9304 and rdar://9045501.
Ted Kremenek [Thu, 24 Feb 2011 03:09:15 +0000 (03:09 +0000)]
Fix tiny error in CFG construction for BinaryConditionalOperators, making sure the branch always has two successors. Also teach Environment::getSVal() about OpaqueValueExprs.
This fixes a crash reported in PR9287, and also fixes a false positive involving the value of such ternary
expressions not properly getting propagated.
Douglas Gregor [Thu, 24 Feb 2011 02:36:08 +0000 (02:36 +0000)]
Teach NestedNameSpecifier to keep track of namespace aliases the same
way it keeps track of namespaces. Previously, we would map from the
namespace alias to its underlying namespace when building a
nested-name-specifier, losing source information in the process.
Ken Dyck [Thu, 24 Feb 2011 02:12:14 +0000 (02:12 +0000)]
Use CharUnits values for Size and DataSize outside of the bitfield layout
methods, when they are known to be exact multiples of the width of the char
type.
Ken Dyck [Thu, 24 Feb 2011 01:13:28 +0000 (01:13 +0000)]
Make the Size and DataSize members more CharUnits-friendly by wrapping them
with getter and setter methods in both bit units and CharUnits. This will help
simplify some of the unit mismatch in the parts of the code where sizes are
known to be exact multiples of the width of the char type.
Assertions in the getters help guard against accidentally converting to
CharUnits when sizes are not exact multiples of the char width.
Douglas Gregor [Thu, 24 Feb 2011 00:17:56 +0000 (00:17 +0000)]
Teach CXXScopeSpec to handle the extension of a nested-name-specifier
with another component in the nested-name-specifiers, updating its
representation (a NestedNameSpecifier) and source-location information
(currently a SourceRange) simultaneously. This is groundwork for
adding source-location information to nested-name-specifiers.
Chandler Carruth [Wed, 23 Feb 2011 23:52:14 +0000 (23:52 +0000)]
Clean up the CMake test execution by nuking this directory before we try
to create it. Lit doesn't apparently clean up test directories
effectively, and so this broke randomly on subsequent runs.
Also XFAIL the test on windows, as there's not much hope for these
commands doing the right thing there.
Chandler Carruth [Wed, 23 Feb 2011 23:34:11 +0000 (23:34 +0000)]
Implement a warning for known shift overflows on constant shift
expressions. Consider the code:
int64_t i = 10 << 30;
This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.
The warning is currently gated behind -Wshift-overflow.
There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.
Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.
-Introduce EndOfFunctionNodeBuilder::withCheckerTag to allow it be "specialized" with a
checker tag and not require the checkers to pass a tag.
-For EndOfFunctionNodeBuilder::generateNode, reverse the order of tag/P parameters since
there are actual calls that assume the second parameter is ExplodedNode.