if (CI.getLangOpts().ObjCRuntime.isNonFragile())
return CreateModernObjCRewriter(InFile, OS,
CI.getDiagnostics(), CI.getLangOpts(),
- CI.getDiagnosticOpts().NoRewriteMacros);
+ CI.getDiagnosticOpts().NoRewriteMacros,
+ (CI.getCodeGenOpts().getDebugInfo() !=
+ CodeGenOptions::NoDebugInfo));
return CreateObjCRewriter(InFile, OS,
CI.getDiagnostics(), CI.getLangOpts(),
CI.getDiagnosticOpts().NoRewriteMacros);
// Needed for header files being rewritten
bool IsHeader;
bool SilenceRewriteMacroWarning;
+ bool GenerateLineInfo;
bool objc_impl_method;
bool DisableReplaceStmt;
void HandleDeclInMainFile(Decl *D);
RewriteModernObjC(std::string inFile, raw_ostream *OS,
DiagnosticsEngine &D, const LangOptions &LOpts,
- bool silenceMacroWarn);
+ bool silenceMacroWarn, bool LineInfo);
~RewriteModernObjC() {}
RewriteModernObjC::RewriteModernObjC(std::string inFile, raw_ostream* OS,
DiagnosticsEngine &D, const LangOptions &LOpts,
- bool silenceMacroWarn)
+ bool silenceMacroWarn,
+ bool LineInfo)
: Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
- SilenceRewriteMacroWarning(silenceMacroWarn) {
+ SilenceRewriteMacroWarning(silenceMacroWarn), GenerateLineInfo(LineInfo) {
IsHeader = IsHeaderFile(inFile);
RewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
"rewriting sub-expression within a macro (may not be correct)");
raw_ostream* OS,
DiagnosticsEngine &Diags,
const LangOptions &LOpts,
- bool SilenceRewriteMacroWarning) {
- return new RewriteModernObjC(InFile, OS, Diags, LOpts, SilenceRewriteMacroWarning);
+ bool SilenceRewriteMacroWarning,
+ bool LineInfo) {
+ return new RewriteModernObjC(InFile, OS, Diags, LOpts,
+ SilenceRewriteMacroWarning, LineInfo);
}
void RewriteModernObjC::InitializeCommon(ASTContext &context) {
void RewriteModernObjC::ConvertSourceLocationToLineDirective(
SourceLocation Loc,
std::string &LineString) {
- if (Loc.isFileID()) {
+ if (Loc.isFileID() && GenerateLineInfo) {
LineString += "\n#line ";
PresumedLoc PLoc = SM->getPresumedLoc(Loc);
LineString += utostr(PLoc.getLine());
SourceLocation Location = D->getLocation();
- if (Location.isFileID()) {
+ if (Location.isFileID() && GenerateLineInfo) {
std::string LineString("\n#line ");
PresumedLoc PLoc = SM->getPresumedLoc(Location);
LineString += utostr(PLoc.getLine());
--- /dev/null
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -g %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LINE --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc %t.mm -o %t-rwnog.cpp
+// RUN: FileCheck -check-prefix NOLINE --input-file=%t-rwnog.cpp %s
+// rdar://13138170
+
+__attribute__((objc_root_class)) @interface MyObject {
+@public
+ id _myMaster;
+ id _isTickledPink;
+}
+@property(retain) id myMaster;
+@property(assign) id isTickledPink;
+@end
+
+@implementation MyObject
+
+@synthesize myMaster = _myMaster;
+@synthesize isTickledPink = _isTickledPink;
+
+- (void) doSomething {
+ _myMaster = _isTickledPink;
+}
+
+@end
+
+MyObject * foo ()
+{
+ MyObject* p;
+ p.isTickledPink = p.myMaster; // ok
+ p->_isTickledPink = p->_myMaster;
+ return p->_isTickledPink;
+}
+
+// CHECK-LINE: #line 22
+// CHECK-LINE: #line 28
+// CHECK-NOLINE-NOT: #line 22
+// CHECK-NOLINE-NOT: #line 28
+