[libclc] r244310 - Require LLVM >=3.7 and bump version to 0.2.0

2015-08-07 Thread Jeroen Ketema via cfe-commits
Author: jketema
Date: Fri Aug  7 03:31:37 2015
New Revision: 244310

URL: http://llvm.org/viewvc/llvm-project?rev=244310&view=rev
Log:
Require LLVM >=3.7 and bump version to 0.2.0

v2: Also remove LLVM 3.6 traces from prepare-builtins.cpp

Patch by: EdB

Modified:
libclc/trunk/configure.py
libclc/trunk/utils/prepare-builtins.cpp

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=244310&r1=244309&r2=244310&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Fri Aug  7 03:31:37 2015
@@ -5,7 +5,7 @@ def c_compiler_rule(b, name, description
   b.rule(name, command, description + " $out", depfile="$out.d")
 
 version_major = 0;
-version_minor = 1;
+version_minor = 2;
 version_patch = 0;
 
 from optparse import OptionParser
@@ -66,12 +66,13 @@ def llvm_config(args):
 sys.exit(1)
 
 llvm_version = string.split(string.replace(llvm_config(['--version']), 'svn', 
''), '.')
-if (int(llvm_version[0]) != 3 and int(llvm_version[1]) != 6):
-print "libclc requires LLVM 3.6"
-sys.exit(1)
-
+llvm_int_version = int(llvm_version[0]) * 100 + int(llvm_version[1]) * 10
 llvm_string_version = 'LLVM' + llvm_version[0] + '.' + llvm_version[1]
 
+if llvm_int_version < 370:
+print "libclc requires LLVM >= 3.7"
+sys.exit(1)
+
 llvm_system_libs = llvm_config(['--system-libs'])
 llvm_bindir = llvm_config(['--bindir'])
 llvm_core_libs = llvm_config(['--libs', 'core', 'bitreader', 'bitwriter']) + ' 
' + \

Modified: libclc/trunk/utils/prepare-builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/utils/prepare-builtins.cpp?rev=244310&r1=244309&r2=244310&view=diff
==
--- libclc/trunk/utils/prepare-builtins.cpp (original)
+++ libclc/trunk/utils/prepare-builtins.cpp Fri Aug  7 03:31:37 2015
@@ -14,10 +14,6 @@
 
 #include 
 
-#define LLVM_360 \
-  (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 6)
-
-
 using namespace llvm;
 
 static cl::opt
@@ -43,20 +39,12 @@ int main(int argc, char **argv) {
 if (std::error_code  ec = BufferOrErr.getError())
   ErrorMessage = ec.message();
 else {
-#if LLVM_360
-  ErrorOr
-#else
-  ErrorOr>
-#endif
-  ModuleOrErr =
+  ErrorOr> ModuleOrErr =
   parseBitcodeFile(BufferPtr.get()->getMemBufferRef(), Context);
   if (std::error_code ec = ModuleOrErr.getError())
 ErrorMessage = ec.message();
-#if LLVM_360
-  M = ModuleOrErr.get();
-#else
+
   M = ModuleOrErr.get().release();
-#endif
 }
   }
 


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


Re: [PATCH] D11781: Refactored pthread usage in libcxx

2015-08-07 Thread David Chisnall via cfe-commits
theraven added inline comments.


Comment at: include/__mutex_base:246
@@ -266,3 +245,3 @@
 
-class _LIBCPP_TYPE_VIS condition_variable
+class _LIBCPP_TYPE_VIS condition_variable : private 
__libcxx_support::condition_variable
 {

espositofulvio wrote:
> theraven wrote:
> > espositofulvio wrote:
> > > theraven wrote:
> > > > Does this change the ABI for a mutex on *NIX platforms?  We can't 
> > > > change the class layout for existing platforms (though we can indirect 
> > > > things via typedefs).
> > > My hunch is that it doesn't, std::condition_variable has no data member 
> > > now and the first base class (__libcxx_support::condition_variable) 
> > > contains only pthread_cond_t which will be effectively laid out at the 
> > > starting address of the object,  as it was previously for 
> > > std::condition_variable,. I will check this out later in the evening 
> > > though.
> > I *think* that it's correct, but it's worth compiling a program that has 
> > one compilation unit using the old header and another using the new one and 
> > check that it's able to interoperate correctly.
> > 
> > Also check whether this depends on the implementation of the condition 
> > variable.  On FreeBSD, the pthread types are all pointers (currently - 
> > we're going to have some painful ABI breakage at some point when we move 
> > them to being something that can live in shared memory).  In glibc, they're 
> > structures.  I don't think that you'll end up with different padding in the 
> > ABI from wrapping them in a class, but it's worth checking.
> > it's worth compiling a program that has one compilation unit using the old 
> > header and another using the new one and check that it's able to 
> > interoperate correctly
> 
> Unfortunately this isn't going to work, some simbols are now defined in 
> __libcxx_support and not in std (they are just made available through using), 
> so an object file that includes the old header won't link against the new 
> library (unreferenced symbols). The alternative is to create inline 
> forwarding methods.
> 
> 
> 
That's going to need some more refactoring then.  Breaking the public ABI of 
libc++ would be a show-stopper.


Repository:
  rL LLVM

http://reviews.llvm.org/D11781



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


r244312 - Silence tools/clang/lib/Tooling/CompilationDatabase.cpp:328:12: warning:

2015-08-07 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Aug  7 05:15:15 2015
New Revision: 244312

URL: http://llvm.org/viewvc/llvm-project?rev=244312&view=rev
Log:
Silence tools/clang/lib/Tooling/CompilationDatabase.cpp:328:12: warning:
‘clang::tooling::JSONAnchorDest’ defined but not used [-Wunused-variable]
from gcc 5.1.


Modified:
cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=244312&r1=244311&r2=244312&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Fri Aug  7 05:15:15 2015
@@ -325,7 +325,7 @@ namespace tooling {
 // This anchor is used to force the linker to link in the generated object file
 // and thus register the JSONCompilationDatabasePlugin.
 extern volatile int JSONAnchorSource;
-static int JSONAnchorDest = JSONAnchorSource;
+int JSONAnchorDest = JSONAnchorSource;
 
 } // end namespace tooling
 } // end namespace clang


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


Re: [PATCH] D6551: Improvements to scan-build.

2015-08-07 Thread Sylvestre Ledru via cfe-commits
sylvestre.ledru added a comment.

(if you commit it, please update the description, "Improvements to scan-build" 
is too general


http://reviews.llvm.org/D6551



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


[PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-07 Thread pierre gousseau via cfe-commits
pgousseau created this revision.
pgousseau added reviewers: cfe-commits, ayartsev, xazax.hun.

Dear All,

I would like to propose a patch to avoid the false positive memory leak warning 
kindly reported by krzysztof in https://llvm.org/bugs/show_bug.cgi?id=22954

The issue seems originates from the CString checker's handling of 'memcpy' (and 
string copy functions in general).
Given the below code snippet:
--
struct aa { char *s; char data[32];};
...
a.s = malloc(nbytes);
memcpy(a.data, source, len);
...
--
As the CString checker handles the memcpy call, it requests the invalidation of 
the 'a.data' region. But the invalidation worker marks the whole memory region 
of 'a' as to be invalidated. The Malloc checker is not made aware of this 
causing the false positive.

Following advices from Anton Yartsev and Gabor Horvath on cfe-dev 
(http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-July/043786.html), this patch 
introduces a new trait 'TK_DoNotInvalidateSuperRegion', for the invalidation 
worker to take into account, when invalidating a destination buffer of type 
'FieldRegion'.

Please let me know if this is an acceptable change and if yes eventually commit 
it for me (as I do not have svn access) ?

Regards,

Pierre Gousseau
SN Systems - Sony Computer Entertainment

http://reviews.llvm.org/D11832

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/pr22954.c

Index: test/Analysis/pr22954.c
===
--- /dev/null
+++ test/Analysis/pr22954.c
@@ -0,0 +1,266 @@
+// Given code 'struct aa { char s1[4]; char * s2;} a; memcpy(a.s1, ...);',
+// this test checks that the CStringChecker only invalidates the destination buffer array a.s1 (instead of a.s1 and a.s2).
+// At the moment the whole of the destination array content is invalidated.
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+
+char *strdup(const char *s);
+void free(void *);
+void *memcpy(void *dst, const void *src, size_t n);
+
+void clang_analyzer_eval(int);
+
+struct aa {
+char s1[4];
+char *s2;
+};
+
+// Test different types of structure initialisation.
+int f0() {
+  struct aa a0 = {{1, 2, 3, 4}, 0};
+  a0.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a0.s1, input, 4);
+  clang_analyzer_eval(a0.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a0.s2); // no warning
+  return 0;
+}
+
+int f1() {
+  struct aa a1;
+  a1.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a1.s1, input, 4);
+  clang_analyzer_eval(a1.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a1.s2); // no warning
+  return 0;
+}
+
+int f2() {
+  struct aa a2 = {{1, 2}};
+  a2.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a2.s1, input, 4);
+  clang_analyzer_eval(a2.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a2.s2); // no warning
+  return 0;
+}
+
+int f3() {
+  struct aa a3 = {{1, 2, 3, 4}, 0};
+  a3.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  int * dest = (int*)a3.s1;
+  memcpy(dest, input, 4);
+  clang_analyzer_eval(a3.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a3.s2); // no warning
+  return 0;
+}
+
+struct bb {
+  struct aa a;
+  char * s2;
+};
+
+int f4() {
+  struct bb b0 = {{1, 2, 3, 4}, 0};
+  b0.s2 = strdup("hello");
+  b0.a.s

[PATCH] D11834: s/NDEBUG/LLVM_NDEBUG/ in most places to match the same LLVM change.

2015-08-07 Thread Tom Stellard via cfe-commits
tstellarAMD created this revision.
tstellarAMD added reviewers: echristo, chandlerc, beanz.
tstellarAMD added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

http://reviews.llvm.org/D11834

Files:
  lib/ARCMigrate/TransProperties.cpp
  lib/AST/ASTContext.cpp
  lib/AST/CommentLexer.cpp
  lib/AST/CommentParser.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclFriend.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/RecordLayout.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/AST/StmtViz.cpp
  lib/ASTMatchers/Dynamic/Marshallers.h
  lib/Analysis/CFG.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/Basic/VirtualFileSystem.cpp
  lib/CodeGen/CGBuilder.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGRecordLayoutBuilder.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Driver/Multilib.cpp
  lib/Driver/Tools.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp
  lib/Lex/ModuleMap.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/TreeTransform.h
  lib/Sema/TypeLocBuilder.cpp
  lib/Sema/TypeLocBuilder.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/Serialization/ModuleManager.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/CheckerManager.cpp
  lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp

Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -30,7 +30,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/raw_ostream.h"
 
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
 #include "llvm/Support/GraphWriter.h"
 #endif
 
@@ -1458,7 +1458,7 @@
   return state->getSVal(Ex, LCtx);
 }
 
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
 static const Stmt *getRightmostLeaf(const Stmt *Condition) {
   while (Condition) {
 const BinaryOperator *BO = dyn_cast(Condition);
@@ -2398,7 +2398,7 @@
 // Visualization.
 //===--===//
 
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
 static ExprEngine* GraphPrintCheckerState;
 static SourceManager* GraphPrintSourceManager;
 
@@ -2655,7 +2655,7 @@
 #endif
 
 void ExprEngine::ViewGraph(bool trim) {
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
   if (trim) {
 std::vector Src;
 
@@ -2686,7 +2686,7 @@
 }
 
 void ExprEngine::ViewGraph(ArrayRef Nodes) {
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
   GraphPrintCheckerState = this;
   GraphPrintSourceManager = &getContext().getSourceManager();
 
Index: lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -33,12 +33,12 @@
 // An out of line virtual method to provide a home for the class vtable.
 ExplodedNode::Auditor::~Auditor() {}
 
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
 static ExplodedNode::Auditor* NodeAuditor = nullptr;
 #endif
 
 void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) {
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
   NodeAuditor = A;
 #endif
 }
@@ -219,7 +219,7 @@
   assert (!V->isSink());
   Preds.addNode(V, G);
   V->Succs.addNode(this, G);
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
   if (NodeAuditor) NodeAuditor->AddEdge(V, this);
 #endif
 }
Index: lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -40,7 +40,7 @@
 }
 
 void CheckerManager::finishedCheckerRegistration() {
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG
   // Make sure that for every event that has listeners, there is at least
   // one dispatcher registered for it.
   for (llvm::DenseMap::iterator
@@ -553,7 +553,7 @@
   if (evaluated) {
 anyEvaluated = true;
 Dst.insert(checkDst);
-#ifdef NDEBUG
+#ifdef LLVM_NDEBUG
 break; // on release don't check that no other checker also evals.
 #endif
   }
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -330,7 +330,7 @@
 const ExplodedNode *PrevN,
 BugReporterContext &BRC,
 BugReport &BR) {
-#ifndef NDEBUG
+#ifndef LLVM_NDEBUG

[PATCH] D11837: Add Qt brace style configuration option.

2015-08-07 Thread Roman Kashitsyn via cfe-commits
lifted created this revision.
lifted added a reviewer: djasper.
lifted added subscribers: cfe-commits, klimek.

Add Qt brace style as described on https://wiki.qt.io/Qt_Coding_Style :

* Use attached braces: the opening brace goes on the same line as the start of
  the statement.  If the closing brace is followed by another keyword, it goes
  into the same line as well.

* Exception: Function implementations and class declarations always have the
  left brace on the start of a line.

http://reviews.llvm.org/D11837

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2329,13 +2329,16 @@
 
 TEST_F(FormatTest, FormatTryCatchBraceStyles) {
   FormatStyle Style = getLLVMStyle();
-  Style.BreakBeforeBraces = FormatStyle::BS_Attach;
-  verifyFormat("try {\n"
-   "  // something\n"
-   "} catch (...) {\n"
-   "  // something\n"
-   "}",
-   Style);
+  for (auto BraceStyle :
+   {FormatStyle::BS_Attach, FormatStyle::BS_Mozilla, FormatStyle::BS_Qt}) {
+Style.BreakBeforeBraces = BraceStyle;
+verifyFormat("try {\n"
+ "  // something\n"
+ "} catch (...) {\n"
+ "  // something\n"
+ "}",
+ Style);
+  }
   Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
   verifyFormat("try {\n"
"  // something\n"
@@ -9060,6 +9063,57 @@
"#endif",
GNUBraceStyle);
 }
+
+TEST_F(FormatTest, QtBraceBreaking) {
+  FormatStyle QtBraceStyle = getLLVMStyle();
+  QtBraceStyle.BreakBeforeBraces = FormatStyle::BS_Qt;
+  verifyFormat("namespace a {\n"
+   "class A\n"
+   "{\n"
+   "  void f()\n"
+   "  {\n"
+   "if (true) {\n"
+   "  a();\n"
+   "  b();\n"
+   "}\n"
+   "  }\n"
+   "  void g() { return; }\n"
+   "};\n"
+   "enum E {\n"
+   "  A,\n"
+   "  // foo\n"
+   "  B,\n"
+   "  C\n"
+   "};\n"
+   "struct B {\n"
+   "  int x;\n"
+   "};\n"
+   "}\n",
+   QtBraceStyle);
+  verifyFormat("struct S {\n"
+   "  int Type;\n"
+   "  union {\n"
+   "int x;\n"
+   "double y;\n"
+   "  } Value;\n"
+   "  class C\n"
+   "  {\n"
+   "MyFavoriteType Value;\n"
+   "  } Class;\n"
+   "};\n",
+   QtBraceStyle);
+
+  QtBraceStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  verifyFormat("static void foo(int g)\n"
+   "{\n"
+   "  qDebug(\"foo: %i\", g);\n"
+   "}\n"
+   "class Moo\n"
+   "{\n"
+   "};",
+   QtBraceStyle);
+}
+
 TEST_F(FormatTest, CatchExceptionReferenceBinding) {
   verifyFormat("void f() {\n"
"  try {\n"
@@ -9336,6 +9390,7 @@
   CHECK_PARSE("BreakBeforeBraces: Allman", BreakBeforeBraces,
   FormatStyle::BS_Allman);
   CHECK_PARSE("BreakBeforeBraces: GNU", BreakBeforeBraces, FormatStyle::BS_GNU);
+  CHECK_PARSE("BreakBeforeBraces: Qt", BreakBeforeBraces, FormatStyle::BS_Qt);
 
   Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
   CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -459,6 +459,8 @@
 return InitialToken.isOneOf(tok::kw_namespace, tok::kw_class);
   case FormatStyle::BS_Mozilla:
 return InitialToken.isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union);
+  case FormatStyle::BS_Qt:
+return InitialToken.is(tok::kw_class);
   case FormatStyle::BS_Allman:
   case FormatStyle::BS_GNU:
 return true;
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -98,6 +98,7 @@
 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup);
 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman);
 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU);
+IO.enumCase(Value, "Qt", FormatStyle::BS_Qt);
   }
 };
 
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -176,7 +176,9 @@
 /// Always break before braces and add an extra level of indentation to

Re: r244312 - Silence tools/clang/lib/Tooling/CompilationDatabase.cpp:328:12: warning:

2015-08-07 Thread David Blaikie via cfe-commits
On Fri, Aug 7, 2015 at 3:15 AM, Yaron Keren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yrnkrn
> Date: Fri Aug  7 05:15:15 2015
> New Revision: 244312
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244312&view=rev
> Log:
> Silence tools/clang/lib/Tooling/CompilationDatabase.cpp:328:12: warning:
> ‘clang::tooling::JSONAnchorDest’ defined but not used [-Wunused-variable]
> from gcc 5.1.
>
>
> Modified:
> cfe/trunk/lib/Tooling/CompilationDatabase.cpp
>
> Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=244312&r1=244311&r2=244312&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
> +++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Fri Aug  7 05:15:15 2015
> @@ -325,7 +325,7 @@ namespace tooling {
>  // This anchor is used to force the linker to link in the generated
> object file
>  // and thus register the JSONCompilationDatabasePlugin.
>  extern volatile int JSONAnchorSource;
> -static int JSONAnchorDest = JSONAnchorSource;
>

Perhaps this just needs __attribute__((used)) or __attribute__((unused))
(probably the latter) - I imagine we have macros for those?


> +int JSONAnchorDest = JSONAnchorSource;
>
>  } // end namespace tooling
>  } // end namespace clang
>
>
> ___
> 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: [PATCH] D11469: [OPENMP] Parsing and sema support for device clause

2015-08-07 Thread Michael Wong via cfe-commits
fraggamuffin added a comment.

This has landed.
Commit
C:\llvmtrunk\tools\clang\include\clang\AST\DataRecursiveASTVisitor.h
C:\llvmtrunk\tools\clang\include\clang\AST\OpenMPClause.h
C:\llvmtrunk\tools\clang\include\clang\AST\RecursiveASTVisitor.h
C:\llvmtrunk\tools\clang\include\clang\Basic\OpenMPKinds.def
C:\llvmtrunk\tools\clang\include\clang\Sema\Sema.h
C:\llvmtrunk\tools\clang\lib\AST\StmtPrinter.cpp
C:\llvmtrunk\tools\clang\lib\AST\StmtProfile.cpp
C:\llvmtrunk\tools\clang\lib\Basic\OpenMPKinds.cpp
C:\llvmtrunk\tools\clang\lib\CodeGen\CGStmtOpenMP.cpp
C:\llvmtrunk\tools\clang\lib\Parse\ParseOpenMP.cpp
C:\llvmtrunk\tools\clang\lib\Sema\SemaOpenMP.cpp
C:\llvmtrunk\tools\clang\lib\Sema\TreeTransform.h
C:\llvmtrunk\tools\clang\lib\Serialization\ASTReaderStmt.cpp
C:\llvmtrunk\tools\clang\lib\Serialization\ASTWriterStmt.cpp
C:\llvmtrunk\tools\clang\test\OpenMP\target_data_device_messages.cpp
C:\llvmtrunk\tools\clang\test\OpenMP\target_device_messages.cpp
C:\llvmtrunk\tools\clang\tools\libclang\CIndex.cpp
C:\llvmtrunk\tools\clang\lib\Serialization\ASTReaderStmt.cpp
C:\llvmtrunk\tools\clang\lib\AST\StmtProfile.cpp
C:\llvmtrunk\tools\clang\test\OpenMP\target_device_messages.cpp
C:\llvmtrunk\tools\clang\lib\Parse\ParseOpenMP.cpp
C:\llvmtrunk\tools\clang\lib\Basic\OpenMPKinds.cpp
C:\llvmtrunk\tools\clang\lib\Serialization\ASTWriterStmt.cpp
C:\llvmtrunk\tools\clang\tools\libclang\CIndex.cpp
C:\llvmtrunk\tools\clang\include\clang\Sema\Sema.h
C:\llvmtrunk\tools\clang\lib\AST\StmtPrinter.cpp
C:\llvmtrunk\tools\clang\lib\CodeGen\CGStmtOpenMP.cpp
C:\llvmtrunk\tools\clang\lib\Sema\TreeTransform.h
C:\llvmtrunk\tools\clang\include\clang\Basic\OpenMPKinds.def
C:\llvmtrunk\tools\clang\include\clang\AST\DataRecursiveASTVisitor.h
C:\llvmtrunk\tools\clang\include\clang\AST\OpenMPClause.h
C:\llvmtrunk\tools\clang\lib\Sema\SemaOpenMP.cpp
C:\llvmtrunk\tools\clang\test\OpenMP\target_data_device_messages.cpp
C:\llvmtrunk\tools\clang\include\clang\AST\RecursiveASTVisitor.h
At revision: 244325


http://reviews.llvm.org/D11469



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


[clang-tools-extra] r244329 - Silence gcc 5.1 unused variable warnings using LLVM_ATTRIBUTE_UNUSED.

2015-08-07 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Aug  7 11:37:34 2015
New Revision: 244329

URL: http://llvm.org/viewvc/llvm-project?rev=244329&view=rev
Log:
Silence gcc 5.1 unused variable warnings using LLVM_ATTRIBUTE_UNUSED.


Modified:
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=244329&r1=244328&r2=244329&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Fri Aug  7 
11:37:34 2015
@@ -336,19 +336,19 @@ static int clangTidyMain(int argc, const
 
 // This anchor is used to force the linker to link the LLVMModule.
 extern volatile int LLVMModuleAnchorSource;
-static int LLVMModuleAnchorDestination = LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination = 
LLVMModuleAnchorSource;
 
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
-static int GoogleModuleAnchorDestination = GoogleModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination = 
GoogleModuleAnchorSource;
 
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
-static int MiscModuleAnchorDestination = MiscModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination = 
MiscModuleAnchorSource;
 
 // This anchor is used to force the linker to link the ReadabilityModule.
 extern volatile int ReadabilityModuleAnchorSource;
-static int ReadabilityModuleAnchorDestination = ReadabilityModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination = 
ReadabilityModuleAnchorSource;
 
 } // namespace tidy
 } // namespace clang


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


Re: r244286 - Continue the work from r243908 by adding a Features field to Builtin::Info

2015-08-07 Thread Eric Christopher via cfe-commits
Ah, but not in the autoconf build. *sigh* We only check and added
-Wno-missing-field-initializers.

I've attempted to fix this in r244330.

-eric

On Thu, Aug 6, 2015 at 10:44 PM Craig Topper  wrote:

> I think it is on by default for clang builds
>
> # Turn off missing field initializer warnings for gcc to avoid noise
> from
> # false positives with empty {}. Turn them on otherwise (they're off by
> # default for clang).
> check_cxx_compiler_flag("-Wmissing-field-initializers"
> CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
> if (CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
>   if (CMAKE_COMPILER_IS_GNUCXX)
> append("-Wno-missing-field-initializers" CMAKE_C_FLAGS
> CMAKE_CXX_FLAGS)
>   else()
> append("-Wmissing-field-initializers" CMAKE_C_FLAGS
> CMAKE_CXX_FLAGS)
>   endif()
> endif()
>
> On Thu, Aug 6, 2015 at 10:35 PM, Eric Christopher 
> wrote:
>
>> Ah thanks Craig. Perhaps we should turn that one on by default?
>>
>> On Thu, Aug 6, 2015, 10:17 PM Craig Topper 
>> wrote:
>>
>>> This was causing -Wmissing-field-initializers to fire due to Features
>>> not being assigned in BUILTIN or LIBBUILTIN macro expansions. Fixed it in
>>> r244307.
>>>
>>> On Thu, Aug 6, 2015 at 3:11 PM, Eric Christopher via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: echristo
 Date: Thu Aug  6 17:11:54 2015
 New Revision: 244286

 URL: http://llvm.org/viewvc/llvm-project?rev=244286&view=rev
 Log:
 Continue the work from r243908 by adding a Features field to
 Builtin::Info
 so that we can populate it on a per-target basis with required features.

 Future commits will start using this information for warnings.

 Modified:
 cfe/trunk/include/clang/Basic/Builtins.h
 cfe/trunk/lib/Basic/Targets.cpp

 Modified: cfe/trunk/include/clang/Basic/Builtins.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=244286&r1=244285&r2=244286&view=diff

 ==
 --- cfe/trunk/include/clang/Basic/Builtins.h (original)
 +++ cfe/trunk/include/clang/Basic/Builtins.h Thu Aug  6 17:11:54 2015
 @@ -51,6 +51,7 @@ enum ID {
  struct Info {
const char *Name, *Type, *Attributes, *HeaderName;
LanguageID Langs;
 +  const char *Features;
  };

  /// \brief Holds information about both target-independent and
 @@ -166,6 +167,10 @@ public:
  return strchr(getRecord(ID).Attributes, 'e') != nullptr;
}

 +  const char *getRequiredFeatures(unsigned ID) const {
 +return getRecord(ID).Features;
 +  }
 +
  private:
const Info &getRecord(unsigned ID) const;


 Modified: cfe/trunk/lib/Basic/Targets.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=244286&r1=244285&r2=244286&view=diff

 ==
 --- cfe/trunk/lib/Basic/Targets.cpp (original)
 +++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug  6 17:11:54 2015
 @@ -2001,8 +2001,10 @@ void AMDGPUTargetInfo::getGCCRegNames(co
  // Namespace for x86 abstract base class
  const Builtin::Info BuiltinInfo[] = {
  #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES
 },
 -#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS,
 HEADER,\
 -  ALL_LANGUAGES },
 +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)
 \
 +  { #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES },
 +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)
  \
 +  { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES, FEATURE },
  #include "clang/Basic/BuiltinsX86.def"
  };



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

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


Re: [PATCH] D11797: [libclang] Expose the ElaboratedType

2015-08-07 Thread Sergey Kalinichev via cfe-commits
skalinichev updated this revision to Diff 31503.
skalinichev added a comment.

Fixed minor formatting issues.


http://reviews.llvm.org/D11797

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -190,6 +190,7 @@
 clang_getDiagnosticSeverity
 clang_getDiagnosticSpelling
 clang_getElementType
+clang_getElabaratedTypeUnderlyingType
 clang_getEnumConstantDeclUnsignedValue
 clang_getEnumConstantDeclValue
 clang_getEnumDeclIntegerType
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -90,6 +90,7 @@
 TKCASE(DependentSizedArray);
 TKCASE(Vector);
 TKCASE(MemberPointer);
+TKCASE(Elaborated);
 default:
   return CXType_Unexposed;
   }
@@ -484,6 +485,7 @@
 TKIND(DependentSizedArray);
 TKIND(Vector);
 TKIND(MemberPointer);
+TKIND(Elaborated);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -977,4 +979,14 @@
   return 0;
 }
 
+CXType clang_getElabaratedTypeUnderlyingType(CXType CT){
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP && TP->getTypeClass() == Type::Elaborated)
+return MakeCXType(cast(TP)->getNamedType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
+
 } // end: extern "C"
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,6 +48,8 @@
 };
 int Blob::*member_pointer;
 
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType();
+
 // RUN: c-index-test -test-print-type %s -std=c++11 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
@@ -61,7 +63,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -119,3 +121,6 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type ()] [typekind=FunctionProto] [canonicaltype=NS::Type ()] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * sizeof(int int] [typekind=Vector] [isPOD=1]
 // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] [typekind=Typedef] [can

Re: [PATCH] D11781: Refactored pthread usage in libcxx

2015-08-07 Thread Fulvio Esposito via cfe-commits
espositofulvio added inline comments.


Comment at: include/__mutex_base:246
@@ -266,3 +245,3 @@
 
-class _LIBCPP_TYPE_VIS condition_variable
+class _LIBCPP_TYPE_VIS condition_variable : private 
__libcxx_support::condition_variable
 {

theraven wrote:
> espositofulvio wrote:
> > theraven wrote:
> > > espositofulvio wrote:
> > > > theraven wrote:
> > > > > Does this change the ABI for a mutex on *NIX platforms?  We can't 
> > > > > change the class layout for existing platforms (though we can 
> > > > > indirect things via typedefs).
> > > > My hunch is that it doesn't, std::condition_variable has no data member 
> > > > now and the first base class (__libcxx_support::condition_variable) 
> > > > contains only pthread_cond_t which will be effectively laid out at the 
> > > > starting address of the object,  as it was previously for 
> > > > std::condition_variable,. I will check this out later in the evening 
> > > > though.
> > > I *think* that it's correct, but it's worth compiling a program that has 
> > > one compilation unit using the old header and another using the new one 
> > > and check that it's able to interoperate correctly.
> > > 
> > > Also check whether this depends on the implementation of the condition 
> > > variable.  On FreeBSD, the pthread types are all pointers (currently - 
> > > we're going to have some painful ABI breakage at some point when we move 
> > > them to being something that can live in shared memory).  In glibc, 
> > > they're structures.  I don't think that you'll end up with different 
> > > padding in the ABI from wrapping them in a class, but it's worth checking.
> > > it's worth compiling a program that has one compilation unit using the 
> > > old header and another using the new one and check that it's able to 
> > > interoperate correctly
> > 
> > Unfortunately this isn't going to work, some simbols are now defined in 
> > __libcxx_support and not in std (they are just made available through 
> > using), so an object file that includes the old header won't link against 
> > the new library (unreferenced symbols). The alternative is to create inline 
> > forwarding methods.
> > 
> > 
> > 
> That's going to need some more refactoring then.  Breaking the public ABI of 
> libc++ would be a show-stopper.
Yes, that's what I thought. In this case it's better to create a new diff and 
abandon this one or just update it?


Repository:
  rL LLVM

http://reviews.llvm.org/D11781



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


r244342 - Move the cpu validating virtual method down to the feature routines

2015-08-07 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Aug  7 13:31:25 2015
New Revision: 244342

URL: http://llvm.org/viewvc/llvm-project?rev=244342&view=rev
Log:
Move the cpu validating virtual method down to the feature routines
where it belongs.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=244342&r1=244341&r2=244342&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Aug  7 13:31:25 2015
@@ -636,9 +636,6 @@ public:
 }
   };
 
-  // Validate the contents of the __builtin_cpu_supports(const char*) argument.
-  virtual bool validateCpuSupports(StringRef Name) const { return false; }
-
   // validateOutputConstraint, validateInputConstraint - Checks that
   // a constraint is valid and provides information about it.
   // FIXME: These should return a real error instead of just true/false.
@@ -817,6 +814,10 @@ public:
   virtual bool hasFeature(StringRef Feature) const {
 return false;
   }
+
+  // \brief Validate the contents of the __builtin_cpu_supports(const char*)
+  // argument.
+  virtual bool validateCpuSupports(StringRef Name) const { return false; }
   
   // \brief Returns maximal number of args passed in registers.
   unsigned getRegParmMax() const {


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


[PATCH] D11842: [analyzer]Don't issue alarm in ObjCSuperCallChecker for the super class itself.

2015-08-07 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, jordan_rose, xazax.hun.
dcoughlin added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

The ObjCSuperCallChecker issues alarms for various Objective-C APIs that require
a subclass to call to its superclass's version of a method when overriding it.
So, for example, it raises an alarm when the -viewDidLoad method in a subclass 
of UIViewController does not call [super viewDidLoad].

This patch fixes a false alarm where the analyzer erroneously required the
implementation of the superclass itself (e.g., UIViewController) to call
super.

http://reviews.llvm.org/D11842

Files:
  lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
  test/Analysis/superclass.m

Index: test/Analysis/superclass.m
===
--- test/Analysis/superclass.m
+++ test/Analysis/superclass.m
@@ -30,7 +30,7 @@
 - (void)didReceiveMemoryWarning;
 - (void)removeFromParentViewController;
 - (void)transitionFromViewController:(UIViewController *)fromViewController
-  toViewController:(UIViewController *)toViewController 
+  toViewController:(UIViewController *)toViewController
   duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
   animations:(void (^)(void))animations
   completion:(void (^)(BOOL finished))completion;
@@ -69,6 +69,25 @@
 - (void)encodeRestorableStateWithCoder:(NSCoder *)coder {}
 @end
 
+// Do not warn for the implementation in the superclass itself.
+@implementation UIViewController
+- (void)addChildViewController:(UIViewController *)childController {}
+- (void)viewDidAppear:(BOOL)animated {}
+- (void)viewDidDisappear:(BOOL)animated {}
+- (void)viewDidUnload {}
+- (void)viewDidLoad {}
+- (void)viewWillUnload {}
+- (void)viewWillAppear:(BOOL)animated {}
+- (void)viewWillDisappear:(BOOL)animated {}
+- (void)didReceiveMemoryWarning {}
+- (void)removeFromParentViewController {}
+- (void)transitionFromViewController:(UIViewController *)fromViewController
+  toViewController:(UIViewController *)toViewController
+  duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
+  animations:(void (^)(void))animations
+  completion:(void (^)(BOOL finished))completion {}
+@end
+
 // Warn if UIViewController is our superclass and we do not call super
 @interface TestB : UIViewController {}
 @end
Index: lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
@@ -88,7 +88,7 @@
 /// \param[out] SuperclassName On return, the found superclass name.
 bool ObjCSuperCallChecker::isCheckableClass(const ObjCImplementationDecl *D,
 StringRef &SuperclassName) const {
-  const ObjCInterfaceDecl *ID = D->getClassInterface();
+  const ObjCInterfaceDecl *ID = D->getClassInterface()->getSuperClass();
   for ( ; ID ; ID = ID->getSuperClass())
   {
 SuperclassName = ID->getIdentifier()->getName();


Index: test/Analysis/superclass.m
===
--- test/Analysis/superclass.m
+++ test/Analysis/superclass.m
@@ -30,7 +30,7 @@
 - (void)didReceiveMemoryWarning;
 - (void)removeFromParentViewController;
 - (void)transitionFromViewController:(UIViewController *)fromViewController
-  toViewController:(UIViewController *)toViewController 
+  toViewController:(UIViewController *)toViewController
   duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
   animations:(void (^)(void))animations
   completion:(void (^)(BOOL finished))completion;
@@ -69,6 +69,25 @@
 - (void)encodeRestorableStateWithCoder:(NSCoder *)coder {}
 @end
 
+// Do not warn for the implementation in the superclass itself.
+@implementation UIViewController
+- (void)addChildViewController:(UIViewController *)childController {}
+- (void)viewDidAppear:(BOOL)animated {}
+- (void)viewDidDisappear:(BOOL)animated {}
+- (void)viewDidUnload {}
+- (void)viewDidLoad {}
+- (void)viewWillUnload {}
+- (void)viewWillAppear:(BOOL)animated {}
+- (void)viewWillDisappear:(BOOL)animated {}
+- (void)didReceiveMemoryWarning {}
+- (void)removeFromParentViewController {}
+- (void)transitionFromViewController:(UIViewController *)fromViewController
+  toViewController:(UIViewController *)toViewController
+  duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
+  animations:(void (^)(void))animations
+  completion:(void (^)(BOOL finished))completion {}
+@end
+
 // Warn if UIViewController is our superclass and we do not call super
 @interface TestB : UIViewController {}
 @end
Index: lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
+++ lib/StaticAnalyze

Re: [PATCH] D11842: [analyzer]Don't issue alarm in ObjCSuperCallChecker for the super class itself.

2015-08-07 Thread Jordan Rose via cfe-commits
jordan_rose accepted this revision.
jordan_rose added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this.


http://reviews.llvm.org/D11842



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


Re: r243851 - Fix invalid shufflevector operands

2015-08-07 Thread Simon Pilgrim via cfe-commits

On 06/08/2015 18:05, Hans Wennborg wrote:

On Sun, Aug 2, 2015 at 8:28 AM, Simon Pilgrim  wrote:

Author: rksimon
Date: Sun Aug  2 10:28:10 2015
New Revision: 243851

URL: http://llvm.org/viewvc/llvm-project?rev=243851&view=rev
Log:
Fix invalid shufflevector operands

This patch fixes bug 23800 ( https://llvm.org/bugs/show_bug.cgi?id=23800#c2 ). 
There existed a case where the index operand from extractelement was directly 
used to create a shufflevector mask. Since the index can be of any integral 
type but the mask must only contain 32 bit integers a 64 bit index operand led 
to an assertion error later on.

Committed on behalf of mpflanzer (Moritz Pflanzer)

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

Is this something we should merge to 3.7?
It is an edge case and not a regression - at best it would be a 'nice to 
have'. But it would be a very straightforward merge.

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


[PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-08-07 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a subscriber: cfe-commits.

If an import directive was put into wrong context, the error message was 
obscure,
complaining on misbalanced braces. To get more descriptive messages, annotation
tokens related to modules are processed where they must not be seen.

http://reviews.llvm.org/D11844

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  test/Modules/auto-module-import.m
  test/Modules/malformed.cpp
  test/Modules/misplaced.cpp

Index: test/Modules/misplaced.cpp
===
--- /dev/null
+++ test/Modules/misplaced.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
+
+namespace N1 {  // expected-note{{namespace 'N1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within namespace 'N1'}}
+}
+
+void func1() {  // expected-note{{function 'func1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within function 'func1'}}
+}
+
+struct S1 {  // expected-note{{'S1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within 'S1'}}
+};
Index: test/Modules/malformed.cpp
===
--- test/Modules/malformed.cpp
+++ test/Modules/malformed.cpp
@@ -12,20 +12,18 @@
 #include STR(HEADER)
 
 // CHECK-A: While building module 'malformed_a'
-// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}'
-// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} note: to match this '{'
+// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: import of module 'malformed_a.a1' appears within function
+// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} note: function 'f' begins here
 //
 // CHECK-A: While building module 'malformed_a'
-// CHECK-A: {{^}}Inputs/malformed/a2.h:1:{{.*}} error: extraneous closing brace
 
 // CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: expected '}'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: to match this '{'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:3:{{.*}} error: extraneous closing brace ('}')
+// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: import of module 'malformed_b.b2' appears within 'S'
+// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: 'S' begins here
 //
 // CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} error: redefinition of 'g'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} note: previous definition is here
+// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} error: import of module 'malformed_b.b2' appears within 'S'
+// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: 'S' begins here
 
 void test() { f(); }
 // Test that we use relative paths to name files within an imported module.
Index: test/Modules/auto-module-import.m
===
--- test/Modules/auto-module-import.m
+++ test/Modules/auto-module-import.m
@@ -83,6 +83,6 @@
   return not_in_module;
 }
 
-void includeNotAtTopLevel() { // expected-note {{to match this '{'}}
-  #include  // expected-warning {{treating #include as an import}} expected-error {{expected '}'}}
-} // expected-error {{extraneous closing brace}}
+void includeNotAtTopLevel() { // expected-note {{function 'includeNotAtTopLevel' begins here}}
+  #include  // expected-warning {{treating #include as an import}} expected-error {{import of module 'NoUmbrella.A' appears within function 'includeNotAtTopLevel'}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -14244,16 +14244,15 @@
   return New;
 }
 
-static void checkModuleImportContext(Sema &S, Module *M,
- SourceLocation ImportLoc,
- DeclContext *DC) {
+void Sema::checkModuleImportContext(Module *M, SourceLocation ImportLoc,
+DeclContext *DC) {
   if (auto *LSD = dyn_cast(DC)) {
 switch (LSD->getLanguage()) {
 case LinkageSpecDecl::lang_c:
   if (!M->IsExternC) {
-S.Diag(ImportLoc, diag::err_module_import_in_extern_c)
+Diag(ImportLoc, diag::err_module_import_in_extern_c)
   << M->getFullModuleName();
-S.Diag(LSD->getLocStart(), diag::note_module_import_in_extern_c);
+Diag(LSD->getLocStart(), diag::note_module_import_in_extern_c);
 return;
   }
   break;
@@ -14266,10 +14265,10 @@
   while (isa(DC))
 DC = DC->getParent();
   if (!isa(DC)) {
-S.Diag(ImportLoc, diag::err_module_import_not_at_top_level)
+Diag(ImportLoc, diag::err_module_import_not_at_top_level)
   << M->getFullModuleName() << DC;
-S.Diag(cas

[PATCH] D11845: Properly pass through the PIC mode to the integrated assembler when doing assembly-only, and unify the Driver's PIC argument parsing.

2015-08-07 Thread James Y Knight via cfe-commits
jyknight created this revision.
jyknight added reviewers: rnk, echristo.
jyknight added a subscriber: cfe-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

On a few architectures, parsing of assembly files annoyingly depends
on whether PIC is enabled or not. This was handled for external 'as'
already (passing -KPIC), but was missed for calls to the standalone
internal assembler.

The integrated-as.s test needed to be modified to not expect
-fsanitize=address to be unused, as now fsanitize *IS* used for
assembly, since -fsanitize=memory can sometimes imply -fPIE, which the
assembler needs to know (gack!!).

http://reviews.llvm.org/D11845

Files:
  include/clang/Driver/CC1Options.td
  lib/Driver/Tools.cpp
  test/Driver/integrated-as.s

Index: test/Driver/integrated-as.s
===
--- test/Driver/integrated-as.s
+++ test/Driver/integrated-as.s
@@ -5,9 +5,6 @@
 // RUN: %clang -### -c -integrated-as -Wa,-L %s 2>&1 | FileCheck --check-prefix=OPT_L %s
 // OPT_L: msave-temp-labels
 
-// RUN: %clang -### -target x86_64-linux-gnu -c -integrated-as %s -fsanitize=address 2>&1 %s | FileCheck --check-prefix=SANITIZE %s
-// SANITIZE: argument unused during compilation: '-fsanitize=address'
-
 // Test that -I params in -Wa, and -Xassembler args are passed to integrated assembler
 // RUN: %clang -### -c -integrated-as %s -Wa,-I,foo_dir 2>&1 | FileCheck --check-prefix=WA_INCLUDE1 %s
 // WA_INCLUDE1: cc1as
@@ -46,3 +43,6 @@
 
 // RUN: %clang -### -x assembler -c -integrated-as %s -I myincludedir 2>&1 | FileCheck --check-prefix=INCLUDEPATH %s
 // INCLUDEPATH: "-I" "myincludedir"
+
+// RUN: %clang -### -x assembler -c -fPIC -integrated-as %s 2>&1 | FileCheck --check-prefix=PIC %s
+// PIC: "-mrelocation-model" "pic"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -32,15 +32,16 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
-#include "llvm/Support/TargetParser.h"
+#include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/TargetParser.h"
 
 #ifdef LLVM_ON_UNIX
 #include  // For getuid().
@@ -51,21 +52,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-static void addAssemblerKPIC(const ArgList &Args, ArgStringList &CmdArgs) {
-  Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
-options::OPT_fpic, options::OPT_fno_pic,
-options::OPT_fPIE, options::OPT_fno_PIE,
-options::OPT_fpie, options::OPT_fno_pie);
-  if (!LastPICArg)
-return;
-  if (LastPICArg->getOption().matches(options::OPT_fPIC) ||
-  LastPICArg->getOption().matches(options::OPT_fpic) ||
-  LastPICArg->getOption().matches(options::OPT_fPIE) ||
-  LastPICArg->getOption().matches(options::OPT_fpie)) {
-CmdArgs.push_back("-KPIC");
-  }
-}
-
 /// CheckPreprocessingOptions - Perform some validation of preprocessing
 /// arguments that is shared with gcc.
 static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
@@ -2938,9 +2924,169 @@
   }
 }
 
+/// Parses the various -fpic/-fPIC/-fpie/-fPIE arguments.  Then,
+/// smooshes them together with platform defaults, to decide with
+/// whether this compile should be using PIC mode or not. Returns the
+/// answer in a tuple of (RelocationModel, PICLevel, IsPIE).
+static std::tuple
+ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &Triple,
+ const ArgList &Args) {
+  // FIXME: why does this code...and so much everywhere else, use both
+  // ToolChain.getTriple() and Triple?
+  bool PIE = ToolChain.isPIEDefault();
+  bool PIC = PIE || ToolChain.isPICDefault();
+  bool IsPICLevelTwo = PIC;
+
+  bool KernelOrKext =
+  Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
+
+  // Android-specific defaults for PIC/PIE
+  if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
+switch (ToolChain.getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::armeb:
+case llvm::Triple::thumb:
+case llvm::Triple::thumbeb:
+case llvm::Triple::aarch64:
+case llvm::Triple::mips:
+case llvm::Triple::mipsel:
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
+  PIC = true; // "-fpic"
+  break;
+
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  PIC = true; // "-fPIC"
+  IsPICLevelTwo = true;
+  break;
+
+default:
+  break;
+}
+  }
+
+  // OpenBSD-specific defaults for PIE
+  if (ToolChain.getTriple().getOS() == llvm::Trip

Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-08-07 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

This doesn't recover from the errors properly any more (leaving junk behind in 
the 'current module' stack), and somewhat breaks the original purpose of these 
checks, which is to detect and diagnose missing close braces. Here's what I 
suggest:

1. Keep the `isEofOrEom` calls as-is.
2. Diagnose the unexpected EOM tokens as you do now (but customize the 
diagnostics in the case of a module_end token).
3. Once you've diagnosed an EOM token, don't consume it; instead update the 
annotation so you know not to diagnose it again, and bail out of parsing the 
current construct.

Then, when we hit an EOM, we'll diagnose it once at the innermost level, bail 
out all the way to the top level, and then handle it properly.



Comment at: include/clang/Sema/Sema.h:1781-1784
@@ -1780,1 +1780,6 @@
 
+  /// \brief Check if module import may be found in the specified context,
+  /// emit error if not.
+  void checkModuleImportContext(Module *M, SourceLocation ImportLoc,
+DeclContext *DC);
+

I don't think this is the right interface. The calls from the parser expect an 
error to be issued, and don't do the right thing if the module import is valid, 
so this should instead be called something more like 
`diagnoseMisplacedModuleImport`, and should either assert if the current 
context allows module imports or not perform the check.


Comment at: lib/Parse/ParseDeclCXX.cpp:2856-2863
@@ -2855,1 +2855,10 @@
 
+  if (Tok.isOneOf(tok::annot_module_include,
+  tok::annot_module_begin,
+  tok::annot_module_end)) {
+Actions.checkModuleImportContext(reinterpret_cast(
+Tok.getAnnotationValue()), Tok.getLocation(), Actions.CurContext);
+ConsumeToken();
+return DeclGroupPtrTy();
+  }
+

Please factor this out into a `bool TryParseMisplacedModuleImport()` function.


Comment at: lib/Parse/ParseDeclCXX.cpp:2857-2858
@@ +2856,4 @@
+  if (Tok.isOneOf(tok::annot_module_include,
+  tok::annot_module_begin,
+  tok::annot_module_end)) {
+Actions.checkModuleImportContext(reinterpret_cast(

For module_end, we probably still want to give the "missing '}'" diagnostic, 
because that's almost certainly the problem if we reach the end of a module 
while still within a function or namespace. Maybe pass a flag into 
`checkModuleImportContext` to say whether you're entering or leaving the module?


Comment at: lib/Parse/ParseDeclCXX.cpp:2861-2862
@@ +2860,4 @@
+Tok.getAnnotationValue()), Tok.getLocation(), Actions.CurContext);
+ConsumeToken();
+return DeclGroupPtrTy();
+  }

This is not a good way to recover from the problem: for that, we should 
probably do what we used to do, and bail out to the top level.


http://reviews.llvm.org/D11844



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


[Patch][LoopVectorize] Print vectorization analysis when loop hint pragma is specified

2015-08-07 Thread Tyler Nowicki via cfe-commits
Hi,Currently, when loop hint is used but vectorization fails we generate a warning. To get the analysis the user needs to provide the command line option -Rpass-analysis= with the correct pass name. BUT we don’t tell the user which pass name they will need to get the analysis message. We should be displaying the analysis without having to request it. These patches print the analysis information when vectorization fails on loops with hints when the compiler option ‘-Rpass-analysis’ is provided without ‘='. Users of loop hints can provide the compiler option with their regular debug builds to ensure they always get the analysis when vectorization fails. This approach is preferred because diagnostic printing needs line number tracking which is not enabled by normally. Specifying the option without a pass-target enables line number tracking and makes viewing the messages optional.The LLVM patches modify the pass-name of the diagnostic to DiagnosticInfo::AlwaysPrint, which is an empty const char*. The use of DiagnosticInfo::AlwaysPrint is recognized when filtering the diagnostics allowing the message to be printed even if the filter doesn’t match. Note that the analysis of loops with hints will always be printed whenever the compiler option is provided even if ‘=' is specified. This allows both types of analyses to be printed at the same time rather than hiding the analysis on loops with hints with an pass-target is given.*These patches build on several previous patches still in review to add late-diagnostics for fp-commut and aliasing. See threads 'Late evaluation of vectorization requirements’ and 'Late evaluate of runtime pointer check's threshold'.Comments and reviews are much appreciated!Tyler(sorry if you received this twice. I used the wrong mailing list addresses)

Clang-When-Rpass-analysis-is-provided-print-all-analyses.patch
Description: Binary data


LLVM-1-Simplify-processLoop.patch
Description: Binary data


LLVM-2-Moved-LoopVectorizeHints.patch
Description: Binary data


LLVM-3-Modify-pass-name-when-vectorization-fails-with-loop-hints.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11848: AST: Implement mangling support for function types without a prototype.

2015-08-07 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: lib/AST/ItaniumMangle.cpp:2060-2062
@@ -2058,2 +2059,5 @@
 void CXXNameMangler::mangleType(const FunctionNoProtoType *T) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  // Function types without prototypes can arise when mangling a function type
+  // within an overloadable function in C. We mangle these as we do a function
+  // with an empty variadic argument list in C++.
+  Out << 'F';

This seems like a suboptimal mangling; a no-prototype function type is not 
compatible with a varargs function type, and in particular may have a different 
calling convention across a C/C++ ABI boundary. How about instead mangling this 
as the absence of any parameter types? (That is, drop the `z`, and mangle your 
testcase below as just `_Z1fPFvzE`.) libc++abi already demangles that as 
desired (but libstdc++ considers it an invalid mangled name).


http://reviews.llvm.org/D11848



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


Re: [PATCH] D11848: AST: Implement mangling support for function types without a prototype.

2015-08-07 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:2060-2062
@@ -2058,2 +2059,5 @@
 void CXXNameMangler::mangleType(const FunctionNoProtoType *T) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  // Function types without prototypes can arise when mangling a function type
+  // within an overloadable function in C. We mangle these as we do a function
+  // with an empty variadic argument list in C++.
+  Out << 'F';

rsmith wrote:
> This seems like a suboptimal mangling; a no-prototype function type is not 
> compatible with a varargs function type, and in particular may have a 
> different calling convention across a C/C++ ABI boundary. How about instead 
> mangling this as the absence of any parameter types? (That is, drop the `z`, 
> and mangle your testcase below as just `_Z1fPFvzE`.) libc++abi already 
> demangles that as desired (but libstdc++ considers it an invalid mangled 
> name).
Do you mean `_Z1fPFvE`? Sounds reasonable to me. I guess on the MS side we can 
use `@` instead of `Z` to create the distinction there.


http://reviews.llvm.org/D11848



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


Re: [PATCH] clang-format: Add "AllowShortNamespacesOnASingleLine" option

2015-08-07 Thread Daniel Jasper via cfe-commits
Would it be possible to send the patch through reviews.llvm.org? It makes
review much easier for me.

On Thu, Aug 6, 2015 at 6:18 PM, chris beck via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Rationale:
>
> I sometimes use a different clang tool, iwyu ("include what you use"), to
> clean up header file inclusions in my C++ projects. Iwyu seeks to correct
> the includes of a header or cpp unit so that definitions which are needed
> are included, and definitions which only need to be forward declared are
> forward declared. It often generates code like this at the top of your file:
>
> namespace foo { class bar; }
> namespace baz { struct quaz; }
> ...
>
> Unfortunately, clang-format dislikes braces which are arranged this way
> and always wants to break after them, and after the forward declaration, no
> matter what configuration options are used (as far as I can tell).
>
> I wrote a small patch so that short namespaces like these can be set on a
> single line regardless of chosen brace-style if a boolean option
> "AllowShortNamespacesOnASingleLine" is enabled, please find attached.
>
> Best Regards,
> Chris Beck
>
> ___
> 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: [PATCH] D11848: AST: Implement mangling support for function types without a prototype.

2015-08-07 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:2060-2062
@@ -2058,2 +2059,5 @@
 void CXXNameMangler::mangleType(const FunctionNoProtoType *T) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  // Function types without prototypes can arise when mangling a function type
+  // within an overloadable function in C. We mangle these as we do a function
+  // with an empty variadic argument list in C++.
+  Out << 'F';

pcc wrote:
> rsmith wrote:
> > This seems like a suboptimal mangling; a no-prototype function type is not 
> > compatible with a varargs function type, and in particular may have a 
> > different calling convention across a C/C++ ABI boundary. How about instead 
> > mangling this as the absence of any parameter types? (That is, drop the 
> > `z`, and mangle your testcase below as just `_Z1fPFvzE`.) libc++abi already 
> > demangles that as desired (but libstdc++ considers it an invalid mangled 
> > name).
> Do you mean `_Z1fPFvE`? Sounds reasonable to me. I guess on the MS side we 
> can use `@` instead of `Z` to create the distinction there.
Er, yes, thanks :)


http://reviews.llvm.org/D11848



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


Re: [PATCH] D11848: AST: Implement mangling support for function types without a prototype.

2015-08-07 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 31546.
pcc added a comment.

- Use a mangling distinct from (...) as suggested by Richard


http://reviews.llvm.org/D11848

Files:
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  test/CodeGen/mangle-ms.c
  test/CodeGen/overloadable.c

Index: test/CodeGen/overloadable.c
===
--- test/CodeGen/overloadable.c
+++ test/CodeGen/overloadable.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
 // CHECK: _Z1fPA10_1X
+// CHECK: _Z1fPFvE
 
 int __attribute__((overloadable)) f(int x) { return x; }
 float __attribute__((overloadable)) f(float x) { return x; }
@@ -13,6 +14,8 @@
 
 void __attribute__((overloadable)) f(int x, int y, ...) { }
 
+void __attribute__((overloadable)) f(void (*x)()) {}
+
 int main() {
   int iv = 17;
   float fv = 3.0f;
Index: test/CodeGen/mangle-ms.c
===
--- /dev/null
+++ test/CodeGen/mangle-ms.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s
+
+// CHECK: define void @"\01?f@@$$J0YAXP6AX@Z@Z"
+__attribute__((overloadable)) void f(void (*x)()) {}
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1620,15 +1620,16 @@
 }
 void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T,
  Qualifiers, SourceRange) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  Out << "$$A6";
+  mangleFunctionType(T);
 }
 
 void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T,
  const FunctionDecl *D,
  bool ForceThisQuals) {
   //  ::=  
   //   
-  const FunctionProtoType *Proto = cast(T);
+  const FunctionProtoType *Proto = dyn_cast(T);
 
   SourceRange Range;
   if (D) Range = D->getSourceRange();
@@ -1699,7 +1700,7 @@
 }
 Out << '@';
   } else {
-QualType ResultType = Proto->getReturnType();
+QualType ResultType = T->getReturnType();
 if (const auto *AT =
 dyn_cast_or_null(ResultType->getContainedAutoType())) {
   Out << '?';
@@ -1717,7 +1718,12 @@
   //  ::= X # void
   // ::= + @
   // ::= * Z # varargs
-  if (Proto->getNumParams() == 0 && !Proto->isVariadic()) {
+  if (!Proto) {
+// Function types without prototypes can arise when mangling a function type
+// within an overloadable function in C. We mangle these as the absence of
+// any parameter types (not even an empty parameter list).
+Out << '@';
+  } else if (Proto->getNumParams() == 0 && !Proto->isVariadic()) {
 Out << 'X';
   } else {
 // Happens for function pointer type arguments for example.
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -2055,9 +2055,23 @@
 
   Out << 'E';
 }
+
 void CXXNameMangler::mangleType(const FunctionNoProtoType *T) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  // Function types without prototypes can arise when mangling a function type
+  // within an overloadable function in C. We mangle these as the absence of any
+  // parameter types (not even an empty parameter list).
+  Out << 'F';
+
+  FunctionTypeDepthState saved = FunctionTypeDepth.push();
+
+  FunctionTypeDepth.enterResultType();
+  mangleType(T->getReturnType());
+  FunctionTypeDepth.leaveResultType();
+
+  FunctionTypeDepth.pop(saved);
+  Out << 'E';
 }
+
 void CXXNameMangler::mangleBareFunctionType(const FunctionType *T,
 bool MangleReturnType) {
   // We should never be mangling something without a prototype.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10356: scan-build: Add --analyzer-target option

2015-08-07 Thread Ted Kremenek via cfe-commits
krememek added a comment.

In http://reviews.llvm.org/D10356#217564, @honggyu.kim wrote:

>




> With --analyzer-target option, we can provide target info to clang static 
> analyzer as follows:

> 

> $ scan-build -v -v -v --analyzer-target=arm-linux-gnueabi 
> --use-cc=arm-linux-gnueabi-gcc make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

> 

>   ...

>   CC  arch/arm/kernel/opcodes.o

> 

> 1. compilation works the same as before ``` arm-linux-gnueabi-gcc ... 
> -march=armv7-a ... -c -o arch/arm/kernel/opcodes.o arch/arm/kernel/opcodes.c 
> ```

> 2. analysis uses the target triple that is given by --analyzer-target option 
> and analysis works fine then. ``` 'clang' '-cc1' '-triple' 
> 'armv7--linux-gnueabi' '-analyze' ... '-target-cpu' 'cortex-a8' ... 
> 'arch/arm/kernel/opcodes.c') ```

> 

>   So we have to use the same target triple for compilation and analysis by 
> using this option. Please let me know if there's a better way to fix this 
> issue.


I see.  The problem is that the ad hoc interposition that scan-build uses does 
not handle the case that the underlying compiler is built as a cross-compiler, 
but does not take a direct target triple.  That compiler only builds for the 
other target, unlike clang which is a cross-compiler.

In that case, I am fine with taking this change.  That you for explaining it.


http://reviews.llvm.org/D10356



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


Re: [PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

2015-08-07 Thread strager via cfe-commits
strager added a comment.

(Sorry for the late feedback.)



Comment at: docs/ClangFormatStyleOptions.rst:221
@@ -220,2 +220,3 @@
 
-**AlwaysBreakAfterDefinitionReturnType** 
(``DefinitionReturnTypeBreakingStyle``)
+**AlwaysBreakAfterDeclarationReturnType** (``ReturnTypeBreakingStyle``)
+  The function declaration return type breaking style to use.

djasper wrote:
> Do you think it'll ever make sense to break differently for declarations and 
> definitions? I think having two entirely independent configuration flags 
> gives us 9 combinations (assuming the three enum values will remain) out of 
> which many will never be used.
> 
> I see two alternatives:
> Add an additional bool flag "TreatDeclarationsLikeDefinitions" (name might 
> not be ideal yet).
> Change existing flag name to AlwaysBreakAfterReturnType and use five enum 
> values (None, TopLevel, All, TopLevelDefinitions, AllDefinitions).
> 
> What do you think?
> 
> Sorry for being very picky on this. The problem is that these options stick 
> around for a long time and we need to think about them carefully.
> I think having two entirely independent configuration flags gives us 9 
> combinations (assuming the three enum values will remain) out of which many 
> will never be used.

I agree that many combinations will be unused. I don't see why we should 
conflate the two if they are configured independently in practice, though.

> Add an additional bool flag "TreatDeclarationsLikeDefinitions" (name might 
> not be ideal yet).
> Change existing flag name to AlwaysBreakAfterReturnType and use five enum 
> values (None, TopLevel, All, TopLevelDefinitions, AllDefinitions).

What about styles where declarations have return types on their own line, but 
definitions don't? I don't see a reason to prevent that style.


Comment at: lib/Format/ContinuationIndenter.cpp:129-132
@@ -128,5 +128,6 @@
   if (Current.is(TT_FunctionDeclarationName) &&
   Style.AlwaysBreakAfterDefinitionReturnType == FormatStyle::DRTBS_None &&
+  Style.AlwaysBreakAfterDeclarationReturnType == FormatStyle::DRTBS_None &&
   State.Column < 6)
 return false;
 

djasper wrote:
> What do you mean exactly?
See `IsDefinition` in `lib/Format/TokenAnnotator.cpp` introduced by this diff. 
The logic here and there should match, I think.


http://reviews.llvm.org/D10370



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


Re: [PATCH] D11693: clang-format: Support generalized lambda captures.

2015-08-07 Thread strager via cfe-commits
strager added a comment.

ping


http://reviews.llvm.org/D11693



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


[PATCH] D11850: Delay emitting members of dllexport classes until the class is fully parsed (PR23542)

2015-08-07 Thread Hans Wennborg via cfe-commits
hans created this revision.
hans added a reviewer: rsmith.
hans added subscribers: cfe-commits, hansw.

This enables Clang to correctly handle code such as:

```
struct __declspec(dllexport) S {
  int x = 42;
};
```

where it would otherwise assert due to trying to generate the default 
constructor before the in-class initializer for x has been parsed.

http://reviews.llvm.org/D11850

Files:
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport.cpp

Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -544,6 +544,7 @@
 struct __declspec(dllexport) B {
   B(A = 0) {}
 };
+
 }
 //
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FB@PR23801@@QAEXXZ"({{.*}}) comdat
@@ -611,7 +612,6 @@
   B::~B() { }
   // Emit a alias definition of B's constructor.
   // M32-DAG: @"\01??1B@UseDtorAlias@@QAE@XZ" = dllexport alias {{.*}} @"\01??1A@UseDtorAlias@@QAE@XZ"
-
 }
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
@@ -729,6 +729,43 @@
 template struct __declspec(dllexport) PR23770DerivedTemplate;
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$PR23770BaseTemplate@H@@QAEXXZ"
 
+namespace InClassInits {
+
+struct __declspec(dllexport) S {
+  int x = 42;
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::S"* @"\01??0S@InClassInits@@QAE@XZ"
+
+// dllexport an already instantiated class template.
+template  struct Base {
+  int x = 42;
+};
+Base base;
+struct __declspec(dllexport) T : Base { };
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::Base"* @"\01??0?$Base@H@InClassInits@@QAE@XZ"
+
+struct A { A(int); };
+struct __declspec(dllexport) U {
+  // Class with both default constructor closure and in-class initializer.
+  U(A = 0) {}
+  int x = 0;
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::U"* @"\01??0U@InClassInits@@QAE@UA@1@@Z"
+
+struct Evil {
+  template  struct Base {
+int x = 0;
+  };
+  struct S : Base {};
+  // The already instantiated Base becomes dllexported below, but the
+  // in-class initializer for Base<>::x still hasn't been parsed, so emitting
+  // the default ctor must still be delayed.
+  struct __declspec(dllexport) T : Base {};
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::Evil::Base"* @"\01??0?$Base@H@Evil@InClassInits@@QAE@XZ"
+
+}
+
 
 //===--===//
 // Classes with template base classes
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -4682,6 +4682,60 @@
   }
 }
 
+static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class) {
+  Attr *ClassAttr = getDLLAttr(Class);
+  if (!ClassAttr)
+return;
+
+  assert(ClassAttr->getKind() == attr::DLLExport);
+
+  TemplateSpecializationKind TSK = Class->getTemplateSpecializationKind();
+
+  for (Decl *Member : Class->decls()) {
+auto *MD = dyn_cast(Member);
+if (!MD)
+  continue;
+
+if (Member->getAttr()) {
+  if (TSK == TSK_ExplicitInstantiationDeclaration)
+// Don't go any further if this is just an explicit instantiation
+// declaration.
+continue;
+
+  if (MD->isUserProvided()) {
+// Instantiate non-default class member functions ...
+
+// .. except for certain kinds of template specializations.
+if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
+  continue;
+
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+
+// The function will be passed to the consumer when its definition is
+// encountered.
+  } else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
+ MD->isCopyAssignmentOperator() ||
+ MD->isMoveAssignmentOperator()) {
+// Synthesize and instantiate non-trivial implicit methods, explicitly
+// defaulted methods, and the copy and move assignment operators. The
+// latter are exported even if they are trivial, because the address of
+// an operator can be taken and should compare equal accross libraries.
+DiagnosticErrorTrap Trap(S.Diags);
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+if (Trap.hasErrorOccurred()) {
+  S.Diag(ClassAttr->getLocation(), diag::note_due_to_dllexported_class)
+  << Class->getName() << !S.getLangOpts().CPlusPlus11;
+  break;
+}
+
+// There is no later point when we will see the definition of this
+// function, so pass it to the consumer now.
+S.Consumer.HandleTopLevelDecl(DeclGroupRef(MD));
+  }
+}
+  }
+}
+
 /// \brief Check class-level dllimport/dllexport attribute.
 void Sema::checkClassLevelDLLAtt

r244370 - [Sparc] XFAIL CodeGen/atomic_ops test.

2015-08-07 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Fri Aug  7 17:52:34 2015
New Revision: 244370

URL: http://llvm.org/viewvc/llvm-project?rev=244370&view=rev
Log:
[Sparc] XFAIL CodeGen/atomic_ops test.

Modified:
cfe/trunk/test/CodeGen/atomic_ops.c

Modified: cfe/trunk/test/CodeGen/atomic_ops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomic_ops.c?rev=244370&r1=244369&r2=244370&view=diff
==
--- cfe/trunk/test/CodeGen/atomic_ops.c (original)
+++ cfe/trunk/test/CodeGen/atomic_ops.c Fri Aug  7 17:52:34 2015
@@ -1,4 +1,5 @@
-// XFAIL: hexagon
+// XFAIL: hexagon,sparc
+//(due to not having native load atomic support)
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
 


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


Re: [PATCH] D2916: [libclang][python] Add test for Index read

2015-08-07 Thread Brian Gesiak via cfe-commits
modocache added a reviewer: ddunbar.
modocache added a subscriber: ddunbar.
modocache added a comment.

Adding @ddunbar, who added the original FIXME, as a reviewer.


http://reviews.llvm.org/D2916



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


Re: [PATCH] D11848: AST: Implement mangling support for function types without a prototype.

2015-08-07 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D11848



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


Re: [PATCH] D11848: AST: Implement mangling support for function types without a prototype.

2015-08-07 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL244374: AST: Implement mangling support for function types 
without a prototype. (authored by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D11848?vs=31546&id=31557#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11848

Files:
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/test/CodeGen/mangle-ms.c
  cfe/trunk/test/CodeGen/overloadable.c

Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -2055,9 +2055,23 @@
 
   Out << 'E';
 }
+
 void CXXNameMangler::mangleType(const FunctionNoProtoType *T) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  // Function types without prototypes can arise when mangling a function type
+  // within an overloadable function in C. We mangle these as the absence of any
+  // parameter types (not even an empty parameter list).
+  Out << 'F';
+
+  FunctionTypeDepthState saved = FunctionTypeDepth.push();
+
+  FunctionTypeDepth.enterResultType();
+  mangleType(T->getReturnType());
+  FunctionTypeDepth.leaveResultType();
+
+  FunctionTypeDepth.pop(saved);
+  Out << 'E';
 }
+
 void CXXNameMangler::mangleBareFunctionType(const FunctionType *T,
 bool MangleReturnType) {
   // We should never be mangling something without a prototype.
Index: cfe/trunk/lib/AST/MicrosoftMangle.cpp
===
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp
@@ -1620,15 +1620,16 @@
 }
 void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T,
  Qualifiers, SourceRange) {
-  llvm_unreachable("Can't mangle K&R function prototypes");
+  Out << "$$A6";
+  mangleFunctionType(T);
 }
 
 void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T,
  const FunctionDecl *D,
  bool ForceThisQuals) {
   //  ::=  
   //   
-  const FunctionProtoType *Proto = cast(T);
+  const FunctionProtoType *Proto = dyn_cast(T);
 
   SourceRange Range;
   if (D) Range = D->getSourceRange();
@@ -1699,7 +1700,7 @@
 }
 Out << '@';
   } else {
-QualType ResultType = Proto->getReturnType();
+QualType ResultType = T->getReturnType();
 if (const auto *AT =
 dyn_cast_or_null(ResultType->getContainedAutoType())) {
   Out << '?';
@@ -1717,7 +1718,12 @@
   //  ::= X # void
   // ::= + @
   // ::= * Z # varargs
-  if (Proto->getNumParams() == 0 && !Proto->isVariadic()) {
+  if (!Proto) {
+// Function types without prototypes can arise when mangling a function type
+// within an overloadable function in C. We mangle these as the absence of
+// any parameter types (not even an empty parameter list).
+Out << '@';
+  } else if (Proto->getNumParams() == 0 && !Proto->isVariadic()) {
 Out << 'X';
   } else {
 // Happens for function pointer type arguments for example.
Index: cfe/trunk/test/CodeGen/mangle-ms.c
===
--- cfe/trunk/test/CodeGen/mangle-ms.c
+++ cfe/trunk/test/CodeGen/mangle-ms.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s
+
+// CHECK: define void @"\01?f@@$$J0YAXP6AX@Z@Z"
+__attribute__((overloadable)) void f(void (*x)()) {}
Index: cfe/trunk/test/CodeGen/overloadable.c
===
--- cfe/trunk/test/CodeGen/overloadable.c
+++ cfe/trunk/test/CodeGen/overloadable.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
 // CHECK: _Z1fPA10_1X
+// CHECK: _Z1fPFvE
 
 int __attribute__((overloadable)) f(int x) { return x; }
 float __attribute__((overloadable)) f(float x) { return x; }
@@ -13,6 +14,8 @@
 
 void __attribute__((overloadable)) f(int x, int y, ...) { }
 
+void __attribute__((overloadable)) f(void (*x)()) {}
+
 int main() {
   int iv = 17;
   float fv = 3.0f;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [libclang] Expose the ElaboratedType

2015-08-07 Thread Brian Gesiak via cfe-commits
modocache added a subscriber: modocache.


Comment at: bindings/python/clang/cindex.py:1875
@@ -1873,1 +1874,3 @@
 
+def getElabaratedTypeUnderlyingType(self):
+"""

Awesome, thanks for updating the Python bindings as well!

As with the C function, I believe this is a typo--shouldn't it be 
`getElaboratedTypeUnderlyingType`?

Furthermore, the convention in Python (and in this file) is to use snake_case, 
so this should probably be `get_elaborated_type_underlying_type`.


Comment at: include/clang-c/Index.h:2859
@@ -2859,1 +2858,3 @@
+  CXType_MemberPointer = 117,
+  CXType_Elaborated = 118
 };

Tangential to this diff, but is there a reason these `CXTypeKind` enum values 
are undocumented? I can see how many would be familiar to most users, but I 
don't think "elaborated" is something that many users would immediately 
recognize. Should these be documented?


Comment at: include/clang-c/Index.h:3224
@@ -3222,1 +3223,3 @@
 /**
+ * \brief Return the inner type of elaborated type
+ *

nit: Other `\brief` documentation in this file uses periods at the end of 
sentences. For example, `clang_getArraySize`, the function immediately prior to 
this newly added function, has the brief `-\brief Return the array size of a 
constant array.`--notice the trailing period.


Comment at: include/clang-c/Index.h:3226
@@ +3225,3 @@
+ *
+ * If a non-elaborated type passed, CXType_Invalid type returned
+ */

nit: Rather than reference the `CXType_Invalid` type directly, most of the 
other documentation in this file states `"an invalid type is returned."`


Comment at: include/clang-c/Index.h:3228
@@ +3227,3 @@
+ */
+CXType clang_getElabaratedTypeUnderlyingType(CXType T);
+

I believe this is a typo--shouldn't it be 
`clang_getElaboratedTypeUnderlyingType`?


Comment at: tools/libclang/CXType.cpp:987
@@ +986,3 @@
+  if (TP && TP->getTypeClass() == Type::Elaborated)
+return MakeCXType(cast(TP)->getNamedType(), GetTU(CT));
+

The documentation of `getNamedType()` itself states `"Retrieve the type named 
by the qualified-id."`. As such, would it make sense to call this function 
`clang_getNamedTypeUnderlyingElaboratedType`, instead of 
`clang_getElaboratedTypeUnderlyingType`?


http://reviews.llvm.org/D11797



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


Re: [PATCH] D11850: Delay emitting members of dllexport classes until the class is fully parsed (PR23542)

2015-08-07 Thread Hans Wennborg via cfe-commits
hans updated this revision to Diff 31564.
hans added a comment.

Turns out ActOnFinishCXXMemberDefaultArgs needs to be re-entrant.


http://reviews.llvm.org/D11850

Files:
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport.cpp

Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -544,6 +544,7 @@
 struct __declspec(dllexport) B {
   B(A = 0) {}
 };
+
 }
 //
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FB@PR23801@@QAEXXZ"({{.*}}) comdat
@@ -611,7 +612,6 @@
   B::~B() { }
   // Emit a alias definition of B's constructor.
   // M32-DAG: @"\01??1B@UseDtorAlias@@QAE@XZ" = dllexport alias {{.*}} @"\01??1A@UseDtorAlias@@QAE@XZ"
-
 }
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
@@ -729,6 +729,54 @@
 template struct __declspec(dllexport) PR23770DerivedTemplate;
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$PR23770BaseTemplate@H@@QAEXXZ"
 
+namespace InClassInits {
+
+struct __declspec(dllexport) S {
+  int x = 42;
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::S"* @"\01??0S@InClassInits@@QAE@XZ"
+
+// dllexport an already instantiated class template.
+template  struct Base {
+  int x = 42;
+};
+Base base;
+struct __declspec(dllexport) T : Base { };
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::Base"* @"\01??0?$Base@H@InClassInits@@QAE@XZ"
+
+struct A { A(int); };
+struct __declspec(dllexport) U {
+  // Class with both default constructor closure and in-class initializer.
+  U(A = 0) {}
+  int x = 0;
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::U"* @"\01??0U@InClassInits@@QAE@UA@1@@Z"
+
+struct Evil {
+  template  struct Base {
+int x = 0;
+  };
+  struct S : Base {};
+  // The already instantiated Base becomes dllexported below, but the
+  // in-class initializer for Base<>::x still hasn't been parsed, so emitting
+  // the default ctor must still be delayed.
+  struct __declspec(dllexport) T : Base {};
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %"struct.InClassInits::Evil::Base"* @"\01??0?$Base@H@Evil@InClassInits@@QAE@XZ"
+
+template  struct Foo {};
+template  struct Bar {
+  Bar &operator=(Foo) {}
+};
+struct __declspec(dllexport) Baz {
+  Bar n;
+};
+// After parsing Baz, in ActOnFinishCXXMemberDefaultArgs we would synthesize
+// Baz's operator=, causing instantiation of Foo after which
+// ActOnFinishCXXMemberDefaultArgs is called, and we would bite our own tail.
+// M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable(1) %"struct.InClassInits::Baz"* @"\01??4Baz@InClassInits@@QAEAAU01@ABU01@@Z"
+}
+
 
 //===--===//
 // Classes with template base classes
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -4682,6 +4682,60 @@
   }
 }
 
+static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class) {
+  Attr *ClassAttr = getDLLAttr(Class);
+  if (!ClassAttr)
+return;
+
+  assert(ClassAttr->getKind() == attr::DLLExport);
+
+  TemplateSpecializationKind TSK = Class->getTemplateSpecializationKind();
+
+  for (Decl *Member : Class->decls()) {
+auto *MD = dyn_cast(Member);
+if (!MD)
+  continue;
+
+if (Member->getAttr()) {
+  if (TSK == TSK_ExplicitInstantiationDeclaration)
+// Don't go any further if this is just an explicit instantiation
+// declaration.
+continue;
+
+  if (MD->isUserProvided()) {
+// Instantiate non-default class member functions ...
+
+// .. except for certain kinds of template specializations.
+if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
+  continue;
+
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+
+// The function will be passed to the consumer when its definition is
+// encountered.
+  } else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
+ MD->isCopyAssignmentOperator() ||
+ MD->isMoveAssignmentOperator()) {
+// Synthesize and instantiate non-trivial implicit methods, explicitly
+// defaulted methods, and the copy and move assignment operators. The
+// latter are exported even if they are trivial, because the address of
+// an operator can be taken and should compare equal accross libraries.
+DiagnosticErrorTrap Trap(S.Diags);
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+if (Trap.hasErrorOccurred()) {
+  S.Diag(ClassAttr->getLocation(), diag::note_due_to_dllexported_class)
+  << Class->getName() << !S.getLangOpts().CPlusPlus11;
+  break;
+}
+
+// There is no later point

r244386 - [analyzer] Don't issue alarm in ObjCSuperCallChecker for the super class itself.

2015-08-07 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Aug  7 20:31:51 2015
New Revision: 244386

URL: http://llvm.org/viewvc/llvm-project?rev=244386&view=rev
Log:
[analyzer] Don't issue alarm in ObjCSuperCallChecker for the super class itself.

The ObjCSuperCallChecker issues alarms for various Objective-C APIs that require
a subclass to call to its superclass's version of a method when overriding it.
So, for example, it raises an alarm when the -viewDidLoad method in a subclass
of UIViewController does not call [super viewDidLoad].

This patch fixes a false alarm where the analyzer erroneously required the
implementation of the superclass itself (e.g., UIViewController) to call
super.

rdar://problem/18416944

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
cfe/trunk/test/Analysis/superclass.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp?rev=244386&r1=244385&r2=244386&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp Fri 
Aug  7 20:31:51 2015
@@ -88,7 +88,7 @@ private:
 /// \param[out] SuperclassName On return, the found superclass name.
 bool ObjCSuperCallChecker::isCheckableClass(const ObjCImplementationDecl *D,
 StringRef &SuperclassName) const {
-  const ObjCInterfaceDecl *ID = D->getClassInterface();
+  const ObjCInterfaceDecl *ID = D->getClassInterface()->getSuperClass();
   for ( ; ID ; ID = ID->getSuperClass())
   {
 SuperclassName = ID->getIdentifier()->getName();

Modified: cfe/trunk/test/Analysis/superclass.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/superclass.m?rev=244386&r1=244385&r2=244386&view=diff
==
--- cfe/trunk/test/Analysis/superclass.m (original)
+++ cfe/trunk/test/Analysis/superclass.m Fri Aug  7 20:31:51 2015
@@ -30,7 +30,7 @@ typedef enum UIViewAnimationOptions {
 - (void)didReceiveMemoryWarning;
 - (void)removeFromParentViewController;
 - (void)transitionFromViewController:(UIViewController *)fromViewController
-  toViewController:(UIViewController *)toViewController 
+  toViewController:(UIViewController *)toViewController
   duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
   animations:(void (^)(void))animations
   completion:(void (^)(BOOL finished))completion;
@@ -69,6 +69,25 @@ typedef enum UIViewAnimationOptions {
 - (void)encodeRestorableStateWithCoder:(NSCoder *)coder {}
 @end
 
+// Do not warn for the implementation in the superclass itself.
+@implementation UIViewController
+- (void)addChildViewController:(UIViewController *)childController {}
+- (void)viewDidAppear:(BOOL)animated {}
+- (void)viewDidDisappear:(BOOL)animated {}
+- (void)viewDidUnload {}
+- (void)viewDidLoad {}
+- (void)viewWillUnload {}
+- (void)viewWillAppear:(BOOL)animated {}
+- (void)viewWillDisappear:(BOOL)animated {}
+- (void)didReceiveMemoryWarning {}
+- (void)removeFromParentViewController {}
+- (void)transitionFromViewController:(UIViewController *)fromViewController
+  toViewController:(UIViewController *)toViewController
+  duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
+  animations:(void (^)(void))animations
+  completion:(void (^)(BOOL finished))completion {}
+@end
+
 // Warn if UIViewController is our superclass and we do not call super
 @interface TestB : UIViewController {}
 @end


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


Re: [PATCH] D11572: [Static Analyzer] Checker for OS X / iOS localizability issues

2015-08-07 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Committed in r244389.
Thank you!


http://reviews.llvm.org/D11572



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


[PATCH] D11859: Generating vptr assume loads

2015-08-07 Thread Piotr Padlewski via cfe-commits
Prazek created this revision.
Prazek added reviewers: rsmith, majnemer.
Prazek added a subscriber: cfe-commits.

Generating vptr assumption loads for better devirtualization.

More here: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

http://reviews.llvm.org/D11859

Files:
  include/clang/AST/VTableBuilder.h
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGen/available-externally-hidden.cpp
  test/CodeGenCXX/ctor-globalopt.cpp
  test/CodeGenCXX/template-instantiation.cpp
  test/CodeGenCXX/thunks.cpp
  test/CodeGenCXX/virtual-base-ctor.cpp
  test/CodeGenCXX/vtable-assume-load.cpp
  test/CodeGenCXX/vtable-available-externally.cpp

Index: test/CodeGenCXX/vtable-available-externally.cpp
===
--- test/CodeGenCXX/vtable-available-externally.cpp
+++ test/CodeGenCXX/vtable-available-externally.cpp
@@ -182,8 +182,8 @@
 namespace Test9 {
 // all virtual functions are outline, so we can assume that it will
 // be generated in translation unit where foo is defined
-// CHECK-TEST9: @_ZTVN5Test91AE = available_externally unnamed_addr constant
-// CHECK-TEST9: @_ZTVN5Test91BE = available_externally unnamed_addr constant
+// CHECK-TEST9-DAG: @_ZTVN5Test91AE = available_externally unnamed_addr constant
+// CHECK-TEST9-DAG: @_ZTVN5Test91BE = available_externally unnamed_addr constant
 struct A {
   virtual void foo();
   virtual void bar();
@@ -206,39 +206,39 @@
 namespace Test10 {
 
 // because A's key function is defined here, vtable is generated in this TU
-// CHECK-TEST10: @_ZTVN6Test101AE = unnamed_addr constant
+// CHECK-TEST10-DAG: @_ZTVN6Test101AE = unnamed_addr constant
 struct A {
   virtual void foo();
   virtual void bar();
 };
 void A::foo() {}
 
 // Because key function is inline we will generate vtable as linkonce_odr
-// CHECK-TEST10: @_ZTVN6Test101DE = linkonce_odr unnamed_addr constant
+// CHECK-TEST10-DAG: @_ZTVN6Test101DE = linkonce_odr unnamed_addr constant
 struct D : A {
   void bar();
 };
 inline void D::bar() {}
 
 // because B has outline key function then we can refer to
-// CHECK-TEST10: @_ZTVN6Test101BE = available_externally unnamed_addr constant
+// CHECK-TEST10-DAG: @_ZTVN6Test101BE = available_externally unnamed_addr constant
 struct B : A {
   void foo();
   void bar();
 };
 
 // C's key function (car) is outline, but C has inline virtual function so we
 // can't guarantee that we will be able to refer to bar from name
 // so (at the moment) we can't emit vtable available_externally
-// CHECK-TEST10: @_ZTVN6Test101CE = external unnamed_addr constant
+// CHECK-TEST10-DAG: @_ZTVN6Test101CE = external unnamed_addr constant
 struct C : A {
   void bar() {}   // defined in body - not key function
   virtual inline void gar();  // inline in body - not key function
   virtual void car();
 };
 
 // no key function, vtable will be generated everywhere it will be used
-// CHECK-TEST10: @_ZTVN6Test101EE = linkonce_odr unnamed_addr constant
+// CHECK-TEST10-DAG: @_ZTVN6Test101EE = linkonce_odr unnamed_addr constant
 struct E : A {};
 
 void g(A& a) {
Index: test/CodeGenCXX/vtable-assume-load.cpp
===
--- /dev/null
+++ test/CodeGenCXX/vtable-assume-load.cpp
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions
+
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK3 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK-MS --input-file=%t.ms.ll %s
+
+namespace test1 {
+
+struct A {
+  A();
+  virtual void foo();
+};
+
+struct B : A {
+  virtual void foo();
+};
+
+void g(A* a) { a->foo(); }
+
+void fooA() {
+  A a;
+  g(&a);
+}
+void fooB() {
+  B b;
+  g(&b);
+}
+// CHECK1-LABEL: define void @_ZN5test14fooAEv()
+// CHECK1: %cmp.vtables = icmp eq i8** %vtable, getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11AE, i64 0, i64 2)
+// CHECK1: call void @llvm.assume(i1 %cmp.vtables)
+// CHECK1-LABEL: }
+
+// CHECK1-LABEL: define void @_ZN5test14fooBEv()
+// CHECK1: call void @_ZN5test11BC1Ev(%"struct.test1::B"* %b)
+// CHECK1: %vtable = load i8**, i8*** %1, !tbaa !5
+// CHECK1: %cmp.vtables = icmp eq i8** %vtable, getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11BE, i64 0, i64 2)
+// CHECK1: call void @llvm.assume(i1 %cmp.vtables)
+// CHECK1-LABLE: }
+
+// there should not be any assumes in the ctor that calls base ctor
+// CHECK1-LABEL: define linkonce_odr void @_ZN5test11BC2Ev(%"struct.test1::B"* %this)
+// CHECK1-NOT: @llvm.assume(
+// CHECK1-LABEL: }
+}
+namespace 

Re: [PATCH] D10225: [Static Analyzer] Remove ObjCContainersChecker size information when a CFMutableArrayRef escapes

2015-08-07 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

This was committed in r239709.


http://reviews.llvm.org/D10225



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


Re: r244389 - [analyzer] Add checkers for OS X / iOS localizability issues

2015-08-07 Thread Chandler Carruth via cfe-commits
Note that this is still failing on bots even after the windows fix:

http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24169

On Fri, Aug 7, 2015 at 6:50 PM Anna Zaks via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: zaks
> Date: Fri Aug  7 20:49:26 2015
> New Revision: 244389
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244389&view=rev
> Log:
> [analyzer] Add checkers for OS X / iOS localizability issues
>
> Add checkers that detect code-level localizability issues for OS X / iOS:
>  - A path sensitive checker that warns about uses of non-localized
>  NSStrings passed to UI methods expecting localized strings.
>  - A syntax checker that warns against not including a comment in
>  NSLocalizedString macros.
>
> A patch by Kulpreet Chilana!
>
> Added:
> cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
> cfe/trunk/test/Analysis/localization-aggressive.m
> cfe/trunk/test/Analysis/localization.m
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
> cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=244389&r1=244388&r2=244389&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri Aug  7
> 20:49:26 2015
> @@ -39,6 +39,7 @@ add_clang_library(clangStaticAnalyzerChe
>IdenticalExprChecker.cpp
>IvarInvalidationChecker.cpp
>LLVMConventionsChecker.cpp
> +  LocalizationChecker.cpp
>MacOSKeychainAPIChecker.cpp
>MacOSXAPIChecker.cpp
>MallocChecker.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=244389&r1=244388&r2=244389&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Fri Aug  7 20:49:26
> 2015
> @@ -452,6 +452,14 @@ def DirectIvarAssignmentForAnnotatedFunc
>HelpText<"Check for direct assignments to instance variables in the
> methods annotated with objc_no_direct_instance_variable_assignment">,
>DescFile<"DirectIvarAssignment.cpp">;
>
> +def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
> +  HelpText<"Warns about uses of non-localized NSStrings passed to UI
> methods expecting localized NSStrings">,
> +  DescFile<"LocalizationChecker.cpp">;
> +
> +def EmptyLocalizationContextChecker :
> Checker<"EmptyLocalizationContextChecker">,
> +  HelpText<"Check that NSLocalizedString macros include a comment for
> context">,
> +  DescFile<"LocalizationChecker.cpp">;
> +
>  } // end "alpha.osx.cocoa"
>
>  let ParentPackage = CoreFoundation in {
>
> Added: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=244389&view=auto
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (added)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Fri Aug
> 7 20:49:26 2015
> @@ -0,0 +1,559 @@
> +//=- LocalizationChecker.cpp -*- 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 a set of checks for localizability including:
> +//  1) A checker that warns about uses of non-localized NSStrings passed
> to
> +// UI methods expecting localized strings
> +//  2) A syntactic checker that warns against the bad practice of
> +// not including a comment in NSLocalizedString macros.
> +//
>
> +//===--===//
> +
> +#include "ClangSACheckers.h"
> +#include "SelectorExtras.h"
> +#include "clang/AST/Attr.h"
> +#include "clang/AST/Decl.h"
> +#include "clang/AST/DeclObjC.h"
> +#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
> +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
> +#include "clang/StaticAnalyzer/Core/Checker.h"
> +#include "clang/StaticAnalyzer/Core/CheckerManager.h"
> +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
> +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
> +#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
> +#include "clang/Lex/Lexer.h"
> +#include "clang/AST/RecursiveASTVisitor.h"
> +#include "clang/AST/St

r244394 - Revert "[analyzer] Add checkers for OS X / iOS localizability issues"

2015-08-07 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Fri Aug  7 23:53:04 2015
New Revision: 244394

URL: http://llvm.org/viewvc/llvm-project?rev=244394&view=rev
Log:
Revert "[analyzer] Add checkers for OS X / iOS localizability issues"

This reverts commit fc885033a30b6e30ccf82398ae7c30e646727b10.

Revert all localization checker commits until the proper fix is implemented.

Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/test/Analysis/localization-aggressive.m
cfe/trunk/test/Analysis/localization.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=244394&r1=244393&r2=244394&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri Aug  7 23:53:04 
2015
@@ -39,7 +39,6 @@ add_clang_library(clangStaticAnalyzerChe
   IdenticalExprChecker.cpp
   IvarInvalidationChecker.cpp
   LLVMConventionsChecker.cpp
-  LocalizationChecker.cpp
   MacOSKeychainAPIChecker.cpp
   MacOSXAPIChecker.cpp
   MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=244394&r1=244393&r2=244394&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Fri Aug  7 23:53:04 2015
@@ -452,14 +452,6 @@ def DirectIvarAssignmentForAnnotatedFunc
   HelpText<"Check for direct assignments to instance variables in the methods 
annotated with objc_no_direct_instance_variable_assignment">,
   DescFile<"DirectIvarAssignment.cpp">;
 
-def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
-  HelpText<"Warns about uses of non-localized NSStrings passed to UI methods 
expecting localized NSStrings">,
-  DescFile<"LocalizationChecker.cpp">;
-
-def EmptyLocalizationContextChecker : 
Checker<"EmptyLocalizationContextChecker">,
-  HelpText<"Check that NSLocalizedString macros include a comment for 
context">,
-  DescFile<"LocalizationChecker.cpp">;
-
 } // end "alpha.osx.cocoa"
 
 let ParentPackage = CoreFoundation in {

Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=244393&view=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (removed)
@@ -1,559 +0,0 @@
-//=- LocalizationChecker.cpp -*- 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 a set of checks for localizability including:
-//  1) A checker that warns about uses of non-localized NSStrings passed to
-// UI methods expecting localized strings
-//  2) A syntactic checker that warns against the bad practice of
-// not including a comment in NSLocalizedString macros.
-//
-//===--===//
-
-#include "ClangSACheckers.h"
-#include "SelectorExtras.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
-#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
-#include "clang/StaticAnalyzer/Core/Checker.h"
-#include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/AST/RecursiveASTVisitor.h"
-#include "clang/AST/StmtVisitor.h"
-#include "llvm/Support/Unicode.h"
-
-using namespace clang;
-using namespace ento;
-
-namespace {
-struct LocalizedState {
-private:
-  enum Kind { NonLocalized, Localized } K;
-  LocalizedState(Kind InK) : K(InK) {}
-
-public:
-  bool isLocalized() const { return K == Localized; }
-  bool isNonLocalized() const { return K == NonLocalized; }
-
-  static LocalizedState getLocalized() { return LocalizedState(Localized); }
-  static LocalizedState getNonLocalized() {
-return LocalizedState(NonLocalized);
-  }
-
-  // Overload the == operator
-  bool operator==(const LocalizedState &X) const { return K == X.K

Re: r244389 - [analyzer] Add checkers for OS X / iOS localizability issues

2015-08-07 Thread Anna Zaks via cfe-commits
Sorry about the breakage! I’ve reverted the commit in r244394.

Anna.

> On Aug 7, 2015, at 9:08 PM, Chandler Carruth  wrote:
> 
> Note that this is still failing on bots even after the windows fix:
> 
> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24169 
> 
> 
> On Fri, Aug 7, 2015 at 6:50 PM Anna Zaks via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: zaks
> Date: Fri Aug  7 20:49:26 2015
> New Revision: 244389
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=244389&view=rev 
> 
> Log:
> [analyzer] Add checkers for OS X / iOS localizability issues
> 
> Add checkers that detect code-level localizability issues for OS X / iOS:
>  - A path sensitive checker that warns about uses of non-localized
>  NSStrings passed to UI methods expecting localized strings.
>  - A syntax checker that warns against not including a comment in
>  NSLocalizedString macros.
> 
> A patch by Kulpreet Chilana!
> 
> Added:
> cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
> cfe/trunk/test/Analysis/localization-aggressive.m
> cfe/trunk/test/Analysis/localization.m
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
> cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
> 
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=244389&r1=244388&r2=244389&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri Aug  7 20:49:26 
> 2015
> @@ -39,6 +39,7 @@ add_clang_library(clangStaticAnalyzerChe
>IdenticalExprChecker.cpp
>IvarInvalidationChecker.cpp
>LLVMConventionsChecker.cpp
> +  LocalizationChecker.cpp
>MacOSKeychainAPIChecker.cpp
>MacOSXAPIChecker.cpp
>MallocChecker.cpp
> 
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=244389&r1=244388&r2=244389&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Fri Aug  7 20:49:26 2015
> @@ -452,6 +452,14 @@ def DirectIvarAssignmentForAnnotatedFunc
>HelpText<"Check for direct assignments to instance variables in the 
> methods annotated with objc_no_direct_instance_variable_assignment">,
>DescFile<"DirectIvarAssignment.cpp">;
> 
> +def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
> +  HelpText<"Warns about uses of non-localized NSStrings passed to UI methods 
> expecting localized NSStrings">,
> +  DescFile<"LocalizationChecker.cpp">;
> +
> +def EmptyLocalizationContextChecker : 
> Checker<"EmptyLocalizationContextChecker">,
> +  HelpText<"Check that NSLocalizedString macros include a comment for 
> context">,
> +  DescFile<"LocalizationChecker.cpp">;
> +
>  } // end "alpha.osx.cocoa"
> 
>  let ParentPackage = CoreFoundation in {
> 
> Added: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=244389&view=auto
>  
> 
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (added)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Fri Aug  7 
> 20:49:26 2015
> @@ -0,0 +1,559 @@
> +//=- LocalizationChecker.cpp -*- 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 a set of checks for localizability including:
> +//  1) A checker that warns about uses of non-localized NSStrings passed to
> +// UI methods expecting localized strings
> +//  2) A syntactic checker that warns against the bad practice of
> +// not including a comment in NSLocalizedString macros.
> +//
> +//===--===//
> +
> +#inclu

Re: r244389 - [analyzer] Add checkers for OS X / iOS localizability issues

2015-08-07 Thread Chandler Carruth via cfe-commits
NP, thanks for the quick fixes!

On Fri, Aug 7, 2015 at 9:56 PM Anna Zaks  wrote:

> Sorry about the breakage! I’ve reverted the commit in r244394.
>
> Anna.
>
> On Aug 7, 2015, at 9:08 PM, Chandler Carruth  wrote:
>
> Note that this is still failing on bots even after the windows fix:
>
> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24169
>
> On Fri, Aug 7, 2015 at 6:50 PM Anna Zaks via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: zaks
>> Date: Fri Aug  7 20:49:26 2015
>> New Revision: 244389
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=244389&view=rev
>> Log:
>> [analyzer] Add checkers for OS X / iOS localizability issues
>>
>> Add checkers that detect code-level localizability issues for OS X / iOS:
>>  - A path sensitive checker that warns about uses of non-localized
>>  NSStrings passed to UI methods expecting localized strings.
>>  - A syntax checker that warns against not including a comment in
>>  NSLocalizedString macros.
>>
>> A patch by Kulpreet Chilana!
>>
>> Added:
>> cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
>> cfe/trunk/test/Analysis/localization-aggressive.m
>> cfe/trunk/test/Analysis/localization.m
>> Modified:
>> cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
>> cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=244389&r1=244388&r2=244389&view=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri Aug  7
>> 20:49:26 2015
>> @@ -39,6 +39,7 @@ add_clang_library(clangStaticAnalyzerChe
>>IdenticalExprChecker.cpp
>>IvarInvalidationChecker.cpp
>>LLVMConventionsChecker.cpp
>> +  LocalizationChecker.cpp
>>MacOSKeychainAPIChecker.cpp
>>MacOSXAPIChecker.cpp
>>MallocChecker.cpp
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=244389&r1=244388&r2=244389&view=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Fri Aug  7 20:49:26
>> 2015
>> @@ -452,6 +452,14 @@ def DirectIvarAssignmentForAnnotatedFunc
>>HelpText<"Check for direct assignments to instance variables in the
>> methods annotated with objc_no_direct_instance_variable_assignment">,
>>DescFile<"DirectIvarAssignment.cpp">;
>>
>> +def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
>> +  HelpText<"Warns about uses of non-localized NSStrings passed to UI
>> methods expecting localized NSStrings">,
>> +  DescFile<"LocalizationChecker.cpp">;
>> +
>> +def EmptyLocalizationContextChecker :
>> Checker<"EmptyLocalizationContextChecker">,
>> +  HelpText<"Check that NSLocalizedString macros include a comment for
>> context">,
>> +  DescFile<"LocalizationChecker.cpp">;
>> +
>>  } // end "alpha.osx.cocoa"
>>
>>  let ParentPackage = CoreFoundation in {
>>
>> Added: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=244389&view=auto
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (added)
>> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Fri
>> Aug  7 20:49:26 2015
>> @@ -0,0 +1,559 @@
>> +//=- LocalizationChecker.cpp -*- 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 a set of checks for localizability including:
>> +//  1) A checker that warns about uses of non-localized NSStrings passed
>> to
>> +// UI methods expecting localized strings
>> +//  2) A syntactic checker that warns against the bad practice of
>> +// not including a comment in NSLocalizedString macros.
>> +//
>>
>> +//===--===//
>> +
>> +#include "ClangSACheckers.h"
>> +#include "SelectorExtras.h"
>> +#include "clang/AST/Attr.h"
>> +#include "clang/AST/Decl.h"
>> +#include "clang/AST/DeclObjC.h"
>> +#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
>> +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
>> +#include "clang/StaticAnalyzer/Core/Checker.h"
>> +#include "clang/StaticAn

Re: [PATCH] D10356: scan-build: Add --analyzer-target option

2015-08-07 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment.

In http://reviews.llvm.org/D10356#219499, @krememek wrote:

> I see.  The problem is that the ad hoc interposition that scan-build uses 
> does not handle the case that the underlying compiler is built as a 
> cross-compiler, but does not take a direct target triple.  That compiler only 
> builds for the other target, unlike clang which is a cross-compiler.


That's exactly what I was going to explain.  I hope that scan-build can 
automatically extract the target triple information from the given compiler, 
but there's no way to do it as of yet.  That's the reason I made this option to 
explicitly set the target triple info for analysis.

> In that case, I am fine with taking this change.  That you for explaining it.


Thanks for the review and comments. If you want to change the option name, 
--analyzer-target, I'm okay to change it. And I would also like to hear some 
feedback about the description for the option as well.
So please let me know if you have any other idea on that. I appreciate your 
help.


http://reviews.llvm.org/D10356



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


Re: [PATCH] D11459: [Driver] Fix handling of -fbuiltin/-fcommon when combined with -mkernel

2015-08-07 Thread Justin Bogner via cfe-commits
(resending with the list address fixed)

John Brawn  writes:
> john.brawn created this revision.
> john.brawn added reviewers: ddunbar, mcrosier.
> john.brawn added a subscriber: cfe-commits.
> john.brawn set the repository for this revision to rL LLVM.
>
> -mkernel enables -fno-builtin and -fno-common by default, but allows
> -fbuiltin and -fcommon to override that. However "-fbuiltin
> -fno-builtin" is treated the same as "-fbuiltin" which is wrong, so
> fix that. Also fixes similar behaviour when -fno-common is default.
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D11459
>
> Files:
>   lib/Driver/Tools.cpp
>   test/Driver/apple-kext-mkernel.c
>
> Index: test/Driver/apple-kext-mkernel.c
> ===
> --- test/Driver/apple-kext-mkernel.c
> +++ test/Driver/apple-kext-mkernel.c
> @@ -1,15 +1,13 @@
> -// RUN: %clang -target x86_64-apple-darwin10 \
> -// RUN:   -mkernel -### -fsyntax-only %s 2> %t
> -// RUN: FileCheck --check-prefix=CHECK-X86 < %t %s
> +// RUN: %clang -target x86_64-apple-darwin10 -mkernel -### -fsyntax-only %s 
> 2>&1 | FileCheck --check-prefix=CHECK-X86 %s
> +// RUN: %clang -target x86_64-apple-darwin10 -mkernel -### -fsyntax-only 
> -fbuiltin -fno-builtin -fcommon -fno-common %s 2>&1 | FileCheck 
> --check-prefix=CHECK-X86 %s

Please also test the -mkernel -fbuiltin -fcommon case, but otherwise LGTM.

>  
>  // CHECK-X86: "-disable-red-zone"
>  // CHECK-X86: "-fno-builtin"
>  // CHECK-X86: "-fno-rtti"
>  // CHECK-X86: "-fno-common"
>  
> -// RUN: %clang -target x86_64-apple-darwin10 \
> -// RUN:   -arch armv7 -mkernel -mstrict-align -### -fsyntax-only %s 2> %t
> -// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
> +// RUN: %clang -target x86_64-apple-darwin10 -arch armv7 -mkernel 
> -mstrict-align -### -fsyntax-only %s 2>&1 | FileCheck 
> --check-prefix=CHECK-ARM %s
> +// RUN: %clang -target x86_64-apple-darwin10 -arch armv7 -mkernel 
> -mstrict-align -### -fsyntax-only -fbuiltin -fno-builtin -fcommon -fno-common 
> %s 2>&1 | FileCheck --check-prefix=CHECK-ARM %s
>  
>  // CHECK-ARM: "-target-feature" "+long-calls"
>  // CHECK-ARM: "-backend-option" "-arm-strict-align"
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -4013,7 +4013,8 @@
>  options::OPT_fno_lax_vector_conversions))
>  CmdArgs.push_back("-fno-lax-vector-conversions");
>  
> -  if (Args.getLastArg(options::OPT_fapple_kext))
> +  if (Args.getLastArg(options::OPT_fapple_kext) ||
> +  (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
>  CmdArgs.push_back("-fapple-kext");
>  
>Args.AddLastArg(CmdArgs, options::OPT_fobjc_sender_dependent_dispatch);
> @@ -4147,15 +4148,9 @@
>A->render(Args, CmdArgs);
>}
>  
> -  if (Args.hasArg(options::OPT_mkernel)) {
> -if (!Args.hasArg(options::OPT_fapple_kext) && types::isCXX(InputType))
> -  CmdArgs.push_back("-fapple-kext");
> -if (!Args.hasArg(options::OPT_fbuiltin))
> -  CmdArgs.push_back("-fno-builtin");
> -Args.ClaimAllArgs(options::OPT_fno_builtin);
> -  }
> -  // -fbuiltin is default.
> -  else if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin))
> +  // -fbuiltin is default unless -mkernel is used
> +  if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin,
> +!Args.hasArg(options::OPT_mkernel)))
>  CmdArgs.push_back("-fno-builtin");
>  
>if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
> @@ -4556,14 +4551,11 @@
>  }
>}
>  
> -  if (KernelOrKext || isNoCommonDefault(getToolChain().getTriple())) {
> -if (!Args.hasArg(options::OPT_fcommon))
> -  CmdArgs.push_back("-fno-common");
> -Args.ClaimAllArgs(options::OPT_fno_common);
> -  }
> -
> -  // -fcommon is default, only pass non-default.
> -  else if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common))
> +  // -fcommon is the default unless compiling kernel code or the target says 
> so
> +  bool NoCommonDefault =
> +  KernelOrKext || isNoCommonDefault(getToolChain().getTriple());
> +  if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common,
> +!NoCommonDefault))
>  CmdArgs.push_back("-fno-common");
>  
>// -fsigned-bitfields is default, and clang doesn't yet support
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits