[Lldb-commits] [PATCH] Fix type detection for 'char' variables

Greg Clayton clayborg at gmail.com
Fri Mar 27 10:17:03 PDT 2015


It seems like all of the code in LanguageOptions could just be a method on ArchSpec instead of adding a new file since this is really just switching off of a triple?


================
Comment at: lldb.xcodeproj/project.pbxproj:749
@@ -748,2 +748,3 @@
 		6D55BAF01A8CD0BD00A70529 /* PlatformAndroidRemoteGDBServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D55BAEC1A8CD08C00A70529 /* PlatformAndroidRemoteGDBServer.h */; };
+		6DA349C81AC5BFA700E845E2 /* LanguageOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DA349C61AC5BFA700E845E2 /* LanguageOptions.cpp */; };
 		8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */; };
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: lldb.xcodeproj/project.pbxproj:2378-2379
@@ -2376,2 +2377,4 @@
 		6D55BAEC1A8CD08C00A70529 /* PlatformAndroidRemoteGDBServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformAndroidRemoteGDBServer.h; sourceTree = "<group>"; };
+		6DA349C61AC5BFA700E845E2 /* LanguageOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LanguageOptions.cpp; path = source/Utility/LanguageOptions.cpp; sourceTree = "<group>"; };
+		6DA349C71AC5BFA700E845E2 /* LanguageOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LanguageOptions.h; path = source/Utility/LanguageOptions.h; sourceTree = "<group>"; };
 		8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MemoryHistory.cpp; path = source/Target/MemoryHistory.cpp; sourceTree = "<group>"; };
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: lldb.xcodeproj/project.pbxproj:3476-3478
@@ -3472,3 +3475,5 @@
 			isa = PBXGroup;
 			children = (
+				6DA349C61AC5BFA700E845E2 /* LanguageOptions.cpp */,
+				6DA349C71AC5BFA700E845E2 /* LanguageOptions.h */,
 				257E47151AA56C2000A62F81 /* ModuleCache.cpp */,
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: lldb.xcodeproj/project.pbxproj:6319
@@ -6313,2 +6318,3 @@
 				494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */,
+				6DA349C81AC5BFA700E845E2 /* LanguageOptions.cpp in Sources */,
 				49DA65031485C92A005FF180 /* AppleObjCDeclVendor.cpp in Sources */,
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: source/Expression/ClangExpressionParser.cpp:73-74
@@ -72,2 +72,4 @@
 
+#include "Utility/LanguageOptions.h"
+
 using namespace clang;
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: source/Expression/ClangExpressionParser.cpp:233-234
@@ -230,1 +232,4 @@
 
+    m_compiler->getLangOpts().CharIsSigned = LanguageOptions::CharIsSignedForTriple(
+            m_compiler->getTargetOpts().Triple.c_str());
+
----------------
```
m_compiler->getLangOpts().CharIsSigned = ArchSpec(m_compiler->getTargetOpts().Triple.c_str()).CharIsSigned();
```

================
Comment at: source/Symbol/ClangASTContext.cpp:75-76
@@ -74,2 +74,4 @@
 
+#include "Utility/LanguageOptions.h"
+
 #include <stdio.h>
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: source/Symbol/ClangASTContext.cpp:235
@@ -237,3 +234,3 @@
 //    Opts.Blocks = Args.hasArg(OPT_fblocks);
-//    Opts.CharIsSigned = !Args.hasArg(OPT_fno_signed_char);
+      Opts.CharIsSigned = LanguageOptions::CharIsSignedForTriple(triple);
 //    Opts.ShortWChar = Args.hasArg(OPT_fshort_wchar);
----------------
This would become:


```
ArchSpec arch(triple);
Opts.CharIsSigned = arch.CharIsSigned();

```

================
Comment at: source/Utility/CMakeLists.txt:9
@@ -8,2 +8,3 @@
   KQueue.cpp
+  LanguageOptions.cpp
   LLDBAssert.cpp
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: source/Utility/LanguageOptions.cpp:1-43
@@ +1,43 @@
+//===-- LanguageOptions.cpp -------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LanguageOptions.h"
+
+#include "llvm/ADT/Triple.h"
+
+using namespace lldb_private;
+using namespace llvm;
+
+bool
+LanguageOptions::CharIsSignedForTriple(const char* triple_name)
+{
+    Triple triple (triple_name);
+
+    switch (triple.getArch()) {
+    default:
+        return true;
+
+    case llvm::Triple::aarch64:
+    case llvm::Triple::aarch64_be:
+    case llvm::Triple::arm:
+    case llvm::Triple::armeb:
+    case llvm::Triple::thumb:
+    case llvm::Triple::thumbeb:
+        return triple.isOSDarwin() || triple.isOSWindows();
+
+    case llvm::Triple::ppc:
+    case llvm::Triple::ppc64:
+        return triple.isOSDarwin();
+
+    case llvm::Triple::ppc64le:
+    case llvm::Triple::systemz:
+    case llvm::Triple::xcore:
+        return false;
+    }
+}
----------------
Remove this and just add a method to lldb_private::ArchSpec.

================
Comment at: source/Utility/LanguageOptions.h:1-23
@@ +1,23 @@
+//===-- LanguageOptions.h ---------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb_private
+{
+
+class LanguageOptions
+{
+public:
+    static bool
+    CharIsSignedForTriple(const char* triple_name);
+
+private:
+    LanguageOptions() = delete;
+};
+
+} // namespace lldb_private
----------------
Remove this and just add a method to lldb_private::ArchSpec.

http://reviews.llvm.org/D8636

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list