[PATCH] D35930: [CMake] Include sancov tool in Fuchsia toolchain

2017-07-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

Repository:
  rL LLVM

https://reviews.llvm.org/D35930

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -68,6 +68,7 @@
   llvm-size
   llvm-symbolizer
   opt
+  sancov
   CACHE STRING "")
 
 set(LLVM_DISTRIBUTION_COMPONENTS


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -68,6 +68,7 @@
   llvm-size
   llvm-symbolizer
   opt
+  sancov
   CACHE STRING "")
 
 set(LLVM_DISTRIBUTION_COMPONENTS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35406: [clangd] Replace ASTUnit with manual AST management.

2017-07-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D35406#821567, @petarj wrote:

> Can you check if this change introduced clang-x86-windows-msvc2015 buildbot 
> failure 
> ?


It did. Was fixed in r308959 .


Repository:
  rL LLVM

https://reviews.llvm.org/D35406



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


[PATCH] D35678: Omit sumbodule semantics for TS modules

2017-07-26 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D35678



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


r309245 - [Coverage] NFC: Simplify sanity checks with a SpellingRange utility

2017-07-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jul 26 19:20:25 2017
New Revision: 309245

URL: http://llvm.org/viewvc/llvm-project?rev=309245&view=rev
Log:
[Coverage] NFC: Simplify sanity checks with a SpellingRange utility

This should simplify D35925.

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=309245&r1=309244&r2=309245&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Wed Jul 26 19:20:25 2017
@@ -73,6 +73,36 @@ public:
   }
 };
 
+/// Spelling locations for the start and end of a source region.
+struct SpellingRegion {
+  /// The line where the region starts.
+  unsigned LineStart;
+
+  /// The column where the region starts.
+  unsigned ColumnStart;
+
+  /// The line where the region ends.
+  unsigned LineEnd;
+
+  /// The column where the region ends.
+  unsigned ColumnEnd;
+
+  SpellingRegion(SourceManager &SM, SourceLocation LocStart,
+ SourceLocation LocEnd) {
+LineStart = SM.getSpellingLineNumber(LocStart);
+ColumnStart = SM.getSpellingColumnNumber(LocStart);
+LineEnd = SM.getSpellingLineNumber(LocEnd);
+ColumnEnd = SM.getSpellingColumnNumber(LocEnd);
+  }
+
+  /// Check if the start and end locations appear in source order, i.e
+  /// top->bottom, left->right.
+  bool isInSourceOrder() const {
+return (LineStart < LineEnd) ||
+   (LineStart == LineEnd && ColumnStart <= ColumnEnd);
+  }
+};
+
 /// \brief Provides the common functionality for the different
 /// coverage mapping region builders.
 class CoverageMappingBuilder {
@@ -241,12 +271,9 @@ public:
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  unsigned LineStart = SM.getSpellingLineNumber(LocStart);
-  unsigned ColumnStart = SM.getSpellingColumnNumber(LocStart);
-  unsigned LineEnd = SM.getSpellingLineNumber(LocEnd);
-  unsigned ColumnEnd = SM.getSpellingColumnNumber(LocEnd);
+  SpellingRegion SR{SM, LocStart, LocEnd};
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, LineStart, ColumnStart, LineEnd, ColumnEnd);
+  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the souce code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&
@@ -284,16 +311,12 @@ public:
   if (Filter.count(std::make_pair(LocStart, LocEnd)))
 continue;
 
-  // Find the spilling locations for the mapping region.
-  unsigned LineStart = SM.getSpellingLineNumber(LocStart);
-  unsigned ColumnStart = SM.getSpellingColumnNumber(LocStart);
-  unsigned LineEnd = SM.getSpellingLineNumber(LocEnd);
-  unsigned ColumnEnd = SM.getSpellingColumnNumber(LocEnd);
-
-  assert(LineStart <= LineEnd && "region start and end out of order");
+  // Find the spelling locations for the mapping region.
+  SpellingRegion SR{SM, LocStart, LocEnd};
+  assert(SR.isInSourceOrder() && "region start and end out of order");
   MappingRegions.push_back(CounterMappingRegion::makeRegion(
-  Region.getCounter(), *CovFileID, LineStart, ColumnStart, LineEnd,
-  ColumnEnd));
+  Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart,
+  SR.LineEnd, SR.ColumnEnd));
 }
   }
 
@@ -317,14 +340,11 @@ public:
  "region spans multiple files");
   Filter.insert(std::make_pair(ParentLoc, LocEnd));
 
-  unsigned LineStart = SM.getSpellingLineNumber(ParentLoc);
-  unsigned ColumnStart = SM.getSpellingColumnNumber(ParentLoc);
-  unsigned LineEnd = SM.getSpellingLineNumber(LocEnd);
-  unsigned ColumnEnd = SM.getSpellingColumnNumber(LocEnd);
-
+  SpellingRegion SR{SM, ParentLoc, LocEnd};
+  assert(SR.isInSourceOrder() && "region start and end out of order");
   MappingRegions.push_back(CounterMappingRegion::makeExpansion(
-  *ParentFileID, *ExpandedFileID, LineStart, ColumnStart, LineEnd,
-  ColumnEnd));
+  *ParentFileID, *ExpandedFileID, SR.LineStart, SR.ColumnStart,
+  SR.LineEnd, SR.ColumnEnd));
 }
 return Filter;
   }


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


r309244 - [Coverage] NFC: Save a pair of calls to get{Start,End}

2017-07-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jul 26 19:20:20 2017
New Revision: 309244

URL: http://llvm.org/viewvc/llvm-project?rev=309244&view=rev
Log:
[Coverage] NFC: Save a pair of calls to get{Start,End}

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=309244&r1=309243&r2=309244&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Wed Jul 26 19:20:20 2017
@@ -481,15 +481,17 @@ struct CounterCoverageMappingBuilder
 
   /// \brief Propagate counts through the children of \c S.
   Counter propagateCounts(Counter TopCount, const Stmt *S) {
-size_t Index = pushRegion(TopCount, getStart(S), getEnd(S));
+SourceLocation StartLoc = getStart(S);
+SourceLocation EndLoc = getEnd(S);
+size_t Index = pushRegion(TopCount, StartLoc, EndLoc);
 Visit(S);
 Counter ExitCount = getRegion().getCounter();
 popRegions(Index);
 
 // The statement may be spanned by an expansion. Make sure we handle a file
 // exit out of this expansion before moving to the next statement.
-if (SM.isBeforeInTranslationUnit(getStart(S), S->getLocStart()))
-  MostRecentLocation = getEnd(S);
+if (SM.isBeforeInTranslationUnit(StartLoc, S->getLocStart()))
+  MostRecentLocation = EndLoc;
 
 return ExitCount;
   }


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


[PATCH] D35925: [Coverage] Precise region termination with deferred regions

2017-07-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

The current coverage implementation doesn't handle region termination
very precisely. Take for example an `if' statement with a `return':

  void f() {
if (true) {
  return; // The `if' body's region is terminated here.
}
// This line gets the same coverage as the `if' condition.
  }

If the function `f' is called, the line containing the comment will be
marked as having executed once, which is not correct.

The solution here is to create a deferred region after terminating a
region. The deferred region is completed once the start location of the
next statement is known, and is then pushed onto the region stack.
In the cases where it's not possible to complete a deferred region, it
can safely be dropped.

Example output (pre-patch): F3800158: deferred-regions-before.txt 

Example output (post-patch): F3800159: deferred-regions-after.txt 


Testing: lit test updates, a stage2 coverage-enabled build of clang


https://reviews.llvm.org/D35925

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/deferred-region.cpp
  test/CoverageMapping/label.cpp
  test/CoverageMapping/moremacros.c
  test/CoverageMapping/return.c
  test/CoverageMapping/switch.cpp
  test/CoverageMapping/switchmacro.c
  test/CoverageMapping/trycatch.cpp

Index: test/CoverageMapping/trycatch.cpp
===
--- test/CoverageMapping/trycatch.cpp
+++ test/CoverageMapping/trycatch.cpp
@@ -18,7 +18,7 @@
   // CHECK-NEXT: File 0, [[@LINE+1]]:10 -> [[@LINE+2]]:27 = (#0 - #1)
   } else if(i == 8)   // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:19 = (#0 - #1)
 throw ImportantError();   // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:27 = #2
-}
+} // CHECK-NEXT: File 0, [[@LINE-1]]:27 -> [[@LINE]]:2 = ((#0 - #1) - #2)
 
   // CHECK-NEXT: main
 int main() {  // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+13]]:2 = #0
Index: test/CoverageMapping/switchmacro.c
===
--- test/CoverageMapping/switchmacro.c
+++ test/CoverageMapping/switchmacro.c
@@ -8,6 +8,7 @@
   default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
 if (i == 1)  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
   return 0;  // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
+ // CHECK-NEXT: File 0, [[@LINE-1]]:15 -> [[@LINE+3]]:5 = (#2 - #3)
 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:5 -> [[@LINE+2]]:8 = (#2 - #3) (Expanded file = 1)
 // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> {{[0-9]+}}:11 = (#2 - #3)
 FOO(1);
Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -6,7 +6,7 @@
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
-break;
+break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
@@ -55,16 +55,16 @@
 i = 2;
 break;
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
-break;
+break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
 i = 1;
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
 i = 2;
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = (#7 + #8)
-break;
+break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+3]]:3 = #5
   }
 
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #5
Index: test/CoverageMapping/return.c
===
--- test/CoverageMapping/return.c
+++ test/CoverageMapping/return.c
@@ -13,7 +13,7 @@
   for(int i = 0; i < 10; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:31 -> {{[0-9]+}}:4 = #1
 // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:13 = #1
 if(i > 2) { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+2]]:6 = #2
-  return;
+  return;   // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+3]]:5 = (#1 - #2)
 }   // CHECK-NEXT: File 0, [[@LINE+2]]:5 -> {{[0-9]+}}:4 = (#1 - #2)
 // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:14 = (#1 - #2)
 if(i == 3) {// CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE+2

[PATCH] D34114: [clang] Change the condition of unnecessary packed warning

2017-07-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 108401.
yawanng added a comment.

Add more tests.


https://reviews.llvm.org/D34114

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/CodeGenCXX/warn-padded-packed.cpp

Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
   char a,b,c,d;
 } __attribute__((packed));
 
 
-struct S11 {
+struct S11 { // expected-warning {{packed attribute is unnecessary for 'S11'}}
   bool x;
   char a,b,c,d;
 } __attribute__((packed));
@@ -72,5 +72,38 @@
   bool b : 10;
 };
 
+struct S14 { // expected-warning {{packed attribute is unnecessary for 'S14'}}
+  char a,b,c,d;
+} __attribute__((packed));
+
+struct S15 { // expected-warning {{packed attribute is unnecessary for 'S15'}}
+  struct S14 s;
+  char a;
+} __attribute__((packed));
+
+struct S16 { // expected-warning {{padding size of 'S16' with 2 bytes to alignment boundar}} expected-warning {{packed attribute is unnecessary for 'S16'}}
+  char a,b;
+} __attribute__((packed, aligned(4)));
+
+struct S17 {
+  struct S16 s;
+  char a,b;
+} __attribute__((packed, aligned(2)));
+
+struct S18 { // expected-warning {{padding size of 'S18' with 2 bytes to alignment boundar}} expected-warning {{packed attribute is unnecessary for 'S18'}}
+  struct S16 s;
+  char a,b;
+} __attribute__((packed, aligned(4)));
+
+struct S19 { // expected-warning {{packed attribute is unnecessary for 'S19'}}
+  bool b;
+  char a;
+} __attribute__((packed, aligned(1)));
+
+struct S20 {
+  int i;
+  char a;
+} __attribute__((packed, aligned(1)));
+
 // The warnings are emitted when the layout of the structs is computed, so we have to use them.
-void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*) { }
+void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*, S14*, S15*, S16*, S17*, S18*, S19*, S20*){}
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1882,10 +1882,9 @@
   << (InBits ? 1 : 0); // (byte|bit)
 }
 
-// Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-// bother since there won't be alignment issues.
-if (Packed && UnpackedAlignment > CharUnits::One() && 
-getSize() == UnpackedSize)
+// Warn if we packed it unnecessarily, when the unpacked alignment is not
+// greater than the one after packing.
+if (Packed && UnpackedAlignment <= Alignment)
   Diag(D->getLocation(), diag::warn_unnecessary_packed)
   << Context.getTypeDeclType(RD);
   }
@@ -1978,12 +1977,6 @@
   << PadSize
   << (InBits ? 1 : 0); // (byte|bit)
   }
-
-  // Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-  // bother since there won't be alignment issues.
-  if (isPacked && UnpackedAlign > CharBitNum && Offset == UnpackedOffset)
-Diag(D->getLocation(), diag::warn_unnecessary_packed)
-<< D->getIdentifier();
 }
 
 static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33900: Print registered targets in clang's version information

2017-07-26 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D33900#820281, @hans wrote:

> In https://reviews.llvm.org/D33900#818968, @mehdi_amini wrote:
>
> > I think @thakis is right: this too verbose to be the default --version.
> >  We likely shouldn't ship this in clang-5.0 (@hans).
>
>
> Let me know if you figure out a solution here and I'll merge it.


I looped you in because the easy short term answer is: that we take our time to 
figure what to do in trunk but in the meantime we just revert from the release 
branch.


https://reviews.llvm.org/D33900



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


Add associateTargetInfo API

2017-07-26 Thread David Gosselin via cfe-commits
Add associateTargetInfo API

Consolidates duplicate logic behind a convenience API on the
CompilerInstance class both to set the target and return whether the target
was set successfully.
Index: include/clang/Frontend/CompilerInstance.h
===
--- include/clang/Frontend/CompilerInstance.h	(revision 308857)
+++ include/clang/Frontend/CompilerInstance.h	(working copy)
@@ -800,6 +800,8 @@
 
   void setExternalSemaSource(IntrusiveRefCntPtr ESS);
 
+  bool associateTargetInfo();
+
   MemoryBufferCache &getPCMCache() const { return *PCMCache; }
 };
 
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp	(revision 308857)
+++ lib/Frontend/ASTUnit.cpp	(working copy)
@@ -1038,9 +1038,7 @@
   Clang->setDiagnostics(&getDiagnostics());
   
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->associateTargetInfo())
 return true;
 
   // Inform the target of the language options.
@@ -1467,9 +1465,7 @@
   Clang->setDiagnostics(&AST->getDiagnostics());
   
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->associateTargetInfo())
 return nullptr;
 
   // Inform the target of the language options.
@@ -2085,9 +2081,7 @@
   ProcessWarningOptions(Diag, Inv.getDiagnosticOpts());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget()) {
+  if (!Clang->associateTargetInfo()) {
 Clang->setInvocation(nullptr);
 return;
   }
Index: lib/Frontend/ChainedIncludesSource.cpp
===
--- lib/Frontend/ChainedIncludesSource.cpp	(revision 308857)
+++ lib/Frontend/ChainedIncludesSource.cpp	(working copy)
@@ -149,8 +149,7 @@
 new CompilerInstance(CI.getPCHContainerOperations()));
 Clang->setInvocation(std::move(CInvok));
 Clang->setDiagnostics(Diags.get());
-Clang->setTarget(TargetInfo::CreateTargetInfo(
-Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
+Clang->associateTargetInfo();
 Clang->createFileManager();
 Clang->createSourceManager(Clang->getFileManager());
 Clang->createPreprocessor(TU_Prefix);
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp	(revision 308857)
+++ lib/Frontend/CompilerInstance.cpp	(working copy)
@@ -931,9 +931,7 @@
   raw_ostream &OS = llvm::errs();
 
   // Create the target instance.
-  setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(),
- getInvocation().TargetOpts));
-  if (!hasTarget())
+  if (!associateTargetInfo())
 return false;
 
   // Create TargetInfo for the other side of CUDA and OpenMP compilation.
@@ -2056,3 +2054,10 @@
 IntrusiveRefCntPtr ESS) {
   ExternalSemaSrc = std::move(ESS);
 }
+
+bool CompilerInstance::associateTargetInfo()
+{
+  setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(),
+ getInvocation().TargetOpts));
+  return hasTarget();
+}
Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp	(revision 308857)
+++ lib/Frontend/PrecompiledPreamble.cpp	(working copy)
@@ -247,9 +247,7 @@
   Clang->setDiagnostics(&Diagnostics);
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->associateTargetInfo())
 return BuildPreambleError::CouldntCreateTargetInfo;
 
   // Inform the target of the language options.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34114: [clang] Change the condition of unnecessary packed warning

2017-07-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 108397.

https://reviews.llvm.org/D34114

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/CodeGenCXX/warn-padded-packed.cpp


Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
   char a,b,c,d;
 } __attribute__((packed));
 
 
-struct S11 {
+struct S11 { // expected-warning {{packed attribute is unnecessary for 'S11'}}
   bool x;
   char a,b,c,d;
 } __attribute__((packed));
@@ -72,5 +72,28 @@
   bool b : 10;
 };
 
+struct S14 { // expected-warning {{packed attribute is unnecessary for 'S14'}}
+  char a,b,c,d;
+} __attribute__((packed));
+
+struct S15 { // expected-warning {{packed attribute is unnecessary for 'S15'}}
+  struct S14 s;
+  char a;
+} __attribute__((packed));
+
+struct S16 { // expected-warning {{padding size of 'S16' with 2 bytes to 
alignment boundar}} expected-warning {{packed attribute is unnecessary for 
'S16'}}
+  char a,b;
+} __attribute__((packed, aligned(4)));
+
+struct S17 {
+  struct S16 s;
+  char a,b;
+} __attribute__((packed, aligned(2)));
+
+struct S18 { // expected-warning {{padding size of 'S18' with 2 bytes to 
alignment boundar}} expected-warning {{packed attribute is unnecessary for 
'S18'}}
+  struct S16 s;
+  char a,b;
+} __attribute__((packed, aligned(4)));
+
 // The warnings are emitted when the layout of the structs is computed, so we 
have to use them.
-void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*) { }
+void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*, 
S14*, S15*, S16*, S17*, S18*) { }
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1882,10 +1882,9 @@
   << (InBits ? 1 : 0); // (byte|bit)
 }
 
-// Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-// bother since there won't be alignment issues.
-if (Packed && UnpackedAlignment > CharUnits::One() && 
-getSize() == UnpackedSize)
+// Warn if we packed it unnecessarily, when the unpacked alignment is not
+// greater than the one after packing.
+if (Packed && UnpackedAlignment <= Alignment)
   Diag(D->getLocation(), diag::warn_unnecessary_packed)
   << Context.getTypeDeclType(RD);
   }
@@ -1978,12 +1977,6 @@
   << PadSize
   << (InBits ? 1 : 0); // (byte|bit)
   }
-
-  // Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-  // bother since there won't be alignment issues.
-  if (isPacked && UnpackedAlign > CharBitNum && Offset == UnpackedOffset)
-Diag(D->getLocation(), diag::warn_unnecessary_packed)
-<< D->getIdentifier();
 }
 
 static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,


Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
   char a,b,c,d;
 } __attribute__((packed));
 
 
-struct S11 {
+struct S11 { // expected-warning {{packed attribute is unnecessary for 'S11'}}
   bool x;
   char a,b,c,d;
 } __attribute__((packed));
@@ -72,5 +72,28 @@
   bool b : 10;
 };
 
+struct S14 { // expected-warning {{packed attribute is unnecessary for 'S14'}}
+  char a,b,c,d;
+} __attribute__((p

[PATCH] D34114: [clang] Change the condition of unnecessary packed warning

2017-07-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 108395.
yawanng edited the summary of this revision.
yawanng added a comment.

Including cases '__attribute__((packed, aligned(X)));'. When the alignment 
before packing is less or equal to the packed one, he 'packed' attribute not 
including 'aligned(X)' seems unnecessary.  Because the alignment won't change 
as well as the size after removing 'packed'.


https://reviews.llvm.org/D34114

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/CodeGenCXX/warn-padded-packed.cpp


Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
   char a,b,c,d;
 } __attribute__((packed));
 
 
-struct S11 {
+struct S11 { // expected-warning {{packed attribute is unnecessary for 'S11'}}
   bool x;
   char a,b,c,d;
 } __attribute__((packed));
@@ -72,5 +72,28 @@
   bool b : 10;
 };
 
+struct S14 { // expected-warning {{packed attribute is unnecessary for 'S14'}}
+  char a,b,c,d;
+} __attribute__((packed));
+
+struct S15 { // expected-warning {{packed attribute is unnecessary for 'S15'}}
+  struct S14 s;
+  char a;
+} __attribute__((packed));
+
+struct S16 { // expected-warning {{padding size of 'S16' with 2 bytes to 
alignment boundar}} expected-warning {{packed attribute is unnecessary for 
'S16'}}
+  char a,b;
+} __attribute__((packed, aligned(4)));
+
+struct S17 {
+  struct S16 s;
+  char a,b;
+} __attribute__((packed, aligned(2)));
+
+struct S18 { // expected-warning {{padding size of 'S18' with 2 bytes to 
alignment boundar}} expected-warning {{packed attribute is unnecessary for 
'S18'}}
+  struct S16 s;
+  char a,b;
+} __attribute__((packed, aligned(4)));
+
 // The warnings are emitted when the layout of the structs is computed, so we 
have to use them.
-void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*) { }
+void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*, 
S14*, S15*, S16*, S17*, S18*) { }
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1882,10 +1882,9 @@
   << (InBits ? 1 : 0); // (byte|bit)
 }
 
-// Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-// bother since there won't be alignment issues.
-if (Packed && UnpackedAlignment > CharUnits::One() && 
-getSize() == UnpackedSize)
+// Warn if we packed it unnecessarily, when the unpacked alignment is not
+// greater than the one after packing.
+if (Packed && UnpackedAlignment <= Alignment || )
   Diag(D->getLocation(), diag::warn_unnecessary_packed)
   << Context.getTypeDeclType(RD);
   }
@@ -1978,12 +1977,6 @@
   << PadSize
   << (InBits ? 1 : 0); // (byte|bit)
   }
-
-  // Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-  // bother since there won't be alignment issues.
-  if (isPacked && UnpackedAlign > CharBitNum && Offset == UnpackedOffset)
-Diag(D->getLocation(), diag::warn_unnecessary_packed)
-<< D->getIdentifier();
 }
 
 static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,


Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
  

[PATCH] D35577: Add -flookup-tables and -fno-lookup-tables flags

2017-07-26 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa added a comment.

I am waiting for others to approve/review the decision.


https://reviews.llvm.org/D35577



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


[PATCH] D35923: Fix PR32332 - PCM nondeterminism with builtins caused by global module index

2017-07-26 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

I am *very* concerned about this. The optimization that avoids doing lookups 
within module files where we "know" we won't find anything was very important 
at the time it was introduced, so I'd like to understand better why it didn't 
make a significant difference in your benchmarks before we disable it. 
(Especially because of built-ins; those are Very Weird and probably modeled 
wrong).


https://reviews.llvm.org/D35923



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


[PATCH] D34114: [clang] Change the condition of unnecessary packed warning

2017-07-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng added inline comments.



Comment at: lib/AST/RecordLayoutBuilder.cpp:1888
-if (Packed && UnpackedAlignment > CharUnits::One() && 
-getSize() == UnpackedSize)
   Diag(D->getLocation(), diag::warn_unnecessary_packed)

chh wrote:
> Why not keeping the (getSize() == UnpackedSize) condition?
> 
It seems to me that when the alignment is 1 byte, the size won't change.


https://reviews.llvm.org/D34114



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


Re: r309189 - Clang and LLVM search for different versions of libxml2, reset found

2017-07-26 Thread NAKAMURA Takumi via cfe-commits
Seems clang.git stuck to r309145. LLVM.ORG's git-svn doesn't fetch r309155.

At the moment, I made llvm-project.git suspended. It will be rebased later.

On Thu, Jul 27, 2017 at 8:13 AM Reid Kleckner  wrote:

> This commit hasn't been imported to
> https://github.com/llvm-project/llvm-project-20170507. Do we need to do
> anything to make sure it gets picked up eventually? I wonder if there are
> more "missing commits" like this. Have we seen divergence between SVN and
> the prototype git monorepo in the past?
>
> On Wed, Jul 26, 2017 at 2:47 PM, Eric Beckmann via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ecbeckmann
>> Date: Wed Jul 26 14:47:17 2017
>> New Revision: 309189
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309189&view=rev
>> Log:
>> Clang and LLVM search for different versions of libxml2, reset found
>> variable before each search so that they don't conflict.
>>
>> Modified:
>> cfe/trunk/CMakeLists.txt
>>
>> Modified: cfe/trunk/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=309189&r1=309188&r2=309189&view=diff
>>
>> ==
>> --- cfe/trunk/CMakeLists.txt (original)
>> +++ cfe/trunk/CMakeLists.txt Wed Jul 26 14:47:17 2017
>> @@ -181,6 +181,7 @@ endif()
>>  # we can include cmake files from this directory.
>>  list(APPEND CMAKE_MODULE_PATH
>> "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
>>
>> +set (LIBXML2_FOUND 0)
>>  find_package(LibXml2 2.5.3 QUIET)
>>  if (LIBXML2_FOUND)
>>set(CLANG_HAVE_LIBXML 1)
>>
>>
>> ___
>> 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


[PATCH] D34114: [clang] Change the condition of unnecessary packed warning

2017-07-26 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added inline comments.



Comment at: lib/AST/RecordLayoutBuilder.cpp:1888
-if (Packed && UnpackedAlignment > CharUnits::One() && 
-getSize() == UnpackedSize)
   Diag(D->getLocation(), diag::warn_unnecessary_packed)

Why not keeping the (getSize() == UnpackedSize) condition?



https://reviews.llvm.org/D34114



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


[PATCH] D35903: [x86][inline-asm]Allow a pack of Control Regs to be properly picked

2017-07-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D35903



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


Re: r309189 - Clang and LLVM search for different versions of libxml2, reset found

2017-07-26 Thread Reid Kleckner via cfe-commits
This commit hasn't been imported to
https://github.com/llvm-project/llvm-project-20170507. Do we need to do
anything to make sure it gets picked up eventually? I wonder if there are
more "missing commits" like this. Have we seen divergence between SVN and
the prototype git monorepo in the past?

On Wed, Jul 26, 2017 at 2:47 PM, Eric Beckmann via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ecbeckmann
> Date: Wed Jul 26 14:47:17 2017
> New Revision: 309189
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309189&view=rev
> Log:
> Clang and LLVM search for different versions of libxml2, reset found
> variable before each search so that they don't conflict.
>
> Modified:
> cfe/trunk/CMakeLists.txt
>
> Modified: cfe/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.
> txt?rev=309189&r1=309188&r2=309189&view=diff
> 
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Wed Jul 26 14:47:17 2017
> @@ -181,6 +181,7 @@ endif()
>  # we can include cmake files from this directory.
>  list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/
> cmake/modules")
>
> +set (LIBXML2_FOUND 0)
>  find_package(LibXml2 2.5.3 QUIET)
>  if (LIBXML2_FOUND)
>set(CLANG_HAVE_LIBXML 1)
>
>
> ___
> 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


[PATCH] D34114: [clang] A better format for unnecessary packed warning.

2017-07-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng added a comment.

In https://reviews.llvm.org/D34114#800253, @rsmith wrote:

> Some concrete suggestions throughout the patch, but I think we should take a 
> step back and reconsider this warning approach: it seems bizarre for us to 
> warn on any packed struct that happens to contain a `char`. It would make 
> sense to warn if an `__attribute__((packed))` written in the source has *no* 
> effect (because it's applied to a struct where all fields already have 
> alignment 1, or because it's applied to a field that has alignment 1) -- even 
> then I'm not entirely convinced this is a valuable warning, but I assume 
> there's some reason you want to warn on it :)


Yes. I think the only case for this warning to be useful is when the alignment 
of the class or struct is 1 byte :-)


https://reviews.llvm.org/D34114



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


[PATCH] D34114: [clang] A better format for unnecessary packed warning.

2017-07-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 108380.
yawanng edited the summary of this revision.
yawanng added a comment.

Change the condition of this unnecessary packed warning to when the alignment 
of the class is one byte. Remove all field-level warning.


https://reviews.llvm.org/D34114

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/CodeGenCXX/warn-padded-packed.cpp


Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
   char a,b,c,d;
 } __attribute__((packed));
 
 
-struct S11 {
+struct S11 { // expected-warning {{packed attribute is unnecessary for 'S11'}}
   bool x;
   char a,b,c,d;
 } __attribute__((packed));
@@ -72,5 +72,14 @@
   bool b : 10;
 };
 
+struct S14 { // expected-warning {{packed attribute is unnecessary for 'S14'}}
+  char a,b,c,d;
+} __attribute__((packed));
+
+struct S15 { // expected-warning {{packed attribute is unnecessary for 'S15'}}
+  struct S14 s;
+  char a;
+} __attribute__((packed));
+
 // The warnings are emitted when the layout of the structs is computed, so we 
have to use them.
-void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*) { }
+void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*, 
S14*, S15*) { }
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1882,10 +1882,8 @@
   << (InBits ? 1 : 0); // (byte|bit)
 }
 
-// Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-// bother since there won't be alignment issues.
-if (Packed && UnpackedAlignment > CharUnits::One() && 
-getSize() == UnpackedSize)
+// Warn if we packed it unnecessarily, when the alignment is 1 byte 
already.
+if (Packed && UnpackedAlignment == CharUnits::One())
   Diag(D->getLocation(), diag::warn_unnecessary_packed)
   << Context.getTypeDeclType(RD);
   }
@@ -1978,12 +1976,6 @@
   << PadSize
   << (InBits ? 1 : 0); // (byte|bit)
   }
-
-  // Warn if we packed it unnecessarily. If the alignment is 1 byte don't
-  // bother since there won't be alignment issues.
-  if (isPacked && UnpackedAlign > CharBitNum && Offset == UnpackedOffset)
-Diag(D->getLocation(), diag::warn_unnecessary_packed)
-<< D->getIdentifier();
 }
 
 static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,


Index: test/CodeGenCXX/warn-padded-packed.cpp
===
--- test/CodeGenCXX/warn-padded-packed.cpp
+++ test/CodeGenCXX/warn-padded-packed.cpp
@@ -17,7 +17,7 @@
 } __attribute__((packed));
 
 struct S4 {
-  int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+  int i;
   char c;
 } __attribute__((packed));
 
@@ -46,18 +46,18 @@
   int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
 };
 
-struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
-  int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+struct S9 {
+  int x;
+  int y;
 } __attribute__((packed));
 
-struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
-  int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+struct S10 {
+  int x;
   char a,b,c,d;
 } __attribute__((packed));
 
 
-struct S11 {
+struct S11 { // expected-warning {{packed attribute is unnecessary for 'S11'}}
   bool x;
   char a,b,c,d;
 } __attribute__((packed));
@@ -72,5 +72,14 @@
   bool b : 10;
 };
 
+struct S14 { // expected-warning {{packed attribute is unnecessary for 'S14'}}
+  char a,b,c,d;
+} __attribute__((packed));
+
+struct S15 { // expected-warning {{packed attribute is unnecessary for 'S15'}}
+  struct S14 s;
+  char a;
+} __attribute__((packed));
+
 // The warnings are emitted when the layout of the structs is computed, so we have to use them.
-void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*) { }
+void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*

r309226 - Headers: improve ARM EHABI coverage of unwind.h

2017-07-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Jul 26 15:55:23 2017
New Revision: 309226

URL: http://llvm.org/viewvc/llvm-project?rev=309226&view=rev
Log:
Headers: improve ARM EHABI coverage of unwind.h

Ensure that we define the `_Unwind_Control_Block` structure used on ARM
EHABI targets.  This is needed for building libc++abi with the unwind.h
from the resource dir.  A minor fallout of this is that we needed to
create a typedef for _Unwind_Exception to work across ARM EHABI and
non-EHABI targets.  The structure definitions here are based originally
on the documentation from ARM under the "Exception Handling ABI for the
ARM® Architecture" Section 7.2.  They are then adjusted to more closely
reflect the definition in libunwind from LLVM.  Those changes are
compatible in layout but permit easier use in libc++abi and help
maintain compatibility between libunwind and the compiler provided
definition.

Modified:
cfe/trunk/lib/Headers/unwind.h

Modified: cfe/trunk/lib/Headers/unwind.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/unwind.h?rev=309226&r1=309225&r2=309226&view=diff
==
--- cfe/trunk/lib/Headers/unwind.h (original)
+++ cfe/trunk/lib/Headers/unwind.h Wed Jul 26 15:55:23 2017
@@ -76,7 +76,13 @@ typedef intptr_t _sleb128_t;
 typedef uintptr_t _uleb128_t;
 
 struct _Unwind_Context;
+#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || 
defined(__ARM_DWARF_EH___))
+struct _Unwind_Control_Block;
+typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
+#else
 struct _Unwind_Exception;
+typedef struct _Unwind_Exception _Unwind_Exception;
+#endif
 typedef enum {
   _URC_NO_REASON = 0,
 #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
@@ -109,8 +115,42 @@ typedef enum {
 } _Unwind_Action;
 
 typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code,
- struct _Unwind_Exception *);
+ _Unwind_Exception *);
 
+#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || 
defined(__ARM_DWARF_EH___))
+typedef struct _Unwind_Control_Block _Unwind_Control_Block;
+typedef uint32_t _Unwind_EHT_Header;
+
+struct _Unwind_Control_Block {
+  uint64_t exception_class;
+  void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
+  /* unwinder cache (private fields for the unwinder's use) */
+  struct {
+uint32_t reserved1; /* forced unwind stop function, 0 if not forced */
+uint32_t reserved2; /* personality routine */
+uint32_t reserved3; /* callsite */
+uint32_t reserved4; /* forced unwind stop argument */
+uint32_t reserved5;
+  } unwinder_cache;
+  /* propagation barrier cache (valid after phase 1) */
+  struct {
+uint32_t sp;
+uint32_t bitpattern[5];
+  } barrier_cache;
+  /* cleanup cache (preserved over cleanup) */
+  struct {
+uint32_t bitpattern[4];
+  } cleanup_cache;
+  /* personality cache (for personality's benefit) */
+  struct {
+uint32_t fnstart; /* function start address */
+_Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
+uint32_t additional;  /* additional data */
+uint32_t reserved1;
+  } pr_cache;
+  long long int : 0; /* force alignment of next item to 8-byte boundary */
+};
+#else
 struct _Unwind_Exception {
   _Unwind_Exception_Class exception_class;
   _Unwind_Exception_Cleanup_Fn exception_cleanup;
@@ -120,16 +160,18 @@ struct _Unwind_Exception {
* aligned".  GCC has interpreted this to mean "use the maximum useful
* alignment for the target"; so do we. */
 } __attribute__((__aligned__));
+#endif
 
 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action,
_Unwind_Exception_Class,
-   struct _Unwind_Exception *,
+   _Unwind_Exception *,
struct _Unwind_Context *,
void *);
 
-typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
-int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
-struct _Unwind_Context *);
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(int, _Unwind_Action,
+  _Unwind_Exception_Class,
+  _Unwind_Exception *,
+  struct _Unwind_Context 
*);
 typedef _Unwind_Personality_Fn __personality_routine;
 
 typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *,
@@ -224,13 +266,12 @@ _Unwind_Ptr _Unwind_GetRegionStart(struc
 
 /* DWARF EH functions; currently not available on Darwin/ARM */
 #if !defined(__APPLE__) || !defined(__arm__)
-
-_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *);
-_Unwind_Reason_Code _Unwind_

[PATCH] D35923: Fix PR32332 - PCM nondeterminism with builtins caused by global module index

2017-07-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.

Long story short: I think that it is too dangerous to rely on the global module 
index for anything but diagnostics.

The global module index is only rebuilt in two cases:

  a. When triggered by Sema for diagnosing errors
  b. At the very end of FrontendAction::Execute() 

This patch is deleting a shortcut in ModuleManager::visit() that uses the 
global module index as a negative cache to determine that it does not make 
sense to open a module when looking for a specific identifier.

In the test case (see also the PR https://bugs.llvm.org/show_bug.cgi?id=32332)  
we get different PCM output for B.pcm when

1. building B.pcm (which also builds the dependency A.pcm in one go)
2. building A.pcm, then building B.pcm in a separate clang invocation

Because of when the global module index is built, (1) does not use the above 
shortcut, but (2) does. The symbol were this makes a difference is a built-in 
macro __FLT_EPSILON__ which does not belong to any module but still makes it 
into the global module index as not being defined in any module. This causes 
the symbol to be serialized in (1) A.pcm and (2) A.pcm and B.pcm.

I have considered the alternative of hunting down why builtins are serialized 
into the PCM in the first place, but frankly I feel like this is just the tip 
of the iceberg, and that relying on the global module index this way is just 
asking for trouble in concurrent or incremental builds. I have looked at the 
performance impact of the change, and in the project I built (a large project, 
~30min build time) the wall-clock numbers were in the noise.

rdar://problem/31122421


https://reviews.llvm.org/D35923

Files:
  lib/Serialization/ModuleManager.cpp
  test/Modules/Inputs/builtins/a.h
  test/Modules/Inputs/builtins/b.h
  test/Modules/Inputs/builtins/module.modulemap
  test/Modules/builtins-incremental.m


Index: test/Modules/builtins-incremental.m
===
--- /dev/null
+++ test/Modules/builtins-incremental.m
@@ -0,0 +1,28 @@
+// RUN: rm -rf %T/cache %T/cache1 %T/cache2 
+//
+// Build B which imports A.
+// RUN: %clang_cc1 -cc1 -fsyntax-only -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%T/cache -fdisable-module-hash \
+// RUN:   -I %S/Inputs/builtins %s
+// RUN: mv %T/cache %T/cache1
+//
+// Build only A.
+// RUN: echo '@import A;' >%t.m
+// RUN: %clang_cc1 -cc1 -fsyntax-only -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%T/cache -fdisable-module-hash \
+// RUN:   -I %S/Inputs/builtins %t.m
+//
+// Incrementally build B which imports A.
+// RUN: %clang_cc1 -cc1 -fsyntax-only -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%T/cache -fdisable-module-hash \
+// RUN:   -I %S/Inputs/builtins %s
+// RUN: mv %T/cache %T/cache2
+//
+// RUN: llvm-bcanalyzer %T/cache1/B.pcm >%t.dump
+// RUN: llvm-bcanalyzer %T/cache2/B.pcm >>%t.dump
+// RUN: cat %t.dump | FileCheck %s
+
+// Verify the identifier table has the same size in both versions of B.pcm:
+// CHECK:  1 [[INDENT_SIZE:[0-9]+]] 100.00 IDENTIFIER_TABLE
+// CHECK:  1 [[INDENT_SIZE]] 100.00 IDENTIFIER_TABLE
+@import B;
Index: test/Modules/Inputs/builtins/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/builtins/module.modulemap
@@ -0,0 +1,7 @@
+module A {
+  header "a.h"
+}
+
+module B {
+  header "b.h"
+}
Index: test/Modules/Inputs/builtins/b.h
===
--- /dev/null
+++ test/Modules/Inputs/builtins/b.h
@@ -0,0 +1,3 @@
+#include "a.h"
+@interface B : A
+@end
Index: test/Modules/Inputs/builtins/a.h
===
--- /dev/null
+++ test/Modules/Inputs/builtins/a.h
@@ -0,0 +1,3 @@
+#include 
+@interface A
+@end
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -363,19 +363,6 @@
 
   VisitState *State = allocateVisitState();
   unsigned VisitNumber = State->NextVisitNumber++;
-
-  // If the caller has provided us with a hit-set that came from the global
-  // module index, mark every module file in common with the global module
-  // index that is *not* in that set as 'visited'.
-  if (ModuleFilesHit && !ModulesInCommonWithGlobalIndex.empty()) {
-for (unsigned I = 0, N = ModulesInCommonWithGlobalIndex.size(); I != N; 
++I)
-{
-  ModuleFile *M = ModulesInCommonWithGlobalIndex[I];
-  if (!ModuleFilesHit->count(M))
-State->VisitNumber[M->Index] = VisitNumber;
-}
-  }
-
   for (unsigned I = 0, N = VisitOrder.size(); I != N; ++I) {
 ModuleFile *CurrentModule = VisitOrder[I];
 // Should we skip this module file?


Index: test/Modules/builtins-incremental.m
===
--- /dev/null
+++ test/Mod

[PATCH] D35922: [Driver] Enable AddressSanitizer for Fuchsia targets

2017-07-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: cmake/caches/Fuchsia-stage2.cmake:50
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 endforeach()

I think we also need:
```
set(RUNTIMES_${target}-fuchsia_SANITIZER_CXX_ABI "libcxxabi" ON CACHE STRING "")
```




Repository:
  rL LLVM

https://reviews.llvm.org/D35922



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


[libunwind] r309224 - Creating release candidate rc1 from release_500 branch

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 15:39:02 2017
New Revision: 309224

URL: http://llvm.org/viewvc/llvm-project?rev=309224&view=rev
Log:
Creating release candidate rc1 from release_500 branch

Added:
libunwind/tags/RELEASE_500/rc1/   (props changed)
  - copied from r309223, libunwind/branches/release_50/

Propchange: libunwind/tags/RELEASE_500/rc1/
--
svn:mergeinfo = /libunwind/trunk:308871,309147


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


[libunwind] r309223 - Creating release directory for release_500.

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 15:39:01 2017
New Revision: 309223

URL: http://llvm.org/viewvc/llvm-project?rev=309223&view=rev
Log:
Creating release directory for release_500.

Added:
libunwind/tags/RELEASE_500/

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


[libcxxabi] r309211 - Creating release directory for release_500.

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 15:38:53 2017
New Revision: 309211

URL: http://llvm.org/viewvc/llvm-project?rev=309211&view=rev
Log:
Creating release directory for release_500.

Added:
libcxxabi/tags/RELEASE_500/

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


[libcxxabi] r309212 - Creating release candidate rc1 from release_500 branch

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 15:38:54 2017
New Revision: 309212

URL: http://llvm.org/viewvc/llvm-project?rev=309212&view=rev
Log:
Creating release candidate rc1 from release_500 branch

Added:
libcxxabi/tags/RELEASE_500/rc1/
  - copied from r309211, libcxxabi/branches/release_50/

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


[libcxx] r309210 - Creating release candidate rc1 from release_500 branch

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 15:38:53 2017
New Revision: 309210

URL: http://llvm.org/viewvc/llvm-project?rev=309210&view=rev
Log:
Creating release candidate rc1 from release_500 branch

Added:
libcxx/tags/RELEASE_500/rc1/   (props changed)
  - copied from r309209, libcxx/branches/release_50/

Propchange: libcxx/tags/RELEASE_500/rc1/
--
svn:mergeinfo = /libcxx/branches/apple:136569-137939


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


[libcxx] r309209 - Creating release directory for release_500.

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 15:38:50 2017
New Revision: 309209

URL: http://llvm.org/viewvc/llvm-project?rev=309209&view=rev
Log:
Creating release directory for release_500.

Added:
libcxx/tags/RELEASE_500/

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


[PATCH] D35922: [Driver] Enable AddressSanitizer for Fuchsia targets

2017-07-26 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.
mcgrathr added a project: Sanitizers.
Herald added subscribers: mgorny, srhines.

Repository:
  rL LLVM

https://reviews.llvm.org/D35922

Files:
  cmake/caches/Fuchsia-stage2.cmake
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/Fuchsia.cpp


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -14,6 +14,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
 
@@ -68,22 +69,21 @@
   else
 CmdArgs.push_back("--build-id");
 
-  if (!Args.hasArg(options::OPT_static))
-CmdArgs.push_back("--eh-frame-hdr");
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-Bstatic");
   else if (Args.hasArg(options::OPT_shared))
 CmdArgs.push_back("-shared");
 
-  if (!Args.hasArg(options::OPT_static)) {
-if (Args.hasArg(options::OPT_rdynamic))
-  CmdArgs.push_back("-export-dynamic");
-
-if (!Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-dynamic-linker");
-  CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "ld.so.1"));
-}
+  if (!Args.hasArg(options::OPT_shared)) {
+std::string Dyld = D.DyldPrefix;
+if (ToolChain.getSanitizerArgs().needsAsanRt() &&
+ToolChain.getSanitizerArgs().needsSharedAsanRt())
+  Dyld += "asan/";
+Dyld += "ld.so.1";
+CmdArgs.push_back("-dynamic-linker");
+CmdArgs.push_back(Args.MakeArgString(Dyld));
   }
 
   CmdArgs.push_back("-o");
@@ -100,6 +100,8 @@
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -284,5 +286,6 @@
 SanitizerMask Fuchsia::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
+  Res |= SanitizerKind::Address;
   return Res;
 }
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -561,8 +561,9 @@
 
   if (AllAddedKinds & Address) {
 AsanSharedRuntime =
-Args.hasArg(options::OPT_shared_libasan) || TC.getTriple().isAndroid();
-NeedPIE |= TC.getTriple().isAndroid();
+Args.hasArg(options::OPT_shared_libasan) ||
+TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia();
+NeedPIE |= TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia();
 if (Arg *A =
 Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
 StringRef S = A->getValue();
@@ -596,7 +597,7 @@
 // globals in ASan is disabled by default on ELF targets.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
 AsanGlobalsDeadStripping =
-!TC.getTriple().isOSBinFormatELF() ||
+!TC.getTriple().isOSBinFormatELF() || TC.getTriple().isOSFuchsia() ||
 Args.hasArg(options::OPT_fsanitize_address_globals_dead_stripping);
   } else {
 AsanUseAfterScope = false;
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -47,6 +47,7 @@
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 endforeach()
 
 # Setup toolchain.


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -14,6 +14,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
 
@@ -68,22 +69,21 @@
   else
 CmdArgs.push_back("--build-id");
 
-  if (!Args.hasArg(options::OPT_static))
-CmdArgs.push_back("--eh-frame-hdr");
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-Bstatic");
   else if (Args.hasArg(options::OPT_shared))
 CmdArgs.push_back("-shared");
 
-  if (!Args.hasArg(options::OPT_static)) {
-if (Args.hasArg(options::OPT_rdynamic))
-  CmdArgs.push_back("-export-dynamic");
-
-if (!Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-dynamic-linker");
-  CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "ld.so.1"));
-}
+  if (!A

[PATCH] D34748: [clang-diff] improve mapping accuracy

2017-07-26 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 108370.
johannes retitled this revision from "[clang-diff] improve mapping accuracy, 
HTML side-by-side diff." to "[clang-diff] improve mapping accuracy".

https://reviews.llvm.org/D34748

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-basic.cpp
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -24,15 +25,13 @@
 static cl::OptionCategory ClangDiffCategory("clang-diff options");
 
 static cl::opt
-DumpAST("ast-dump",
+ASTDump("ast-dump",
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
-static cl::opt NoCompilationDatabase(
-"no-compilation-database",
-cl::desc(
-"Do not attempt to load build settings from a compilation database"),
-cl::init(false), cl::cat(ClangDiffCategory));
+static cl::opt
+PrintMatches("m", cl::desc("Print the matched nodes (verbose)."),
+ cl::init(false), cl::cat(ClangDiffCategory));
 
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
@@ -43,12 +42,69 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
+static cl::opt NoCompilationDatabase(
+"no-compilation-database",
+cl::desc(
+"Do not attempt to load build settings from a compilation database"),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt BuildPath("p", cl::desc("Build path"), cl::Optional,
+  cl::cat(ClangDiffCategory));
+
+static cl::list ArgsAfter(
+"extra-arg",
+cl::desc("Additional argument to append to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static cl::list ArgsBefore(
+"extra-arg-before",
+cl::desc("Additional argument to prepend to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+namespace {
+class ArgumentsAdjustingCompilations : public CompilationDatabase {
+public:
+  ArgumentsAdjustingCompilations(
+  std::unique_ptr Compilations)
+  : Compilations(std::move(Compilations)) {}
+
+  void appendArgumentsAdjuster(ArgumentsAdjuster Adjuster) {
+Adjusters.push_back(std::move(Adjuster));
+  }
+
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
+return adjustCommands(Compilations->getCompileCommands(FilePath));
+  }
+
+  std::vector getAllFiles() const override {
+return Compilations->getAllFiles();
+  }
+
+  std::vector getAllCompileCommands() const override {
+return adjustCommands(Compilations->getAllCompileCommands());
+  }
+
+private:
+  std::unique_ptr Compilations;
+  std::vector Adjusters;
+
+  std::vector
+  adjustCommands(std::vector Commands) const {
+for (CompileCommand &Command : Commands)
+  for (const auto &Adjuster : Adjusters)
+Command.CommandLine = Adjuster(Command.CommandLine, Command.Filename);
+return Commands;
+  }
+};
+} // end anonymous namespace
+
 static std::unique_ptr getAST(const StringRef Filename) {
   std::string ErrorMessage;
   std::unique_ptr Compilations;
   if (!NoCompilationDatabase)
-Compilations =
-CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
+Compilations = CompilationDatabase::autoDetectFromSource(
+BuildPath.empty() ? Filename : BuildPath, ErrorMessage);
   if (!Compilations) {
 if (!NoCompilationDatabase)
   llvm::errs()
@@ -58,6 +114,14 @@
 Compilations = llvm::make_unique(
 ".", std::vector());
   }
+  auto AdjustingCompilations =
+  llvm::make_unique(
+  std::move(Compilations));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsBefore, ArgumentInsertPosition::BEGIN));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsAfter, ArgumentInsertPosition::END));
+  Compilations = std::move(AdjustingCompilations);
   std::array Files = {{Filename}};
   ClangTool Tool(*Compilations, Files);
   std::vector> ASTs;
@@ -67,23 +131,143 @@
   return std::move(ASTs[0]);
 }
 
+static char hexdigit(int N) { return N &= 0xf, N + (N < 10 ? '0' : 'a' - 10); }
+
+static void printJsonString(raw_ostream &OS, const StringRef Str) {
+  for (char C : Str) {
+switch (C) {
+case '"':
+  OS << R"(\")";
+  break

[PATCH] D34801: [coverage] Make smaller regions for the first case of a switch.

2017-07-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Hi Eli, are you waiting on something before landing this?


Repository:
  rL LLVM

https://reviews.llvm.org/D34801



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


r309195 - Add branch weights to branches for static initializers.

2017-07-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jul 26 15:01:09 2017
New Revision: 309195

URL: http://llvm.org/viewvc/llvm-project?rev=309195&view=rev
Log:
Add branch weights to branches for static initializers.

The initializer for a static local variable cannot be hot, because it runs at
most once per program. That's not quite the same thing as having a low branch
probability, but under the assumption that the function is invoked many times,
modeling this as a branch probability seems reasonable.

For TLS variables, the situation is less clear, since the initialization side
of the branch can run multiple times in a program execution, but we still
expect initialization to be rare relative to non-initialization uses. It would
seem worthwhile to add a PGO counter along this path to make this estimation
more accurate in future.

For globals with guarded initialization, we don't yet apply any branch weights.
Due to our use of COMDATs, the guard will be reached exactly once per DSO, but
we have no idea how many DSOs will define the variable.

Added:
cfe/trunk/test/CodeGenCXX/static-initializer-branch-weights.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=309195&r1=309194&r2=309195&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Jul 26 15:01:09 2017
@@ -18,6 +18,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang;
@@ -259,6 +260,43 @@ void CodeGenFunction::EmitCXXGuardedInit
   CGM.getCXXABI().EmitGuardedInit(*this, D, DeclPtr, PerformInit);
 }
 
+void CodeGenFunction::EmitCXXGuardedInitBranch(llvm::Value *NeedsInit,
+   llvm::BasicBlock *InitBlock,
+   llvm::BasicBlock *NoInitBlock,
+   GuardKind Kind,
+   const VarDecl *D) {
+  assert((Kind == GuardKind::TlsGuard || D) && "no guarded variable");
+
+  // A guess at how many times we will enter the initialization of a
+  // variable, depending on the kind of variable.
+  static const uint64_t InitsPerTLSVar = 1024;
+  static const uint64_t InitsPerLocalVar = 1024 * 1024;
+
+  llvm::MDNode *Weights;
+  if (Kind == GuardKind::VariableGuard && !D->isLocalVarDecl()) {
+// For non-local variables, don't apply any weighting for now. Due to our
+// use of COMDATs, we expect there to be at most one initialization of the
+// variable per DSO, but we have no way to know how many DSOs will try to
+// initialize the variable.
+Weights = nullptr;
+  } else {
+uint64_t NumInits;
+// FIXME: For the TLS case, collect and use profiling information to
+// determine a more accurate brach weight.
+if (Kind == GuardKind::TlsGuard || D->getTLSKind())
+  NumInits = InitsPerTLSVar;
+else
+  NumInits = InitsPerLocalVar;
+
+// The probability of us entering the initializer is
+//   1 / (total number of times we attempt to initialize the variable).
+llvm::MDBuilder MDHelper(CGM.getLLVMContext());
+Weights = MDHelper.createBranchWeights(1, NumInits - 1);
+  }
+
+  Builder.CreateCondBr(NeedsInit, InitBlock, NoInitBlock, Weights);
+}
+
 llvm::Function *CodeGenModule::CreateGlobalInitOrDestructFunction(
 llvm::FunctionType *FTy, const Twine &Name, const CGFunctionInfo &FI,
 SourceLocation Loc, bool TLS) {
@@ -539,7 +577,8 @@ CodeGenFunction::GenerateCXXGlobalInitFu
  "guard.uninitialized");
   llvm::BasicBlock *InitBlock = createBasicBlock("init");
   ExitBlock = createBasicBlock("exit");
-  Builder.CreateCondBr(Uninit, InitBlock, ExitBlock);
+  EmitCXXGuardedInitBranch(Uninit, InitBlock, ExitBlock,
+   GuardKind::TlsGuard, nullptr);
   EmitBlock(InitBlock);
   // Mark as initialized before initializing anything else. If the
   // initializers use previously-initialized thread_local vars, that's

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=309195&r1=309194&r2=309195&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGen

r309193 - Convert mac file format to unix

2017-07-26 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Wed Jul 26 14:59:45 2017
New Revision: 309193

URL: http://llvm.org/viewvc/llvm-project?rev=309193&view=rev
Log:
Convert mac file format to unix

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

Modified:
cfe/trunk/include/clang/Lex/VariadicMacroSupport.h

Modified: cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/VariadicMacroSupport.h?rev=309193&r1=309192&r2=309193&view=diff
==
--- cfe/trunk/include/clang/Lex/VariadicMacroSupport.h (original)
+++ cfe/trunk/include/clang/Lex/VariadicMacroSupport.h Wed Jul 26 14:59:45 2017
@@ -1,56 +1,56 @@
-//===- VariadicMacroSupport.h - scope-guards etc. -*- C++ 
-*---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines support types to help with preprocessing variadic macro 
-// (i.e. macros that use: ellipses __VA_ARGS__ ) definitions and 
-// expansions.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_LEX_VARIADICMACROSUPPORT_H
-#define LLVM_CLANG_LEX_VARIADICMACROSUPPORT_H
-
-#include "clang/Lex/Preprocessor.h"
-
-namespace clang {
-
-/// An RAII class that tracks when the Preprocessor starts and stops lexing the
-/// definition of a (ISO C/C++) variadic macro.  As an example, this is useful
-/// for unpoisoning and repoisoning certain identifiers (such as __VA_ARGS__)
-/// that are only allowed in this context.  Also, being a friend of the
-/// Preprocessor class allows it to access PP's cached identifiers directly (as
-/// opposed to performing a lookup each time).
-class VariadicMacroScopeGuard {
-  const Preprocessor &PP;
-  IdentifierInfo &Ident__VA_ARGS__;
-
-public:
-  VariadicMacroScopeGuard(const Preprocessor &P)
-  : PP(P), Ident__VA_ARGS__(*PP.Ident__VA_ARGS__) {
-assert(Ident__VA_ARGS__.isPoisoned() && "__VA_ARGS__ should be poisoned "
-"outside an ISO C/C++ variadic "
-"macro definition!");
-  }
-
-  /// Client code should call this function just before the Preprocessor is
-  /// about to Lex tokens from the definition of a variadic (ISO C/C++) macro.
-  void enterScope() { Ident__VA_ARGS__.setIsPoisoned(false); }
-
-  /// Client code should call this function as soon as the Preprocessor has
-  /// either completed lexing the macro's definition tokens, or an error 
occured
-  /// and the context is being exited.  This function is idempotent (might be
-  /// explicitly called, and then reinvoked via the destructor).
-  void exitScope() { Ident__VA_ARGS__.setIsPoisoned(true); }
-  
-  ~VariadicMacroScopeGuard() { exitScope(); }
-};
-
-}  // end namespace clang
-
-#endif
+//===- VariadicMacroSupport.h - scope-guards etc. -*- C++ 
-*---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines support types to help with preprocessing variadic macro
+// (i.e. macros that use: ellipses __VA_ARGS__ ) definitions and
+// expansions.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LEX_VARIADICMACROSUPPORT_H
+#define LLVM_CLANG_LEX_VARIADICMACROSUPPORT_H
+
+#include "clang/Lex/Preprocessor.h"
+
+namespace clang {
+
+/// An RAII class that tracks when the Preprocessor starts and stops lexing the
+/// definition of a (ISO C/C++) variadic macro.  As an example, this is useful
+/// for unpoisoning and repoisoning certain identifiers (such as __VA_ARGS__)
+/// that are only allowed in this context.  Also, being a friend of the
+/// Preprocessor class allows it to access PP's cached identifiers directly (as
+/// opposed to performing a lookup each time).
+class VariadicMacroScopeGuard {
+  const Preprocessor &PP;
+  IdentifierInfo &Ident__VA_ARGS__;
+
+public:
+  VariadicMacroScopeGuard(const Preprocessor &P)
+  : PP(P), Ident__VA_ARGS__(*PP.Ident__VA_ARGS__) {
+assert(Ident__VA_ARGS__.isPoisoned() && "__VA_ARGS__ should be poisoned "
+"outside an ISO C/C++ variadic "
+"macro definition!");
+  }
+
+  /// Client code should call this function just before the Preprocessor is
+  /// about to Lex tokens from the definition of a variadic (ISO C/C++) macro.
+  void enterScope() { Ident__VA_ARGS__.setIsPoisoned(false); }
+
+  /// Client code should call this function as soon as the Preproces

r309189 - Clang and LLVM search for different versions of libxml2, reset found

2017-07-26 Thread Eric Beckmann via cfe-commits
Author: ecbeckmann
Date: Wed Jul 26 14:47:17 2017
New Revision: 309189

URL: http://llvm.org/viewvc/llvm-project?rev=309189&view=rev
Log:
Clang and LLVM search for different versions of libxml2, reset found
variable before each search so that they don't conflict.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=309189&r1=309188&r2=309189&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Jul 26 14:47:17 2017
@@ -181,6 +181,7 @@ endif()
 # we can include cmake files from this directory.
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
+set (LIBXML2_FOUND 0)
 find_package(LibXml2 2.5.3 QUIET)
 if (LIBXML2_FOUND)
   set(CLANG_HAVE_LIBXML 1)


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


Re: r309106 - Recommit r308327 2nd time: Add a warning for missing

2017-07-26 Thread Hans Wennborg via cfe-commits
On Wed, Jul 26, 2017 at 11:27 AM, Hans Wennborg  wrote:
> On Wed, Jul 26, 2017 at 5:20 AM, Alex Lorenz via cfe-commits
>  wrote:
>> Author: arphaman
>> Date: Wed Jul 26 05:20:57 2017
>> New Revision: 309106
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309106&view=rev
>> Log:
>> Recommit r308327 2nd time: Add a warning for missing
>> '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included files
>>
>> The first recommit (r308441) caused a "non-default #pragma pack value might
>> change the alignment of struct or union members in the included file" warning
>> in LLVM itself. This recommit tweaks the added warning to avoid warnings for
>> #includes that don't have any records that are affected by the non-default
>> alignment. This tweak avoids the previously emitted warning in LLVM.
>>
>> Original message:
>>
>> This commit adds a new -Wpragma-pack warning. It warns in the following 
>> cases:
>>
>> - When a translation unit is missing terminating #pragma pack (pop) 
>> directives.
>> - When entering an included file if the current alignment value as determined
>>   by '#pragma pack' directives is different from the default alignment value.
>> - When leaving an included file that changed the state of the current 
>> alignment
>>   value.
>>
>> rdar://10184173
>>
>> Differential Revision: https://reviews.llvm.org/D35484
>
> We have code in Chromium that does exactly this:
>
> gles2_cmd_format.h does #pragma pack(push, 4) and then #includes a
> file with some generated structs, with the intention that the pragma
> applies to them.
>
> What's the best way to pacify the warning in this case?
>
> (We're tracking this in
> https://bugs.chromium.org/p/chromium/issues/detail?id=749197)

I agree that cases 1) and 3) from your patch description make sense to
warn for, but I'm not sure that's the case for 2). Do you have
examples where this catches any bugs? In our case #pragma packing an
included file is intentional, and I suspect it might be a bit of a
pattern.

Wouldn't cases 1) and 3) catch most situations where this happens
unintentionally? E.g. when one #includes a file that forgets to
#pragma pop, and then includes a new file afterwards?

I've reverted in r309186 in the meantime.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-07-26 Thread Simon Dardis via Phabricator via cfe-commits
sdardis created this revision.
Herald added a subscriber: arichardson.

This option when combined with -mgpopt and -membedded-data places all
uninitialized constant variables in the read-only section.


https://reviews.llvm.org/D35917

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/mips-uninit-const-in-ro.c

Index: test/CodeGen/mips-uninit-const-in-ro.c
===
--- /dev/null
+++ test/CodeGen/mips-uninit-const-in-ro.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple mips-mti--elf -emit-llvm -mrelocation-model static \
+// RUN:-target-feature +noabicalls -mllvm -mgpopt -mllvm \
+// RUN:-membedded-data=1 -muninit-const-in-rodata -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that -muninit-const-in-rodata places constant uninitialized structures
+// in the .rodata section rather than the commeon section.
+
+// CHECK: @a = global [8 x i32] zeroinitializer, section "rodata", align 4
+const int a[8];
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -949,6 +949,8 @@
 
   Opts.Backchain = Args.hasArg(OPT_mbackchain);
 
+  Opts.UInitCstDataInROData = Args.hasArg(OPT_muninit_const_in_rodata);
+
   Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
   Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1515,6 +1515,14 @@
 CmdArgs.push_back("-membedded-data=0");
   }
   EmbeddedData->claim();
+
+  if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata,
+   options::OPT_mno_uninit_const_in_rodata)) {
+if (A->getOption().matches(options::OPT_muninit_const_in_rodata)) {
+  CmdArgs.push_back("-muninit-const-in-rodata");
+  A->claim();
+}
+  }
 }
 
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6659,6 +6659,20 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM,
ForDefinition_t IsForDefinition) const override {
+
+if (const VarDecl *VD = dyn_cast_or_null(D)) {
+  if (CGM.getCodeGenOpts().UInitCstDataInROData &&
+  VD->getType().isConstQualified() && !VD->hasInit()) {
+llvm::GlobalVariable *GVar = dyn_cast_or_null(GV);
+if (GVar && !GVar->hasSection()) {
+  GVar->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  GVar->setSection("rodata");
+}
+  }
+
+  return;
+}
+
 const FunctionDecl *FD = dyn_cast_or_null(D);
 if (!FD) return;
 llvm::Function *Fn = cast(GV);
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -101,6 +101,8 @@
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled.
 CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is enabled.
+CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data
+   ///< & -muinit-const-in-rodata is set
 CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2057,6 +2057,14 @@
 def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
   HelpText<"Do not place constants in the .rodata section instead of the "
".sdata if they meet the -G  threshold (MIPS)">;
+def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">,
+  Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place "
+  "uninitialized constants in the read-only data section instead of"
+  " the common section (MIPS)">;
+def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">,
+  Group, HelpText<"Do not Place uninitialized constants in the "
+   "read-only data section instead of the common"
+   " section (MIPS)">;

r309186 - Revert r309106 "Recommit r308327 2nd time: Add a warning for missing"

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 14:29:24 2017
New Revision: 309186

URL: http://llvm.org/viewvc/llvm-project?rev=309186&view=rev
Log:
Revert r309106 "Recommit r308327 2nd time: Add a warning for missing"

The warning fires on non-suspicious code in Chromium. Reverting until a
solution is figured out.

> Recommit r308327 2nd time: Add a warning for missing
> '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included files
>
> The first recommit (r308441) caused a "non-default #pragma pack value might
> change the alignment of struct or union members in the included file" warning
> in LLVM itself. This recommit tweaks the added warning to avoid warnings for
> #includes that don't have any records that are affected by the non-default
> alignment. This tweak avoids the previously emitted warning in LLVM.
>
> Original message:
>
> This commit adds a new -Wpragma-pack warning. It warns in the following cases:
>
> - When a translation unit is missing terminating #pragma pack (pop) 
> directives.
> - When entering an included file if the current alignment value as determined
>   by '#pragma pack' directives is different from the default alignment value.
> - When leaving an included file that changed the state of the current 
> alignment
>   value.
>
> rdar://10184173
>
> Differential Revision: https://reviews.llvm.org/D35484

Removed:
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/Inputs/pragma-pack1.h
cfe/trunk/test/Sema/Inputs/pragma-pack2.h
cfe/trunk/test/Sema/suspicious-pragma-pack.c
cfe/trunk/test/SemaObjC/Inputs/empty.h
cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/PCH/pragma-pack.c
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-options.cpp
cfe/trunk/test/Parser/pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=309186&r1=309185&r2=309186&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 26 14:29:24 2017
@@ -471,9 +471,8 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
-def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute, PragmaPack]>;
+PragmaClangAttribute]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=309186&r1=309185&r2=309186&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 26 14:29:24 
2017
@@ -712,16 +712,6 @@ def err_pragma_options_align_mac68k_targ
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;
-def warn_pragma_pack_non_default_at_include : Warning<
-  "non-default #pragma pack value changes the alignment of struct or union "
-  "members in the included file">, InGroup;
-def warn_pragma_pack_modified_after_include : Warning<
-  "the current #pragma pack aligment value is modified in the included "
-  "file">, InGroup;
-def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
-  "'#pragma pack (push, ...)' at end of file">, InGroup;
-def note_pragma_pack_here : Note<
-  "previous '#pragma pack' directive that modifies alignment is here">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=309186&r1=309185&r2=3

[PATCH] D35914: [mips] Add support -m(no-)embedded-data option

2017-07-26 Thread Simon Dardis via Phabricator via cfe-commits
sdardis created this revision.
Herald added a subscriber: arichardson.

Add support for the -membedded-data option which places constant data in
the .rodata section, rather than the .sdata section.


https://reviews.llvm.org/D35914

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mips-features.c


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -65,6 +65,21 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s
 // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata"
 //
+// -mno-abicalls -mgpopt -membedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 
-mno-embedded-data -membedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s
+// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1"
+//
+// -mno-abicalls -mgpopt -mno-embedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 
-membedded-data -mno-embedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s
+// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
+// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1484,7 +1484,9 @@
 Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata,
   options::OPT_mno_local_sdata);
 Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata,
-  options::OPT_mno_extern_sdata);
+   options::OPT_mno_extern_sdata);
+Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data,
+options::OPT_mno_embedded_data);
 if (LocalSData) {
   CmdArgs.push_back("-mllvm");
   if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) {
@@ -1504,6 +1506,17 @@
   }
   ExternSData->claim();
 }
+
+if (EmbeddedData) {
+  CmdArgs.push_back("-mllvm");
+  if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) {
+CmdArgs.push_back("-membedded-data=1");
+  } else {
+CmdArgs.push_back("-membedded-data=0");
+  }
+  EmbeddedData->claim();
+}
+
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
 D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1);
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2051,6 +2051,12 @@
 def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group,
   HelpText<"Do not assume that externally defined data is in the small data if"
" it meets the -G  threshold (MIPS)">;
+def membedded_data : Flag<["-"], "membedded-data">, Group,
+  HelpText<"Place constants in the .rodata section instead of the .sdata "
+   "section even if they meet the -G  threshold (MIPS)">;
+def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
+  HelpText<"Do not place constants in the .rodata section instead of the "
+   ".sdata if they meet the -G  threshold (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -65,6 +65,21 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s
 // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata"
 //
+// -mno-abicalls -mgpopt -membedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-embedded-data -membedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s
+// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1"
+//
+// -mno-abicalls -mgpopt -mno-embedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -membedded-data -mno-embedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s
+// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
+// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
+//
 // -mips16
 // RUN: %clang -target mips-linux-

[PATCH] D35854: Fix double destruction of objects when OpenMP construct is canceled

2017-07-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D35854



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


r309155 - [OpenCL] Fix access qualifiers metadata for kernel arguments with typedef

2017-07-26 Thread via cfe-commits
Author: AlexeySotkin
Date: Wed Jul 26 11:49:54 2017
New Revision: 309155

URL: http://llvm.org/viewvc/llvm-project?rev=309155&view=rev
Log:
[OpenCL] Fix access qualifiers metadata for kernel arguments with typedef

Subscribers: cfe-commits, yaxunl, Anastasia

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


Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=309155&r1=309154&r2=309155&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Jul 26 11:49:54 2017
@@ -620,7 +620,10 @@ static void GenOpenCLArgMetadata(const F
 
 // Get image and pipe access qualifier:
 if (ty->isImageType()|| ty->isPipeType()) {
-  const OpenCLAccessAttr *A = parm->getAttr();
+  const Decl *PDecl = parm;
+  if (auto *TD = dyn_cast(ty))
+PDecl = TD->getDecl();
+  const OpenCLAccessAttr *A = PDecl->getAttr();
   if (A && A->isWriteOnly())
 accessQuals.push_back(llvm::MDString::get(Context, "write_only"));
   else if (A && A->isReadWrite())

Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl?rev=309155&r1=309154&r2=309155&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Wed Jul 26 11:49:54 2017
@@ -78,6 +78,21 @@ kernel void foo5(myImage img1, write_onl
 typedef char char16 __attribute__((ext_vector_type(16)));
 __kernel void foo6(__global char16 arg[]) {}
 // CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
+
+typedef read_only  image1d_t ROImage;
+typedef write_only image1d_t WOImage;
+typedef read_write image1d_t RWImage;
+kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
+}
+// CHECK: define spir_kernel void @foo7{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD76:[0-9]+]]
 
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
@@ -105,4 +120,11 @@ __kernel void foo6(__global char16 arg[]
 // CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
 // ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
 // CHECK: ![[MD61]] = !{!"char16*"}
+// ARGINFO: ![[MD62]] = !{!"arg"}
+// CHECK: ![[MD71]] = !{i32 1, i32 1, i32 1}
+// CHECK: ![[MD72]] = !{!"read_only", !"write_only", !"read_write"}
+// CHECK: ![[MD73]] = !{!"ROImage", !"WOImage", !"RWImage"}
+// CHECK: ![[MD74]] = !{!"image1d_t", !"image1d_t", !"image1d_t"}
+// CHECK: ![[MD75]] = !{!"", !"", !""}
+// ARGINFO: ![[MD76]] = !{!"ro", !"wo", !"rw"}
 


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


[PATCH] D35420: [OpenCL] Fix access qualifiers metadata for kernel arguments with typedef

2017-07-26 Thread Alexey Sotkin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309155: [OpenCL] Fix access qualifiers metadata for kernel 
arguments with typedef (authored by AlexeySotkin).

Repository:
  rL LLVM

https://reviews.llvm.org/D35420

Files:
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl


Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -620,7 +620,10 @@
 
 // Get image and pipe access qualifier:
 if (ty->isImageType()|| ty->isPipeType()) {
-  const OpenCLAccessAttr *A = parm->getAttr();
+  const Decl *PDecl = parm;
+  if (auto *TD = dyn_cast(ty))
+PDecl = TD->getDecl();
+  const OpenCLAccessAttr *A = PDecl->getAttr();
   if (A && A->isWriteOnly())
 accessQuals.push_back(llvm::MDString::get(Context, "write_only"));
   else if (A && A->isReadWrite())
Index: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -78,6 +78,21 @@
 typedef char char16 __attribute__((ext_vector_type(16)));
 __kernel void foo6(__global char16 arg[]) {}
 // CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
+
+typedef read_only  image1d_t ROImage;
+typedef write_only image1d_t WOImage;
+typedef read_write image1d_t RWImage;
+kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
+}
+// CHECK: define spir_kernel void @foo7{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD76:[0-9]+]]
 
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
@@ -105,4 +120,11 @@
 // CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
 // ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
 // CHECK: ![[MD61]] = !{!"char16*"}
+// ARGINFO: ![[MD62]] = !{!"arg"}
+// CHECK: ![[MD71]] = !{i32 1, i32 1, i32 1}
+// CHECK: ![[MD72]] = !{!"read_only", !"write_only", !"read_write"}
+// CHECK: ![[MD73]] = !{!"ROImage", !"WOImage", !"RWImage"}
+// CHECK: ![[MD74]] = !{!"image1d_t", !"image1d_t", !"image1d_t"}
+// CHECK: ![[MD75]] = !{!"", !"", !""}
+// ARGINFO: ![[MD76]] = !{!"ro", !"wo", !"rw"}
 


Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -620,7 +620,10 @@
 
 // Get image and pipe access qualifier:
 if (ty->isImageType()|| ty->isPipeType()) {
-  const OpenCLAccessAttr *A = parm->getAttr();
+  const Decl *PDecl = parm;
+  if (auto *TD = dyn_cast(ty))
+PDecl = TD->getDecl();
+  const OpenCLAccessAttr *A = PDecl->getAttr();
   if (A && A->isWriteOnly())
 accessQuals.push_back(llvm::MDString::get(Context, "write_only"));
   else if (A && A->isReadWrite())
Index: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -78,6 +78,21 @@
 typedef char char16 __attribute__((ext_vector_type(16)));
 __kernel void foo6(__global char16 arg[]) {}
 // CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
+
+typedef read_only  image1d_t ROImage;
+typedef write_only image1d_t WOImage;
+typedef read_write image1d_t RWImage;
+kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
+}
+// CHECK: define spir_kernel void @foo7{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD76:[0-9]+]]
 
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"

[PATCH] D33719: Add _Float16 as a C/C++ source language type

2017-07-26 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Ping.

(CXX ABI change committed, doc patch created)


https://reviews.llvm.org/D33719



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


[PATCH] D35420: [OpenCL] Fix access qualifiers metadata for kernel arguments with typedef

2017-07-26 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 108334.
AlexeySotkin added a comment.

Rebasing on tip of trank


https://reviews.llvm.org/D35420

Files:
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGenOpenCL/kernel-arg-info.cl


Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -78,6 +78,21 @@
 typedef char char16 __attribute__((ext_vector_type(16)));
 __kernel void foo6(__global char16 arg[]) {}
 // CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
+
+typedef read_only  image1d_t ROImage;
+typedef write_only image1d_t WOImage;
+typedef read_write image1d_t RWImage;
+kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
+}
+// CHECK: define spir_kernel void @foo7{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD76:[0-9]+]]
 
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
@@ -105,4 +120,11 @@
 // CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
 // ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
 // CHECK: ![[MD61]] = !{!"char16*"}
+// ARGINFO: ![[MD62]] = !{!"arg"}
+// CHECK: ![[MD71]] = !{i32 1, i32 1, i32 1}
+// CHECK: ![[MD72]] = !{!"read_only", !"write_only", !"read_write"}
+// CHECK: ![[MD73]] = !{!"ROImage", !"WOImage", !"RWImage"}
+// CHECK: ![[MD74]] = !{!"image1d_t", !"image1d_t", !"image1d_t"}
+// CHECK: ![[MD75]] = !{!"", !"", !""}
+// ARGINFO: ![[MD76]] = !{!"ro", !"wo", !"rw"}
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -620,7 +620,10 @@
 
 // Get image and pipe access qualifier:
 if (ty->isImageType()|| ty->isPipeType()) {
-  const OpenCLAccessAttr *A = parm->getAttr();
+  const Decl *PDecl = parm;
+  if (auto *TD = dyn_cast(ty))
+PDecl = TD->getDecl();
+  const OpenCLAccessAttr *A = PDecl->getAttr();
   if (A && A->isWriteOnly())
 accessQuals.push_back(llvm::MDString::get(Context, "write_only"));
   else if (A && A->isReadWrite())


Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -78,6 +78,21 @@
 typedef char char16 __attribute__((ext_vector_type(16)));
 __kernel void foo6(__global char16 arg[]) {}
 // CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
+
+typedef read_only  image1d_t ROImage;
+typedef write_only image1d_t WOImage;
+typedef read_write image1d_t RWImage;
+kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
+}
+// CHECK: define spir_kernel void @foo7{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD76:[0-9]+]]
 
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
@@ -105,4 +120,11 @@
 // CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
 // ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
 // CHECK: ![[MD61]] = !{!"char16*"}
+// ARGINFO: ![[MD62]] = !{!"arg"}
+// CHECK: ![[MD71]] = !{i32 1, i32 1, i32 1}
+// CHECK: ![[MD72]] = !{!"read_only", !"write_only", !"read_write"}
+// CHECK: ![[MD73]] = !{!"ROImage", !"WOImage", !"RWImage"}
+// CHECK: ![[MD74]] = !{!"image1d_t", !"image1d_t", !"image1d_t"}
+// CHECK: ![[MD75]] = !{!"", !"", !""}
+// ARGINFO: ![[MD76]] = !{!"ro", !"wo", !"rw"}
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -620,7 +620,10 @@
 
 // Get image and pipe access qualifier:
 if (ty->isImageType()|| ty->isPipeType()) {
-  const OpenCLAccessAttr

Re: [libunwind] r309147 - Partial fix for PR33858

2017-07-26 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r309150.

On Wed, Jul 26, 2017 at 11:13 AM, Jonathan Roelofs via cfe-commits
 wrote:
> Author: jroelofs
> Date: Wed Jul 26 11:13:57 2017
> New Revision: 309147
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309147&view=rev
> Log:
> Partial fix for PR33858
>
> https://reviews.llvm.org/D35848
>
> Modified:
> libunwind/trunk/test/CMakeLists.txt
> libunwind/trunk/test/lit.site.cfg.in
>
> Modified: libunwind/trunk/test/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/CMakeLists.txt?rev=309147&r1=309146&r2=309147&view=diff
> ==
> --- libunwind/trunk/test/CMakeLists.txt (original)
> +++ libunwind/trunk/test/CMakeLists.txt Wed Jul 26 11:13:57 2017
> @@ -16,7 +16,6 @@ pythonize_bool(LIBCXX_ENABLE_SHARED)
>  pythonize_bool(LIBUNWIND_ENABLE_SHARED)
>  pythonize_bool(LIBUNWIND_ENABLE_THREADS)
>  pythonize_bool(LIBUNWIND_ENABLE_EXCEPTIONS)
> -pythonize_bool(LIBUNWIND_USE_LLVM_UNWINDER)
>  pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY)
>  set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
>  "TargetInfo to use when setting up test environment.")
>
> Modified: libunwind/trunk/test/lit.site.cfg.in
> URL: 
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/lit.site.cfg.in?rev=309147&r1=309146&r2=309147&view=diff
> ==
> --- libunwind/trunk/test/lit.site.cfg.in (original)
> +++ libunwind/trunk/test/lit.site.cfg.in Wed Jul 26 11:13:57 2017
> @@ -7,7 +7,7 @@ config.abi_library_path = "@LIBU
>  config.libcxx_src_root  = "@LIBUNWIND_LIBCXX_PATH@"
>  config.libunwind_headers= "@LIBUNWIND_SOURCE_DIR@/include"
>  config.cxx_library_root = "@LIBUNWIND_LIBCXX_LIBRARY_PATH@"
> -config.llvm_unwinder= "@LIBUNWIND_USE_LLVM_UNWINDER@"
> +config.llvm_unwinder= "1"
>  config.enable_threads   = "@LIBUNWIND_ENABLE_THREADS@"
>  config.use_sanitizer= "@LLVM_USE_SANITIZER@"
>  config.enable_32bit = "@LIBUNWIND_BUILD_32_BITS@"
>
>
> ___
> 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


[libunwind] r309150 - Merging r309147:

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 11:30:42 2017
New Revision: 309150

URL: http://llvm.org/viewvc/llvm-project?rev=309150&view=rev
Log:
Merging r309147:

r309147 | jroelofs | 2017-07-26 11:13:57 -0700 (Wed, 26 Jul 2017) | 4 lines

Partial fix for PR33858

https://reviews.llvm.org/D35848



Modified:
libunwind/branches/release_50/   (props changed)
libunwind/branches/release_50/test/CMakeLists.txt
libunwind/branches/release_50/test/lit.site.cfg.in

Propchange: libunwind/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 26 11:30:42 2017
@@ -1 +1 @@
-/libunwind/trunk:308871
+/libunwind/trunk:308871,309147

Modified: libunwind/branches/release_50/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_50/test/CMakeLists.txt?rev=309150&r1=309149&r2=309150&view=diff
==
--- libunwind/branches/release_50/test/CMakeLists.txt (original)
+++ libunwind/branches/release_50/test/CMakeLists.txt Wed Jul 26 11:30:42 2017
@@ -16,7 +16,6 @@ pythonize_bool(LIBCXX_ENABLE_SHARED)
 pythonize_bool(LIBUNWIND_ENABLE_SHARED)
 pythonize_bool(LIBUNWIND_ENABLE_THREADS)
 pythonize_bool(LIBUNWIND_ENABLE_EXCEPTIONS)
-pythonize_bool(LIBUNWIND_USE_LLVM_UNWINDER)
 pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY)
 set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")

Modified: libunwind/branches/release_50/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_50/test/lit.site.cfg.in?rev=309150&r1=309149&r2=309150&view=diff
==
--- libunwind/branches/release_50/test/lit.site.cfg.in (original)
+++ libunwind/branches/release_50/test/lit.site.cfg.in Wed Jul 26 11:30:42 2017
@@ -7,7 +7,7 @@ config.abi_library_path = "@LIBU
 config.libcxx_src_root  = "@LIBUNWIND_LIBCXX_PATH@"
 config.libunwind_headers= "@LIBUNWIND_SOURCE_DIR@/include"
 config.cxx_library_root = "@LIBUNWIND_LIBCXX_LIBRARY_PATH@"
-config.llvm_unwinder= "@LIBUNWIND_USE_LLVM_UNWINDER@"
+config.llvm_unwinder= "1"
 config.enable_threads   = "@LIBUNWIND_ENABLE_THREADS@"
 config.use_sanitizer= "@LLVM_USE_SANITIZER@"
 config.enable_32bit = "@LIBUNWIND_BUILD_32_BITS@"


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


Re: r309106 - Recommit r308327 2nd time: Add a warning for missing

2017-07-26 Thread Hans Wennborg via cfe-commits
On Wed, Jul 26, 2017 at 5:20 AM, Alex Lorenz via cfe-commits
 wrote:
> Author: arphaman
> Date: Wed Jul 26 05:20:57 2017
> New Revision: 309106
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309106&view=rev
> Log:
> Recommit r308327 2nd time: Add a warning for missing
> '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included files
>
> The first recommit (r308441) caused a "non-default #pragma pack value might
> change the alignment of struct or union members in the included file" warning
> in LLVM itself. This recommit tweaks the added warning to avoid warnings for
> #includes that don't have any records that are affected by the non-default
> alignment. This tweak avoids the previously emitted warning in LLVM.
>
> Original message:
>
> This commit adds a new -Wpragma-pack warning. It warns in the following cases:
>
> - When a translation unit is missing terminating #pragma pack (pop) 
> directives.
> - When entering an included file if the current alignment value as determined
>   by '#pragma pack' directives is different from the default alignment value.
> - When leaving an included file that changed the state of the current 
> alignment
>   value.
>
> rdar://10184173
>
> Differential Revision: https://reviews.llvm.org/D35484

We have code in Chromium that does exactly this:

gles2_cmd_format.h does #pragma pack(push, 4) and then #includes a
file with some generated structs, with the intention that the pragma
applies to them.

What's the best way to pacify the warning in this case?

(We're tracking this in
https://bugs.chromium.org/p/chromium/issues/detail?id=749197)

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


[libunwind] r309147 - Partial fix for PR33858

2017-07-26 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Wed Jul 26 11:13:57 2017
New Revision: 309147

URL: http://llvm.org/viewvc/llvm-project?rev=309147&view=rev
Log:
Partial fix for PR33858

https://reviews.llvm.org/D35848

Modified:
libunwind/trunk/test/CMakeLists.txt
libunwind/trunk/test/lit.site.cfg.in

Modified: libunwind/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/CMakeLists.txt?rev=309147&r1=309146&r2=309147&view=diff
==
--- libunwind/trunk/test/CMakeLists.txt (original)
+++ libunwind/trunk/test/CMakeLists.txt Wed Jul 26 11:13:57 2017
@@ -16,7 +16,6 @@ pythonize_bool(LIBCXX_ENABLE_SHARED)
 pythonize_bool(LIBUNWIND_ENABLE_SHARED)
 pythonize_bool(LIBUNWIND_ENABLE_THREADS)
 pythonize_bool(LIBUNWIND_ENABLE_EXCEPTIONS)
-pythonize_bool(LIBUNWIND_USE_LLVM_UNWINDER)
 pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY)
 set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")

Modified: libunwind/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/lit.site.cfg.in?rev=309147&r1=309146&r2=309147&view=diff
==
--- libunwind/trunk/test/lit.site.cfg.in (original)
+++ libunwind/trunk/test/lit.site.cfg.in Wed Jul 26 11:13:57 2017
@@ -7,7 +7,7 @@ config.abi_library_path = "@LIBU
 config.libcxx_src_root  = "@LIBUNWIND_LIBCXX_PATH@"
 config.libunwind_headers= "@LIBUNWIND_SOURCE_DIR@/include"
 config.cxx_library_root = "@LIBUNWIND_LIBCXX_LIBRARY_PATH@"
-config.llvm_unwinder= "@LIBUNWIND_USE_LLVM_UNWINDER@"
+config.llvm_unwinder= "1"
 config.enable_threads   = "@LIBUNWIND_ENABLE_THREADS@"
 config.use_sanitizer= "@LLVM_USE_SANITIZER@"
 config.enable_32bit = "@LIBUNWIND_BUILD_32_BITS@"


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


r309145 - Add bitrig removal to release notes

2017-07-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jul 26 11:04:45 2017
New Revision: 309145

URL: http://llvm.org/viewvc/llvm-project?rev=309145&view=rev
Log:
Add bitrig removal to release notes

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309145&r1=309144&r2=309145&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jul 26 11:04:45 2017
@@ -54,6 +54,12 @@ Improvements to Clang's diagnostics
 
 -  ...
 
+Non-comprehensive list of changes in this release
+-
+
+- Bitrig OS was merged back into OpenBSD, so Bitrig support has been 
+  removed from Clang/LLVM.
+
 New Compiler Flags
 --
 


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


[PATCH] D35906: Add bitrig removal to release notes

2017-07-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks!




Comment at: docs/ReleaseNotes.rst:61
+- Bitrig OS was merged back into OpenBSD, so Bitrig support has been 
+removed from Clang/LLVM.
+

I think the second row should be indented to match the first one, otherwise the 
docs system can get confused.


https://reviews.llvm.org/D35906



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


Re: [libunwind] r308871 - [libunwind] Handle .ARM.exidx tables without sentinel last entry

2017-07-26 Thread Hans Wennborg via cfe-commits
Saleem asked for this to be merged to 5.0: r309143.

On Mon, Jul 24, 2017 at 2:19 AM, Momchil Velikov via cfe-commits
 wrote:
> Author: chill
> Date: Mon Jul 24 02:19:32 2017
> New Revision: 308871
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308871&view=rev
> Log:
> [libunwind] Handle .ARM.exidx tables without sentinel last entry
>
> UnwindCursor::getInfoFromEHABISection assumes the last
> entry in the index table never corresponds to a real function.
> Indeed, GNU ld always inserts an EXIDX_CANTUNWIND entry,
> containing the end of the .text section. However, the EHABI specification
> (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf)
> does not seem to contain text that requires the presence of a sentinel entry.
> In that sense the libunwind implementation isn't compliant with the 
> specification.
>
> This patch makes getInfoFromEHABISection examine the last entry in the index
> table if upper_bound returns the end iterator.
>
> Fixes https://bugs.llvm.org/show_bug.cgi?id=31091
>
> Differential revision: https://reviews.llvm.org/D35265
>
> Modified:
> libunwind/trunk/src/UnwindCursor.hpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r309143 - Merging r308871:

2017-07-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 26 10:57:50 2017
New Revision: 309143

URL: http://llvm.org/viewvc/llvm-project?rev=309143&view=rev
Log:
Merging r308871:

r308871 | chill | 2017-07-24 02:19:32 -0700 (Mon, 24 Jul 2017) | 17 lines

[libunwind] Handle .ARM.exidx tables without sentinel last entry

UnwindCursor::getInfoFromEHABISection assumes the last
entry in the index table never corresponds to a real function.
Indeed, GNU ld always inserts an EXIDX_CANTUNWIND entry,
containing the end of the .text section. However, the EHABI specification
(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf)
does not seem to contain text that requires the presence of a sentinel entry.
In that sense the libunwind implementation isn't compliant with the 
specification.

This patch makes getInfoFromEHABISection examine the last entry in the index
table if upper_bound returns the end iterator.

Fixes https://bugs.llvm.org/show_bug.cgi?id=31091

Differential revision: https://reviews.llvm.org/D35265



Modified:
libunwind/branches/release_50/   (props changed)
libunwind/branches/release_50/src/UnwindCursor.hpp

Propchange: libunwind/branches/release_50/
--
svn:mergeinfo = /libunwind/trunk:308871

Modified: libunwind/branches/release_50/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_50/src/UnwindCursor.hpp?rev=309143&r1=309142&r2=309143&view=diff
==
--- libunwind/branches/release_50/src/UnwindCursor.hpp (original)
+++ libunwind/branches/release_50/src/UnwindCursor.hpp Wed Jul 26 10:57:50 2017
@@ -744,14 +744,21 @@ bool UnwindCursor::getInfoFromEHAB
   EHABISectionIterator::begin(_addressSpace, sects);
   EHABISectionIterator end =
   EHABISectionIterator::end(_addressSpace, sects);
+  if (begin == end)
+return false;
 
   EHABISectionIterator itNextPC = std::upper_bound(begin, end, pc);
-  if (itNextPC == begin || itNextPC == end)
+  if (itNextPC == begin)
 return false;
   EHABISectionIterator itThisPC = itNextPC - 1;
 
   pint_t thisPC = itThisPC.functionAddress();
-  pint_t nextPC = itNextPC.functionAddress();
+  // If an exception is thrown from a function, corresponding to the last entry
+  // in the table, we don't really know the function extent and have to choose 
a
+  // value for nextPC. Choosing max() will allow the range check during trace 
to
+  // succeed.
+  pint_t nextPC = (itNextPC == end) ? std::numeric_limits::max()
+: itNextPC.functionAddress();
   pint_t indexDataAddr = itThisPC.dataAddress();
 
   if (indexDataAddr == 0)


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


[PATCH] D35906: Add bitrig removal to release notes

2017-07-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

As requested, I hope I did this right.


https://reviews.llvm.org/D35906

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -54,6 +54,12 @@
 
 -  ...
 
+Non-comprehensive list of changes in this release
+-
+
+- Bitrig OS was merged back into OpenBSD, so Bitrig support has been 
+removed from Clang/LLVM.
+
 New Compiler Flags
 --
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -54,6 +54,12 @@
 
 -  ...
 
+Non-comprehensive list of changes in this release
+-
+
+- Bitrig OS was merged back into OpenBSD, so Bitrig support has been 
+removed from Clang/LLVM.
+
 New Compiler Flags
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-26 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

I've created https://reviews.llvm.org/D35904 to cover adding a test for LLVMs 
use of the runtime helper functions.


https://reviews.llvm.org/D35538



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


[PATCH] D35903: [x86][inline-asm]Allow a pack of Control Regs to be properly picked

2017-07-26 Thread coby via Phabricator via cfe-commits
coby created this revision.
Herald added a subscriber: eraman.

Allows the incorporation of legit (x86) Control Regs within inline asm 
stataements


Repository:
  rL LLVM

https://reviews.llvm.org/D35903

Files:
  lib/Basic/Targets/X86.cpp
  test/CodeGen/ms-inline-asm.c


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -58,6 +58,7 @@
 "zmm18", "zmm19", "zmm20", "zmm21", "zmm22",   "zmm23", "zmm24", "zmm25",
 "zmm26", "zmm27", "zmm28", "zmm29", "zmm30",   "zmm31", "k0","k1",
 "k2","k3","k4","k5","k6",  "k7",
+"cr0",   "cr2",   "cr3",   "cr4",   "cr8",
 };
 
 const TargetInfo::AddlRegName AddlRegNames[] = {
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -627,6 +627,17 @@
 // CHECK: call void asm sideeffect inteldialect "mov eax, $0", 
"*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
+void t44() {
+  // CHECK-LABEL: define void @t44
+  __asm {
+mov cr0, eax
+mov cr2, ebx
+mov cr3, ecx
+mov cr4, edx
+  }
+  // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, 
ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", 
"~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
__asm { mov eax, 3[ebx]A.b}


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -58,6 +58,7 @@
 "zmm18", "zmm19", "zmm20", "zmm21", "zmm22",   "zmm23", "zmm24", "zmm25",
 "zmm26", "zmm27", "zmm28", "zmm29", "zmm30",   "zmm31", "k0","k1",
 "k2","k3","k4","k5","k6",  "k7",
+"cr0",   "cr2",   "cr3",   "cr4",   "cr8",
 };
 
 const TargetInfo::AddlRegName AddlRegNames[] = {
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -627,6 +627,17 @@
 // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
+void t44() {
+  // CHECK-LABEL: define void @t44
+  __asm {
+mov cr0, eax
+mov cr2, ebx
+mov cr3, ecx
+mov cr4, edx
+  }
+  // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", "~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
 	__asm { mov eax, 3[ebx]A.b}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35746: Make new PM honor -fdebug-info-for-profiling (clang side)

2017-07-26 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh marked 2 inline comments as done.
danielcdh added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:847-859
   if (PGOOpt.RunProfileGen)
 PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
   DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
 
   // -fprofile-use.
   if (CodeGenOpts.hasProfileIRUse())
 PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;

chandlerc wrote:
> At least some of these seem mutually exclusive, so show that with `else if`?
> 
> I wonder, are all of these mutually exclusive?
-fprofile-generate, -fprofile-use and -fprofile-sample-use are mutually 
exclusive.


https://reviews.llvm.org/D35746



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


[PATCH] D35746: Make new PM honor -fdebug-info-for-profiling (clang side)

2017-07-26 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 108316.
danielcdh marked an inline comment as done.
danielcdh added a comment.

update


https://reviews.llvm.org/D35746

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -840,28 +840,29 @@
 return;
   TheModule->setDataLayout(TM->createDataLayout());
 
-  PGOOptions PGOOpt;
+  Optional PGOOpt;
 
-  // -fprofile-generate.
-  PGOOpt.RunProfileGen = CodeGenOpts.hasProfileIRInstr();
-  if (PGOOpt.RunProfileGen)
-PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
-  DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
-
-  // -fprofile-use.
-  if (CodeGenOpts.hasProfileIRUse())
-PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;
-
-  if (!CodeGenOpts.SampleProfileFile.empty())
-PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile;
+  if (CodeGenOpts.hasProfileIRInstr())
+// -fprofile-generate.
+PGOOpt = PGOOptions(CodeGenOpts.InstrProfileOutput.empty()
+? DefaultProfileGenName
+: CodeGenOpts.InstrProfileOutput,
+"", "", true, CodeGenOpts.DebugInfoForProfiling);
+  else if (CodeGenOpts.hasProfileIRUse())
+// -fprofile-use.
+PGOOpt = PGOOptions("", CodeGenOpts.ProfileInstrumentUsePath, "", false,
+CodeGenOpts.DebugInfoForProfiling);
+  else if (!CodeGenOpts.SampleProfileFile.empty())
+// -fprofile-sample-use
+PGOOpt = PGOOptions("", "", CodeGenOpts.SampleProfileFile, false,
+CodeGenOpts.DebugInfoForProfiling);
+  else if (CodeGenOpts.DebugInfoForProfiling)
+// -fdebug-info-for-profiling
+PGOOpt = PGOOptions("", "", "", false, true);
+  else
+PGOOpt = None;
 
-  // Only pass a PGO options struct if -fprofile-generate or
-  // -fprofile-use were passed on the cmdline.
-  PassBuilder PB(TM.get(),
-(PGOOpt.RunProfileGen ||
-  !PGOOpt.ProfileUseFile.empty() ||
-  !PGOOpt.SampleProfileFile.empty()) ?
-Optional(PGOOpt) : None);
+  PassBuilder PB(TM.get(), PGOOpt);
 
   LoopAnalysisManager LAM;
   FunctionAnalysisManager FAM;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -840,28 +840,29 @@
 return;
   TheModule->setDataLayout(TM->createDataLayout());
 
-  PGOOptions PGOOpt;
+  Optional PGOOpt;
 
-  // -fprofile-generate.
-  PGOOpt.RunProfileGen = CodeGenOpts.hasProfileIRInstr();
-  if (PGOOpt.RunProfileGen)
-PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
-  DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
-
-  // -fprofile-use.
-  if (CodeGenOpts.hasProfileIRUse())
-PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;
-
-  if (!CodeGenOpts.SampleProfileFile.empty())
-PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile;
+  if (CodeGenOpts.hasProfileIRInstr())
+// -fprofile-generate.
+PGOOpt = PGOOptions(CodeGenOpts.InstrProfileOutput.empty()
+? DefaultProfileGenName
+: CodeGenOpts.InstrProfileOutput,
+"", "", true, CodeGenOpts.DebugInfoForProfiling);
+  else if (CodeGenOpts.hasProfileIRUse())
+// -fprofile-use.
+PGOOpt = PGOOptions("", CodeGenOpts.ProfileInstrumentUsePath, "", false,
+CodeGenOpts.DebugInfoForProfiling);
+  else if (!CodeGenOpts.SampleProfileFile.empty())
+// -fprofile-sample-use
+PGOOpt = PGOOptions("", "", CodeGenOpts.SampleProfileFile, false,
+CodeGenOpts.DebugInfoForProfiling);
+  else if (CodeGenOpts.DebugInfoForProfiling)
+// -fdebug-info-for-profiling
+PGOOpt = PGOOptions("", "", "", false, true);
+  else
+PGOOpt = None;
 
-  // Only pass a PGO options struct if -fprofile-generate or
-  // -fprofile-use were passed on the cmdline.
-  PassBuilder PB(TM.get(),
-(PGOOpt.RunProfileGen ||
-  !PGOOpt.ProfileUseFile.empty() ||
-  !PGOOpt.SampleProfileFile.empty()) ?
-Optional(PGOOpt) : None);
+  PassBuilder PB(TM.get(), PGOOpt);
 
   LoopAnalysisManager LAM;
   FunctionAnalysisManager FAM;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Cool, i totally forgot that we have valgrind! :)


https://reviews.llvm.org/D34260



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


[PATCH] D35670: [StaticAnalyzer] Handle LoopExit CFGElement in the analyzer

2017-07-26 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 108312.
szepet added a subscriber: cfe-commits.
szepet added a comment.

Accidentally left debug print removed.


https://reviews.llvm.org/D35670

Files:
  include/clang/Analysis/ProgramPoint.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/CoreEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp

Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -364,8 +364,10 @@
 case CFGElement::TemporaryDtor:
   ProcessImplicitDtor(E.castAs(), Pred);
   return;
-case CFGElement::LifetimeEnds:
 case CFGElement::LoopExit:
+  ProcessLoopExit(E.castAs().getLoopStmt(), Pred);
+  return;
+case CFGElement::LifetimeEnds:
   return;
   }
 }
@@ -510,6 +512,21 @@
   Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
 }
 
+void ExprEngine::ProcessLoopExit(const Stmt* S, ExplodedNode *Pred) {
+  PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
+S->getLocStart(),
+"Error evaluating end of the loop");
+  ExplodedNodeSet Dst;
+  Dst.Add(Pred);
+  NodeBuilder Bldr(Pred, Dst, *currBldrCtx);
+
+  LoopExit PP(S, Pred->getLocationContext());
+  Bldr.generateNode(PP, Pred->getState(), Pred);
+
+  // Enqueue the new nodes onto the work list.
+  Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx);
+}
+
 void ExprEngine::ProcessInitializer(const CFGInitializer Init,
 ExplodedNode *Pred) {
   const CXXCtorInitializer *BMI = Init.getInitializer();
@@ -2689,6 +2706,12 @@
 Out << "Epsilon Point";
 break;
 
+  case ProgramPoint::LoopExitKind: {
+LoopExit LE = Loc.castAs();
+Out << "LoopExit: " << LE.getLoopStmt()->getStmtClassName();
+break;
+  }
+
   case ProgramPoint::PreImplicitCallKind: {
 ImplicitCallPoint PC = Loc.castAs();
 Out << "PreCall: ";
Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -274,7 +274,8 @@
   assert(Loc.getAs() ||
  Loc.getAs() ||
  Loc.getAs() ||
- Loc.getAs());
+ Loc.getAs() ||
+ Loc.getAs());
   HandlePostStmt(WU.getBlock(), WU.getIndex(), Pred);
   break;
   }
@@ -566,7 +567,8 @@
 
   // Do not create extra nodes. Move to the next CFG element.
   if (N->getLocation().getAs() ||
-  N->getLocation().getAs()) {
+  N->getLocation().getAs()||
+  N->getLocation().getAs()) {
 WList->enqueue(N, Block, Idx+1);
 return;
   }
@@ -581,6 +583,11 @@
 return;
   }
 
+  if ((*Block)[Idx].getKind() == CFGElement::LoopExit) {
+WList->enqueue(N, Block, Idx+1);
+return;
+  }
+
   // At this point, we know we're processing a normal statement.
   CFGStmt CS = (*Block)[Idx].castAs();
   PostStmt Loc(CS.getStmt(), N->getLocationContext());
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -196,6 +196,8 @@
 
   void ProcessStmt(const CFGStmt S, ExplodedNode *Pred);
 
+  void ProcessLoopExit(const Stmt* S, ExplodedNode *Pred);
+
   void ProcessInitializer(const CFGInitializer I, ExplodedNode *Pred);
 
   void ProcessImplicitDtor(const CFGImplicitDtor D, ExplodedNode *Pred);
Index: include/clang/Analysis/ProgramPoint.h
===
--- include/clang/Analysis/ProgramPoint.h
+++ include/clang/Analysis/ProgramPoint.h
@@ -83,6 +83,7 @@
   PostImplicitCallKind,
   MinImplicitCallKind = PreImplicitCallKind,
   MaxImplicitCallKind = PostImplicitCallKind,
+  LoopExitKind,
   EpsilonKind};
 
 private:
@@ -654,6 +655,23 @@
   }
 };
 
+class LoopExit : public ProgramPoint {
+public:
+LoopExit(const Stmt *LoopStmt, const LocationContext *LC)
+: ProgramPoint(LoopStmt, nullptr, LoopExitKind, LC) {}
+
+const Stmt *getLoopStmt() const {
+  return static_cast(getData1());
+}
+
+private:
+LoopExit() {}
+friend class ProgramPoint;
+static bool isKind(const ProgramPoint &Location) {
+  return Location.getKind() == LoopExitKind;
+}
+};
+
 /// This is a meta program point, which should be skipped by all the diagnostic
 /// reasoning etc.
 class EpsilonPoint : public ProgramPoint {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309058 - [CodeGen] Correctly model std::byte's aliasing properties

2017-07-26 Thread Hans Wennborg via cfe-commits
r309135. Thanks!

On Wed, Jul 26, 2017 at 9:29 AM, Richard Smith  wrote:
> I think so too :)
>
> On 26 Jul 2017 9:23 am, "Hans Wennborg via cfe-commits"
>  wrote:
>
> Yes, I think so. Richard, what say you?
>
> On Tue, Jul 25, 2017 at 4:41 PM, David Majnemer via cfe-commits
>  wrote:
>> Should this go into 5.0 ?
>>
>> On Tue, Jul 25, 2017 at 4:33 PM, David Majnemer via cfe-commits
>>  wrote:
>>>
>>> Author: majnemer
>>> Date: Tue Jul 25 16:33:58 2017
>>> New Revision: 309058
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=309058&view=rev
>>> Log:
>>> [CodeGen] Correctly model std::byte's aliasing properties
>>>
>>> std::byte, when defined as an enum, needs to be given special treatment
>>> with regards to its aliasing properties. An array of std::byte is
>>> allowed to be used as storage for other types.
>>>
>>> This fixes PR33916.
>>>
>>> Differential Revision: https://reviews.llvm.org/D35824
>>>
>>> Added:
>>> cfe/trunk/test/CodeGenCXX/std-byte.cpp
>>> Modified:
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/lib/AST/Type.cpp
>>> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
> ___
> 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: r309058 - [CodeGen] Correctly model std::byte's aliasing properties

2017-07-26 Thread Richard Smith via cfe-commits
I think so too :)

On 26 Jul 2017 9:23 am, "Hans Wennborg via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Yes, I think so. Richard, what say you?

On Tue, Jul 25, 2017 at 4:41 PM, David Majnemer via cfe-commits
 wrote:
> Should this go into 5.0 ?
>
> On Tue, Jul 25, 2017 at 4:33 PM, David Majnemer via cfe-commits
>  wrote:
>>
>> Author: majnemer
>> Date: Tue Jul 25 16:33:58 2017
>> New Revision: 309058
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309058&view=rev
>> Log:
>> [CodeGen] Correctly model std::byte's aliasing properties
>>
>> std::byte, when defined as an enum, needs to be given special treatment
>> with regards to its aliasing properties. An array of std::byte is
>> allowed to be used as storage for other types.
>>
>> This fixes PR33916.
>>
>> Differential Revision: https://reviews.llvm.org/D35824
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/std-byte.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/lib/AST/Type.cpp
>> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
___
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: r309058 - [CodeGen] Correctly model std::byte's aliasing properties

2017-07-26 Thread Hans Wennborg via cfe-commits
Yes, I think so. Richard, what say you?

On Tue, Jul 25, 2017 at 4:41 PM, David Majnemer via cfe-commits
 wrote:
> Should this go into 5.0 ?
>
> On Tue, Jul 25, 2017 at 4:33 PM, David Majnemer via cfe-commits
>  wrote:
>>
>> Author: majnemer
>> Date: Tue Jul 25 16:33:58 2017
>> New Revision: 309058
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309058&view=rev
>> Log:
>> [CodeGen] Correctly model std::byte's aliasing properties
>>
>> std::byte, when defined as an enum, needs to be given special treatment
>> with regards to its aliasing properties. An array of std::byte is
>> allowed to be used as storage for other types.
>>
>> This fixes PR33916.
>>
>> Differential Revision: https://reviews.llvm.org/D35824
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/std-byte.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/lib/AST/Type.cpp
>> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308824 - [Bash-autocompletion] Fixed typo and add '-' after -Wno

2017-07-26 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r309130.

On Sat, Jul 22, 2017 at 5:35 AM, Yuka Takahashi via cfe-commits
 wrote:
> Author: yamaguchi
> Date: Sat Jul 22 05:35:15 2017
> New Revision: 308824
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308824&view=rev
> Log:
> [Bash-autocompletion] Fixed typo and add '-' after -Wno
>
> Summary: -Wno- was autocompleted as -Wno, so fixed this 
> typo.
>
> Differential Revision: https://reviews.llvm.org/D35762
>
> Modified:
> cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> cfe/trunk/test/Driver/autocomplete.c
>
> Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=308824&r1=308823&r2=308824&view=diff
> ==
> --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
> +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Sat Jul 22 05:35:15 2017
> @@ -516,7 +516,7 @@ std::vector DiagnosticIDs::
>  std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]);
>  I += DiagGroupNames[I] + 1;
>  Res.push_back("-W" + Diag);
> -Res.push_back("-Wno" + Diag);
> +Res.push_back("-Wno-" + Diag);
>}
>
>return Res;
>
> Modified: cfe/trunk/test/Driver/autocomplete.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=308824&r1=308823&r2=308824&view=diff
> ==
> --- cfe/trunk/test/Driver/autocomplete.c (original)
> +++ cfe/trunk/test/Driver/autocomplete.c Sat Jul 22 05:35:15 2017
> @@ -42,5 +42,5 @@
>  // MRELOCMODEL_CC1: -mrelocation-model
>  // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
>  // WARNING: -Wmacro-redefined -Wmain -Wmain-return-type 
> -Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
> -// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s 
> -check-prefix=NOWARNING
> -// NOWARNING: -Wnoinvalid-pp-token
> +// RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s 
> -check-prefix=NOWARNING
> +// NOWARNING: -Wno-invalid-pp-token
>
>
> ___
> 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


[PATCH] D35894: Code hover for Clangd

2017-07-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.
arphaman added inline comments.



Comment at: clangd/Protocol.h:106
   Range range;
+  FileID unitFileID;
 

It doesn't look like it's appropriate to store a translation unit specific 
value in the `Location` which, if I'm not mistaken, is supposed to be composed 
of values that are directly present in the protocol. 

I think it would be more appropriate to teach `ClangdUnit` how to convert a URI 
to a `FileID`. Then you won't have a need for this field.


Repository:
  rL LLVM

https://reviews.llvm.org/D35894



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


[PATCH] D35894: Code hover for Clangd

2017-07-26 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added a comment.
This revision now requires changes to proceed.

Normally we put [clangd] in the title.




Comment at: clangd/ClangdLSPServer.cpp:11
 #include "ClangdLSPServer.h"
+#include "clang/Basic/SourceManager.h"
 #include "JSONRPCDispatcher.h"

I don't think this include is needed?



Comment at: clangd/ClangdLSPServer.cpp:193
 
+
   std::string Completions;

unintentional change?



Comment at: clangd/ClangdLSPServer.cpp:209
 
-  auto Items = LangServer.Server.findDefinitions(
-  Params.textDocument.uri.file,
+  auto Items = LangServer.Server.findDefinitions(Params.textDocument.uri.file,
   Position{Params.position.line, Params.position.character}).Value;

unintentional change?



Comment at: clangd/ClangdServer.cpp:20
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 

is this include needed?



Comment at: clangd/ClangdServer.cpp:26
 
+const char* const DEFAULT_SOURCE_EXTENSIONS [] = { ".cpp", ".c", ".cc", ".cxx",
+".c++", ".C", ".m", ".mm" };

those line belong to another patch?



Comment at: clangd/ClangdServer.cpp:291
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
-  Units.runOnUnit(File, *FileContents.Draft, ResourceDir, CDB, PCHs,
-  TaggedFS.Value, [&](ClangdUnit &Unit) {
-Result = Unit.findDefinitions(Pos);
-  });
+  Units.runOnUnit(
+  File, *FileContents.Draft, ResourceDir, CDB, PCHs, TaggedFS.Value,

unintentional reformat?



Comment at: clangd/ClangdServer.h:195
   /// Gets current document contents for \p File. \p File must point to a
-  /// currently tracked file.
+  /// currently tracked file
   /// FIXME(ibiryukov): This function is here to allow offset-to-Position

unintentional change?



Comment at: clangd/ClangdUnit.cpp:17
 #include "clang/Index/IndexDataConsumer.h"
+#include "clang/Index/IndexingAction.h"
 #include "clang/Lex/Lexer.h"

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:281
   DeclarationLocationsFinder(raw_ostream &OS,
-  const SourceLocation &SearchedLocation, ASTUnit &Unit) :
-  SearchedLocation(SearchedLocation), Unit(Unit) {}
+ const SourceLocation &SearchedLocation,
+ ASTUnit &Unit)

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:310
+
+return SourceMgr.getFileOffset(SearchedLocation) == Offset &&
+   SourceMgr.getFileID(SearchedLocation) == FID;

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:314
 
-  void addDeclarationLocation(const SourceRange& ValSourceRange) {
-const SourceManager& SourceMgr = Unit.getSourceManager();
-const LangOptions& LangOpts = Unit.getLangOpts();
+  void addDeclarationLocation(const SourceRange &ValSourceRange) {
+const SourceManager &SourceMgr = Unit.getSourceManager();

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:320
+   0, SourceMgr, LangOpts);
+
+

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:345
   }
-  IdentifierInfo* IdentifierInfo = Result.getIdentifierInfo();
+  IdentifierInfo *IdentifierInfo = Result.getIdentifierInfo();
   if (IdentifierInfo && IdentifierInfo->hadMacroDefinition()) {

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:355
 MacroDefinition MacroDef =
-Unit.getPreprocessor().getMacroDefinitionAtLoc(IdentifierInfo,
-BeforeSearchedLocation);
-MacroInfo* MacroInf = MacroDef.getMacroInfo();
+Unit.getPreprocessor().getMacroDefinitionAtLoc(
+IdentifierInfo, BeforeSearchedLocation);

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:390
   // Clang uses one-based numbers.
-  SourceLocation InputLocation = Unit->getLocation(FE, Pos.line + 1,
-  Pos.character + 1);
+  SourceLocation InputLocation =
+  Unit->getLocation(FE, Pos.line + 1, Pos.character + 1);

unintentional reformat?



Comment at: clangd/ClangdUnit.cpp:405
   // identifiers without another token in between.)
-  SourceLocation PeekBeforeLocation = Unit->getLocation(FE, Pos.line + 1,
-  Pos.character);
+  SourceLocation PeekBeforeLocation =
+  Unit->getLocation(FE, Pos.line + 1, Pos.character);

unintentional reformat?



Comment at: clangd/ClangdUnit.h:95
+  
 
   SourceLocation getBeginningOfIdentifier(const Position& Pos, const 
FileEntry* FE) const;

remove


=

[PATCH] D35406: [clangd] Replace ASTUnit with manual AST management.

2017-07-26 Thread Petar Jovanovic via Phabricator via cfe-commits
petarj added a comment.

Can you check if this change introduced clang-x86-windows-msvc2015 buildbot 
failure 
?


Repository:
  rL LLVM

https://reviews.llvm.org/D35406



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


[PATCH] D34158: For standards compatibility, preinclude if the file is available

2017-07-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


r309118 - Regression test for PR10856

2017-07-26 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed Jul 26 07:58:55 2017
New Revision: 309118

URL: http://llvm.org/viewvc/llvm-project?rev=309118&view=rev
Log:
Regression test for PR10856

Added:
cfe/trunk/test/SemaTemplate/instantiate-friend-function.cpp

Added: cfe/trunk/test/SemaTemplate/instantiate-friend-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-friend-function.cpp?rev=309118&view=auto
==
--- cfe/trunk/test/SemaTemplate/instantiate-friend-function.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiate-friend-function.cpp Wed Jul 26 
07:58:55 2017
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -S -triple %itanium_abi_triple -std=c++11 -emit-llvm %s -o 
- | FileCheck %s
+// expected-no-diagnostics
+
+namespace PR10856 {
+  template class C;
+
+  template C operator - (C m0, C m1);
+  template class C {
+public:
+  template friend C operator - (C m0, C 
m1);
+  };
+
+  template inline C operator - (C m0, C m1) {
+C ret;
+return ret;
+  }
+};
+
+int PR10856_main(int argc, char** argv) {
+  using namespace PR10856;
+  C a;
+  a-a;
+  return 0;
+}
+
+// PR10856::C PR10856::operator-(PR10856::C, 
PR10856::C)
+// CHECK: define {{.*}} @_ZN7PR10856miIiiEENS_1CIT0_EENS1_IT_EES5_
+
+namespace PR10856_Root {
+  template
+  bool g(Value value);
+
+  template class MyClass {
+  private:
+template
+friend bool g(Value value);
+  };
+}
+
+namespace PR10856_Root {
+  void f() {
+MyClass value;
+g(value);
+  }
+}
+
+// bool PR10856_Root::g, 
void>(PR10856_Root::MyClass)
+// CHECK: call {{.*}} @_ZN12PR10856_Root1gINS_7MyClassIiEEvEEbT_


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


[PATCH] D30155: [clang-tools-extra] [test] Fix clang library dir in LD_LIBRARY_PATH For stand-alone build

2017-07-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Another ping. @beanz, any chance you could take a look at this?


Repository:
  rL LLVM

https://reviews.llvm.org/D30155



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


[PATCH] D34091: Support for querying the exception specification type through libclang

2017-07-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This patch has introduced a test suite failure:

  ==
  ERROR: Failure: ImportError (No module named util)
  --
  Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/nose/loader.py", line 420, in 
loadTestsFromName
  addr.filename, addr.module)
File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 47, in 
importFromPath
  return self.importFromDir(dir_path, fqname)
File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 94, in 
importFromDir
  mod = load_module(part_fqname, fh, filename, desc)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/test_exception_specification_kind.py",
 line 3, in 
  from .util import get_tu
  ImportError: No module named util

I presume that this patch meant to include the `util` module but you forgot to 
add the file. Could you fix that, please?




Comment at: 
cfe/trunk/bindings/python/tests/test_exception_specification_kind.py:3
+from clang.cindex import ExceptionSpecificationKind
+from .util import get_tu
+

It seems that the `util` module has never been committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D34091



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


r309116 - unguarded availability: add a fixit for the "annotate '...'

2017-07-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jul 26 06:58:02 2017
New Revision: 309116

URL: http://llvm.org/viewvc/llvm-project?rev=309116&view=rev
Log:
unguarded availability: add a fixit for the "annotate '...'
with an availability attribute to silence" note

rdar://33539233

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

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/FixIt/fixit-availability.c
cfe/trunk/test/FixIt/fixit-availability.mm

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=309116&r1=309115&r2=309116&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jul 26 06:58:02 2017
@@ -7032,6 +7032,49 @@ static NamedDecl *findEnclosingDeclToAnn
   return dyn_cast(OrigCtx);
 }
 
+namespace {
+
+struct AttributeInsertion {
+  StringRef Prefix;
+  SourceLocation Loc;
+  StringRef Suffix;
+
+  static AttributeInsertion createInsertionAfter(const NamedDecl *D) {
+return {" ", D->getLocEnd(), ""};
+  }
+  static AttributeInsertion createInsertionAfter(SourceLocation Loc) {
+return {" ", Loc, ""};
+  }
+  static AttributeInsertion createInsertionBefore(const NamedDecl *D) {
+return {"", D->getLocStart(), "\n"};
+  }
+};
+
+} // end anonymous namespace
+
+/// Returns a source location in which it's appropriate to insert a new
+/// attribute for the given declaration \D.
+static Optional
+createAttributeInsertion(const NamedDecl *D, const SourceManager &SM,
+ const LangOptions &LangOpts) {
+  if (isa(D))
+return AttributeInsertion::createInsertionAfter(D);
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->hasBody())
+  return None;
+return AttributeInsertion::createInsertionAfter(D);
+  }
+  if (const auto *TD = dyn_cast(D)) {
+SourceLocation Loc =
+Lexer::getLocForEndOfToken(TD->getInnerLocStart(), 0, SM, LangOpts);
+if (Loc.isInvalid())
+  return None;
+// Insert after the 'struct'/whatever keyword.
+return AttributeInsertion::createInsertionAfter(Loc);
+  }
+  return AttributeInsertion::createInsertionBefore(D);
+}
+
 /// Actually emit an availability diagnostic for a reference to an unavailable
 /// decl.
 ///
@@ -7221,8 +7264,29 @@ static void DoEmitAvailabilityWarning(Se
   << /*Anonymous*/1 << TD->getKindName();
   return;
 }
-  S.Diag(Enclosing->getLocation(), diag::note_partial_availability_silence)
-  << /*Named*/0 << Enclosing;
+  auto FixitNoteDiag = S.Diag(Enclosing->getLocation(),
+  diag::note_partial_availability_silence)
+   << /*Named*/ 0 << Enclosing;
+  // Don't offer a fixit for declarations with availability attributes.
+  if (Enclosing->hasAttr())
+return;
+  if (!S.getPreprocessor().isMacroDefined("API_AVAILABLE"))
+return;
+  Optional Insertion = createAttributeInsertion(
+  Enclosing, S.getSourceManager(), S.getLangOpts());
+  if (!Insertion)
+return;
+  std::string PlatformName =
+  AvailabilityAttr::getPlatformNameSourceSpelling(
+  S.getASTContext().getTargetInfo().getPlatformName())
+  .lower();
+  std::string Introduced =
+  OffendingDecl->getVersionIntroduced().getAsString();
+  FixitNoteDiag << FixItHint::CreateInsertion(
+  Insertion->Loc,
+  (llvm::Twine(Insertion->Prefix) + "API_AVAILABLE(" + PlatformName +
+   "(" + Introduced + "))" + Insertion->Suffix)
+  .str());
 }
 }
 

Modified: cfe/trunk/test/FixIt/fixit-availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-availability.c?rev=309116&r1=309115&r2=309116&view=diff
==
--- cfe/trunk/test/FixIt/fixit-availability.c (original)
+++ cfe/trunk/test/FixIt/fixit-availability.c Wed Jul 26 06:58:02 2017
@@ -8,3 +8,11 @@ void use() {
 // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if 
(__builtin_available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n   
   // Fallback on earlier versions\n  }"
 }
+
+__attribute__((availability(macos, introduced=10.12)))
+struct New { };
+
+struct NoFixit {
+  struct New field;
+};
+// CHECK-NOT: API_AVAILABLE

Modified: cfe/trunk/test/FixIt/fixit-availability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-availability.mm?rev=309116&r1=309115&r2=309116&view=diff
==
--- cfe/trunk/test/FixIt/fixit-availability.mm (original)
+++ cfe/trunk/test/FixIt/fixit-availability.mm Wed Jul 26 06:58:02 2017
@@ -109,3 +109,34 @@ void wrapDeclStmtUses() {
   anotherFunction(y);
   anotherFunction(x);
 }
+

[PATCH] D35726: unguarded availability: add a fixit for the "annotate '...' with an availability attribute to silence" note

2017-07-26 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked 2 inline comments as done.
Closed by commit rL309116: unguarded availability: add a fixit for the 
"annotate '...' (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D35726?vs=107903&id=108271#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35726

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/FixIt/fixit-availability.c
  cfe/trunk/test/FixIt/fixit-availability.mm

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -7032,6 +7032,49 @@
   return dyn_cast(OrigCtx);
 }
 
+namespace {
+
+struct AttributeInsertion {
+  StringRef Prefix;
+  SourceLocation Loc;
+  StringRef Suffix;
+
+  static AttributeInsertion createInsertionAfter(const NamedDecl *D) {
+return {" ", D->getLocEnd(), ""};
+  }
+  static AttributeInsertion createInsertionAfter(SourceLocation Loc) {
+return {" ", Loc, ""};
+  }
+  static AttributeInsertion createInsertionBefore(const NamedDecl *D) {
+return {"", D->getLocStart(), "\n"};
+  }
+};
+
+} // end anonymous namespace
+
+/// Returns a source location in which it's appropriate to insert a new
+/// attribute for the given declaration \D.
+static Optional
+createAttributeInsertion(const NamedDecl *D, const SourceManager &SM,
+ const LangOptions &LangOpts) {
+  if (isa(D))
+return AttributeInsertion::createInsertionAfter(D);
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->hasBody())
+  return None;
+return AttributeInsertion::createInsertionAfter(D);
+  }
+  if (const auto *TD = dyn_cast(D)) {
+SourceLocation Loc =
+Lexer::getLocForEndOfToken(TD->getInnerLocStart(), 0, SM, LangOpts);
+if (Loc.isInvalid())
+  return None;
+// Insert after the 'struct'/whatever keyword.
+return AttributeInsertion::createInsertionAfter(Loc);
+  }
+  return AttributeInsertion::createInsertionBefore(D);
+}
+
 /// Actually emit an availability diagnostic for a reference to an unavailable
 /// decl.
 ///
@@ -7221,8 +7264,29 @@
   << /*Anonymous*/1 << TD->getKindName();
   return;
 }
-  S.Diag(Enclosing->getLocation(), diag::note_partial_availability_silence)
-  << /*Named*/0 << Enclosing;
+  auto FixitNoteDiag = S.Diag(Enclosing->getLocation(),
+  diag::note_partial_availability_silence)
+   << /*Named*/ 0 << Enclosing;
+  // Don't offer a fixit for declarations with availability attributes.
+  if (Enclosing->hasAttr())
+return;
+  if (!S.getPreprocessor().isMacroDefined("API_AVAILABLE"))
+return;
+  Optional Insertion = createAttributeInsertion(
+  Enclosing, S.getSourceManager(), S.getLangOpts());
+  if (!Insertion)
+return;
+  std::string PlatformName =
+  AvailabilityAttr::getPlatformNameSourceSpelling(
+  S.getASTContext().getTargetInfo().getPlatformName())
+  .lower();
+  std::string Introduced =
+  OffendingDecl->getVersionIntroduced().getAsString();
+  FixitNoteDiag << FixItHint::CreateInsertion(
+  Insertion->Loc,
+  (llvm::Twine(Insertion->Prefix) + "API_AVAILABLE(" + PlatformName +
+   "(" + Introduced + "))" + Insertion->Suffix)
+  .str());
 }
 }
 
Index: cfe/trunk/test/FixIt/fixit-availability.mm
===
--- cfe/trunk/test/FixIt/fixit-availability.mm
+++ cfe/trunk/test/FixIt/fixit-availability.mm
@@ -109,3 +109,34 @@
   anotherFunction(y);
   anotherFunction(x);
 }
+
+#define API_AVAILABLE(X) __attribute__((availability(macos, introduced=10.12))) // dummy macro
+
+API_AVAILABLE(macos(10.12))
+@interface NewClass
+@end
+
+@interface OldButOfferFixit
+@property(copy) NewClass *prop;
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:1-[[@LINE-2]]:1}:"API_AVAILABLE(macos(10.12))\n"
+
+- (NewClass *)fixitMe;
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:22-[[@LINE-1]]:22}:" API_AVAILABLE(macos(10.12))"
+@end
+
+void oldButOfferFixitFn(NewClass *) {
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:1-[[@LINE-1]]:1}:"API_AVAILABLE(macos(10.12))\n"
+}
+
+template
+struct OldButOfferFixitTag {
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:7-[[@LINE-1]]:7}:" API_AVAILABLE(macos(10.12))"
+  NewClass *x;
+};
+
+// Avoid a fixit for declarations that already have an attribute:
+__attribute__((availability(macos, introduced=10.11)))
+@interface WithoutFixit
+@property(copy) NewClass *prop;
+// CHECK-NOT: API_AVAILABLE
+@end
Index: cfe/trunk/test/FixIt/fixit-availability.c
===
--- cfe/trunk/test/FixIt/fixit-availability.c
+++ cfe/trunk/test/FixIt/fixit-availability.c
@@ -8,3 +8,11 @@
 // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (_

[PATCH] D35759: [Bash-autocompletion] Show HelpText with possible flags

2017-07-26 Thread Yuka Takahashi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309113: [Bash-autocompletion] Show HelpText with possible 
flags (authored by yamaguchi).

Changed prior to commit:
  https://reviews.llvm.org/D35759?vs=107791&id=108267#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35759

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/autocomplete.c
  cfe/trunk/utils/bash-autocomplete.sh
  llvm/trunk/lib/Option/OptTable.cpp

Index: llvm/trunk/lib/Option/OptTable.cpp
===
--- llvm/trunk/lib/Option/OptTable.cpp
+++ llvm/trunk/lib/Option/OptTable.cpp
@@ -235,7 +235,9 @@
   continue;
 
 for (int I = 0; In.Prefixes[I]; I++) {
-  std::string S = std::string(In.Prefixes[I]) + std::string(In.Name);
+  std::string S = std::string(In.Prefixes[I]) + std::string(In.Name) + "\t";
+  if (In.HelpText)
+S += In.HelpText;
   if (StringRef(S).startswith(Cur))
 Ret.push_back(S);
 }
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1297,7 +1297,7 @@
 std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
   [](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
 
-llvm::outs() << llvm::join(SuggestedCompletions, " ") << '\n';
+llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 return false;
   }
 
Index: cfe/trunk/utils/bash-autocomplete.sh
===
--- cfe/trunk/utils/bash-autocomplete.sh
+++ cfe/trunk/utils/bash-autocomplete.sh
@@ -57,7 +57,7 @@
 
   # expand ~ to $HOME
   eval local path=${COMP_WORDS[0]}
-  flags=$( "$path" --autocomplete="$arg" 2>/dev/null )
+  flags=$( "$path" --autocomplete="$arg" 2>/dev/null | sed -e 's/\t.*//' )
   # If clang is old that it does not support --autocomplete,
   # fall back to the filename completion.
   if [[ "$?" != 0 ]]; then
Index: cfe/trunk/test/Driver/autocomplete.c
===
--- cfe/trunk/test/Driver/autocomplete.c
+++ cfe/trunk/test/Driver/autocomplete.c
@@ -1,46 +1,91 @@
 // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
-// RUN: %clang --autocomplete=-s | FileCheck %s -check-prefix=STD
-// STD: -std={{.*}}-stdlib=
+// RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
+// STD: -std= Language standard to compile for
 // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO
 // FOO-NOT: foo
 // RUN: %clang --autocomplete=-stdlib=,l | FileCheck %s -check-prefix=STDLIB
-// STDLIB: libc++ libstdc++
+// STDLIB: libc++
+// STDLIB-NEXT: libstdc++
 // RUN: %clang --autocomplete=-stdlib=, | FileCheck %s -check-prefix=STDLIBALL
-// STDLIBALL: libc++ libstdc++ platform
+// STDLIBALL: libc++
+// STDLIBALL-NEXT: libstdc++
+// STDLIBALL-NEXT: platform
 // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI
 // MEABI: default
 // RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL
-// MEABIALL: 4 5 default gnu
+// MEABIALL: 4
+// MEABIALL-NEXT: 5
+// MEABIALL-NEXT: default
+// MEABIALL-NEXT: gnu
 // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD
 // CLSTD: CL2.0
 // RUN: %clang --autocomplete=-cl-std=, | FileCheck %s -check-prefix=CLSTDALL
-// CLSTDALL: cl CL cl1.1 CL1.1 cl1.2 CL1.2 cl2.0 CL2.0
+// CLSTDALL: cl
+// CLSTDALL-NEXT: CL
+// CLSTDALL-NEXT: cl1.1
+// CLSTDALL-NEXT: CL1.1
+// CLSTDALL-NEXT: cl1.2
+// CLSTDALL-NEXT: CL1.2
+// CLSTDALL-NEXT: cl2.0
+// CLSTDALL-NEXT: CL2.0
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=, | FileCheck %s -check-prefix=FNOSANICOVERALL
-// FNOSANICOVERALL: 8bit-counters bb edge func indirect-calls inline-8bit-counters no-prune trace-bb trace-cmp trace-div trace-gep trace-pc trace-pc-guard
+// FNOSANICOVERALL: 8bit-counters
+// FNOSANICOVERALL-NEXT: bb
+// FNOSANICOVERALL-NEXT: edge
+// FNOSANICOVERALL-NEXT: func
+// FNOSANICOVERALL-NEXT: indirect-calls
+// FNOSANICOVERALL-NEXT: inline-8bit-counters
+// FNOSANICOVERALL-NEXT: no-prune
+// FNOSANICOVERALL-NEXT: trace-bb
+// FNOSANICOVERALL-NEXT: trace-cmp
+// FNOSANICOVERALL-NEXT: trace-div
+// FNOSANICOVERALL-NEXT: trace-gep
+// FNOSANICOVERALL-NEXT: trace-pc
+// FNOSANICOVERALL-NEXT: trace-pc-guard
 // RUN: %clang --autocomplete=-ffp-contract=, | FileCheck %s -check-prefix=FFPALL
-// FFPALL: fast off on
+// FFPALL: fast
+// FFPALL-NEXT: off
+// FFPALL-NEXT: on
 // RUN: %clang --autocomplete=-flto=, | FileCheck %s -check-prefix=FLTOALL
-// FLTOALL: full thin
+// FLTOALL: full
+// FLTOALL-NEXT: thin
 // RUN: %clang --autocomplete=-fveclib=, | FileCheck %s -check-prefix=FVECLIBALL
-//

r309113 - [Bash-autocompletion] Show HelpText with possible flags

2017-07-26 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Wed Jul 26 06:36:58 2017
New Revision: 309113

URL: http://llvm.org/viewvc/llvm-project?rev=309113&view=rev
Log:
[Bash-autocompletion] Show HelpText with possible flags

Summary:
`clang --autocomplete=-std` will show
```
-std:   Language standard to compile for
-std=   Language standard to compile for
-stdlib=C++ standard library to use
```
after this change.

However, showing HelpText with completion in bash seems super tricky, so
this feature will be used in other shells (fish, zsh...).

Reviewers: v.g.vassilev, teemperor, ruiu

Subscribers: cfe-commits, hiraditya

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/autocomplete.c
cfe/trunk/utils/bash-autocomplete.sh

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=309113&r1=309112&r2=309113&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jul 26 06:36:58 2017
@@ -1297,7 +1297,7 @@ bool Driver::HandleImmediateArgs(const C
 std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
   [](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
 
-llvm::outs() << llvm::join(SuggestedCompletions, " ") << '\n';
+llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 return false;
   }
 

Modified: cfe/trunk/test/Driver/autocomplete.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=309113&r1=309112&r2=309113&view=diff
==
--- cfe/trunk/test/Driver/autocomplete.c (original)
+++ cfe/trunk/test/Driver/autocomplete.c Wed Jul 26 06:36:58 2017
@@ -1,46 +1,91 @@
 // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
-// RUN: %clang --autocomplete=-s | FileCheck %s -check-prefix=STD
-// STD: -std={{.*}}-stdlib=
+// RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
+// STD: -std= Language standard to compile for
 // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO
 // FOO-NOT: foo
 // RUN: %clang --autocomplete=-stdlib=,l | FileCheck %s -check-prefix=STDLIB
-// STDLIB: libc++ libstdc++
+// STDLIB: libc++
+// STDLIB-NEXT: libstdc++
 // RUN: %clang --autocomplete=-stdlib=, | FileCheck %s -check-prefix=STDLIBALL
-// STDLIBALL: libc++ libstdc++ platform
+// STDLIBALL: libc++
+// STDLIBALL-NEXT: libstdc++
+// STDLIBALL-NEXT: platform
 // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI
 // MEABI: default
 // RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL
-// MEABIALL: 4 5 default gnu
+// MEABIALL: 4
+// MEABIALL-NEXT: 5
+// MEABIALL-NEXT: default
+// MEABIALL-NEXT: gnu
 // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD
 // CLSTD: CL2.0
 // RUN: %clang --autocomplete=-cl-std=, | FileCheck %s -check-prefix=CLSTDALL
-// CLSTDALL: cl CL cl1.1 CL1.1 cl1.2 CL1.2 cl2.0 CL2.0
+// CLSTDALL: cl
+// CLSTDALL-NEXT: CL
+// CLSTDALL-NEXT: cl1.1
+// CLSTDALL-NEXT: CL1.1
+// CLSTDALL-NEXT: cl1.2
+// CLSTDALL-NEXT: CL1.2
+// CLSTDALL-NEXT: cl2.0
+// CLSTDALL-NEXT: CL2.0
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s 
-check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=, | FileCheck %s 
-check-prefix=FNOSANICOVERALL
-// FNOSANICOVERALL: 8bit-counters bb edge func indirect-calls 
inline-8bit-counters no-prune trace-bb trace-cmp trace-div trace-gep trace-pc 
trace-pc-guard
+// FNOSANICOVERALL: 8bit-counters
+// FNOSANICOVERALL-NEXT: bb
+// FNOSANICOVERALL-NEXT: edge
+// FNOSANICOVERALL-NEXT: func
+// FNOSANICOVERALL-NEXT: indirect-calls
+// FNOSANICOVERALL-NEXT: inline-8bit-counters
+// FNOSANICOVERALL-NEXT: no-prune
+// FNOSANICOVERALL-NEXT: trace-bb
+// FNOSANICOVERALL-NEXT: trace-cmp
+// FNOSANICOVERALL-NEXT: trace-div
+// FNOSANICOVERALL-NEXT: trace-gep
+// FNOSANICOVERALL-NEXT: trace-pc
+// FNOSANICOVERALL-NEXT: trace-pc-guard
 // RUN: %clang --autocomplete=-ffp-contract=, | FileCheck %s 
-check-prefix=FFPALL
-// FFPALL: fast off on
+// FFPALL: fast
+// FFPALL-NEXT: off
+// FFPALL-NEXT: on
 // RUN: %clang --autocomplete=-flto=, | FileCheck %s -check-prefix=FLTOALL
-// FLTOALL: full thin
+// FLTOALL: full
+// FLTOALL-NEXT: thin
 // RUN: %clang --autocomplete=-fveclib=, | FileCheck %s 
-check-prefix=FVECLIBALL
-// FVECLIBALL: Accelerate none SVML
+// FVECLIBALL: Accelerate
+// FVECLIBALL-NEXT: none
+// FVECLIBALL-NEXT: SVML
 // RUN: %clang --autocomplete=-fshow-overloads=, | FileCheck %s 
-check-prefix=FSOVERALL
-// FSOVERALL: all best
+// FSOVERALL: all
+// FSOVERALL-NEXT: best
 // RUN: %clang --autocomplete=-fvisibility=, | FileCheck %s 
-check-prefix=FVISIBILITYALL
-// FVISIBILITYALL: default hidden
+/

[PATCH] D35763: [Bash-completion] Fixed a bug that file doesn't autocompleted after =

2017-07-26 Thread Yuka Takahashi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309112: [Bash-completion] Fixed a bug that file doesn't 
autocompleted after = (authored by yamaguchi).

Changed prior to commit:
  https://reviews.llvm.org/D35763?vs=107787&id=108266#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35763

Files:
  cfe/trunk/utils/bash-autocomplete.sh


Index: cfe/trunk/utils/bash-autocomplete.sh
===
--- cfe/trunk/utils/bash-autocomplete.sh
+++ cfe/trunk/utils/bash-autocomplete.sh
@@ -65,10 +65,14 @@
 return
   fi
 
-  if [[ "$cur" == '=' ]]; then
-COMPREPLY=( $( compgen -W "$flags" -- "") )
-  elif [[ "$flags" == "" || "$arg" == "" ]]; then
+  # When clang does not emit any possible autocompletion, or user pushed tab 
after " ",
+  # just autocomplete files.
+  if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then
+# If -foo= and there was no possible values, autocomplete files.
+[[ "$cur" == '=' || "$cur" == -*= ]] && cur=""
 _clang_filedir
+  elif [[ "$cur" == '=' ]]; then
+COMPREPLY=( $( compgen -W "$flags" -- "") )
   else
 # Bash automatically appends a space after '=' by default.
 # Disable it so that it works nicely for options in the form of -foo=bar.


Index: cfe/trunk/utils/bash-autocomplete.sh
===
--- cfe/trunk/utils/bash-autocomplete.sh
+++ cfe/trunk/utils/bash-autocomplete.sh
@@ -65,10 +65,14 @@
 return
   fi
 
-  if [[ "$cur" == '=' ]]; then
-COMPREPLY=( $( compgen -W "$flags" -- "") )
-  elif [[ "$flags" == "" || "$arg" == "" ]]; then
+  # When clang does not emit any possible autocompletion, or user pushed tab after " ",
+  # just autocomplete files.
+  if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then
+# If -foo= and there was no possible values, autocomplete files.
+[[ "$cur" == '=' || "$cur" == -*= ]] && cur=""
 _clang_filedir
+  elif [[ "$cur" == '=' ]]; then
+COMPREPLY=( $( compgen -W "$flags" -- "") )
   else
 # Bash automatically appends a space after '=' by default.
 # Disable it so that it works nicely for options in the form of -foo=bar.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309112 - [Bash-completion] Fixed a bug that file doesn't autocompleted after =

2017-07-26 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Wed Jul 26 06:30:36 2017
New Revision: 309112

URL: http://llvm.org/viewvc/llvm-project?rev=309112&view=rev
Log:
[Bash-completion] Fixed a bug that file doesn't autocompleted after =

Summary:
File path wasn't autocompleted after `-fmodule-cache-path=[tab]`, so
fixed this bug by checking if $flags contains only a newline or not.

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

Modified:
cfe/trunk/utils/bash-autocomplete.sh

Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=309112&r1=309111&r2=309112&view=diff
==
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Wed Jul 26 06:30:36 2017
@@ -65,10 +65,14 @@ _clang()
 return
   fi
 
-  if [[ "$cur" == '=' ]]; then
-COMPREPLY=( $( compgen -W "$flags" -- "") )
-  elif [[ "$flags" == "" || "$arg" == "" ]]; then
+  # When clang does not emit any possible autocompletion, or user pushed tab 
after " ",
+  # just autocomplete files.
+  if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then
+# If -foo= and there was no possible values, autocomplete files.
+[[ "$cur" == '=' || "$cur" == -*= ]] && cur=""
 _clang_filedir
+  elif [[ "$cur" == '=' ]]; then
+COMPREPLY=( $( compgen -W "$flags" -- "") )
   else
 # Bash automatically appends a space after '=' by default.
 # Disable it so that it works nicely for options in the form of -foo=bar.


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


r309106 - Recommit r308327 2nd time: Add a warning for missing

2017-07-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jul 26 05:20:57 2017
New Revision: 309106

URL: http://llvm.org/viewvc/llvm-project?rev=309106&view=rev
Log:
Recommit r308327 2nd time: Add a warning for missing
'#pragma pack (pop)' and suspicious uses of '#pragma pack' in included files

The first recommit (r308441) caused a "non-default #pragma pack value might
change the alignment of struct or union members in the included file" warning
in LLVM itself. This recommit tweaks the added warning to avoid warnings for
#includes that don't have any records that are affected by the non-default
alignment. This tweak avoids the previously emitted warning in LLVM.

Original message:

This commit adds a new -Wpragma-pack warning. It warns in the following cases:

- When a translation unit is missing terminating #pragma pack (pop) directives.
- When entering an included file if the current alignment value as determined
  by '#pragma pack' directives is different from the default alignment value.
- When leaving an included file that changed the state of the current alignment
  value.

rdar://10184173

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

Added:
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/Inputs/pragma-pack1.h
cfe/trunk/test/Sema/Inputs/pragma-pack2.h
cfe/trunk/test/Sema/suspicious-pragma-pack.c
cfe/trunk/test/SemaObjC/Inputs/empty.h
cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/PCH/pragma-pack.c
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-options.cpp
cfe/trunk/test/Parser/pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=309106&r1=309105&r2=309106&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 26 05:20:57 2017
@@ -471,8 +471,9 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
+def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute]>;
+PragmaClangAttribute, PragmaPack]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=309106&r1=309105&r2=309106&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 26 05:20:57 
2017
@@ -712,6 +712,16 @@ def err_pragma_options_align_mac68k_targ
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;
+def warn_pragma_pack_non_default_at_include : Warning<
+  "non-default #pragma pack value changes the alignment of struct or union "
+  "members in the included file">, InGroup;
+def warn_pragma_pack_modified_after_include : Warning<
+  "the current #pragma pack aligment value is modified in the included "
+  "file">, InGroup;
+def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
+  "'#pragma pack (push, ...)' at end of file">, InGroup;
+def note_pragma_pack_here : Note<
+  "previous '#pragma pack' directive that modifies alignment is here">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=309106&r1=309105&r2=309106&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Jul 26 05

r309088 - Update after LLVM change r309087

2017-07-26 Thread George Rimar via cfe-commits
Author: grimar
Date: Wed Jul 26 02:10:17 2017
New Revision: 309088

URL: http://llvm.org/viewvc/llvm-project?rev=309088&view=rev
Log:
Update after LLVM change r309087

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=309088&r1=309087&r2=309088&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jul 26 02:10:17 2017
@@ -1124,7 +1124,8 @@ void Driver::PrintHelp(bool ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
   getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
-  IncludedFlagsBitmask, ExcludedFlagsBitmask);
+  IncludedFlagsBitmask, ExcludedFlagsBitmask,
+  /*ShowAllAliases=*/false);
 }
 
 void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=309088&r1=309087&r2=309088&view=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Wed Jul 26 
02:10:17 2017
@@ -179,7 +179,8 @@ bool clang::ExecuteCompilerInvocation(Co
 std::unique_ptr Opts = driver::createDriverOptTable();
 Opts->PrintHelp(llvm::outs(), "clang -cc1",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
-/*Include=*/ driver::options::CC1Option, /*Exclude=*/ 0);
+/*Include=*/driver::options::CC1Option,
+/*Exclude=*/0, /*ShowAllAliases=*/false);
 return true;
   }
 

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=309088&r1=309087&r2=309088&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Wed Jul 26 02:10:17 2017
@@ -504,7 +504,8 @@ int cc1as_main(ArrayRef Ar
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
 Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
-/*Include=*/driver::options::CC1AsOption, /*Exclude=*/0);
+/*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
+/*ShowAllAliases=*/false);
 return 0;
   }
 


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


[PATCH] D35013: [inline asm] repeating constraint matches the same output

2017-07-26 Thread Ziv Izhar via Phabricator via cfe-commits
zizhar abandoned this revision.
zizhar added a comment.

I agree,
My bad, apparently gcc doesn't support that, I see no reason to add that.
Closing the review.


Repository:
  rL LLVM

https://reviews.llvm.org/D35013



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


[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-26 Thread Peter Smith via Phabricator via cfe-commits
peter.smith updated this revision to Diff 108245.
peter.smith added a comment.

Thanks both for the comments, I've added the missing punctuation and have 
expanded the tests so that we anchor the check to the function and check for 
the operation that will be lowered by the back-end.


https://reviews.llvm.org/D35538

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arm-float-helpers.c
  test/CodeGen/complex-math.c

Index: test/CodeGen/complex-math.c
===
--- test/CodeGen/complex-math.c
+++ test/CodeGen/complex-math.c
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM
+// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 
 float _Complex add_float_rr(float a, float b) {
@@ -476,8 +477,15 @@
 
 // Check that the libcall will obtain proper calling convention on ARM
 _Complex double foo(_Complex double a, _Complex double b) {
+  // These functions are not defined as floating point helper functions in
+  // Run-time ABI for the ARM architecture document so they must not always
+  // use the base AAPCS.
+
   // ARM-LABEL: @foo(
-  // ARM: call arm_aapcscc { double, double } @__muldc3
+  // ARM: call void { double, double } @__muldc3
+
+  // ARMHF-LABEL: @foo(
+  // ARMHF: call { double, double } @__muldc3
 
   // ARM7K-LABEL: @foo(
   // ARM7K: call { double, double } @__muldc3
Index: test/CodeGen/arm-float-helpers.c
===
--- /dev/null
+++ test/CodeGen/arm-float-helpers.c
@@ -0,0 +1,233 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s
+
+// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The
+// floating-point helper functions to always use the base AAPCS (soft-float)
+// calling convention.
+//
+// These helper functions such as __aeabi_fadd are not explicitly called by
+// clang, instead they are generated by the ARMISelLowering when they are
+// needed; clang relies on llvm to use the base AAPCS.
+//
+// In this test we check that clang is not directly calling the __aeabi_
+// functions. We rely on llvm to test that the base AAPCS is used for any
+// __aeabi_ function from 4.1.2 that is used.
+//
+// When compiled to an object file with -mfloat-abi=soft each function F
+// below should result in a call to __aeabi_F. If clang is changed to call any
+// of these functions directly the test will need to be altered to check that
+// arm_aapcscc is used.
+//
+// Note that it is only the functions in 4.1.2 that must use the base AAPCS,
+// other runtime functions such as the _Complex helper routines are not covered.
+
+float fadd(float a, float b) { return a + b; }
+// CHECK-LABEL: define float @fadd(float %a, float %b)
+// CHECK-NOT: __aeabi_fadd
+// CHECK: %add = fadd float %0, %1
+
+float fdiv(float a, float b) { return a / b; }
+// CHECK-LABEL: define float @fdiv(float %a, float %b)
+// CHECK-NOT: __aeabi_fdiv
+// CHECK: %div = fdiv float %0, %1
+
+float fmul(float a, float b) { return a * b; }
+// CHECK-LABEL: define float @fmul(float %a, float %b)
+// CHECK-NOT: __aeabi_fmul
+// CHECK: %mul = fmul float %0, %1
+
+float fsub(float a, float b) { return a - b; }
+// CHECK-LABEL: define float @fsub(float %a, fl

[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-26 Thread Peter Szecsi via Phabricator via cfe-commits
szepet closed this revision.
szepet added a comment.

So the fixes seem to work. The problem was the line 'StackFrame = 
StackFrame->getParent()->getCurrentStackFrame();' since I havent checked if the 
parent of the StackFrame is nullptr. (It is quite interesting that it just not 
crashed on my computer.)


https://reviews.llvm.org/D34260



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


Re: r308965 - This patch enables the usage of constant Enum identifiers within Microsoft style inline assembly statements.

2017-07-26 Thread Alexander Kornienko via cfe-commits
FTR, this was reverted in r309004.

On Tue, Jul 25, 2017 at 12:43 PM, Matan Haroush via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mharoush
> Date: Tue Jul 25 03:43:43 2017
> New Revision: 308965
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308965&view=rev
> Log:
> This patch enables the usage of constant Enum identifiers within Microsoft
> style inline assembly statements.
>
> Differential Revision:
> https://reviews.llvm.org/D33277
> https://reviews.llvm.org/D33278
>
>
> Added:
> cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> cfe/trunk/test/CodeGen/ms-inline-asm.c
> cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaStmtAsm.cpp?rev=308965&r1=308964&r2=308965&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Jul 25 03:43:43 2017
> @@ -645,8 +645,8 @@ ExprResult Sema::LookupInlineAsmIdentifi
>// Referring to parameters is not allowed in naked functions.
>if (CheckNakedParmReference(Result.get(), *this))
>  return ExprError();
> -
> -  QualType T = Result.get()->getType();
> +  Expr *Res = Result.get();
> +  QualType T = Res->getType();
>
>if (T->isDependentType()) {
>  return Result;
> @@ -658,16 +658,26 @@ ExprResult Sema::LookupInlineAsmIdentifi
>}
>
>// Otherwise, it needs to be a complete type.
> -  if (RequireCompleteExprType(Result.get(),
> diag::err_asm_incomplete_type)) {
> +  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
>  return ExprError();
>}
>
>fillInlineAsmTypeInfo(Context, T, Info);
>
>// We can work with the expression as long as it's not an r-value.
> -  if (!Result.get()->isRValue())
> -Info.IsVarDecl = true;
> +  if (!Res->isRValue()) {
> +Info.setKindVariable();
> +return Result;
> +  }
>
> +  Expr::EvalResult EvlResult;
> +  // Try to evaluate the identifier as enum constant, currently we do not
> allow
> +  // other constant integers to be folded.
> +  if (isa(T) &&
> +Res->EvaluateAsRValue(EvlResult, getASTContext())) {
> +Info.ConstIntValue = EvlResult.Val.getInt();
> +Info.setKindConstEnum();
> +  }
>return Result;
>  }
>
> @@ -774,7 +784,7 @@ Sema::LookupInlineAsmVarDeclField(Expr *
>fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
>
>// Fields are "variables" as far as inline assembly is concerned.
> -  Info.IsVarDecl = true;
> +  Info.setKindVariable();
>
>return Result;
>  }
>
> Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGen/ms-inline-asm.c?rev=308965&r1=308964&r2=308965&view=diff
> 
> ==
> --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
> +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Jul 25 03:43:43 2017
> @@ -42,7 +42,7 @@ void t5(void) {
>  void t6(void) {
>__asm int 0x2c
>  // CHECK: t6
> -// CHECK: call void asm sideeffect inteldialect "int $$0x2c",
> "~{dirflag},~{fpsr},~{flags}"()
> +// CHECK: call void asm sideeffect inteldialect "int $$44",
> "~{dirflag},~{fpsr},~{flags}"()
>  }
>
>  void t7() {
> @@ -61,7 +61,7 @@ void t7() {
>  mov eax, ebx
>}
>  // CHECK: t7
> -// CHECK: call void asm sideeffect inteldialect "int $$0x2cU",
> "~{dirflag},~{fpsr},~{flags}"()
> +// CHECK: call void asm sideeffect inteldialect "int $$44",
> "~{dirflag},~{fpsr},~{flags}"()
>  // CHECK: call void asm sideeffect inteldialect "",
> "~{dirflag},~{fpsr},~{flags}"()
>  // CHECK: call void asm sideeffect inteldialect "mov eax, ebx",
> "~{eax},~{dirflag},~{fpsr},~{flags}"()
>  }
> @@ -94,7 +94,7 @@ void t9() {
>  // CHECK: t9
>  // CHECK: call void asm sideeffect inteldialect
>  // CHECK-SAME: push ebx
> -// CHECK-SAME: mov ebx, $$0x07
> +// CHECK-SAME: mov ebx, $$7
>  // CHECK-SAME: pop ebx
>  // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
>  }
> @@ -265,7 +265,7 @@ void t21() {
>  // CHECK: t21
>  // CHECK: call void asm sideeffect inteldialect
>  // CHECK-SAME: push ebx
> -// CHECK-SAME: mov ebx, $$07H
> +// CHECK-SAME: mov ebx, $$7
>  // CHECK-SAME: pop ebx
>  // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
>  }
> @@ -312,13 +312,13 @@ void t24() {
>  void t25() {
>  // CHECK: t25
>__asm mov eax, 0h
> -// CHECK: mov eax, $$0h
> +// CHECK: mov eax, $$4294967295
>__asm mov eax, 0fhU
>  // CHECK: mov eax, $$15
>__asm mov eax, 0a2h
> -// CHECK: mov eax, $$0a2h
> +// CHECK: mov eax, $$162
>__asm mov eax, 10100010b
> -// CHECK: mov eax, $$10100010b
> +// CHECK: mov eax, $$162
>__asm mov eax, 10100010BU
>  // CHECK: mov eax, $$162
>  // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
>
> Added: cfe/trunk/te

[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-07-26 Thread Peter Siket via Phabricator via cfe-commits
MontyKutyi updated this revision to Diff 108241.
MontyKutyi added a comment.

Added test for the fix.


https://reviews.llvm.org/D34030

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/AST/PostOrderASTVisitor.cpp

Index: unittests/AST/PostOrderASTVisitor.cpp
===
--- unittests/AST/PostOrderASTVisitor.cpp
+++ unittests/AST/PostOrderASTVisitor.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
+#include 
 
 using namespace clang;
 
@@ -75,7 +76,47 @@
 }
   };
 
-}
+  // Serializes the AST. It is not complete! It only serializes the Statement
+  // and the Declaration nodes.
+  class ASTSerializerVisitor
+: public RecursiveASTVisitor
+  {
+  private:
+std::vector& visitedNodes;
+const bool visitPostOrder;
+  public:
+
+ASTSerializerVisitor(bool visitPostOrder, std::vector& visitedNodes)
+  : visitedNodes (visitedNodes)
+  , visitPostOrder (visitPostOrder)
+{}
+
+bool shouldTraversePostOrder() const
+{
+  return visitPostOrder;
+}
+
+bool VisitStmt(Stmt *s)
+{
+  visitedNodes.push_back(s);
+  return true;
+}
+
+bool PostVisitStmt(Stmt *s)
+{
+  if (visitPostOrder)
+visitedNodes.push_back(s);
+  return true;
+}
+
+bool VisitDecl(Decl *d)
+{
+  visitedNodes.push_back(d);
+  return true;
+}
+  };
+
+} // anonymous namespace
 
 TEST(RecursiveASTVisitor, PostOrderTraversal) {
   auto ASTUnit = tooling::buildASTFromCode(
@@ -126,3 +167,32 @@
 ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
   }
 }
+
+TEST(RecursiveASTVisitor, PrePostComparisonTest) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class X {};"
+"template class X;"
+  );
+
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+
+  std::vector preorderNodeList, postorderNodeList;
+
+  ASTSerializerVisitor PreVisitor(false, preorderNodeList);
+  PreVisitor.TraverseTranslationUnitDecl(TU);
+
+  ASTSerializerVisitor PostVisitor(true, postorderNodeList);
+  PostVisitor.TraverseTranslationUnitDecl(TU);
+
+  // The number of visited nodes must be independent of the ordering mode.
+  ASSERT_EQ(preorderNodeList.size(), postorderNodeList.size());
+
+  std::sort(preorderNodeList.begin(), preorderNodeList.end());
+  std::sort(postorderNodeList.begin(), postorderNodeList.end());
+
+  // Both traversal must visit the same nodes.
+  ASSERT_EQ(std::mismatch(preorderNodeList.begin(),
+  preorderNodeList.end(),
+  postorderNodeList.begin()).first,
+preorderNodeList.end());
+}
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -1802,11 +1802,10 @@
 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));  \
 if (!getDerived().shouldVisitTemplateInstantiations() &&   \
 D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization)  \
-  /* Returning from here skips traversing the  \
- declaration context of the *TemplateSpecializationDecl\
- (embedded in the DEF_TRAVERSE_DECL() macro)   \
- which contains the instantiated members of the template. */   \
-  return true; \
+  /* Skip traversing the declaration context of the\
+ *TemplateSpecializationDecl (embedded in the DEF_TRAVERSE_DECL()  \
+ macro) which contains the instantiated members of the template. */\
+  ShouldVisitChildren = false; \
   })
 
 DEF_TRAVERSE_TMPL_SPEC_DECL(Class)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35884: Update to use enum classes for various ARM *Kind enums

2017-07-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added subscribers: kristof.beyls, aemerson.

This updates the relevant Clang parts for the LLVM change 
https://reviews.llvm.org/D35882.


https://reviews.llvm.org/D35884

Files:
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/ARM.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Arch/AArch64.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Gnu.cpp

Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1482,7 +1482,7 @@
   bool IsV7SubArch = TargetTriple.getSubArch() == llvm::Triple::ARMSubArch_v7;
   bool IsThumbMode = IsThumbArch ||
   Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, false) ||
-  (IsArmArch && llvm::ARM::parseArchISA(Arch) == llvm::ARM::IK_THUMB);
+  (IsArmArch && llvm::ARM::parseArchISA(Arch) == llvm::ARM::ISAKind::THUMB);
   bool IsArmV7Mode = (IsArmArch || IsThumbArch) &&
   (llvm::ARM::parseArchVersion(Arch) == 7 ||
(IsArmArch && Arch == "" && IsV7SubArch));
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -68,14 +68,14 @@
 
 void darwin::setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str) {
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
-  unsigned ArchKind = llvm::ARM::parseArch(Str);
+  llvm::ARM::ArchKind AK = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
 
   if (Str == "x86_64h")
 T.setArchName(Str);
-  else if (ArchKind == llvm::ARM::AK_ARMV6M ||
-   ArchKind == llvm::ARM::AK_ARMV7M ||
-   ArchKind == llvm::ARM::AK_ARMV7EM) {
+  else if (AK == llvm::ARM::ArchKind::ARMV6M ||
+   AK == llvm::ARM::ArchKind::ARMV7M ||
+   AK == llvm::ARM::ArchKind::ARMV7EM) {
 T.setOS(llvm::Triple::UnknownOS);
 T.setObjectFormat(llvm::Triple::MachO);
   }
@@ -740,10 +740,10 @@
 }
 
 static const char *ArmMachOArchNameCPU(StringRef CPU) {
-  unsigned ArchKind = llvm::ARM::parseCPUArch(CPU);
-  if (ArchKind == llvm::ARM::AK_INVALID)
+  llvm::ARM::ArchKind AK = llvm::ARM::parseCPUArch(CPU);
+  if (AK == llvm::ARM::ArchKind::INVALID)
 return nullptr;
-  StringRef Arch = llvm::ARM::getArchName(ArchKind);
+  StringRef Arch = llvm::ARM::getArchName(AK);
 
   // FIXME: Make sure this MachO triple mangling is really necessary.
   // ARMv5* normalises to ARMv5.
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -29,8 +29,7 @@
 // True if M-profile.
 bool arm::isARMMProfile(const llvm::Triple &Triple) {
   llvm::StringRef Arch = Triple.getArchName();
-  unsigned Profile = llvm::ARM::parseArchProfile(Arch);
-  return Profile == llvm::ARM::PK_M;
+  return llvm::ARM::parseArchProfile(Arch) == llvm::ARM::ProfileKind::M;
 }
 
 // Get Arch/CPU from args.
@@ -98,7 +97,7 @@
   std::pair Split = ArchName.split("+");
 
   std::string MArch = arm::getARMArch(ArchName, Triple);
-  if (llvm::ARM::parseArch(MArch) == llvm::ARM::AK_INVALID ||
+  if (llvm::ARM::parseArch(MArch) == llvm::ARM::ArchKind::INVALID ||
   (Split.second.size() && !DecodeARMFeatures(D, Split.second, Features)))
 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
@@ -393,7 +392,7 @@
 if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) {
   if (A->getOption().matches(options::OPT_mexecute_only)) {
 if (getARMSubArchVersionNumber(Triple) < 7 &&
-llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
+llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::ArchKind::ARMV6T2)
   D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName();
 else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
   D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
@@ -525,22 +524,22 @@
 // FIXME: This is redundant with -mcpu, why does LLVM use this.
 StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
const llvm::Triple &Triple) {
-  unsigned ArchKind;
+  llvm::ARM::ArchKind ArchKind;
   if (CPU == "generic") {
 std::string ARMArch = tools::arm::getARMArch(Arch, Triple);
 ArchKind = llvm::ARM::parseArch(ARMArch);
-if (ArchKind == llvm::ARM::AK_INVALID)
+if (ArchKind == llvm::ARM::ArchKind::INVALID)
   // In case of generic Arch, i.e. "arm",
   // extract arch from default cpu of the Triple
   ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(ARMArch));
   } else {
 // FIXME: horrible hack to get around the fact that Cortex-A7 is only an
 //

[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-07-26 Thread wangxin via Phabricator via cfe-commits
wangxindsb updated this revision to Diff 108236.
wangxindsb added a comment.

- Change the bugtype, just like the older checker.


https://reviews.llvm.org/D34275

Files:
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp

Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,79 +1,43 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
 
-/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
-   from a constructor or destructor. If it is not set, we expect diagnostics
-   only in the constructor or destructor.
-
-   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
-   functions not to non-pure virtual functions.
-*/
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
 
 class A {
 public:
   A();
-  A(int i);
 
   ~A() {};
   
-  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
-  virtual void bar() = 0;
+  virtual int foo()=0;
+  virtual void bar()=0;
   void f() {
 foo();
-#if INTERPROCEDURAL
-// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
-#endif
+// expected-warning:Call to virtual function during construction
   }
 };
 
 class B : public A {
 public:
   B() {
 foo();
-#if !PUREONLY
-#if INTERPROCEDURAL
-// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
-#endif
-#endif
-
+// expected-warning:Call to virtual function during construction
   }
   ~B();
   
   virtual int foo();
   virtual void bar() { foo(); }
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
-#endif
+  // expected-warning:Call to virtual function during destruction
 };
 
 A::A() {
   f();
 }
 
-A::A(int i) {
-  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
-#else
-  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
-#endif
-}
-
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
   this->foo();
-#if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}}
-#endif
-#endif
-
+  // expected-warning:Call to virtual function during destruction
 }
 
 class C : public B {
@@ -87,13 +51,7 @@
 
 C::C() {
   f(foo());
-#if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
-#endif
-#endif
+  // expected-warning:Call to virtual function during construction
 }
 
 class D : public B {
@@ -103,7 +61,8 @@
   }
   ~D() { bar(); }
   int foo() final;
-  void bar() final { foo(); } // no-warning
+  void bar() final { foo(); } 
+  // no-warning
 };
 
 class E final : public B {
@@ -115,7 +74,6 @@
   int foo() override;
 };
 
-// Regression test: don't crash when there's no direct callee.
 class F {
 public:
   F() {
@@ -125,17 +83,103 @@
   void foo();
 };
 
-int main() {
-  A *a;
-  B *b;
-  C *c;
-  D *d;
-  E *e;
-  F *f;
+class G {
+public:
+  G() {}
+  virtual void bar();
+  void foo() {
+bar();
+  // no warning
+  }
+};
+
+class H{
+public:
+  H() : initState(0) { init(); }
+  int initState;
+  virtual void f() const;
+  void init() {
+if (initState)
+  f();
+  // no warning
+  }
+
+  H(int i) {
+G g;
+g.foo();
+g.bar();
+  // no warning
+f();
+  // expected-warning:Call to 

[PATCH] D35796: [analyzer] Misused polymorphic object checker

2017-07-26 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

In https://reviews.llvm.org/D35796#819965, @NoQ wrote:

> It seems that this check is more powerful because it works by knowing the 
> dynamic type of the object. However, i still suspect that 
> `-Wnon-virtual-dtor` (the other one, without `delete-`, that simply asks to 
> make the destructor of polymorphic classes virtual) covers most practical 
> cases. The only thing i see not covered by `-Wnon-virtual-dtor` but covered 
> by this checker is the situation when the destructor is private. Reka, would 
> you confirm our understanding?


You're right, the flag covers many cases, but there are some common exceptions. 
E.g. deleting a polymorphic object without a virtual destructor might not be a 
problem if it's referenced by its precise type. The checker is aware of this. 
It looks for object deletions, checks their dynamic and static types, and only 
warns if an object is deleted through a base pointer (with no virtual 
destructor).

I added a slightly more sophisticated test case for the private destructor 
situation, I'm wondering whether you meant something like that.


https://reviews.llvm.org/D35796



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


[PATCH] D35796: [analyzer] Misused polymorphic object checker

2017-07-26 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 108226.

https://reviews.llvm.org/D35796

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MisusedPolymorphicObjectChecker.cpp
  test/Analysis/MisusedPolymorphicObject.cpp

Index: test/Analysis/MisusedPolymorphicObject.cpp
===
--- /dev/null
+++ test/Analysis/MisusedPolymorphicObject.cpp
@@ -0,0 +1,187 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.PolymorphicDtorNotCalled -std=c++11 -verify -analyzer-output=text %s
+
+struct Virtual {
+  virtual ~Virtual() {}
+};
+
+struct VDerived : public Virtual {};
+
+struct NonVirtual {
+  ~NonVirtual() {}
+};
+
+struct NVDerived : public NonVirtual {};
+struct NVDoubleDerived : public NVDerived {};
+
+struct Base {
+  virtual void destroy() = 0;
+};
+
+class PrivateDtor : public Base {
+public:
+  void destroy() { delete this; }
+private:
+  ~PrivateDtor() {}
+};
+
+struct ImplicitNV {
+  virtual void f();
+};
+
+struct ImplicitNVDerived : public ImplicitNV {};
+
+NVDerived *get();
+
+NonVirtual *create() {
+  NonVirtual *x = new NVDerived(); // expected-note{{Derived-to-base conversion happened here}}
+  return x;
+}
+
+void sink(NonVirtual *x) {
+  delete x; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void sinkCast(NonVirtual *y) {
+  delete reinterpret_cast(y);
+}
+
+void sinkParamCast(NVDerived *z) {
+  delete z;
+}
+
+void singleDerived() {
+  NonVirtual *sd;
+  sd = new NVDerived(); // expected-note{{Derived-to-base conversion happened here}}
+  delete sd; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void singleDerivedArr() {
+  NonVirtual *sda = new NVDerived[5]; // expected-note{{Derived-to-base conversion happened here}}
+  delete[] sda; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void doubleDerived() {
+  NonVirtual *dd = new NVDoubleDerived(); // expected-note{{Derived-to-base conversion happened here}}
+  delete (dd); // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void assignThroughFunction() {
+  NonVirtual *atf = get(); // expected-note{{Derived-to-base conversion happened here}}
+  delete atf; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void assignThroughFunction2() {
+  NonVirtual *atf2;
+  atf2 = get(); // expected-note{{Derived-to-base conversion happened here}}
+  delete atf2; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void createThroughFunction() {
+  NonVirtual *ctf = create(); // expected-note{{Calling 'create'}}
+  // expected-note@-1{{Returning from 'create'}}
+  delete ctf; // expected-warning {{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void deleteThroughFunction() {
+  NonVirtual *dtf = new NVDerived(); // expected-note{{Derived-to-base conversion happened here}}
+  sink(dtf); // expected-note{{Calling 'sink'}}
+}
+
+void singleCastCStyle() {
+  NVDerived *sccs = new NVDerived();
+  NonVirtual *sccs2 = (NonVirtual*)sccs; // expected-note{{Derived-to-base conversion happened here}}
+  delete sccs2; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void doubleCastCStyle() {
+  NonVirtual *dccs = new NVDerived();
+  NVDerived *dccs2 = (NVDerived*)dccs;
+  dccs = (NonVirtual*)dccs2; // expected-note{{Derived-to-base conversion happened here}}
+  delete dccs; // expected-warning{{Polymorphic object without virtual destructor deleted through base pointer}}
+  // expected-note@-1{{Polymorphic object without virtual destructor deleted through base pointer}}
+}
+
+void singleCast() {
+  NVDerived *sc = new NVDerived();
+  NonVirtual *sc2 = reinterpret_cast(sc); // expected-note{{Derived-to-base conversion happened here}}
+  delete sc2; // expected-warning{{Polymorphic object without virtual destructor deleted th

[PATCH] D34365: [FrontEnd] Allow overriding the default C/C++ -std via CMake vars

2017-07-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


https://reviews.llvm.org/D34365



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


[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-26 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment.

In https://reviews.llvm.org/D34260#821186, @teemperor wrote:

> Try fixing this invalid read and the buildbots (and my builds :) ) should be 
> working again.


Yeah, thanks for the help! :)
I already sent a fix for that: https://reviews.llvm.org/rL309036 and another 
one: https://reviews.llvm.org/rL309061 which I think was not necessary but the 
buildbot failed on the first try (I still think it just haven't picked up the 
commit)
For me it seems that these fixes solved the problem as the address sanitizer 
tests passes as well on clang (and nobody reverted the commits^^).


https://reviews.llvm.org/D34260



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-07-26 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I have some concerns about soundness when the rearrangement may overflow.

Here is an example:

  void clang_analyzer_eval(int);
  
  void foo(signed char A, signed char B) {
if (A + 0 >= B + 0) {
  clang_analyzer_eval(A - 126 == B + 3); // This yields FALSE with this 
patch
}
  }

But for A = 126 and B = -3 the `clang_analyzer_eval` is reachable and should 
evaluate to true.


https://reviews.llvm.org/D35109



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