Commit Graph

190 Commits

Author SHA1 Message Date
Logan Chien d3d385d624 Frontend: Fix SourceColumnMap assertion failure on non-ascii characters.
If there are some non-ascii character in the input source code, the
column index might be smallar than the byte index.  This will result
in two possible assertion failures.  This CL fixes the computation of
the column index and byte index.

1. The assertion in startOfNextColumn() and startOfPreviousColumn()
   should not be raised when the byte index is greater than the column
   index since the non-ascii characters may use more than one bytes to
   store a character in a column.

2. The length of the caret line should be equal to the number of columns
   of source line, instead of the length of the source line.  Otherwise,
   the assertion in selectInterestingSourceRegion will be raised because
   the removed columns plus the kept columns are not greater than the max
   column, which means that we should not remove any column at all.

llvm-svn: 225442
2015-01-08 13:19:07 +00:00
Nico Weber 007215044b Add driver flags -ftrigraphs, -fno-trigraphs.
-trigraphs is now an alias for -ftrigraphs.  -fno-trigraphs makes it possible
to explicitly disable trigraphs, which couldn't be done before.

  clang -std=c++11 -fno-trigraphs

now builds without GNU extensions, but with trigraphs disabled.  Previously,
trigraphs were only disabled in GNU modes or with -std=c++1z.

Make the new -f flags the cc1 interface too.  This requires changing -trigraphs
to -ftrigraphs in a few cc1 tests.

Related to PR21974.

llvm-svn: 224790
2014-12-23 22:32:37 +00:00
Nico Weber b62ba516e7 Disable trigraphs in microsoft mode by default. Matches cl.exe.
The default value of Opts.Trigraphs now no longer depends solely on the
language input kind, so move the code out of setLangDefaults().  Also make
sure that Opts.MSVCCompat is set before the Trigraph code runs.

Related to PR21974.

llvm-svn: 224719
2014-12-22 18:35:03 +00:00
Nico Weber 4f371b031b Add test coverage for cc1's trigraph option handling.
llvm-svn: 224714
2014-12-22 17:56:50 +00:00
Reid Kleckner dccbabfacf Destroy the diagnostic client first in ~DiagnosticEngine
Add a comment and a test to ~DiagnosticEngine about the ordering
requirements on the teardown of DiagnosticConsumer. This could also be
accomplished by rearranging the fields of ~DiagnosticEngine, but I felt
that this was a better, more explicit solution.

This fixes PR21911, an issue that occurred after the unique_ptr
migration in r222193.

llvm-svn: 224454
2014-12-17 20:23:11 +00:00
Rafael Espindola fd8de1c3ae Fix handling of invalid -O options.
We were checking the value after truncating it to a bitfield.

Thanks to Yunzhong Gao for noticing it.

llvm-svn: 224378
2014-12-16 21:57:03 +00:00
Chandler Carruth a94a68a8d2 Don't actually generate code for testing the frontend's target cpu flag,
just verify. This should fix the bots where the x86 backend isn't built
into Clang. Sorry for the breakage.

llvm-svn: 223779
2014-12-09 15:52:55 +00:00
Chandler Carruth 04ca0bba9c Re-work the Clang system for classifying Intel x86 CPUs to use their
basic microarchitecture names, and add support (with tests) for parsing
all of the masic microarchitecture names for CPUs documented to be
accepted by GCC with -march. I didn't go back through the 32-bit-only
old microarchitectures, but this at least brings the recent architecture
names up to speed. This is essentially the follow-up to the LLVM commit
r223769 which did similar cleanups for the LLVM CPUs.

One particular benefit is that you can now use -march=westmere in Clang
and get the LLVM westmere processor which is a different ISA variant (!)
and so quite significant.

Much like with r223769, I would appreciate the Intel folks carefully
thinking about the macros defined, names used, etc for the atom chips
and newest primary x86 chips. The current patterns seem quite strange to
me, especially here in Clang.

Note that I haven't replicated the per-microarchitecture macro defines
provided by GCC. I'm really opposed to source code using these rather
than using ISA feature macros.

llvm-svn: 223776
2014-12-09 14:50:25 +00:00
Anastasia Stulova 561e0aa180 Extended list of valid frontend options with '-cl-std=CL2.0'.
This option sets language mode for the compilation of a source file to be OpenCL v2.0.

Example: clang -cc1 -cl-std=CL2.0 myfile.cl
llvm-svn: 222444
2014-11-20 19:25:00 +00:00
David Majnemer 8ef921a48b Frontend: Define __EXCEPTIONS if -fexceptions is passed
GCC defines __EXCEPTIONS, regardless of language mode, if -fexceptions
is passed.  We should do the same.

This fixes PR21358.

llvm-svn: 220714
2014-10-27 20:02:19 +00:00
Diego Novillo 795f53ba64 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.

Reviewers: echristo, dblaikie

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5888

llvm-svn: 220383
2014-10-22 13:00:05 +00:00
Aaron Ballman c0a596eabd This test was updated in r216397, but was failing on Windows due to mixed path separators as well as case sensitivity of the "no" in "no such file or directory." Rather than revert this file back to its original form, I've made some incredibly ugly regexes so that it will pass everywhere.
Note, the path this test reports a failure on (for my Windows setup) is: E:\llvm\llvm\tools\clang\test\Frontend/doesnotexist/somename

llvm-svn: 216456
2014-08-26 14:09:25 +00:00
Rafael Espindola dae941a6c8 Update for llvm api change.
llvm-svn: 216397
2014-08-25 18:17:04 +00:00
NAKAMURA Takumi 70e3646d22 clang/test/Frontend/print-header-includes.c REQUIRES shell due to "cd".
llvm-svn: 215434
2014-08-12 09:31:27 +00:00
Manuel Klimek 9af34aeac1 Correctly implement -include search logic.
According to the gcc docs, -include uses the current working directory
for the lookup instead of the main source file.

This patch gets rid of NormalizeIncludePath (which relied on an
implementation detail of FileManager / FileEntry for the include path
logic to work), and instead hands the correct lookup information down to
LookupFile.

This will allow us to change the FileEntry's behavior regarding its Name
caching.

llvm-svn: 215433
2014-08-12 08:25:57 +00:00
Bob Wilson 2a3710ec9e Change __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ for versions > 10.9.
The previous encoding only allowed a single digit for the minor version
number. This changes it to use 2 digits for both the minor version and the
revision number.

llvm-svn: 215245
2014-08-08 21:45:53 +00:00
Richard Smith 3be1cb294f Use -Rblah, not -Wblah, to control remark diagnostics. This was always the
intent when we added remark support, but was never implemented in the general
case, because the first -R flags didn't need it. (-Rpass= had special handling
to accomodate its argument.)

-Rno-foo, -Reverything, and -Rno-everything can be used to turn off a remark,
or to turn on or off all remarks. Per discussion on cfe-commits, -Weverything
does not affect remarks, and -Reverything does not affect warnings or errors.

The only "real" -R flag we have right now is -Rmodule-build; that flag is
effectively renamed from -Wmodule-build to -Rmodule-build by this change.

-Wpass and -Wno-pass (and their friends) are also renamed to -Rpass and
-Rno-pass by this change; it's not completely clear whether we intended to have
a -Rpass (with no =pattern), but that is unchanged by this commit, other than
the flag name. The default pattern is effectively one which matches no passes.
In future, we may want to make the default pattern be .*, so that -Reverything
works for -Rpass properly.

llvm-svn: 215046
2014-08-07 00:24:21 +00:00
Alp Toker a3c494f0db Revert "clang/test/Driver/crash-report.c: This requires rewriter for -frewrite-includes. [PR20321]"
We've decided to make the core rewriter class and PP rewriters mandatory.
They're only a few hundred lines of code in total and not worth supporting as a
distinct build configuration, especially since doing so disables key compiler
features.

This reverts commit r213150.

Revert "clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter."

This reverts commit r213148.

Revert "Move clang/test/Frontend/rewrite-*.c to clang/test/Frontend/Rewriter/"

This reverts commit r213146.

llvm-svn: 213159
2014-07-16 15:12:48 +00:00
NAKAMURA Takumi 692d6bb544 clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter.
llvm-svn: 213148
2014-07-16 13:36:39 +00:00
NAKAMURA Takumi f596539288 Move clang/test/Frontend/rewrite-*.c to clang/test/Frontend/Rewriter/
llvm-svn: 213146
2014-07-16 13:23:13 +00:00
NAKAMURA Takumi 7d452f198d Trailing linefeed.
llvm-svn: 213145
2014-07-16 13:21:58 +00:00
Alp Toker cd3acb5604 Avoid non-attributive uses of 'unsupported' in diagnostics
We don't have a style guide for diagnostic messages, but convention strongly
favours the forms:

  'attribute is not supported', 'unsupported attribute'

We generally avoid:

  'attribute is unsupported', 'non-supported attribute'

llvm-svn: 212972
2014-07-14 19:16:22 +00:00
Andy Gibbs c1f152ee6c Provide -verify support to match "any" line for diagnostics in included files.
Allow diagnostic checks that originate in included files to be matched without necessarily determining the line number that the diagnostic occurs on.  The new syntax replaces the line number with '*'.  This extension is limited to diagnostics in included files and may be used where the include file is not part of the test-suite itself.

Expected uses are for diagnostics originating in system headers, or for users who use -verify in testing 3rd-party library code where the location of diagnostics in header files may change from revision to revision and their precise location is not important to the success of the test-case.

llvm-svn: 212735
2014-07-10 16:43:29 +00:00
Nico Weber 2582895832 clang-cl: /showIncludes output should go to stdout, not stderr. Fixes PR20217.
llvm-svn: 212383
2014-07-06 03:04:24 +00:00
Alp Toker 1d1ac112f0 Account for differences in grep implementations
llvm-svn: 211856
2014-06-27 03:11:38 +00:00
Alp Toker 830c34e269 Restore test from r211844 skipping '.file' directives
At least this answers the question of whether .bc/.ll input processed by the
frontend produces identical output to the original compilation.

llvm-svn: 211853
2014-06-27 02:59:39 +00:00
Alp Toker 8e7e1b87c6 Partially disable test from r211844
ELF assembly contains .line directives that differ based on the input filename.
Weaken the test while considering options.

llvm-svn: 211849
2014-06-27 02:35:57 +00:00
Alp Toker 1a5a520d95 Add test coverage for .bc input in the frontend
Test that we can consume LLVM bitcode and additionally check that it produces
the same output as a direct compilation.

The feature is crashy and has gone untested until now, but we might as well
provide some coverage as long as it remains in tree.

Also test LL source input in the same way because the existing tests for that
don't look convincing.

llvm-svn: 211844
2014-06-27 02:04:28 +00:00
Alp Toker aab3a8f2fb Remove .bc from test config.suffixes
This was unused. Besides, a binary file can't really contain lit ShTests.

llvm-svn: 211843
2014-06-27 02:04:21 +00:00
Alp Toker 51dc8e9b53 Simplify optimization-remark.c test following r211610
With LocTrackingOnly there's no longer a user-facing distinction so the NDEBUG
checks can go away. (Except maybe column info, but -verify only checks line
numbers anyway.)

Also add a RUN line to validate the traditional !LocTrackingOnly case.

llvm-svn: 211622
2014-06-24 19:23:10 +00:00
David Blaikie bcc6004a0e Fix test added in r211610 so it doesn't race on output file creation.
llvm-svn: 211615
2014-06-24 17:31:05 +00:00
Diego Novillo 913690c7bc Add new debug kind LocTrackingOnly.
Summary:
This new debug emission kind supports emitting line location
information in all instructions, but stops code generation
from emitting debug info to the final output.

This mode is useful when the backend wants to track source
locations during code generation, but it does not want to
produce debug info. This is currently used by optimization
remarks (-Rpass, -Rpass-missed and -Rpass-analysis).

When one of the -Rpass flags is used, the front end will enable
location tracking, only if no other debug option is enabled.

To prevent debug information from being generated, a new debug
info kind LocTrackingOnly causes DIBuilder::createCompileUnit() to
not emit the llvm.dbg.cu annotation. This blocks final code generation
from generating debug info in the back end.

Depends on D4234.

Reviewers: echristo, dblaikie

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4235

llvm-svn: 211610
2014-06-24 17:02:17 +00:00
Hans Wennborg 35bbf1cf8a Do not predefine __EXCEPTIONS in clang-cl (PR19977)
Patch by Ehsan Akhgari! (Test tweak by me.)

Differential Revision: http://reviews.llvm.org/D4065

llvm-svn: 210582
2014-06-10 20:46:38 +00:00
Alp Toker d08473415f Make '-Werror=frame-larger-than=' and associated diagnostic pragmas GCC-compatible
It turns out the trailing '=' really is part of the option name spelling and
treating it as such gets us compatible with GCC's -Werror= and pragmas.

(GCC doesn't appear to support any -Wno- form for this diagnostic but we do.)

llvm-svn: 210503
2014-06-09 23:59:38 +00:00
Alp Toker 7ce5f025a3 Don't generate assembly in backend diagnostic tests
A leftover -S was generating unwanted output in the source tree overriding
-only flags that normally disable output.

This reverts commit r210323 and implements the proper fix.

Reported by Timur Iskhodzhanov!

llvm-svn: 210326
2014-06-06 11:20:58 +00:00
Timur Iskhodzhanov 27700e28de Add -o /dev/null to one of the tests as it fails when run from a read-only checkout
llvm-svn: 210323
2014-06-06 10:58:21 +00:00
Alp Toker 27506271b4 Provide fallback locations for backend remarks
Instead of disembodied diagnostics when debug info is disabled it's now
possible to identify the associated function's location in order to provide
some amount of of context.

We use the definition's body right brace location to differentiate the fallback
from diagnostics that genuinely relate to the function declaration itself (a
convention also used by gcc).

llvm-svn: 210294
2014-06-05 22:11:12 +00:00
Alp Toker fb8d02b179 Implement -Wframe-larger-than backend diagnostic
Add driver and frontend support for the GCC -Wframe-larger-than=bytes warning.
This is the first GCC-compatible backend diagnostic built around LLVM's
reporting feature.

This commit adds infrastructure to perform reverse lookup from mangled names
emitted after LLVM IR generation. We use that to resolve precise locations and
originating AST functions, lambdas or block declarations to produce seamless
codegen-guided diagnostics.

An associated change, StringMap now maintains unique mangled name strings
instead of allocating copies. This is a net memory saving in C++ and a small
hit for C where we no longer reuse IdentifierInfo storage, pending further
optimisation.

llvm-svn: 210293
2014-06-05 22:10:59 +00:00
Alp Toker ea04672c82 Fix leak from r210059
Also revert r210096 which temporarily disabled the test while this was being
investigated.

llvm-svn: 210115
2014-06-03 17:23:34 +00:00
Kostya Serebryany be6d91f1ba temporary disable part of a test because it causes clang to leak memory (want to have the sanitizer bot green)
llvm-svn: 210096
2014-06-03 11:45:37 +00:00
Alp Toker cf2048bbb3 Fix -emit-codegen-only to not generate binaries
llvm-svn: 210059
2014-06-03 02:14:20 +00:00
Diego Novillo 6bfdaf5a20 Remove unnecessary test.
llvm-svn: 209893
2014-05-30 13:19:28 +00:00
NAKAMURA Takumi 2a07bf4ef7 clang/test/Frontend/Weverything-and-remarks.cpp: Add explicit -target.
You could see unexpected result (*.tmp.err) with "-target x86_64-win32".

  Weverything-and-remarks.cpp:11:9: warning: 'char32_t' type specifier is incompatible with C++98 [-Wc++98-compat]
  typedef __char32_t char32_t;
          ^
  Weverything-and-remarks.cpp:12:27: error: typedef redefinition with different types ('unsigned long' vs 'unsigned long long')
  typedef long unsigned int size_t;
                            ^
  Weverything-and-remarks.cpp:19:62: warning: dynamic exception specifications are deprecated [-Wdeprecated]
    static void assign(char_type& __c1, const char_type& __c2) throw() {
                                                               ^~~~~~~
  Weverything-and-remarks.cpp:19:62: note: use 'noexcept' instead
    static void assign(char_type& __c1, const char_type& __c2) throw() {
                                                               ^~~~~~~
                                                               noexcept
  Weverything-and-remarks.cpp:25:46: warning: unused parameter '__n' [-Wunused-parameter]
                                        size_t __n) {
                                               ^
  3 warnings and 1 error generated.

llvm-svn: 209878
2014-05-30 07:03:16 +00:00
Diego Novillo d23ec94393 Add flags -Rpass-missed and -Rpass-analysis.
Summary:
These two flags are in the same family as -Rpass, but are used in
different situations.

-Rpass-missed is used by optimizers to inform the user when they tried
to apply an optimization but couldn't (or wouldn't).

-Rpass-analysis is used by optimizers to report analysis results back
to the user (e.g., why the transformation could not be applied).

Depends on D3682.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3683

llvm-svn: 209839
2014-05-29 19:55:06 +00:00
Diego Novillo 30531eff57 Add missing -S to avoid invoking assembler unnecessarily.
llvm-svn: 209828
2014-05-29 16:52:06 +00:00
Aaron Ballman a670c20894 No longer allow the -std options to entirely override the -x language option. This allows -x cuda -std=c++11, for instance.
llvm-svn: 209824
2014-05-29 16:39:42 +00:00
Diego Novillo 9c89ff1945 Fix spurious remarks when -Weverything is used.
With -Weverything, the backend remarks are enabled. This was
causing spurious diagnostics for remarks that we don't yet
handle (cf http://reviews.llvm.org/D3683).

This will stop being a problem once http://reviews.llvm.org/D3683
is committed.

llvm-svn: 209823
2014-05-29 16:19:27 +00:00
Diego Novillo 6dc9c4814f Fix segmentation fault when mixing -Rpass with #line.
Summary:
When using #line directives, FileManager::getFile() will return a nil
entry. This triggers an assert in translateFileLineCol().

This patch handles nil FileEntry instances by emitting a note that the
location could not be translated back to a SourceLocation. I don't
really like this solution, but we are translating presumed locations,
so some information has already been lost.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3625

llvm-svn: 208315
2014-05-08 13:49:54 +00:00
Lubos Lunak d9070c5ee7 -fsyntax-only for a test
llvm-svn: 207814
2014-05-01 23:58:20 +00:00
Reid Kleckner c9bb8b5af4 Use %clang_cc1 in rewrite-includes-messages.c test and drop REQUIRES: shell
This test passes on Windows with lit's shell interpreter.

llvm-svn: 207810
2014-05-01 22:45:16 +00:00