Hans Wennborg [Mon, 27 Oct 2014 22:28:50 +0000 (22:28 +0000)]
Try to appease the C++ gods
Looks like some builds were not happy with the potentially-throwing move
constructor that was added in r220723, and reached for the implicitly
deleted copy constructor instead.
Kaelyn Takata [Mon, 27 Oct 2014 18:07:40 +0000 (18:07 +0000)]
Add simple way for a CorrectionCandidateCallback to reject exact
matches of the typo.
Also be more proactive about checking a correction's visibility so that
a correction requiring a module import can be distinguished from the
original typo even if it looks identical. Otherwise the correction will
be excluded and the diagnostic about needing the module import won't be
emitted.
Note that no change was made to checkCorrectionVisibility other than
moving where it is at in SemaLookup.cpp.
Kaelyn Takata [Mon, 27 Oct 2014 18:07:37 +0000 (18:07 +0000)]
Start adding the infrastructure for handling TypoExprs.
Part of the infrastructure is a map from a TypoExpr to the Sema-specific
state needed to correct it, along with helpers to ease dealing with the
state.
The the typo count is propagated up the stack of
ExpressionEvaluationContextRecords when one is popped off of to
avoid accidentally dropping TypoExprs on the floor. For example,
the attempted correction of g() in test/CXX/class/class.mem/p5-0x.cpp
happens with an ExpressionEvaluationContextRecord that is popped off
the stack prior to ActOnFinishFullExpr being called and the tree
transform for TypoExprs being run.
Kaelyn Takata [Mon, 27 Oct 2014 18:07:34 +0000 (18:07 +0000)]
Have TypoCorrectionConsumer remember the TypoCorrections it returned.
Two additional methods are provided: one to return the current
correction (the last correction returned by getNextCorrection), and one
to "reset" the state so that getNextCorrection will return the previous
corrections before returning any new corrections.
Also ensure that all TypoCorrections have valid source ranges.
Kaelyn Takata [Mon, 27 Oct 2014 18:07:13 +0000 (18:07 +0000)]
Move TypoCorrectionConsumer into a header.
This makes it available outside of SemaLookup.cpp, as
needed for the forthcoming TypoExpr AST node which will
keep a TypoCorrectionConsumer that provides the possible
typo corrections for that TypoExpr.
Improve the documentation for vim integration of clang-format. Prefer the use
of <c-o> to do the normal mode command execution to avoid side-effects of the
escape and re-insertion (cursor movement). Tweak the macros to use a double
return to avoid having to manually return control to the editor from the
subprocess.
Samuel Benzaquen [Mon, 27 Oct 2014 15:22:59 +0000 (15:22 +0000)]
Speed up clang-tidy when profiling in on.
Summary:
Speed up clang-tidy when profiling in on.
It makes profiling runs twice as fast by reusing the time samples between the
different actions.
It also joins together the sampling of different matchers of the same check.
Add a fake linker in to a sysroot to use for testing the driver's tool
invocation. Should make the test behave similarly on all platforms. Addresses
review comments from Reid Kleckner from SVN r220546.
David Majnemer [Sat, 25 Oct 2014 11:40:40 +0000 (11:40 +0000)]
Lex: Fix an invalid access into a SmallString
We would crash because we used operator[] to access past the end of a
SmallString. This occured because our token had length zero.
Instead, form the pointer using .data() and arithmetic. This is safe
because this forms a one-past-the-end pointer and it is only used to
compare with another one-past-the-end pointer.
CodeGen: correct materialize temporary aggregates in ARC mode
Avoid an assertion when materializing a lifetime type aggregate temporary. When
performing CodeGen for ObjC++, we could generate a lifetime-only aggregate
temporary by using an initializer list (which is effectively an array). We
would reach through the temporary expression, fishing out the inner expression.
If this expression was a lifetime expression, we would attempt to emit this as a
scalar. This would eventually result in an assertion as the emission would
eventually assert that the expression being emitted has a scalar evaluation
kind.
Add a case to handle the aggregate expressions. Use the EmitAggExpr to emit the
aggregate expression rather than the EmitScalarInit.
David Majnemer [Fri, 24 Oct 2014 20:22:57 +0000 (20:22 +0000)]
Itanium ABI: Template template parameters are usable as substitutions
Template template parameters weren't added to the list of substitutions.
This would make the substitution map contain inaccurate mappings,
leading to Clang violating the Itanium ABI and breaking compatibility
with GCC.
David Majnemer [Fri, 24 Oct 2014 19:49:04 +0000 (19:49 +0000)]
CodeGen: GLValue exprs in template parameters should have reference type
This fixes a corner-case where __uuidof as a template argument would
result in us trying to emit a GLValue as an RValue. This would lead to
a crash down the road.
Daniel Sanders [Fri, 24 Oct 2014 15:30:16 +0000 (15:30 +0000)]
[mips] Mark aggregate arguments passed in registers with the inreg attribute
Summary:
This allows us to easily identify them in the backend which in turn allows us
to handle them correctly for big-endian targets (where they must be shifted
into the upper bits of the register).
Daniel Sanders [Fri, 24 Oct 2014 14:42:42 +0000 (14:42 +0000)]
[mips] Promote all integral/enumeration types to the GPR width
Summary:
Ensure all integral/enumeration types are appropriately annotated with
signext/zeroext. In particular, i32 now has these attributes when using the
N32/N64 ABI. This paves the way for accurately representing the way the
N32/N64 ABI's promotes integer arguments to i64.
Olivier Goffart [Fri, 24 Oct 2014 13:52:55 +0000 (13:52 +0000)]
Fix initializing TypeOfTypeLoc
This fixes a crash in the RecursiveASTVisitor on such code
__typeof__(struct F*) var[invalid];
The UnderlyingTInfo of a TypeOfTypeLoc was left uninitialized when
created from ASTContext::getTrivialTypeSourceInfo
This lead to a crash in RecursiveASTVisitor when trying to access it.
Oliver Stannard [Fri, 24 Oct 2014 11:28:47 +0000 (11:28 +0000)]
[Thumb] Clang thinks "char" is signed when using a thumb triple
'char' is unsigned on all ARM and Thumb architectures. Clang gets this
right for ARM, and for thumb when using and arm triple and the -mthumb
option, but gets it wrong for thumb triples. This fixes that.
This is a very basic toolchain. It supports cross-compiling Windows (primarily
inspired by the WoA target). It is meant to use clang with the LLVM IAS and a
binutils ld-compatible interface for the linker (eventually to be lld). It does
not perform any "standard" GCC lookup, nor does it perform any special
adjustments given that it is expected to be used in an environment where the
user is using MSVCRT (and as such Visual Studio headers) and the Windows SDK.
The primary runtime library is expected to be compiler-rt and the C++
implementation to be libc++.
It also expects that a sysroot has been setup given the usual Unix semantics
(standard C headers in /usr/include, all the import libraries available in
/usr/lib). It also expects that an entry point stub is present in /usr/lib
(crtbegin.obj for executables, crtbeginS.obj for shared libraries).
The entry point stub is responsible for running any GNU constructors.
Hans Wennborg [Thu, 23 Oct 2014 22:40:46 +0000 (22:40 +0000)]
Don't emit strong vtable definitions for imported classes with key functions (PR21355)
Clang would previously assert on the following code when targeting MinGW:
struct __declspec(dllimport) S {
virtual ~S();
};
S::~S() {}
Because ~S is a key function and the class is dllimport, we would try to emit a
strong definition of the vtable, with dllimport - which is a conflict. We
should not emit strong vtable definitions for imported classes.
Justin Bogner [Thu, 23 Oct 2014 22:20:11 +0000 (22:20 +0000)]
Driver: Include driver diagnostics when we --serialize-diagnostics
Currently, when --serialize-diagnostics is passed this only includes
the diagnostics from clang -cc1, and driver diagnostics are
dropped. This causes issues for tools that use the serialized
diagnostics, since stderr is lost and these diagnostics aren't seen at
all.
We handle this by merging the diagnostics from the CC1 process and the
driver diagnostics into a single file when the driver invokes CC1.
patch to issue warning on comparing parameters with
nonnull attribute when comparison is always
true/false. Patch by Steven Wu with few fixes and minor
refactoring and adding tests by me. rdar://18712242
Ben Langmuir [Thu, 23 Oct 2014 18:05:36 +0000 (18:05 +0000)]
Add a "signature" to AST files to verify that they haven't changed
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs)
is not stable, it is not safe to load an AST file that depends on
another AST file that has been rebuilt since the importer was built,
even if "nothing changed". We previously used size and modtime to check
this, but I've seen cases where a module rebuilt quickly enough to foil
this check and caused very hard to debug build errors.
To save cycles when we're loading the AST, we just generate a random
nonce value and check that it hasn't changed when we load an imported
module, rather than actually hash the whole file.
This is slightly complicated by the fact that we need to verify the
signature inside addModule, since we might otherwise consider that a
mdoule is "OutOfDate" when really it is the importer that is out of
date. I didn't see any regressions in module load time after this
change.
David Blaikie [Thu, 23 Oct 2014 16:39:49 +0000 (16:39 +0000)]
DebugInfo: Correctly describe the lexical decl context of static member variable definitions.
The previous IR representation used the non-lexical decl context, which
placed the definitions in the same scope as the declarations (ie: within
the class) - this was hidden by the fact that LLVM currently doesn't
respect the context of global variable definitions at all, and always
puts them at the top level (as direct children of the compile_unit).
Having the correct lexical scope improves source fidelity and simplify
backend global variable emission (with changes coming shortly).
Doing something similar for non-member global variables would help
simplify/cleanup things further (see FIXME in the commit) and provide
similar source fidelity benefits to the final debug info.
Richard Smith [Thu, 23 Oct 2014 02:01:19 +0000 (02:01 +0000)]
Refactor implementation of 'exclude header'.
This was not a real header role, and was never exposed to clients of ModuleMap.
Remove the enumeration value for it and track it as marking the header as
'known' rather than creating an extra KnownHeader entry that *every single*
client ignores.
Alexey Samsonov [Thu, 23 Oct 2014 00:46:10 +0000 (00:46 +0000)]
Revert r218541 - Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is provided.
This is a sad thing to do, but all the alternatives look ugly.
Looks like there are legitimate cases when users may want to link
with sanitizer runtimes *and* -nodefaultlibs (and ensure they provide
replacements for system libraries). For example, this happens in libc++
test suite.
"-nodefaultlibs" is told to link only the libraries explicitly provided
by the user, and providing "-fsanitize=address" is a clear indication of
intention to link with ASan runtime.
We can't easily introduce analogue of "-print-libgcc-name": linking with
sanitizers runtimes is not trivial: some runtimes are split into several
archive libraries, which are required to be wrapped in
-whole-archive/-no-whole-archive.
If "-fsanitize=whatever" and "-nodefaultlibs" are provided, system library
dependencies of sanitizer runtimes (-lc/-ldl/-lpthread/-lrt) will *not* be
linked, and user would have to link them in manually. Note that this can
cause problems, as failing to provide "-lrt" might lead to crashes in runtime
during ASan initialization. But looks like we should bite this bullet.
Richard Smith [Wed, 22 Oct 2014 23:50:56 +0000 (23:50 +0000)]
[modules] Add support for 'textual header' directives.
This allows a module to specify that it logically contains a file, but that
said file is non-modular and intended for textual inclusion. This allows
layering checks to work properly in the presence of such files.
Aaron Ballman [Wed, 22 Oct 2014 21:06:18 +0000 (21:06 +0000)]
Removing the setLBracLoc and setRBracLoc functions from CompoundStmt -- their only use was with the AST reader, and friendship can be used to handle that. Drive-by rename of "Brac" to "Brace" for the private data members. NFC.
Zachary Turner [Wed, 22 Oct 2014 20:40:43 +0000 (20:40 +0000)]
Make a good guess about where MSVC and Windows SDK libraries are for linking.
When a user has not configured a standard Visual Studio environment
by running vcvarsall, clang tries its best to find Visual Studio
include files and executables anyway. This patch makes clang also
try to find system and Windows SDK libraries for linking against,
as well.
Reviewed by: Hans Wennborg
Differential Revision: http://reviews.llvm.org/D5873
Zachary Turner [Wed, 22 Oct 2014 20:40:28 +0000 (20:40 +0000)]
Resubmit "Improve Windows toolchain support for non-standard environments."
This resubmits change r220226. That change broke the chromium
build bots because chromium it ships an hermetic MSVC toolchain
that it expects clang to fallback to by finding it on the path.
This patch fixes the issue by bumping up the prioritization of PATH
when looking for MSVC binaries.
Reviewed by: Hans Wennborg, Reid Kleckner
Differential Revision: http://reviews.llvm.org/D5892
David Blaikie [Wed, 22 Oct 2014 19:54:16 +0000 (19:54 +0000)]
Correct importing of the type of a TemplateArgument
It's not clear how this would be tested - I imagine we should have an
ASTImporter test that RAVs the new AST and checks that all the elements
in it are from this ASTContext and not the foreign one... but I know
little about the ASTImporter and how/where that testing might be done.
(post-commit review feedback from Richard Smith on r219900)
Alexey Samsonov [Wed, 22 Oct 2014 18:26:07 +0000 (18:26 +0000)]
SanitizerBlacklist: Use spelling location for blacklisting purposes.
When SanitizerBlacklist decides if the SourceLocation is blacklisted,
we need to first turn it into a SpellingLoc before fetching the filename
and scanning "src:" entries. Otherwise we will fail to fecth the
correct filename for function definitions coming from macro expansion.
Reid Kleckner [Wed, 22 Oct 2014 17:50:19 +0000 (17:50 +0000)]
Reland r219810 "Fix late template parsing leak with incremental processing"
Original message:
Add a second late template parser callback meant to cleanup any
resources allocated by late template parsing. Call it from the
Sema::ActOnEndOfTranslationUnit method after all pending template
instantiations have been completed. Teach Parser::ParseTopLevelDecl to
install the cleanup callback when incremental processing is enabled so
that Parser::TemplateIds can be freed.
Reid Kleckner [Wed, 22 Oct 2014 17:26:00 +0000 (17:26 +0000)]
MS ABI: Emit more canonical vbptr stores and loads
This eliminates some i8* GEPs and makes the IR that clang emits a bit
more canonical. More work is needed for vftables, but that isn't a clear
win so I plan to send it for review.
Diego Novillo [Wed, 22 Oct 2014 13:00:05 +0000 (13:00 +0000)]
Support using sample profiles with partial debug info (driver)
Summary:
When using a profile, we used to require the use -gmlt so that we could
get access to the line locations. This is used to match line numbers in
the input profile to the line numbers in the function's IR.
But this is actually not necessary. The driver can provide source
location tracking without the emission of debug information. In these
cases, the annotation 'llvm.dbg.cu' is missing from the IR, but the
actual line location annotations are still present.
This patch tells the driver to only emit source location tracking
when -fprofile-sample-use is present in the command line.