Re: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via cfe-commits
What's strange is that I copied this pattern from
clang-tidy-run-with-database.cpp, and I'm not sure why it would work there
and not here..

On Fri, Feb 17, 2017 at 8:16 PM, Ehsan Akhgari <ehsan.akhg...@gmail.com>
wrote:

> Hi Douglas,
>
> Sorry about this.  It seems to me that the reason for this test failure is
> the slashes that appear in the -path argument in the log:
>
> "-path" 
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\clang-tidy\Output/compilation-database-test"
> $ "FileCheck" "-check-prefix=CHECK" 
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
>
> However I'm not sure how to fix this.  I'm using slashes as the path 
> separator in the test RUN command.  Is there a safer platform independent 
> token I should use instead?
>
>
> On Fri, Feb 17, 2017 at 3:57 PM, Yung, Douglas <douglas.y...@sony.com>
> wrote:
>
>> Hi Ehsan,
>>
>> Your commit has caused the PS4 Windows bot to go red. Can you take a look?
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast/builds/5661
>>
>> $ "FileCheck" "-check-prefix=CHECK" "C:\Buildbot\Slave\llvm-clang-
>> lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\
>> tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
>> # command stderr:
>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pr
>> o-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp:17:11:
>> error: expected string not found in input
>>
>> // CHECK: [[@LINE-2]]:8: warning: annotate this
>>
>>   ^
>>
>> :1:1: note: scanning from here
>>
>> YAML:1:1: error: Unrecognized escape code!
>>
>> ^
>>
>> :1:1: note: with expression "@LINE-2" equal to "15"
>>
>> YAML:1:1: error: Unrecognized escape code!
>>
>> ^
>>
>> :1:7: note: possible intended match here
>>
>> YAML:1:1: error: Unrecognized escape code!
>>
>>   ^
>>
>>
>> error: command failed with exit status: 1
>>
>> Douglas Yung
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>> Behalf Of
>> > Ehsan Akhgari via cfe-commits
>> > Sent: Friday, February 17, 2017 11:32
>> > To: cfe-commits@lists.llvm.org
>> > Subject: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to
>> clang-
>> > tidy-diff.py
>> >
>> > Author: ehsan
>> > Date: Fri Feb 17 13:31:43 2017
>> > New Revision: 295482
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
>> > Log:
>> > [clang-tidy] Add -path option to clang-tidy-diff.py
>> >
>> > Summary:
>> > This flag allows specifying a custom path for the compilation database.
>> > Unfortunately we can't use the -p flag like other clang-tidy tools
>> because
>> > it's already taken.
>> >
>> > Reviewers: alexfh
>> >
>> > Subscribers: JDevlieghere, cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D29806
>> >
>> > Modified:
>> > clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
>> >
>> > Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
>> > tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
>> > 
>> ==
>> > --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> (original)
>> > +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb
>> > +++ 17 13:31:43 2017
>> > @@ -55,6 +55,8 @@ def main():
>> >help='checks filter, when not specified, use
>> clang-tidy
>> > '
>> >'default',
>> >default='')
>> > +  parser.add_argument('-path', dest='build_path',
>> > +  help='Path used to read a compile command
>> > + database.')
>> >parser.add_argument('-extra-arg', dest='extra_arg',
>> >action='append', default=[],
>> > 

Re: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via cfe-commits
Hi Douglas,

Sorry about this.  It seems to me that the reason for this test failure is
the slashes that appear in the -path argument in the log:

"-path" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\clang-tidy\Output/compilation-database-test"
$ "FileCheck" "-check-prefix=CHECK"
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"

However I'm not sure how to fix this.  I'm using slashes as the path
separator in the test RUN command.  Is there a safer platform
independent token I should use instead?


On Fri, Feb 17, 2017 at 3:57 PM, Yung, Douglas <douglas.y...@sony.com>
wrote:

> Hi Ehsan,
>
> Your commit has caused the PS4 Windows bot to go red. Can you take a look?
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/5661
>
> $ "FileCheck" "-check-prefix=CHECK" "C:\Buildbot\Slave\llvm-clang-
> lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\
> tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
> # command stderr:
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\tools\extra\test\
> clang-tidy\clang-tidy-diff.cpp:17:11: error: expected string not found in
> input
>
> // CHECK: [[@LINE-2]]:8: warning: annotate this
>
>   ^
>
> :1:1: note: scanning from here
>
> YAML:1:1: error: Unrecognized escape code!
>
> ^
>
> :1:1: note: with expression "@LINE-2" equal to "15"
>
> YAML:1:1: error: Unrecognized escape code!
>
> ^
>
> :1:7: note: possible intended match here
>
> YAML:1:1: error: Unrecognized escape code!
>
>   ^
>
>
> error: command failed with exit status: 1
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Ehsan Akhgari via cfe-commits
> > Sent: Friday, February 17, 2017 11:32
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to
> clang-
> > tidy-diff.py
> >
> > Author: ehsan
> > Date: Fri Feb 17 13:31:43 2017
> > New Revision: 295482
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
> > Log:
> > [clang-tidy] Add -path option to clang-tidy-diff.py
> >
> > Summary:
> > This flag allows specifying a custom path for the compilation database.
> > Unfortunately we can't use the -p flag like other clang-tidy tools
> because
> > it's already taken.
> >
> > Reviewers: alexfh
> >
> > Subscribers: JDevlieghere, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D29806
> >
> > Modified:
> > clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
> > tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> (original)
> > +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb
> > +++ 17 13:31:43 2017
> > @@ -55,6 +55,8 @@ def main():
> >help='checks filter, when not specified, use
> clang-tidy
> > '
> >'default',
> >default='')
> > +  parser.add_argument('-path', dest='build_path',
> > +  help='Path used to read a compile command
> > + database.')
> >parser.add_argument('-extra-arg', dest='extra_arg',
> >action='append', default=[],
> >help='Additional argument to append to the
> compiler '
> > @@ -124,6 +126,8 @@ def main():
> >  command.append('-checks=' + quote + args.checks + quote)
> >if args.quiet:
> >  command.append('-quiet')
> > +  if args.build_path is not None:
> > +command.append('-p=%s' % args.build_path)
> >command.extend(lines_by_file.keys())
> >for arg in args.extra_arg:
> >command.append('-extra-arg=%s' % arg)
> >
> > Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-
> > tidy/clang-tidy-

[clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Fri Feb 17 13:31:43 2017
New Revision: 295482

URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
Log:
[clang-tidy] Add -path option to clang-tidy-diff.py

Summary:
This flag allows specifying a custom path for the compilation
database.  Unfortunately we can't use the -p flag like other
clang-tidy tools because it's already taken.

Reviewers: alexfh

Subscribers: JDevlieghere, cfe-commits

Differential Revision: https://reviews.llvm.org/D29806

Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb 17 
13:31:43 2017
@@ -55,6 +55,8 @@ def main():
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-path', dest='build_path',
+  help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -124,6 +126,8 @@ def main():
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
+  if args.build_path is not None:
+command.append('-p=%s' % args.build_path)
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)

Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp?rev=295482=295481=295482=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp Fri Feb 17 
13:31:43 2017
@@ -2,6 +2,9 @@
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | 
FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck 
-check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 
%t.cpp", "file": "%t.cpp"}]' > 
%T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | 
FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r294607 - [clang-tidy] Add -quiet option to suppress extra output

2017-02-09 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Thu Feb  9 12:32:02 2017
New Revision: 294607

URL: http://llvm.org/viewvc/llvm-project?rev=294607=rev
Log:
[clang-tidy] Add -quiet option to suppress extra output

Summary:
This new flag instructs clang-tidy to not output anything
except for errors and warnings.  This makes it easier to
script clang-tidy to run as part of external build systems.

Reviewers: bkramer, alexfh, klimek

Subscribers: JDevlieghere, cfe-commits

Differential Revision: https://reviews.llvm.org/D29661

Modified:
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
clang-tools-extra/trunk/test/clang-tidy/file-filter.cpp
clang-tools-extra/trunk/test/clang-tidy/werrors-diagnostics.cpp
clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp
clang-tools-extra/trunk/test/clang-tidy/werrors.cpp

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=294607=294606=294607=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu Feb  9 
12:32:02 2017
@@ -188,6 +188,15 @@ code with clang-apply-replacements.
 cl::value_desc("filename"),
 cl::cat(ClangTidyCategory));
 
+static cl::opt Quiet("quiet", cl::desc(R"(
+Run clang-tidy in quiet mode.  This suppresses
+printing statistics about ignored warnings and
+warnings treated as errors if the respective
+options are specified.
+)"),
+   cl::init(false),
+   cl::cat(ClangTidyCategory));
+
 namespace clang {
 namespace tidy {
 
@@ -406,19 +415,23 @@ static int clangTidyMain(int argc, const
 exportReplacements(FilePath.str(), Errors, OS);
   }
 
-  printStats(Stats);
-  if (DisableFixes)
-llvm::errs()
-<< "Found compiler errors, but -fix-errors was not specified.\n"
-   "Fixes have NOT been applied.\n\n";
+  if (!Quiet) {
+printStats(Stats);
+if (DisableFixes)
+  llvm::errs()
+  << "Found compiler errors, but -fix-errors was not specified.\n"
+ "Fixes have NOT been applied.\n\n";
+  }
 
   if (EnableCheckProfile)
 printProfileData(Profile, llvm::errs());
 
   if (WErrorCount) {
-StringRef Plural = WErrorCount == 1 ? "" : "s";
-llvm::errs() << WErrorCount << " warning" << Plural << " treated as error"
- << Plural << "\n";
+if (!Quiet) {
+  StringRef Plural = WErrorCount == 1 ? "" : "s";
+  llvm::errs() << WErrorCount << " warning" << Plural << " treated as 
error"
+   << Plural << "\n";
+}
 return WErrorCount;
   }
 

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=294607=294606=294607=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Thu Feb  9 
12:32:02 2017
@@ -63,6 +63,8 @@ def main():
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-quiet', action='store_true', default=False,
+  help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
   argv = sys.argv[1:]
   if '--' in argv:
@@ -120,6 +122,8 @@ def main():
 command.append('-fix')
   if args.checks != '':
 command.append('-checks=' + quote + args.checks + quote)
+  if args.quiet:
+command.append('-quiet')
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=294607=294606=294607=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Thu Feb  9 
12:32:02 2017
@@ -59,7 +59,7 @@ def find_compilation_database(path):
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter, extra_arg, extra_arg_before):
+header_filter, extra_arg, extra_arg_before, quiet):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is 

[clang-tools-extra] r294491 - [clang-tidy] Add -extra-arg and -extra-arg-before to clang-tidy-diff.py

2017-02-08 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Wed Feb  8 11:50:24 2017
New Revision: 294491

URL: http://llvm.org/viewvc/llvm-project?rev=294491=rev
Log:
[clang-tidy] Add -extra-arg and -extra-arg-before to clang-tidy-diff.py

Summary:
These flags allow specifying extra arguments to the tool's command
line which don't appear in the compilation database.

Reviewers: alexfh, klimek, bkramer

Subscribers: JDevlieghere, cfe-commits

Differential Revision: https://reviews.llvm.org/D29699

Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=294491=294490=294491=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Wed Feb  8 
11:50:24 2017
@@ -55,6 +55,14 @@ def main():
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-extra-arg', dest='extra_arg',
+  action='append', default=[],
+  help='Additional argument to append to the compiler '
+  'command line.')
+  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
+  action='append', default=[],
+  help='Additional argument to prepend to the compiler '
+  'command line.')
   clang_tidy_args = []
   argv = sys.argv[1:]
   if '--' in argv:
@@ -113,6 +121,10 @@ def main():
   if args.checks != '':
 command.append('-checks=' + quote + args.checks + quote)
   command.extend(lines_by_file.keys())
+  for arg in args.extra_arg:
+  command.append('-extra-arg=%s' % arg)
+  for arg in args.extra_arg_before:
+  command.append('-extra-arg-before=%s' % arg)
   command.extend(clang_tidy_args)
 
   sys.exit(subprocess.call(' '.join(command), shell=True))


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r292415 - [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

2017-01-18 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Wed Jan 18 11:49:35 2017
New Revision: 292415

URL: http://llvm.org/viewvc/llvm-project?rev=292415=rev
Log:
[clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

Summary:
These flags allow specifying extra arguments to the tool's command
line which don't appear in the compilation database.

Reviewers: alexfh

Differential Revision: https://reviews.llvm.org/D28334

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=292415=292414=292415=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Wed Jan 18 
11:49:35 2017
@@ -59,7 +59,7 @@ def find_compilation_database(path):
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter):
+header_filter, extra_arg, extra_arg_before):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -76,6 +76,10 @@ def get_tidy_invocation(f, clang_tidy_bi
 (handle, name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
 os.close(handle)
 start.append(name)
+  for arg in extra_arg:
+  start.append('-extra-arg=%s' % arg)
+  for arg in extra_arg_before:
+  start.append('-extra-arg-before=%s' % arg)
   start.append('-p=' + build_path)
   start.append(f)
   return start
@@ -96,7 +100,8 @@ def run_tidy(args, tmpdir, build_path, q
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
- tmpdir, build_path, args.header_filter)
+ tmpdir, build_path, args.header_filter,
+ args.extra_arg, args.extra_arg_before)
 sys.stdout.write(' '.join(invocation) + '\n')
 subprocess.call(invocation)
 queue.task_done()
@@ -130,6 +135,14 @@ def main():
   'after applying fixes')
   parser.add_argument('-p', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-extra-arg', dest='extra_arg',
+  action='append', default=[],
+  help='Additional argument to append to the compiler '
+  'command line.')
+  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
+  action='append', default=[],
+  help='Additional argument to prepend to the compiler '
+  'command line.')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22221: Decide whether to enable plugin tests based on cmake variables

2016-10-14 Thread Ehsan Akhgari via cfe-commits
ehsan resigned from this revision.
ehsan removed a reviewer: ehsan.
ehsan added a comment.

I also don't know enough about the build system to review this, sorry!


Repository:
  rL LLVM

https://reviews.llvm.org/D1



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r253909 - Make clang_Cursor_getMangling not mangle if the declaration isn't mangled

2016-05-31 Thread Ehsan Akhgari via cfe-commits
Of course, apologies for this.  Reverted in r271291 and recommitted in
r271292.

On Tue, May 31, 2016 at 10:18 AM, David Blaikie <dblai...@gmail.com> wrote:

> Burt Wesarg points out on cfe-dev that this commit message doesn't match
> the patch (nor the description provided in the code review thread that lead
> to this commit) - this one might be worth reverting and recommitting with a
> more accurate commit message (I don't usually suggest this for most commits
> that are missing a commit message, but this one is actively misleading so
> might be trickier when people are doing archaeology)?
>
> On Mon, Nov 23, 2015 at 11:56 AM, Ehsan Akhgari via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ehsan
>> Date: Mon Nov 23 13:56:46 2015
>> New Revision: 253909
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253909=rev
>> Log:
>> Make clang_Cursor_getMangling not mangle if the declaration isn't mangled
>>
>> Right now clang_Cursor_getMangling will attempt to mangle any
>> declaration, even if the declaration isn't mangled (extern C).  This
>> results in a partially mangled name which isn't useful for much. This
>> patch makes clang_Cursor_getMangling return an empty string if the
>> declaration isn't mangled.
>>
>> Patch by Michael Wu <m...@mozilla.com>.
>>
>> Added:
>> cfe/trunk/test/Index/symbol-visibility.c
>> Modified:
>> cfe/trunk/include/clang-c/Index.h
>> cfe/trunk/tools/c-index-test/c-index-test.c
>> cfe/trunk/tools/libclang/CIndex.cpp
>> cfe/trunk/tools/libclang/libclang.exports
>>
>> Modified: cfe/trunk/include/clang-c/Index.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=253909=253908=253909=diff
>>
>> ==
>> --- cfe/trunk/include/clang-c/Index.h (original)
>> +++ cfe/trunk/include/clang-c/Index.h Mon Nov 23 13:56:46 2015
>> @@ -2461,6 +2461,32 @@ enum CXLinkageKind {
>>  CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor
>> cursor);
>>
>>  /**
>> + * \brief Describe the visibility of the entity referred to by a cursor.
>> + *
>> + * This returns the default visibility if not explicitly specified by
>> + * a visibility attribute. The default visibility may be changed by
>> + * commandline arguments.
>> + *
>> + * \param cursor The cursor to query.
>> + *
>> + * \returns The visibility of the cursor.
>> + */
>> +enum CXVisibilityKind {
>> +  /** \brief This value indicates that no visibility information is
>> available
>> +   * for a provided CXCursor. */
>> +  CXVisibility_Invalid,
>> +
>> +  /** \brief Symbol not seen by the linker. */
>> +  CXVisibility_Hidden,
>> +  /** \brief Symbol seen by the linker but resolves to a symbol inside
>> this object. */
>> +  CXVisibility_Protected,
>> +  /** \brief Symbol seen by the linker and acts like a normal symbol. */
>> +  CXVisibility_Default,
>> +};
>> +
>> +CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor
>> cursor);
>> +
>> +/**
>>   * \brief Determine the availability of the entity that this cursor
>> refers to,
>>   * taking the current target platform into account.
>>   *
>>
>> Added: cfe/trunk/test/Index/symbol-visibility.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/symbol-visibility.c?rev=253909=auto
>>
>> ==
>> --- cfe/trunk/test/Index/symbol-visibility.c (added)
>> +++ cfe/trunk/test/Index/symbol-visibility.c Mon Nov 23 13:56:46 2015
>> @@ -0,0 +1,7 @@
>> +// RUN: c-index-test -test-print-visibility %s | FileCheck %s
>> +
>> +__attribute__ ((visibility ("default"))) void foo1();
>> +__attribute__ ((visibility ("hidden"))) void foo2();
>> +
>> +// CHECK: FunctionDecl=foo1:3:47visibility=Default
>> +// CHECK: FunctionDecl=foo2:4:46visibility=Hidden
>>
>> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=253909=253908=253909=diff
>>
>> ==
>> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
>> +++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Nov 23 13:56:46 2015
>> @@ -1248,6 +1248,32 @@ static enum CXChildVisitResult PrintLink
>>  }
>>
>&g

r271292 - clang-c: Add the clang_getCursorVisibility() API

2016-05-31 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue May 31 10:55:51 2016
New Revision: 271292

URL: http://llvm.org/viewvc/llvm-project?rev=271292=rev
Log:
clang-c: Add the clang_getCursorVisibility() API

This patch adds an API for querying the visibility of the entity
referred to by a cursor.

Patch by Michael Wu .

Added:
cfe/trunk/test/Index/symbol-visibility.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=271292=271291=271292=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue May 31 10:55:51 2016
@@ -2516,6 +2516,32 @@ enum CXLinkageKind {
  */
 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
 
+enum CXVisibilityKind {
+  /** \brief This value indicates that no visibility information is available
+   * for a provided CXCursor. */
+  CXVisibility_Invalid,
+
+  /** \brief Symbol not seen by the linker. */
+  CXVisibility_Hidden,
+  /** \brief Symbol seen by the linker but resolves to a symbol inside this 
object. */
+  CXVisibility_Protected,
+  /** \brief Symbol seen by the linker and acts like a normal symbol. */
+  CXVisibility_Default
+};
+
+/**
+ * \brief Describe the visibility of the entity referred to by a cursor.
+ *
+ * This returns the default visibility if not explicitly specified by
+ * a visibility attribute. The default visibility may be changed by
+ * commandline arguments.
+ *
+ * \param cursor The cursor to query.
+ *
+ * \returns The visibility of the cursor.
+ */
+CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor 
cursor);
+
 /**
  * \brief Determine the availability of the entity that this cursor refers to,
  * taking the current target platform into account.

Added: cfe/trunk/test/Index/symbol-visibility.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/symbol-visibility.c?rev=271292=auto
==
--- cfe/trunk/test/Index/symbol-visibility.c (added)
+++ cfe/trunk/test/Index/symbol-visibility.c Tue May 31 10:55:51 2016
@@ -0,0 +1,7 @@
+// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+
+__attribute__ ((visibility ("default"))) void foo1();
+__attribute__ ((visibility ("hidden"))) void foo2();
+
+// CHECK: FunctionDecl=foo1:3:47visibility=Default
+// CHECK: FunctionDecl=foo2:4:46visibility=Hidden

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=271292=271291=271292=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue May 31 10:55:51 2016
@@ -1265,6 +1265,32 @@ static enum CXChildVisitResult PrintLink
 }
 
 
/**/
+/* Visibility testing.
*/
+/**/
+
+static enum CXChildVisitResult PrintVisibility(CXCursor cursor, CXCursor p,
+   CXClientData d) {
+  const char *visibility = 0;
+
+  if (clang_isInvalid(clang_getCursorKind(cursor)))
+return CXChildVisit_Recurse;
+
+  switch (clang_getCursorVisibility(cursor)) {
+case CXVisibility_Invalid: break;
+case CXVisibility_Hidden: visibility = "Hidden"; break;
+case CXVisibility_Protected: visibility = "Protected"; break;
+case CXVisibility_Default: visibility = "Default"; break;
+  }
+
+  if (visibility) {
+PrintCursor(cursor, NULL);
+printf("visibility=%s\n", visibility);
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Typekind testing.  
*/
 
/**/
 
@@ -4240,6 +4266,7 @@ static void print_usage(void) {
 "   c-index-test -test-inclusion-stack-tu \n");
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
+"   c-index-test -test-print-visibility {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
@@ -4334,6 +4361,9 @@ int cindextest_main(int argc, const char
   else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage,
 NULL);
+  else 

r271291 - Revert r253909 because it was committed with an incorrect message

2016-05-31 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue May 31 10:39:10 2016
New Revision: 271291

URL: http://llvm.org/viewvc/llvm-project?rev=271291=rev
Log:
Revert r253909 because it was committed with an incorrect message

Removed:
cfe/trunk/test/Index/symbol-visibility.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=271291=271290=271291=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue May 31 10:39:10 2016
@@ -2516,32 +2516,6 @@ enum CXLinkageKind {
  */
 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
 
-enum CXVisibilityKind {
-  /** \brief This value indicates that no visibility information is available
-   * for a provided CXCursor. */
-  CXVisibility_Invalid,
-
-  /** \brief Symbol not seen by the linker. */
-  CXVisibility_Hidden,
-  /** \brief Symbol seen by the linker but resolves to a symbol inside this 
object. */
-  CXVisibility_Protected,
-  /** \brief Symbol seen by the linker and acts like a normal symbol. */
-  CXVisibility_Default
-};
-
-/**
- * \brief Describe the visibility of the entity referred to by a cursor.
- *
- * This returns the default visibility if not explicitly specified by
- * a visibility attribute. The default visibility may be changed by
- * commandline arguments.
- *
- * \param cursor The cursor to query.
- *
- * \returns The visibility of the cursor.
- */
-CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor 
cursor);
-
 /**
  * \brief Determine the availability of the entity that this cursor refers to,
  * taking the current target platform into account.

Removed: cfe/trunk/test/Index/symbol-visibility.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/symbol-visibility.c?rev=271290=auto
==
--- cfe/trunk/test/Index/symbol-visibility.c (original)
+++ cfe/trunk/test/Index/symbol-visibility.c (removed)
@@ -1,7 +0,0 @@
-// RUN: c-index-test -test-print-visibility %s | FileCheck %s
-
-__attribute__ ((visibility ("default"))) void foo1();
-__attribute__ ((visibility ("hidden"))) void foo2();
-
-// CHECK: FunctionDecl=foo1:3:47visibility=Default
-// CHECK: FunctionDecl=foo2:4:46visibility=Hidden

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=271291=271290=271291=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue May 31 10:39:10 2016
@@ -1265,32 +1265,6 @@ static enum CXChildVisitResult PrintLink
 }
 
 
/**/
-/* Visibility testing.
*/
-/**/
-
-static enum CXChildVisitResult PrintVisibility(CXCursor cursor, CXCursor p,
-   CXClientData d) {
-  const char *visibility = 0;
-
-  if (clang_isInvalid(clang_getCursorKind(cursor)))
-return CXChildVisit_Recurse;
-
-  switch (clang_getCursorVisibility(cursor)) {
-case CXVisibility_Invalid: break;
-case CXVisibility_Hidden: visibility = "Hidden"; break;
-case CXVisibility_Protected: visibility = "Protected"; break;
-case CXVisibility_Default: visibility = "Default"; break;
-  }
-
-  if (visibility) {
-PrintCursor(cursor, NULL);
-printf("visibility=%s\n", visibility);
-  }
-
-  return CXChildVisit_Recurse;
-}
-
-/**/
 /* Typekind testing.  
*/
 
/**/
 
@@ -4266,7 +4240,6 @@ static void print_usage(void) {
 "   c-index-test -test-inclusion-stack-tu \n");
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
-"   c-index-test -test-print-visibility {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
@@ -4361,9 +4334,6 @@ int cindextest_main(int argc, const char
   else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage,
 NULL);
-  else if (argc > 2 && strcmp(argv[1], "-test-print-visibility") == 0)
-return perform_test_load_source(argc - 2, argv + 2, 

r260266 - clang-cl: Enable plugins on Windows

2016-02-09 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Feb  9 13:43:13 2016
New Revision: 260266

URL: http://llvm.org/viewvc/llvm-project?rev=260266=rev
Log:
clang-cl: Enable plugins on Windows

Modified:
cfe/trunk/test/Frontend/plugins.c
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/Frontend/plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/plugins.c?rev=260266=260265=260266=diff
==
--- cfe/trunk/test/Frontend/plugins.c (original)
+++ cfe/trunk/test/Frontend/plugins.c Tue Feb  9 13:43:13 2016
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin 
print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang 
%llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 
2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=260266=260265=260266=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Tue Feb  9 13:43:13 2016
@@ -196,7 +196,7 @@ if not lit_config.quiet:
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260265 - clang-cl: Support loading plugins on Windows

2016-02-09 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Feb  9 13:43:11 2016
New Revision: 260265

URL: http://llvm.org/viewvc/llvm-project?rev=260265=rev
Log:
clang-cl: Support loading plugins on Windows

This builds on the support being added to LLVM to import and export
registries from DLLs.  This will allow us to pick up the registry
entries added in the DLL's copy of FrontendPluginRegistry.

This will allow us to use plugins on Windows using:
$ clang-cl -Xclang -load -Xclang plugin.dll \
   -Xclang -add-plugin -Xclang foo

Modified:
cfe/trunk/docs/ClangPlugins.rst
cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/docs/ClangPlugins.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangPlugins.rst?rev=260265=260264=260265=diff
==
--- cfe/trunk/docs/ClangPlugins.rst (original)
+++ cfe/trunk/docs/ClangPlugins.rst Tue Feb  9 13:43:11 2016
@@ -37,11 +37,14 @@ Registering a plugin
 
 
 A plugin is loaded from a dynamic library at runtime by the compiler. To
-register a plugin in a library, use ``FrontendPluginRegistry::Add<>``:
+register a plugin in a library, use ``FrontendPluginRegistry::Add<>``.
+On Windows, you also need to export your plugin registry using
+``LLVM_EXPORT_REGISTRY``.  Here is an example:
 
 .. code-block:: c++
 
   static FrontendPluginRegistry::Add X("my-plugin-name", "my plugin 
description");
+  LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
 
 Putting it all together
 ===

Modified: cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp?rev=260265=260264=260265=diff
==
--- cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp (original)
+++ cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp Tue Feb  9 
13:43:11 2016
@@ -121,3 +121,4 @@ protected:
 
 static FrontendPluginRegistry::Add
 X("print-fns", "print function names");
+LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=260265=260264=260265=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Tue Feb  9 
13:43:11 2016
@@ -189,9 +189,16 @@ bool clang::ExecuteCompilerInvocation(Co
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), 
))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260276 - Fix the test added in r260266

2016-02-09 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Feb  9 14:49:24 2016
New Revision: 260276

URL: http://llvm.org/viewvc/llvm-project?rev=260276=rev
Log:
Fix the test added in r260266

Modified:
cfe/trunk/test/Frontend/plugins.c

Modified: cfe/trunk/test/Frontend/plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/plugins.c?rev=260276=260275=260276=diff
==
--- cfe/trunk/test/Frontend/plugins.c (original)
+++ cfe/trunk/test/Frontend/plugins.c Tue Feb  9 14:49:24 2016
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin 
print-fns %s 2>&1 | FileCheck %s
-// RUN: %clang_cl -Xclang -load -Xclang 
%llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 
2>&1 | FileCheck %s
+// RUN: %clang_cl -c -Xclang -load -Xclang 
%llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns 
-Tc %s 2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16761: clang-cl: Support loading plugins on Windows

2016-02-05 Thread Ehsan Akhgari via cfe-commits
ehsan updated this revision to Diff 47056.
ehsan added a comment.

Updating based on the LLVM side changes.


http://reviews.llvm.org/D16761

Files:
  docs/ClangPlugins.rst
  examples/PrintFunctionNames/PrintFunctionNames.cpp
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ExprConstant.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/CodeGenCXX/static-init-msvc.cpp
  test/Frontend/plugins.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: test/CodeGenCXX/static-init-msvc.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-init-msvc.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+
+void fun_and() {
+// CHECK-LABEL: @"\01?fun_and@@YAXXZ"()
+// GNU-LABEL: @_Z7fun_andv()
+  static int k;
+  static const int foo = 0 && k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_and@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_or() {
+// CHECK-LABEL: @"\01?fun_or@@YAXXZ"()
+// GNU-LABEL: @_Z6fun_orv()
+  static int k;
+  static const int foo = 1 || k;
+// CHECK: init:
+// CHECK-NEXT: store i32 1, i32* @"\01?foo@?1??fun_or@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_comma() {
+// CHECK-LABEL: @"\01?fun_comma@@YAXXZ"()
+// GNU-LABEL: @_Z9fun_commav()
+  static int k;
+  static const int foo = (k, 0);
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_comma@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_cond() {
+// CHECK-LABEL: @"\01?fun_cond@@YAXXZ"()
+// GNU-LABEL: @_Z8fun_condv()
+  static int k;
+  static const int foo = true ? 0 : k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_cond@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,16 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), ))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -477,6 +477,19 @@
 /// fold (not just why it's not strictly a constant expression)?
 bool HasFoldFailureDiagnostic;
 
+/// \brief True if we need to obey the Microsoft ABI.  This affects whether
+/// some expressions can be evaluated as a constant if they refer to
+/// variables in some cases.  See PR26210 for the discussion.
+bool IsMicrosoftABI;
+
+/// \brief True if we are looking for a DeclRefExpr.
+bool LookingForDeclRefExpr;
+
+/// \brief True if we have observed a DeclRefExpr since the last time that
+/// awaitDeclRefExpr() was called.  This is used in order to handle Microsoft
+/// ABI requirements.
+bool HaveSeenDeclRefExpr;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the expression
   /// is not a constant expression.
@@ -541,7 +554,9 @@

Re: [PATCH] D16761: clang-cl: Support loading plugins on Windows

2016-02-05 Thread Ehsan Akhgari via cfe-commits
ehsan updated this revision to Diff 47057.
ehsan added a comment.

Sorry for the noise, arconist fail...


http://reviews.llvm.org/D16761

Files:
  docs/ClangPlugins.rst
  examples/PrintFunctionNames/PrintFunctionNames.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/Frontend/plugins.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin 
print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang 
%llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 
2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,16 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), 
))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: examples/PrintFunctionNames/PrintFunctionNames.cpp
===
--- examples/PrintFunctionNames/PrintFunctionNames.cpp
+++ examples/PrintFunctionNames/PrintFunctionNames.cpp
@@ -121,3 +121,4 @@
 
 static FrontendPluginRegistry::Add
 X("print-fns", "print function names");
+LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
Index: docs/ClangPlugins.rst
===
--- docs/ClangPlugins.rst
+++ docs/ClangPlugins.rst
@@ -37,11 +37,14 @@
 
 
 A plugin is loaded from a dynamic library at runtime by the compiler. To
-register a plugin in a library, use ``FrontendPluginRegistry::Add<>``:
+register a plugin in a library, use ``FrontendPluginRegistry::Add<>``.
+On Windows, you also need to export your plugin registry using
+``LLVM_EXPORT_REGISTRY``.  Here is an example:
 
 .. code-block:: c++
 
   static FrontendPluginRegistry::Add X("my-plugin-name", "my plugin 
description");
+  LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
 
 Putting it all together
 ===


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,16 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), ))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: 

Re: [PATCH] D16503: [MSVC Compat] Warn when suppressing a trailing comma in macro args

2016-02-02 Thread Ehsan Akhgari via cfe-commits
ehsan added a comment.

In http://reviews.llvm.org/D16503#342116, @thakis wrote:

> Sorry for the slow response. I was reading http://reviews.llvm.org/D15670 to 
> understand this patch, and I couldn't find anything in that patch that 
> enables this extension only in Microsoft mode. Trying 
> suppressed-comma-msextension.cpp locally, it seems to pass without 
> -fms-compatibility too. Am I missing something, or does 
> http://reviews.llvm.org/D15670 lack a check for MicrosoftExt?


Hmm, is the `PP.getLangOpts().MSVCCompat` check earlier in 
`MaybeRemoveCommaBeforeVaArgs()` insufficient?

(Note that this whole thing mostly builds on top of r167613 which was done by 
Andy, so it's possible that I needed to do something extra and I forgot that...)


http://reviews.llvm.org/D16503



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16761: clang-cl: Support loading plugins on Windows

2016-01-31 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added a reviewer: rnk.
ehsan added a subscriber: cfe-commits.

This builds on the support being added to LLVM to import and export
registries from DLLs.  This will allow us to pick up the registry
entries added in the DLL's copy of FrontendPluginRegistry.

This will allow us to use plugins on Windows using:
$ clang-cl -Xclang -load -Xclang plugin.dll \
   -Xclang -add-plugin -Xclang foo

clang-cl: Enable plugins on Windows

http://reviews.llvm.org/D16761

Files:
  docs/ClangPlugins.rst
  examples/PrintFunctionNames/PrintFunctionNames.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/Frontend/plugins.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin 
print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang 
%llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 
2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,18 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), 
))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+#ifdef _MSC_VER
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+#endif
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: examples/PrintFunctionNames/PrintFunctionNames.cpp
===
--- examples/PrintFunctionNames/PrintFunctionNames.cpp
+++ examples/PrintFunctionNames/PrintFunctionNames.cpp
@@ -121,3 +121,6 @@
 
 static FrontendPluginRegistry::Add
 X("print-fns", "print function names");
+#ifdef _MSC_VER
+LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
+#endif
Index: docs/ClangPlugins.rst
===
--- docs/ClangPlugins.rst
+++ docs/ClangPlugins.rst
@@ -37,11 +37,16 @@
 
 
 A plugin is loaded from a dynamic library at runtime by the compiler. To
-register a plugin in a library, use ``FrontendPluginRegistry::Add<>``:
+register a plugin in a library, use ``FrontendPluginRegistry::Add<>``.
+Note that on Windows, you also need to export your plugin registry using
+``LLVM_EXPORT_REGISTRY``.  Here is an example:
 
 .. code-block:: c++
 
   static FrontendPluginRegistry::Add X("my-plugin-name", "my plugin 
description");
+  #ifdef _MSC_VER
+  LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
+  #endif
 
 Putting it all together
 ===


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,18 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if 

Re: r258720 - [MSVC Compat] Only warn for unknown clang-cl arguments

2016-01-26 Thread Ehsan Akhgari via cfe-commits
Hi Renato,

Thanks, Nico helped me diagnose and fix the test yesterday <
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160125/147979.html>.
I fixed the test accordingly in r258776 and that seems to have worked!

Cheers,
Ehsan

On Tue, Jan 26, 2016 at 7:41 AM, Renato Golin 
wrote:

> Hi,
>
> So, the results I'm getting on that RUN list is:
>
> 1. clang -cake-is-lie etc.
>
> Runs ok, prints expected error messages, returns 1.
>
> 2. clang-cl -cake-is-lie
>
> I've hit an assert on
> llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp:80:
> llvm::MCCodeGenInfo* createAArch64MCCodeGenInfo(const llvm::Triple&,
> llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOpt::Level):
> Assertion `(TT.isOSBinFormatELF() || TT.isOSBinFormatMachO()) && "Only
> expect Darwin and ELF targets"' failed.
>
> Returns with error code 254, which is the one the bot was complaining
> about. Script attached.
>
> 3. Same, with -Werror=unknown-argument
>
> Runs ok, prints expected error messages, returns 1.
>
> 4. Same, with -Wno-unknown-argument
>
> Fails on "// SILENT-NOT: error", since Clang's -v output contains:
> "-ferror-limit 19". I think you'll have to be more specific there. I'm
> not sure how this passed anywhere.
>
> 5. Clang -S
>
> Get the expected warning, returns 0.
>
> Hope that helps.
>
> cheers,
> --renato
>



-- 
Ehsan
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16511: [MSVC Compat] Only warn for unknown clang-cl arguments

2016-01-25 Thread Ehsan Akhgari via cfe-commits
Thanks for the reviews!  Will address both when landing.

On Mon, Jan 25, 2016 at 2:34 PM, Hans Wennborg  wrote:

> hans added a subscriber: hans.
> hans added a comment.
>
> Maybe this behavior should be called out in the Command-Line Options
> section under clang-cl in docs/UsersManual.rst?
>
>
> http://reviews.llvm.org/D16511
>
>
>
>


-- 
Ehsan
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16511: [MSVC Compat] Only warn for unknown clang-cl arguments

2016-01-25 Thread Ehsan Akhgari via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258720: [MSVC Compat] Only warn for unknown clang-cl 
arguments (authored by ehsan).

Changed prior to commit:
  http://reviews.llvm.org/D16511?vs=45796=45906#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16511

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cl-fallback.c
  cfe/trunk/test/Driver/unknown-arg.c
  cfe/trunk/test/Misc/serialized-diags-driver.c

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9708,6 +9708,10 @@
options::OPT__SLASH_MT, options::OPT__SLASH_MTd))
 A->render(Args, CmdArgs);
 
+  // Pass through all unknown arguments so that the fallback command can see
+  // them too.
+  Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
+
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo  = Inputs[0];
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -146,7 +146,9 @@
   }
 
   for (const Arg *A : Args.filtered(options::OPT_UNKNOWN))
-Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
+Diags.Report(IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl :
+  diag::err_drv_unknown_argument)
+  << A->getAsString(Args);
 
   return Args;
 }
@@ -1710,8 +1712,11 @@
   continue;
   }
 
-  Diag(clang::diag::warn_drv_unused_argument)
-  << A->getAsString(C.getArgs());
+  // In clang-cl, don't mention unknown arguments here since they have
+  // already been warned about.
+  if (!IsCLMode() || !A->getOption().matches(options::OPT_UNKNOWN))
+Diag(clang::diag::warn_drv_unused_argument)
+<< A->getAsString(C.getArgs());
 }
   }
 }
Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -2024,8 +2024,9 @@
 
 To suppress warnings about unused arguments, use the ``-Qunused-arguments`` option.
 
-Options that are not known to clang-cl will cause errors. If they are spelled with a
-leading ``/``, they will be mistaken for a filename:
+Options that are not known to clang-cl will be ignored by default. Use the
+``-Werror=unknown-argument`` option in order to treat them as errors. If these
+options are spelled with a leading ``/``, they will be mistaken for a filename:
 
   ::
 
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -848,3 +848,5 @@
 def InvalidOrNonExistentDirectory : DiagGroup<"invalid-or-nonexistent-directory">;
 
 def OptionIgnored : DiagGroup<"option-ignored">;
+
+def UnknownArgument : DiagGroup<"unknown-argument">;
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -93,6 +93,9 @@
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;
+def warn_drv_unknown_argument_clang_cl : Warning<
+  "unknown argument ignored in clang-cl: '%0'">,
+  InGroup;
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
 def err_drv_invalid_remap_file : Error<
Index: cfe/trunk/test/Driver/cl-fallback.c
===
--- cfe/trunk/test/Driver/cl-fallback.c
+++ cfe/trunk/test/Driver/cl-fallback.c
@@ -3,6 +3,7 @@
 
 // RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
 // RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \
+// RUN:   -garbage -moregarbage \
 // RUN:   -### -- %s 2>&1 \
 // RUN:   | FileCheck %s
 // CHECK: "-fdiagnostics-format" "msvc-fallback"
@@ -31,6 +32,8 @@
 // CHECK: "/EHs-"
 // CHECK: "/Zl"
 // CHECK: "/MT"
+// CHECK: "-garbage"
+// CHECK: "-moregarbage"
 // CHECK: "/Tc" "{{.*cl-fallback.c}}"
 // CHECK: "/Fo{{.*cl-fallback.*.obj}}"
 
Index: cfe/trunk/test/Driver/unknown-arg.c
===
--- cfe/trunk/test/Driver/unknown-arg.c
+++ cfe/trunk/test/Driver/unknown-arg.c
@@ -1,13 +1,28 @@
 // RUN: not %clang %s 

r258720 - [MSVC Compat] Only warn for unknown clang-cl arguments

2016-01-25 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Mon Jan 25 15:14:52 2016
New Revision: 258720

URL: http://llvm.org/viewvc/llvm-project?rev=258720=rev
Log:
[MSVC Compat] Only warn for unknown clang-cl arguments

Summary:
MSVC's driver accepts all unknown arguments but warns about them.  clang
by default rejects all unknown arguments.  This causes issues
specifically with build systems such as autoconf which liberally pass
things such as $LDFLAGS to the compiler and expect everything to work.
This patch teaches clang-cl to ignore unknown driver arguments.

Reviewers: rnk

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-fallback.c
cfe/trunk/test/Driver/unknown-arg.c
cfe/trunk/test/Misc/serialized-diags-driver.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=258720=258719=258720=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jan 25 15:14:52 2016
@@ -2024,8 +2024,9 @@ with a warning. For example:
 
 To suppress warnings about unused arguments, use the ``-Qunused-arguments`` 
option.
 
-Options that are not known to clang-cl will cause errors. If they are spelled 
with a
-leading ``/``, they will be mistaken for a filename:
+Options that are not known to clang-cl will be ignored by default. Use the
+``-Werror=unknown-argument`` option in order to treat them as errors. If these
+options are spelled with a leading ``/``, they will be mistaken for a filename:
 
   ::
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=258720=258719=258720=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jan 25 15:14:52 
2016
@@ -93,6 +93,9 @@ def err_target_unsupported_arch
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;
+def warn_drv_unknown_argument_clang_cl : Warning<
+  "unknown argument ignored in clang-cl: '%0'">,
+  InGroup;
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
 def err_drv_invalid_remap_file : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=258720=258719=258720=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Jan 25 15:14:52 2016
@@ -848,3 +848,5 @@ def FutureCompat : DiagGroup<"future-com
 def InvalidOrNonExistentDirectory : 
DiagGroup<"invalid-or-nonexistent-directory">;
 
 def OptionIgnored : DiagGroup<"option-ignored">;
+
+def UnknownArgument : DiagGroup<"unknown-argument">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=258720=258719=258720=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jan 25 15:14:52 2016
@@ -146,7 +146,9 @@ InputArgList Driver::ParseArgStrings(Arr
   }
 
   for (const Arg *A : Args.filtered(options::OPT_UNKNOWN))
-Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
+Diags.Report(IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl :
+  diag::err_drv_unknown_argument)
+  << A->getAsString(Args);
 
   return Args;
 }
@@ -1710,8 +1712,11 @@ void Driver::BuildJobs(Compilation ) c
   continue;
   }
 
-  Diag(clang::diag::warn_drv_unused_argument)
-  << A->getAsString(C.getArgs());
+  // In clang-cl, don't mention unknown arguments here since they have
+  // already been warned about.
+  if (!IsCLMode() || !A->getOption().matches(options::OPT_UNKNOWN))
+Diag(clang::diag::warn_drv_unused_argument)
+<< A->getAsString(C.getArgs());
 }
   }
 }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=258720=258719=258720=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jan 25 15:14:52 2016
@@ 

r258772 - Revert the test for r258720 temporarily

2016-01-25 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Mon Jan 25 19:51:47 2016
New Revision: 258772

URL: http://llvm.org/viewvc/llvm-project?rev=258772=rev
Log:
Revert the test for r258720 temporarily

This test is failing on a bot for reasons that are unclear to me.
Reverting for now...

Modified:
cfe/trunk/test/Driver/unknown-arg.c

Modified: cfe/trunk/test/Driver/unknown-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=258772=258771=258772=diff
==
--- cfe/trunk/test/Driver/unknown-arg.c (original)
+++ cfe/trunk/test/Driver/unknown-arg.c Mon Jan 25 19:51:47 2016
@@ -1,11 +1,5 @@
 // RUN: not %clang %s -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option 2>&1 | \
 // RUN: FileCheck %s
-// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -c -- %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=CL
-// RUN: not %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -c -Werror=unknown-argument -- %s 2>&1 | 
\
-// RUN: FileCheck %s --check-prefix=CL
-// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -c -Wno-unknown-argument -- %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=SILENT --allow-empty
 
 // CHECK: unknown argument: '-cake-is-lie'
 // CHECK: unknown argument: '-%0'
@@ -14,15 +8,6 @@
 // CHECK: unknown argument: '-munknown-to-clang-option'
 // CHECK: unknown argument: '-print-stats'
 // CHECK: unknown argument: '-funknown-to-clang-option'
-// CL: unknown argument ignored in clang-cl: '-cake-is-lie'
-// CL: unknown argument ignored in clang-cl: '-%0'
-// CL: unknown argument ignored in clang-cl: '-%d'
-// CL: unknown argument ignored in clang-cl: '-'
-// CL: unknown argument ignored in clang-cl: '-munknown-to-clang-option'
-// CL: unknown argument ignored in clang-cl: '-print-stats'
-// CL: unknown argument ignored in clang-cl: '-funknown-to-clang-option'
-// SILENT-NOT: error
-// SILENT-NOT: warning
 
 
 // RUN: %clang -S %s -o %t.s  -Wunknown-to-clang-option 2>&1 | FileCheck 
--check-prefix=IGNORED %s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258720 - [MSVC Compat] Only warn for unknown clang-cl arguments

2016-01-25 Thread Ehsan Akhgari via cfe-commits
Ouch, sorry about that! I'm afk right now, I would appreciate if you can
revert it for me. I will look at fixing this tomorrow.
On Jan 25, 2016 6:49 PM, "Renato Golin" <renato.go...@linaro.org> wrote:

> On 25 January 2016 at 21:14, Ehsan Akhgari via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
> > Author: ehsan
> > Date: Mon Jan 25 15:14:52 2016
> > New Revision: 258720
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=258720=rev
> > Log:
> > [MSVC Compat] Only warn for unknown clang-cl arguments
>
> Hi Eshan,
>
> Not sure you've seen, but:
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/4279
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/5435
>
> If you can't fix it now, please revert the test and let me help you
> look into it tomorrow.
>
> cheers,
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258776 - Recommit the test for r258720 using -###

2016-01-25 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Mon Jan 25 20:23:05 2016
New Revision: 258776

URL: http://llvm.org/viewvc/llvm-project?rev=258776=rev
Log:
Recommit the test for r258720 using -###

Modified:
cfe/trunk/test/Driver/unknown-arg.c

Modified: cfe/trunk/test/Driver/unknown-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=258776=258775=258776=diff
==
--- cfe/trunk/test/Driver/unknown-arg.c (original)
+++ cfe/trunk/test/Driver/unknown-arg.c Mon Jan 25 20:23:05 2016
@@ -1,13 +1,35 @@
-// RUN: not %clang %s -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option 2>&1 | \
+// RUN: %clang %s -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -### 2>&1 | \
 // RUN: FileCheck %s
+// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -### -c -- %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CL
+// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -c -Werror=unknown-argument -### -- %s 
2>&1 | \
+// RUN: FileCheck %s --check-prefix=CL-ERROR
+// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option 
-print-stats -funknown-to-clang-option -c -Wno-unknown-argument -### -- %s 2>&1 
| \
+// RUN: FileCheck %s --check-prefix=SILENT
 
-// CHECK: unknown argument: '-cake-is-lie'
-// CHECK: unknown argument: '-%0'
-// CHECK: unknown argument: '-%d'
-// CHECK: unknown argument: '-'
-// CHECK: unknown argument: '-munknown-to-clang-option'
-// CHECK: unknown argument: '-print-stats'
-// CHECK: unknown argument: '-funknown-to-clang-option'
+// CHECK: error: unknown argument: '-cake-is-lie'
+// CHECK: error: unknown argument: '-%0'
+// CHECK: error: unknown argument: '-%d'
+// CHECK: error: unknown argument: '-'
+// CHECK: error: unknown argument: '-munknown-to-clang-option'
+// CHECK: error: unknown argument: '-print-stats'
+// CHECK: error: unknown argument: '-funknown-to-clang-option'
+// CL: warning: unknown argument ignored in clang-cl: '-cake-is-lie'
+// CL: warning: unknown argument ignored in clang-cl: '-%0'
+// CL: warning: unknown argument ignored in clang-cl: '-%d'
+// CL: warning: unknown argument ignored in clang-cl: '-'
+// CL: warning: unknown argument ignored in clang-cl: 
'-munknown-to-clang-option'
+// CL: warning: unknown argument ignored in clang-cl: '-print-stats'
+// CL: warning: unknown argument ignored in clang-cl: 
'-funknown-to-clang-option'
+// CL-ERROR: error: unknown argument ignored in clang-cl: '-cake-is-lie'
+// CL-ERROR: error: unknown argument ignored in clang-cl: '-%0'
+// CL-ERROR: error: unknown argument ignored in clang-cl: '-%d'
+// CL-ERROR: error: unknown argument ignored in clang-cl: '-'
+// CL-ERROR: error: unknown argument ignored in clang-cl: 
'-munknown-to-clang-option'
+// CL-ERROR: error: unknown argument ignored in clang-cl: '-print-stats'
+// CL-ERROR: error: unknown argument ignored in clang-cl: 
'-funknown-to-clang-option'
+// SILENT-NOT: error:
+// SILENT-NOT: warning:
 
 
 // RUN: %clang -S %s -o %t.s  -Wunknown-to-clang-option 2>&1 | FileCheck 
--check-prefix=IGNORED %s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258772 - Revert the test for r258720 temporarily

2016-01-25 Thread Ehsan Akhgari via cfe-commits
Thanks for the suggestion!  I converted the test to a -### test and
recommitted.  Also rewrote the existing test (which I guess was failing for
another reason than what the author intended since it was merely checking
for an error return code...)

On Mon, Jan 25, 2016 at 9:16 PM, Nico Weber <tha...@chromium.org> wrote:

> Since it isn't a -### test, the test probably just needs a `// REQUIRES:
> x86-registered-target`? Is adding -### a possibility?
>
> On Mon, Jan 25, 2016 at 8:51 PM, Ehsan Akhgari via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ehsan
>> Date: Mon Jan 25 19:51:47 2016
>> New Revision: 258772
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258772=rev
>> Log:
>> Revert the test for r258720 temporarily
>>
>> This test is failing on a bot for reasons that are unclear to me.
>> Reverting for now...
>>
>> Modified:
>> cfe/trunk/test/Driver/unknown-arg.c
>>
>> Modified: cfe/trunk/test/Driver/unknown-arg.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=258772=258771=258772=diff
>>
>> ==
>> --- cfe/trunk/test/Driver/unknown-arg.c (original)
>> +++ cfe/trunk/test/Driver/unknown-arg.c Mon Jan 25 19:51:47 2016
>> @@ -1,11 +1,5 @@
>>  // RUN: not %clang %s -cake-is-lie -%0 -%d -
>> -munknown-to-clang-option -print-stats -funknown-to-clang-option 2>&1 | \
>>  // RUN: FileCheck %s
>> -// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option
>> -print-stats -funknown-to-clang-option -c -- %s 2>&1 | \
>> -// RUN: FileCheck %s --check-prefix=CL
>> -// RUN: not %clang_cl -cake-is-lie -%0 -%d -
>> -munknown-to-clang-option -print-stats -funknown-to-clang-option -c
>> -Werror=unknown-argument -- %s 2>&1 | \
>> -// RUN: FileCheck %s --check-prefix=CL
>> -// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option
>> -print-stats -funknown-to-clang-option -c -Wno-unknown-argument -- %s 2>&1
>> | \
>> -// RUN: FileCheck %s --check-prefix=SILENT --allow-empty
>>
>>  // CHECK: unknown argument: '-cake-is-lie'
>>  // CHECK: unknown argument: '-%0'
>> @@ -14,15 +8,6 @@
>>  // CHECK: unknown argument: '-munknown-to-clang-option'
>>  // CHECK: unknown argument: '-print-stats'
>>  // CHECK: unknown argument: '-funknown-to-clang-option'
>> -// CL: unknown argument ignored in clang-cl: '-cake-is-lie'
>> -// CL: unknown argument ignored in clang-cl: '-%0'
>> -// CL: unknown argument ignored in clang-cl: '-%d'
>> -// CL: unknown argument ignored in clang-cl: '-'
>> -// CL: unknown argument ignored in clang-cl: '-munknown-to-clang-option'
>> -// CL: unknown argument ignored in clang-cl: '-print-stats'
>> -// CL: unknown argument ignored in clang-cl: '-funknown-to-clang-option'
>> -// SILENT-NOT: error
>> -// SILENT-NOT: warning
>>
>>
>>  // RUN: %clang -S %s -o %t.s  -Wunknown-to-clang-option 2>&1 | FileCheck
>> --check-prefix=IGNORED %s
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>


-- 
Ehsan
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16511: [MSVC Compat] Only warn for unknown clang-cl arguments

2016-01-23 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added a reviewer: rnk.
ehsan added a subscriber: cfe-commits.

MSVC's driver accepts all unknown arguments but warns about them.  clang
by default rejects all unknown arguments.  This causes issues
specifically with build systems such as autoconf which liberally pass
things such as $LDFLAGS to the compiler and expect everything to work.
This patch teaches clang-cl to ignore unknown driver arguments.

http://reviews.llvm.org/D16511

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/cl-fallback.c
  test/Driver/unknown-arg.c
  test/Misc/warning-flags.c

Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (84):
+CHECK: Warnings without flags (85):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,6 +58,7 @@
 CHECK-NEXT:   warn_drv_clang_unsupported
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
+CHECK-NEXT:   warn_drv_unknown_argument_clang_cl
 CHECK-NEXT:   warn_dup_category_def
 CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
Index: test/Driver/unknown-arg.c
===
--- test/Driver/unknown-arg.c
+++ test/Driver/unknown-arg.c
@@ -1,13 +1,22 @@
 // RUN: not %clang %s -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option 2>&1 | \
 // RUN: FileCheck %s
+// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -- %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CL
 
 // CHECK: unknown argument: '-cake-is-lie'
 // CHECK: unknown argument: '-%0'
 // CHECK: unknown argument: '-%d'
 // CHECK: unknown argument: '-'
 // CHECK: unknown argument: '-munknown-to-clang-option'
 // CHECK: unknown argument: '-print-stats'
 // CHECK: unknown argument: '-funknown-to-clang-option'
+// CL: unknown argument ignored in clang-cl: '-cake-is-lie'
+// CL: unknown argument ignored in clang-cl: '-%0'
+// CL: unknown argument ignored in clang-cl: '-%d'
+// CL: unknown argument ignored in clang-cl: '-'
+// CL: unknown argument ignored in clang-cl: '-munknown-to-clang-option'
+// CL: unknown argument ignored in clang-cl: '-print-stats'
+// CL: unknown argument ignored in clang-cl: '-funknown-to-clang-option'
 
 
 // RUN: %clang -S %s -o %t.s  -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s
Index: test/Driver/cl-fallback.c
===
--- test/Driver/cl-fallback.c
+++ test/Driver/cl-fallback.c
@@ -3,6 +3,7 @@
 
 // RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
 // RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \
+// RUN:   -garbage -moregarbage \
 // RUN:   -### -- %s 2>&1 \
 // RUN:   | FileCheck %s
 // CHECK: "-fdiagnostics-format" "msvc-fallback"
@@ -31,6 +32,8 @@
 // CHECK: "/EHs-"
 // CHECK: "/Zl"
 // CHECK: "/MT"
+// CHECK: "-garbage"
+// CHECK: "-moregarbage"
 // CHECK: "/Tc" "{{.*cl-fallback.c}}"
 // CHECK: "/Fo{{.*cl-fallback.*.obj}}"
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9694,6 +9694,10 @@
options::OPT__SLASH_MT, options::OPT__SLASH_MTd))
 A->render(Args, CmdArgs);
 
+  // Pass through all unknown arguments so that the fallback command can see
+  // them too.
+  Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
+
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo  = Inputs[0];
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -146,7 +146,9 @@
   }
 
   for (const Arg *A : Args.filtered(options::OPT_UNKNOWN))
-Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
+Diags.Report(IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl :
+  diag::err_drv_unknown_argument)
+  << A->getAsString(Args);
 
   return Args;
 }
@@ -1710,8 +1712,11 @@
   continue;
   }
 
-  Diag(clang::diag::warn_drv_unused_argument)
-  << A->getAsString(C.getArgs());
+  // In clang-cl, don't mention unknown arguments here since they have
+  // already been warned about.
+  if (!IsCLMode() || !A->getOption().matches(options::OPT_UNKNOWN))
+Diag(clang::diag::warn_drv_unused_argument)
+<< A->getAsString(C.getArgs());
 }
   }
 }
Index: 

[PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added a reviewer: rnk.
ehsan added a subscriber: cfe-commits.

In the Microsoft ABI, some expressions containing references to variables
cannot be evaluated as a constant.  These are expressions containing a
conditional, logical and/or, or comma operator with an operand that is a
variable name.

This is observable at the ABI level by whether the compiler would emit a
static initializer for such expressions where normally it would emit a
readonly constant data.  See PR26210 for more details.

http://reviews.llvm.org/D16465

Files:
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ExprConstant.cpp
  test/CodeGenCXX/static-init-msvc.cpp

Index: test/CodeGenCXX/static-init-msvc.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-init-msvc.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+
+void fun_and() {
+// CHECK-LABEL: @"\01?fun_and@@YAXXZ"()
+// GNU-LABEL: @_Z7fun_andv()
+  static int k;
+  static const int foo = 0 && k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_and@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_or() {
+// CHECK-LABEL: @"\01?fun_or@@YAXXZ"()
+// GNU-LABEL: @_Z6fun_orv()
+  static int k;
+  static const int foo = 1 || k;
+// CHECK: init:
+// CHECK-NEXT: store i32 1, i32* @"\01?foo@?1??fun_or@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_comma() {
+// CHECK-LABEL: @"\01?fun_comma@@YAXXZ"()
+// GNU-LABEL: @_Z9fun_commav()
+  static int k;
+  static const int foo = (k, 0);
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_comma@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_cond() {
+// CHECK-LABEL: @"\01?fun_cond@@YAXXZ"()
+// GNU-LABEL: @_Z8fun_condv()
+  static int k;
+  static const int foo = true ? 0 : k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_cond@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -477,6 +477,19 @@
 /// fold (not just why it's not strictly a constant expression)?
 bool HasFoldFailureDiagnostic;
 
+/// \brief True if we need to obey the Microsoft ABI.  This affects whether
+/// some expressions can be evaluated as a constant if they refer to
+/// variables in some cases.  See PR26210 for the discussion.
+bool IsMicrosoftABI;
+
+/// \brief True if we are looking for a DeclRefExpr.
+bool LookingForDeclRefExpr;
+
+/// \brief True if we have observed a DeclRefExpr since the last time that
+/// awaitDeclRefExpr() was called.  This is used in order to handle Microsoft
+/// ABI requirements.
+bool HaveSeenDeclRefExpr;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the expression
   /// is not a constant expression.
@@ -541,7 +554,9 @@
 BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
 EvaluatingDecl((const ValueDecl *)nullptr),
 EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
-HasFoldFailureDiagnostic(false), EvalMode(Mode) {}
+HasFoldFailureDiagnostic(false), IsMicrosoftABI(false),
+LookingForDeclRefExpr(false), HaveSeenDeclRefExpr(false),
+EvalMode(Mode) {}
 
 void setEvaluatingDecl(APValue::LValueBase Base, APValue ) {
   EvaluatingDecl = Base;
@@ -766,6 +781,22 @@
 bool allowInvalidBaseExpr() const {
   return EvalMode == EM_DesignatorFold;
 }
+
+/// Use the Microsoft ABI during evaluation.
+void useMicrosoftABI() {
+  IsMicrosoftABI = true;
+}
+
+/// Start watching for a DeclRefExpr.
+void awaitDeclRefExpr() {
+  LookingForDeclRefExpr = true;
+  HaveSeenDeclRefExpr = false;
+}
+
+/// Remember that we have observed a DeclRefExpr.
+void noteDeclRefExpr() {
+  HaveSeenDeclRefExpr = true;
+}
   };
 
   /// Object used to treat all foldable expressions as constant expressions.
@@ -814,13 +845,14 @@
   /// RAII object used to suppress diagnostics and side-effects from a
   /// speculative evaluation.
   class SpeculativeEvaluationRAII {
-EvalInfo 
 Expr::EvalStatus Old;
+  protected:
+EvalInfo 
 
   public:
 SpeculativeEvaluationRAII(EvalInfo ,
 SmallVectorImpl *NewDiag = nullptr)
-  : Info(Info), Old(Info.EvalStatus) {
+  : 

Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan added inline comments.


Comment at: lib/AST/ExprConstant.cpp:4113
@@ +4112,3 @@
+  if (!CheckPotentialExpressionContainingDeclRefExpr(E->getTrueExpr(),
+  E->getFalseExpr()))
+return false;

Oops, sorry, just noticed this whitespace issue, will fix when landing!


http://reviews.llvm.org/D16465



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2016-01-22 Thread Ehsan Akhgari via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258530: [MSVC Compat] Accept elided commas in macro function 
arguments (authored by ehsan).

Changed prior to commit:
  http://reviews.llvm.org/D15670?vs=43310=45718#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15670

Files:
  cfe/trunk/include/clang/Lex/Token.h
  cfe/trunk/lib/Lex/PPMacroExpansion.cpp
  cfe/trunk/lib/Lex/TokenLexer.cpp
  cfe/trunk/test/Preprocessor/microsoft-ext.c

Index: cfe/trunk/include/clang/Lex/Token.h
===
--- cfe/trunk/include/clang/Lex/Token.h
+++ cfe/trunk/include/clang/Lex/Token.h
@@ -85,6 +85,7 @@
 IgnoredComma = 0x80,   // This comma is not a macro argument separator (MS).
 StringifiedInMacro = 0x100, // This string or character literal is formed by
 // macro stringizing or charizing operator.
+CommaAfterElided = 0x200, // The comma following this token was elided (MS).
   };
 
   tok::TokenKind getKind() const { return Kind; }
@@ -297,6 +298,11 @@
   bool stringifiedInMacro() const {
 return (Flags & StringifiedInMacro) ? true : false;
   }
+
+  /// Returns true if the comma after this token was elided.
+  bool commaAfterElided() const {
+return (Flags & CommaAfterElided) ? true : false;
+  }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
Index: cfe/trunk/test/Preprocessor/microsoft-ext.c
===
--- cfe/trunk/test/Preprocessor/microsoft-ext.c
+++ cfe/trunk/test/Preprocessor/microsoft-ext.c
@@ -34,3 +34,12 @@
 
 MAKE_FUNC(MAK, ER, int a, _COMMA, int b);
 // CHECK: void func(int a , int b) {}
+
+#define macro(a, b) (a - b)
+void function(int a);
+#define COMMA_ELIDER(...) \
+  macro(x, __VA_ARGS__); \
+  function(x, __VA_ARGS__);
+COMMA_ELIDER();
+// CHECK: (x - );
+// CHECK: function(x);
Index: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
===
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp
@@ -723,6 +723,7 @@
   // heap allocations in the common case.
   SmallVector ArgTokens;
   bool ContainsCodeCompletionTok = false;
+  bool FoundElidedComma = false;
 
   SourceLocation TooManyArgsLoc;
 
@@ -765,6 +766,10 @@
 // If we found the ) token, the macro arg list is done.
 if (NumParens-- == 0) {
   MacroEnd = Tok.getLocation();
+  if (!ArgTokens.empty() &&
+  ArgTokens.back().commaAfterElided()) {
+FoundElidedComma = true;
+  }
   break;
 }
   } else if (Tok.is(tok::l_paren)) {
@@ -909,7 +914,7 @@
   // then we have an empty "()" argument empty list.  This is fine, even if
   // the macro expects one argument (the argument is just empty).
   isVarargsElided = MI->isVariadic();
-} else if (MI->isVariadic() &&
+} else if ((FoundElidedComma || MI->isVariadic()) &&
(NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
 (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...) -> A()
   // Varargs where the named vararg parameter is missing: OK as extension.
Index: cfe/trunk/lib/Lex/TokenLexer.cpp
===
--- cfe/trunk/lib/Lex/TokenLexer.cpp
+++ cfe/trunk/lib/Lex/TokenLexer.cpp
@@ -154,12 +154,17 @@
   // Remove the comma.
   ResultToks.pop_back();
 
-  // If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
-  // then removal of the comma should produce a placemarker token (in C99
-  // terms) which we model by popping off the previous ##, giving us a plain
-  // "X" when __VA_ARGS__ is empty.
-  if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash))
-ResultToks.pop_back();
+  if (!ResultToks.empty()) {
+// If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
+// then removal of the comma should produce a placemarker token (in C99
+// terms) which we model by popping off the previous ##, giving us a plain
+// "X" when __VA_ARGS__ is empty.
+if (ResultToks.back().is(tok::hashhash))
+  ResultToks.pop_back();
+
+// Remember that this comma was elided.
+ResultToks.back().setFlag(Token::CommaAfterElided);
+  }
 
   // Never add a space, even if the comma, ##, or arg had a space.
   NextTokGetsSpace = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan added a comment.

Sure.  I'd be happy to address any comments post-landing.

Thanks!


http://reviews.llvm.org/D15670



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258530 - [MSVC Compat] Accept elided commas in macro function arguments

2016-01-22 Thread Ehsan Akhgari via cfe-commits
Do you mean only a warning for the case this patch is handling, or also for
cases such as the second test case in
https://llvm.org/bugs/show_bug.cgi?id=25875#c1 too?

(I think it would probably be a good idea to warn in both cases.)

On Fri, Jan 22, 2016 at 2:39 PM, Nico Weber <tha...@chromium.org> wrote:

> Is it possible to emit some -Wmicrosoft warning in cases where this is
> necessary?
>
> On Fri, Jan 22, 2016 at 2:26 PM, Ehsan Akhgari via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ehsan
>> Date: Fri Jan 22 13:26:44 2016
>> New Revision: 258530
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258530=rev
>> Log:
>> [MSVC Compat] Accept elided commas in macro function arguments
>>
>> Summary:
>> This fixes PR25875.  When the trailing comma in a macro argument list is
>> elided, we need to treat it similarly to the case where a variadic macro
>> misses one actual argument.
>>
>> Reviewers: rnk, rsmith
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D15670
>>
>> Modified:
>> cfe/trunk/include/clang/Lex/Token.h
>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> cfe/trunk/lib/Lex/TokenLexer.cpp
>> cfe/trunk/test/Preprocessor/microsoft-ext.c
>>
>> Modified: cfe/trunk/include/clang/Lex/Token.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=258530=258529=258530=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Lex/Token.h (original)
>> +++ cfe/trunk/include/clang/Lex/Token.h Fri Jan 22 13:26:44 2016
>> @@ -85,6 +85,7 @@ public:
>>  IgnoredComma = 0x80,   // This comma is not a macro argument
>> separator (MS).
>>  StringifiedInMacro = 0x100, // This string or character literal is
>> formed by
>>  // macro stringizing or charizing
>> operator.
>> +CommaAfterElided = 0x200, // The comma following this token was
>> elided (MS).
>>};
>>
>>tok::TokenKind getKind() const { return Kind; }
>> @@ -297,6 +298,11 @@ public:
>>bool stringifiedInMacro() const {
>>  return (Flags & StringifiedInMacro) ? true : false;
>>}
>> +
>> +  /// Returns true if the comma after this token was elided.
>> +  bool commaAfterElided() const {
>> +return (Flags & CommaAfterElided) ? true : false;
>> +  }
>>  };
>>
>>  /// \brief Information about the conditional stack (\#if directives)
>>
>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=258530=258529=258530=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Jan 22 13:26:44 2016
>> @@ -723,6 +723,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>// heap allocations in the common case.
>>SmallVector<Token, 64> ArgTokens;
>>bool ContainsCodeCompletionTok = false;
>> +  bool FoundElidedComma = false;
>>
>>SourceLocation TooManyArgsLoc;
>>
>> @@ -765,6 +766,10 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>  // If we found the ) token, the macro arg list is done.
>>  if (NumParens-- == 0) {
>>MacroEnd = Tok.getLocation();
>> +  if (!ArgTokens.empty() &&
>> +  ArgTokens.back().commaAfterElided()) {
>> +FoundElidedComma = true;
>> +  }
>>break;
>>  }
>>} else if (Tok.is(tok::l_paren)) {
>> @@ -909,7 +914,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>// then we have an empty "()" argument empty list.  This is fine,
>> even if
>>// the macro expects one argument (the argument is just empty).
>>isVarargsElided = MI->isVariadic();
>> -} else if (MI->isVariadic() &&
>> +} else if ((FoundElidedComma || MI->isVariadic()) &&
>> (NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
>>  (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...)
>> -> A()
>>// Varargs where the named vararg parameter is missing: OK as
>> extension.
>>
>> Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev

[PATCH] D16503: [MSVC Compat] Warn when suppressing a trailing comma in macro args

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added a reviewer: thakis.
ehsan added a subscriber: cfe-commits.

MSVC suppresses a trailing comma if no arguments are passed in place of
a variadic argument[1].  This patch adds a -Wmicrosoft warning when
accepting such code.

[1] https://msdn.microsoft.com/en-us/library/ms177415.aspx

http://reviews.llvm.org/D16503

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/TokenLexer.cpp
  test/Preprocessor/microsoft-ext.c
  test/Preprocessor/suppressed-comma-msextension.cpp

Index: test/Preprocessor/suppressed-comma-msextension.cpp
===
--- /dev/null
+++ test/Preprocessor/suppressed-comma-msextension.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fms-compatibility -Wmicrosoft %s
+// RUN: %clang_cc1 -P -E -fms-compatibility %s | FileCheck %s
+
+void function(int a);
+#define macro(a, b) function(b - a)
+#define COMMA_ELIDER(...) \
+  macro(x, __VA_ARGS__); \
+  function(x, __VA_ARGS__);
+// expected-warning@-2 {{suppressing trailing comma when not specifying any 
macro variadic arguments is a Microsoft extension}}
+// expected-warning@-2 {{suppressing trailing comma when not specifying any 
macro variadic arguments is a Microsoft extension}}
+void func() {
+int x;
+COMMA_ELIDER()
+// CHECK: function( - x); function(x);
+}
Index: test/Preprocessor/microsoft-ext.c
===
--- test/Preprocessor/microsoft-ext.c
+++ test/Preprocessor/microsoft-ext.c
@@ -34,12 +34,3 @@
 
 MAKE_FUNC(MAK, ER, int a, _COMMA, int b);
 // CHECK: void func(int a , int b) {}
-
-#define macro(a, b) (a - b)
-void function(int a);
-#define COMMA_ELIDER(...) \
-  macro(x, __VA_ARGS__); \
-  function(x, __VA_ARGS__);
-COMMA_ELIDER();
-// CHECK: (x - );
-// CHECK: function(x);
Index: lib/Lex/TokenLexer.cpp
===
--- lib/Lex/TokenLexer.cpp
+++ lib/Lex/TokenLexer.cpp
@@ -150,6 +150,9 @@
   // Issue an extension diagnostic for the paste operator.
   if (HasPasteOperator)
 PP.Diag(ResultToks.back().getLocation(), diag::ext_paste_comma);
+  else
+// Issue an extension diagnostic for the suppressed trailing comma.
+PP.Diag(ResultToks.back().getLocation(), 
diag::ext_elided_macro_argument_microsoft);
 
   // Remove the comma.
   ResultToks.pop_back();
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -65,6 +65,10 @@
 def ext_ctrl_z_eof_microsoft : Extension<
   "treating Ctrl-Z as end-of-file is a Microsoft extension">,
   InGroup;
+def ext_elided_macro_argument_microsoft: Extension<
+  "suppressing trailing comma when not specifying any macro variadic "
+  "arguments is a Microsoft extension">,
+  InGroup;
 
 def ext_token_used : Extension<"extension used">,
   InGroup>;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -769,6 +769,7 @@
 def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
 def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
 def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">;
+def MicrosoftElidedMacroArgument : 
DiagGroup<"microsoft-elided-macro-argument">;
 // Aliases.
 def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // -Wmsvc-include = -Wmicrosoft-include
@@ -783,7 +784,7 @@
  MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto,
  MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
  MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
- MicrosoftCommentPaste, MicrosoftEndOfFile]>;
+ MicrosoftCommentPaste, MicrosoftEndOfFile, MicrosoftElidedMacroArgument]>;
 
 def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
 


Index: test/Preprocessor/suppressed-comma-msextension.cpp
===
--- /dev/null
+++ test/Preprocessor/suppressed-comma-msextension.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fms-compatibility -Wmicrosoft %s
+// RUN: %clang_cc1 -P -E -fms-compatibility %s | FileCheck %s
+
+void function(int a);
+#define macro(a, b) function(b - a)
+#define COMMA_ELIDER(...) \
+  macro(x, __VA_ARGS__); \
+  function(x, __VA_ARGS__);
+// expected-warning@-2 {{suppressing trailing comma when not specifying any macro variadic arguments is a Microsoft extension}}
+// expected-warning@-2 {{suppressing trailing comma when not specifying any macro variadic arguments is a Microsoft extension}}
+void func() {
+int x;
+COMMA_ELIDER()
+// CHECK: function( - x); function(x);
+}
Index: test/Preprocessor/microsoft-ext.c

Re: r258530 - [MSVC Compat] Accept elided commas in macro function arguments

2016-01-22 Thread Ehsan Akhgari via cfe-commits
On Fri, Jan 22, 2016 at 3:22 PM, Nico Weber  wrote:

> Every time we accept something in MS mode that isn't standards compliant,
> we should accept it with a warning (for stuff that's harmless, an Extension
> warning, for stuff that can lead to bugs a Warning warning), unless it's
> really hard to implement.
>

Makes sense.  I added a warning in http://reviews.llvm.org/D16503.  Please
review.  :-)

Thanks,
Ehsan
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15839: Move _xgetbv to immintrin.h

2015-12-31 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added a reviewer: hansw.
ehsan added a subscriber: cfe-commits.

The documentation in https://msdn.microsoft.com/en-us/library/hh977022.aspx
says that this intrinsic is defined in immintrin.h, and that's the header
where MSVC declares this intrinsic, but clang-cl mistakenly provides it in
intrin.h.

http://reviews.llvm.org/D15839

Files:
  lib/Headers/Intrin.h
  lib/Headers/xsaveintrin.h

Index: lib/Headers/xsaveintrin.h
===
--- lib/Headers/xsaveintrin.h
+++ lib/Headers/xsaveintrin.h
@@ -53,6 +53,15 @@
 }
 #endif
 
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
+_xgetbv(unsigned int __xcr_no) {
+  unsigned int __eax, __edx;
+  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
+  return ((unsigned __int64)__edx << 32) | __eax;
+}
+#endif
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -905,12 +905,6 @@
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), 
"=d"(__info[3])
: "a"(__level), "c"(__ecx));
 }
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
-_xgetbv(unsigned int __xcr_no) {
-  unsigned int __eax, __edx;
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ void __DEFAULT_FN_ATTRS
 __halt(void) {
   __asm__ volatile ("hlt");


Index: lib/Headers/xsaveintrin.h
===
--- lib/Headers/xsaveintrin.h
+++ lib/Headers/xsaveintrin.h
@@ -53,6 +53,15 @@
 }
 #endif
 
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
+_xgetbv(unsigned int __xcr_no) {
+  unsigned int __eax, __edx;
+  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
+  return ((unsigned __int64)__edx << 32) | __eax;
+}
+#endif
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -905,12 +905,6 @@
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3])
: "a"(__level), "c"(__ecx));
 }
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
-_xgetbv(unsigned int __xcr_no) {
-  unsigned int __eax, __edx;
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ void __DEFAULT_FN_ATTRS
 __halt(void) {
   __asm__ volatile ("hlt");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15839: Move _xgetbv to immintrin.h

2015-12-31 Thread Ehsan Akhgari via cfe-commits
ehsan abandoned this revision.
ehsan added a comment.

Oops, sorry, I submitted this by mistake.


http://reviews.llvm.org/D15839



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15795: [ms inline asm] Add support for label names with '$' chars

2015-12-28 Thread Ehsan Akhgari via cfe-commits
ehsan accepted this revision.
ehsan added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D15795



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2015-12-19 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added reviewers: rnk, rsmith.
ehsan added a subscriber: cfe-commits.

This fixes PR25875.  When the trailing comma in a macro argument list is
elided, we need to treat it similarly to the case where a variadic macro
misses one actual argument.

http://reviews.llvm.org/D15670

Files:
  include/clang/Lex/Token.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Lex/TokenLexer.cpp
  test/Preprocessor/microsoft-ext.c

Index: test/Preprocessor/microsoft-ext.c
===
--- test/Preprocessor/microsoft-ext.c
+++ test/Preprocessor/microsoft-ext.c
@@ -34,3 +34,12 @@
 
 MAKE_FUNC(MAK, ER, int a, _COMMA, int b);
 // CHECK: void func(int a , int b) {}
+
+#define macro(a, b) (a - b)
+void function(int a);
+#define COMMA_ELIDER(...) \
+  macro(x, __VA_ARGS__); \
+  function(x, __VA_ARGS__);
+COMMA_ELIDER();
+// CHECK: (x - );
+// CHECK: function(x);
Index: lib/Lex/TokenLexer.cpp
===
--- lib/Lex/TokenLexer.cpp
+++ lib/Lex/TokenLexer.cpp
@@ -154,12 +154,17 @@
   // Remove the comma.
   ResultToks.pop_back();
 
-  // If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
-  // then removal of the comma should produce a placemarker token (in C99
-  // terms) which we model by popping off the previous ##, giving us a plain
-  // "X" when __VA_ARGS__ is empty.
-  if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash))
-ResultToks.pop_back();
+  if (!ResultToks.empty()) {
+// If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
+// then removal of the comma should produce a placemarker token (in C99
+// terms) which we model by popping off the previous ##, giving us a plain
+// "X" when __VA_ARGS__ is empty.
+if (ResultToks.back().is(tok::hashhash))
+  ResultToks.pop_back();
+
+// Remember that this comma was elided.
+ResultToks.back().setFlag(Token::CommaAfterElided);
+  }
 
   // Never add a space, even if the comma, ##, or arg had a space.
   NextTokGetsSpace = false;
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -725,6 +725,7 @@
   // heap allocations in the common case.
   SmallVector ArgTokens;
   bool ContainsCodeCompletionTok = false;
+  bool FoundElidedComma = false;
 
   SourceLocation TooManyArgsLoc;
 
@@ -767,6 +768,10 @@
 // If we found the ) token, the macro arg list is done.
 if (NumParens-- == 0) {
   MacroEnd = Tok.getLocation();
+  if (!ArgTokens.empty() &&
+  ArgTokens.back().commaAfterElided()) {
+FoundElidedComma = true;
+  }
   break;
 }
   } else if (Tok.is(tok::l_paren)) {
@@ -911,7 +916,7 @@
   // then we have an empty "()" argument empty list.  This is fine, even if
   // the macro expects one argument (the argument is just empty).
   isVarargsElided = MI->isVariadic();
-} else if (MI->isVariadic() &&
+} else if ((FoundElidedComma || MI->isVariadic()) &&
(NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
 (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...) -> A()
   // Varargs where the named vararg parameter is missing: OK as extension.
Index: include/clang/Lex/Token.h
===
--- include/clang/Lex/Token.h
+++ include/clang/Lex/Token.h
@@ -85,6 +85,7 @@
 IgnoredComma = 0x80,   // This comma is not a macro argument separator (MS).
 StringifiedInMacro = 0x100, // This string or character literal is formed by
 // macro stringizing or charizing operator.
+CommaAfterElided = 0x200, // The comma following this token was elided (MS).
   };
 
   tok::TokenKind getKind() const { return Kind; }
@@ -297,6 +298,11 @@
   bool stringifiedInMacro() const {
 return (Flags & StringifiedInMacro) ? true : false;
   }
+
+  /// Returns true if the comma after this token was elided.
+  bool commaAfterElided() const {
+return (Flags & CommaAfterElided) ? true : false;
+  }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r253909 - Make clang_Cursor_getMangling not mangle if the declaration isn't mangled

2015-11-23 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Mon Nov 23 13:56:46 2015
New Revision: 253909

URL: http://llvm.org/viewvc/llvm-project?rev=253909=rev
Log:
Make clang_Cursor_getMangling not mangle if the declaration isn't mangled

Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern C).  This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.

Patch by Michael Wu .

Added:
cfe/trunk/test/Index/symbol-visibility.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=253909=253908=253909=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Nov 23 13:56:46 2015
@@ -2461,6 +2461,32 @@ enum CXLinkageKind {
 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
 
 /**
+ * \brief Describe the visibility of the entity referred to by a cursor.
+ *
+ * This returns the default visibility if not explicitly specified by
+ * a visibility attribute. The default visibility may be changed by
+ * commandline arguments.
+ *
+ * \param cursor The cursor to query.
+ *
+ * \returns The visibility of the cursor.
+ */
+enum CXVisibilityKind {
+  /** \brief This value indicates that no visibility information is available
+   * for a provided CXCursor. */
+  CXVisibility_Invalid,
+
+  /** \brief Symbol not seen by the linker. */
+  CXVisibility_Hidden,
+  /** \brief Symbol seen by the linker but resolves to a symbol inside this 
object. */
+  CXVisibility_Protected,
+  /** \brief Symbol seen by the linker and acts like a normal symbol. */
+  CXVisibility_Default,
+};
+
+CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor 
cursor);
+
+/**
  * \brief Determine the availability of the entity that this cursor refers to,
  * taking the current target platform into account.
  *

Added: cfe/trunk/test/Index/symbol-visibility.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/symbol-visibility.c?rev=253909=auto
==
--- cfe/trunk/test/Index/symbol-visibility.c (added)
+++ cfe/trunk/test/Index/symbol-visibility.c Mon Nov 23 13:56:46 2015
@@ -0,0 +1,7 @@
+// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+
+__attribute__ ((visibility ("default"))) void foo1();
+__attribute__ ((visibility ("hidden"))) void foo2();
+
+// CHECK: FunctionDecl=foo1:3:47visibility=Default
+// CHECK: FunctionDecl=foo2:4:46visibility=Hidden

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=253909=253908=253909=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Nov 23 13:56:46 2015
@@ -1248,6 +1248,32 @@ static enum CXChildVisitResult PrintLink
 }
 
 
/**/
+/* Visibility testing.
*/
+/**/
+
+static enum CXChildVisitResult PrintVisibility(CXCursor cursor, CXCursor p,
+   CXClientData d) {
+  const char *visibility = 0;
+
+  if (clang_isInvalid(clang_getCursorKind(cursor)))
+return CXChildVisit_Recurse;
+
+  switch (clang_getCursorVisibility(cursor)) {
+case CXVisibility_Invalid: break;
+case CXVisibility_Hidden: visibility = "Hidden"; break;
+case CXVisibility_Protected: visibility = "Protected"; break;
+case CXVisibility_Default: visibility = "Default"; break;
+  }
+
+  if (visibility) {
+PrintCursor(cursor, NULL);
+printf("visibility=%s\n", visibility);
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Typekind testing.  
*/
 
/**/
 
@@ -4084,6 +4110,7 @@ static void print_usage(void) {
 "   c-index-test -test-inclusion-stack-tu \n");
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
+"   c-index-test -test-print-visibility {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
@@ -4171,6 +4198,9 @@ int 

Re: [PATCH] D13388: Add support for querying the visibility of a cursor

2015-11-23 Thread Ehsan Akhgari via cfe-commits
ehsan accepted this revision.
ehsan added a reviewer: ehsan.
ehsan added a comment.

Landed in r253909.


http://reviews.llvm.org/D13388



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r251638 - Add a link to the DXR project

2015-10-29 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Thu Oct 29 12:20:17 2015
New Revision: 251638

URL: http://llvm.org/viewvc/llvm-project?rev=251638=rev
Log:
Add a link to the DXR project

DXR is a project developed at Mozilla that implements a code indexing
and browsing utility on top of libclang that has features such as
call graph querying.

Modified:
cfe/trunk/www/related.html

Modified: cfe/trunk/www/related.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/related.html?rev=251638=251637=251638=diff
==
--- cfe/trunk/www/related.html (original)
+++ cfe/trunk/www/related.html Thu Oct 29 12:20:17 2015
@@ -82,6 +82,17 @@
 
   
 
+  DXR
+  
+
+  Site:
+https://github.com/mozilla/dxr#dxr;>https://github.com/mozilla/dxr
+
+
+DXR is a code search and navigation tool aimed at making sense of 
large projects like Firefox. It supports full-text and regex searches as well 
as structural queries like "Find all the callers of this function."
+
+  
+
 
   
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249437 - Make clang_Cursor_getMangling don't mangle if the declaration isn't mangled

2015-10-06 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Oct  6 13:24:33 2015
New Revision: 249437

URL: http://llvm.org/viewvc/llvm-project?rev=249437=rev
Log:
Make clang_Cursor_getMangling don't mangle if the declaration isn't mangled

Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern "C").  This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.

Patch by Michael Wu .

Modified:
cfe/trunk/test/Index/print-mangled-name.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/print-mangled-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-mangled-name.cpp?rev=249437=249436=249437=diff
==
--- cfe/trunk/test/Index/print-mangled-name.cpp (original)
+++ cfe/trunk/test/Index/print-mangled-name.cpp Tue Oct  6 13:24:33 2015
@@ -29,3 +29,8 @@ int foo(S, S&);
 // ITANIUM: mangled=_Z3foo1SRS_
 // MACHO: mangled=__Z3foo1SRS_
 // MICROSOFT: mangled=?foo@@YAHUS
+
+extern "C" int foo(int);
+// ITANIUM: mangled=foo
+// MACHO: mangled=_foo
+// MICROSOFT: mangled=_foo

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=249437=249436=249437=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Oct  6 13:24:33 2015
@@ -1429,6 +1429,8 @@ static enum CXChildVisitResult PrintType
 
 static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
 CXClientData d) {
+  if (clang_isInvalid(clang_getCursorKind(cursor)))
+return CXChildVisit_Recurse;
   CXString MangledName;
   PrintCursor(cursor, NULL);
   MangledName = clang_Cursor_getMangling(cursor);

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=249437=249436=249437=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Oct  6 13:24:33 2015
@@ -3890,7 +3890,11 @@ CXString clang_Cursor_getMangling(CXCurs
 
   std::string FrontendBuf;
   llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
-  MC->mangleName(ND, FrontendBufOS);
+  if (MC->shouldMangleDeclName(ND)) {
+MC->mangleName(ND, FrontendBufOS);
+  } else {
+ND->printName(FrontendBufOS);
+  }
 
   // Now apply backend mangling.
   std::unique_ptr DL(


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13317: clang_Cursor_getMangling shouldn't mangle if the declaration isn't mangled

2015-10-06 Thread Ehsan Akhgari via cfe-commits
ehsan closed this revision.
ehsan added a comment.

Landed in r249437.


http://reviews.llvm.org/D13317



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249440 - Revert r249437

2015-10-06 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Oct  6 13:53:12 2015
New Revision: 249440

URL: http://llvm.org/viewvc/llvm-project?rev=249440=rev
Log:
Revert r249437

Modified:
cfe/trunk/test/Index/print-mangled-name.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/print-mangled-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-mangled-name.cpp?rev=249440=249439=249440=diff
==
--- cfe/trunk/test/Index/print-mangled-name.cpp (original)
+++ cfe/trunk/test/Index/print-mangled-name.cpp Tue Oct  6 13:53:12 2015
@@ -29,8 +29,3 @@ int foo(S, S&);
 // ITANIUM: mangled=_Z3foo1SRS_
 // MACHO: mangled=__Z3foo1SRS_
 // MICROSOFT: mangled=?foo@@YAHUS
-
-extern "C" int foo(int);
-// ITANIUM: mangled=foo
-// MACHO: mangled=_foo
-// MICROSOFT: mangled=_foo

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=249440=249439=249440=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Oct  6 13:53:12 2015
@@ -1429,8 +1429,6 @@ static enum CXChildVisitResult PrintType
 
 static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
 CXClientData d) {
-  if (clang_isInvalid(clang_getCursorKind(cursor)))
-return CXChildVisit_Recurse;
   CXString MangledName;
   PrintCursor(cursor, NULL);
   MangledName = clang_Cursor_getMangling(cursor);

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=249440=249439=249440=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Oct  6 13:53:12 2015
@@ -3890,11 +3890,7 @@ CXString clang_Cursor_getMangling(CXCurs
 
   std::string FrontendBuf;
   llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
-  if (MC->shouldMangleDeclName(ND)) {
-MC->mangleName(ND, FrontendBufOS);
-  } else {
-ND->printName(FrontendBufOS);
-  }
+  MC->mangleName(ND, FrontendBufOS);
 
   // Now apply backend mangling.
   std::unique_ptr DL(


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9286: Insert override at the same line as the end of the function declaration

2015-08-18 Thread Ehsan Akhgari via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245401: Insert override at the same line as the end of the 
function declaration (authored by ehsan).

Changed prior to commit:
  http://reviews.llvm.org/D9286?vs=24449id=32492#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D9286

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
@@ -32,6 +32,12 @@
   virtual void m();
   virtual void m2();
   virtual void o() __attribute__((unused));
+
+  virtual void r() ;
+  virtual void rr() ;
+
+  virtual void cv() const volatile;
+  virtual void cv2() const volatile;
 };
 
 struct SimpleCases : public Base {
@@ -157,25 +163,47 @@
   // CHECK-MESSAGES-NOT: warning:
   // CHECK-FIXES: {{^}}  void b() override {}
 
-  virtual void c() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override {}
+  virtual void c()
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() override
 
   virtual void d() override {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
   // CHECK-FIXES: {{^}}  void d() override {}
 
-  virtual void j() const {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void j() const override {}
+  virtual void j() const
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void j() const override
 
   virtual MustUseResultObject k() {}  // Has an implicit attribute.
   // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
   // CHECK-FIXES: {{^}}  MustUseResultObject k() override {}
 
   virtual bool l() MUST_USE_RESULT UNUSED {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
   // CHECK-FIXES: {{^}}  bool l() override MUST_USE_RESULT UNUSED {}
+
+  virtual void r() 
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void r()  override
+
+  virtual void rr() 
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void rr()  override
+
+  virtual void cv() const volatile
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv() const volatile override
+
+  virtual void cv2() const volatile // some comment
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv2() const volatile override // some comment
 };
 
 struct Macros : public Base {
Index: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
@@ -140,8 +140,20 @@
 }
 
 if (InsertLoc.isInvalid()  Method-doesThisDeclarationHaveABody() 
-Method-getBody()  !Method-isDefaulted())
-  InsertLoc = Method-getBody()-getLocStart();
+Method-getBody()  !Method-isDefaulted()) {
+  // For methods with inline definition, add the override keyword at the
+  // end of the declaration of the function, but prefer to put it on the
+  // same line as the declaration if the beginning brace for the start of
+  // the body falls on the next line.
+  Token LastNonCommentToken;
+  for (Token T : Tokens) {
+if (!T.is(tok::comment)) {
+  LastNonCommentToken = T;
+}
+  }
+  InsertLoc = LastNonCommentToken.getEndLoc();
+  ReplacementText =  override;
+}
 
 if (!InsertLoc.isValid()) {
   // For declarations marked with = 0 or = [default|delete], the end


Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
@@ -32,6 +32,12 @@
   virtual void m();
   virtual void m2();
   virtual void o() __attribute__((unused));
+
+  virtual void r() ;
+  virtual void rr() ;
+
+  virtual void cv() const volatile;
+  virtual void cv2() const volatile;
 };
 
 struct SimpleCases : public Base {
@@ -157,25 +163,47 @@
   // CHECK-MESSAGES-NOT: warning:
   // CHECK-FIXES: {{^}}  void b() override {}
 
-  virtual void c() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override {}
+  virtual void c()
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() override
 
   virtual void d() override {}
   // CHECK-MESSAGES: 

[clang-tools-extra] r245401 - Insert override at the same line as the end of the function declaration

2015-08-18 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Aug 18 21:05:37 2015
New Revision: 245401

URL: http://llvm.org/viewvc/llvm-project?rev=245401view=rev
Log:
Insert override at the same line as the end of the function declaration

Summary:
The existing check converts the code pattern below:

  void f()
  {
  }

to:

  void f()
  override {
  }

which is fairly sub-optimal.  This patch fixes this by inserting the
override keyword on the same line as the function declaration if
possible, so that we instead get:

  void f() override
  {
  }

We do this by looking for the last token before the start of the body
and inserting the override keyword at the end of its location.  Note
that we handle const, volatile and ref-qualifiers correctly.

Test Plan: Includes an automated test.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp?rev=245401r1=245400r2=245401view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp Tue Aug 18 
21:05:37 2015
@@ -140,8 +140,20 @@ void UseOverrideCheck::check(const Match
 }
 
 if (InsertLoc.isInvalid()  Method-doesThisDeclarationHaveABody() 
-Method-getBody()  !Method-isDefaulted())
-  InsertLoc = Method-getBody()-getLocStart();
+Method-getBody()  !Method-isDefaulted()) {
+  // For methods with inline definition, add the override keyword at the
+  // end of the declaration of the function, but prefer to put it on the
+  // same line as the declaration if the beginning brace for the start of
+  // the body falls on the next line.
+  Token LastNonCommentToken;
+  for (Token T : Tokens) {
+if (!T.is(tok::comment)) {
+  LastNonCommentToken = T;
+}
+  }
+  InsertLoc = LastNonCommentToken.getEndLoc();
+  ReplacementText =  override;
+}
 
 if (!InsertLoc.isValid()) {
   // For declarations marked with = 0 or = [default|delete], the end

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp?rev=245401r1=245400r2=245401view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp Tue Aug 18 
21:05:37 2015
@@ -32,6 +32,12 @@ struct Base {
   virtual void m();
   virtual void m2();
   virtual void o() __attribute__((unused));
+
+  virtual void r() ;
+  virtual void rr() ;
+
+  virtual void cv() const volatile;
+  virtual void cv2() const volatile;
 };
 
 struct SimpleCases : public Base {
@@ -157,17 +163,19 @@ public:
   // CHECK-MESSAGES-NOT: warning:
   // CHECK-FIXES: {{^}}  void b() override {}
 
-  virtual void c() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override {}
+  virtual void c()
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() override
 
   virtual void d() override {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
   // CHECK-FIXES: {{^}}  void d() override {}
 
-  virtual void j() const {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void j() const override {}
+  virtual void j() const
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void j() const override
 
   virtual MustUseResultObject k() {}  // Has an implicit attribute.
   // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
@@ -176,6 +184,26 @@ public:
   virtual bool l() MUST_USE_RESULT UNUSED {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
   // CHECK-FIXES: {{^}}  bool l() override MUST_USE_RESULT UNUSED {}
+
+  virtual void r() 
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void r()  override
+
+  virtual void rr() 
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void rr()  override
+
+  virtual void cv() const volatile
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv() const volatile override
+
+  virtual void cv2() const volatile // some comment
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv2() const volatile override // some comment
 };
 
 struct Macros : public Base {



Re: [PATCH] D9285: Add a KeepVirtual option to misc-use-override

2015-08-14 Thread Ehsan Akhgari via cfe-commits
ehsan added a comment.

Sorry, I kind of dropped the ball here!

At Mozilla we ended up deciding on allowing only a maximum of one of virtual, 
final or override per function declaration, similar to the Google coding style, 
so we won't need the KeepVirtual option.  Should I still add it nevertheless?


http://reviews.llvm.org/D9285



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits