[clang] Enable frame pointer for non-leaf functions on Android (PR #97614)

2024-07-03 Thread Stephen Hines via cfe-commits

https://github.com/stephenhines approved this pull request.

Looks great! Thanks for making this more consistent.

https://github.com/llvm/llvm-project/pull/97614
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9d5a8b7 - Fix a missing update that C compiles default to gnu17.

2020-07-13 Thread Stephen Hines via cfe-commits

Author: Stephen Hines
Date: 2020-07-13T16:35:54-07:00
New Revision: 9d5a8b7edb28707879b8e2a37d14a4cf6dbcbefa

URL: 
https://github.com/llvm/llvm-project/commit/9d5a8b7edb28707879b8e2a37d14a4cf6dbcbefa
DIFF: 
https://github.com/llvm/llvm-project/commit/9d5a8b7edb28707879b8e2a37d14a4cf6dbcbefa.diff

LOG: Fix a missing update that C compiles default to gnu17.

https://reviews.llvm.org/D75383 switched the C default to gnu17, but
missed this instance.

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

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 5978650c3288..2cca04fb31f1 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -146,7 +146,7 @@ Language Selection and Mode Options
 
ISO C 2017 with GNU extensions
 
- The default C language standard is ``gnu11``, except on PS4, where it is
+ The default C language standard is ``gnu17``, except on PS4, where it is
  ``gnu99``.
 
  Supported values for the C++ language are:



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


Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Stephen Hines via cfe-commits
Ah I just saw this. Please feel free to CC me on the fix CL and I will
approve it. I didn't realize that the exact specification was missing
for that.

Thanks,
Steve

On Thu, Apr 4, 2019 at 6:31 PM Alex L  wrote:
>
> Thanks, for the explanation, it makes sense. It looks like an explicit 
> `darwin14` in one of the non-versioned darwin triples fixes the issue. I will 
> commit the fix right away.
>
> Cheers,
> Alex
>
>
> On Thu, 4 Apr 2019 at 18:24, Adrian Prantl  wrote:
>>
>> IIRC, the dwarf version on Darwin depends on the deployment target and is 2 
>> for earlier versions of macOS and and 4 for newer ones (I need to dig 
>> through the driver code to determine the exact version).
>>
>> I can take a look at this tomorrow morning.
>>
>> -- adrian
>>
>> On Apr 4, 2019, at 6:21 PM, Alex L  wrote:
>>
>> Hi Stephen,
>>
>> It looks like your change has caused the 'debug-options.c' test to start 
>> failing on Darwin. It looks like we emit "-dwarf-version=4" by default, and 
>> not 2. Could you please take a look.
>>
>> Here's a link to a latest build on the public LLVM CI that contains the 
>> failure:
>> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console
>>
>> Here's the failure itself:
>> Command Output (stderr): -- 
>> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
>>  error: G_DWARF2: expected string not found in input // G_DWARF2: 
>> "-dwarf-version=2" ^ :5:515: note: scanning from here 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
>>  "-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage" 
>> "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" 
>> "-disable-free" "-main-file-name" "debug-options.c" "-mrelocation-model" 
>> "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" 
>> "-masm-verbose" "-munwind-tables" "-faligned-alloc-unavailable" 
>> "-target-cpu" "penryn" "-dwarf-column-info" "-debug-info-kind=standalone" 
>> "-dwarf-version=4" "-debugger-tuning=lldb" "-ggnu-pubnames" 
>> "-target-linker-version" "351.8" "-coverage-notes-file" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
>>  "-resource-dir" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
>>  "-fdebug-compilation-dir" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
>>  "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1" 
>> "-fblocks" "-fencode-extended-block-signature" 
>> "-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0" 
>> "-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o" 
>> "-x" "c" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
>>  ^
>>
>>
>> Adrian, I've looped you in since you reviewed the commit it looks like. Do 
>> you know if that's expected behavior on Darwin?
>>
>> Cheers,
>> Alex
>>
>> On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits 
>>  wrote:
>>>
>>> Author: srhines
>>> Date: Thu Apr  4 11:17:46 2019
>>> New Revision: 357713
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
>>> Log:
>>> Verify that Android targets generate DWARF 4 by default.
>>>
>>> Summary:
>>> In the future, Android releases will support DWARF 5, but we need to
>>> ensure that older targets only have DWARF 4 generated for them. This
>>> patch inserts that verification for all Android releases now. The patch
>>> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
>>> missing G_DWARF2 check label).
>>>
>>> Reviewers: aprantl
>>>
>>> Reviewed By: aprantl
>>>
>>> Subscribers: chh, pirama, 

r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Apr  4 11:17:46 2019
New Revision: 357713

URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
Log:
Verify that Android targets generate DWARF 4 by default.

Summary:
In the future, Android releases will support DWARF 5, but we need to
ensure that older targets only have DWARF 4 generated for them. This
patch inserts that verification for all Android releases now. The patch
also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
missing G_DWARF2 check label).

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: chh, pirama, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"


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


r353318 - Switch to cantFail(), since it does the same assertion.

2019-02-06 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Wed Feb  6 09:59:39 2019
New Revision: 353318

URL: http://llvm.org/viewvc/llvm-project?rev=353318=rev
Log:
Switch to cantFail(), since it does the same assertion.

Reviewers: cfe-commits, lhames

Reviewed By: lhames

Subscribers: hintonda, klimek, pirama

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

Modified:
cfe/trunk/lib/Tooling/Core/Replacement.cpp

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=353318=353317=353318=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Feb  6 09:59:39 2019
@@ -519,12 +519,11 @@ calculateRangesAfterReplacements(const R
 return MergedRanges;
   tooling::Replacements FakeReplaces;
   for (const auto  : MergedRanges) {
-auto Err = FakeReplaces.add(Replacement(Replaces.begin()->getFilePath(),
-R.getOffset(), R.getLength(),
-std::string(R.getLength(), ' ')));
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));
+llvm::cantFail(
+FakeReplaces.add(Replacement(Replaces.begin()->getFilePath(),
+ R.getOffset(), R.getLength(),
+ std::string(R.getLength(), ' '))),
+"Replacements must not conflict since ranges have been merged.");
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }


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


Re: r342501 - Fix logic around determining use of frame pointer with -pg.

2018-09-18 Thread Stephen Hines via cfe-commits
r342510 by dblaikie fixed this.

Thanks,
Steve

On Tue, Sep 18, 2018 at 1:18 PM Stephen Hines  wrote:

> Sure, I'm looking now.
>
> Thanks,
> Steve
>
> On Tue, Sep 18, 2018 at 1:02 PM  wrote:
>
>> Hi Stephen,
>>
>> Your change is causing a test failure on the PS4 linux bot, can you
>> please take a look?
>>
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/36712/steps/test/logs/stdio
>>
>> FAIL: Clang :: Driver/clang_f_opts.c (8141 of 44013)
>>  TEST 'Clang :: Driver/clang_f_opts.c' FAILED
>> 
>> ...
>> Command Output (stderr):
>> --
>> /home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/clang_f_opts.c:537:29:
>> error: CHECK-NO-MIX-OMIT-FP-PG: expected string not found in input
>> // CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
>> ^
>> :1:1: note: scanning from here
>> clang version 8.0.0 (trunk 342502)
>> ^
>> :5:934: note: possible intended match here
>>  
>> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/bin/clang-8"
>> "-cc1" "-triple" "x86_64-scei-ps4" "-S" "-disable-free" "-main-file-name"
>> "clang_f_opts.c" "-mrelocation-model" "pic" "-pic-level" "2"
>> "-mthread-model" "posix" "-masm-verbose" "-mconstructor-aliases"
>> "-munwind-tables" "-target-cpu" "btver2" "-debugger-tuning=sce" "-mllvm"
>> "-generate-arange-section" "-debug-forward-template-params"
>> "-dwarf-explicit-import" "-coverage-notes-file"
>> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/tools/clang/test/Driver/clang_f_opts.gcno"
>> "-resource-dir"
>> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/lib/clang/8.0.0"
>> "-fdebug-compilation-dir"
>> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/tools/clang/test/Driver"
>> "-fstack-size-section" "-ferror-limit" "19" "-fmessage-length" "0" "-pg"
>> "-stack-protector" "2" "-fdeclspec" "-fobjc-runtime=gnustep"
>> "-fdiagnostics-show-option" "-o" "clang_f_opts.s" "-x" "c"
>> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/clang_f_opts.c"
>> "-faddrsig"
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>^
>>
>> Douglas Yung
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
>> > Of Stephen Hines via cfe-commits
>> > Sent: Tuesday, September 18, 2018 11:35
>> > To: cfe-commits@lists.llvm.org
>> > Subject: r342501 - Fix logic around determining use of frame pointer
>> > with -pg.
>> >
>> > Author: srhines
>> > Date: Tue Sep 18 11:34:33 2018
>> > New Revision: 342501
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=342501=rev
>> > Log:
>> > Fix logic around determining use of frame pointer with -pg.
>> >
>> > Summary:
>> > As part of r342165, I rewrote the logic to check whether
>> > -fno-omit-frame-pointer was passed after a -fomit-frame-pointer
>> > argument. This CL switches that logic to use the consolidated
>> > shouldUseFramePointer() function. This fixes a potential issue where -
>> > pg
>> > gets used with -fomit-frame-pointer on a platform that must always
>> > retain
>> > frame pointers.
>> >
>> > Reviewers: dblaikie
>> >
>> > Reviewed By: dblaikie
>> >
>> > Subscribers: cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D52191
>> >
>> > Modified:
>> > cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> >
>> > Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> > URL: http://llvm.org/viewvc/llvm-
>> > project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=342501=342500&
>> > r2=342501=diff
>> > ===
>> > ===
>> > --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> > +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep 18 11:34:33 2018
>> > @@ -4956,8 +4956,7 @@ void Clang::ConstructJob(Compilation ,
>> >}
>> >
>> >if (Arg *A = Args.getLastArg(options::OPT_pg))
>> > -if (Args.hasFlag(options::OPT_fomit_frame_pointer,
>> > - options::OPT_fno_omit_frame_pointer,
>> > /*default=*/false))
>> > +if (shouldUseFramePointer(Args, Triple))
>> >D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-
>> > frame-pointer"
>> ><< A-
>> > >getAsString(Args);
>> >
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r342501 - Fix logic around determining use of frame pointer with -pg.

2018-09-18 Thread Stephen Hines via cfe-commits
Sure, I'm looking now.

Thanks,
Steve

On Tue, Sep 18, 2018 at 1:02 PM  wrote:

> Hi Stephen,
>
> Your change is causing a test failure on the PS4 linux bot, can you please
> take a look?
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/36712/steps/test/logs/stdio
>
> FAIL: Clang :: Driver/clang_f_opts.c (8141 of 44013)
>  TEST 'Clang :: Driver/clang_f_opts.c' FAILED
> 
> ...
> Command Output (stderr):
> --
> /home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/clang_f_opts.c:537:29:
> error: CHECK-NO-MIX-OMIT-FP-PG: expected string not found in input
> // CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
> ^
> :1:1: note: scanning from here
> clang version 8.0.0 (trunk 342502)
> ^
> :5:934: note: possible intended match here
>  
> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/bin/clang-8"
> "-cc1" "-triple" "x86_64-scei-ps4" "-S" "-disable-free" "-main-file-name"
> "clang_f_opts.c" "-mrelocation-model" "pic" "-pic-level" "2"
> "-mthread-model" "posix" "-masm-verbose" "-mconstructor-aliases"
> "-munwind-tables" "-target-cpu" "btver2" "-debugger-tuning=sce" "-mllvm"
> "-generate-arange-section" "-debug-forward-template-params"
> "-dwarf-explicit-import" "-coverage-notes-file"
> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/tools/clang/test/Driver/clang_f_opts.gcno"
> "-resource-dir"
> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/lib/clang/8.0.0"
> "-fdebug-compilation-dir"
> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/tools/clang/test/Driver"
> "-fstack-size-section" "-ferror-limit" "19" "-fmessage-length" "0" "-pg"
> "-stack-protector" "2" "-fdeclspec" "-fobjc-runtime=gnustep"
> "-fdiagnostics-show-option" "-o" "clang_f_opts.s" "-x" "c"
> "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/clang_f_opts.c"
> "-faddrsig"
>
>
>
>
>
>
>
>
>
>
>
>
>^
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> > Of Stephen Hines via cfe-commits
> > Sent: Tuesday, September 18, 2018 11:35
> > To: cfe-commits@lists.llvm.org
> > Subject: r342501 - Fix logic around determining use of frame pointer
> > with -pg.
> >
> > Author: srhines
> > Date: Tue Sep 18 11:34:33 2018
> > New Revision: 342501
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=342501=rev
> > Log:
> > Fix logic around determining use of frame pointer with -pg.
> >
> > Summary:
> > As part of r342165, I rewrote the logic to check whether
> > -fno-omit-frame-pointer was passed after a -fomit-frame-pointer
> > argument. This CL switches that logic to use the consolidated
> > shouldUseFramePointer() function. This fixes a potential issue where -
> > pg
> > gets used with -fomit-frame-pointer on a platform that must always
> > retain
> > frame pointers.
> >
> > Reviewers: dblaikie
> >
> > Reviewed By: dblaikie
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D52191
> >
> > Modified:
> > cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> >
> > Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> > URL: http://llvm.org/viewvc/llvm-
> > project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=342501=342500&
> > r2=342501=diff
> > ===
> > ===
> > --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep 18 11:34:33 2018
> > @@ -4956,8 +4956,7 @@ void Clang::ConstructJob(Compilation ,
> >}
> >
> >if (Arg *A = Args.getLastArg(options::OPT_pg))
> > -if (Args.hasFlag(options::OPT_fomit_frame_pointer,
> > - options::OPT_fno_omit_frame_pointer,
> > /*default=*/false))
> > +if (shouldUseFramePointer(Args, Triple))
> >D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-
> > frame-pointer"
> ><< A-
> > >getAsString(Args);
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342501 - Fix logic around determining use of frame pointer with -pg.

2018-09-18 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Sep 18 11:34:33 2018
New Revision: 342501

URL: http://llvm.org/viewvc/llvm-project?rev=342501=rev
Log:
Fix logic around determining use of frame pointer with -pg.

Summary:
As part of r342165, I rewrote the logic to check whether
-fno-omit-frame-pointer was passed after a -fomit-frame-pointer
argument. This CL switches that logic to use the consolidated
shouldUseFramePointer() function. This fixes a potential issue where -pg
gets used with -fomit-frame-pointer on a platform that must always retain
frame pointers.

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=342501=342500=342501=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep 18 11:34:33 2018
@@ -4956,8 +4956,7 @@ void Clang::ConstructJob(Compilation ,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (Args.hasFlag(options::OPT_fomit_frame_pointer,
- options::OPT_fno_omit_frame_pointer, /*default=*/false))
+if (shouldUseFramePointer(Args, Triple))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


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


r342165 - Support -fno-omit-frame-pointer with -pg.

2018-09-13 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Sep 13 12:50:02 2018
New Revision: 342165

URL: http://llvm.org/viewvc/llvm-project?rev=342165=rev
Log:
Support -fno-omit-frame-pointer with -pg.

Summary:
Previously, any instance of -fomit-frame-pointer would make it such that
-pg was an invalid flag combination. If -fno-omit-frame-pointer is
passed later on the command line (such that it actually takes effect),
-pg should be allowed.

Reviewers: nickdesaulniers

Reviewed By: nickdesaulniers

Subscribers: manojgupta, nickdesaulniers, cfe-commits, kongyi, chh, pirama

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=342165=342164=342165=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep 13 12:50:02 2018
@@ -4910,7 +4910,8 @@ void Clang::ConstructJob(Compilation ,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (Args.hasArg(options::OPT_fomit_frame_pointer))
+if (Args.hasFlag(options::OPT_fomit_frame_pointer,
+ options::OPT_fno_omit_frame_pointer, /*default=*/false))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=342165=342164=342165=diff
==
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Thu Sep 13 12:50:02 2018
@@ -531,3 +531,8 @@
 // RUN: %clang -### -S -fno-delete-null-pointer-checks 
-fdelete-null-pointer-checks %s 2>&1 | FileCheck 
-check-prefix=CHECK-NULL-POINTER-CHECKS %s
 // CHECK-NO-NULL-POINTER-CHECKS: "-fno-delete-null-pointer-checks"
 // CHECK-NULL-POINTER-CHECKS-NOT: "-fno-delete-null-pointer-checks"
+
+// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
+// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 
2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
+// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
+// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'


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


Re: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Stephen Hines via cfe-commits
Ah, sorry I had to run off for a meeting. Yes, I was able to finally fix
this. For anyone else who hits it, you can "git reset --hard" back to the
CL before the initial change. Then you can "git pull" to move past the
issue. Thanks for fixing this.

Steve

On Thu, Aug 24, 2017 at 4:35 PM, Keane, Erich  wrote:

> Alright, final update.  Thanks to some fantastic help on #llvm, I believe
> this is fixed.
>
>
>
> Stephen: You may have to do some shenanigans to fix your local stuff, but
> the monorepo and another repo both seem to work.  Sorry for this everyone :/
>
>
>
> *From:* Stephen Hines [mailto:srhi...@google.com]
> *Sent:* Thursday, August 24, 2017 3:18 PM
> *To:* Keane, Erich 
> *Cc:* cfe-commits 
> *Subject:* Re: r311683 - [Preprocessor] Correct internal token parsing of
> newline characters in CRLF
>
>
>
> This change seems to have broken the git mirrors, as I can no longer check
> out clang without having a merge conflict as git alters the line endings.
> Setting core.autocrlf to false doesn't help either. Does anyone have any
> idea how to fix this svn <-> git issue?
>
>
>
> Thanks,
>
> Steve
>
>
>
> On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: erichkeane
> Date: Thu Aug 24 11:36:07 2017
> New Revision: 311683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
> Log:
> [Preprocessor] Correct internal token parsing of newline characters in CRLF
>
> Discovered due to a goofy git setup, the test system-headerline-directive.c
> (and a few others) failed because the token-consumption will consume only
> the
> '\r' in CRLF, making the preprocessor's printed value give the wrong line
> number
> when returning from an include. For example:
>
> (line 1):#include \r\n
>
> The "file exit" code causes the printer to try to print the 'returned to
> the
> main file' line. It looks up what the current line number is. However,
> since the
> current 'token' is the '\n' (since only the \r was consumed), it will give
> the
> line number as '1", not '2'. This results in a few failed tests, but more
> importantly, results in error messages being incorrect when compiling a
> previously preprocessed file.
>
> Differential Revision: https://reviews.llvm.org/D37079
>
> Added:
> cfe/trunk/test/Frontend/.gitattributes
> cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
>  (with props)
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> Lexer.cpp?rev=311683=311682=311683=diff
> 
> ==
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
> @@ -3073,6 +3073,8 @@ LexNextToken:
>
>case '\n':
>case '\r':
> +if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
> +  Char = getAndAdvanceChar(CurPtr, Result);
>  // If we are inside a preprocessor directive and we see the end of
> line,
>  // we know we are done with the directive, so return an EOD token.
>  if (ParsingPreprocessorDirective) {
>
> Added: cfe/trunk/test/Frontend/.gitattributes
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/.gitattributes?rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/.gitattributes (added)
> +++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,2 @@
> +# Below test validates crlf line endings, so it should stay crlf.
> +system-header-line-directive-ms-lineendings.c text eol=crlf
>
> Added: cfe/trunk/test/Frontend/system-header-line-directive-
> ms-lineendings.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/system-header-line-directive-ms-lineendings.c?
> rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> (added)
> +++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem
> %S/Inputs/SystemHeaderPrefix | FileCheck %s
> +#include 
> +#include 
> +
> +#include "line-directive.h"
> +
> +// This tests that the line numbers for the current file are correctly
> outputted
> +// for the include-file-completed test case.
> +
> +// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}noline.h" 1 3
> +// CHECK: foo();
> +// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
> +//  The "3" below indicates that "foo.h" is considered a system
> header.
> +// CHECK: # 1 "foo.h" 3
> +// CHECK: foo();
> +// CHECK: # 4 

Re: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Stephen Hines via cfe-commits
This change seems to have broken the git mirrors, as I can no longer check
out clang without having a merge conflict as git alters the line endings.
Setting core.autocrlf to false doesn't help either. Does anyone have any
idea how to fix this svn <-> git issue?

Thanks,
Steve

On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Thu Aug 24 11:36:07 2017
> New Revision: 311683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
> Log:
> [Preprocessor] Correct internal token parsing of newline characters in CRLF
>
> Discovered due to a goofy git setup, the test system-headerline-directive.c
> (and a few others) failed because the token-consumption will consume only
> the
> '\r' in CRLF, making the preprocessor's printed value give the wrong line
> number
> when returning from an include. For example:
>
> (line 1):#include \r\n
>
> The "file exit" code causes the printer to try to print the 'returned to
> the
> main file' line. It looks up what the current line number is. However,
> since the
> current 'token' is the '\n' (since only the \r was consumed), it will give
> the
> line number as '1", not '2'. This results in a few failed tests, but more
> importantly, results in error messages being incorrect when compiling a
> previously preprocessed file.
>
> Differential Revision: https://reviews.llvm.org/D37079
>
> Added:
> cfe/trunk/test/Frontend/.gitattributes
> cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
>  (with props)
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> Lexer.cpp?rev=311683=311682=311683=diff
> 
> ==
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
> @@ -3073,6 +3073,8 @@ LexNextToken:
>
>case '\n':
>case '\r':
> +if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
> +  Char = getAndAdvanceChar(CurPtr, Result);
>  // If we are inside a preprocessor directive and we see the end of
> line,
>  // we know we are done with the directive, so return an EOD token.
>  if (ParsingPreprocessorDirective) {
>
> Added: cfe/trunk/test/Frontend/.gitattributes
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/.gitattributes?rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/.gitattributes (added)
> +++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,2 @@
> +# Below test validates crlf line endings, so it should stay crlf.
> +system-header-line-directive-ms-lineendings.c text eol=crlf
>
> Added: cfe/trunk/test/Frontend/system-header-line-directive-
> ms-lineendings.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/system-header-line-directive-ms-lineendings.c?
> rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> (added)
> +++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem
> %S/Inputs/SystemHeaderPrefix | FileCheck %s
> +#include 
> +#include 
> +
> +#include "line-directive.h"
> +
> +// This tests that the line numbers for the current file are correctly
> outputted
> +// for the include-file-completed test case.
> +
> +// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}noline.h" 1 3
> +// CHECK: foo();
> +// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
> +//  The "3" below indicates that "foo.h" is considered a system
> header.
> +// CHECK: # 1 "foo.h" 3
> +// CHECK: foo();
> +// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}line-directive.h" 1
> +// CHECK: # 10 "foo.h"{{$}}
> +// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
>
> Propchange: cfe/trunk/test/Frontend/system-header-line-directive-
> ms-lineendings.c
> 
> --
> svn:eol-style = CRLF
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310958 - Switch to consumeError(), since this can crash otherwise.

2017-08-15 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Aug 15 14:20:41 2017
New Revision: 310958

URL: http://llvm.org/viewvc/llvm-project?rev=310958=rev
Log:
Switch to consumeError(), since this can crash otherwise.

Summary:
If assertions are disabled, but LLVM_ABI_BREAKING_CHANGES is enabled,
this will cause an issue with an unchecked Success. Switching to
consumeError() is the correct way to bypass the check.

Reviewers: llvm-commits, cfe-commits, arphaman

Reviewed By: arphaman

Subscribers: arphaman, klimek, pirama

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

Modified:
cfe/trunk/lib/Tooling/Core/Replacement.cpp

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=310958=310957=310958=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Tue Aug 15 14:20:41 2017
@@ -503,7 +503,7 @@ calculateRangesAfterReplacements(const R
 std::string(R.getLength(), ' ')));
 assert(!Err &&
"Replacements must not conflict since ranges have been merged.");
-(void)Err;
+llvm::consumeError(std::move(Err));
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }


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


[PATCH] D24933: Enable configuration files in clang

2016-11-18 Thread Stephen Hines via cfe-commits
srhines added a comment.

Thanks to Hans for notifying me about this. Cross-compilation flags are a big 
challenge in Android, but I have similar concerns about looking for magic 
files/dirs. Richard's suggestion about improving @file is really interesting, 
and would satisfy a large part of our needs in Android. Can you comment on 
whether you think that would work for your cases as well?




Comment at: docs/UsersManual.rst:655-656
+
+Command line option `--config` can be used to specify configuration file in
+a clang invocation. For instance:
+

rsmith wrote:
> Rather than inventing a new mechanism, could we extend our existing `@file` 
> facility to support comments and nested inclusion of further `@file`s?
This is a very interesting idea, and seems like something that would be very 
interesting for large systems that do a lot of cross-compilation. For instance, 
in Android, I would love to have a set of generic flags to add to all of our 
cross-compiles, and then a set of per-ABI flags for each of our major targets. 
If I could nest @file directives, that would get me most of this with 
minimal/no duplication of flags.



Comment at: docs/UsersManual.rst:667
+extension `cfg` if it is not specified yet, and the obtained file name is 
searched
+for in the directories: `~/.llvm` and the directory where clang executable 
resides.
+The first found file is used. It is an error if the required file cannot be 
found.

rsmith wrote:
> hans wrote:
> > The "add .cfg extension" magic seems a little awkward. It seems this is 
> > mixing the possibility of taking a filename and taking some other name.
> > 
> > For `clang --config myfile.cfg`, should it also search the current working 
> > directory?
> > 
> > I'm not keen on it searching in `~/.llvm`.
> I'm also not keen on searching `~/.llvm`. Whoever makes the `blah-clang` 
> symlink should get to control what the default configuration for `blah-clang` 
> is, I think. But then this seems to immediately lead to the conclusion that 
> we don't need this implicit-config-file feature at all, since you can replace 
> a `blah-clang` symlink with a shell script containing `exec clang @blah.cfg 
> "@$"` -- and it's better to handle it that way, since you get more control 
> over where the config file lives.
Android is essentially taking the shell script wrapper approach today (although 
we are using python, and we don't do a lot with it just yet).


https://reviews.llvm.org/D24933



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


[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.

2016-11-10 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286543: Define __ANDROID_API__ when specified as part of an 
Android target. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D26491?vs=77446=77578#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26491

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8497,14 +8497,19 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8497,14 +8497,19 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286543 - Define __ANDROID_API__ when specified as part of an Android target.

2016-11-10 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Nov 10 19:29:39 2016
New Revision: 286543

URL: http://llvm.org/viewvc/llvm-project?rev=286543=rev
Log:
Define __ANDROID_API__ when specified as part of an Android target.

Summary:
This macro should be defined only when the user directly specifies an
API level as part of an Android target. For any regular Android target,
we leave this macro undefined.

Bug: https://llvm.org/bugs/show_bug.cgi?id=30940

Reviewers: eugenis, pirama

Subscribers: tberghammer, cfe-commits, pirama, eugenis, danalbert

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286543=286542=286543=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Nov 10 19:29:39 2016
@@ -465,6 +465,8 @@ protected:
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=286543=286542=286543=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Nov 10 19:29:39 2016
@@ -8497,6 +8497,7 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
@@ -8505,6 +8506,10 @@
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //


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


[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.

2016-11-09 Thread Stephen Hines via cfe-commits
srhines updated this revision to Diff 77446.
srhines added a comment.

Added bug link to commit message.


https://reviews.llvm.org/D26491

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8496,14 +8496,19 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8496,14 +8496,19 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.

2016-11-09 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added subscribers: danalbert, eugenis, pirama, cfe-commits.
Herald added a subscriber: tberghammer.

This macro should be defined only when the user directly specifies an
API level as part of an Android target. For any regular Android target,
we leave this macro undefined.


https://reviews.llvm.org/D26491

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8496,14 +8496,19 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8496,14 +8496,19 @@
 // NORTTI:#define __STDC__ 1
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
+// ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
+// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
+// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID__ 1
+//
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

Reverted because this broke builds:

clang-hexagon-elf
llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
clang-ppc64be-linux-multistage
llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

It isn't clear from the logs why these builds failed, since I did a general 
build, but perhaps there is something that is stripping out Android-specific 
targets there.


Repository:
  rL LLVM

https://reviews.llvm.org/D26422



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


[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286298: Revert "Define __ANDROID_API__ for all Android 
builds." (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D26422?vs=77254=77256#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26422

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Driver/android-targets.cpp

Index: cfe/trunk/test/Driver/android-targets.cpp
===
--- cfe/trunk/test/Driver/android-targets.cpp
+++ cfe/trunk/test/Driver/android-targets.cpp
@@ -1,83 +0,0 @@
-// Test API-related defines for various Android targets.
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-
-// CHECK: __ANDROID__defined
-// LEVEL19: __ANDROID__defined
-// LEVEL20: __ANDROID__defined
-#ifdef __ANDROID__
-void __ANDROID__defined(void) {}
-#endif
-
-// CHECK-NOT: __ANDROID_API__defined
-// LEVEL19: __ANDROID_API__defined
-// LEVEL20: __ANDROID_API__defined
-#ifdef __ANDROID_API__
-void __ANDROID_API__defined(void) {}
-int android_api = __ANDROID_API__;
-#endif
-
-// CHECK-NOT: __ANDROID_API__20
-// LEVEL19-NOT: __ANDROID_API__20
-// LEVEL20: __ANDROID_API__20
-#if __ANDROID_API__ >= 20
-void __ANDROID_API__20(void) {}
-#endif
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -465,8 +465,6 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286298 - Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Nov  8 15:54:49 2016
New Revision: 286298

URL: http://llvm.org/viewvc/llvm-project?rev=286298=rev
Log:
Revert "Define __ANDROID_API__ for all Android builds."

Summary: This reverts commit a8804ddd9fe71304b28e5b834d134fe93e568ee0.

Subscribers: cfe-commits, pirama, eugenis, tberghammer, danalbert

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

Removed:
cfe/trunk/test/Driver/android-targets.cpp
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286298=286297=286298=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov  8 15:54:49 2016
@@ -465,8 +465,6 @@ protected:
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");

Removed: cfe/trunk/test/Driver/android-targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-targets.cpp?rev=286297=auto
==
--- cfe/trunk/test/Driver/android-targets.cpp (original)
+++ cfe/trunk/test/Driver/android-targets.cpp (removed)
@@ -1,83 +0,0 @@
-// Test API-related defines for various Android targets.
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-
-// CHECK: __ANDROID__defined
-// LEVEL19: __ANDROID__defined
-// LEVEL20: __ANDROID__defined
-#ifdef __ANDROID__
-void __ANDROID__defined(void) {}
-#endif
-
-// CHECK-NOT: __ANDROID_API__defined
-// LEVEL19: __ANDROID_API__defined
-// LEVEL20: __ANDROID_API__defined
-#ifdef __ANDROID_API__
-void __ANDROID_API__defined(void) {}
-int android_api = __ANDROID_API__;
-#endif
-
-// CHECK-NOT: __ANDROID_API__20
-// LEVEL19-NOT: __ANDROID_API__20
-// LEVEL20: __ANDROID_API__20
-#if __ANDROID_API__ >= 20
-void __ANDROID_API__20(void) {}
-#endif


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


[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added subscribers: danalbert, eugenis, pirama, cfe-commits.
Herald added a subscriber: tberghammer.

This reverts commit a8804ddd9fe71304b28e5b834d134fe93e568ee0.


https://reviews.llvm.org/D26422

Files:
  lib/Basic/Targets.cpp
  test/Driver/android-targets.cpp

Index: test/Driver/android-targets.cpp
===
--- test/Driver/android-targets.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// Test API-related defines for various Android targets.
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-
-// CHECK: __ANDROID__defined
-// LEVEL19: __ANDROID__defined
-// LEVEL20: __ANDROID__defined
-#ifdef __ANDROID__
-void __ANDROID__defined(void) {}
-#endif
-
-// CHECK-NOT: __ANDROID_API__defined
-// LEVEL19: __ANDROID_API__defined
-// LEVEL20: __ANDROID_API__defined
-#ifdef __ANDROID_API__
-void __ANDROID_API__defined(void) {}
-int android_api = __ANDROID_API__;
-#endif
-
-// CHECK-NOT: __ANDROID_API__20
-// LEVEL19-NOT: __ANDROID_API__20
-// LEVEL20: __ANDROID_API__20
-#if __ANDROID_API__ >= 20
-void __ANDROID_API__20(void) {}
-#endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,8 +465,6 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

Ugh, phabricator dropped my updated commit message, so that is completely wrong 
now. Oh well. I guess I will just use repo/gerrit for staging things in the 
future (and get consensus there) before asking for any upstream reviews.


Repository:
  rL LLVM

https://reviews.llvm.org/D26385



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286295: Define __ANDROID_API__ for all Android builds. 
(authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D26385?vs=77236=77250#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26385

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Driver/android-targets.cpp

Index: cfe/trunk/test/Driver/android-targets.cpp
===
--- cfe/trunk/test/Driver/android-targets.cpp
+++ cfe/trunk/test/Driver/android-targets.cpp
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK-NOT: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286295 - Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Nov  8 15:23:26 2016
New Revision: 286295

URL: http://llvm.org/viewvc/llvm-project?rev=286295=rev
Log:
Define __ANDROID_API__ for all Android builds.

Summary:
Bug: https://llvm.org/bugs/show_bug.cgi?id=30940

This macro (along with __ANDROID__) should always be defined for Android
targets. We set it to the major (only) version of the Android API being
compiled for. The Android version is able to be set as an integer suffix
for any valid Android target.

Reviewers: danalbert, eugenis

Subscribers: cfe-commits, pirama, eugenis, tberghammer, danalbert

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

Added:
cfe/trunk/test/Driver/android-targets.cpp
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286295=286294=286295=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov  8 15:23:26 2016
@@ -465,6 +465,8 @@ protected:
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");

Added: cfe/trunk/test/Driver/android-targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-targets.cpp?rev=286295=auto
==
--- cfe/trunk/test/Driver/android-targets.cpp (added)
+++ cfe/trunk/test/Driver/android-targets.cpp Tue Nov  8 15:23:26 2016
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK-NOT: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif


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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines updated this revision to Diff 77236.
srhines added a comment.

Switched to conditionally defining __ANDROID_API__ instead.


https://reviews.llvm.org/D26385

Files:
  lib/Basic/Targets.cpp
  test/Driver/android-targets.cpp

Index: test/Driver/android-targets.cpp
===
--- /dev/null
+++ test/Driver/android-targets.cpp
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK-NOT: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D26385#589589, @eugenis wrote:

> This is a good change, but I don't think it is the right fix for PR30940. 
> Instead of handling this in the NDK, we should change *::getIRStackGuard to 
> fallback to __stack_chk_guard when targeting an old version.


Right, this is only addressing part of the problem related to that issue. I can 
probably put together a follow up to address the rest of the bug, although I am 
not all that familiar with __stack_chk_guard, so testing might be a problem.


https://reviews.llvm.org/D26385



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D26385#589534, @danalbert wrote:

> > This macro (along with ANDROID) should always be defined for Android 
> > targets.
>
> What if only `arm-linux-androideabi` (without a version) is specified? We 
> should be falling back to the old behavior (don't defined `__ANDROID_API__`) 
> when that happens since that's what every build system out there is going to 
> be relying on.


It is defines with a value of 0. This allows you to actually do something 
better, IMO. You can now handle old or new NDKs by seeing if this is defined to 
a special level, or 0 for no level, or not defined at all (old toolchain, build 
rules, etc.). Does that make sense?


https://reviews.llvm.org/D26385



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


[PATCH] D26287: clang-format: Use git-ls-tree to get file mode in diff mode

2016-11-07 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286212: clang-format: Use git-ls-tree to get file mode in 
diff mode (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D26287?vs=76878=77142#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26287

Files:
  cfe/trunk/tools/clang-format/git-clang-format


Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -346,7 +346,16 @@
   Returns the object ID (SHA-1) of the created tree."""
   def index_info_generator():
 for filename, line_ranges in changed_lines.iteritems():
-  mode = oct(os.stat(filename).st_mode)
+  if revision:
+git_metadata_cmd = ['git', 'ls-tree',
+'%s:%s' % (revision, os.path.dirname(filename)),
+os.path.basename(filename)]
+git_metadata = subprocess.Popen(git_metadata_cmd, 
stdin=subprocess.PIPE,
+stdout=subprocess.PIPE)
+stdout = git_metadata.communicate()[0]
+mode = oct(int(stdout.split()[0], 8))
+  else:
+mode = oct(os.stat(filename).st_mode)
   blob_id = clang_format_to_blob(filename, line_ranges,
  revision=revision,
  binary=binary,


Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -346,7 +346,16 @@
   Returns the object ID (SHA-1) of the created tree."""
   def index_info_generator():
 for filename, line_ranges in changed_lines.iteritems():
-  mode = oct(os.stat(filename).st_mode)
+  if revision:
+git_metadata_cmd = ['git', 'ls-tree',
+'%s:%s' % (revision, os.path.dirname(filename)),
+os.path.basename(filename)]
+git_metadata = subprocess.Popen(git_metadata_cmd, stdin=subprocess.PIPE,
+stdout=subprocess.PIPE)
+stdout = git_metadata.communicate()[0]
+mode = oct(int(stdout.split()[0], 8))
+  else:
+mode = oct(os.stat(filename).st_mode)
   blob_id = clang_format_to_blob(filename, line_ranges,
  revision=revision,
  binary=binary,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286212 - clang-format: Use git-ls-tree to get file mode in diff mode

2016-11-07 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Mon Nov  7 23:50:14 2016
New Revision: 286212

URL: http://llvm.org/viewvc/llvm-project?rev=286212=rev
Log:
clang-format: Use git-ls-tree to get file mode in diff mode

Summary:
If a file has been renamed/deleted from the filesystem and --diff mode
with two commits is active, attempting to get the file's mode will fail.
This change uses git-ls-tree instead to get the correct permissions for
the given revision.

Patch by Luis Hector Chavez!

Reviewers: djasper, lodato

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=286212=286211=286212=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Mon Nov  7 23:50:14 2016
@@ -346,7 +346,16 @@ def run_clang_format_and_save_to_tree(ch
   Returns the object ID (SHA-1) of the created tree."""
   def index_info_generator():
 for filename, line_ranges in changed_lines.iteritems():
-  mode = oct(os.stat(filename).st_mode)
+  if revision:
+git_metadata_cmd = ['git', 'ls-tree',
+'%s:%s' % (revision, os.path.dirname(filename)),
+os.path.basename(filename)]
+git_metadata = subprocess.Popen(git_metadata_cmd, 
stdin=subprocess.PIPE,
+stdout=subprocess.PIPE)
+stdout = git_metadata.communicate()[0]
+mode = oct(int(stdout.split()[0], 8))
+  else:
+mode = oct(os.stat(filename).st_mode)
   blob_id = clang_format_to_blob(filename, line_ranges,
  revision=revision,
  binary=binary,


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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-07 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added subscribers: danalbert, eugenis, pirama, cfe-commits.
Herald added a subscriber: tberghammer.

Bug: https://llvm.org/bugs/show_bug.cgi?id=30940

This macro (along with __ANDROID__) should always be defined for Android
targets. We set it to the major (only) version of the Android API being
compiled for. The Android version is able to be set as an integer suffix
for any valid Android target.


https://reviews.llvm.org/D26385

Files:
  lib/Basic/Targets.cpp
  test/Driver/android-targets.cpp


Index: test/Driver/android-targets.cpp
===
--- /dev/null
+++ test/Driver/android-targets.cpp
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,7 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");


Index: test/Driver/android-targets.cpp
===
--- /dev/null
+++ test/Driver/android-targets.cpp
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s 

[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-31 Thread Stephen Hines via cfe-commits
srhines added a comment.

Ping. Other developers (Firefox) are now starting to hit this issue.


https://reviews.llvm.org/D24010



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


[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-25 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285127: Use linker flag --fix-cortex-a53-843419 on Android 
ARM64 compilation. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D25761?vs=75174=75801#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25761

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/android-aarch64-link.cpp


Index: cfe/trunk/test/Driver/android-aarch64-link.cpp
===
--- cfe/trunk/test/Driver/android-aarch64-link.cpp
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9712,6 +9712,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: cfe/trunk/test/Driver/android-aarch64-link.cpp
===
--- cfe/trunk/test/Driver/android-aarch64-link.cpp
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9712,6 +9712,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285127 - Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-25 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Oct 25 16:44:35 2016
New Revision: 285127

URL: http://llvm.org/viewvc/llvm-project?rev=285127=rev
Log:
Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

Summary:
This is only forced on if there is no non-Cortex-A53 CPU specified as
well. Android's platform and NDK builds need to assume that the code can
be run on Cortex-A53 devices, so we always enable the fix unless we know
specifically that the code is only running on a different kind of CPU.

Reviewers: cfe-commits

Subscribers: aemerson, rengolin, tberghammer, pirama, danalbert

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

Added:
cfe/trunk/test/Driver/android-aarch64-link.cpp
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285127=285126=285127=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 25 16:44:35 2016
@@ -9712,6 +9712,14 @@ void gnutools::Linker::ConstructJob(Comp
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 

Added: cfe/trunk/test/Driver/android-aarch64-link.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-aarch64-link.cpp?rev=285127=auto
==
--- cfe/trunk/test/Driver/android-aarch64-link.cpp (added)
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp Tue Oct 25 16:44:35 2016
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419


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


[PATCH] D25928: [cfi] Enable cfi-icall on ARM and AArch64.

2016-10-25 Thread Stephen Hines via cfe-commits
srhines accepted this revision.
srhines added a reviewer: srhines.
srhines added a comment.
This revision is now accepted and ready to land.

Looks good for the Android side.


Repository:
  rL LLVM

https://reviews.llvm.org/D25928



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


[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-19 Thread Stephen Hines via cfe-commits
srhines updated this revision to Diff 75174.
srhines added a comment.

Added a test for this behavior.

I missed that "-### -v" was actually working correctly last night. Tests added
so I am more satisfied that this won't break accidentally in the future.


https://reviews.llvm.org/D25761

Files:
  lib/Driver/Tools.cpp
  test/Driver/android-aarch64-link.cpp


Index: test/Driver/android-aarch64-link.cpp
===
--- /dev/null
+++ test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9677,6 +9677,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: test/Driver/android-aarch64-link.cpp
===
--- /dev/null
+++ test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9677,6 +9677,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-19 Thread Stephen Hines via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D25761#573902, @rengolin wrote:

> In https://reviews.llvm.org/D25761#573892, @srhines wrote:
>
> > From what I can tell, there is no nice way to generate tests for Clang's 
> > driver when producing linker flags. -### only works for the -cc1 command 
> > line (which won't see this flag, since it is only for linking, and not 
> > compilation). If there is a suggestion for how to automatically test this, 
> > I am listening, but all my local tests looked fine (for 
> > generating/suppressing the flag). :)
>
>
> I think "clang -v" will show the linker invocation, with all its flags.


But is there a way to get a dry-run of the linker? I don't want to run 
/usr/bin/ld for ARM targets. It seems like all of the other linker flag-related 
tests in tests/Driver/ only work for x86.


https://reviews.llvm.org/D25761



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


[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-19 Thread Stephen Hines via cfe-commits
srhines added a comment.

From what I can tell, there is no nice way to generate tests for Clang's driver 
when producing linker flags. -### only works for the -cc1 command line (which 
won't see this flag, since it is only for linking, and not compilation). If 
there is a suggestion for how to automatically test this, I am listening, but 
all my local tests looked fine (for generating/suppressing the flag). :)


https://reviews.llvm.org/D25761



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


[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-19 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added a reviewer: cfe-commits.
srhines added subscribers: danalbert, pirama.
Herald added subscribers: tberghammer, rengolin, aemerson.

This is only forced on if there is no non-Cortex-A53 CPU specified as
well. Android's platform and NDK builds need to assume that the code can
be run on Cortex-A53 devices, so we always enable the fix unless we know
specifically that the code is only running on a different kind of CPU.


https://reviews.llvm.org/D25761

Files:
  lib/Driver/Tools.cpp


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9677,6 +9677,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9677,6 +9677,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24319: clang-format: Add an option to git-clang-format to diff between to commits

2016-09-22 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282136: clang-format: Add an option to git-clang-format to 
diff between to commits (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24319?vs=72064=72138#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24319

Files:
  cfe/trunk/tools/clang-format/git-clang-format

Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -32,12 +32,15 @@
 import subprocess
 import sys
 
-usage = 'git clang-format [OPTIONS] [] [--] [...]'
+usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
 
 desc = '''
-Run clang-format on all lines that differ between the working directory
-and , which defaults to HEAD.  Changes are only applied to the working
-directory.
+If zero or one commits are given, run clang-format on all lines that differ
+between the working directory and , which defaults to HEAD.  Changes are
+only applied to the working directory.
+
+If two commits are given (requires --diff), run clang-format on all lines in the
+second  that differ from the first .
 
 The following git-config settings set the default of the corresponding option:
   clangFormat.binary
@@ -121,8 +124,14 @@
   opts.verbose -= opts.quiet
   del opts.quiet
 
-  commit, files = interpret_args(opts.args, dash_dash, opts.commit)
-  changed_lines = compute_diff_and_extract_lines(commit, files)
+  commits, files = interpret_args(opts.args, dash_dash, opts.commit)
+  if len(commits) > 1:
+if not opts.diff:
+  die('--diff is required when two commits are given')
+  else:
+if len(commits) > 2:
+  die('at most two commits allowed; %d given' % len(commits))
+  changed_lines = compute_diff_and_extract_lines(commits, files)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -142,10 +151,17 @@
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
   cd_to_toplevel()
-  old_tree = create_tree_from_workdir(changed_lines)
-  new_tree = run_clang_format_and_save_to_tree(changed_lines,
-   binary=opts.binary,
-   style=opts.style)
+  if len(commits) > 1:
+old_tree = commits[1]
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ revision=commits[1],
+ binary=opts.binary,
+ style=opts.style)
+  else:
+old_tree = create_tree_from_workdir(changed_lines)
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ binary=opts.binary,
+ style=opts.style)
   if opts.verbose >= 1:
 print 'old tree:', old_tree
 print 'new tree:', new_tree
@@ -182,40 +198,41 @@
 
 
 def interpret_args(args, dash_dash, default_commit):
-  """Interpret `args` as "[commit] [--] [files...]" and return (commit, files).
+  """Interpret `args` as "[commits] [--] [files]" and return (commits, files).
 
   It is assumed that "--" and everything that follows has been removed from
   args and placed in `dash_dash`.
 
-  If "--" is present (i.e., `dash_dash` is non-empty), the argument to its
-  left (if present) is taken as commit.  Otherwise, the first argument is
-  checked if it is a commit or a file.  If commit is not given,
-  `default_commit` is used."""
+  If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its
+  left (if present) are taken as commits.  Otherwise, the arguments are checked
+  from left to right if they are commits or files.  If commits are not given,
+  a list with `default_commit` is used."""
   if dash_dash:
 if len(args) == 0:
-  commit = default_commit
-elif len(args) > 1:
-  die('at most one commit allowed; %d given' % len(args))
+  commits = [default_commit]
 else:
-  commit = args[0]
-object_type = get_object_type(commit)
-if object_type not in ('commit', 'tag'):
-  if object_type is None:
-die("'%s' is not a commit" % commit)
-  else:
-die("'%s' is a %s, but a commit was expected" % (commit, object_type))
+  commits = args
+for commit in commits:
+  object_type = get_object_type(commit)
+  if object_type not in ('commit', 'tag'):
+if object_type is None:
+  die("'%s' is not a commit" % commit)
+else:
+  die("'%s' is a %s, but a commit was expected" % (commit, object_type))
 files = dash_dash[1:]
   elif args:
-if disambiguate_revision(args[0]):
-  commit = args[0]
-  files = args[1:]
-else:
-  commit = default_commit
-  

r282136 - clang-format: Add an option to git-clang-format to diff between to commits

2016-09-22 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Sep 22 00:52:55 2016
New Revision: 282136

URL: http://llvm.org/viewvc/llvm-project?rev=282136=rev
Log:
clang-format: Add an option to git-clang-format to diff between to commits

Summary:
When building pre-upload hooks using git-clang-format, it is useful to limit 
the scope to a diff of two commits (instead of from a commit against the 
working tree) to allow for less false positives in dependent commits.

This change adds the option of specifying two git commits to git-clang-format 
when using the `--diff` flag, which uses a different strategy to diff (using 
`git-diff-tree` instead of `git-diff-index`), and runs clang-format against the 
second commit instead of the working directory.

There is a slight backwards-incompatibility introduced with this change: if a 
filename matches a branch name or other commit-ish, then `git clang-format 
 ` will no longer work as expected; use `git clang-format 
 -- ` instead.

Patch by Luis Hector Chavez!

Reviewers: djasper, lodato

Subscribers: lodato, cfe-commits, srhines

Projects: #clang-c

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

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=282136=282135=282136=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Thu Sep 22 00:52:55 2016
@@ -32,12 +32,15 @@ import re
 import subprocess
 import sys
 
-usage = 'git clang-format [OPTIONS] [] [--] [...]'
+usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
 
 desc = '''
-Run clang-format on all lines that differ between the working directory
-and , which defaults to HEAD.  Changes are only applied to the working
-directory.
+If zero or one commits are given, run clang-format on all lines that differ
+between the working directory and , which defaults to HEAD.  Changes 
are
+only applied to the working directory.
+
+If two commits are given (requires --diff), run clang-format on all lines in 
the
+second  that differ from the first .
 
 The following git-config settings set the default of the corresponding option:
   clangFormat.binary
@@ -121,8 +124,14 @@ def main():
   opts.verbose -= opts.quiet
   del opts.quiet
 
-  commit, files = interpret_args(opts.args, dash_dash, opts.commit)
-  changed_lines = compute_diff_and_extract_lines(commit, files)
+  commits, files = interpret_args(opts.args, dash_dash, opts.commit)
+  if len(commits) > 1:
+if not opts.diff:
+  die('--diff is required when two commits are given')
+  else:
+if len(commits) > 2:
+  die('at most two commits allowed; %d given' % len(commits))
+  changed_lines = compute_diff_and_extract_lines(commits, files)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -142,10 +151,17 @@ def main():
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
   cd_to_toplevel()
-  old_tree = create_tree_from_workdir(changed_lines)
-  new_tree = run_clang_format_and_save_to_tree(changed_lines,
-   binary=opts.binary,
-   style=opts.style)
+  if len(commits) > 1:
+old_tree = commits[1]
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ revision=commits[1],
+ binary=opts.binary,
+ style=opts.style)
+  else:
+old_tree = create_tree_from_workdir(changed_lines)
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ binary=opts.binary,
+ style=opts.style)
   if opts.verbose >= 1:
 print 'old tree:', old_tree
 print 'new tree:', new_tree
@@ -182,40 +198,41 @@ def load_git_config(non_string_options=N
 
 
 def interpret_args(args, dash_dash, default_commit):
-  """Interpret `args` as "[commit] [--] [files...]" and return (commit, files).
+  """Interpret `args` as "[commits] [--] [files]" and return (commits, files).
 
   It is assumed that "--" and everything that follows has been removed from
   args and placed in `dash_dash`.
 
-  If "--" is present (i.e., `dash_dash` is non-empty), the argument to its
-  left (if present) is taken as commit.  Otherwise, the first argument is
-  checked if it is a commit or a file.  If commit is not given,
-  `default_commit` is used."""
+  If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its
+  left (if present) are taken as commits.  Otherwise, the arguments are checked
+  from left to right if they are commits or files.  If commits 

Re: [PATCH] D24648: Fix unused result from sign extending an Offset.

2016-09-16 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281706: Fix unused result from sign extending an Offset. 
(authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24648?vs=71598=71599#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24648

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3882,7 +3882,7 @@
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3882,7 +3882,7 @@
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281706 - Fix unused result from sign extending an Offset.

2016-09-16 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Fri Sep 16 02:21:24 2016
New Revision: 281706

URL: http://llvm.org/viewvc/llvm-project?rev=281706=rev
Log:
Fix unused result from sign extending an Offset.

Summary:
Offset was doubled in size, but the assignment was missing. We just need
to reassign to the original variable in this case to fix it.

Reviewers: cfe-commits, echristo

Subscribers: meikeb

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=281706=281705=281706=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Sep 16 02:21:24 2016
@@ -3882,7 +3882,7 @@ static void sumOffsets(llvm::APSInt 
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }


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


Re: [PATCH] D24648: Fix unused result from sign extending an Offset.

2016-09-16 Thread Stephen Hines via cfe-commits
It is marked LLVM_ATTRIBUTE_UNUSED_RESULT (which boils down to having
__warn_unused_result__). I am not sure why this didn't trigger during any
local build/test that we did.

Steve

On Thu, Sep 15, 2016 at 11:45 PM, David Majnemer <david.majne...@gmail.com>
wrote:

> sext should probably be marked WARN_UNUSED_RESULT
>
>
> On Thursday, September 15, 2016, Stephen Hines via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> srhines created this revision.
>> srhines added a reviewer: cfe-commits.
>> srhines added a subscriber: meikeb.
>>
>> Offset was doubled in size, but the assignment was missing. We just need
>> to reassign to the original variable in this case to fix it.
>>
>> https://reviews.llvm.org/D24648
>>
>> Files:
>>   lib/Sema/SemaChecking.cpp
>>
>> Index: lib/Sema/SemaChecking.cpp
>> ===
>> --- lib/Sema/SemaChecking.cpp
>> +++ lib/Sema/SemaChecking.cpp
>> @@ -3882,7 +3882,7 @@
>>// possible.
>>if (Ov) {
>>  assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too
>> big");
>> -Offset.sext(2 * BitWidth);
>> +Offset = Offset.sext(2 * BitWidth);
>>  sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
>>  return;
>>}
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24648: Fix unused result from sign extending an Offset.

2016-09-16 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added a reviewer: cfe-commits.
srhines added a subscriber: meikeb.

Offset was doubled in size, but the assignment was missing. We just need
to reassign to the original variable in this case to fix it.

https://reviews.llvm.org/D24648

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3882,7 +3882,7 @@
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3882,7 +3882,7 @@
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24584: Do not warn about format strings that are indexed string literals.

2016-09-15 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281686: Do not warn about format strings that are indexed 
string literals. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24584?vs=71585=71586#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24584

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/format-strings.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3850,7 +3850,95 @@
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema , const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt , llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { return FExpr->isUTF8(); }
+  bool isUTF16() const { return FExpr->isUTF16(); }
+  bool isUTF32() const { return FExpr->isUTF32(); }
+  bool isPascal() const { return FExpr->isPascal(); }
+
+  SourceLocation getLocationOfByte(
+  unsigned ByteNo, const SourceManager , const LangOptions ,
+  const TargetInfo , unsigned *StartToken = nullptr,
+  unsigned *StartTokenByteOffset = nullptr) const {
+return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
+StartToken, StartTokenByteOffset);
+  }
+
+  SourceLocation getLocStart() const LLVM_READONLY {
+return FExpr->getLocStart().getLocWithOffset(Offset);
+  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
+};
+}  // end anonymous namespace
+
+static void CheckFormatString(Sema , const FormatStringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3871,8 +3959,11 @@
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,
   llvm::SmallBitVector ,
-  UncoveredArgHandler ) {
+  UncoveredArgHandler ,
+  llvm::APSInt Offset) {
  tryAgain:
+  assert(Offset.isSigned() && "invalid offset");
+
   if (E->isTypeDependent() || E->isValueDependent())
 return SLCT_NotALiteral;
 
@@ -3906,23 +3997,28 @@
 CheckLeft = false;
 }
 
+// We need to maintain the offsets for the right and the left hand side
+// separately to check if every possible indexed expression is a valid
+// string literal. They might have different offsets for different string
+// literals in the end.
  

r281686 - Do not warn about format strings that are indexed string literals.

2016-09-15 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Sep 15 20:07:04 2016
New Revision: 281686

URL: http://llvm.org/viewvc/llvm-project?rev=281686=rev
Log:
Do not warn about format strings that are indexed string literals.

Summary:
The warning for a format string not being a string literal and therefore
being potentially insecure is overly strict for indices into string
literals. This fix checks if the index into the string literal is
precomputable. If that's the case it will check if the suffix of that
string literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indices into the
string literal.

Patch by Meike Baumgärtner (meikeb)

Reviewers: rsmith

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=281686=281685=281686=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 15 20:07:04 2016
@@ -3850,7 +3850,95 @@ enum StringLiteralCheckType {
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema , const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt , llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big 
as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes 
correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { return FExpr->isUTF8(); }
+  bool isUTF16() const { return FExpr->isUTF16(); }
+  bool isUTF32() const { return FExpr->isUTF32(); }
+  bool isPascal() const { return FExpr->isPascal(); }
+
+  SourceLocation getLocationOfByte(
+  unsigned ByteNo, const SourceManager , const LangOptions ,
+  const TargetInfo , unsigned *StartToken = nullptr,
+  unsigned *StartTokenByteOffset = nullptr) const {
+return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
+StartToken, StartTokenByteOffset);
+  }
+
+  SourceLocation getLocStart() const LLVM_READONLY {
+return FExpr->getLocStart().getLocWithOffset(Offset);
+  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
+};
+}  // end anonymous namespace
+
+static void CheckFormatString(Sema , const FormatStringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3871,8 +3959,11 @@ checkFormatStringExpr(Sema , const Exp
   unsigned firstDataArg, Sema::FormatStringType Type,
   

Re: [PATCH] D24579: Revert "Do not warn about format strings that are indexed string literals."

2016-09-14 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281530: Revert "Do not warn about format strings that are 
indexed string literals." (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24579?vs=71417=71419#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24579

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/format-strings.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3841,95 +3841,7 @@
 };
 } // end anonymous namespace
 
-static void sumOffsets(llvm::APSInt , llvm::APSInt Addend,
- BinaryOperatorKind BinOpKind,
- bool AddendIsRight) {
-  unsigned BitWidth = Offset.getBitWidth();
-  unsigned AddendBitWidth = Addend.getBitWidth();
-  // There might be negative interim results.
-  if (Addend.isUnsigned()) {
-Addend = Addend.zext(++AddendBitWidth);
-Addend.setIsSigned(true);
-  }
-  // Adjust the bit width of the APSInts.
-  if (AddendBitWidth > BitWidth) {
-Offset = Offset.sext(AddendBitWidth);
-BitWidth = AddendBitWidth;
-  } else if (BitWidth > AddendBitWidth) {
-Addend = Addend.sext(BitWidth);
-  }
-
-  bool Ov = false;
-  llvm::APSInt ResOffset = Offset;
-  if (BinOpKind == BO_Add)
-ResOffset = Offset.sadd_ov(Addend, Ov);
-  else {
-assert(AddendIsRight && BinOpKind == BO_Sub &&
-   "operator must be add or sub with addend on the right");
-ResOffset = Offset.ssub_ov(Addend, Ov);
-  }
-
-  // We add an offset to a pointer here so we should support an offset as big as
-  // possible.
-  if (Ov) {
-assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
-sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
-return;
-  }
-
-  Offset = ResOffset;
-}
-
-namespace {
-// This is a wrapper class around StringLiteral to support offsetted string
-// literals as format strings. It takes the offset into account when returning
-// the string and its length or the source locations to display notes correctly.
-class FormatStringLiteral {
-  const StringLiteral *FExpr;
-  int64_t Offset;
-
- public:
-  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
-  : FExpr(fexpr), Offset(Offset) {}
-
-  StringRef getString() const {
-return FExpr->getString().drop_front(Offset);
-  }
-
-  unsigned getByteLength() const {
-return FExpr->getByteLength() - getCharByteWidth() * Offset;
-  }
-  unsigned getLength() const { return FExpr->getLength() - Offset; }
-  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
-
-  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
-
-  QualType getType() const { return FExpr->getType(); }
-
-  bool isAscii() const { return FExpr->isAscii(); }
-  bool isWide() const { return FExpr->isWide(); }
-  bool isUTF8() const { return FExpr->isUTF8(); }
-  bool isUTF16() const { return FExpr->isUTF16(); }
-  bool isUTF32() const { return FExpr->isUTF32(); }
-  bool isPascal() const { return FExpr->isPascal(); }
-
-  SourceLocation getLocationOfByte(
-  unsigned ByteNo, const SourceManager , const LangOptions ,
-  const TargetInfo , unsigned *StartToken = nullptr,
-  unsigned *StartTokenByteOffset = nullptr) const {
-return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
-StartToken, StartTokenByteOffset);
-  }
-
-  SourceLocation getLocStart() const LLVM_READONLY {
-return FExpr->getLocStart().getLocWithOffset(Offset);
-  }
-  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
-};
-}  // end anonymous namespace
-
-static void CheckFormatString(Sema , const FormatStringLiteral *FExpr,
+static void CheckFormatString(Sema , const StringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3950,11 +3862,8 @@
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,
   llvm::SmallBitVector ,
-  UncoveredArgHandler ,
-  llvm::APSInt Offset) {
+  UncoveredArgHandler ) {
  tryAgain:
-  assert(Offset.isSigned() && "invalid offset");
-
   if (E->isTypeDependent() || E->isValueDependent())
 return SLCT_NotALiteral;
 
@@ -3988,28 +3897,23 @@
 CheckLeft = false;
 }
 
-// We need to maintain the offsets for the right and the left hand side
-// separately to check if every possible indexed expression is a valid
-// string literal. They might have different offsets for different string
-// literals in 

[PATCH] D24579: Revert "Do not warn about format strings that are indexed string literals."

2016-09-14 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added a subscriber: cfe-commits.

This reverts r281527 because I messed up the attribution.

https://reviews.llvm.org/D24579

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings.c

Index: test/Sema/format-strings.c
===
--- test/Sema/format-strings.c
+++ test/Sema/format-strings.c
@@ -652,38 +652,3 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
-
-void test_char_pointer_arithmetic(int b) {
-  const char s1[] = "string";
-  const char s2[] = "%s string";
-
-  printf(s1 - 1);  // expected-warning {{format string is not a string literal (potentially insecure)}}
-  // expected-note@-1{{treat the string as an argument to avoid this}}
-
-  printf(s1 + 2);  // no-warning
-  printf(s2 + 2);  // no-warning
-
-  const char s3[] = "%s string";
-  printf((s3 + 2) - 2);  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-  printf(2 + s2); // no-warning
-  printf(6 + s2 - 2); // no-warning
-  printf(2 + (b ? s1 : s2));  // no-warning
-
-  const char s5[] = "string %s";
-  printf(2 + (b ? s2 : s5));  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-  printf(2 + (b ? s2 : s5), "");  // no-warning
-  printf(2 + (b ? s1 : s2 - 2), "");  // no-warning
-
-  const char s6[] = "%s string";
-  printf(2 + (b ? s1 : s6 - 2));  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-  printf(1 ? s2 + 2 : s2);  // no-warning
-  printf(0 ? s2 : s2 + 2);  // no-warning
-  printf(2 + s2 + 5 * 3 - 16, "");  // expected-warning{{data argument not used}}
-
-  const char s7[] = "%s string %s %s";
-  printf(s7 + 3, "");  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3841,95 +3841,7 @@
 };
 } // end anonymous namespace
 
-static void sumOffsets(llvm::APSInt , llvm::APSInt Addend,
- BinaryOperatorKind BinOpKind,
- bool AddendIsRight) {
-  unsigned BitWidth = Offset.getBitWidth();
-  unsigned AddendBitWidth = Addend.getBitWidth();
-  // There might be negative interim results.
-  if (Addend.isUnsigned()) {
-Addend = Addend.zext(++AddendBitWidth);
-Addend.setIsSigned(true);
-  }
-  // Adjust the bit width of the APSInts.
-  if (AddendBitWidth > BitWidth) {
-Offset = Offset.sext(AddendBitWidth);
-BitWidth = AddendBitWidth;
-  } else if (BitWidth > AddendBitWidth) {
-Addend = Addend.sext(BitWidth);
-  }
-
-  bool Ov = false;
-  llvm::APSInt ResOffset = Offset;
-  if (BinOpKind == BO_Add)
-ResOffset = Offset.sadd_ov(Addend, Ov);
-  else {
-assert(AddendIsRight && BinOpKind == BO_Sub &&
-   "operator must be add or sub with addend on the right");
-ResOffset = Offset.ssub_ov(Addend, Ov);
-  }
-
-  // We add an offset to a pointer here so we should support an offset as big as
-  // possible.
-  if (Ov) {
-assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
-sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
-return;
-  }
-
-  Offset = ResOffset;
-}
-
-namespace {
-// This is a wrapper class around StringLiteral to support offsetted string
-// literals as format strings. It takes the offset into account when returning
-// the string and its length or the source locations to display notes correctly.
-class FormatStringLiteral {
-  const StringLiteral *FExpr;
-  int64_t Offset;
-
- public:
-  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
-  : FExpr(fexpr), Offset(Offset) {}
-
-  StringRef getString() const {
-return FExpr->getString().drop_front(Offset);
-  }
-
-  unsigned getByteLength() const {
-return FExpr->getByteLength() - getCharByteWidth() * Offset;
-  }
-  unsigned getLength() const { return FExpr->getLength() - Offset; }
-  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
-
-  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
-
-  QualType getType() const { return FExpr->getType(); }
-
-  bool isAscii() const { return FExpr->isAscii(); }
-  bool isWide() const { return FExpr->isWide(); }
-  bool isUTF8() const { return FExpr->isUTF8(); }
-  bool isUTF16() const { return FExpr->isUTF16(); }
-  bool isUTF32() const { return FExpr->isUTF32(); }
-  bool isPascal() const { return FExpr->isPascal(); }
-
-  SourceLocation getLocationOfByte(
-  unsigned ByteNo, const SourceManager , const LangOptions ,
-  const TargetInfo , 

Re: [PATCH] D23820: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281527: Do not warn about format strings that are indexed 
string literals. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D23820?vs=71286=71416#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23820

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/format-strings.c

Index: cfe/trunk/test/Sema/format-strings.c
===
--- cfe/trunk/test/Sema/format-strings.c
+++ cfe/trunk/test/Sema/format-strings.c
@@ -652,3 +652,38 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
+
+void test_char_pointer_arithmetic(int b) {
+  const char s1[] = "string";
+  const char s2[] = "%s string";
+
+  printf(s1 - 1);  // expected-warning {{format string is not a string literal (potentially insecure)}}
+  // expected-note@-1{{treat the string as an argument to avoid this}}
+
+  printf(s1 + 2);  // no-warning
+  printf(s2 + 2);  // no-warning
+
+  const char s3[] = "%s string";
+  printf((s3 + 2) - 2);  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + s2); // no-warning
+  printf(6 + s2 - 2); // no-warning
+  printf(2 + (b ? s1 : s2));  // no-warning
+
+  const char s5[] = "string %s";
+  printf(2 + (b ? s2 : s5));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + (b ? s2 : s5), "");  // no-warning
+  printf(2 + (b ? s1 : s2 - 2), "");  // no-warning
+
+  const char s6[] = "%s string";
+  printf(2 + (b ? s1 : s6 - 2));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(1 ? s2 + 2 : s2);  // no-warning
+  printf(0 ? s2 : s2 + 2);  // no-warning
+  printf(2 + s2 + 5 * 3 - 16, "");  // expected-warning{{data argument not used}}
+
+  const char s7[] = "%s string %s %s";
+  printf(s7 + 3, "");  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3841,7 +3841,95 @@
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema , const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt , llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { return 

r281527 - Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Wed Sep 14 15:05:20 2016
New Revision: 281527

URL: http://llvm.org/viewvc/llvm-project?rev=281527=rev
Log:
Do not warn about format strings that are indexed string literals.

Summary:
The warning for a format string not being a sting literal and therefore
being potentially insecure is overly strict for indecies into sting
literals. This fix checks if the index into the string literal is
precomputable. If thats the case it will check if the suffix of that
sting literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indecies into the
string literal.

Reviewers: rsmith

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=281527=281526=281527=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 14 15:05:20 2016
@@ -3841,7 +3841,95 @@ enum StringLiteralCheckType {
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema , const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt , llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big 
as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes 
correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { return FExpr->isUTF8(); }
+  bool isUTF16() const { return FExpr->isUTF16(); }
+  bool isUTF32() const { return FExpr->isUTF32(); }
+  bool isPascal() const { return FExpr->isPascal(); }
+
+  SourceLocation getLocationOfByte(
+  unsigned ByteNo, const SourceManager , const LangOptions ,
+  const TargetInfo , unsigned *StartToken = nullptr,
+  unsigned *StartTokenByteOffset = nullptr) const {
+return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
+StartToken, StartTokenByteOffset);
+  }
+
+  SourceLocation getLocStart() const LLVM_READONLY {
+return FExpr->getLocStart().getLocWithOffset(Offset);
+  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
+};
+}  // end anonymous namespace
+
+static void CheckFormatString(Sema , const FormatStringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3862,8 +3950,11 @@ checkFormatStringExpr(Sema , const Exp
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,

Re: [PATCH] D23820: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Stephen Hines via cfe-commits
srhines added a comment.

I will take care of submitting this. Thanks for the reviews everybody!


https://reviews.llvm.org/D23820



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


Re: [PATCH] D23820: Do not warn about format strings that are indexed string literals.

2016-09-13 Thread Stephen Hines via cfe-commits
srhines added a comment.

My comment is mostly naming considerations to improve clarity. I do have 
concerns though about the unhandled else path.



Comment at: lib/Sema/SemaChecking.cpp:3842
@@ -3841,2 +3841,3 @@
 
-static void CheckFormatString(Sema , const StringLiteral *FExpr,
+static void sumUpStringLiteralOffset(llvm::APSInt , llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,

Is "computeStringLiteralOffset" or "calculate..." a better name here?


Comment at: lib/Sema/SemaChecking.cpp:3844
@@ +3843,3 @@
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();

Is "Operand" better than "Addend"? In particular, there is the possibility that 
we do subtraction of the value instead of addition, so "Addend" makes it a bit 
confusing. Of course, I then would expect "OperandIsRight" instead of 
"AddendIsRight" too.


Comment at: lib/Sema/SemaChecking.cpp:3852
@@ +3851,3 @@
+  }
+  // Align the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {

Align -> Canonicalize or Adjust

This is confusing here as "Align" already has too many overloaded meanings in 
programming (that could be relevant to bitwidths). Canonicalize or Adjust don't 
have this problem.


Comment at: lib/Sema/SemaChecking.cpp:3860
@@ +3859,3 @@
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;

Ov -> Overflow


Comment at: lib/Sema/SemaChecking.cpp:3865
@@ +3864,3 @@
+  else if (AddendIsRight && BinOpKind == BO_Sub)
+ResOffset = Offset.ssub_ov(Addend, Ov);
+

What happens if someone passes something that isn't caught by these two cases? 
Should we be returning an indicator that the calculation failed? If not, should 
we assert here?


Comment at: lib/Sema/SemaChecking.cpp:3867
@@ +3866,3 @@
+
+  // We add a offset to a pointer here so we should support a offset as big as
+  // possible.

2 places to fix: "a offset" -> "an offset"


https://reviews.llvm.org/D23820



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


Re: [PATCH] D24401: clang-format: Add Java detection to git-clang-format.

2016-09-12 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281294: clang-format: Add Java detection to 
git-clang-format. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24401?vs=71104=71107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24401

Files:
  cfe/trunk/tools/clang-format/git-clang-format

Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -77,6 +77,7 @@
   'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers
+  'java',  # Java
   'js',  # JavaScript
   'ts',  # TypeScript
   ])


Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -77,6 +77,7 @@
   'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers
+  'java',  # Java
   'js',  # JavaScript
   'ts',  # TypeScript
   ])
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281294 - clang-format: Add Java detection to git-clang-format.

2016-09-12 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Sep 13 00:00:20 2016
New Revision: 281294

URL: http://llvm.org/viewvc/llvm-project?rev=281294=rev
Log:
clang-format: Add Java detection to git-clang-format.

Summary: This change adds "java" to the list of known extensions that 
clang-format supports.

Patch by Luis Hector Chavez

Reviewers: djasper

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=281294=281293=281294=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Tue Sep 13 00:00:20 2016
@@ -77,6 +77,7 @@ def main():
   'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers
+  'java',  # Java
   'js',  # JavaScript
   'ts',  # TypeScript
   ])


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


Re: [PATCH] D20709: For RenderScript, set alignment and width of long to 64-bits

2016-06-01 Thread Stephen Hines via cfe-commits
srhines added a comment.

After talking to Richard this afternoon on IRC, we are going with a slightly 
different plan here. We will create two new triples (renderscript32-*-* and 
renderscript64-*-*), which are direct subclasses of the general Android ARM32 
and ARM64 targets. In this case, we can use all of the existing ABI info we 
already have built up for these targets (and override longs to be 64-bit on the 
renderscript32-*-* target). Additionally, the renderscript targets will also 
set the triple name back to the ARM-related triple, since we can't break 
compatibility for generating RenderScript code that is expected to embed the 
ARM triples in the bitcode (mostly ignored, but might be validated).

One thing that didn't come up in the IRC discussion, but we probably still need 
a LangOpt for RenderScript. There is a coming patch that adds a single 
attribute (for "kernel"), that has error checking to ensure that it is only 
used by our RenderScript targets. I assume that the cleanest way to retain that 
diagnostic (and get the last of these divergent patches in) will be to still 
key off of a LangOpt. If you think it is preferable to check against a target 
instead, I can change the code to do that, but I figured this is more 
consistent with how other attributes work.


http://reviews.llvm.org/D20709



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


Re: [PATCH] D20709: Support ARM subtarget feature +long64

2016-05-30 Thread Stephen Hines via cfe-commits
srhines added a comment.

In http://reviews.llvm.org/D20709#443536, @kristof.beyls wrote:

> Hi Pirama,
>
> My understanding is that this introduces (yet another) ARM 32 bit ABI variant 
> - in this case with longs being 64 bit.
>  My understanding is also that this is the ABI that is used in Renderscript, 
> and this patch helps to remove local patches that currently live in the 
> Renderscript toolchain downstream only.


Correct. This is only used by RenderScript, and unfortunately can't be done any 
differently. We had hoped to just predicate this with our own LangOpt (the 
patch that adds the RenderScript LangOpt is coming soon), but unfortunately, at 
the point where LangOpts are being parsed, the target machine already has the 
size and alignment of long specified (and it can't change).

> I think it's good not to need downstream patches for a Renderscript toolchain.


Same here, although these patches seem so small that I don't want to introduce 
too much trouble in upstream. If there isn't a nice way to clean this up, I 
would be fine with this amount of divergence, since it really doesn't impact 
our ability to update LLVM (and again, the feature is only used by 
RenderScript).

> In effect, this introduces another abi variant.

>  I'm wondering if the abi variant should be controlled using a triple, just 
> like e.g. the hard float vs. soft float abi variants also get controlled via 
> a triple?


We can't unfortunately control this via a separate triple because RenderScript 
has (and always) will use the ARM triple. This really only affects the frontend 
for RenderScript, since RS doesn't allow the full libc runtime. That is why the 
LLVM side of this patch has no tests (because there is nothing there, and we 
only need the option recognized or the backend generates warnings about an 
unsupported flag - perhaps there is a better way to suppress that, but at the 
time that I fixed this years ago, I think my only option was to add it in both 
places).

> Tim, do you happen to have insights on this?

> 

> Thanks,

> 

> Kristof





http://reviews.llvm.org/D20709



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-24 Thread Stephen Hines via cfe-commits
srhines added a comment.

In http://reviews.llvm.org/D20602#438528, @rsmith wrote:

> Looks like this extension was added at some point between 1.1 and 2.1. It 
> would make sense to produce an `ExtWarn` for it if the OpenCL standard 
> version is less than the one that introduced it (whenever that was) -- that 
> would match what we do for extensions in other languages.


This isn't just for OpenCL (actually we don't care about it in the context of 
OpenCL at all). We really are adding this as more of an extension for C99, 
where Android has used this in the past. In the case of OpenCL, I also don't 
know that it should be recognized as invalid, because it can be lowered to an 
appropriate construct on any implementation (since they all have to support 
regular 4-vectors).


http://reviews.llvm.org/D20602



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


Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-27 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267835: Fix include path in ClangTidy.cpp. (authored by 
srhines).

Changed prior to commit:
  http://reviews.llvm.org/D19249?vs=54587=55368#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19249

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -58,7 +58,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   
\
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -58,7 +58,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   \
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r267835 - Fix include path in ClangTidy.cpp.

2016-04-27 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Wed Apr 27 20:42:12 2016
New Revision: 267835

URL: http://llvm.org/viewvc/llvm-project?rev=267835=rev
Log:
Fix include path in ClangTidy.cpp.

Summary:
https://llvm.org/bugs/show_bug.cgi?id=27355
To compile with other binary output directory structures in build systems like 
Android.

Reviewers: srhines, alexfh

Subscribers: tberghammer, danalbert, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=267835=267834=267835=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Apr 27 20:42:12 2016
@@ -58,7 +58,7 @@ static const StringRef StaticAnalyzerChe
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   
\
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };


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


Re: [PATCH] D19393: Move Checkers.inc to clang/include/.../Checkers

2016-04-21 Thread Stephen Hines via cfe-commits
srhines added inline comments.


Comment at: include/clang/StaticAnalyzer/Checkers/CMakeLists.txt:3
@@ +2,3 @@
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../
+  SOURCE ../../../../lib/StaticAnalyzer/Checkers/Checkers.td
+  TARGET ClangSACheckers)

Anna should probably decide here, but I think it might be preferable to 
actually move Checkers.td into include/..., since it is indeed being used 
beyond just the lib/... directory it currently resides in (hence the original 
problem here of a bizarre include path in clang/tools/extra).


http://reviews.llvm.org/D19393



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


Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-21 Thread Stephen Hines via cfe-commits
srhines added inline comments.


Comment at: clang-tidy/ClangTidy.cpp:61
@@ -60,3 +60,3 @@
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "Checkers.inc"
 #undef CHECKER

alexfh wrote:
> As it is, the change leaves almost no context of where the Checkers.inc file 
> comes from. I'd prefer to leave at least 
> `lib/StaticAnalyzer/Checkers/Checkers.inc`. Will this work for you?
> 
> Another question is how do you deal with other .inc files generated from .td 
> files in llvm/lib/... or llvm/tools/clang/lib/...?
I think that the other .inc files have proper exported include paths so that 
you only include the final part of the name.

Looking at llvm/lib/Option/CMakeLists.txt, I see the following export o fthe 
includes:

  ADDITIONAL_HEADER_DIRS
  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Option
  )

Should this export actually be happening in 
lib/StaticAnalyzer/Checkers/CMakeLists.txt? Even in that case, it will shorten 
down to just the final name, without any other part of the path (like you are 
requesting here).


http://reviews.llvm.org/D19249



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


r266840 - MarkEOLs should only be true for clang-cl.exe.

2016-04-19 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Apr 19 19:33:06 2016
New Revision: 266840

URL: http://llvm.org/viewvc/llvm-project?rev=266840=rev
Log:
MarkEOLs should only be true for clang-cl.exe.

Summary:
https://llvm.org/bugs/show_bug.cgi?id=27396

This fixes an issue in response files where "\r\n" was being interpreted
as two EOL markers (i.e. we consumed the '\r' as terminating the
previous token, and then parsed the '\n' as a significant EOL). This
breaks response files where joined arguments get split across multiple
lines (like "-x\r\nc"). I also fixed an accidental issue in the
response-file.c test, where the response file is appended to, instead of
being overwritten.

Reviewers: rnk

Subscribers: danalbert, llvm-commits

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

Added:
cfe/trunk/test/Driver/response-file-extra-whitespace.c
Modified:
cfe/trunk/test/Driver/response-file.c
cfe/trunk/tools/driver/driver.cpp

Added: cfe/trunk/test/Driver/response-file-extra-whitespace.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file-extra-whitespace.c?rev=266840=auto
==
--- cfe/trunk/test/Driver/response-file-extra-whitespace.c (added)
+++ cfe/trunk/test/Driver/response-file-extra-whitespace.c Tue Apr 19 19:33:06 
2016
@@ -0,0 +1,12 @@
+// Check that clang is able to process response files with extra whitespace.
+// We generate a dos-style file with \r\n for line endings, and then split
+// some joined arguments (like "-x c") across lines to ensure that regular
+// clang (not clang-cl) can process it correctly.
+//
+// RUN: echo -en "-x\r\nc\r\n-DTEST\r\n" > %t.0.txt
+// RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT
+// SHORT: extern int it_works;
+
+#ifdef TEST
+extern int it_works;
+#endif

Modified: cfe/trunk/test/Driver/response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file.c?rev=266840=266839=266840=diff
==
--- cfe/trunk/test/Driver/response-file.c (original)
+++ cfe/trunk/test/Driver/response-file.c Tue Apr 19 19:33:06 2016
@@ -4,7 +4,7 @@
 // Since this is a short response file, clang must not use a response file
 // to pass its parameters to other tools. This is only necessary for a large
 // number of parameters.
-// RUN: echo "-DTEST" >> %t.0.txt
+// RUN: echo "-DTEST" > %t.0.txt
 // RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT
 // SHORT-NOT: Arguments passed via response file
 // SHORT: extern int it_works;

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=266840=266839=266840=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Tue Apr 19 19:33:06 2016
@@ -338,18 +338,26 @@ int main(int argc_, const char **argv_)
   // have to manually search for a --driver-mode=cl argument the hard way.
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
-  llvm::cl::TokenizerCallback Tokenizer = ::cl::TokenizeGNUCommandLine;
+  bool ClangCLMode = false;
   if (TargetAndMode.second == "--driver-mode=cl" ||
   std::find_if(argv.begin(), argv.end(), [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
   }) != argv.end()) {
-Tokenizer = ::cl::TokenizeWindowsCommandLine;
+ClangCLMode = true;
   }
 
   // Determines whether we want nullptr markers in argv to indicate response
-  // files end-of-lines. We only use this for the /LINK driver argument.
-  bool MarkEOLs = true;
-  if (argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
+  // files end-of-lines. We only use this for the /LINK driver argument with
+  // clang-cl.exe on Windows.
+  bool MarkEOLs = false;
+
+  llvm::cl::TokenizerCallback Tokenizer = ::cl::TokenizeGNUCommandLine;
+  if (ClangCLMode) {
+Tokenizer = ::cl::TokenizeWindowsCommandLine;
+MarkEOLs = true;
+  }
+
+  if (MarkEOLs && argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
 MarkEOLs = false;
   llvm::cl::ExpandResponseFiles(Saver, Tokenizer, argv, MarkEOLs);
 


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


Re: [PATCH] D18363: Fix typo s/initalize/initialize/

2016-03-22 Thread Stephen Hines via cfe-commits
srhines accepted this revision.
srhines added a comment.
This revision is now accepted and ready to land.

I think this is trivial enough for me to accept. I also added cfe-commits, so 
that they at least have a chance to review/comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D18363



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


Re: [PATCH] D18138: Add -fnative-half-arguments-and-returns

2016-03-15 Thread Stephen Hines via cfe-commits
srhines added a reviewer: kristof.beyls.
srhines added a comment.

Kristof, can you or someone at ARM (where this is clearly relevant) take a look 
here? The CL obviously looks fine to me, but I might not have all of the 
original context as to why this was so constrained to OpenCL. Thanks.


http://reviews.llvm.org/D18138



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


Re: [PATCH] D17874: Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

2016-03-04 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262742: Switch krait to use -mcpu=cortex-a15 for assembler 
tool invocations. (authored by srhines).

Changed prior to commit:
  http://reviews.llvm.org/D17874?vs=49791=49844#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17874

Files:
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8706,12 +8706,12 @@
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8706,12 +8706,12 @@
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262742 - Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

2016-03-04 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Fri Mar  4 14:57:22 2016
New Revision: 262742

URL: http://llvm.org/viewvc/llvm-project?rev=262742=rev
Log:
Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

Summary:
Using -no-integrated-as causes -mcpu=krait to be transformed into
-march=armv7-a today. This precludes the assembler from using
instructions like sdiv, which are present for krait. Cortex-a15 is the
closest subset of functionality for krait, so we should switch the
assembler to use that instead.

Reviewers: cfe-commits, apazos, weimingz

Subscribers: aemerson

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=262742=262741=262742=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar  4 14:57:22 2016
@@ -8706,12 +8706,12 @@ void gnutools::Assembler::ConstructJob(C
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);


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


[PATCH] D17874: Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

2016-03-03 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added reviewers: cfe-commits, weimingz.
Herald added a subscriber: aemerson.

Using -no-integrated-as causes -mcpu=krait to be transformed into
-march=armv7-a today. This precludes the assembler from using
instructions like sdiv, which are present for krait. Cortex-a15 is the
closest subset of functionality for krait, so we should switch the
assembler to use that instead.

http://reviews.llvm.org/D17874

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8706,12 +8706,12 @@
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8706,12 +8706,12 @@
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r254682 - LLDB JIT needs android vector passing rules.

2015-12-03 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Dec  3 19:39:30 2015
New Revision: 254682

URL: http://llvm.org/viewvc/llvm-project?rev=254682=rev
Log:
LLDB JIT needs android vector passing rules.

Summary:
Looking into some recent issues with LLDBs expression parser highlighted that 
upstream clang passes vectors types differently to Android Open Source 
Project's clang for Arm Android targets.
This patch reflects the changes present in the AOSP and allows LLDB's JIT 
expression evaluation to work correctly for Arm Android targets when passing 
vectors.

This is submitted with consent of the original author Stephen Hines.

Reviewers: asl, rsmith, ADodds, rnk

Subscribers: rnk, aemerson, tberghammer, danalbert, srhines, cfe-commits, pirama

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/arm-abi-vector.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=254682=254681=254682=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Dec  3 19:39:30 2015
@@ -4730,6 +4730,11 @@ public:
 }
   }
 
+  bool isAndroid() const {
+return (getTarget().getTriple().getEnvironment() ==
+llvm::Triple::Android);
+  }
+
   ABIKind getABIKind() const { return Kind; }
 
 private:
@@ -5233,15 +5238,27 @@ ABIArgInfo ARMABIInfo::classifyReturnTyp
 
 /// isIllegalVector - check whether Ty is an illegal vector type.
 bool ARMABIInfo::isIllegalVectorType(QualType Ty) const {
-  if (const VectorType *VT = Ty->getAs()) {
-// Check whether VT is legal.
-unsigned NumElements = VT->getNumElements();
-uint64_t Size = getContext().getTypeSize(VT);
-// NumElements should be power of 2.
-if ((NumElements & (NumElements - 1)) != 0)
-  return true;
-// Size should be greater than 32 bits.
-return Size <= 32;
+  if (const VectorType *VT = Ty->getAs ()) {
+if (isAndroid()) {
+  // Android shipped using Clang 3.1, which supported a slightly different
+  // vector ABI. The primary differences were that 3-element vector types
+  // were legal, and so were sub 32-bit vectors (i.e. <2 x i8>). This path
+  // accepts that legacy behavior for Android only.
+  // Check whether VT is legal.
+  unsigned NumElements = VT->getNumElements();
+  // NumElements should be power of 2 or equal to 3.
+  if (!llvm::isPowerOf2_32(NumElements) && NumElements != 3)
+return true;
+} else {
+  // Check whether VT is legal.
+  unsigned NumElements = VT->getNumElements();
+  uint64_t Size = getContext().getTypeSize(VT);
+  // NumElements should be power of 2.
+  if (!llvm::isPowerOf2_32(NumElements))
+return true;
+  // Size should be greater than 32 bits.
+  return Size <= 32;
+}
   }
   return false;
 }

Modified: cfe/trunk/test/CodeGen/arm-abi-vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-abi-vector.c?rev=254682=254681=254682=diff
==
--- cfe/trunk/test/CodeGen/arm-abi-vector.c (original)
+++ cfe/trunk/test/CodeGen/arm-abi-vector.c Thu Dec  3 19:39:30 2015
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi aapcs -emit-llvm -o 
- %s | FileCheck %s
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi apcs-gnu -emit-llvm 
-o - %s | FileCheck -check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -emit-llvm -o - %s | 
FileCheck -check-prefix=ANDROID %s
 
 #include 
 
@@ -28,6 +29,14 @@ double varargs_vec_2i(int fixed, ...) {
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <2 x i32>*
 // APCS-GNU: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 4
 // APCS-GNU: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
+// ANDROID: varargs_vec_2i
+// ANDROID: [[VAR:%.*]] = alloca <2 x i32>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 
8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <2 x i32>*
+// ANDROID: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 8
+// ANDROID: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -42,6 +51,8 @@ double test_2i(__int2 *in) {
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> 
{{%.*}})
 // APCS-GNU: test_2i
 // APCS-GNU: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
+// ANDROID: test_2i
+// ANDROID: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
   return varargs_vec_2i(3, *in);
 }
 
@@ -54,6 +65,10 @@ double varargs_vec_3c(int fixed, ...) {
 // APCS-GNU: alloca <3 x 

Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-03 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254682: LLDB JIT needs android vector passing rules. 
(authored by srhines).

Changed prior to commit:
  http://reviews.llvm.org/D14639?vs=41654=41837#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14639

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/arm-abi-vector.c

Index: cfe/trunk/test/CodeGen/arm-abi-vector.c
===
--- cfe/trunk/test/CodeGen/arm-abi-vector.c
+++ cfe/trunk/test/CodeGen/arm-abi-vector.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi aapcs -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi apcs-gnu -emit-llvm -o - %s | FileCheck -check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -emit-llvm -o - %s | FileCheck -check-prefix=ANDROID %s
 
 #include 
 
@@ -28,6 +29,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <2 x i32>*
 // APCS-GNU: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 4
 // APCS-GNU: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
+// ANDROID: varargs_vec_2i
+// ANDROID: [[VAR:%.*]] = alloca <2 x i32>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <2 x i32>*
+// ANDROID: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 8
+// ANDROID: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -42,6 +51,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
 // APCS-GNU: test_2i
 // APCS-GNU: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
+// ANDROID: test_2i
+// ANDROID: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
   return varargs_vec_2i(3, *in);
 }
 
@@ -54,6 +65,10 @@
 // APCS-GNU: alloca <3 x i8>, align 4
 // APCS-GNU: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
 // APCS-GNU: bitcast i8* [[AP]] to <3 x i8>*
+// ANDROID: varargs_vec_3c
+// ANDROID: alloca <3 x i8>, align 4
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
+// ANDROID: bitcast i8* [[AP]] to <3 x i8>*
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -68,6 +83,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_3c(i32 3, i32 {{%.*}})
 // APCS-GNU: test_3c
 // APCS-GNU: call double (i32, ...) @varargs_vec_3c(i32 3, i32 {{%.*}})
+// ANDROID: test_3c
+// ANDROID: call double (i32, ...) @varargs_vec_3c(i32 3, <3 x i8> {{%.*}})
   return varargs_vec_3c(3, *in);
 }
 
@@ -87,6 +104,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <5 x i8>*
 // APCS-GNU: [[VEC:%.*]] = load <5 x i8>, <5 x i8>* [[AP_CAST]], align 4
 // APCS-GNU: store <5 x i8> [[VEC]], <5 x i8>* [[VAR]], align 8
+// ANDROID: varargs_vec_5c
+// ANDROID: [[VAR:%.*]] = alloca <5 x i8>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <5 x i8>*
+// ANDROID: [[VEC:%.*]] = load <5 x i8>, <5 x i8>* [[AP_CAST]], align 8
+// ANDROID: store <5 x i8> [[VEC]], <5 x i8>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -101,6 +126,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
 // APCS-GNU: test_5c
 // APCS-GNU: call double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
+// ANDROID: test_5c
+// ANDROID: call double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
   return varargs_vec_5c(5, *in);
 }
 
@@ -120,6 +147,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <9 x i8>*
 // APCS-GNU: [[VEC:%.*]] = load <9 x i8>, <9 x i8>* [[AP_CAST]], align 4
 // APCS-GNU: store <9 x i8> [[VEC]], <9 x i8>* [[VAR]], align 16
+// ANDROID: varargs_vec_9c
+// ANDROID: [[VAR:%.*]] = alloca <9 x i8>, align 16
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 16
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <9 x i8>*
+// ANDROID: [[T0:%.*]] = load <9 x i8>, <9 x i8>* [[AP_CAST]], align 8
+// ANDROID: store <9 x i8> [[T0]], <9 x i8>* [[VAR]], align 16
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -134,6 +169,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
 // APCS-GNU: test_9c
 // APCS-GNU: call double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
+// ANDROID: test_9c
+// ANDROID: call double (i32, ...) 

Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-02 Thread Stephen Hines via cfe-commits
srhines updated this revision to Diff 41654.
srhines added a comment.

Switched to isPowerOf2_32() and added more details about Android's ABI.


http://reviews.llvm.org/D14639

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arm-abi-vector.c

Index: test/CodeGen/arm-abi-vector.c
===
--- test/CodeGen/arm-abi-vector.c
+++ test/CodeGen/arm-abi-vector.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi aapcs -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi apcs-gnu -emit-llvm -o - %s | FileCheck -check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -emit-llvm -o - %s | FileCheck -check-prefix=ANDROID %s
 
 #include 
 
@@ -28,6 +29,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <2 x i32>*
 // APCS-GNU: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 4
 // APCS-GNU: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
+// ANDROID: varargs_vec_2i
+// ANDROID: [[VAR:%.*]] = alloca <2 x i32>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <2 x i32>*
+// ANDROID: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 8
+// ANDROID: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -42,6 +51,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
 // APCS-GNU: test_2i
 // APCS-GNU: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
+// ANDROID: test_2i
+// ANDROID: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
   return varargs_vec_2i(3, *in);
 }
 
@@ -54,6 +65,10 @@
 // APCS-GNU: alloca <3 x i8>, align 4
 // APCS-GNU: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
 // APCS-GNU: bitcast i8* [[AP]] to <3 x i8>*
+// ANDROID: varargs_vec_3c
+// ANDROID: alloca <3 x i8>, align 4
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
+// ANDROID: bitcast i8* [[AP]] to <3 x i8>*
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -68,6 +83,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_3c(i32 3, i32 {{%.*}})
 // APCS-GNU: test_3c
 // APCS-GNU: call double (i32, ...) @varargs_vec_3c(i32 3, i32 {{%.*}})
+// ANDROID: test_3c
+// ANDROID: call double (i32, ...) @varargs_vec_3c(i32 3, <3 x i8> {{%.*}})
   return varargs_vec_3c(3, *in);
 }
 
@@ -87,6 +104,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <5 x i8>*
 // APCS-GNU: [[VEC:%.*]] = load <5 x i8>, <5 x i8>* [[AP_CAST]], align 4
 // APCS-GNU: store <5 x i8> [[VEC]], <5 x i8>* [[VAR]], align 8
+// ANDROID: varargs_vec_5c
+// ANDROID: [[VAR:%.*]] = alloca <5 x i8>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <5 x i8>*
+// ANDROID: [[VEC:%.*]] = load <5 x i8>, <5 x i8>* [[AP_CAST]], align 8
+// ANDROID: store <5 x i8> [[VEC]], <5 x i8>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -101,6 +126,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
 // APCS-GNU: test_5c
 // APCS-GNU: call double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
+// ANDROID: test_5c
+// ANDROID: call double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
   return varargs_vec_5c(5, *in);
 }
 
@@ -120,6 +147,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <9 x i8>*
 // APCS-GNU: [[VEC:%.*]] = load <9 x i8>, <9 x i8>* [[AP_CAST]], align 4
 // APCS-GNU: store <9 x i8> [[VEC]], <9 x i8>* [[VAR]], align 16
+// ANDROID: varargs_vec_9c
+// ANDROID: [[VAR:%.*]] = alloca <9 x i8>, align 16
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 16
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <9 x i8>*
+// ANDROID: [[T0:%.*]] = load <9 x i8>, <9 x i8>* [[AP_CAST]], align 8
+// ANDROID: store <9 x i8> [[T0]], <9 x i8>* [[VAR]], align 16
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -134,6 +169,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
 // APCS-GNU: test_9c
 // APCS-GNU: call double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
+// ANDROID: test_9c
+// ANDROID: call double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
   return varargs_vec_9c(9, *in);
 }
 
@@ -146,6 +183,10 @@
 // APCS-GNU: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
 

Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-02 Thread Stephen Hines via cfe-commits
srhines marked 3 inline comments as done.
srhines added a comment.

I uploaded a fixed version to use isPowerOf2_32() and more comments. Thanks for 
the reviews.


http://reviews.llvm.org/D14639



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


Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-01 Thread Stephen Hines via cfe-commits
srhines commandeered this revision.
srhines added a reviewer: ADodds.
srhines added a comment.

Commandeering, since I am going to upload a version with the updated tests.


Repository:
  rL LLVM

http://reviews.llvm.org/D14639



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


Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-01 Thread Stephen Hines via cfe-commits
srhines added a comment.

In http://reviews.llvm.org/D14639#300077, @rnk wrote:

> Were these changes made to AOSP Clang to match upstream GCC, or some custom 
> Android version of GCC? Where would one go to find ground truth on how these 
> types should be passed?


These changes are reverting to an existing behavior before it was changed in 
r166043. This has nothing to do with GCC, and is purely related to Clang/LLVM 
as used on Android starting with the Honeycomb release in 2011. Android had 
already shipped APIs that used ARM's original ext-vector calling conventions 
(which treated them more like homogeneous aggregates). Later on, the ARM ABI 
was amended to reflect what Apple shipped in this change:

  commit 97f81573636068fb9536436188caadf030584e58
  Author: Manman Ren 
  Date:   Tue Oct 16 19:18:39 2012 +
  
  ARM ABI: passing illegal vector types as varargs.
  
  We expand varargs in clang and the call site is handled in the back end, 
it 
  is
  hard to match exactly how illegal vectors are handled in the backend. 
Theref
  ore,
  we legalize the illegal vector types in clang:
  if (Size <= 32), legalize to i32.
  if (Size == 64), legalize to v2i32.
  if (Size == 128), legalize to v4i32.
  if (Size > 128), use indirect.
  
  rdar://12439123
  
  
  git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166043 
91177308-0d34-0410-b5e6-96231b3b80d8

This basically removes the need for a local patch that Android's platform 
toolchain/NDK has (and will continue to have), while other upstream users of 
Clang continue to generate potentially broken ext-vector code if they try to 
build using their own compiler.


http://reviews.llvm.org/D14639



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


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


Re: [PATCH] D11948: Add some macros to abstract marking of parameters as not null, and use them in cstring

2015-08-13 Thread Stephen Hines via cfe-commits
I don't see anywhere in the C standard that says that a memcpy() with NULL
for either pointer is UB (which would only be valid for the case where n ==
0). This seems like a particularly aggressive (mis)optimization in the
general case. It should only be acceptable if the length is guaranteed to
be nonzero. That doesn't seem to be how the optimizers work today,
unfortunately.

Steve

On Thu, Aug 13, 2015 at 1:47 PM, Dan Albert via cfe-commits 
cfe-commits@lists.llvm.org wrote:

 Because we consider the fact that clang and gcc do this when those
 functions are not marked with nonnull by the libc to be a bug. Adding it to
 libc++ would just make another place that we have to fix that bug.

 What is the objection to using _Nullable instead of
 __attribute__(nonnull)? The original motivation in the PSA for this was for
 better ubsan diagnostics. _Nullable does that for us, and leaves the
 decision of whether null is allowed up to the libc implementers (assuming
 the compilers are fixed).
 On Aug 13, 2015 07:16, Marshall Clow mclow.li...@gmail.com wrote:

 On Wed, Aug 12, 2015 at 4:03 PM, Dan Albert danalb...@google.com wrote:

 My testing was varied. I could not get GCC or clang to optimize it away
 for Linux, but both did for ARM Android.


 Then I don't understand your objection to this change, then.

 On your platform, the effect of this change is (therefore) a compile-time
 warning when you pass (a constant) NULL to a set of functions that are
 documented to require non-null parameters.

 -- Marshall



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


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